From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 503D481A34 for ; Fri, 16 Dec 2016 10:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1481914669; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s77XIkcSzYjoE/37vOGJfJ44JEsy8I1k4RXlhLJzlGU=; b=VxjLs8Xk7nalIF3ciR+a5GX5Oe4+6Mp/DenYkbEeK0JtEdVvth6ACpZ6cmoWr/2C jpXf+oQ2tVbnFyS6+LSO90D0s2UStLCx8jko0jTMlc+kY7l/gcZhS4xiBPeCsnho o/iSnnYdiu/KTR50SauPAgJHVkuDj0JQYhuFi2B/td6VNxhUPgmQNSMeZioqbG0s AdKA8tAsHvfxn9GGNk81K5X/fv+O+I9FIbJx3X6rJtg8AXptTqKZS7BirJpVf6ks v7lpyk/JZY4imLSoxMXwZLjQjWwVunxCy56E0708YICDqA6hmAeQsCTiwFIP+hHI Yfe2GdV58F0VEpSdm9Sy6Q==; Received: from relay4.apple.com (relay4.apple.com [17.128.113.87]) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id 01.6D.06020.D2934585; Fri, 16 Dec 2016 10:57:49 -0800 (PST) X-AuditID: 11973e12-a7d449a000001784-b9-5854392de962 Received: from nwk-mmpp-sz10.apple.com (nwk-mmpp-sz10.apple.com [17.128.115.122]) by relay4.apple.com (Apple SCV relay) with SMTP id 02.91.20305.D2934585; Fri, 16 Dec 2016 10:57:49 -0800 (PST) MIME-version: 1.0 Received: from [17.153.89.39] by nwk-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OIA003HIKOCYP30@nwk-mmpp-sz10.apple.com>; Fri, 16 Dec 2016 10:57:49 -0800 (PST) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Fri, 16 Dec 2016 10:57:54 -0800 Cc: edk2-devel@lists.01.org Message-id: <624C74C7-61CA-4DF8-A097-148884B45F2D@apple.com> References: <744508F7-BA9E-4DEA-B065-010B01515EEC@apple.com> To: Arka Sharma X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsUi2FAYrqtrGRJhcHS+kcXmnh52iz2HjjI7 MHnsnHWX3aN79j+WAKYoLpuU1JzMstQifbsErowXX08yF/RJVnw8Z9jAuFiki5GTQ0LAROLA qwuMXYxcHEICexkl/nzqZoRJdG6/zw6ROMQo0df7jw0kwSsgKPFj8j2WLkYODmYBeYmD52VB wswCWhLfH7WyQNS/BRr07DsTSEJYQFzi3ZlNzBC2hcSdh6vB4mwCyhIr5n9gB7E5BYIlbr9b yAoyk0VAVWLmYxeImdISDyceZ4VYayOx+/kuqEPPMErM3vMR7FARAXWJ/ruzGEF6JQRkJWb/ 8gKpkRDYwibxZko78wRG4VlIzp6FcPYsJGcvYGRexSiUm5iZo5uZZ6KXWFCQk6qXnJ+7iREU 1tPthHYwnlpldYhRgINRiYc341dwhBBrYllxZe4hRmkOFiVx3gMqIRFCAumJJanZqakFqUXx RaU5qcWHGJk4OKUaGGsebdzXYSK6f5/Nae3JKr9DPNhPfP8d9NRc7JWci0JX/qWdu24YaWaz +vK0zz/xe6KBo9mJnrU9W2Q7pgesksjca77+WN/bBUXqKxo4jj9RTZSfUx019YX9gbd/Z6yy MuFbs9DGvqUwWCtvpW5Kf5NhvdW0Cy/+tHearDsZLc6dx8uwnffnQiWW4oxEQy3mouJEAAKi 1hpMAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42IRbCiu0tW1DIkwmNmoYrG5p4fdYs+ho8wO TB47Z91l9+ie/Y8lgCmKyyYlNSezLLVI3y6BK+PF15PMBX2SFR/PGTYwLhbpYuTkkBAwkejc fp8dwhaTuHBvPVsXIxeHkMAhRom+3n9sIAleAUGJH5PvsXQxcnAwC8hLHDwvCxJmFtCS+P6o lQWi/i2jxJ9n35lAEsIC4hLvzmxihrAtJO48XA0WZxNQllgx/wPYMk6BYInb7xaygsxkEVCV mPnYBWKmtMTDicdZIdbaSOx+vosRYv4ZRonZez4ygiREBNQl+u/OYgTplRCQlZj9y2sCo+As JJfOQrh0FpJLFzAyr2IUKErNSaw00UssKMhJ1UvOz93ECA7PwvAdjP+WWR1iFOBgVOLhzfgV HCHEmlhWXJkLDAoOZiUR3k6zkAgh3pTEyqrUovz4otKc1OJDjMlA509klhJNzgfGTl5JvKGJ iYGJsbGZsbG5iTlpwkrivBzOARFCAumJJanZqakFqUUwW5g4OKUaGI++0VzVUBXw8XJAcciV y8veWnr0LguKu2S4+rfBlx8u4tt2iNUc7tDzjdy76uLygruiT4M3JfxR6D6yQ/Go3u7DCqef PpRQ3uand9p056PNDzYtdDi/PH96Rn53TGhP3pKcw+2KUUor2ELNo6YyK/UwRgdHZXxPdTGw vu6fl3r0xPzwn897NymxFGckGmoxFxUnAgA3E9ESkwIAAA== Subject: Re: Closing PciIo protocol inside Stop() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 18:57:50 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Dec 16, 2016, at 1:22 AM, Arka Sharma 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 wrote: >> >> On Dec 15, 2016, at 3:15 AM, Arka Sharma 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