Re: iMac11,2: internal display only works when DisplayPort is connected

2022-08-29 Thread Jonathan Gray
On Mon, Aug 29, 2022 at 10:03:34AM +0100, Hashim Mahmoud wrote:
> On Mon, 29 Aug 2022 17:19:16 +1000
> Jonathan Gray  wrote:
> 
> > On Mon, Aug 29, 2022 at 07:56:40AM +0100, Hashim Mahmoud wrote:
> > > This iMac's screen works fine, but always turns off when the radeon
> > > GPU driver is loaded on any UNIX (tried Linux Mint and NomadBSD as
> > > well). I had to install OpenBSD on another machine since I was
> > > installing to an SD card, as I didn't have any (big enough) spare
> > > SSDs or USBs, and writing to the SD card from the installer on the
> > > same iMac gives me permission errors.
> > > 
> > > I had installed the radeon firmware already by the time I put the SD
> > > card into the iMac. The GPU seems to work fine and I can login and
> > > run commands blindly, but the display is off... until I had the
> > > bright idea to connect a display over the DisplayPort at boot time,
> > > via a VGA to mini DisplayPort adapter. The internal eDP display
> > > worked, but the tty framebuffer took the resolution of the external
> > > display (similar to what would happen when a low resolution laptop
> > > is connected to a higher resolution display, and both displays are
> > > on), which is 1440x900, and the external display receives no
> > > output, though Xorg seems to acknowledge its existence and renders
> > > itself as if that display exists, as the xenodm login window is not
> > > available on the main display, and the mouse disappears as if it
> > > went to another display when hitting the left edge. I can login
> > > blind and run `xrandr --output DisplayPort-0 --off`, and everything
> > > seems to work perfectly fine and GPU accelerated, as the output of
> > > `glxinfo -B` indicates, and glxgears runs smoothly.
> > > 
> > > However, this only works if the DisplayPort is connected at boot
> > > time:
> > > 
> > > - If it is disconnected after the radeon driver is loaded, but X
> > > hasn't started yet, then the display goes black again, but I can
> > > plug it back in and the display shows up as normal (still in
> > > 1440x900, though), and I get this in blue: `[drm] *ERROR* chosen
> > > encoder in use 0`. No idea what that means.
> > > 
> > > - Once X is started however, I can just disconnect the DisplayPort,
> > > and life is good :) ... except I get the following in xconsole:
> > > ```
> > > [drm] *ERROR* displayport link status failed
> > > [drm] *ERROR* clock recovery failed
> > > [drm] *ERROR* displayport link status failed
> > > [drm] *ERROR* clock recovery failed
> > > ```
> > > - Doesn't seem to effect me in any way, though.
> > > 
> > > - I also get this error message, when I switch from my X session to
> > >   tty: `[drm] *ERROR*
> > > rv770_restrict_performance_levels_before_switch failed`. Also seems
> > > to have no effect.
> > > - Note that these errors only appear in xconsole and not on the
> > > actual console in blue... weird.
> > > 
> > > 
> > > Is there some sort of software remedy for this? I doubt this (unless
> > > someone can tell me otherwise), so I was thinking of getting
> > > something like a Raspberry Pi Zero or an Arduino, and connecting to
> > > the DisplayPort, making it like some sort of dummy DisplayPort
> > > input by programming it... I'm not sure at all how to go about
> > > doing this, as I'm a very amateur programmer, but I know that it
> > > *should* be theoretically possible; any pointers would be very
> > > appreciated.  
> > 
> > Does this help?
> > 
> > RV730 has DCE3.2
> > 
> > Index: sys/dev/pci/drm/radeon/atombios_encoders.c
> > ===
> > RCS file: /cvs/src/sys/dev/pci/drm/radeon/atombios_encoders.c,v
> > retrieving revision 1.17
> > diff -u -p -U6 -r1.17 atombios_encoders.c
> > --- sys/dev/pci/drm/radeon/atombios_encoders.c  24 Feb 2022
> > 12:49:47 -  1.17 +++
> > sys/dev/pci/drm/radeon/atombios_encoders.c  29 Aug 2022
> > 07:12:12 - @@ -2189,13 +2189,14 @@ int
> > radeon_atom_pick_dig_encoder(struct /*
> >  * On DCE32 any encoder can drive any block so usually just
> > use crtc id,
> >  * but Apple thinks different at least on iMac10,1, so there
> > use linkb,
> >  * otherwise the internal eDP panel will stay dark.
> >  */
> > if (ASIC_IS_DCE32(rdev)) {
> > -   if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1"))
> > +   if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1") ||
> > +   dmi_match(DMI_PRODUCT_NAME, "iMac11,2"))
> > enc_idx = (dig->linkb) ? 1 : 0;
> > else
> > enc_idx = radeon_crtc->crtc_id;
> >  
> > goto assigned;
> > }
> 
> Sorry for the relatively late reply, this is my first time compiling
> the kernel from source... but man you're a life saver; it worked! I do
> get this error though:
> `WARNING bo->pin_count failed at /usr/src/sys/dev/pci/drm/ttm/ttm_bo.c:409`
> Which also doesn't affect me, but worth pointing out. I tried making an
> external monitor work 

