diff options
author | Mahantesh Kumbar <mkumbar@nvidia.com> | 2017-10-12 12:52:18 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-16 16:35:05 -0400 |
commit | 0b6eb9fd80cf53b86de0f8ca4d12db7ead499e40 (patch) | |
tree | 224414760bbb0e6d7b79ab735c02522bef561bb4 /drivers/gpu/nvgpu/common | |
parent | 61b263d83222cd5d2ff3d2d5d699b07ebdf44288 (diff) |
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>
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/pci.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index 50d079bb..0ce2ceef 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c | |||
@@ -443,9 +443,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, | |||
443 | return -EINVAL; | 443 | return -EINVAL; |
444 | } | 444 | } |
445 | 445 | ||
446 | platform = &nvgpu_pci_device[pent->driver_data]; | ||
447 | pci_set_drvdata(pdev, platform); | ||
448 | |||
449 | l = kzalloc(sizeof(*l), GFP_KERNEL); | 446 | l = kzalloc(sizeof(*l), GFP_KERNEL); |
450 | if (!l) { | 447 | if (!l) { |
451 | dev_err(&pdev->dev, "couldn't allocate gk20a support"); | 448 | dev_err(&pdev->dev, "couldn't allocate gk20a support"); |
@@ -456,6 +453,20 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, | |||
456 | 453 | ||
457 | nvgpu_kmem_init(g); | 454 | nvgpu_kmem_init(g); |
458 | 455 | ||
456 | /* Allocate memory to hold platform data*/ | ||
457 | platform = (struct gk20a_platform *)nvgpu_kzalloc( g, | ||
458 | sizeof(struct gk20a_platform)); | ||
459 | if (!platform) { | ||
460 | dev_err(&pdev->dev, "couldn't allocate platform data"); | ||
461 | return -ENOMEM; | ||
462 | } | ||
463 | |||
464 | /* copy detected device data to allocated platform space*/ | ||
465 | memcpy((void *)platform, (void *)&nvgpu_pci_device[pent->driver_data], | ||
466 | sizeof(struct gk20a_platform)); | ||
467 | |||
468 | pci_set_drvdata(pdev, platform); | ||
469 | |||
459 | err = nvgpu_init_enabled_flags(g); | 470 | err = nvgpu_init_enabled_flags(g); |
460 | if (err) { | 471 | if (err) { |
461 | kfree(g); | 472 | kfree(g); |
@@ -563,6 +574,10 @@ static void nvgpu_pci_remove(struct pci_dev *pdev) | |||
563 | enable_irq(g->irq_stall); | 574 | enable_irq(g->irq_stall); |
564 | } | 575 | } |
565 | #endif | 576 | #endif |
577 | |||
578 | /* free allocated platform data space */ | ||
579 | nvgpu_kfree(g, gk20a_get_platform(&pdev->dev)); | ||
580 | |||
566 | gk20a_get_platform(&pdev->dev)->g = NULL; | 581 | gk20a_get_platform(&pdev->dev)->g = NULL; |
567 | gk20a_put(g); | 582 | gk20a_put(g); |
568 | } | 583 | } |