From nobody Thu May 2 03:12:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82250+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82250+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590293; cv=none; d=zohomail.com; s=zohoarc; b=cd1LTVeVcTgOAoqxfYXIQH5CwGzIP7eYtK7I5wjhH8y7vLBHCSjTVDD7Nyp90iH5NUFmrojEwMl5VSPiXez5Cbic4995HAwK9MBEeQkAvuOFCONmYX0XKhACBS3zXvxGfWmtDNn09kpVEQkJlR7RS5AY7fTP8ukc6F1yKcMUC40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590293; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ieNM7wpQ8MocOHUCyXNZHoFPU/N2ps2v7pviO7xoXy8=; b=KduJevSZ20uoolo7zAULKQ7j1zhjcj/uu5i6LKiHpw+DkpipNRVAHwiE0EmtYfywrE/2TKKhoVIsLxWoVdxYZc5q2IsfswvqvGWlAQtrB0KkQ9V7pHeKATkQI7pqRFciRkfwgDvjjbeQLZors9HOHZLY+ypQaHPjs5enLS3APHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82250+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634590292929193.15970678939743; Mon, 18 Oct 2021 13:51:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DktIYY1788612x58WOwMteqx; Mon, 18 Oct 2021 13:51:32 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.139.1634590291481303876 for ; Mon, 18 Oct 2021 13:51:31 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15338ED1; Mon, 18 Oct 2021 13:51:31 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7F363F73D; Mon, 18 Oct 2021 13:51:30 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 1/5] Platform/RaspberryPi: Always use non translating DMA in DT mode Date: Mon, 18 Oct 2021 15:51:23 -0500 Message-Id: <20211018205127.7099-2-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,jeremy.linton@arm.com X-Gm-Message-State: q4f9lgYeyGLxYxfV0kaIV49Ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590292; bh=qGpdEGOvj0jp23FE/NEiRvoAReZjqKrYYwHfrgMdSUk=; h=Cc:Date:From:Reply-To:Subject:To; b=Fl4klpGE5e55GgLMhrG4ULpq9iEE5PvYRtuDMw3jlwU1xM6464zVIOGqULK3tX30EVj egOHCB8AGP2ljKdWjJ3+Ho39Nxlr3UkNde4d/IVIobVsfQ8yOfIdi/a4TFvBZXp45/lBV Yo4Cy19TSjl/ieCmCWw5hcyqQsUaUICmN3U= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634590294536100001 Content-Type: text/plain; charset="utf-8" One of the many issues with the PCIe on this platform is its inbound DMA is either constrained to the lower 3G, or on later SOC's a translation may be used. That translation is problematic with some of the OS's expected to boot on this platform. So, across the board a 3G DMA limit is enforced during boot when in ACPI mode. This itself causes problems because the later boards removed the SPI EEPROM used by the onboard XHCI controller, instead favoring using a block of RAM to load its firmware. Hence it is the lower level firmware's responsibility via a mailbox call, to read the bridge translation/configuration before telling the XHCI controller where it can find its firmware. Everything is great in ACPI land. Now it appears that Linux after reprogramming the bridge to match the DT (when using a translation) can't actually get the XHCI/quirk/reset to function. Apparently, because the firmware only reads the bridge configuration the first time its called(?), or the kernel reset sequence isn't correct. Worse, with just the DMA ranges corrected, the XHCI/QUIRK itself then causes the controller to start having what appear to be DMA issues. Lets simplify the situation and make all DT's provided by this firmware have a 3G DMA limit on the PCIe bus. Then remove the ability for Linux/etc to trigger the quirk by remove the DT node attaching the reset controller to the XHCI. The latter seems somewhat questionable, since the DT/PCIe host bridge driver is doing what appears to be a PERST which might then require a firmware reload, but at the moment seems to work without. The first part of this patch also appears to fix a problem with OpenBSD which interprets the DT as describing how the firmware has configured the device, and makes no attempt to reconfigure it. Hence the newer SOC's implementing a translation fail to boot since the DT being passed to the OS doesn't match the translation the firmware has setup. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 75 ++++++++++++++++++++++++= ++++ 1 file changed, 75 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/Raspbe= rryPi/Drivers/FdtDxe/FdtDxe.c index 0472d8ecf6..a4816d4295 100644 --- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c +++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c @@ -334,6 +334,76 @@ CleanSimpleFramebuffer ( return EFI_SUCCESS; } =20 +STATIC +EFI_STATUS +SyncPcie ( + VOID + ) +{ +#if (RPI_MODEL =3D=3D 4) + INTN Node; + INTN Retval; + UINT32 DmaRanges[7]; + + Node =3D fdt_path_offset (mFdtImage, "pcie0"); + if (Node < 0) { + DEBUG ((DEBUG_ERROR, "%a: failed to locate 'pcie0' alias\n", __FUNCTIO= N__)); + return EFI_NOT_FOUND; + } + + // non translated 32-bit DMA window with a limit of 0xc0000000 + DmaRanges[0] =3D cpu_to_fdt32 (0x02000000);=20 + DmaRanges[1] =3D cpu_to_fdt32 (0x00000000);=20 + DmaRanges[2] =3D cpu_to_fdt32 (0x00000000); + DmaRanges[3] =3D cpu_to_fdt32 (0x00000000); + DmaRanges[4] =3D cpu_to_fdt32 (0x00000000); + DmaRanges[5] =3D cpu_to_fdt32 (0x00000000); + DmaRanges[6] =3D cpu_to_fdt32 (0xc0000000); + + DEBUG ((DEBUG_INFO, "%a: Updating PCIe dma-ranges\n", __FUNCTION__)); + + /*=20 + * Match dma-ranges with the EDK2+ACPI setup we are using. This works + * around a failure in Linux and OpenBSD to reset the PCIe/XHCI correctly + * when in DT mode. + */ + Retval =3D fdt_setprop (mFdtImage, Node, "dma-ranges", + DmaRanges, sizeof DmaRanges); + if (Retval !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: failed to locate PCIe 'dma-ranges' property = (%d)\n", + __FUNCTION__, Retval)); + return EFI_NOT_FOUND; + } + + /* + * Now that we are always running without DMA translation, and with a 3G + * limit, there shouldn't be a need to reset/reload the XHCI. The + * possible problem is that the PCIe root port is itself being reset (by + * Linux+DT). The RPi foundation claims this is needed as a pre-req to + * reloading the XHCI firmware, which also implies that a PCI fundamental + * reset should cause the XHCI itself to reset. This isn't happening + * fully, otherwise reloading the firmware would be mandatory. As it is, + * recent kernels actually start to have problems following the XHCI + * reset notification mailbox! Instead lets stop the kernel from + * triggering the mailbox by removing the node. + */ + + Node =3D fdt_path_offset (mFdtImage, "/scb/pcie@7d500000/pci@1,0"); + if (Node < 0) { + // This can happen on CM4/etc which doesn't have an onboard XHCI + DEBUG ((DEBUG_INFO, "%a: failed to locate /scb/pcie@7d500000/pci@1/usb= @1\n", __FUNCTION__)); + } else { + Retval =3D fdt_del_node (mFdtImage, Node); + if (Retval !=3D 0) { + DEBUG ((DEBUG_ERROR, "Failed to remove /scb/pcie@7d500000/pci@1/usb@= 1\n")); + return EFI_NOT_FOUND; + } + } + +#endif + return EFI_SUCCESS; +} + /** @param ImageHandle of the loaded driver @param SystemTable Pointer to the System Table @@ -431,6 +501,11 @@ FdtDxeInitialize ( Print (L"Failed to update USB compatible properties: %r\n", Status); } =20 + SyncPcie (); + if (EFI_ERROR (Status)) { + Print (L"Failed to update PCIe address ranges: %r\n", Status); + } + DEBUG ((DEBUG_INFO, "Installed devicetree at address %p\n", mFdtImage)); Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid, mFdtImage); if (EFI_ERROR (Status)) { --=20 2.13.7 -=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 (#82250): https://edk2.groups.io/g/devel/message/82250 Mute This Topic: https://groups.io/mt/86424957/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 03:12:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82251+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82251+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590293; cv=none; d=zohomail.com; s=zohoarc; b=nwPaR3Sbx+i+m67q7s80XbSbNHKcAXjLGz50XrbcpZFSyr8vXWcLimv5pwMI9bIPRrHGhoDKbqYet2gmNsH7xtQUUn5Jw7vyvyDhddvvtWEBNMvwFR+tPnylo5SP3hKFpm6ftuRpioayE71szWtQuaHPARSsPwcGDGK/D8BSFak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590293; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=c5Wa5vmlOInxlr02KH+eSMPpLR1TR6rf8fy9awJQPa8=; b=GdVSugyhzj5325jCmWnjy/ZqHI3TWv3wB+1nA26GHGmflyUxqNubHWCtNlcdQb5y7tH2AB0agc1jT+RkNQ8FZjHAubQsUx0epYZDvksIt8NS2YO+9n3iGhIBTrQNR4R4a3dyVn5Rb8zIwMmEn8XA0BZvqYi2+vj2k/kQRtl0gXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82251+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634590293830980.7556588765937; Mon, 18 Oct 2021 13:51:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IVRqYY1788612xrl9VVJg5LE; Mon, 18 Oct 2021 13:51:33 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.134.1634590292530700943 for ; Mon, 18 Oct 2021 13:51:32 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0EB4011B3; Mon, 18 Oct 2021 13:51:32 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD9983F73D; Mon, 18 Oct 2021 13:51:31 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 2/5] Platform/RaspberryPi: Fix vfr warning caused by two defaults Date: Mon, 18 Oct 2021 15:51:24 -0500 Message-Id: <20211018205127.7099-3-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,jeremy.linton@arm.com X-Gm-Message-State: y5TgiftdPqN6Vjr6r3feIgrsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590293; bh=yPodwDCZX7R0h7Ao5FXDWNp3H4KGvAj+zMiBNkH5i/M=; h=Cc:Date:From:Reply-To:Subject:To; b=dO8BhtWpBwk6uT7lDEoBfn4Cszmmu8JxilmJwiOaumHI4QU0iq1f75yrgrk2VlffCCw QRcpsaRQSfvbMAOw5E5RgxgiA0jfQ/v20jv27mMsXPU4gm84/PiytY/V8o8+letjX4wWh XK1tDG5Yb5oYZLqa4bEyzOe9zmZ5F2TkKqk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634590294570100005 Content-Type: text/plain; charset="utf-8" The build has been tossing a warning about having two defaults for a while now, lets fix it. Signed-off-by: Jeremy Linton Reviewed-by: Andrei Warkentin --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index 18b3ec726e..e8bf16312d 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -192,7 +192,7 @@ formset flags =3D NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, option text =3D STRING_TOKEN(STR_ADVANCED_SYSTAB_ACPI), value = =3D SYSTEM_TABLE_MODE_ACPI, flags =3D 0; option text =3D STRING_TOKEN(STR_ADVANCED_SYSTAB_BOTH), value = =3D SYSTEM_TABLE_MODE_BOTH, flags =3D DEFAULT; - option text =3D STRING_TOKEN(STR_ADVANCED_SYSTAB_DT), value = =3D SYSTEM_TABLE_MODE_DT, flags =3D DEFAULT; + option text =3D STRING_TOKEN(STR_ADVANCED_SYSTAB_DT), value = =3D SYSTEM_TABLE_MODE_DT, flags =3D0; endoneof; =20 #if (RPI_MODEL =3D=3D 4) --=20 2.13.7 -=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 (#82251): https://edk2.groups.io/g/devel/message/82251 Mute This Topic: https://groups.io/mt/86424960/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 03:12:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82252+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82252+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590294; cv=none; d=zohomail.com; s=zohoarc; b=gHBUeyko2grij1FGqRn8f6pddi7+u2Rj9Nv3N+dTLUyyCX0B0J3U4e19lunC6+OVqLrQ5oOUcsb7r0FjqJms+riRbBwgw9hUKv/NwHIVAFB4RHLX19zcl9MoyYjZwjloHGL8/SX3vocs7k5oICZT6BUwD5tT946xfHxt3kKR4vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590294; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+P1rW9E9q+8dGpvlHMzjVKbMYLRN9SiDv8NlRYYn/vY=; b=ON09qrBME9MmWWbYl7aEXVOel9dkeORvQMvwj4h9fBiOeV61gz31b4ES93dSftqUUc+4gIMpYTd/X6BsFKYW6Insh/cxZ7SeXj4ClysbtptwUERPn/fLBqGzztBqQMtPT87MhXDfd5zkpi274fu9dZDOyxk7916CqYWqrRjN0Lo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82252+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16345902946295.070782804621217; Mon, 18 Oct 2021 13:51:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JvqqYY1788612xUjfVKcpa6A; Mon, 18 Oct 2021 13:51:34 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.135.1634590293387540245 for ; Mon, 18 Oct 2021 13:51:33 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10180D6E; Mon, 18 Oct 2021 13:51:33 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CC953F73D; Mon, 18 Oct 2021 13:51:32 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 3/5] Platform/RaspberryPi: Expand locking to cover return data Date: Mon, 18 Oct 2021 15:51:25 -0500 Message-Id: <20211018205127.7099-4-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,jeremy.linton@arm.com X-Gm-Message-State: UvcAiGNflAbiO3TAzTHVuzN5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590294; bh=48EIJcZK2M0+kBczmVSFEV1+Wer/w3JLDTDJgBxuSTA=; h=Cc:Date:From:Reply-To:Subject:To; b=j78LDiNdAzKokaxlaXcrcYU/qiarihToSCIMTNCVH/24sesLGdk+InI8xLNjR9uSFrc Dlv6//gfnxu5Xg/Nc0hOp27mb3StqVeTLtRUHasZDb0z6dcUrg3GSZ5H17ksnBqCrtWBT 96eIAZSHo+JqBrKHnhReLSQEtHvAILUlkhg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634590296652100014 Content-Type: text/plain; charset="utf-8" It appears that the locking for many of the mailbox commands is incorrect. All UEFI firmware calls to the RPi mailbox share a single mDmaBuffer. That buffer is used to fill out the command passed to the vc firmware, and record its response. The buffer is protected by mMailboxLock, yet in many cases the mailbox response is copied from the buffer after the lock has been released. This doesn't currently appear to be causing any problems, but should be fixed anyway. There are a couple other minor tweaks in this patch that are hard to justify on their own, one is a bit of whitespace cleanup, and the other is the addition of a debug message to print the returned clock rate for the requested clock. This latter print would have immediatly shown that the vc firmware was returning 0 as the emmc clock rate rather than something reasonable. Signed-off-by: Jeremy Linton Reviewed-by: Andrei Warkentin --- .../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 102 ++++++++++++-----= ---- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b= /Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index bf74148bbb..d38ffbc7d3 100644 --- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -203,7 +203,6 @@ RpiFirmwareSetPowerState ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); =20 if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { @@ -219,6 +218,7 @@ RpiFirmwareSetPowerState ( __FUNCTION__, PowerState ? "en" : "dis", DeviceId)); Status =3D EFI_DEVICE_ERROR; } + ReleaseSpinLock (&mMailboxLock); =20 return Status; } @@ -266,18 +266,20 @@ RpiFirmwareGetArmMemory ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); =20 if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Base =3D Cmd->TagBody.Base; *Size =3D Cmd->TagBody.Size; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -323,17 +325,18 @@ RpiFirmwareGetMacAddress ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 CopyMem (MacAddress, Cmd->TagBody.MacAddress, sizeof (Cmd->TagBody.MacAd= dress)); + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -378,17 +381,17 @@ RpiFirmwareGetSerial ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Serial =3D Cmd->TagBody.Serial; + ReleaseSpinLock (&mMailboxLock); // Some platforms return 0 or 0x0000000010000000 for serial. // For those, try to use the MAC address. if ((*Serial =3D=3D 0) || ((*Serial & 0xFFFFFFFF0FFFFFFFULL) =3D=3D 0)) { @@ -441,17 +444,18 @@ RpiFirmwareGetModel ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Model =3D Cmd->TagBody.Model; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -496,17 +500,18 @@ RpiFirmwareGetModelRevision ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Revision =3D Cmd->TagBody.Revision; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -538,17 +543,18 @@ RpiFirmwareGetFirmwareRevision ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Revision =3D Cmd->TagBody.Revision; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -831,18 +837,19 @@ RpiFirmwareGetFbSize ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0= x%x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Width =3D Cmd->TagBody.Width; *Height =3D Cmd->TagBody.Height; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -872,16 +879,18 @@ RpiFirmwareFreeFb (VOID) Cmd->EndTag =3D 0; =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); - ReleaseSpinLock (&mMailboxLock); =20 if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -935,19 +944,20 @@ RpiFirmwareAllocFb ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *Pitch =3D Cmd->Pitch.Pitch; *FbBase =3D Cmd->AllocFb.AlignmentBase - BCM2836_DMA_DEVICE_OFFSET; *FbSize =3D Cmd->AllocFb.Size; + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -999,13 +1009,12 @@ RpiFirmwareGetCommmandLine ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 @@ -1013,6 +1022,7 @@ RpiFirmwareGetCommmandLine ( if (Cmd->TagHead.TagValueSize >=3D BufferSize && Cmd->CommandLine[Cmd->TagHead.TagValueSize - 1] !=3D '\0') { DEBUG ((DEBUG_ERROR, "%a: insufficient buffer size\n", __FUNCTION__)); + ReleaseSpinLock (&mMailboxLock); return EFI_OUT_OF_RESOURCES; } =20 @@ -1026,6 +1036,7 @@ RpiFirmwareGetCommmandLine ( CommandLine[Cmd->TagHead.TagValueSize] =3D '\0'; } =20 + ReleaseSpinLock (&mMailboxLock); return EFI_SUCCESS; } =20 @@ -1075,18 +1086,20 @@ RpiFirmwareSetClockRate ( Cmd->TagBody.SkipTurbo =3D SkipTurbo ? 1 : 0; Cmd->EndTag =3D 0; =20 + DEBUG ((DEBUG_INFO, "%a: Request clock rate %X =3D %d\n", __FUNCTION__, = ClockId, ClockRate)); Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -1131,20 +1144,23 @@ RpiFirmwareGetClockRate ( Cmd->TagHead.TagValueSize =3D 0; Cmd->TagBody.ClockId =3D ClockId; Cmd->EndTag =3D 0; - +=20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 *ClockRate =3D Cmd->TagBody.ClockRate; + ReleaseSpinLock (&mMailboxLock); + + DEBUG ((DEBUG_INFO, "%a: Get Clock Rate return: ClockRate=3D%d ClockId= =3D%X\n", __FUNCTION__, *ClockRate, ClockId)); + return EFI_SUCCESS; } =20 @@ -1191,7 +1207,7 @@ RpiFirmwareGetMinClockRate ( { return RpiFirmwareGetClockRate (ClockId, RPI_MBOX_GET_MIN_CLOCK_RATE, Cl= ockRate); } - + #pragma pack() typedef struct { UINT32 ClockId; @@ -1236,16 +1252,17 @@ RpiFirmwareSetClockState ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); + ReleaseSpinLock (&mMailboxLock); return EFI_DEVICE_ERROR; } =20 + ReleaseSpinLock (&mMailboxLock); + return EFI_SUCCESS; } =20 @@ -1297,16 +1314,15 @@ RpiFirmwareSetGpio ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0= x%x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); } + ReleaseSpinLock (&mMailboxLock); } - + STATIC VOID EFIAPI @@ -1361,8 +1377,6 @@ RpiFirmwareNotifyXhciReset ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, @@ -1370,6 +1384,8 @@ RpiFirmwareNotifyXhciReset ( __FUNCTION__, Status, Cmd->BufferHead.Response)); } =20 + ReleaseSpinLock (&mMailboxLock); + return Status; } =20 @@ -1424,8 +1440,6 @@ RpiFirmwareNotifyGpioGetCfg ( =20 *Polarity =3D Cmd->TagBody.Polarity; =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, @@ -1433,6 +1447,8 @@ RpiFirmwareNotifyGpioGetCfg ( __FUNCTION__, Status, Cmd->BufferHead.Response)); } =20 + ReleaseSpinLock (&mMailboxLock); + return Status; } =20 @@ -1471,8 +1487,8 @@ RpiFirmwareNotifyGpioSetCfg ( =20 Status =3D RpiFirmwareNotifyGpioGetCfg (Gpio, &Result); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: Failed to get GPIO polarity\n", __FUNCTION__)= ); - Result =3D 0; //default polarity + DEBUG ((DEBUG_ERROR, "%a: Failed to get GPIO polarity\n", __FUNCTION= __)); + Result =3D 0; //default polarity } =20 =20 @@ -1488,7 +1504,7 @@ RpiFirmwareNotifyGpioSetCfg ( Cmd->BufferHead.Response =3D 0; Cmd->TagHead.TagId =3D RPI_MBOX_SET_GPIO_CONFIG; Cmd->TagHead.TagSize =3D sizeof (Cmd->TagBody); - + Cmd->TagBody.Gpio =3D 128 + Gpio; Cmd->TagBody.Direction =3D Direction; Cmd->TagBody.Polarity =3D Result; @@ -1501,17 +1517,17 @@ RpiFirmwareNotifyGpioSetCfg ( =20 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); =20 - ReleaseSpinLock (&mMailboxLock); - if (EFI_ERROR (Status) || Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0= x%x\n", __FUNCTION__, Status, Cmd->BufferHead.Response)); } - - RpiFirmwareSetGpio (Gpio,!State); - + + ReleaseSpinLock (&mMailboxLock); + + RpiFirmwareSetGpio (Gpio,!State); + =20 return Status; } @@ -1540,7 +1556,7 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwarePro= tocol =3D { RPiFirmwareGetModelInstalledMB, RpiFirmwareNotifyXhciReset, RpiFirmwareGetCurrentClockState, - RpiFirmwareSetClockState, + RpiFirmwareSetClockState, RpiFirmwareNotifyGpioSetCfg }; =20 --=20 2.13.7 -=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 (#82252): https://edk2.groups.io/g/devel/message/82252 Mute This Topic: https://groups.io/mt/86424962/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 03:12:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82253+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82253+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590295; cv=none; d=zohomail.com; s=zohoarc; b=Qhh7JT0wdpYYdwv1hOgPZBNV4pnOXQWHiKV0hulBAGO9rwS+fol2wiZCNqQQtU/hCdsLbm/47c2+9/j5Zic4hdCSV2llg1ODFbfh6bMSJ26nUETsXoiTpNgepZvufPdnKtuXct07f5noXVvsE6HcUz0+pZjBpliwmjAbcd6iQl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590295; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Ch2dmFqZpC/j1K5af/m/hqXsJmg4rFfxGVOu1wr7kZE=; b=eA0E0FlRkKW4ytmv5LW8GUkhU8RTOPKHjDGOn9FfOTjeWyR/HE5SEWqFFzE4NztmwtYcYuQevEOoFHWzmxyknFIwYB/xdk98t0CobvUTuDdTsSRIrHiBAEDwyKpjaiLijb7pCVkez0NQ1jOr1QIP44Rx9HSTrdHq+cGUZPkzt0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82253+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634590295620194.4579227259834; Mon, 18 Oct 2021 13:51:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id eHEiYY1788612xnnWZkaNHZn; Mon, 18 Oct 2021 13:51:35 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.136.1634590294693608263 for ; Mon, 18 Oct 2021 13:51:34 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4DA20ED1; Mon, 18 Oct 2021 13:51:34 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E16E23F73D; Mon, 18 Oct 2021 13:51:33 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 4/5] Platform/RaspberryPi: Normal memory should not be marked as uncached Date: Mon, 18 Oct 2021 15:51:26 -0500 Message-Id: <20211018205127.7099-5-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,jeremy.linton@arm.com X-Gm-Message-State: ER5ss5q0s1DoDn4YxndhGqrXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590295; bh=pBypAq/HzzeYml3wTqYtM4LfJ0+fMO3F1G7uGhPTtGI=; h=Cc:Date:From:Reply-To:Subject:To; b=eYADyY0YH/4M9qRfyJShiVZtF33KZhKvEyvNwEaOLVQwBt1L3S4JGLajknAoCSiFKKo Gir74ERdMmSHrdDhx0Caz0yFNMHHBS1+azUDTn6IEYb+AgmIfHwh3pnmjIy0UdGfKOzIe XgE8cOcKJx8zgYGT6lUOfLiV7nOhiS0/gU0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634591198579100001 Content-Type: text/plain; charset="utf-8" The efi spec seems to indicate that the efi uncacheable attribute should be mapped to device memory rather than normal-nc. This means that the uefi mem attribute for the >3G ram doesn't match the remainder of the RAM in the machine. So, lets remove the uncacheable attribute to make it more consistent. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 2ef7da67bd..415d99fadb 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -499,7 +499,7 @@ ApplyVariables ( =20 Status =3D gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, 3UL * BA= SE_1GB, SystemMemorySizeBelow4GB - (3UL * SIZE_1GB), - EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_ME= MORY_WB); + EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB); ASSERT_EFI_ERROR (Status); Status =3D gDS->SetMemorySpaceAttributes (3UL * BASE_1GB, SystemMemorySizeBelow4GB - (3UL * SIZE_1GB), EFI_MEMOR= Y_WB); @@ -511,7 +511,7 @@ ApplyVariables ( // Status =3D gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, 4UL * = BASE_1GB, SystemMemorySize - (4UL * SIZE_1GB), - EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_= MEMORY_WB); + EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB); ASSERT_EFI_ERROR (Status); Status =3D gDS->SetMemorySpaceAttributes (4UL * BASE_1GB, SystemMemorySize - (4UL * SIZE_1GB), EFI_MEMORY_WB); --=20 2.13.7 -=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 (#82253): https://edk2.groups.io/g/devel/message/82253 Mute This Topic: https://groups.io/mt/86424964/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 03:12:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82254+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82254+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590296; cv=none; d=zohomail.com; s=zohoarc; b=mZyrT3UysCUJ6k8YMj6ISmN7YstiOscnsf0T+fNf9IMXaiYwJkEK0OmVSufc38UyO2TKhzKWN+Cqj9M/P3769xkzUUgIpncjYjTLZK3/tvVb2TiZxd+eCRNpz0SvthLpRF98Eu8dFDXjooYds2M1oqEzwRt4/Sr/CMfdsWHjXjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590296; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hCc5VTO0spZs33MhBb4pmtq6JgxBr8GYg0duaH3Z+fE=; b=VMrsIHqoUq3TKtiqErH23qH+gOETsMqy+b48+p/bzvT4YMX4yieEBquW7tx6hiVq4cigfN79uRBaEoUkC8va0i3XSjtETu4+FJKIloCzC/NOjZASZwXjxTQFjr7s2lRj0xbRH2WIXvlqdVDJ/3UtKS2mpnkMC+p/kmUgCQKGaWw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82254+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634590296722911.02634900516; Mon, 18 Oct 2021 13:51:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kS83YY1788612xZWK2N7yTVo; Mon, 18 Oct 2021 13:51:36 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.155.1634590295534584673 for ; Mon, 18 Oct 2021 13:51:35 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 364B6D6E; Mon, 18 Oct 2021 13:51:35 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D20293F73D; Mon, 18 Oct 2021 13:51:34 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 5/5] Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot Date: Mon, 18 Oct 2021 15:51:27 -0500 Message-Id: <20211018205127.7099-6-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,jeremy.linton@arm.com X-Gm-Message-State: GNazCZAcEJumSUM2BKQ4YfCnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590296; bh=Jpk+QfP0hpSfLmA0dyWrcHIDViqHUsn9kKkrkrqyjwA=; h=Cc:Date:From:Reply-To:Subject:To; b=psMcsy2Pe7fpd2LVp7c6mbV5Ml+LQZGqhUMWUPv/iWCJBx5QZzW8PlTWpmbhG9j7MNQ CDIPzI6meaxRqt593fZTj5jmdcNPM8bcB5wmug+uyyBwKgn4FstnYW1VhTO8RSomDXqpF v1DVi4mt+e0VBJKgrdmhWYv6mizAfuK4cwk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634590298770100021 Content-Type: text/plain; charset="utf-8" In theory we should be properly cleaning up all the device drivers before hitting the big reset. The partition manager will issue flush commands to attached disks as it goes down. This assures that devices running in WB mod= e, which correctly handle flush/sync/etc commands, are persisted to physical media before reset. Without this, there are definitely cases where the relevant specifications don't guarantee persistence of data in their buffers in the face of reset conditions. We can't really do anything about the many devices that don't honor persistence requests, but we can start here. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 42 ++++++++++++++++++++= ++++ 1 file changed, 42 insertions(+) diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/Ra= spberryPi/Library/ResetLib/ResetLib.c index a70eee485d..2bcef8d4db 100644 --- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c +++ b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c @@ -19,11 +19,51 @@ #include #include #include +#include #include #include =20 #include =20 + +/** + Disconnect everything. + Modified from the UEFI 2.3 spec (May 2009 version) + +**/ +STATIC +VOID +DisconnectAll ( + VOID + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN HandleIndex; + + /* + * Retrieve the list of all handles from the handle database + */ + Status =3D gBS->LocateHandleBuffer ( + AllHandles, + NULL, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return; + } + + for (HandleIndex =3D 0; HandleIndex < HandleCount; HandleIndex++) { + gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL); + } + + gBS->FreePool(HandleBuffer); +} + + /** Resets the entire platform. =20 @@ -53,6 +93,8 @@ LibResetSystem ( */ EfiEventGroupSignal (&gRaspberryPiEventResetGuid); =20 + DisconnectAll (); + Delay =3D PcdGet32 (PcdPlatformResetDelay); if (Delay !=3D 0) { DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n", --=20 2.13.7 -=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 (#82254): https://edk2.groups.io/g/devel/message/82254 Mute This Topic: https://groups.io/mt/86424965/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-