diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2016-05-24 16:50:06 -0400 |
---|---|---|
committer | Terje Bergstrom <tbergstrom@nvidia.com> | 2016-05-25 14:58:54 -0400 |
commit | dc08f78c578e60c0b58e1f489bd9527e4ce2c254 (patch) | |
tree | 4586da9da29da22ae34fb40b3b825d65d0fe5025 /drivers/gpu/nvgpu | |
parent | 01a0c3f1b4ed2f43f3943125961f3cfd726ababf (diff) |
gpu: nvgpu: Move PCI devnodes to own directory
To be able to scan, PCI devnodes need to be in a directory with read
permission. By default /dev is read protected by SELinux policy. Move
the devnodes to their own directory so that reading this one
directory can be allowed.
At the same time rename the nodes to start with string "card-".
JIRA DNVGPU-54
Change-Id: I0df4ced08afd1f3a468e983d07395ffcb8050365
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1152745
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 52 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 5 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/pci.c | 24 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.c | 4 |
4 files changed, 56 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 3ab26fb9..a381fa4a 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c | |||
@@ -966,7 +966,8 @@ static int gk20a_create_device( | |||
966 | struct device *dev, int devno, | 966 | struct device *dev, int devno, |
967 | const char *interface_name, const char *cdev_name, | 967 | const char *interface_name, const char *cdev_name, |
968 | struct cdev *cdev, struct device **out, | 968 | struct cdev *cdev, struct device **out, |
969 | const struct file_operations *ops) | 969 | const struct file_operations *ops, |
970 | struct class *class) | ||
970 | { | 971 | { |
971 | struct device *subdev; | 972 | struct device *subdev; |
972 | int err; | 973 | int err; |
@@ -982,7 +983,7 @@ static int gk20a_create_device( | |||
982 | return err; | 983 | return err; |
983 | } | 984 | } |
984 | 985 | ||
985 | subdev = device_create(&nvgpu_class, NULL, devno, NULL, | 986 | subdev = device_create(class, NULL, devno, NULL, |
986 | interface_name, cdev_name); | 987 | interface_name, cdev_name); |
987 | 988 | ||
988 | if (IS_ERR(subdev)) { | 989 | if (IS_ERR(subdev)) { |
@@ -997,42 +998,42 @@ static int gk20a_create_device( | |||
997 | return 0; | 998 | return 0; |
998 | } | 999 | } |
999 | 1000 | ||
1000 | void gk20a_user_deinit(struct device *dev) | 1001 | void gk20a_user_deinit(struct device *dev, struct class *class) |
1001 | { | 1002 | { |
1002 | struct gk20a *g = gk20a_from_dev(dev); | 1003 | struct gk20a *g = gk20a_from_dev(dev); |
1003 | 1004 | ||
1004 | if (g->channel.node) { | 1005 | if (g->channel.node) { |
1005 | device_destroy(&nvgpu_class, g->channel.cdev.dev); | 1006 | device_destroy(class, g->channel.cdev.dev); |
1006 | cdev_del(&g->channel.cdev); | 1007 | cdev_del(&g->channel.cdev); |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | if (g->as.node) { | 1010 | if (g->as.node) { |
1010 | device_destroy(&nvgpu_class, g->as.cdev.dev); | 1011 | device_destroy(class, g->as.cdev.dev); |
1011 | cdev_del(&g->as.cdev); | 1012 | cdev_del(&g->as.cdev); |
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | if (g->ctrl.node) { | 1015 | if (g->ctrl.node) { |
1015 | device_destroy(&nvgpu_class, g->ctrl.cdev.dev); | 1016 | device_destroy(class, g->ctrl.cdev.dev); |
1016 | cdev_del(&g->ctrl.cdev); | 1017 | cdev_del(&g->ctrl.cdev); |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | if (g->dbg.node) { | 1020 | if (g->dbg.node) { |
1020 | device_destroy(&nvgpu_class, g->dbg.cdev.dev); | 1021 | device_destroy(class, g->dbg.cdev.dev); |
1021 | cdev_del(&g->dbg.cdev); | 1022 | cdev_del(&g->dbg.cdev); |
1022 | } | 1023 | } |
1023 | 1024 | ||
1024 | if (g->prof.node) { | 1025 | if (g->prof.node) { |
1025 | device_destroy(&nvgpu_class, g->prof.cdev.dev); | 1026 | device_destroy(class, g->prof.cdev.dev); |
1026 | cdev_del(&g->prof.cdev); | 1027 | cdev_del(&g->prof.cdev); |
1027 | } | 1028 | } |
1028 | 1029 | ||
1029 | if (g->tsg.node) { | 1030 | if (g->tsg.node) { |
1030 | device_destroy(&nvgpu_class, g->tsg.cdev.dev); | 1031 | device_destroy(class, g->tsg.cdev.dev); |
1031 | cdev_del(&g->tsg.cdev); | 1032 | cdev_del(&g->tsg.cdev); |
1032 | } | 1033 | } |
1033 | 1034 | ||
1034 | if (g->ctxsw.node) { | 1035 | if (g->ctxsw.node) { |
1035 | device_destroy(&nvgpu_class, g->ctxsw.cdev.dev); | 1036 | device_destroy(class, g->ctxsw.cdev.dev); |
1036 | cdev_del(&g->ctxsw.cdev); | 1037 | cdev_del(&g->ctxsw.cdev); |
1037 | } | 1038 | } |
1038 | 1039 | ||
@@ -1040,7 +1041,8 @@ void gk20a_user_deinit(struct device *dev) | |||
1040 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | 1041 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | int gk20a_user_init(struct device *dev, const char *interface_name) | 1044 | int gk20a_user_init(struct device *dev, const char *interface_name, |
1045 | struct class *class) | ||
1044 | { | 1046 | { |
1045 | int err; | 1047 | int err; |
1046 | dev_t devno; | 1048 | dev_t devno; |
@@ -1055,44 +1057,51 @@ int gk20a_user_init(struct device *dev, const char *interface_name) | |||
1055 | 1057 | ||
1056 | err = gk20a_create_device(dev, devno++, interface_name, "", | 1058 | err = gk20a_create_device(dev, devno++, interface_name, "", |
1057 | &g->channel.cdev, &g->channel.node, | 1059 | &g->channel.cdev, &g->channel.node, |
1058 | &gk20a_channel_ops); | 1060 | &gk20a_channel_ops, |
1061 | class); | ||
1059 | if (err) | 1062 | if (err) |
1060 | goto fail; | 1063 | goto fail; |
1061 | 1064 | ||
1062 | err = gk20a_create_device(dev, devno++, interface_name, "-as", | 1065 | err = gk20a_create_device(dev, devno++, interface_name, "-as", |
1063 | &g->as.cdev, &g->as.node, | 1066 | &g->as.cdev, &g->as.node, |
1064 | &gk20a_as_ops); | 1067 | &gk20a_as_ops, |
1068 | class); | ||
1065 | if (err) | 1069 | if (err) |
1066 | goto fail; | 1070 | goto fail; |
1067 | 1071 | ||
1068 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", | 1072 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", |
1069 | &g->ctrl.cdev, &g->ctrl.node, | 1073 | &g->ctrl.cdev, &g->ctrl.node, |
1070 | &gk20a_ctrl_ops); | 1074 | &gk20a_ctrl_ops, |
1075 | class); | ||
1071 | if (err) | 1076 | if (err) |
1072 | goto fail; | 1077 | goto fail; |
1073 | 1078 | ||
1074 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", | 1079 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", |
1075 | &g->dbg.cdev, &g->dbg.node, | 1080 | &g->dbg.cdev, &g->dbg.node, |
1076 | &gk20a_dbg_ops); | 1081 | &gk20a_dbg_ops, |
1082 | class); | ||
1077 | if (err) | 1083 | if (err) |
1078 | goto fail; | 1084 | goto fail; |
1079 | 1085 | ||
1080 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", | 1086 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", |
1081 | &g->prof.cdev, &g->prof.node, | 1087 | &g->prof.cdev, &g->prof.node, |
1082 | &gk20a_prof_ops); | 1088 | &gk20a_prof_ops, |
1089 | class); | ||
1083 | if (err) | 1090 | if (err) |
1084 | goto fail; | 1091 | goto fail; |
1085 | 1092 | ||
1086 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", | 1093 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", |
1087 | &g->tsg.cdev, &g->tsg.node, | 1094 | &g->tsg.cdev, &g->tsg.node, |
1088 | &gk20a_tsg_ops); | 1095 | &gk20a_tsg_ops, |
1096 | class); | ||
1089 | if (err) | 1097 | if (err) |
1090 | goto fail; | 1098 | goto fail; |
1091 | 1099 | ||
1092 | #ifdef CONFIG_GK20A_CTXSW_TRACE | 1100 | #ifdef CONFIG_GK20A_CTXSW_TRACE |
1093 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", | 1101 | err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw", |
1094 | &g->ctxsw.cdev, &g->ctxsw.node, | 1102 | &g->ctxsw.cdev, &g->ctxsw.node, |
1095 | &gk20a_ctxsw_ops); | 1103 | &gk20a_ctxsw_ops, |
1104 | class); | ||
1096 | if (err) | 1105 | if (err) |
1097 | goto fail; | 1106 | goto fail; |
1098 | #endif | 1107 | #endif |
@@ -1100,7 +1109,7 @@ int gk20a_user_init(struct device *dev, const char *interface_name) | |||
1100 | 1109 | ||
1101 | return 0; | 1110 | return 0; |
1102 | fail: | 1111 | fail: |
1103 | gk20a_user_deinit(dev); | 1112 | gk20a_user_deinit(dev, &nvgpu_class); |
1104 | return err; | 1113 | return err; |
1105 | } | 1114 | } |
1106 | 1115 | ||
@@ -1464,7 +1473,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1464 | if (gk20a->irq_stall != gk20a->irq_nonstall) | 1473 | if (gk20a->irq_stall != gk20a->irq_nonstall) |
1465 | disable_irq(gk20a->irq_nonstall); | 1474 | disable_irq(gk20a->irq_nonstall); |
1466 | 1475 | ||
1467 | err = gk20a_user_init(&dev->dev, INTERFACE_NAME); | 1476 | err = gk20a_user_init(&dev->dev, INTERFACE_NAME, &nvgpu_class); |
1468 | if (err) | 1477 | if (err) |
1469 | return err; | 1478 | return err; |
1470 | 1479 | ||
@@ -1644,7 +1653,7 @@ static int __exit gk20a_remove(struct platform_device *pdev) | |||
1644 | if (g->remove_support) | 1653 | if (g->remove_support) |
1645 | g->remove_support(dev); | 1654 | g->remove_support(dev); |
1646 | 1655 | ||
1647 | gk20a_user_deinit(dev); | 1656 | gk20a_user_deinit(dev, &nvgpu_class); |
1648 | 1657 | ||
1649 | debugfs_remove_recursive(platform->debugfs); | 1658 | debugfs_remove_recursive(platform->debugfs); |
1650 | debugfs_remove_recursive(platform->debugfs_alias); | 1659 | debugfs_remove_recursive(platform->debugfs_alias); |
@@ -1751,7 +1760,6 @@ static int gk20a_domain_init(struct of_device_id *matches) | |||
1751 | } | 1760 | } |
1752 | #endif | 1761 | #endif |
1753 | 1762 | ||
1754 | |||
1755 | struct class nvgpu_class = { | 1763 | struct class nvgpu_class = { |
1756 | .owner = THIS_MODULE, | 1764 | .owner = THIS_MODULE, |
1757 | .name = CLASS_NAME, | 1765 | .name = CLASS_NAME, |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index f5b4bb3f..d131862b 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -1067,8 +1067,9 @@ int gk20a_init_gpu_characteristics(struct gk20a *g); | |||
1067 | 1067 | ||
1068 | void gk20a_pbus_isr(struct gk20a *g); | 1068 | void gk20a_pbus_isr(struct gk20a *g); |
1069 | 1069 | ||
1070 | int gk20a_user_init(struct device *dev, const char *interface_name); | 1070 | int gk20a_user_init(struct device *dev, const char *interface_name, |
1071 | void gk20a_user_deinit(struct device *dev); | 1071 | struct class *class); |
1072 | void gk20a_user_deinit(struct device *dev, struct class *class); | ||
1072 | 1073 | ||
1073 | void gk20a_debug_dump_device(void *dev); | 1074 | void gk20a_debug_dump_device(void *dev); |
1074 | 1075 | ||
diff --git a/drivers/gpu/nvgpu/pci.c b/drivers/gpu/nvgpu/pci.c index 9ae5e2c6..3057a625 100644 --- a/drivers/gpu/nvgpu/pci.c +++ b/drivers/gpu/nvgpu/pci.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include "gk20a/gk20a.h" | 21 | #include "gk20a/gk20a.h" |
22 | #include "gk20a/platform_gk20a.h" | 22 | #include "gk20a/platform_gk20a.h" |
23 | 23 | ||
24 | #define PCI_INTERFACE_NAME "nvgpu-pci-%s%%s" | 24 | #define PCI_INTERFACE_NAME "card-%s%%s" |
25 | 25 | ||
26 | static int nvgpu_pci_tegra_probe(struct device *dev) | 26 | static int nvgpu_pci_tegra_probe(struct device *dev) |
27 | { | 27 | { |
@@ -135,6 +135,17 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev) | |||
135 | return err; | 135 | return err; |
136 | } | 136 | } |
137 | 137 | ||
138 | static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode) | ||
139 | { | ||
140 | return kasprintf(GFP_KERNEL, "nvgpu-pci/%s", dev_name(dev)); | ||
141 | } | ||
142 | |||
143 | struct class nvgpu_pci_class = { | ||
144 | .owner = THIS_MODULE, | ||
145 | .name = "nvidia-pci-gpu", | ||
146 | .devnode = nvgpu_pci_devnode, | ||
147 | }; | ||
148 | |||
138 | static int nvgpu_pci_probe(struct pci_dev *pdev, | 149 | static int nvgpu_pci_probe(struct pci_dev *pdev, |
139 | const struct pci_device_id *pent) | 150 | const struct pci_device_id *pent) |
140 | { | 151 | { |
@@ -187,7 +198,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, | |||
187 | if (!nodefmt) | 198 | if (!nodefmt) |
188 | return -ENOMEM; | 199 | return -ENOMEM; |
189 | 200 | ||
190 | err = gk20a_user_init(&pdev->dev, nodefmt); | 201 | err = gk20a_user_init(&pdev->dev, nodefmt, &nvgpu_pci_class); |
191 | kfree(nodefmt); | 202 | kfree(nodefmt); |
192 | nodefmt = NULL; | 203 | nodefmt = NULL; |
193 | if (err) | 204 | if (err) |
@@ -248,7 +259,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev) | |||
248 | if (g->remove_support) | 259 | if (g->remove_support) |
249 | g->remove_support(g->dev); | 260 | g->remove_support(g->dev); |
250 | 261 | ||
251 | gk20a_user_deinit(g->dev); | 262 | gk20a_user_deinit(g->dev, &nvgpu_pci_class); |
252 | 263 | ||
253 | debugfs_remove_recursive(platform->debugfs); | 264 | debugfs_remove_recursive(platform->debugfs); |
254 | debugfs_remove_recursive(platform->debugfs_alias); | 265 | debugfs_remove_recursive(platform->debugfs_alias); |
@@ -270,10 +281,17 @@ static struct pci_driver nvgpu_pci_driver = { | |||
270 | 281 | ||
271 | int __init nvgpu_pci_init(void) | 282 | int __init nvgpu_pci_init(void) |
272 | { | 283 | { |
284 | int ret; | ||
285 | |||
286 | ret = class_register(&nvgpu_pci_class); | ||
287 | if (ret) | ||
288 | return ret; | ||
289 | |||
273 | return pci_register_driver(&nvgpu_pci_driver); | 290 | return pci_register_driver(&nvgpu_pci_driver); |
274 | } | 291 | } |
275 | 292 | ||
276 | void __exit nvgpu_pci_exit(void) | 293 | void __exit nvgpu_pci_exit(void) |
277 | { | 294 | { |
278 | pci_unregister_driver(&nvgpu_pci_driver); | 295 | pci_unregister_driver(&nvgpu_pci_driver); |
296 | class_unregister(&nvgpu_pci_class); | ||
279 | } | 297 | } |
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index 78492d3b..3c06652b 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c | |||
@@ -418,7 +418,7 @@ int vgpu_probe(struct platform_device *pdev) | |||
418 | platform->g = gk20a; | 418 | platform->g = gk20a; |
419 | gk20a->dev = dev; | 419 | gk20a->dev = dev; |
420 | 420 | ||
421 | err = gk20a_user_init(dev, INTERFACE_NAME); | 421 | err = gk20a_user_init(dev, INTERFACE_NAME, &nvgpu_class); |
422 | if (err) | 422 | if (err) |
423 | return err; | 423 | return err; |
424 | 424 | ||
@@ -498,7 +498,7 @@ int vgpu_remove(struct platform_device *pdev) | |||
498 | kfree(vgpu_gpd); | 498 | kfree(vgpu_gpd); |
499 | 499 | ||
500 | vgpu_comm_deinit(); | 500 | vgpu_comm_deinit(); |
501 | gk20a_user_deinit(dev); | 501 | gk20a_user_deinit(dev, &nvgpu_class); |
502 | gk20a_get_platform(dev)->g = NULL; | 502 | gk20a_get_platform(dev)->g = NULL; |
503 | kfree(g); | 503 | kfree(g); |
504 | return 0; | 504 | return 0; |