public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH edk2-platforms v6 0/4] Provide XHCI USB controller only for newer hardware
@ 2023-10-26 17:33 Marcin Juszkiewicz
  2023-10-26 17:33 ` [edk2-devel] [PATCH edk2-platforms v6 1/4] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-26 17:33 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton, Nhi Pham,
	Chuong Tran, Rebecca Cran, Marcin Juszkiewicz

Platform version 0.3 introduced XHCI USB controller instead of EHCI one.
But we did it in a way that there is no in-EDK2 check for platform
version (XHCI is always given).

This behaviour works with Linux as it complains about being unable to
initialize EHCI and goes on. Free/Net/Open BSD systems hang in such
situation.

Now we check are we on Platform Version 0.3 at least and then initialize
XHCI controller. Otherwise we disable it's node in DSDT table.

I checked several ways to handle the situation. 

SSDT overlay enabling with LocateAndInstallAcpiFromFvConfitional() was
first one but this function had only DBG2 and FACP tables.

Then looked at trying to detect XHCI from _STA method. But this is
sysbus device which is there or not without way to discover it.

Next attempt was to have variable in DSDT and to use it in _STA. Too
much trouble.

Then looked again at code from
Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiDsdt.c and noticed
UpdateStatusMethodObject() function. Copied some code and it worked.

Booting OpenBSD reminded me to update table checksum.

Nhi Pham pointed me to AcpiLib/AcpiAmlObjectUpdateInteger() function. So
v3 got AML variable (called XHCI) which is set to 0xF (enabled, working)
by default or to 0x0 (disabled, ignore) on Platform Version below 0.3
one.

This allowed to remove copy of UpdateStatusMethodObject() function.

---
Changes in v6:
- made DisableXhciOnOlderPlatVer() static
- added usual "if EFI_ERROR(Status)" dance

Changes in v5:
- added missing s-o-b lines
- run uncrustify on changed code
- fixed typos
- added comments

Changes in v4:
- make use of DisableXhciOnOlderPlatVer() return value

Changes in v3:
- use AML variable in DSDT

Changes in v2:
- XHCI initialized only on PlatVer 0.3+
- XHCI disabled in DSDT for older platforms
- no SSDT overlays for EHCI/XHCI
- no EHCI at all (it does not work anyway)
- no Pcd renaming

---
Marcin Juszkiewicz (4):
      SbsaQemu: introduce macro to compare platform version
      SbsaQemu: add AcpiLib
      SbsaQemu: initialize XHCI only if it exists
      SbsaQemu: disable XHCI in DSDT if not present

 Platform/Qemu/SbsaQemu/SbsaQemu.dsc                  |  2 +
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf      |  4 ++
 .../IndustryStandard/SbsaQemuPlatformVersion.h       | 25 +++++++
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c        | 74 +++++++++++++++++++-
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c        | 49 +++++++------
 Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl            |  3 +-
 6 files changed, 133 insertions(+), 24 deletions(-)
---
base-commit: 74b9eacfd453c56b8bcc5ac68b3bf5ca243d60a9
change-id: 20231013-ehci-xhci-fix-c529356a7a8f

Best regards,
-- 
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110133): https://edk2.groups.io/g/devel/message/110133
Mute This Topic: https://groups.io/mt/102205079/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-26 17:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26 17:33 [edk2-devel] [PATCH edk2-platforms v6 0/4] Provide XHCI USB controller only for newer hardware Marcin Juszkiewicz
2023-10-26 17:33 ` [edk2-devel] [PATCH edk2-platforms v6 1/4] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
2023-10-26 17:33 ` [edk2-devel] [PATCH edk2-platforms v6 2/4] SbsaQemu: add AcpiLib Marcin Juszkiewicz
2023-10-26 17:33 ` [edk2-devel] [PATCH edk2-platforms v6 3/4] SbsaQemu: initialize XHCI only if it exists Marcin Juszkiewicz
2023-10-26 17:33 ` [edk2-devel] [PATCH edk2-platforms v6 4/4] SbsaQemu: disable XHCI in DSDT if not present Marcin Juszkiewicz
2023-10-26 17:48   ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox