Re: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / DCE3.1 systems

2026-05-18 Thread Alex Deucher
On Mon, May 18, 2026 at 10:40 AM Gilles Risch  wrote:
>
> Am Mo., 18. Mai 2026 um 16:13 Uhr schrieb Alex Deucher 
> :
> >
> > On Sat, May 16, 2026 at 2:52 PM Gilles Risch  wrote:
> > >
> > > After suspend/resume the internal eDP display on iMac11,1 (and
> > > potentially other DCE3.1 systems) stays dark because
> > > atombios_set_edp_panel_power() skips panel power control for
> > > anything older than DCE4.
> > >
> > > Fix this by:
> > > - Extending atombios_set_edp_panel_power() to also handle DCE3.1
> > >   by changing the !ASIC_IS_DCE4() guard to !ASIC_IS_DCE31().
> > >   HPD polling works correctly on DCE3.1 (verified: HPD is asserted
> > >   at iteration 0 on iMac11,1).
> > > - Issuing ATOM_ENCODER_CMD_DP_VIDEO_ON/OFF for DCE3.1 in addition
> > >   to DCE4+.
> > >
> > > Tested on iMac11,1 (Mobility Radeon HD 4850, RV770/DCE3.1).
> > >
> > > Signed-off-by: Gilles Risch 
> > > ---
> > >  drivers/gpu/drm/radeon/atombios_encoders.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c 
> > > b/drivers/gpu/drm/radeon/atombios_encoders.c
> > > index 4e984973c043..b62fd713efcf 100644
> > > --- a/drivers/gpu/drm/radeon/atombios_encoders.c
> > > +++ b/drivers/gpu/drm/radeon/atombios_encoders.c
> > > @@ -1383,7 +1383,7 @@ atombios_set_edp_panel_power(struct drm_connector 
> > > *connector, int action)
> > > if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
> > > goto done;
> > >
> > > -   if (!ASIC_IS_DCE4(rdev))
> > > +   if (!ASIC_IS_DCE31(rdev))
> > > goto done;
> > >
> > > if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) &&
> > > @@ -1707,7 +1707,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> > > *encoder, int mode)
> > > if 
> > > (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
> > > /* DP_SET_POWER_D0 is set in radeon_dp_link_train 
> > > */
> > > radeon_dp_link_train(encoder, connector);
> > > -   if (ASIC_IS_DCE4(rdev))
> > > +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev))
> > > atombios_dig_encoder_setup(encoder, 
> > > ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
> > > }
> > > if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
> > > @@ -1724,7 +1724,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> > > *encoder, int mode)
> > > case DRM_MODE_DPMS_SUSPEND:
> > > case DRM_MODE_DPMS_OFF:
> > >
> > > -   if (ASIC_IS_DCE4(rdev)) {
> > > +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev)) {
> > > if 
> > > (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector)
> > > atombios_dig_encoder_setup(encoder, 
> > > ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0);
> > > }
> >
> > These changes don't make sense and will break other DCE3.c boards.   I
> > had the attached patch from you in one of my old branches, does it fix
> > the issue?
> >
> > Alex
>
> While the initial attached patch resolved the dark screen issue after
> a fresh boot, this follow-up patch addresses the same problem
> occurring after resuming from suspend. Should I used dmi_match() to
> avoid breaking other DCE3.c boards?

Yes.  Even that is a hack.  You are effectively just skipping some of
the required programming sequences.  Presumably the mac is wired up
strangely or there are issues with its atom tables.  Ideally we'd sort
that out, but this hardware is pretty old so I'm ok with a hack.

Alex


Re: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / DCE3.1 systems

