There's no need to keep vgaswitcheroo around for HG
systems.  They don't use muxes and their power control
is handled via ACPI.

Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 38 +++++++++-------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 34 ++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    |  9 ++---
 4 files changed, 34 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index b5310b35721c..d47626ce9bc5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1260,7 +1260,7 @@ void amdgpu_device_program_register_sequence(struct 
amdgpu_device *adev,
                                             const u32 *registers,
                                             const u32 array_size);
 
-bool amdgpu_device_supports_atpx(struct drm_device *dev);
+bool amdgpu_device_supports_px(struct drm_device *dev);
 bool amdgpu_device_supports_boco(struct drm_device *dev);
 bool amdgpu_device_supports_baco(struct drm_device *dev);
 bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6eb3b4d2c9b2..ac5f7837285b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -211,18 +211,18 @@ static DEVICE_ATTR(serial_number, S_IRUGO,
                amdgpu_device_get_serial_number, NULL);
 
 /**
- * amdgpu_device_supports_atpx - Is the device a dGPU with HG/PX power control
+ * amdgpu_device_supports_px - Is the device a dGPU with ATPX power control
  *
  * @dev: drm_device pointer
  *
- * Returns true if the device is a dGPU with HG/PX power control,
+ * Returns true if the device is a dGPU with ATPX power control,
  * otherwise return false.
  */
-bool amdgpu_device_supports_atpx(struct drm_device *dev)
+bool amdgpu_device_supports_px(struct drm_device *dev)
 {
        struct amdgpu_device *adev = drm_to_adev(dev);
 
-       if (adev->flags & AMD_IS_PX)
+       if ((adev->flags & AMD_IS_PX) && !amdgpu_is_atpx_hybrid())
                return true;
        return false;
 }
@@ -232,14 +232,15 @@ bool amdgpu_device_supports_atpx(struct drm_device *dev)
  *
  * @dev: drm_device pointer
  *
- * Returns true if the device is a dGPU with HG/PX power control,
+ * Returns true if the device is a dGPU with ACPI power control,
  * otherwise return false.
  */
 bool amdgpu_device_supports_boco(struct drm_device *dev)
 {
        struct amdgpu_device *adev = drm_to_adev(dev);
 
-       if (adev->has_pr3)
+       if (adev->has_pr3 ||
+           ((adev->flags & AMD_IS_PX) && amdgpu_is_atpx_hybrid()))
                return true;
        return false;
 }
@@ -1429,7 +1430,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev 
*pdev,
        struct drm_device *dev = pci_get_drvdata(pdev);
        int r;
 
-       if (amdgpu_device_supports_atpx(dev) && state == VGA_SWITCHEROO_OFF)
+       if (amdgpu_device_supports_px(dev) && state == VGA_SWITCHEROO_OFF)
                return;
 
        if (state == VGA_SWITCHEROO_ON) {
@@ -3213,7 +3214,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        struct drm_device *ddev = adev_to_drm(adev);
        struct pci_dev *pdev = adev->pdev;
        int r, i;
-       bool atpx = false;
+       bool px = false;
        u32 max_MBps;
 
        adev->shutdown = false;
@@ -3385,16 +3386,12 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
                vga_client_register(adev->pdev, adev, NULL, 
amdgpu_device_vga_set_decode);
 
-       if (amdgpu_device_supports_atpx(ddev))
-               atpx = true;
-       if (amdgpu_has_atpx() &&
-           (amdgpu_is_atpx_hybrid() ||
-            amdgpu_has_atpx_dgpu_power_cntl()) &&
-           !pci_is_thunderbolt_attached(adev->pdev))
+       if (amdgpu_device_supports_px(ddev)) {
+               px = true;
                vga_switcheroo_register_client(adev->pdev,
-                                              &amdgpu_switcheroo_ops, atpx);
-       if (atpx)
+                                              &amdgpu_switcheroo_ops, px);
                vga_switcheroo_init_domain_pm_ops(adev->dev, 
&adev->vga_pm_domain);
+       }
 
        if (amdgpu_emu_mode == 1) {
                /* post the asic on emulation mode */
@@ -3576,7 +3573,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
 failed:
        amdgpu_vf_error_trans_all(adev);
-       if (atpx)
+       if (px)
                vga_switcheroo_fini_domain_pm_ops(adev->dev);
 
 failed_unmap:
@@ -3636,13 +3633,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 
        kfree(adev->bios);
        adev->bios = NULL;
-       if (amdgpu_has_atpx() &&
-           (amdgpu_is_atpx_hybrid() ||
-            amdgpu_has_atpx_dgpu_power_cntl()) &&
-           !pci_is_thunderbolt_attached(adev->pdev))
+       if (amdgpu_device_supports_px(adev_to_drm(adev))) {
                vga_switcheroo_unregister_client(adev->pdev);
-       if (amdgpu_device_supports_atpx(adev_to_drm(adev)))
                vga_switcheroo_fini_domain_pm_ops(adev->dev);
+       }
        if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
                vga_client_register(adev->pdev, NULL, NULL, NULL);
        if (adev->rio_mem)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 8d4fbee01011..3e6bb7d79652 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1301,9 +1301,7 @@ static int amdgpu_pmops_prepare(struct device *dev)
        /* Return a positive number here so
         * DPM_FLAG_SMART_SUSPEND works properly
         */
-       if ((amdgpu_device_supports_atpx(drm_dev) &&
-           amdgpu_is_atpx_hybrid()) ||
-           amdgpu_device_supports_boco(drm_dev))
+       if (amdgpu_device_supports_boco(drm_dev))
                return pm_runtime_suspended(dev) &&
                        pm_suspend_via_firmware();
 
@@ -1392,7 +1390,7 @@ static int amdgpu_pmops_runtime_suspend(struct device 
*dev)
        }
 
        adev->in_runpm = true;