Re: iMac11,2: internal display only works when DisplayPort is connected

2022-08-29 Thread Hashim Mahmoud
On Mon, 29 Aug 2022 17:19:16 +1000
Jonathan Gray  wrote:

> On Mon, Aug 29, 2022 at 07:56:40AM +0100, Hashim Mahmoud wrote:
> > This iMac's screen works fine, but always turns off when the radeon
> > GPU driver is loaded on any UNIX (tried Linux Mint and NomadBSD as
> > well). I had to install OpenBSD on another machine since I was
> > installing to an SD card, as I didn't have any (big enough) spare
> > SSDs or USBs, and writing to the SD card from the installer on the
> > same iMac gives me permission errors.
> > 
> > I had installed the radeon firmware already by the time I put the SD
> > card into the iMac. The GPU seems to work fine and I can login and
> > run commands blindly, but the display is off... until I had the
> > bright idea to connect a display over the DisplayPort at boot time,
> > via a VGA to mini DisplayPort adapter. The internal eDP display
> > worked, but the tty framebuffer took the resolution of the external
> > display (similar to what would happen when a low resolution laptop
> > is connected to a higher resolution display, and both displays are
> > on), which is 1440x900, and the external display receives no
> > output, though Xorg seems to acknowledge its existence and renders
> > itself as if that display exists, as the xenodm login window is not
> > available on the main display, and the mouse disappears as if it
> > went to another display when hitting the left edge. I can login
> > blind and run `xrandr --output DisplayPort-0 --off`, and everything
> > seems to work perfectly fine and GPU accelerated, as the output of
> > `glxinfo -B` indicates, and glxgears runs smoothly.
> > 
> > However, this only works if the DisplayPort is connected at boot
> > time:
> > 
> > - If it is disconnected after the radeon driver is loaded, but X
> > hasn't started yet, then the display goes black again, but I can
> > plug it back in and the display shows up as normal (still in
> > 1440x900, though), and I get this in blue: `[drm] *ERROR* chosen
> > encoder in use 0`. No idea what that means.
> > 
> > - Once X is started however, I can just disconnect the DisplayPort,
> > and life is good :) ... except I get the following in xconsole:
> > ```
> > [drm] *ERROR* displayport link status failed
> > [drm] *ERROR* clock recovery failed
> > [drm] *ERROR* displayport link status failed
> > [drm] *ERROR* clock recovery failed
> > ```
> > - Doesn't seem to effect me in any way, though.
> > 
> > - I also get this error message, when I switch from my X session to
> >   tty: `[drm] *ERROR*
> > rv770_restrict_performance_levels_before_switch failed`. Also seems
> > to have no effect.
> > - Note that these errors only appear in xconsole and not on the
> > actual console in blue... weird.
> > 
> > 
> > Is there some sort of software remedy for this? I doubt this (unless
> > someone can tell me otherwise), so I was thinking of getting
> > something like a Raspberry Pi Zero or an Arduino, and connecting to
> > the DisplayPort, making it like some sort of dummy DisplayPort
> > input by programming it... I'm not sure at all how to go about
> > doing this, as I'm a very amateur programmer, but I know that it
> > *should* be theoretically possible; any pointers would be very
> > appreciated.  
> 
> Does this help?
> 
> RV730 has DCE3.2
> 
> Index: sys/dev/pci/drm/radeon/atombios_encoders.c
> ===
> RCS file: /cvs/src/sys/dev/pci/drm/radeon/atombios_encoders.c,v
> retrieving revision 1.17
> diff -u -p -U6 -r1.17 atombios_encoders.c
> --- sys/dev/pci/drm/radeon/atombios_encoders.c24 Feb 2022
> 12:49:47 -1.17 +++
> sys/dev/pci/drm/radeon/atombios_encoders.c29 Aug 2022
> 07:12:12 - @@ -2189,13 +2189,14 @@ int
> radeon_atom_pick_dig_encoder(struct /*
>* On DCE32 any encoder can drive any block so usually just
> use crtc id,
>* but Apple thinks different at least on iMac10,1, so there
> use linkb,
>* otherwise the internal eDP panel will stay dark.
>*/
>   if (ASIC_IS_DCE32(rdev)) {
> - if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1"))
> + if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1") ||
> + dmi_match(DMI_PRODUCT_NAME, "iMac11,2"))
>   enc_idx = (dig->linkb) ? 1 : 0;
>   else
>   enc_idx = radeon_crtc->crtc_id;
>  
>   goto assigned;
>   }