2026-05-18 Thread Gilles Risch
Am Mo., 18. Mai 2026 um 16:13 Uhr schrieb Alex Deucher :
>
> On Sat, May 16, 2026 at 2:52 PM Gilles Risch  wrote:
> >
> > After suspend/resume the internal eDP display on iMac11,1 (and
> > potentially other DCE3.1 systems) stays dark because
> > atombios_set_edp_panel_power() skips panel power control for
> > anything older than DCE4.
> >
> > Fix this by:
> > - Extending atombios_set_edp_panel_power() to also handle DCE3.1
> >   by changing the !ASIC_IS_DCE4() guard to !ASIC_IS_DCE31().
> >   HPD polling works correctly on DCE3.1 (verified: HPD is asserted
> >   at iteration 0 on iMac11,1).
> > - Issuing ATOM_ENCODER_CMD_DP_VIDEO_ON/OFF for DCE3.1 in addition
> >   to DCE4+.
> >
> > Tested on iMac11,1 (Mobility Radeon HD 4850, RV770/DCE3.1).
> >
> > Signed-off-by: Gilles Risch 
> > ---
> >  drivers/gpu/drm/radeon/atombios_encoders.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c 
> > b/drivers/gpu/drm/radeon/atombios_encoders.c
> > index 4e984973c043..b62fd713efcf 100644
> > --- a/drivers/gpu/drm/radeon/atombios_encoders.c
> > +++ b/drivers/gpu/drm/radeon/atombios_encoders.c
> > @@ -1383,7 +1383,7 @@ atombios_set_edp_panel_power(struct drm_connector 
> > *connector, int action)
> > if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
> > goto done;
> >
> > -   if (!ASIC_IS_DCE4(rdev))
> > +   if (!ASIC_IS_DCE31(rdev))
> > goto done;
> >
> > if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) &&
> > @@ -1707,7 +1707,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> > *encoder, int mode)
> > if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) 
> > && connector) {
> > /* DP_SET_POWER_D0 is set in radeon_dp_link_train */
> > radeon_dp_link_train(encoder, connector);
> > -   if (ASIC_IS_DCE4(rdev))
> > +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev))
> > atombios_dig_encoder_setup(encoder, 
> > ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
> > }
> > if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
> > @@ -1724,7 +1724,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> > *encoder, int mode)
> > case DRM_MODE_DPMS_SUSPEND:
> > case DRM_MODE_DPMS_OFF:
> >
> > -   if (ASIC_IS_DCE4(rdev)) {
> > +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev)) {
> > if 
> > (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector)
> > atombios_dig_encoder_setup(encoder, 
> > ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0);
> > }
>
> These changes don't make sense and will break other DCE3.c boards.   I
> had the attached patch from you in one of my old branches, does it fix
> the issue?
>
> Alex

While the initial attached patch resolved the dark screen issue after
a fresh boot, this follow-up patch addresses the same problem
occurring after resuming from suspend. Should I used dmi_match() to
avoid breaking other DCE3.c boards?

Regards,
Gilles


Re: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / DCE3.1 systems

2026-05-18 Thread Alex Deucher
On Sat, May 16, 2026 at 2:52 PM Gilles Risch  wrote:
>
> After suspend/resume the internal eDP display on iMac11,1 (and
> potentially other DCE3.1 systems) stays dark because
> atombios_set_edp_panel_power() skips panel power control for
> anything older than DCE4.
>
> Fix this by:
> - Extending atombios_set_edp_panel_power() to also handle DCE3.1
>   by changing the !ASIC_IS_DCE4() guard to !ASIC_IS_DCE31().
>   HPD polling works correctly on DCE3.1 (verified: HPD is asserted
>   at iteration 0 on iMac11,1).
> - Issuing ATOM_ENCODER_CMD_DP_VIDEO_ON/OFF for DCE3.1 in addition
>   to DCE4+.
>
> Tested on iMac11,1 (Mobility Radeon HD 4850, RV770/DCE3.1).
>
> Signed-off-by: Gilles Risch 
> ---
>  drivers/gpu/drm/radeon/atombios_encoders.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c 
> b/drivers/gpu/drm/radeon/atombios_encoders.c
> index 4e984973c043..b62fd713efcf 100644
> --- a/drivers/gpu/drm/radeon/atombios_encoders.c
> +++ b/drivers/gpu/drm/radeon/atombios_encoders.c
> @@ -1383,7 +1383,7 @@ atombios_set_edp_panel_power(struct drm_connector 
> *connector, int action)
> if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
> goto done;
>
> -   if (!ASIC_IS_DCE4(rdev))
> +   if (!ASIC_IS_DCE31(rdev))
> goto done;
>
> if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) &&
> @@ -1707,7 +1707,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> *encoder, int mode)
> if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && 
> connector) {
> /* DP_SET_POWER_D0 is set in radeon_dp_link_train */
> radeon_dp_link_train(encoder, connector);
> -   if (ASIC_IS_DCE4(rdev))
> +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev))
> atombios_dig_encoder_setup(encoder, 
> ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
> }
> if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
> @@ -1724,7 +1724,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder 
> *encoder, int mode)
> case DRM_MODE_DPMS_SUSPEND:
> case DRM_MODE_DPMS_OFF:
>
> -   if (ASIC_IS_DCE4(rdev)) {
> +   if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev)) {
> if 
> (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector)
> atombios_dig_encoder_setup(encoder, 
> ATOM_ENCODER_CMD_DP_VIDEO_OFF, 0);
> }

