During the time when the device handle with PciIo is published? Presumably only via the event callbacks (thus no). I see a similar approach done in ArmJunoDxe to populate MAC address into the PCI device. I'm up for the RpiFirmwareDxe cleanup (as fas as moving to a model where the TPL is raised instead of using spinlock), but could that be done separately to this change? A ________________________________ From: Ard Biesheuvel Sent: Monday, June 1, 2020 4:44 AM To: Andrei Warkentin ; Andrei Warkentin ; devel@edk2.groups.io Cc: leif@nuviainc.com ; pete@akeo.ie ; philmd@redhat.com Subject: Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Pi4: notify VPU to load xHCI firmware before XhciDxe binds On 6/1/20 11:37 AM, Andrei Warkentin wrote: > Hi Ard, > > The xHCI controller is initialized with its microcode by the VPU > firmware, if > I understood correctly, synchronously. When RPI_MBOX_NOTIFY_XHCI_RESET > finishes, the XHCI controller is ready to go. > I suppose there are no other agents that may consume the config space during this time, right? > So this is not any more unsafe than any of the other mailbox calls. To > be honest, I think RpiFirmwareDxe should be cleaned up to replace the > useless spinlocks (there's no multiprocessing component) with a TPL > manip (I checked SynchonizationLib and it doesn't touch the TPL) > The spinlock protects from re-entrancy: if an event callback routine (such as the one you are adding for PCI I/O protocol registration) attempts to do a firmware call while one is already in progress, it will fail. But perhaps it is indeed better to run at TPL_NOTIFY level - that way, the calls will be ordered one after the other instead of one being shot down. > Applying your other feedback now... > > A > ------------------------------------------------------------------------ > *From:* devel@edk2.groups.io on behalf of Ard > Biesheuvel via groups.io > >> + >> + Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result); >> + > > So this pokes the XHCI controller via its config space? Is it safe to do > that without raising the TPL? What happens if another config space > access occurs concurrently? > > A