diff mbox series

[3/5] efi_loader: disconnect all controllers when uninstalling a protocol

Message ID 20230615143941.416924-3-ilias.apalodimas@linaro.org
State New
Headers show
Series [1/5] efi_loader: check the status of disconnected drivers | expand

Commit Message

Ilias Apalodimas June 15, 2023, 2:39 p.m. UTC
When we are trying to uninstall a protocol interface from a controller
handle we are trying to disconnect drivers related to that protocol.
However, when we call efi_disconnect_all_drivers() we pass the protocol
GUID.  If 2 different drivers are using the same protocol interface and
one of them can't be stopped (e.g by returning EFI_DEVICE_ERROR) we
should stop uninstalling it.

Instead of explicitly passing the protocol GUID, pass NULL as an argument.
That will force efi_get_drivers() to return all drivers consuming the
interface regardless of the protocol GUID.
While at it call efi_disconnect_all_drivers() with a handle instead of
the efiobj

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_boottime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.39.2

Comments

Heinrich Schuchardt June 19, 2023, 7:03 a.m. UTC | #1
On 6/15/23 16:39, Ilias Apalodimas wrote:
> When we are trying to uninstall a protocol interface from a controller
> handle we are trying to disconnect drivers related to that protocol.
> However, when we call efi_disconnect_all_drivers() we pass the protocol
> GUID.  If 2 different drivers are using the same protocol interface and
> one of them can't be stopped (e.g by returning EFI_DEVICE_ERROR) we
> should stop uninstalling it.
>
> Instead of explicitly passing the protocol GUID, pass NULL as an argument.
> That will force efi_get_drivers() to return all drivers consuming the
> interface regardless of the protocol GUID.
> While at it call efi_disconnect_all_drivers() with a handle instead of
> the efiobj
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>   lib/efi_loader/efi_boottime.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index df675d0ad488..b148824c7ec5 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1374,7 +1374,7 @@ static efi_status_t efi_uninstall_protocol
>   	if (r != EFI_SUCCESS)
>   		goto out;
>   	/* Disconnect controllers */
> -	r = efi_disconnect_all_drivers(efiobj, protocol, NULL);
> +	r = efi_disconnect_all_drivers(handle, NULL, NULL);

When uninstalling a *single* protocol we don't want to disconnect
drivers for *all* protocols on this handle but only for the specified
one. This will not work if you don't pass the protocol GUID to
DisconnectController().

Best regards

Heinrich

>   	if (r != EFI_SUCCESS) {
>   		r = EFI_DEVICE_ERROR;
>   		goto out;
> --
> 2.39.2
>
Ilias Apalodimas June 19, 2023, 7:43 a.m. UTC | #2
On Mon, 19 Jun 2023 at 10:04, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 6/15/23 16:39, Ilias Apalodimas wrote:
> > When we are trying to uninstall a protocol interface from a controller
> > handle we are trying to disconnect drivers related to that protocol.
> > However, when we call efi_disconnect_all_drivers() we pass the protocol
> > GUID.  If 2 different drivers are using the same protocol interface and
> > one of them can't be stopped (e.g by returning EFI_DEVICE_ERROR) we
> > should stop uninstalling it.
> >
> > Instead of explicitly passing the protocol GUID, pass NULL as an argument.
> > That will force efi_get_drivers() to return all drivers consuming the
> > interface regardless of the protocol GUID.
> > While at it call efi_disconnect_all_drivers() with a handle instead of
> > the efiobj
> >
> > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> >   lib/efi_loader/efi_boottime.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> > index df675d0ad488..b148824c7ec5 100644
> > --- a/lib/efi_loader/efi_boottime.c
> > +++ b/lib/efi_loader/efi_boottime.c
> > @@ -1374,7 +1374,7 @@ static efi_status_t efi_uninstall_protocol
> >       if (r != EFI_SUCCESS)
> >               goto out;
> >       /* Disconnect controllers */
> > -     r = efi_disconnect_all_drivers(efiobj, protocol, NULL);
> > +     r = efi_disconnect_all_drivers(handle, NULL, NULL);
>
> When uninstalling a *single* protocol we don't want to disconnect
> drivers for *all* protocols on this handle but only for the specified
> one. This will not work if you don't pass the protocol GUID to
> DisconnectController().

Right, I missread the spec and the selftests are probably wrong as well...
I'll fix that on v2

Thanks
/Ilias
>
> Best regards
>
> Heinrich
>
> >       if (r != EFI_SUCCESS) {
> >               r = EFI_DEVICE_ERROR;
> >               goto out;
> > --
> > 2.39.2
> >
>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index df675d0ad488..b148824c7ec5 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1374,7 +1374,7 @@  static efi_status_t efi_uninstall_protocol
 	if (r != EFI_SUCCESS)
 		goto out;
 	/* Disconnect controllers */
-	r = efi_disconnect_all_drivers(efiobj, protocol, NULL);
+	r = efi_disconnect_all_drivers(handle, NULL, NULL);
 	if (r != EFI_SUCCESS) {
 		r = EFI_DEVICE_ERROR;
 		goto out;