These changes don't make sense and will break other DCE3.c boards.   I
had the attached patch from you in one of my old branches, does it fix
the issue?

Alex
From ca4fc2fd58dcd3bf9f6afd8d37b27a1cfcc42337 Mon Sep 17 00:00:00 2001
From: Gilles Risch 
Date: Fri, 17 Nov 2023 20:48:24 +0100
Subject: [PATCH] drm/radeon: Fix eDP for single-display iMac11,1

The Apple iMac11,1 (late 2009) has an integrated ATI Mobility Radeon HD 4850.
This machine suffers from a similar problem as the iMac10,1 (late 2009) and
the iMac11,2 (mid 2010). This small patch fixes the issue on this machine.

Fixes freedesktop issue 164
Link: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ati/-/issues/164

Signed-off-by: Gilles Risch 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/atombios_crtc.c | 4 ++--
 drivers/gpu/drm/radeon/atombios_encoders.c | 9 +
 drivers/gpu/drm/radeon/radeon.h| 1 +
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 2fc0334e0d6c5..3c6d332739e3c 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -580,7 +580,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
 			radeon_crtc->pll_flags |= (/*RADEON_PLL_USE_FRAC_FB_DIV |*/
 RADEON_PLL_PREFER_CLOSEST_LOWER);
 
-		if (ASIC_IS_DCE32(rdev) && mode->clock > 20)	/* range limits??? */
+		if (ASIC_IS_DCE31(rdev) && mode->clock > 20)	/* range limits??? */
 			radeon_crtc->pll_flags |= RADEON_PLL_PREFER_HIGH_FB_DIV;
 		else
 			radeon_crtc->pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
@@ -594,7 +594,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
 		if (((rdev->family == CHIP_RS780) || (rdev->family == CHIP_RS880))
 		&& !radeon_crtc->ss_enabled)
 			radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
-		if (ASIC_IS_DCE32(rdev) && mode->clock > 165000)
+		if (ASIC_IS_DCE31(rdev) && mode->clock > 165000)
 			radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
 	} else {
 		radeon_crtc->pll_flags |= RADEON_PLL_LEGACY;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index 3d9f47bc807af..37da7961ce792 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -2123,12 +2123,13 @@ int radeon_atom_pick_dig_encod

Re: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / DCE3.1 systems

2026-05-16 Thread kernel test robot
Hi Gilles,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Gilles-Risch/drm-radeon-fix-eDP-resume-from-suspend-on-iMac11-1-DCE3-1-systems/20260517-025343
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:
https://lore.kernel.org/r/20260516185226.3005-1-gilles.risch%40gmail.com
patch subject: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / 
DCE3.1 systems
config: riscv-randconfig-002-20260517 
(https://download.01.org/0day-ci/archive/20260517/[email protected]/config)
compiler: riscv32-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20260517/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

   drivers/gpu/drm/radeon/atombios_encoders.c: In function 
'atombios_set_edp_panel_power':
>> drivers/gpu/drm/radeon/atombios_encoders.c:1386:14: error: implicit 
>> declaration of function 'ASIC_IS_DCE31'; did you mean 'ASIC_IS_DCE3'? 
>> [-Wimplicit-function-declaration]
1386 | if (!ASIC_IS_DCE31(rdev))
 |  ^
 |  ASIC_IS_DCE3


vim +1386 drivers/gpu/drm/radeon/atombios_encoders.c

  1372  
  1373  bool
  1374  atombios_set_edp_panel_power(struct drm_connector *connector, int 
action)
  1375  {
  1376  struct radeon_connector *radeon_connector = 
to_radeon_connector(connector);
  1377  struct drm_device *dev = radeon_connector->base.dev;
  1378  struct radeon_device *rdev = dev->dev_private;
  1379  union dig_transmitter_control args;
  1380  int index = GetIndexIntoMasterTable(COMMAND, 
UNIPHYTransmitterControl);
  1381  uint8_t frev, crev;
  1382  
  1383  if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
  1384  goto done;
  1385  
> 1386  if (!ASIC_IS_DCE31(rdev))
  1387  goto done;
  1388  
  1389  if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) &&
  1390  (action != ATOM_TRANSMITTER_ACTION_POWER_OFF))
  1391  goto done;
  1392  
  1393  if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, 
&frev, &crev))
  1394  goto done;
  1395  
  1396  memset(&args, 0, sizeof(args));
  1397  
  1398  args.v1.ucAction = action;
  1399  
  1400  atom_execute_table(rdev->mode_info.atom_context, index, 
(uint32_t *)&args, sizeof(args));
  1401  
  1402  /* wait for the panel to power up */
  1403  if (action == ATOM_TRANSMITTER_ACTION_POWER_ON) {
  1404  int i;
  1405  
  1406  for (i = 0; i < 300; i++) {
  1407  if (radeon_hpd_sense(rdev, 
radeon_connector->hpd.hpd))
  1408  return true;
  1409  mdelay(1);
  1410  }
  1411  return false;
  1412  }
  1413  done:
  1414  return true;
  1415  }
  1416  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Re: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / DCE3.1 systems

