summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2016-05-24 16:50:06 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-05-25 14:58:54 -0400
commitdc08f78c578e60c0b58e1f489bd9527e4ce2c254 (patch)
tree4586da9da29da22ae34fb40b3b825d65d0fe5025 /drivers/gpu/nvgpu/gk20a
parent01a0c3f1b4ed2f43f3943125961f3cfd726ababf (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/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c52
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h5
2 files changed, 33 insertions, 24 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
1000void gk20a_user_deinit(struct device *dev) 1001void 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
1043int gk20a_user_init(struct device *dev, const char *interface_name) 1044int 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;
1102fail: 1111fail:
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
1755struct class nvgpu_class = { 1763struct 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
1068void gk20a_pbus_isr(struct gk20a *g); 1068void gk20a_pbus_isr(struct gk20a *g);
1069 1069
1070int gk20a_user_init(struct device *dev, const char *interface_name); 1070int gk20a_user_init(struct device *dev, const char *interface_name,
1071void gk20a_user_deinit(struct device *dev); 1071 struct class *class);
1072void gk20a_user_deinit(struct device *dev, struct class *class);
1072 1073
1073void gk20a_debug_dump_device(void *dev); 1074void gk20a_debug_dump_device(void *dev);
1074 1075