Sorry for the relatively late reply, this is my first time compiling
the kernel from source... but man you're a life saver; it worked! I do
get this error though:
`WARNING bo->pin_count failed at /usr/src/sys/dev/pci/drm/ttm/ttm_bo.c:409`
Which also doesn't affect me, but worth pointing out. I tried making an
external monitor work over the DisplayPort, but seems to still have the
problem of rendering but not actually outputting... I might've got the
above error after I tried making the monitor work, I'm not sure, but
not like it matters much; no external 

Re: iMac11,2: internal display only works when DisplayPort is connected

2022-08-29 Thread Jonathan Gray
On Mon, Aug 29, 2022 at 07:56:40AM +0100, Hashim Mahmoud wrote:
> This iMac's screen works fine, but always turns off when the radeon GPU
> driver is loaded on any UNIX (tried Linux Mint and NomadBSD as well). I
> had to install OpenBSD on another machine since I was installing to an
> SD card, as I didn't have any (big enough) spare SSDs or USBs, and
> writing to the SD card from the installer on the same iMac gives me
> permission errors.
> 
> I had installed the radeon firmware already by the time I put the SD
> card into the iMac. The GPU seems to work fine and I can login and run
> commands blindly, but the display is off... until I had the bright
> idea to connect a display over the DisplayPort at boot time, via a VGA
> to mini DisplayPort adapter. The internal eDP display worked, but the
> tty framebuffer took the resolution of the external display (similar to
> what would happen when a low resolution laptop is connected to a
> higher resolution display, and both displays are on), which is
> 1440x900, and the external display receives no output, though Xorg
> seems to acknowledge its existence and renders itself as if that
> display exists, as the xenodm login window is not available on the main
> display, and the mouse disappears as if it went to another display when
> hitting the left edge. I can login blind and run `xrandr --output
> DisplayPort-0 --off`, and everything seems to work perfectly fine and
> GPU accelerated, as the output of `glxinfo -B` indicates, and glxgears
> runs smoothly.
> 
> However, this only works if the DisplayPort is connected at boot time:
> 
> - If it is disconnected after the radeon driver is loaded, but X hasn't
> started yet, then the display goes black again, but I can plug it back
> in and the display shows up as normal (still in 1440x900, though), and
> I get this in blue: `[drm] *ERROR* chosen encoder in use 0`. No idea
> what that means.
> 
> - Once X is started however, I can just disconnect the DisplayPort, and
>   life is good :) ... except I get the following in xconsole:
> ```
> [drm] *ERROR* displayport link status failed
> [drm] *ERROR* clock recovery failed
> [drm] *ERROR* displayport link status failed
> [drm] *ERROR* clock recovery failed
> ```
> - Doesn't seem to effect me in any way, though.
> 
> - I also get this error message, when I switch from my X session to
>   tty: `[drm] *ERROR* rv770_restrict_performance_levels_before_switch
>   failed`. Also seems to have no effect.
> - Note that these errors only appear in xconsole and not on the actual
>   console in blue... weird.
> 
> 
> Is there some sort of software remedy for this? I doubt this (unless
> someone can tell me otherwise), so I was thinking of getting something
> like a Raspberry Pi Zero or an Arduino, and connecting to the
> DisplayPort, making it like some sort of dummy DisplayPort input by
> programming it... I'm not sure at all how to go about doing this, as
> I'm a very amateur programmer, but I know that it *should* be
> theoretically possible; any pointers would be very appreciated.

Does this help?

RV730 has DCE3.2