2026-05-16 Thread kernel test robot
Hi Gilles,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Gilles-Risch/drm-radeon-fix-eDP-resume-from-suspend-on-iMac11-1-DCE3-1-systems/20260517-025343
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:
https://lore.kernel.org/r/20260516185226.3005-1-gilles.risch%40gmail.com
patch subject: [PATCH] drm/radeon: fix eDP resume from suspend on iMac11, 1 / 
DCE3.1 systems
config: riscv-randconfig-001-20260517 
(https://download.01.org/0day-ci/archive/20260517/[email protected]/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 
5bac06718f502014fade905512f1d26d578a18f3)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20260517/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/radeon/atombios_encoders.c:1386:7: error: call to undeclared 
>> function 'ASIC_IS_DCE31'; ISO C99 and later do not support implicit function 
>> declarations [-Wimplicit-function-declaration]
1386 | if (!ASIC_IS_DCE31(rdev))
 |  ^
   drivers/gpu/drm/radeon/atombios_encoders.c:1710:30: error: call to 
undeclared function 'ASIC_IS_DCE31'; ISO C99 and later do not support implicit 
function declarations [-Wimplicit-function-declaration]
1710 | if (ASIC_IS_DCE4(rdev) || 
ASIC_IS_DCE31(rdev))
 |   ^
   drivers/gpu/drm/radeon/atombios_encoders.c:1727:29: error: call to 
undeclared function 'ASIC_IS_DCE31'; ISO C99 and later do not support implicit 
function declarations [-Wimplicit-function-declaration]
1727 | if (ASIC_IS_DCE4(rdev) || ASIC_IS_DCE31(rdev)) {
 |   ^
   3 errors generated.


vim +/ASIC_IS_DCE31 +1386 drivers/gpu/drm/radeon/atombios_encoders.c

  1372  
  1373  bool
  1374  atombios_set_edp_panel_power(struct drm_connector *connector, int 
action)
  1375  {
  1376  struct radeon_connector *radeon_connector = 
to_radeon_connector(connector);
  1377  struct drm_device *dev = radeon_connector->base.dev;
  1378  struct radeon_device *rdev = dev->dev_private;
  1379  union dig_transmitter_control args;
  1380  int index = GetIndexIntoMasterTable(COMMAND, 
UNIPHYTransmitterControl);
  1381  uint8_t frev, crev;
  1382  
  1383  if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
  1384  goto done;
  1385  
> 1386  if (!ASIC_IS_DCE31(rdev))
  1387  goto done;
  1388  
  1389  if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) &&
  1390  (action != ATOM_TRANSMITTER_ACTION_POWER_OFF))
  1391  goto done;
  1392  
  1393  if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, 
&frev, &crev))
  1394  goto done;
  1395  
  1396  memset(&args, 0, sizeof(args));
  1397  
  1398  args.v1.ucAction = action;
  1399  
  1400  atom_execute_table(rdev->mode_info.atom_context, index, 
(uint32_t *)&args, sizeof(args));
  1401  
  1402  /* wait for the panel to power up */
  1403  if (action == ATOM_TRANSMITTER_ACTION_POWER_ON) {
  1404  int i;
  1405  
  1406  for (i = 0; i < 300; i++) {
  1407  if (radeon_hpd_sense(rdev, 
radeon_connector->hpd.hpd))
  1408  return true;
  1409  mdelay(1);
  1410  }
  1411  return false;
  1412  }
  1413  done:
  1414  return true;
  1415  }
  1416  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki