gpu: nvgpu: remove interface names and static classes to create dev nodes

Remove static class definition and registration for iGPU and dGPU.
Create the class dynamically in gk20a_user_init() and setup the callback
function to create devnode name based on GPU type.

For now add nvgpu_pci_devnode() callback for dGPU that sets correct
dev node path for dGPUs. For iGPU, Android apparently does not honor dev
node path set in callback and hence override the device name for iGPU
with function nvgpu_devnode().

Destroy the class in gk20a_user_deinit().

This will overall be helpful in adding multiple classes and dev nodes
for each GPU instance in MIG mode.

Set GPU device pointer as the parent of new devices created with
device_create(). This is helpful in getting GPU device name in
callback function nvgpu_pci_devnode().

Update functions to not pass class structure and interface names :
nvgpu_probe()
gk20a_user_init()
gk20a_user_deinit()
nvgpu_remove()

Remove static interface name format like INTERFACE_NAME since it is no
longer needed.

Update GK20A_NUM_CDEVS to 10 since there are 10 dev nodes per GPU right
now.

Jira NVGPU-5648

Change-Id: I5d41db5a0f87fa4a558297fb4135a9fbfcd51080
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2423492
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-10-14 15:16:58 +05:30
committed by Alex Waterman
parent 5e5ac92aee
commit 2a6c473fe6
9 changed files with 97 additions and 81 deletions

View File

@@ -46,7 +46,6 @@
#include "dmabuf_priv.h"
#define BOOT_GPC2CLK_MHZ 2581U
#define PCI_INTERFACE_NAME "card-%s%%s"
static int nvgpu_pci_tegra_probe(struct device *dev)
{
@@ -395,19 +394,6 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
return err;
}
static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode)
{
if (mode)
*mode = S_IRUGO | S_IWUGO;
return kasprintf(GFP_KERNEL, "nvgpu-pci/%s", dev_name(dev));
}
static struct class nvgpu_pci_class = {
.owner = THIS_MODULE,
.name = "nvidia-pci-gpu",
.devnode = nvgpu_pci_devnode,
};
#ifdef CONFIG_PM
static int nvgpu_pci_pm_runtime_resume(struct device *dev)
{
@@ -506,7 +492,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
struct nvgpu_os_linux *l;
struct gk20a *g;
int err;
char nodefmt[64];
struct device_node *np;
u32 device_index = PCI_DEVICE_INDEX(pent->driver_data);
u32 device_flags = PCI_DEVICE_FLAGS(pent->driver_data);
@@ -636,10 +621,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
goto err_free_irq;
}
(void) snprintf(nodefmt, sizeof(nodefmt),
PCI_INTERFACE_NAME, dev_name(&pdev->dev));
err = nvgpu_probe(g, "gpu_pci", nodefmt, &nvgpu_pci_class);
err = nvgpu_probe(g, "gpu_pci");
if (err)
goto err_free_irq;
@@ -756,7 +738,7 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
nvgpu_free_irq(g);
nvgpu_remove(dev, &nvgpu_pci_class);
nvgpu_remove(dev);
#if defined(CONFIG_PCI_MSI)
if (g->msi_enabled)
@@ -830,13 +812,9 @@ int __init nvgpu_pci_init(void)
{
int ret;
ret = class_register(&nvgpu_pci_class);
if (ret)
return ret;
ret = pci_register_driver(&nvgpu_pci_driver);
if (ret)
goto driver_fail;
return ret;
ret = nvgpu_pci_power_init(&nvgpu_pci_driver);
if (ret)
@@ -846,8 +824,6 @@ int __init nvgpu_pci_init(void)
power_init_fail:
pci_unregister_driver(&nvgpu_pci_driver);
driver_fail:
class_unregister(&nvgpu_pci_class);
return ret;
}
@@ -855,6 +831,5 @@ void __exit nvgpu_pci_exit(void)
{
nvgpu_pci_power_exit(&nvgpu_pci_driver);
pci_unregister_driver(&nvgpu_pci_driver);
class_unregister(&nvgpu_pci_class);
nvgpu_pci_power_cleanup();
}