Index: sys/dev/pci/drm/radeon/atombios_encoders.c
===
RCS file: /cvs/src/sys/dev/pci/drm/radeon/atombios_encoders.c,v
retrieving revision 1.17
diff -u -p -U6 -r1.17 atombios_encoders.c
--- sys/dev/pci/drm/radeon/atombios_encoders.c  24 Feb 2022 12:49:47 -  
1.17
+++ sys/dev/pci/drm/radeon/atombios_encoders.c  29 Aug 2022 07:12:12 -
@@ -2189,13 +2189,14 @@ int radeon_atom_pick_dig_encoder(struct 
/*
 * On DCE32 any encoder can drive any block so usually just use crtc id,
 * but Apple thinks different at least on iMac10,1, so there use linkb,
 * otherwise the internal eDP panel will stay dark.
 */
if (ASIC_IS_DCE32(rdev)) {
-   if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1"))
+   if (dmi_match(DMI_PRODUCT_NAME, "iMac10,1") ||
+   dmi_match(DMI_PRODUCT_NAME, "iMac11,2"))
enc_idx = (dig->linkb) ? 1 : 0;
else
enc_idx = radeon_crtc->crtc_id;
 
goto assigned;
}



iMac11,2: internal display only works when DisplayPort is connected

2022-08-29 Thread Hashim Mahmoud
This iMac's screen works fine, but always turns off when the radeon GPU
driver is loaded on any UNIX (tried Linux Mint and NomadBSD as well). I
had to install OpenBSD on another machine since I was installing to an
SD card, as I didn't have any (big enough) spare SSDs or USBs, and
writing to the SD card from the installer on the same iMac gives me
permission errors.

I had installed the radeon firmware already by the time I put the SD
card into the iMac. The GPU seems to work fine and I can login and run
commands blindly, but the display is off... until I had the bright
idea to connect a display over the DisplayPort at boot time, via a VGA
to mini DisplayPort adapter. The internal eDP display worked, but the
tty framebuffer took the resolution of the external display (similar to
what would happen when a low resolution laptop is connected to a
higher resolution display, and both displays are on), which is
1440x900, and the external display receives no output, though Xorg
seems to acknowledge its existence and renders itself as if that
display exists, as the xenodm login window is not available on the main
display, and the mouse disappears as if it went to another display when
hitting the left edge. I can login blind and run `xrandr --output
DisplayPort-0 --off`, and everything seems to work perfectly fine and
GPU accelerated, as the output of `glxinfo -B` indicates, and glxgears
runs smoothly.

However, this only works if the DisplayPort is connected at boot time:

- If it is disconnected after the radeon driver is loaded, but X hasn't
started yet, then the display goes black again, but I can plug it back
in and the display shows up as normal (still in 1440x900, though), and
I get this in blue: `[drm] *ERROR* chosen encoder in use 0`. No idea
what that means.

- Once X is started however, I can just disconnect the DisplayPort, and
  life is good :) ... except I get the following in xconsole:
```
[drm] *ERROR* displayport link status failed
[drm] *ERROR* clock recovery failed
[drm] *ERROR* displayport link status failed
[drm] *ERROR* clock recovery failed
```
- Doesn't seem to effect me in any way, though.

- I also get this error message, when I switch from my X session to
  tty: `[drm] *ERROR* rv770_restrict_performance_levels_before_switch
  failed`. Also seems to have no effect.
- Note that these errors only appear in xconsole and not on the actual
  console in blue... weird.


Is there some sort of software remedy for this? I doubt this (unless
someone can tell me otherwise), so I was thinking of getting something
like a Raspberry Pi Zero or an Arduino, and connecting to the
DisplayPort, making it like some sort of dummy DisplayPort input by
programming it... I'm not sure at all how to go about doing this, as
I'm a very amateur programmer, but I know that it *should* be
theoretically possible; any pointers would be very appreciated.

dmesg:
OpenBSD 7.1 (GENERIC.MP) #465: Mon Apr 11 18:03:57 MDT 2022
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 12858105856 (12262MB)
avail mem = 12451119104 (11874MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xbf672000 (64 entries)
bios0: vendor Apple Inc. version "99.0.0.0.0" date 06/13/2019
bios0: Apple Inc. iMac11,2
acpi0 at bios0: ACPI 4.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP ASF! HPET APIC APIC SBST ECDT SSDT SSDT SSDT MCFG
acpi0: wakeup devices P0P2(S4) GFX0(S4) EC__(S3) HDEF(S4) RP01(S4) GIGE(S5) 
RP02(S4) ARPT(S5) RP03(S4) RP04(S4) EHC1(S3) EHC2(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i3 CPU 540 @ 3.07GHz, 3059.42 MHz, 06-25-05
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 132MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.1, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i3 CPU 540 @ 3.07GHz, 3059.00 MHz, 06-25-05
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i3 CPU 540 @ 3.07GHz, 3059.01 MHz, 06-25-05
cpu2: