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
This commit is contained in:
Terje Bergstrom
2016-05-24 13:50:06 -07:00
parent 01a0c3f1b4
commit dc08f78c57
4 changed files with 56 additions and 29 deletions

View File

@@ -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);
}