From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.33551.1591004650837052142 for ; Mon, 01 Jun 2020 02:44:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) 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 6F4851FB; Mon, 1 Jun 2020 02:44:10 -0700 (PDT) Received: from [192.168.1.69] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C1873F305; Mon, 1 Jun 2020 02:44:09 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Pi4: notify VPU to load xHCI firmware before XhciDxe binds To: Andrei Warkentin , Andrei Warkentin , "devel@edk2.groups.io" Cc: "leif@nuviainc.com" , "pete@akeo.ie" , "philmd@redhat.com" References: <20200601032130.95634-1-andrey.warkentin@gmail.com> <3121e7a6-afb7-038e-4fcd-5a317d3194e9@arm.com> From: "Ard Biesheuvel" Message-ID: <33ce3c90-7675-19aa-c659-6f5d4d51c368@arm.com> Date: Mon, 1 Jun 2020 11:44:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/1/20 11:37 AM, Andrei Warkentin wrote: > Hi Ard, >=20 > The xHCI controller is initialized with its microcode by the VPU=20 > firmware, if > I understood correctly, synchronously. When=A0RPI_MBOX_NOTIFY_XHCI_RESE= T=20 > finishes, the XHCI controller is ready to go. >=20 I suppose there are no other agents that may consume the config space=20 during this time, right? > So this is not any more unsafe than any of the other mailbox calls. To=20 > be honest, I think RpiFirmwareDxe should be cleaned up to replace the=20 > useless spinlocks (there's no multiprocessing component) with a TPL=20 > manip (I checked SynchonizationLib and it doesn't touch the TPL) >=20 The spinlock protects from re-entrancy: if an event callback routine=20 (such as the one you are adding for PCI I/O protocol registration)=20 attempts to do a firmware call while one is already in progress, it will=20 fail. But perhaps it is indeed better to run at TPL_NOTIFY level - that way,=20 the calls will be ordered one after the other instead of one being shot=20 down. > Applying your other feedback now... >=20 > A > -----------------------------------------------------------------------= - > *From:* devel@edk2.groups.io on behalf of Ard=20 > Biesheuvel via groups.io >=20 >> + >> +=A0 Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MB= OX_VC_CHANNEL, &Result); >> + >=20 > So this pokes the XHCI controller via its config space? Is it safe to d= o > that without raising the TPL? What happens if another config space > access occurs concurrently? >=20 > A