From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C0A0678003C for ; Wed, 18 Oct 2023 10:08:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=aMvS3c1WvfzD3sMluCRoS0WLDHRcu7P0lvHwNtP3OXg=; c=relaxed/simple; d=groups.io; h=From:Subject:Date:Message-Id:MIME-Version:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1697623687; v=1; b=qD1IxFNSSltCsnWyid/TnQyma6p2TiRbaJB1AKHolh2LssEWHt6jO0yCkOe71uBxdHx1xvml naVETnb8wDCyj8apkYnfIHFJ2XP2wIHMX3rifgHa4CWDspV17nchzh3LcUQh0fwHkk5T522vMVh kLI/odWWbr6UE9D6bmw8DefI= X-Received: by 127.0.0.2 with SMTP id gflnYY7687511xAg9flSKBBI; Wed, 18 Oct 2023 03:08:07 -0700 X-Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web10.278335.1697623686418408909 for ; Wed, 18 Oct 2023 03:08:06 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id ECFF3260CC8; Wed, 18 Oct 2023 12:08:03 +0200 (CEST) X-Virus-Scanned: Debian amavis at juszkiewicz.com.pl X-Received: from muminek.juszkiewicz.com.pl ([127.0.0.1]) by localhost (muminek.juszkiewicz.com.pl [127.0.0.1]) (amavis, port 10024) with ESMTP id 8Ex1Pl2mT5eg; Wed, 18 Oct 2023 12:08:02 +0200 (CEST) X-Received: from [172.17.0.1] (83.11.27.172.ipv4.supernova.orange.pl [83.11.27.172]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id 28A9F2600DA; Wed, 18 Oct 2023 12:07:55 +0200 (CEST) From: "Marcin Juszkiewicz" Subject: [edk2-devel] [PATCH edk2-platforms v4 0/4] Provide XHCI USB controller only for newer hardware Date: Wed, 18 Oct 2023 12:07:52 +0200 Message-Id: <20231018-ehci-xhci-fix-v4-0-aa53138997a5@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAHiuL2UC/3XMTQrCMBCG4atI1kbyn8aV9xAXMZ20AWkkkVApv btpV7XiZuAbeN4JZUgBMjofJpSghBziUIc4HpDr7dABDm3diBHGKaEcQ+8CHpfjw4idZIZLZbV tPKrmmaC+1971Vncf8ium95ovdPn+KxWKCfZSedaAJsDV5REGm+Ippg4tqcK2XO05q9yBU0wKS Vvrfzjfcr3nvHJyN+BMI7QR+ovP8/wBUJgmVSkBAAA= To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Jeremy Linton , Nhi Pham , Chuong Tran , Rebecca Cran , Marcin Juszkiewicz Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,marcin.juszkiewicz@linaro.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Nw4lSwCpwuGT58rPWG8M573gx7686176AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=qD1IxFNS; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linaro.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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.=20 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 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 | 66 ++++++++++++++++= +++- .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 47 +++++++------- Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl | 3 +- 6 files changed, 123 insertions(+), 24 deletions(-) --- base-commit: 06f6274d56422084281886fad447ab117fd0e487 change-id: 20231013-ehci-xhci-fix-c529356a7a8f Best regards, --=20 Marcin Juszkiewicz -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109719): https://edk2.groups.io/g/devel/message/109719 Mute This Topic: https://groups.io/mt/102035950/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-