summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/pci.c
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/pci.c
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/pci.c')
-rw-r--r--drivers/gpu/nvgpu/pci.c24
1 files changed, 21 insertions, 3 deletions
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
26static int nvgpu_pci_tegra_probe(struct device *dev) 26static 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
138static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode)
139{
140 return kasprintf(GFP_KERNEL, "nvgpu-pci/%s", dev_name(dev));
141}
142
143struct class nvgpu_pci_class = {
144 .owner = THIS_MODULE,
145 .name = "nvidia-pci-gpu",
146 .devnode = nvgpu_pci_devnode,
147};
148
138static int nvgpu_pci_probe(struct pci_dev *pdev, 149static 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
271int __init nvgpu_pci_init(void) 282int __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
276void __exit nvgpu_pci_exit(void) 293void __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}