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 CA952941598 for ; Wed, 18 Oct 2023 11:55:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+gDeLSE+dGA1e8stthPfvz0mpERr49nkbmVqhU8F8WA=; 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=1697630146; v=1; b=bDjfbSfmnFToF2dTZDE3S0kW13ESKw/XrkiOS5TidwxpirH86fPNQiYtbJbVbjW1VH7PVSGx qUlR/Z1NA68Z86J+cbfIolV1CVbS6Y+fJur0yCNZquBJMM23D48+W2cerV1UlmysYGboBlsiN2S LGP06RUWsQw6ljsRC6Phx9b0= X-Received: by 127.0.0.2 with SMTP id suZjYY7687511xeB9XnSUtqN; Wed, 18 Oct 2023 04:55:46 -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.279891.1697630145267202141 for ; Wed, 18 Oct 2023 04:55:45 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id 1F78C260C04; Wed, 18 Oct 2023 13:55:42 +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 7smtTo1EGvJS; Wed, 18 Oct 2023 13:55:40 +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 53B002600DA; Wed, 18 Oct 2023 13:55:39 +0200 (CEST) From: "Marcin Juszkiewicz" Subject: [edk2-devel] [PATCH edk2-platforms v5 0/4] Provide XHCI USB controller only for newer hardware Date: Wed, 18 Oct 2023 13:55:37 +0200 Message-Id: <20231018-ehci-xhci-fix-v5-0-f42995a3dfd9@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALnHL2UC/3XMSwqDMBSF4a1Ixk3J+9FR91E6SOONBoqWpIhF3 HujI6t0cuFc+P4JZUgRMrpUE0owxBz7rgx5qpBvXdcAjnXZiBHGKaEcQ+sjHpcT4oi9ZJZL5bQ zARXzSlDea+92L7uN+d2nz5of6PL9VxooJjhIFZgBTYCr6zN2LvXnPjVoSQ1sy9Wes8I9eMWkk LR24cD5lus954WThwVvjdBW6AMXW272XBTunOSUG2u1kz98nucvBHXOsmgBAAA= 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: TbFhmkmccqOo4TlJbqCAeLEax7686176AA= 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=bDjfbSfm; 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 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 | 68 ++++++++++++++++= +++- .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 49 +++++++------- Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl | 3 +- 6 files changed, 127 insertions(+), 24 deletions(-) --- base-commit: 8b20188ced2318c970b3666d2a7c132c40aaee68 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 (#109734): https://edk2.groups.io/g/devel/message/109734 Mute This Topic: https://groups.io/mt/102037240/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-