public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Andrew Fish <afish@apple.com>
To: Arka Sharma <arka.sw1988@gmail.com>
Cc: edk2-devel@lists.01.org
Subject: Re: Closing PciIo protocol inside Stop()
Date: Fri, 16 Dec 2016 10:57:54 -0800	[thread overview]
Message-ID: <624C74C7-61CA-4DF8-A097-148884B45F2D@apple.com> (raw)
In-Reply-To: <CAPO=kN0iNmq8ww4jxAu1oJz1Y69gkGvBx-OTwhDTekz0xGxFaQ@mail.gmail.com>


> 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



      reply	other threads:[~2016-12-16 18:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=624C74C7-61CA-4DF8-A097-148884B45F2D@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox