summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/amd/pm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-02-02 03:32:47 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-02-02 03:32:47 +0000
commit5a4f9e6a964ce45ef373b14cc2c7b3be8c1ce619 (patch)
tree0f227edcd3d309bf3eae7fce6c4ae64a201108a9 /sys/dev/pci/drm/amd/pm
parent1af831fc62acb94bdc3963f0b23413ad959977ac (diff)
drm/amdgpu/pm: Fix the power source flag error
From Ma Jun dcda362dc5b4d5aa0df9d1511cb9427df04d2d11 in linux-6.6.y/6.6.15 ca1ffb174f16b699c536734fc12a4162097c49f4 in mainline linux
Diffstat (limited to 'sys/dev/pci/drm/amd/pm')
-rw-r--r--sys/dev/pci/drm/amd/pm/swsmu/amdgpu_smu.c13
-rw-r--r--sys/dev/pci/drm/amd/pm/swsmu/smu11/smu_v11_0.c2
-rw-r--r--sys/dev/pci/drm/amd/pm/swsmu/smu13/smu_v13_0.c2
3 files changed, 7 insertions, 10 deletions
diff --git a/sys/dev/pci/drm/amd/pm/swsmu/amdgpu_smu.c b/sys/dev/pci/drm/amd/pm/swsmu/amdgpu_smu.c
index 69ce8224424..7c4a436ded3 100644
--- a/sys/dev/pci/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/sys/dev/pci/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -24,6 +24,7 @@
#include <linux/firmware.h>
#include <linux/pci.h>
+#include <linux/power_supply.h>
#include <linux/reboot.h>
#include "amdgpu.h"
@@ -741,16 +742,8 @@ static int smu_late_init(void *handle)
* handle the switch automatically. Driver involvement
* is unnecessary.
*/
- if (!smu->dc_controlled_by_gpio) {
- ret = smu_set_power_source(smu,
- adev->pm.ac_power ? SMU_POWER_SOURCE_AC :
- SMU_POWER_SOURCE_DC);
- if (ret) {
- dev_err(adev->dev, "Failed to switch to %s mode!\n",
- adev->pm.ac_power ? "AC" : "DC");
- return ret;
- }
- }
+ adev->pm.ac_power = power_supply_is_system_supplied() > 0;
+ smu_set_ac_dc(smu);
if ((adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 1)) ||
(adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 3)))
diff --git a/sys/dev/pci/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/sys/dev/pci/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index a447351a42c..0a46bff1781 100644
--- a/sys/dev/pci/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/sys/dev/pci/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1441,10 +1441,12 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
case 0x3:
dev_dbg(adev->dev, "Switched to AC mode!\n");
schedule_work(&smu->interrupt_work);
+ adev->pm.ac_power = true;
break;
case 0x4:
dev_dbg(adev->dev, "Switched to DC mode!\n");
schedule_work(&smu->interrupt_work);
+ adev->pm.ac_power = false;
break;
case 0x7:
/*
diff --git a/sys/dev/pci/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/sys/dev/pci/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index ecc687ac846..8f9e4414345 100644
--- a/sys/dev/pci/drm/amd/pm/swsmu/smu13/smu_v13_0.c
+++ b/sys/dev/pci/drm/amd/pm/swsmu/smu13/smu_v13_0.c
@@ -1377,10 +1377,12 @@ static int smu_v13_0_irq_process(struct amdgpu_device *adev,
case 0x3:
dev_dbg(adev->dev, "Switched to AC mode!\n");
smu_v13_0_ack_ac_dc_interrupt(smu);
+ adev->pm.ac_power = true;
break;
case 0x4:
dev_dbg(adev->dev, "Switched to DC mode!\n");
smu_v13_0_ack_ac_dc_interrupt(smu);
+ adev->pm.ac_power = false;
break;
case 0x7:
/*