]> git.baikalelectronics.ru Git - kernel.git/commitdiff
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 bc75e35dd8d8d620b0a272abba5ac7b4701cfb50..f20a65017db56e414373de08837044b6b9d1f342 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 c5a9a4fb10d2bde0767b8f76d95d633e5f44709f..6460cf723f0a068d81fa5d0150ef2222b11be9bc 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 a25fe97b0196da4b6754e3a7bfbc62c4cab906e8..030b9d4c736ac5b12c15f6cfe8425a8fcba599a9 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 faaa6aa2faaf2aba9c32bdd4497c985cbfbc4571..433469ace6f458e77c771815f702300d45545dca 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 233b64dab94b215a31420a37e2e8656c06920126..32ce0e679dc7855b501d57791436539329409da0 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 183d44a6583c03644beb6233cbcf3b56adc6d0ce..df385ffc97683e8ac2892753bb862aa36a30c852 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 d32743949003d9011faeccbd6a0ca8e44c281d58..b8c47e0cf37ad53bcb3f1afe161e6356b91789e3 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 498b28a35f5b6bfcb4f9663469759340afeac670..192bdcf592602c7694d217b6907057c81d2c576e 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 405d6ad09022ca8a63fbcba78a418481fcdb1c4e..0e81e03e9b498762febe0787028bf22e31d1d3d6 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 210ada2289ec9cf931991f4f37b448474306ca9e..0795ea736573d53945e58af67a92bbed736d8e81 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 e4f27b3f28fb586ac1a3fc0748652d47a3c7f3ea..492ebed2915be44d92c285fd14fc95d30b7d27c0 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 455bb91060d0bc571150fa20afa6a395e3345750..2bb001b3f140c43437f9a4b9f73096a49f6d27a0 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 da96c6013477c563a14f7453e2a20734d6b1627b..ddfe4eaeea05ec40b0045867c52302590be11038 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 5eea4550b85648fa19fddbe894e626994af5569a..941d464a2b47c9617e9e5f63ea752759dcf0ad2d 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 751307f3252ceb5e968e794a986ddde1471619b3..9a24f17a57502edaa744451bd312dfcd8b3d678c 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 973d80ec7f6c379444c8884afcd1e58e16668897..b08905d1c00f06c65913964cb0e6b8b0ba0e8261 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 dead9c2fbd4c5681aaeb6fbd156c07e710801a5a..32ec4b8e806af2894f37f29104e5142c531e065b 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 58993ae1fe11a658953ac34784f5249ca5a4379f..f51dfc38ac656ed53a6543cf52d475844b343d5f 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;
 }