* Closing PciIo protocol inside Stop() @ 2016-12-15 11:15 Arka Sharma 2016-12-15 18:08 ` Andrew Fish 0 siblings, 1 reply; 4+ messages in thread From: Arka Sharma @ 2016-12-15 11:15 UTC (permalink / raw) To: edk2-devel I am wondering if the PciIo protocol instance for a PCI driver, is opened with _BY_DRIVER | EXCLUSIVE in Start() function, is not closed in the Stop() will the instance be uninstalled and the ControllerHandle removed ? Also is it possible to Close() the PciIo in Stop() and reopen the PciIo instance on the same controller handle from some other driver image with _BY_DRIVER attribute and accessing Pci resources on the ControllerHandle even after Stop() is called. I know it is not recommended way but curious about it. Or it could be specific to the implementation ? Thanks & Regards, ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Closing PciIo protocol inside Stop() 2016-12-15 11:15 Closing PciIo protocol inside Stop() Arka Sharma @ 2016-12-15 18:08 ` Andrew Fish 2016-12-16 9:22 ` Arka Sharma 0 siblings, 1 reply; 4+ messages in thread From: Andrew Fish @ 2016-12-15 18:08 UTC (permalink / raw) To: Arka Sharma; +Cc: edk2-devel > On Dec 15, 2016, at 3:15 AM, Arka Sharma <arka.sw1988@gmail.com> wrote: > > I am wondering if the PciIo protocol instance for a PCI driver, is > opened with _BY_DRIVER | EXCLUSIVE in Start() function, is not closed > in the Stop() will the instance be uninstalled and the > ControllerHandle removed ? > Don't do that. The Start() and Stop() need to be symmetric. If you don't Stop() properly I think your Stop() function could get called again, and that would be really bad if you your driver was unloaded or something like that. > Also is it possible to Close() the PciIo in Stop() and reopen the > PciIo instance on the same controller handle from some other driver > image with _BY_DRIVER attribute and accessing Pci resources on the > ControllerHandle even after Stop() is called. I know it is not > recommended way but curious about it. Or it could be specific to the > implementation ? Maybe you should just ask what you want to do? If you just want to dump out PCI info you can use gEfiPciRootBridgeIoProtocolGuid ByProtocol. There is an example in the Shell PCI command: https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c#L2537 <https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c#L2537> Note: On a large server, or exotic SoC there could be multiple gEfiPciRootBridgeIoProtocolGuid instances, and the Shell command deals with that. Thanks, Andrew Fish > > Thanks & Regards, > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Closing PciIo protocol inside Stop() 2016-12-15 18:08 ` Andrew Fish @ 2016-12-16 9:22 ` Arka Sharma 2016-12-16 18:57 ` Andrew Fish 0 siblings, 1 reply; 4+ messages in thread From: Arka Sharma @ 2016-12-16 9:22 UTC (permalink / raw) To: Andrew Fish; +Cc: edk2-devel Actually I am thinking if it will be possible to use PciIo from a driver on a ControllerHandle which managed by another driver which has been stopped. So is it possible that driver which wants to access it restarts the ControllerHandle with it's own DriverBindingHandle, or it is that as soon as the driver closes PciIo and DevicePath on the ControllerHandle inside Stop() function, the ControllerHandle is destroyed. On Thu, Dec 15, 2016 at 11:38 PM, Andrew Fish <afish@apple.com> wrote: > > On Dec 15, 2016, at 3:15 AM, Arka Sharma <arka.sw1988@gmail.com> wrote: > > I am wondering if the PciIo protocol instance for a PCI driver, is > opened with _BY_DRIVER | EXCLUSIVE in Start() function, is not closed > in the Stop() will the instance be uninstalled and the > ControllerHandle removed ? > > > Don't do that. The Start() and Stop() need to be symmetric. If you don't > Stop() properly I think your Stop() function could get called again, and > that would be really bad if you your driver was unloaded or something like > that. > > > Also is it possible to Close() the PciIo in Stop() and reopen the > PciIo instance on the same controller handle from some other driver > image with _BY_DRIVER attribute and accessing Pci resources on the > ControllerHandle even after Stop() is called. I know it is not > recommended way but curious about it. Or it could be specific to the > implementation ? > > > Maybe you should just ask what you want to do? > > If you just want to dump out PCI info you can use > gEfiPciRootBridgeIoProtocolGuid ByProtocol. There is an example in the Shell > PCI command: > https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c#L2537 > > Note: On a large server, or exotic SoC there could be multiple > gEfiPciRootBridgeIoProtocolGuid instances, and the Shell command deals with > that. > > Thanks, > > Andrew Fish > > > Thanks & Regards, > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Closing PciIo protocol inside Stop() 2016-12-16 9:22 ` Arka Sharma @ 2016-12-16 18:57 ` Andrew Fish 0 siblings, 0 replies; 4+ messages in thread From: Andrew Fish @ 2016-12-16 18:57 UTC (permalink / raw) To: Arka Sharma; +Cc: edk2-devel > On Dec 16, 2016, at 1:22 AM, Arka Sharma <arka.sw1988@gmail.com> wrote: > > Actually I am thinking if it will be possible to use PciIo from a > driver on a ControllerHandle which managed by another driver which has > been stopped. So is it possible that driver which wants to access it > restarts the ControllerHandle with it's own DriverBindingHandle, or it > is that as soon as the driver closes PciIo and DevicePath on the > ControllerHandle inside Stop() function, the ControllerHandle is > destroyed. > As long as there is only a single owner of the protocol from a driver model point of view you should be OK. A handle is destroyed when you uninstall all the protocols from it. Given the PCI bus driver placed a device path and PCI IO protocol on the handle other drivers are not going to make that handle go away. In general in the EFI Driver Model you have: Drivers: Adds protocols to an existing handle, usually opening a protocol on that handle. Bus Drivers: Opens a protocol(s) on a handle and creates a child handle. The Stop() function will uninstall the installed protocols and that will cause the child handle to be removed. If other drivers have opened handles on this bus drivers handle they will get Stopped first. Thanks, Andrew Fish > On Thu, Dec 15, 2016 at 11:38 PM, Andrew Fish <afish@apple.com> wrote: >> >> On Dec 15, 2016, at 3:15 AM, Arka Sharma <arka.sw1988@gmail.com> wrote: >> >> I am wondering if the PciIo protocol instance for a PCI driver, is >> opened with _BY_DRIVER | EXCLUSIVE in Start() function, is not closed >> in the Stop() will the instance be uninstalled and the >> ControllerHandle removed ? >> >> >> Don't do that. The Start() and Stop() need to be symmetric. If you don't >> Stop() properly I think your Stop() function could get called again, and >> that would be really bad if you your driver was unloaded or something like >> that. >> >> >> Also is it possible to Close() the PciIo in Stop() and reopen the >> PciIo instance on the same controller handle from some other driver >> image with _BY_DRIVER attribute and accessing Pci resources on the >> ControllerHandle even after Stop() is called. I know it is not >> recommended way but curious about it. Or it could be specific to the >> implementation ? >> >> >> Maybe you should just ask what you want to do? >> >> If you just want to dump out PCI info you can use >> gEfiPciRootBridgeIoProtocolGuid ByProtocol. There is an example in the Shell >> PCI command: >> https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c#L2537 >> >> Note: On a large server, or exotic SoC there could be multiple >> gEfiPciRootBridgeIoProtocolGuid instances, and the Shell command deals with >> that. >> >> Thanks, >> >> Andrew Fish >> >> >> Thanks & Regards, >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel >> >> > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-16 18:57 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-15 11:15 Closing PciIo protocol inside Stop() Arka Sharma 2016-12-15 18:08 ` Andrew Fish 2016-12-16 9:22 ` Arka Sharma 2016-12-16 18:57 ` Andrew Fish
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox