Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'coresight-next-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-next

Suzuki writes:

coresigh: Updates for v6.6

Coresight and hwtracing subsystem updates for Linux v6.6 includes:

- ACPI support for CoreSight ETMv4x via system instructions and Arm ETE (v9.x).
- Fix potential sleeping in atomic context for TRBE driver
- Fix memory leak in ACPI platform parsing code
- Fix all warnings with W=1
- Fix warning with double free attempt for TRBE platform data
- Miscellaneous cleanups and fixes

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

* tag 'coresight-next-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux:
coresight: trbe: Fix TRBE potential sleep in atomic context
coresight: Fix memory leak in acpi_buffer->pointer
coresight: etm4x: Ensure valid drvdata and clock before clk_put()
coresight: trbe: Allocate platform data per device
hwtracing: hisi_ptt: Use pci_dev_id() to simplify the code
coresight: dummy: simplify the code with module_platform_driver
coresight: tmc: Explicit type conversions to prevent integer overflow
coresight: trbe: Directly use ID_AA64DFR0_EL1_TraceBuffer_IMP
coresight: Fix all W=1 build warnings
coresight: etm4x: Add ACPI support in platform driver
coresight: platform: acpi: Ignore the absence of graph
coresight: etm4x: Change etm4_platform_driver driver for MMIO devices
coresight: etm4x: Drop pid argument from etm4_probe()
coresight: etm4x: Drop iomem 'base' argument from etm4_probe()
coresight: etm4x: Allocate and device assign 'struct etmv4_drvdata' earlier
hwtracing: coresight: Explicitly include correct DT includes

