Skip to content

Commit 7ad54c9

Browse files
committed
Merge branch 'drm-fixes-4.9' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
one small powerplay fix and one regression fix for older PX systems and d3cold * 'drm-fixes-4.9' of git://people.freedesktop.org/~agd5f/linux: drm/radeon: fix power state when port pm is unavailable (v2) drm/amdgpu: fix power state when port pm is unavailable drm/amd/powerplay: avoid out of bounds access on array ps.
2 parents 9c76358 + d3ac31f commit 7ad54c9

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct amdgpu_atpx {
3434

3535
static struct amdgpu_atpx_priv {
3636
bool atpx_detected;
37+
bool bridge_pm_usable;
3738
/* handle for device - and atpx */
3839
acpi_handle dhandle;
3940
acpi_handle other_handle;
@@ -205,7 +206,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
205206
atpx->is_hybrid = false;
206207
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
207208
printk("ATPX Hybrid Graphics\n");
208-
atpx->functions.power_cntl = false;
209+
/*
210+
* Disable legacy PM methods only when pcie port PM is usable,
211+
* otherwise the device might fail to power off or power on.
212+
*/
213+
atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
209214
atpx->is_hybrid = true;
210215
}
211216

@@ -480,6 +485,7 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id,
480485
*/
481486
static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
482487
{
488+
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
483489
acpi_handle dhandle, atpx_handle;
484490
acpi_status status;
485491

@@ -494,6 +500,7 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
494500
}
495501
amdgpu_atpx_priv.dhandle = dhandle;
496502
amdgpu_atpx_priv.atpx.handle = atpx_handle;
503+
amdgpu_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
497504
return true;
498505
}
499506

drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
29842984
if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
29852985
data->highest_mclk = memory_clock;
29862986

2987-
performance_level = &(ps->performance_levels
2988-
[ps->performance_level_count++]);
2989-
29902987
PP_ASSERT_WITH_CODE(
29912988
(ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
29922989
"Performance levels exceeds SMC limit!",
29932990
return -EINVAL);
29942991

29952992
PP_ASSERT_WITH_CODE(
2996-
(ps->performance_level_count <=
2993+
(ps->performance_level_count <
29972994
hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
2998-
"Performance levels exceeds Driver limit!",
2999-
return -EINVAL);
2995+
"Performance levels exceeds Driver limit, Skip!",
2996+
return 0);
2997+
2998+
performance_level = &(ps->performance_levels
2999+
[ps->performance_level_count++]);
30003000

30013001
/* Performance levels are arranged from low to high. */
30023002
performance_level->memory_clock = memory_clock;

drivers/gpu/drm/radeon/radeon_atpx_handler.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct radeon_atpx {
3434

3535
static struct radeon_atpx_priv {
3636
bool atpx_detected;
37+
bool bridge_pm_usable;
3738
/* handle for device - and atpx */
3839
acpi_handle dhandle;
3940
struct radeon_atpx atpx;
@@ -203,7 +204,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
203204
atpx->is_hybrid = false;
204205
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
205206
printk("ATPX Hybrid Graphics\n");
206-
atpx->functions.power_cntl = false;
207+
/*
208+
* Disable legacy PM methods only when pcie port PM is usable,
209+
* otherwise the device might fail to power off or power on.
210+
*/
211+
atpx->functions.power_cntl = !radeon_atpx_priv.bridge_pm_usable;
207212
atpx->is_hybrid = true;
208213
}
209214

@@ -474,6 +479,7 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id,
474479
*/
475480
static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
476481
{
482+
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
477483
acpi_handle dhandle, atpx_handle;
478484
acpi_status status;
479485

@@ -487,6 +493,7 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
487493

488494
radeon_atpx_priv.dhandle = dhandle;
489495
radeon_atpx_priv.atpx.handle = atpx_handle;
496+
radeon_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
490497
return true;
491498
}
492499

0 commit comments

Comments
 (0)