mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: Allocate memory for dGPU platform
- Allocate memory for platform data for each dgpu device detected on PCIe, - Copy detected device static data to allocated platform data - Free allocated space in nvgpu_pci_remove() Issue: Static platform data is overwritten When two same SKU/device-id dGPU connected on single platform which cause accessing wrong dGPU space, Fix: Fixing issue by allocating space dynamically for each dGPU device detected & copy data from detected dGPU static data. JIRA NVGPUGV100-18 Change-Id: Idf2d2d6d2016b831c21b9da6f8ee38b34304bd12 Signed-off-by: Mahantesh Kumbar <mkumbar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1577913 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
61b263d832
commit
0b6eb9fd80
@@ -443,9 +443,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
platform = &nvgpu_pci_device[pent->driver_data];
|
||||
pci_set_drvdata(pdev, platform);
|
||||
|
||||
l = kzalloc(sizeof(*l), GFP_KERNEL);
|
||||
if (!l) {
|
||||
dev_err(&pdev->dev, "couldn't allocate gk20a support");
|
||||
@@ -456,6 +453,20 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
|
||||
nvgpu_kmem_init(g);
|
||||
|
||||
/* Allocate memory to hold platform data*/
|
||||
platform = (struct gk20a_platform *)nvgpu_kzalloc( g,
|
||||
sizeof(struct gk20a_platform));
|
||||
if (!platform) {
|
||||
dev_err(&pdev->dev, "couldn't allocate platform data");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* copy detected device data to allocated platform space*/
|
||||
memcpy((void *)platform, (void *)&nvgpu_pci_device[pent->driver_data],
|
||||
sizeof(struct gk20a_platform));
|
||||
|
||||
pci_set_drvdata(pdev, platform);
|
||||
|
||||
err = nvgpu_init_enabled_flags(g);
|
||||
if (err) {
|
||||
kfree(g);
|
||||
@@ -563,6 +574,10 @@ static void nvgpu_pci_remove(struct pci_dev *pdev)
|
||||
enable_irq(g->irq_stall);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* free allocated platform data space */
|
||||
nvgpu_kfree(g, gk20a_get_platform(&pdev->dev));
|
||||
|
||||
gk20a_get_platform(&pdev->dev)->g = NULL;
|
||||
gk20a_put(g);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user