+225 -85
-1
drivers/acpi/acpi_amba.c
··· 22 22 static const struct acpi_device_id amba_id_list[] = { 23 23 {"ARMH0061", 0}, /* PL061 GPIO Device */ 24 24 {"ARMH0330", 0}, /* ARM DMA Controller DMA-330 */ 25 - {"ARMHC500", 0}, /* ARM CoreSight ETM4x */ 26 25 {"ARMHC501", 0}, /* ARM CoreSight ETR */ 27 26 {"ARMHC502", 0}, /* ARM CoreSight STM */ 28 27 {"ARMHC503", 0}, /* ARM CoreSight Debug */
+1 -1
drivers/hwtracing/coresight/coresight-core.c
··· 17 17 #include <linux/mutex.h> 18 18 #include <linux/clk.h> 19 19 #include <linux/coresight.h> 20 - #include <linux/of_platform.h> 20 + #include <linux/property.h> 21 21 #include <linux/delay.h> 22 22 #include <linux/pm_runtime.h> 23 23
+1 -1
drivers/hwtracing/coresight/coresight-cti-core.c
··· 22 22 #include "coresight-priv.h" 23 23 #include "coresight-cti.h" 24 24 25 - /** 25 + /* 26 26 * CTI devices can be associated with a PE, or be connected to CoreSight 27 27 * hardware. We have a list of all CTIs irrespective of CPU bound or 28 28 * otherwise.
+1 -11
drivers/hwtracing/coresight/coresight-dummy.c
··· 147 147 }, 148 148 }; 149 149 150 - static int __init dummy_init(void) 151 - { 152 - return platform_driver_register(&dummy_driver); 153 - } 154 - module_init(dummy_init); 155 - 156 - static void __exit dummy_exit(void) 157 - { 158 - platform_driver_unregister(&dummy_driver); 159 - } 160 - module_exit(dummy_exit); 150 + module_platform_driver(dummy_driver); 161 151 162 152 MODULE_LICENSE("GPL"); 163 153 MODULE_DESCRIPTION("CoreSight dummy driver");
+2 -2
drivers/hwtracing/coresight/coresight-etm4x-cfg.c
··· 40 40 * Invalid offsets will result in fail code return and feature load failure. 41 41 * 42 42 * @drvdata: driver data to map into. 43 - * @reg: register to map. 43 + * @reg_csdev: register to map. 44 44 * @offset: device offset for the register 45 45 */ 46 46 static int etm4_cfg_map_reg_offset(struct etmv4_drvdata *drvdata, ··· 132 132 * etm4_cfg_load_feature - load a feature into a device instance. 133 133 * 134 134 * @csdev: An ETMv4 CoreSight device. 135 - * @feat: The feature to be loaded. 135 + * @feat_csdev: The feature to be loaded. 136 136 * 137 137 * The function will load a feature instance into the device, checking that 138 138 * the register definitions are valid for the device.
+96 -22
drivers/hwtracing/coresight/coresight-etm4x-core.c
··· 3 3 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 4 4 */ 5 5 6 + #include <linux/acpi.h> 6 7 #include <linux/bitops.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/moduleparam.h> ··· 31 30 #include <linux/platform_device.h> 32 31 #include <linux/pm_runtime.h> 33 32 #include <linux/property.h> 33 + #include <linux/clk/clk-conf.h> 34 34 35 35 #include <asm/barrier.h> 36 36 #include <asm/sections.h> ··· 68 66 static enum cpuhp_state hp_online; 69 67 70 68 struct etm4_init_arg { 71 - unsigned int pid; 72 69 struct device *dev; 73 70 struct csdev_access *csa; 74 71 }; ··· 371 370 } 372 371 373 372 static void etm4_check_arch_features(struct etmv4_drvdata *drvdata, 374 - unsigned int id) 373 + struct csdev_access *csa) 375 374 { 376 - if (etm4_hisi_match_pid(id)) 375 + /* 376 + * TRCPIDR* registers are not required for ETMs with system 377 + * instructions. They must be identified by the MIDR+REVIDRs. 378 + * Skip the TRCPID checks for now. 379 + */ 380 + if (!csa->io_mem) 381 + return; 382 + 383 + if (etm4_hisi_match_pid(coresight_get_pid(csa))) 377 384 set_bit(ETM4_IMPDEF_HISI_CORE_COMMIT, drvdata->arch_features); 378 385 } 379 386 #else ··· 394 385 } 395 386 396 387 static void etm4_check_arch_features(struct etmv4_drvdata *drvdata, 397 - unsigned int id) 388 + struct csdev_access *csa) 398 389 { 399 390 } 400 391 #endif /* CONFIG_ETM4X_IMPDEF_FEATURE */ ··· 1075 1066 return true; 1076 1067 } 1077 1068 1069 + static bool is_devtype_cpu_trace(void __iomem *base) 1070 + { 1071 + u32 devtype = readl(base + TRCDEVTYPE); 1072 + 1073 + return (devtype == CS_DEVTYPE_PE_TRACE); 1074 + } 1075 + 1078 1076 static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, 1079 1077 struct csdev_access *csa) 1080 1078 { 1081 1079 u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH); 1080 + 1081 + if (!is_coresight_device(drvdata->base) || !is_devtype_cpu_trace(drvdata->base)) 1082 + return false; 1082 1083 1083 1084 /* 1084 1085 * All ETMs must implement TRCDEVARCH to indicate that ··· 1180 1161 etm4_os_unlock_csa(drvdata, csa); 1181 1162 etm4_cs_unlock(drvdata, csa); 1182 1163 1183 - etm4_check_arch_features(drvdata, init_arg->pid); 1164 + etm4_check_arch_features(drvdata, csa); 1184 1165 1185 1166 /* find all capabilities of the tracing unit */ 1186 1167 etmidr0 = etm4x_relaxed_read32(csa, TRCIDR0); ··· 2063 2044 return 0; 2064 2045 } 2065 2046 2066 - static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) 2047 + static int etm4_probe(struct device *dev) 2067 2048 { 2068 - struct etmv4_drvdata *drvdata; 2049 + struct etmv4_drvdata *drvdata = dev_get_drvdata(dev); 2069 2050 struct csdev_access access = { 0 }; 2070 2051 struct etm4_init_arg init_arg = { 0 }; 2071 2052 struct etm4_init_arg *delayed; 2072 2053 2073 - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); 2074 - if (!drvdata) 2054 + if (WARN_ON(!drvdata)) 2075 2055 return -ENOMEM; 2076 - 2077 - dev_set_drvdata(dev, drvdata); 2078 2056 2079 2057 if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE) 2080 2058 pm_save_enable = coresight_loses_context_with_cpu(dev) ? ··· 2084 2068 return -ENOMEM; 2085 2069 } 2086 2070 2087 - drvdata->base = base; 2088 - 2089 2071 spin_lock_init(&drvdata->spinlock); 2090 2072 2091 2073 drvdata->cpu = coresight_get_cpu(dev); ··· 2092 2078 2093 2079 init_arg.dev = dev; 2094 2080 init_arg.csa = &access; 2095 - init_arg.pid = etm_pid; 2096 2081 2097 2082 /* 2098 2083 * Serialize against CPUHP callbacks to avoid race condition ··· 2121 2108 2122 2109 static int etm4_probe_amba(struct amba_device *adev, const struct amba_id *id) 2123 2110 { 2111 + struct etmv4_drvdata *drvdata; 2124 2112 void __iomem *base; 2125 2113 struct device *dev = &adev->dev; 2126 2114 struct resource *res = &adev->res; ··· 2132 2118 if (IS_ERR(base)) 2133 2119 return PTR_ERR(base); 2134 2120 2135 - ret = etm4_probe(dev, base, id->id); 2121 + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); 2122 + if (!drvdata) 2123 + return -ENOMEM; 2124 + 2125 + drvdata->base = base; 2126 + dev_set_drvdata(dev, drvdata); 2127 + ret = etm4_probe(dev); 2136 2128 if (!ret) 2137 2129 pm_runtime_put(&adev->dev); 2138 2130 ··· 2147 2127 2148 2128 static int etm4_probe_platform_dev(struct platform_device *pdev) 2149 2129 { 2130 + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2131 + struct etmv4_drvdata *drvdata; 2150 2132 int ret; 2151 2133 2134 + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); 2135 + if (!drvdata) 2136 + return -ENOMEM; 2137 + 2138 + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); 2139 + if (IS_ERR(drvdata->pclk)) 2140 + return -ENODEV; 2141 + 2142 + if (res) { 2143 + drvdata->base = devm_ioremap_resource(&pdev->dev, res); 2144 + if (IS_ERR(drvdata->base)) { 2145 + clk_put(drvdata->pclk); 2146 + return PTR_ERR(drvdata->base); 2147 + } 2148 + } 2149 + 2150 + dev_set_drvdata(&pdev->dev, drvdata); 2152 2151 pm_runtime_get_noresume(&pdev->dev); 2153 2152 pm_runtime_set_active(&pdev->dev); 2154 2153 pm_runtime_enable(&pdev->dev); 2155 2154 2156 - /* 2157 - * System register based devices could match the 2158 - * HW by reading appropriate registers on the HW 2159 - * and thus we could skip the PID. 2160 - */ 2161 - ret = etm4_probe(&pdev->dev, NULL, 0); 2155 + ret = etm4_probe(&pdev->dev); 2162 2156 2163 2157 pm_runtime_put(&pdev->dev); 2164 2158 return ret; ··· 2212 2178 /* ETMv4 UCI data */ 2213 2179 .devarch = ETM_DEVARCH_ETMv4x_ARCH, 2214 2180 .devarch_mask = ETM_DEVARCH_ID_MASK, 2215 - .devtype = 0x00000013, 2181 + .devtype = CS_DEVTYPE_PE_TRACE, 2216 2182 } 2217 2183 }; 2218 2184 ··· 2268 2234 if (drvdata) 2269 2235 etm4_remove_dev(drvdata); 2270 2236 pm_runtime_disable(&pdev->dev); 2237 + 2238 + if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) 2239 + clk_put(drvdata->pclk); 2240 + 2271 2241 return 0; 2272 2242 } 2273 2243 ··· 2316 2278 .id_table = etm4_ids, 2317 2279 }; 2318 2280 2281 + #ifdef CONFIG_PM 2282 + static int etm4_runtime_suspend(struct device *dev) 2283 + { 2284 + struct etmv4_drvdata *drvdata = dev_get_drvdata(dev); 2285 + 2286 + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) 2287 + clk_disable_unprepare(drvdata->pclk); 2288 + 2289 + return 0; 2290 + } 2291 + 2292 + static int etm4_runtime_resume(struct device *dev) 2293 + { 2294 + struct etmv4_drvdata *drvdata = dev_get_drvdata(dev); 2295 + 2296 + if (drvdata->pclk && !IS_ERR(drvdata->pclk)) 2297 + clk_prepare_enable(drvdata->pclk); 2298 + 2299 + return 0; 2300 + } 2301 + #endif 2302 + 2303 + static const struct dev_pm_ops etm4_dev_pm_ops = { 2304 + SET_RUNTIME_PM_OPS(etm4_runtime_suspend, etm4_runtime_resume, NULL) 2305 + }; 2306 + 2319 2307 static const struct of_device_id etm4_sysreg_match[] = { 2320 2308 { .compatible = "arm,coresight-etm4x-sysreg" }, 2321 2309 { .compatible = "arm,embedded-trace-extension" }, 2322 2310 {} 2323 2311 }; 2312 + 2313 + #ifdef CONFIG_ACPI 2314 + static const struct acpi_device_id etm4x_acpi_ids[] = { 2315 + {"ARMHC500", 0}, /* ARM CoreSight ETM4x */ 2316 + {} 2317 + }; 2318 + MODULE_DEVICE_TABLE(acpi, etm4x_acpi_ids); 2319 + #endif 2324 2320 2325 2321 static struct platform_driver etm4_platform_driver = { 2326 2322 .probe = etm4_probe_platform_dev, ··· 2362 2290 .driver = { 2363 2291 .name = "coresight-etm4x", 2364 2292 .of_match_table = etm4_sysreg_match, 2293 + .acpi_match_table = ACPI_PTR(etm4x_acpi_ids), 2365 2294 .suppress_bind_attrs = true, 2295 + .pm = &etm4_dev_pm_ops, 2366 2296 }, 2367 2297 }; 2368 2298
+4
drivers/hwtracing/coresight/coresight-etm4x.h
··· 701 701 #define ETM_DEVARCH_ETE_ARCH \ 702 702 (ETM_DEVARCH_ARCHITECT_ARM | ETM_DEVARCH_ARCHID_ETE | ETM_DEVARCH_PRESENT) 703 703 704 + #define CS_DEVTYPE_PE_TRACE 0x00000013 705 + 704 706 #define TRCSTATR_IDLE_BIT 0 705 707 #define TRCSTATR_PMSTABLE_BIT 1 706 708 #define ETM_DEFAULT_ADDR_COMP 0 ··· 946 944 947 945 /** 948 946 * struct etm4_drvdata - specifics associated to an ETM component 947 + * @pclk APB clock if present, otherwise NULL 949 948 * @base: Memory mapped base address for this component. 950 949 * @csdev: Component vitals needed by the framework. 951 950 * @spinlock: Only one at a time pls. ··· 1012 1009 * @arch_features: Bitmap of arch features of etmv4 devices. 1013 1010 */ 1014 1011 struct etmv4_drvdata { 1012 + struct clk *pclk; 1015 1013 void __iomem *base; 1016 1014 struct coresight_device *csdev; 1017 1015 spinlock_t spinlock;
+30 -16
drivers/hwtracing/coresight/coresight-platform.c
··· 9 9 #include <linux/slab.h> 10 10 #include <linux/clk.h> 11 11 #include <linux/of.h> 12 - #include <linux/of_address.h> 13 12 #include <linux/of_graph.h> 14 - #include <linux/of_platform.h> 15 13 #include <linux/platform_device.h> 16 14 #include <linux/amba/bus.h> 17 15 #include <linux/coresight.h> ··· 492 494 493 495 /* acpi_get_dsd_graph - Find the _DSD Graph property for the given device. */ 494 496 static const union acpi_object * 495 - acpi_get_dsd_graph(struct acpi_device *adev) 497 + acpi_get_dsd_graph(struct acpi_device *adev, struct acpi_buffer *buf) 496 498 { 497 499 int i; 498 - struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; 499 500 acpi_status status; 500 501 const union acpi_object *dsd; 501 502 502 503 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, 503 - &buf, ACPI_TYPE_PACKAGE); 504 + buf, ACPI_TYPE_PACKAGE); 504 505 if (ACPI_FAILURE(status)) 505 506 return NULL; 506 507 507 - dsd = buf.pointer; 508 + dsd = buf->pointer; 508 509 509 510 /* 510 511 * _DSD property consists tuples { Prop_UUID, Package() } ··· 554 557 * returns NULL. 555 558 */ 556 559 static const union acpi_object * 557 - acpi_get_coresight_graph(struct acpi_device *adev) 560 + acpi_get_coresight_graph(struct acpi_device *adev, struct acpi_buffer *buf) 558 561 { 559 562 const union acpi_object *graph_list, *graph; 560 563 int i, nr_graphs; 561 564 562 - graph_list = acpi_get_dsd_graph(adev); 565 + graph_list = acpi_get_dsd_graph(adev, buf); 563 566 if (!graph_list) 564 567 return graph_list; 565 568 ··· 660 663 struct acpi_device *adev, 661 664 struct coresight_platform_data *pdata) 662 665 { 666 + int ret = 0; 663 667 int i, nlinks; 664 668 const union acpi_object *graph; 665 669 struct coresight_connection conn, zero_conn = {}; 666 670 struct coresight_connection *new_conn; 671 + struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; 667 672 668 - graph = acpi_get_coresight_graph(adev); 673 + graph = acpi_get_coresight_graph(adev, &buf); 674 + /* 675 + * There are no graph connections, which is fine for some components. 676 + * e.g., ETE 677 + */ 669 678 if (!graph) 670 - return -ENOENT; 679 + goto free; 671 680 672 681 nlinks = graph->package.elements[2].integer.value; 673 682 if (!nlinks) 674 - return 0; 683 + goto free; 675 684 676 685 for (i = 0; i < nlinks; i++) { 677 686 const union acpi_object *link = &graph->package.elements[3 + i]; ··· 685 682 686 683 conn = zero_conn; 687 684 dir = acpi_coresight_parse_link(adev, link, &conn); 688 - if (dir < 0) 689 - return dir; 685 + if (dir < 0) { 686 + ret = dir; 687 + goto free; 688 + } 690 689 691 690 if (dir == ACPI_CORESIGHT_LINK_MASTER) { 692 691 new_conn = coresight_add_out_conn(dev, pdata, &conn); 693 - if (IS_ERR(new_conn)) 694 - return PTR_ERR(new_conn); 692 + if (IS_ERR(new_conn)) { 693 + ret = PTR_ERR(new_conn); 694 + goto free; 695 + } 695 696 } 696 697 } 697 698 698 - return 0; 699 + free: 700 + /* 701 + * When ACPI fails to alloc a buffer, it will free the buffer 702 + * created via ACPI_ALLOCATE_BUFFER and set to NULL. 703 + * ACPI_FREE can handle NULL pointers, so free it directly. 704 + */ 705 + ACPI_FREE(buf.pointer); 706 + return ret; 699 707 } 700 708 701 709 /*
+1 -1
drivers/hwtracing/coresight/coresight-tmc-etf.c
··· 452 452 return -EINVAL; 453 453 454 454 /* wrap head around to the amount of space we have */ 455 - head = handle->head & ((buf->nr_pages << PAGE_SHIFT) - 1); 455 + head = handle->head & (((unsigned long)buf->nr_pages << PAGE_SHIFT) - 1); 456 456 457 457 /* find the page to write to */ 458 458 buf->cur = head / PAGE_SIZE;
+3 -2
drivers/hwtracing/coresight/coresight-tmc-etr.c
··· 45 45 }; 46 46 47 47 /* Convert the perf index to an offset within the ETR buffer */ 48 - #define PERF_IDX2OFF(idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT)) 48 + #define PERF_IDX2OFF(idx, buf) \ 49 + ((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT)) 49 50 50 51 /* Lower limit for ETR hardware buffer */ 51 52 #define TMC_ETR_PERF_MIN_BUF_SIZE SZ_1M ··· 1268 1267 * than the size requested via sysfs. 1269 1268 */ 1270 1269 if ((nr_pages << PAGE_SHIFT) > drvdata->size) { 1271 - etr_buf = tmc_alloc_etr_buf(drvdata, (nr_pages << PAGE_SHIFT), 1270 + etr_buf = tmc_alloc_etr_buf(drvdata, ((ssize_t)nr_pages << PAGE_SHIFT), 1272 1271 0, node, NULL); 1273 1272 if (!IS_ERR(etr_buf)) 1274 1273 goto done;
+1 -1
drivers/hwtracing/coresight/coresight-tmc.h
··· 325 325 static inline unsigned long 326 326 tmc_sg_table_buf_size(struct tmc_sg_table *sg_table) 327 327 { 328 - return sg_table->data_pages.nr_pages << PAGE_SHIFT; 328 + return (unsigned long)sg_table->data_pages.nr_pages << PAGE_SHIFT; 329 329 } 330 330 331 331 struct coresight_device *tmc_etr_get_catu_device(struct tmc_drvdata *drvdata);
+21 -22
drivers/hwtracing/coresight/coresight-trbe.c
··· 1225 1225 enable_percpu_irq(drvdata->irq, IRQ_TYPE_NONE); 1226 1226 } 1227 1227 1228 + static void arm_trbe_disable_cpu(void *info) 1229 + { 1230 + struct trbe_drvdata *drvdata = info; 1231 + struct trbe_cpudata *cpudata = this_cpu_ptr(drvdata->cpudata); 1232 + 1233 + disable_percpu_irq(drvdata->irq); 1234 + trbe_reset_local(cpudata); 1235 + } 1236 + 1237 + 1228 1238 static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cpu) 1229 1239 { 1230 1240 struct trbe_cpudata *cpudata = per_cpu_ptr(drvdata->cpudata, cpu); ··· 1254 1244 if (!desc.name) 1255 1245 goto cpu_clear; 1256 1246 1247 + desc.pdata = coresight_get_platform_data(dev); 1248 + if (IS_ERR(desc.pdata)) 1249 + goto cpu_clear; 1250 + 1257 1251 desc.type = CORESIGHT_DEV_TYPE_SINK; 1258 1252 desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM; 1259 1253 desc.ops = &arm_trbe_cs_ops; 1260 - desc.pdata = dev_get_platdata(dev); 1261 1254 desc.groups = arm_trbe_groups; 1262 1255 desc.dev = dev; 1263 1256 trbe_csdev = coresight_register(&desc); ··· 1339 1326 cpumask_clear_cpu(cpu, &drvdata->supported_cpus); 1340 1327 } 1341 1328 1342 - static void arm_trbe_remove_coresight_cpu(void *info) 1329 + static void arm_trbe_remove_coresight_cpu(struct trbe_drvdata *drvdata, int cpu) 1343 1330 { 1344 - int cpu = smp_processor_id(); 1345 - struct trbe_drvdata *drvdata = info; 1346 - struct trbe_cpudata *cpudata = per_cpu_ptr(drvdata->cpudata, cpu); 1347 1331 struct coresight_device *trbe_csdev = coresight_get_percpu_sink(cpu); 1348 1332 1349 - disable_percpu_irq(drvdata->irq); 1350 - trbe_reset_local(cpudata); 1351 1333 if (trbe_csdev) { 1352 1334 coresight_unregister(trbe_csdev); 1353 - cpudata->drvdata = NULL; 1354 1335 coresight_set_percpu_sink(cpu, NULL); 1355 1336 } 1356 1337 } ··· 1373 1366 { 1374 1367 int cpu; 1375 1368 1376 - for_each_cpu(cpu, &drvdata->supported_cpus) 1377 - smp_call_function_single(cpu, arm_trbe_remove_coresight_cpu, drvdata, 1); 1369 + for_each_cpu(cpu, &drvdata->supported_cpus) { 1370 + smp_call_function_single(cpu, arm_trbe_disable_cpu, drvdata, 1); 1371 + arm_trbe_remove_coresight_cpu(drvdata, cpu); 1372 + } 1378 1373 free_percpu(drvdata->cpudata); 1379 1374 return 0; 1380 1375 } ··· 1415 1406 { 1416 1407 struct trbe_drvdata *drvdata = hlist_entry_safe(node, struct trbe_drvdata, hotplug_node); 1417 1408 1418 - if (cpumask_test_cpu(cpu, &drvdata->supported_cpus)) { 1419 - struct trbe_cpudata *cpudata = per_cpu_ptr(drvdata->cpudata, cpu); 1420 - 1421 - disable_percpu_irq(drvdata->irq); 1422 - trbe_reset_local(cpudata); 1423 - } 1409 + if (cpumask_test_cpu(cpu, &drvdata->supported_cpus)) 1410 + arm_trbe_disable_cpu(drvdata); 1424 1411 return 0; 1425 1412 } 1426 1413 ··· 1484 1479 1485 1480 static int arm_trbe_device_probe(struct platform_device *pdev) 1486 1481 { 1487 - struct coresight_platform_data *pdata; 1488 1482 struct trbe_drvdata *drvdata; 1489 1483 struct device *dev = &pdev->dev; 1490 1484 int ret; ··· 1498 1494 if (!drvdata) 1499 1495 return -ENOMEM; 1500 1496 1501 - pdata = coresight_get_platform_data(dev); 1502 - if (IS_ERR(pdata)) 1503 - return PTR_ERR(pdata); 1504 - 1505 1497 dev_set_drvdata(dev, drvdata); 1506 - dev->platform_data = pdata; 1507 1498 drvdata->pdev = pdev; 1508 1499 ret = arm_trbe_probe_irq(pdev, drvdata); 1509 1500 if (ret)
+1 -1
drivers/hwtracing/coresight/coresight-trbe.h
··· 23 23 unsigned int trbe = cpuid_feature_extract_unsigned_field(aa64dfr0, 24 24 ID_AA64DFR0_EL1_TraceBuffer_SHIFT); 25 25 26 - return trbe >= 0b0001; 26 + return trbe >= ID_AA64DFR0_EL1_TraceBuffer_IMP; 27 27 } 28 28 29 29 static inline bool is_trbe_enabled(void)
+4 -4
drivers/hwtracing/ptt/hisi_ptt.c
··· 618 618 if (!root_port) 619 619 return 0; 620 620 621 - port_devid = PCI_DEVID(root_port->bus->number, root_port->devfn); 621 + port_devid = pci_dev_id(root_port); 622 622 if (port_devid < hisi_ptt->lower_bdf || 623 623 port_devid > hisi_ptt->upper_bdf) 624 624 return 0; 625 625 626 626 info.is_port = pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT; 627 - info.devid = PCI_DEVID(pdev->bus->number, pdev->devfn); 627 + info.devid = pci_dev_id(pdev); 628 628 629 629 switch (action) { 630 630 case BUS_NOTIFY_ADD_DEVICE: ··· 664 664 if (!root_port) 665 665 return 0; 666 666 667 - port_devid = PCI_DEVID(root_port->bus->number, root_port->devfn); 667 + port_devid = pci_dev_id(root_port); 668 668 if (port_devid < hisi_ptt->lower_bdf || 669 669 port_devid > hisi_ptt->upper_bdf) 670 670 return 0; ··· 674 674 * should be partial initialized and users would know which filter fails 675 675 * through the log. Other functions of PTT device are still available. 676 676 */ 677 - filter = hisi_ptt_alloc_add_filter(hisi_ptt, PCI_DEVID(pdev->bus->number, pdev->devfn), 677 + filter = hisi_ptt_alloc_add_filter(hisi_ptt, pci_dev_id(pdev), 678 678 pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT); 679 679 if (!filter) 680 680 return -ENOMEM;
+59
include/linux/coresight.h
··· 6 6 #ifndef _LINUX_CORESIGHT_H 7 7 #define _LINUX_CORESIGHT_H 8 8 9 + #include <linux/amba/bus.h> 10 + #include <linux/clk.h> 9 11 #include <linux/device.h> 10 12 #include <linux/io.h> 11 13 #include <linux/perf_event.h> ··· 386 384 return readl_relaxed(csa->base + offset); 387 385 388 386 return csa->read(offset, true, false); 387 + } 388 + 389 + #define CORESIGHT_CIDRn(i) (0xFF0 + ((i) * 4)) 390 + 391 + static inline u32 coresight_get_cid(void __iomem *base) 392 + { 393 + u32 i, cid = 0; 394 + 395 + for (i = 0; i < 4; i++) 396 + cid |= readl(base + CORESIGHT_CIDRn(i)) << (i * 8); 397 + 398 + return cid; 399 + } 400 + 401 + static inline bool is_coresight_device(void __iomem *base) 402 + { 403 + u32 cid = coresight_get_cid(base); 404 + 405 + return cid == CORESIGHT_CID; 406 + } 407 + 408 + /* 409 + * Attempt to find and enable "APB clock" for the given device 410 + * 411 + * Returns: 412 + * 413 + * clk - Clock is found and enabled 414 + * NULL - clock is not found 415 + * ERROR - Clock is found but failed to enable 416 + */ 417 + static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev) 418 + { 419 + struct clk *pclk; 420 + int ret; 421 + 422 + pclk = clk_get(dev, "apb_pclk"); 423 + if (IS_ERR(pclk)) 424 + return NULL; 425 + 426 + ret = clk_prepare_enable(pclk); 427 + if (ret) { 428 + clk_put(pclk); 429 + return ERR_PTR(ret); 430 + } 431 + return pclk; 432 + } 433 + 434 + #define CORESIGHT_PIDRn(i) (0xFE0 + ((i) * 4)) 435 + 436 + static inline u32 coresight_get_pid(struct csdev_access *csa) 437 + { 438 + u32 i, pid = 0; 439 + 440 + for (i = 0; i < 4; i++) 441 + pid |= csdev_access_relaxed_read32(csa, CORESIGHT_PIDRn(i)) << (i * 8); 442 + 443 + return pid; 389 444 } 390 445 391 446 static inline u64 csdev_access_relaxed_read_pair(struct csdev_access *csa,