diff options
author | Adeel Raza <araza@nvidia.com> | 2018-04-27 17:45:08 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-06-19 21:23:10 -0400 |
commit | c484fb35bf3edee3b12dc41dbbe49fff0e24c2c5 (patch) | |
tree | 99d5dcd5d7378a77259f5781bea9077f310929ee | |
parent | a1243f3f047ec226723d514c12c8c5d3984048e0 (diff) |
nvlink: add support for kernel tests
Add support for NVLINK kernel test modules:
- Create an NVLINK tests debugfs directory which will be used as the
parent directory for all test related debugfs nodes
- Export NVLINK logging APIs
- Rename the NVLINK_DRV_NAME macros to NVLINK_MODULE_NAME. This
was done because now the NVLINK logging APIs are being used by
non-driver modules (i.e. tests) as well.
- Export an ARM64 cache flush API - this API is needed by the Tegra
loopback test
Bug 2133882
Jira NVLINK-107
Change-Id: I587b704ff44327ee4d9767156cb87cbe27408e08
Signed-off-by: Adeel Raza <araza@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1704230
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Petlozu Pravareshwar <petlozup@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r-- | drivers/nvlink/nvlink-core.c | 59 | ||||
-rw-r--r-- | drivers/nvlink/t19x-nvlink-endpt-debugfs.c | 6 | ||||
-rw-r--r-- | drivers/nvlink/t19x-nvlink-endpt.c | 8 | ||||
-rw-r--r-- | drivers/nvlink/t19x-nvlink-endpt.h | 2 | ||||
-rw-r--r-- | include/linux/platform/tegra/tegra-nvlink.h | 8 |
5 files changed, 64 insertions, 19 deletions
diff --git a/drivers/nvlink/nvlink-core.c b/drivers/nvlink/nvlink-core.c index 5ff8c038f..7e0c0faa3 100644 --- a/drivers/nvlink/nvlink-core.c +++ b/drivers/nvlink/nvlink-core.c | |||
@@ -25,8 +25,11 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/platform/tegra/tegra-nvlink.h> | 26 | #include <linux/platform/tegra/tegra-nvlink.h> |
27 | 27 | ||
28 | #define NVLINK_DRV_NAME "nvlink-core" | 28 | #include <asm/cacheflush.h> |
29 | |||
30 | #define NVLINK_MODULE_NAME "nvlink-core" | ||
29 | #define NVLINK_DEBUGFS_ROOT "nvlink" | 31 | #define NVLINK_DEBUGFS_ROOT "nvlink" |
32 | #define NVLINK_DEBUGFS_TESTS "tests" | ||
30 | #define DEFAULT_LOOP_SLEEP_US 100 | 33 | #define DEFAULT_LOOP_SLEEP_US 100 |
31 | #define DEFAULT_LOOP_TIMEOUT_US 1000000 | 34 | #define DEFAULT_LOOP_TIMEOUT_US 1000000 |
32 | #define NVLINK_TRANSITION_HS_TIMEOUT_MS 2000 | 35 | #define NVLINK_TRANSITION_HS_TIMEOUT_MS 2000 |
@@ -52,11 +55,25 @@ struct nvlink_core { | |||
52 | struct mutex mutex; | 55 | struct mutex mutex; |
53 | }; | 56 | }; |
54 | 57 | ||
58 | /* | ||
59 | * We're exporting the NVLINK driver stack's logging APIs to the NVLINK kernel | ||
60 | * test modules. The logging APIs use nvlink_log_mask. Therefore, we have to | ||
61 | * export nvlink_log_mask along with the logging APIs. | ||
62 | */ | ||
55 | u32 nvlink_log_mask = NVLINK_DEFAULT_LOG_MASK; | 63 | u32 nvlink_log_mask = NVLINK_DEFAULT_LOG_MASK; |
64 | EXPORT_SYMBOL(nvlink_log_mask); | ||
56 | 65 | ||
57 | #ifdef CONFIG_DEBUG_FS | 66 | #ifdef CONFIG_DEBUG_FS |
58 | /* This is the root debugfs directory for the entire NVLINK driver stack */ | 67 | /* This is the root debugfs directory for the entire NVLINK driver stack */ |
59 | struct dentry *nvlink_debugfs; | 68 | struct dentry *nvlink_debugfs_root; |
69 | |||
70 | /* | ||
71 | * This is the parent debugfs directory for NVLINK tests. We need to export this | ||
72 | * symbol so that the NVLINK kernel test modules can create their debugfs nodes | ||
73 | * under the correct path. | ||
74 | */ | ||
75 | struct dentry *nvlink_debugfs_tests; | ||
76 | EXPORT_SYMBOL(nvlink_debugfs_tests); | ||
60 | #endif /* CONFIG_DEBUG_FS */ | 77 | #endif /* CONFIG_DEBUG_FS */ |
61 | 78 | ||
62 | static struct nvlink_core nvlink_core; | 79 | static struct nvlink_core nvlink_core; |
@@ -244,6 +261,20 @@ success: | |||
244 | return ret; | 261 | return ret; |
245 | } | 262 | } |
246 | 263 | ||
264 | /* | ||
265 | * This is a wrapper function for an ARM64 cache flush API. This API is used in | ||
266 | * NVLINK kernel test modules. We've created this NVLINK wrapper because we | ||
267 | * don't want to directly export the ARM64 API. We want to minimize the exposure | ||
268 | * of this API outside of the kernel. By creating this NVLINK wrapper we're | ||
269 | * trying to ensure that only NVLINK kernel test modules will use this API | ||
270 | * outside of the kernel. | ||
271 | */ | ||
272 | void __nvlink_dma_flush_area(const void *ptr, size_t size) | ||
273 | { | ||
274 | __dma_flush_area(ptr, size); | ||
275 | } | ||
276 | EXPORT_SYMBOL(__nvlink_dma_flush_area); | ||
277 | |||
247 | int nvlink_register_device(struct nvlink_device *ndev) | 278 | int nvlink_register_device(struct nvlink_device *ndev) |
248 | { | 279 | { |
249 | int ret = 0; | 280 | int ret = 0; |
@@ -1459,13 +1490,21 @@ void nvlink_core_debugfs_init(void) | |||
1459 | struct dentry *core_debugfs = NULL; | 1490 | struct dentry *core_debugfs = NULL; |
1460 | struct dentry *debugfs_node = NULL; | 1491 | struct dentry *debugfs_node = NULL; |
1461 | 1492 | ||
1462 | nvlink_debugfs = debugfs_create_dir(NVLINK_DEBUGFS_ROOT, NULL); | 1493 | nvlink_debugfs_root = debugfs_create_dir(NVLINK_DEBUGFS_ROOT, NULL); |
1463 | if (!nvlink_debugfs) { | 1494 | if (!nvlink_debugfs_root) { |
1464 | nvlink_err("Failed to create NVLINK debugfs root directory"); | 1495 | nvlink_err("Failed to create NVLINK debugfs root directory"); |
1465 | goto fail; | 1496 | goto fail; |
1466 | } | 1497 | } |
1467 | 1498 | ||
1468 | core_debugfs = debugfs_create_dir(NVLINK_DRV_NAME, nvlink_debugfs); | 1499 | nvlink_debugfs_tests = debugfs_create_dir(NVLINK_DEBUGFS_TESTS, |
1500 | nvlink_debugfs_root); | ||
1501 | if (!nvlink_debugfs_tests) { | ||
1502 | nvlink_err("Failed to create NVLINK tests debugfs directory"); | ||
1503 | goto fail; | ||
1504 | } | ||
1505 | |||
1506 | core_debugfs = debugfs_create_dir(NVLINK_MODULE_NAME, | ||
1507 | nvlink_debugfs_root); | ||
1469 | if (!core_debugfs) { | 1508 | if (!core_debugfs) { |
1470 | nvlink_err("Failed to create NVLINK core driver's debugfs directory"); | 1509 | nvlink_err("Failed to create NVLINK core driver's debugfs directory"); |
1471 | goto fail; | 1510 | goto fail; |
@@ -1484,14 +1523,16 @@ void nvlink_core_debugfs_init(void) | |||
1484 | 1523 | ||
1485 | fail: | 1524 | fail: |
1486 | nvlink_err("Failed to create debugfs nodes"); | 1525 | nvlink_err("Failed to create debugfs nodes"); |
1487 | debugfs_remove_recursive(nvlink_debugfs); | 1526 | debugfs_remove_recursive(nvlink_debugfs_root); |
1488 | nvlink_debugfs = NULL; | 1527 | nvlink_debugfs_root = NULL; |
1528 | nvlink_debugfs_tests = NULL; | ||
1489 | } | 1529 | } |
1490 | 1530 | ||
1491 | void nvlink_core_debugfs_deinit(void) | 1531 | void nvlink_core_debugfs_deinit(void) |
1492 | { | 1532 | { |
1493 | debugfs_remove_recursive(nvlink_debugfs); | 1533 | debugfs_remove_recursive(nvlink_debugfs_root); |
1494 | nvlink_debugfs = NULL; | 1534 | nvlink_debugfs_root = NULL; |
1535 | nvlink_debugfs_tests = NULL; | ||
1495 | } | 1536 | } |
1496 | #endif /* CONFIG_DEBUG_FS */ | 1537 | #endif /* CONFIG_DEBUG_FS */ |
1497 | 1538 | ||
diff --git a/drivers/nvlink/t19x-nvlink-endpt-debugfs.c b/drivers/nvlink/t19x-nvlink-endpt-debugfs.c index 5eddc3f6b..d1bd3bb93 100644 --- a/drivers/nvlink/t19x-nvlink-endpt-debugfs.c +++ b/drivers/nvlink/t19x-nvlink-endpt-debugfs.c | |||
@@ -293,13 +293,13 @@ fail: | |||
293 | 293 | ||
294 | void t19x_nvlink_endpt_debugfs_init(struct tnvlink_dev *tdev) | 294 | void t19x_nvlink_endpt_debugfs_init(struct tnvlink_dev *tdev) |
295 | { | 295 | { |
296 | if (!nvlink_debugfs) { | 296 | if (!nvlink_debugfs_root) { |
297 | nvlink_err("Root NVLINK debugfs directory doesn't exist"); | 297 | nvlink_err("Root NVLINK debugfs directory doesn't exist"); |
298 | goto fail; | 298 | goto fail; |
299 | } | 299 | } |
300 | 300 | ||
301 | tdev->tegra_debugfs = debugfs_create_dir(NVLINK_DRV_NAME, | 301 | tdev->tegra_debugfs = debugfs_create_dir(NVLINK_MODULE_NAME, |
302 | nvlink_debugfs); | 302 | nvlink_debugfs_root); |
303 | if (!tdev->tegra_debugfs) { | 303 | if (!tdev->tegra_debugfs) { |
304 | nvlink_err("Failed to create Tegra NVLINK endpoint driver's" | 304 | nvlink_err("Failed to create Tegra NVLINK endpoint driver's" |
305 | " debugfs directory"); | 305 | " debugfs directory"); |
diff --git a/drivers/nvlink/t19x-nvlink-endpt.c b/drivers/nvlink/t19x-nvlink-endpt.c index 23b6dca97..617aba9da 100644 --- a/drivers/nvlink/t19x-nvlink-endpt.c +++ b/drivers/nvlink/t19x-nvlink-endpt.c | |||
@@ -1090,7 +1090,7 @@ static int t19x_nvlink_endpt_probe(struct platform_device *pdev) | |||
1090 | 1090 | ||
1091 | tdev->dev = &pdev->dev; | 1091 | tdev->dev = &pdev->dev; |
1092 | tdev->class.owner = THIS_MODULE; | 1092 | tdev->class.owner = THIS_MODULE; |
1093 | tdev->class.name = NVLINK_DRV_NAME; | 1093 | tdev->class.name = NVLINK_MODULE_NAME; |
1094 | 1094 | ||
1095 | /* Create device node */ | 1095 | /* Create device node */ |
1096 | ret = class_register(&tdev->class); | 1096 | ret = class_register(&tdev->class); |
@@ -1118,7 +1118,7 @@ static int t19x_nvlink_endpt_probe(struct platform_device *pdev) | |||
1118 | NULL, | 1118 | NULL, |
1119 | tdev->dev_t, | 1119 | tdev->dev_t, |
1120 | NULL, | 1120 | NULL, |
1121 | NVLINK_DRV_NAME); | 1121 | NVLINK_MODULE_NAME); |
1122 | if (IS_ERR(dev)) { | 1122 | if (IS_ERR(dev)) { |
1123 | nvlink_err("Failed to create device"); | 1123 | nvlink_err("Failed to create device"); |
1124 | ret = PTR_ERR(dev); | 1124 | ret = PTR_ERR(dev); |
@@ -1368,7 +1368,7 @@ static struct platform_driver t19x_nvlink_endpt_pdrv = { | |||
1368 | .probe = t19x_nvlink_endpt_probe, | 1368 | .probe = t19x_nvlink_endpt_probe, |
1369 | .remove = t19x_nvlink_endpt_remove, | 1369 | .remove = t19x_nvlink_endpt_remove, |
1370 | .driver = { | 1370 | .driver = { |
1371 | .name = NVLINK_DRV_NAME, | 1371 | .name = NVLINK_MODULE_NAME, |
1372 | #if IS_ENABLED(CONFIG_PM_SLEEP) | 1372 | #if IS_ENABLED(CONFIG_PM_SLEEP) |
1373 | .pm = &tegra_nvlink_pm_ops, | 1373 | .pm = &tegra_nvlink_pm_ops, |
1374 | #endif | 1374 | #endif |
@@ -1397,6 +1397,6 @@ static void __exit t19x_nvlink_endpt_exit(void) | |||
1397 | module_init(t19x_nvlink_endpt_init); | 1397 | module_init(t19x_nvlink_endpt_init); |
1398 | module_exit(t19x_nvlink_endpt_exit); | 1398 | module_exit(t19x_nvlink_endpt_exit); |
1399 | 1399 | ||
1400 | MODULE_ALIAS(NVLINK_DRV_NAME); | 1400 | MODULE_ALIAS(NVLINK_MODULE_NAME); |
1401 | MODULE_DESCRIPTION("T19x NVLINK Endpoint Driver"); | 1401 | MODULE_DESCRIPTION("T19x NVLINK Endpoint Driver"); |
1402 | MODULE_LICENSE("GPL v2"); | 1402 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/nvlink/t19x-nvlink-endpt.h b/drivers/nvlink/t19x-nvlink-endpt.h index 0243247c8..0add7e976 100644 --- a/drivers/nvlink/t19x-nvlink-endpt.h +++ b/drivers/nvlink/t19x-nvlink-endpt.h | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/cdev.h> | 37 | #include <linux/cdev.h> |
38 | #include <linux/platform/tegra/tegra-nvlink.h> | 38 | #include <linux/platform/tegra/tegra-nvlink.h> |
39 | 39 | ||
40 | #define NVLINK_DRV_NAME "t19x-nvlink-endpt" | 40 | #define NVLINK_MODULE_NAME "t19x-nvlink-endpt" |
41 | #define NVLINK_IP_VERSION 2 /* NVLINK VERSION 2.0 */ | 41 | #define NVLINK_IP_VERSION 2 /* NVLINK VERSION 2.0 */ |
42 | #define DEFAULT_IS_NEA 0 | 42 | #define DEFAULT_IS_NEA 0 |
43 | 43 | ||
diff --git a/include/linux/platform/tegra/tegra-nvlink.h b/include/linux/platform/tegra/tegra-nvlink.h index 09798b293..7760837eb 100644 --- a/include/linux/platform/tegra/tegra-nvlink.h +++ b/include/linux/platform/tegra/tegra-nvlink.h | |||
@@ -45,7 +45,10 @@ enum nvlink_log_categories { | |||
45 | 45 | ||
46 | #ifdef CONFIG_DEBUG_FS | 46 | #ifdef CONFIG_DEBUG_FS |
47 | /* This is the root debugfs directory for the entire NVLINK driver stack */ | 47 | /* This is the root debugfs directory for the entire NVLINK driver stack */ |
48 | extern struct dentry *nvlink_debugfs; | 48 | extern struct dentry *nvlink_debugfs_root; |
49 | |||
50 | /* This is the parent debugfs directory for NVLINK tests */ | ||
51 | extern struct dentry *nvlink_debugfs_tests; | ||
49 | #endif /* CONFIG_DEBUG_FS */ | 52 | #endif /* CONFIG_DEBUG_FS */ |
50 | 53 | ||
51 | extern u32 nvlink_log_mask; | 54 | extern u32 nvlink_log_mask; |
@@ -55,7 +58,7 @@ extern u32 nvlink_log_mask; | |||
55 | do { \ | 58 | do { \ |
56 | if ((log_mask) & nvlink_log_mask) \ | 59 | if ((log_mask) & nvlink_log_mask) \ |
57 | printk("%s: %s: %d: " fmt "\n", \ | 60 | printk("%s: %s: %d: " fmt "\n", \ |
58 | NVLINK_DRV_NAME, \ | 61 | NVLINK_MODULE_NAME, \ |
59 | __func__, \ | 62 | __func__, \ |
60 | __LINE__, \ | 63 | __LINE__, \ |
61 | ##arg); \ | 64 | ##arg); \ |
@@ -298,6 +301,7 @@ struct nvlink_device { | |||
298 | 301 | ||
299 | /* APIs used by endpoint drivers for interfacing with the core driver */ | 302 | /* APIs used by endpoint drivers for interfacing with the core driver */ |
300 | void nvlink_print_topology(void); | 303 | void nvlink_print_topology(void); |
304 | void __nvlink_dma_flush_area(const void *ptr, size_t size); | ||
301 | int nvlink_register_device(struct nvlink_device* device); | 305 | int nvlink_register_device(struct nvlink_device* device); |
302 | int nvlink_register_link(struct nvlink_link* link); | 306 | int nvlink_register_link(struct nvlink_link* link); |
303 | int nvlink_unregister_device(struct nvlink_device* device); | 307 | int nvlink_unregister_device(struct nvlink_device* device); |