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 E9971AC189B for ; Thu, 26 Oct 2023 17:48:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5/lfohwGB1S4dUau5HlrlY94Qoo4A8zLIq3aAEMJiDk=; c=relaxed/simple; d=groups.io; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Disposition; s=20140610; t=1698342527; v=1; b=Z/NYbTvvPcxIutDYqFr7yosDlr22ajqy0AxLPm9KuSkK00r2j2ZZNOeW3Edf0y7GzmWRM0Cn l9ljhNlqY/pN7e8PEugBuKRGA15pHM1Ba3/rZaUptigt2K8p4HMdBjfBF73rviFqKk4tr6bmjl8 T3GeC0NRVa1wgtHheUJ946/Q= X-Received: by 127.0.0.2 with SMTP id gOCJYY7687511xJaBCoeAO22; Thu, 26 Oct 2023 10:48:47 -0700 X-Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web10.207244.1698342526858353868 for ; Thu, 26 Oct 2023 10:48:47 -0700 X-Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39QGK91p025217; Thu, 26 Oct 2023 17:48:42 GMT X-Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tyq5b0y6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 17:48:42 +0000 X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39QHmfds004872 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 17:48:41 GMT X-Received: from qc-i7.hemma.eciton.net (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Thu, 26 Oct 2023 10:48:39 -0700 Date: Thu, 26 Oct 2023 18:48:35 +0100 From: "Leif Lindholm" To: Marcin Juszkiewicz CC: , Ard Biesheuvel , Jeremy Linton , Nhi Pham , Chuong Tran , Rebecca Cran Subject: Re: [edk2-devel] [PATCH edk2-platforms v6 4/4] SbsaQemu: disable XHCI in DSDT if not present Message-ID: References: <20231026-ehci-xhci-fix-v6-0-923ae4f73b8e@linaro.org> <20231026-ehci-xhci-fix-v6-4-923ae4f73b8e@linaro.org> MIME-Version: 1.0 In-Reply-To: <20231026-ehci-xhci-fix-v6-4-923ae4f73b8e@linaro.org> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-ORIG-GUID: l7AtVtLxIFmOcEAF2CONApolD3mO7V1h X-Proofpoint-GUID: l7AtVtLxIFmOcEAF2CONApolD3mO7V1h 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,quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 84L9w1tJ0QjtmIDdvVhPKcolx7686176AA= Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="Z/NYbTvv"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=quicinc.com (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 On Thu, Oct 26, 2023 at 19:33:52 +0200, Marcin Juszkiewicz wrote: > We need platform version to be at least 0.3 to have XHCI > in virtual hardware. On older platforms there is non-working > EHCI which we ignore. > > Set DSDT node to be disabled so operating system will not try > to initialize not-existing hardware. > > Signed-off-by: Marcin Juszkiewicz > --- > .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 4 ++ > .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 74 +++++++++++++++++++- > Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl | 3 +- > 3 files changed, 79 insertions(+), 2 deletions(-) > > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > index 7c7e08e0fd3a..291743b19115 100644 > --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > @@ -29,6 +29,7 @@ [Packages] > Silicon/Qemu/SbsaQemu/SbsaQemu.dec > > [LibraryClasses] > + AcpiLib > ArmLib > BaseMemoryLib > BaseLib > @@ -49,6 +50,8 @@ [Pcd] > gArmTokenSpaceGuid.PcdGicDistributorBase > gArmTokenSpaceGuid.PcdGicRedistributorsBase > gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase > + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor > + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor > gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase > > [Depex] > @@ -58,6 +61,7 @@ [Guids] > gEdkiiPlatformHasAcpiGuid > > [Protocols] > + gEfiAcpiSdtProtocolGuid > gEfiAcpiTableProtocolGuid ## CONSUMES > > [FixedPcd] > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > index fd849ca1594b..523d9035e0c1 100644 > --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -682,6 +683,72 @@ AddGtdtTable ( > return Status; > } > > +/* > + * A function to disable XHCI node on Platform Version lower than 0.3 > + */ > +STATIC > +EFI_STATUS > +DisableXhciOnOlderPlatVer ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol; > + EFI_ACPI_DESCRIPTION_HEADER *Table; > + UINTN TableKey; > + UINTN TableIndex; > + EFI_ACPI_HANDLE TableHandle; > + > + Status = EFI_SUCCESS; > + > + if ( PLATFORM_VERSION_LESS_THAN (0, 3)) { > + DEBUG ((DEBUG_ERROR, "Platform Version < 0.3 - disabling XHCI\n")); > + Status = gBS->LocateProtocol ( > + &gEfiAcpiSdtProtocolGuid, > + NULL, > + (VOID **)&AcpiSdtProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Unable to locate ACPI table protocol\n")); > + return Status; > + } > + > + Status = AcpiLocateTableBySignature ( > + AcpiSdtProtocol, > + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, > + &TableIndex, > + &Table, > + &TableKey > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "ACPI DSDT table not found!\n")); > + ASSERT_EFI_ERROR (Status); > + return Status; > + } > + > + Status = AcpiSdtProtocol->OpenSdt (TableKey, &TableHandle); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + AcpiSdtProtocol->Close (TableHandle); > + return Status; > + } > + > + Status = AcpiAmlObjectUpdateInteger (AcpiSdtProtocol, TableHandle, "\\_SB.USB0.XHCI", 0x0); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Failed to disable XHCI!\n")); > + ASSERT_EFI_ERROR (Status); > + AcpiSdtProtocol->Close (TableHandle); > + return Status; > + } > + > + AcpiSdtProtocol->Close (TableHandle); > + AcpiUpdateChecksum ((UINT8 *)Table, Table->Length); > + } > + > + return Status; > +} > + > + > EFI_STATUS > EFIAPI > InitializeSbsaQemuAcpiDxe ( > @@ -738,5 +805,10 @@ InitializeSbsaQemuAcpiDxe ( > DEBUG ((DEBUG_ERROR, "Failed to add GTDT table\n")); > } > > - return EFI_SUCCESS; > + Status = DisableXhciOnOlderPlatVer (); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Failed to handle XHCI enablement\n")); > + } > + > + return Status; Right, this isn't what I asked for though. There is nothing valid about returning a bad status here - it is the entry point of the module. If we wanted some sort of error handling, we would need to plumb that in manually. Anyway, no point in you spinning another version, I'll change this back to the original return statement. For the series: Reviewed-by: Leif Lindholm Pushed as 74b9eacfd453..d61836283a4c. Thanks! > } > diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl > index 6661bc8195ee..b55ad6c5cc07 100644 > --- a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl > +++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl > @@ -73,8 +73,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", > Name (_HID, "PNP0D10") // _HID: Hardware ID > Name (_UID, 0x00) // _UID: Unique ID > Name (_CCA, 0x01) // _CCA: Cache Coherency Attribute > + Name (XHCI, 0xF) // will be set using AcpiLib > Method (_STA) { > - Return (0xF) > + Return (XHCI) > } > Method (_CRS, 0x0, Serialized) { > Name (RBUF, ResourceTemplate() { > > -- > 2.41.0 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110138): https://edk2.groups.io/g/devel/message/110138 Mute This Topic: https://groups.io/mt/102205083/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-