drm/amd: Refactor `amdgpu_aspm` to be evaluated per device
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 17 Feb 2022 05:19:58 +0000 (23:19 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 17 Feb 2022 20:59:05 +0000 (15:59 -0500)
Evaluating `pcie_aspm_enabled` as part of driver probe has the implication
that if one PCIe bridge with an AMD GPU connected doesn't support ASPM
then none of them do.  This is an invalid assumption as the PCIe core will
configure ASPM for individual PCIe bridges.

Create a new helper function that can be called by individual dGPUs to
react to the `amdgpu_aspm` module parameter without having negative results
for other dGPUs on the PCIe bus.

Suggested-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/cik.c
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/si.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/vi.c
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

index 33f5773..566303c 100644 (file)
@@ -1296,6 +1296,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
 int amdgpu_device_pci_reset(struct amdgpu_device *adev);
 bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
 
 void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes,
                                  u64 num_vis_bytes);
index 5b772f2..0cfccea 100644 (file)
@@ -1318,6 +1318,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
        return true;
 }
 
+/**
+ * amdgpu_device_should_use_aspm - check if the device should program ASPM
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Confirm whether the module parameter and pcie bridge agree that ASPM should
+ * be set for this device.
+ *
+ * Returns true if it should be used or false if not.
+ */
+bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev)
+{
+       switch (amdgpu_aspm) {
+       case -1:
+               break;
+       case 0:
+               return false;
+       case 1:
+               return true;
+       default:
+               return false;
+       }
+       return pcie_aspm_enabled(adev->pdev);
+}
+
 /* if we get transitioned to only one device, take VGA back */
 /**
  * amdgpu_device_vga_set_decode - enable/disable vga decode
index d406659..a0b5cf9 100644 (file)
@@ -2008,9 +2008,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
                        return -ENODEV;
        }
 
-       if (amdgpu_aspm == -1 && !pcie_aspm_enabled(pdev))
-               amdgpu_aspm = 0;
-
        if (amdgpu_virtual_display ||
            amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
                supports_atomic = true;
index f10ce74..de6d103 100644 (file)
@@ -1719,7 +1719,7 @@ static void cik_program_aspm(struct amdgpu_device *adev)
        bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
        bool disable_clkreq = false;
 
-       if (amdgpu_aspm == 0)
+       if (!amdgpu_device_should_use_aspm(adev))
                return;
 
        if (pci_is_root_bus(adev->pdev->bus))
index 4b39f27..a4a6362 100644 (file)
@@ -522,7 +522,7 @@ static void nv_pcie_gen3_enable(struct amdgpu_device *adev)
 
 static void nv_program_aspm(struct amdgpu_device *adev)
 {
-       if (!amdgpu_aspm)
+       if (!amdgpu_device_should_use_aspm(adev))
                return;
 
        if (!(adev->flags & AMD_IS_APU) &&
index e6d2f74..7f99e13 100644 (file)
@@ -2453,7 +2453,7 @@ static void si_program_aspm(struct amdgpu_device *adev)
        bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
        bool disable_clkreq = false;
 
-       if (amdgpu_aspm == 0)
+       if (!amdgpu_device_should_use_aspm(adev))
                return;
 
        if (adev->flags & AMD_IS_APU)
index 25e1ee2..35d2ebd 100644 (file)
@@ -670,7 +670,7 @@ static void soc15_pcie_gen3_enable(struct amdgpu_device *adev)
 
 static void soc15_program_aspm(struct amdgpu_device *adev)
 {
-       if (!amdgpu_aspm)
+       if (!amdgpu_device_should_use_aspm(adev))
                return;
 
        if (!(adev->flags & AMD_IS_APU) &&
index 6645ebb..039b90c 100644 (file)
@@ -1140,7 +1140,7 @@ static void vi_program_aspm(struct amdgpu_device *adev)
        bool bL1SS = false;
        bool bClkReqSupport = true;
 
-       if (!amdgpu_aspm)
+       if (!amdgpu_device_should_use_aspm(adev))
                return;
 
        if (adev->flags & AMD_IS_APU ||
index 4f0bc18..d9d634c 100644 (file)
@@ -348,7 +348,7 @@ sienna_cichlid_get_allowed_feature_mask(struct smu_context *smu,
        if (smu->dc_controlled_by_gpio)
        *(uint64_t *)feature_mask |= FEATURE_MASK(FEATURE_ACDC_BIT);
 
-       if (amdgpu_aspm)
+       if (amdgpu_device_should_use_aspm(adev))
                *(uint64_t *)feature_mask |= FEATURE_MASK(FEATURE_DS_LCLK_BIT);
 
        return 0;