OSDN Git Service

drm/amdgpu: Handle IOMMU enabled case.
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Mon, 17 May 2021 14:38:51 +0000 (10:38 -0400)
committerAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Thu, 20 May 2021 03:50:27 +0000 (23:50 -0400)
Problem:
Handle all DMA IOMMU group related dependencies before the
group is removed. Those manifest themself in that when IOMMU
enabled DMA map/unmap is dependent on the presence of IOMMU
group the device belongs to but, this group is released once
the device is removed from PCI topology.

Fix:
Expedite all such unmap operations to pci remove driver callback.

v5: Drop IOMMU notifier and switch to lockless call to ttm_tt_unpopulate
v6: Drop the BO unamp list
v7:
Drop amdgpu_gart_fini
In amdgpu_ih_ring_fini do uncinditional  check (!ih->ring)
to avoid freeing uniniitalized rings.
Call amdgpu_ih_ring_fini unconditionally.
v8: Add deatiled explanation

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210517143851.475058-1-andrey.grodzovsky@amd.com
18 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
drivers/gpu/drm/amd/amdgpu/cik_ih.c
drivers/gpu/drm/amd/amdgpu/cz_ih.c
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
drivers/gpu/drm/amd/amdgpu/iceland_ih.c
drivers/gpu/drm/amd/amdgpu/navi10_ih.c
drivers/gpu/drm/amd/amdgpu/si_ih.c
drivers/gpu/drm/amd/amdgpu/tonga_ih.c
drivers/gpu/drm/amd/amdgpu/vega10_ih.c
drivers/gpu/drm/amd/amdgpu/vega20_ih.c

index bc75e35..f20a650 100644 (file)
@@ -3256,7 +3256,6 @@ static const struct attribute *amdgpu_dev_attributes[] = {
        NULL
 };
 
-
 /**
  * amdgpu_device_init - initialize the driver
  *
@@ -3696,12 +3695,13 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
                amdgpu_ucode_sysfs_fini(adev);
        sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
 
-
        amdgpu_fbdev_fini(adev);
 
        amdgpu_irq_fini_hw(adev);
 
        amdgpu_device_ip_fini_early(adev);
+
+       amdgpu_gart_dummy_page_fini(adev);
 }
 
 void amdgpu_device_fini_sw(struct amdgpu_device *adev)
index c5a9a4f..6460cf7 100644 (file)
@@ -92,7 +92,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device *adev)
  *
  * Frees the dummy page used by the driver (all asics).
  */
-static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
 {
        if (!adev->dummy_page_addr)
                return;
@@ -365,15 +365,3 @@ int amdgpu_gart_init(struct amdgpu_device *adev)
 
        return 0;
 }
-
-/**
- * amdgpu_gart_fini - tear down the driver info for managing the gart
- *
- * @adev: amdgpu_device pointer
- *
- * Tear down the gart driver info and free the dummy page (all asics).
- */
-void amdgpu_gart_fini(struct amdgpu_device *adev)
-{
-       amdgpu_gart_dummy_page_fini(adev);
-}
index a25fe97..030b9d4 100644 (file)
@@ -57,7 +57,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev);
 int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
 void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
 int amdgpu_gart_init(struct amdgpu_device *adev);
-void amdgpu_gart_fini(struct amdgpu_device *adev);
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev);
 int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
                       int pages);
 int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
index faaa6aa..433469a 100644 (file)
@@ -115,9 +115,11 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih,
  */
 void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih)
 {
+
+       if (!ih->ring)
+               return;
+
        if (ih->use_bus_addr) {
-               if (!ih->ring)
-                       return;
 
                /* add 8 bytes for the rptr/wptr shadows and
                 * add them to the end of the ring allocation.
index 233b64d..32ce0e6 100644 (file)
@@ -361,6 +361,11 @@ void amdgpu_irq_fini_hw(struct amdgpu_device *adev)
                if (!amdgpu_device_has_dc_support(adev))
                        flush_work(&adev->hotplug_work);
        }
+
+       amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
+       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
+       amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
+       amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
 }
 
 /**
index 183d44a..df385ff 100644 (file)
@@ -310,7 +310,6 @@ static int cik_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
        amdgpu_irq_remove_domain(adev);
 
        return 0;
index d327439..b8c47e0 100644 (file)
@@ -302,7 +302,6 @@ static int cz_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
        amdgpu_irq_remove_domain(adev);
 
        return 0;
index 498b28a..192bdcf 100644 (file)
@@ -953,7 +953,6 @@ static int gmc_v10_0_sw_init(void *handle)
 static void gmc_v10_0_gart_fini(struct amdgpu_device *adev)
 {
        amdgpu_gart_table_vram_free(adev);
-       amdgpu_gart_fini(adev);
 }
 
 static int gmc_v10_0_sw_fini(void *handle)
index 405d6ad..0e81e03 100644 (file)
@@ -898,7 +898,6 @@ static int gmc_v6_0_sw_fini(void *handle)
        amdgpu_vm_manager_fini(adev);
        amdgpu_gart_table_vram_free(adev);
        amdgpu_bo_fini(adev);
-       amdgpu_gart_fini(adev);
        release_firmware(adev->gmc.fw);
        adev->gmc.fw = NULL;
 
index 210ada2..0795ea7 100644 (file)
@@ -1085,7 +1085,6 @@ static int gmc_v7_0_sw_fini(void *handle)
        kfree(adev->gmc.vm_fault_info);
        amdgpu_gart_table_vram_free(adev);
        amdgpu_bo_fini(adev);
-       amdgpu_gart_fini(adev);
        release_firmware(adev->gmc.fw);
        adev->gmc.fw = NULL;
 
index e4f27b3..492ebed 100644 (file)
@@ -1201,7 +1201,6 @@ static int gmc_v8_0_sw_fini(void *handle)
        kfree(adev->gmc.vm_fault_info);
        amdgpu_gart_table_vram_free(adev);
        amdgpu_bo_fini(adev);
-       amdgpu_gart_fini(adev);
        release_firmware(adev->gmc.fw);
        adev->gmc.fw = NULL;
 
index 455bb91..2bb001b 100644 (file)
@@ -1602,7 +1602,6 @@ static int gmc_v9_0_sw_fini(void *handle)
        amdgpu_gart_table_vram_free(adev);
        amdgpu_bo_unref(&adev->gmc.pdb0_bo);
        amdgpu_bo_fini(adev);
-       amdgpu_gart_fini(adev);
 
        return 0;
 }
index da96c60..ddfe4ea 100644 (file)
@@ -301,7 +301,6 @@ static int iceland_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
        amdgpu_irq_remove_domain(adev);
 
        return 0;
index 5eea455..941d464 100644 (file)
@@ -570,10 +570,6 @@ static int navi10_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
 
        return 0;
 }
index 751307f..9a24f17 100644 (file)
@@ -176,7 +176,6 @@ static int si_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
 
        return 0;
 }
index 973d80e..b08905d 100644 (file)
@@ -313,7 +313,6 @@ static int tonga_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
        amdgpu_irq_remove_domain(adev);
 
        return 0;
index dead9c2..32ec4b8 100644 (file)
@@ -514,10 +514,6 @@ static int vega10_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
 
        return 0;
 }
index 58993ae..f51dfc3 100644 (file)
@@ -566,10 +566,6 @@ static int vega20_ih_sw_fini(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        amdgpu_irq_fini_sw(adev);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
-       amdgpu_ih_ring_fini(adev, &adev->irq.ih);
 
        return 0;
 }