From dc08f78c578e60c0b58e1f489bd9527e4ce2c254 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 24 May 2016 13:50:06 -0700 Subject: 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 Reviewed-on: http://git-master/r/1152745 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Konsta Holtta GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/pci.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/pci.c') 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 @@ #include "gk20a/gk20a.h" #include "gk20a/platform_gk20a.h" -#define PCI_INTERFACE_NAME "nvgpu-pci-%s%%s" +#define PCI_INTERFACE_NAME "card-%s%%s" static int nvgpu_pci_tegra_probe(struct device *dev) { @@ -135,6 +135,17 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev) return err; } +static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode) +{ + return kasprintf(GFP_KERNEL, "nvgpu-pci/%s", dev_name(dev)); +} + +struct class nvgpu_pci_class = { + .owner = THIS_MODULE, + .name = "nvidia-pci-gpu", + .devnode = nvgpu_pci_devnode, +}; + static int nvgpu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pent) { @@ -187,7 +198,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, if (!nodefmt) return -ENOMEM; - err = gk20a_user_init(&pdev->dev, nodefmt); + err = gk20a_user_init(&pdev->dev, nodefmt, &nvgpu_pci_class); kfree(nodefmt); nodefmt = NULL; if (err) @@ -248,7 +259,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev) if (g->remove_support) g->remove_support(g->dev); - gk20a_user_deinit(g->dev); + gk20a_user_deinit(g->dev, &nvgpu_pci_class); debugfs_remove_recursive(platform->debugfs); debugfs_remove_recursive(platform->debugfs_alias); @@ -270,10 +281,17 @@ static struct pci_driver nvgpu_pci_driver = { int __init nvgpu_pci_init(void) { + int ret; + + ret = class_register(&nvgpu_pci_class); + if (ret) + return ret; + return pci_register_driver(&nvgpu_pci_driver); } void __exit nvgpu_pci_exit(void) { pci_unregister_driver(&nvgpu_pci_driver); + class_unregister(&nvgpu_pci_class); } -- cgit v1.2.2