On Tue, 11 Dec 2018 at 10:27, Pankaj Bansal <pankaj.bansal@xxxxxxx> wrote: > > > > > -----Original Message----- > > From: Ard Biesheuvel [mailto:ard.biesheuvel@xxxxxxxxxx] > > Sent: Tuesday, December 11, 2018 2:55 PM > > To: Pankaj Bansal <pankaj.bansal@xxxxxxx> > > Cc: Mark Rutland <mark.rutland@xxxxxxx>; Leif Lindholm > > <leif.lindholm@xxxxxxxxxx>; Grant Likely <grant.likely@xxxxxxx>; Varun Sethi > > <V.Sethi@xxxxxxx>; Udit Kumar <udit.kumar@xxxxxxx>; Bhupesh Sharma > > <bhsharma@xxxxxxxxxx>; linux-efi <linux-efi@xxxxxxxxxxxxxxx> > > Subject: Re: [PATCH v2 2/2] drivers: firmware: efi: install new fdt in > > configuration table > > > > On Tue, 11 Dec 2018 at 10:23, Pankaj Bansal <pankaj.bansal@xxxxxxx> wrote: > > > > > > > > > > > > > -----Original Message----- > > > > From: Ard Biesheuvel [mailto:ard.biesheuvel@xxxxxxxxxx] > > > > Sent: Tuesday, December 11, 2018 2:48 PM > > > > To: Pankaj Bansal <pankaj.bansal@xxxxxxx> > > > > Cc: Mark Rutland <mark.rutland@xxxxxxx>; Leif Lindholm > > > > <leif.lindholm@xxxxxxxxxx>; Grant Likely <grant.likely@xxxxxxx>; > > > > Varun Sethi <V.Sethi@xxxxxxx>; Udit Kumar <udit.kumar@xxxxxxx>; > > > > Bhupesh Sharma <bhsharma@xxxxxxxxxx>; linux-efi > > > > <linux-efi@xxxxxxxxxxxxxxx> > > > > Subject: Re: [PATCH v2 2/2] drivers: firmware: efi: install new fdt > > > > in configuration table > > > > > > > > On Tue, 11 Dec 2018 at 10:04, Pankaj Bansal <pankaj.bansal@xxxxxxx> > > wrote: > > > > > > > > > > Bootloader may need to fixup the device tree before OS can use it. > > > > > > > > > > Therefore, install fdt used by OS in configuration tables and > > > > > associate it with device tree guid. > > > > > > > > > > UEFI/DXE drivers can fixup this device tree in their respective > > > > > ExitBootServices events. > > > > > > > > > > Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> > > > > > Cc: linux-efi@xxxxxxxxxxxxxxx > > > > > Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx> > > > > > > > > I still think this is a bad idea. The firmware is closely tied to > > > > the platform, so it should provide the DT instead of the kernel. > > > > > > It is. It's just that firmware is responsible to fix the status of > > > devices before kernel can use those. In efi stub, the fdt is copied into new_fdt > > before exit boot services. > > > We need to fix the status of devices as part of exit boot services. We > > > cannot do it before, because firmware is using these device and they are not > > ready for kernel to use yet. > > > > > > > That doesn't matter. The kernel will not use devices from the DT before > > ExitBootServices() anyway. > > But what is the indication uefi driver has to "relieve the device and restore it because now kernel need to use it"? That is ExitBootServices(). > The kernel is just like any other UEFI application to uefi firmware. How will uefi firmware know when to relinquish control? At ExitBootServices() time. Any modification you make to the device tree can be made beforehand, since the kernel does not even read the device tree to discover devices until after the stub terminates.