-       if (amdgpu_device_supports_atpx(drm_dev))
+       if (amdgpu_device_supports_px(drm_dev))
                drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
        ret = amdgpu_device_suspend(drm_dev, false);
@@ -1401,16 +1399,14 @@ static int amdgpu_pmops_runtime_suspend(struct device 
*dev)
                return ret;
        }
 
-       if (amdgpu_device_supports_atpx(drm_dev)) {
+       if (amdgpu_device_supports_px(drm_dev)) {
                /* Only need to handle PCI state in the driver for ATPX
                 * PCI core handles it for _PR3.
                 */
-               if (!amdgpu_is_atpx_hybrid()) {
-                       amdgpu_device_cache_pci_state(pdev);
-                       pci_disable_device(pdev);
-                       pci_ignore_hotplug(pdev);
-                       pci_set_power_state(pdev, PCI_D3cold);
-               }
+               amdgpu_device_cache_pci_state(pdev);
+               pci_disable_device(pdev);
+               pci_ignore_hotplug(pdev);
+               pci_set_power_state(pdev, PCI_D3cold);
                drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
        } else if (amdgpu_device_supports_baco(drm_dev)) {
                amdgpu_device_baco_enter(drm_dev);
@@ -1429,19 +1425,17 @@ static int amdgpu_pmops_runtime_resume(struct device 
*dev)
        if (!adev->runpm)
                return -EINVAL;
 
-       if (amdgpu_device_supports_atpx(drm_dev)) {
+       if (amdgpu_device_supports_px(drm_dev)) {
                drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
                /* Only need to handle PCI state in the driver for ATPX
                 * PCI core handles it for _PR3.
                 */
-               if (!amdgpu_is_atpx_hybrid()) {
-                       pci_set_power_state(pdev, PCI_D0);
-                       amdgpu_device_load_pci_state(pdev);
-                       ret = pci_enable_device(pdev);
-                       if (ret)
-                               return ret;
-               }
+               pci_set_power_state(pdev, PCI_D0);
+               amdgpu_device_load_pci_state(pdev);
+               ret = pci_enable_device(pdev);
+               if (ret)
+                       return ret;
                pci_set_master(pdev);
        } else if (amdgpu_device_supports_boco(drm_dev)) {
                /* Only need to handle PCI state in the driver for ATPX
@@ -1452,7 +1446,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
                amdgpu_device_baco_exit(drm_dev);
        }
        ret = amdgpu_device_resume(drm_dev, false);
-       if (amdgpu_device_supports_atpx(drm_dev))
+       if (amdgpu_device_supports_px(drm_dev))
                drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
        adev->in_runpm = false;
        return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8e6ef4d8b7ee..86eeeb4f3513 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -161,7 +161,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, 
unsigned long flags)
                goto out;
        }
 
-       if (amdgpu_device_supports_atpx(dev) &&
+       if (amdgpu_device_supports_px(dev) &&
            (amdgpu_runtime_pm != 0)) { /* enable runpm by default for atpx */
                adev->runpm = true;
                dev_info(adev->dev, "Using ATPX for runtime pm\n");
@@ -202,13 +202,10 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, 
unsigned long flags)
 
        if (adev->runpm) {
                /* only need to skip on ATPX */
-               if (amdgpu_device_supports_atpx(dev) &&
-                   !amdgpu_is_atpx_hybrid())
+               if (amdgpu_device_supports_px(dev))
                        dev_pm_set_driver_flags(dev->dev, 
DPM_FLAG_NO_DIRECT_COMPLETE);
                /* we want direct complete for BOCO */
-               if ((amdgpu_device_supports_atpx(dev) &&
-                   amdgpu_is_atpx_hybrid()) ||
-                   amdgpu_device_supports_boco(dev))
+               if (amdgpu_device_supports_boco(dev))
                        dev_pm_set_driver_flags(dev->dev, 
DPM_FLAG_SMART_PREPARE |
                                                DPM_FLAG_SMART_SUSPEND |
                                                DPM_FLAG_MAY_SKIP_RESUME);
-- 
2.29.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to