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 08DEE740039 for ; Thu, 26 Oct 2023 17:34:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=CBOKYIcv8mxrKIBBRoG5/9jHY6fvtbwGhkhci0kWVGE=; 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=1698341641; v=1; b=HH+2f8drm0qAtyHSvbp3S48IjgqpKIfSs3XijD0Ne930TceFcjaB01OULccpaolxpYDJU7Xq LuKugES3bS42tD+NOxw+6r1qlCSV/lbWedJPjkS29HZXpMgfS9/0WP4QKrCsrHIJ/vgZG85BHOR EnQvFvSC+QFdf7tsRC/h8oDQ= X-Received: by 127.0.0.2 with SMTP id oabgYY7687511xDEgfEkz0ti; Thu, 26 Oct 2023 10:34:01 -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.206876.1698341640467788687 for ; Thu, 26 Oct 2023 10:34:00 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id C2249260BB4; Thu, 26 Oct 2023 19:33:57 +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 cGcA678thDFd; Thu, 26 Oct 2023 19:33:55 +0200 (CEST) X-Received: from [192.168.210.114] (83.11.185.48.ipv4.supernova.orange.pl [83.11.185.48]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id 117422600A6; Thu, 26 Oct 2023 19:33:54 +0200 (CEST) From: "Marcin Juszkiewicz" Subject: [edk2-devel] [PATCH edk2-platforms v6 0/4] Provide XHCI USB controller only for newer hardware Date: Thu, 26 Oct 2023 19:33:48 +0200 Message-Id: <20231026-ehci-xhci-fix-v6-0-923ae4f73b8e@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAPyiOmUC/33PQWrDMBAF0KsErasiaTSSpqveo2ShyqNYUOwgF 5MQfPfKWbk27Wbgf3gf5iEmroUn8XZ6iMpzmco4tOBeTiL1cbiwLF3LwigDWmmQ3Kcib+vJ5SY TGgJ00ceQRTPXyq1+7n2cW+7L9D3W+3N+1mv719KspZIZXTaBvWJw719liHV8HetFrFOz2XK35 6bxxMkZtKi7mA8cttzvOTSuPokTBevJ+gO3Wx723DYeI4KGQOQjHjj+y3H93RoijNDljn7xZVl +AC2quEOnAQAA 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: zRzyl64U3wbh5H2DcXiFWhXax7686176AA= 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=HH+2f8dr; 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 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, --=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 (#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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-