From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F185FC433FE for ; Mon, 10 Oct 2022 08:00:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3394384E1F; Mon, 10 Oct 2022 10:00:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SapTSVxO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7450184E21; Mon, 10 Oct 2022 10:00:25 +0200 (CEST) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5267984E1F for ; Mon, 10 Oct 2022 10:00:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62a.google.com with SMTP id r17so23143830eja.7 for ; Mon, 10 Oct 2022 01:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TZXS1oDhnxuHj17dHZ7Unqg02ppIKi9qWElwW39GMn0=; b=SapTSVxO5zax6wKlfPySWyUk6Rx5REnTr3IZlMmv1ows3ZXw3ySYirRZNQLwMyfM4I sZKu+Eof1vYxvTXSP/fA2vlzVmRDrWoh814zFqgAQkp6HE02xNG2TevsuL1aZeXMg44Z NVDCEr7UOXlgGQuI7T8c16Eyq50T3ch1mnEiXrHoyeoLzhx0bqAXqJ90muEgT8zqO3YC X+T0rvf7hb+ZNdQWlhC4hgmZRDLJ7WoQwH/cXj2LtO5X0oPBb5LApz+LkPRAULdT4FfX GBJ15O+uI9XKMrJPgfRFnTNg6ie7mMY01hrG7GGdF5cDRIrZkYE6r3glbnpqTSH3N+ff 8pDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TZXS1oDhnxuHj17dHZ7Unqg02ppIKi9qWElwW39GMn0=; b=q5TqJ4vipwf9+TNdeyWGOepftqD+F1OiaEZGPNoeF5wmsY7G7B7e/Q/VB63X7bP+nL Tljy6Xsk1tWHdwu50fEgfahtWUJUX72tpm09KdcNMVOhxclRKQkWQkiDVoaiVcJarCpg s5sM8ETs3C1ksOdHzCVI8hxWXsZcC7FoTMtY6lO0di6B3FVInF9/PW6WoclmpdhzsxHE gpmIxjjRClA8muqYFY0kLHDBMoUdw48MeVuxZrf3wdFp0DgjtMCUMO0RUH8HUMfuGq5N HAkP86SDKyV1E9q1trJwsdIigTT6d8V5thvQ9+bYaDwZE4HhvUCwwz72FWdlVK6XPlru q2Dg== X-Gm-Message-State: ACrzQf3eUVnIjwo60XNFWQobTVrzL+zDG8Tf1BN35jnwfAMg6vLYq59c rimWVVRe1CtDZ9RO5et7wPg3QkrD+dtyMw== X-Google-Smtp-Source: AMsMyM5r+f1AUS4pNu1uH/dHeZfl5x8L8DISgRsZEzSxahRGGa7imD0h0taBxCH7j9hv5/y7RzuCGQ== X-Received: by 2002:a17:906:8b81:b0:77e:cd92:9d with SMTP id nr1-20020a1709068b8100b0077ecd92009dmr13384299ejc.484.1665388820891; Mon, 10 Oct 2022 01:00:20 -0700 (PDT) Received: from hades (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id m6-20020a170906258600b0078d261f9f44sm4890239ejb.224.2022.10.10.01.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 01:00:20 -0700 (PDT) Date: Mon, 10 Oct 2022 11:00:18 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: Re: [PATCH 1/2] efi_loader: internal CloseProtocol Message-ID: References: <20221008071442.5963-1-heinrich.schuchardt@canonical.com> <20221008071442.5963-2-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221008071442.5963-2-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Sat, Oct 08, 2022 at 09:14:41AM +0200, Heinrich Schuchardt wrote: > Allow avoiding using EFI_CALL() when closing a protocol by providing an > internal function. > > Signed-off-by: Heinrich Schuchardt > --- > include/efi_loader.h | 9 ++-- > lib/efi_loader/efi_boottime.c | 90 ++++++++++++++++++++++------------- > 2 files changed, 61 insertions(+), 38 deletions(-) > > diff --git a/include/efi_loader.h b/include/efi_loader.h > index c70d977298..1bac3f49a3 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -661,11 +661,10 @@ efi_status_t EFIAPI efi_locate_handle_buffer( > enum efi_locate_search_type search_type, > const efi_guid_t *protocol, void *search_key, > efi_uintn_t *no_handles, efi_handle_t **buffer); > -/* Close an previously opened protocol interface */ > -efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle, > - const efi_guid_t *protocol, > - efi_handle_t agent_handle, > - efi_handle_t controller_handle); > +/* Close a previously opened protocol interface */ > +efi_status_t efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol, > + efi_handle_t agent_handle, > + efi_handle_t controller_handle); > /* Open a protocol interface */ > efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle, > const efi_guid_t *protocol, > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c > index e776d25830..9151aa771a 100644 > --- a/lib/efi_loader/efi_boottime.c > +++ b/lib/efi_loader/efi_boottime.c > @@ -1993,7 +1993,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy, > if (ret != EFI_SUCCESS) > efi_free_pages(addr, pages); > out: > - EFI_CALL(efi_close_protocol(device, guid, efi_root, NULL)); > + efi_close_protocol(device, guid, efi_root, NULL); > if (ret == EFI_SUCCESS) { > *buffer = (void *)(uintptr_t)addr; > *size = buffer_size; > @@ -2290,45 +2290,70 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, > * @agent_handle: handle of the driver > * @controller_handle: handle of the controller > * > - * This function implements the CloseProtocol service. > + * This is the function implementing the CloseProtocol service is for internal > + * usage in U-Boot. For API usage wrapper efi_close_protocol_ext() is provided. > * > * See the Unified Extensible Firmware Interface (UEFI) specification for > * details. > * > * Return: status code > */ > -efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle, > - const efi_guid_t *protocol, > - efi_handle_t agent_handle, > - efi_handle_t controller_handle) > +efi_status_t efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol, > + efi_handle_t agent_handle, > + efi_handle_t controller_handle) > { > struct efi_handler *handler; > struct efi_open_protocol_info_item *item; > struct efi_open_protocol_info_item *pos; > - efi_status_t r; > - > - EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, agent_handle, > - controller_handle); > + efi_status_t ret; > > if (!efi_search_obj(agent_handle) || > - (controller_handle && !efi_search_obj(controller_handle))) { > - r = EFI_INVALID_PARAMETER; > - goto out; > - } > - r = efi_search_protocol(handle, protocol, &handler); > - if (r != EFI_SUCCESS) > - goto out; > + (controller_handle && !efi_search_obj(controller_handle))) > + return EFI_INVALID_PARAMETER; > + ret = efi_search_protocol(handle, protocol, &handler); > + if (ret != EFI_SUCCESS) > + return ret; > > - r = EFI_NOT_FOUND; > + ret = EFI_NOT_FOUND; > list_for_each_entry_safe(item, pos, &handler->open_infos, link) { > if (item->info.agent_handle == agent_handle && > item->info.controller_handle == controller_handle) { > efi_delete_open_info(item); > - r = EFI_SUCCESS; > + ret = EFI_SUCCESS; > } > } > -out: > - return EFI_EXIT(r); > + > + return ret; > +} > + > +/** > + * efi_close_protocol_ext() - close a protocol > + * @handle: handle on which the protocol shall be closed > + * @protocol: GUID of the protocol to close > + * @agent_handle: handle of the driver > + * @controller_handle: handle of the controller > + * > + * This function implements the CloseProtocol service. > + * > + * See the Unified Extensible Firmware Interface (UEFI) specification for > + * details. > + * > + * Return: status code > + */ > +efi_status_t EFIAPI efi_close_protocol_ext(efi_handle_t handle, > + const efi_guid_t *protocol, > + efi_handle_t agent_handle, > + efi_handle_t controller_handle) > +{ This needs to be static Other than that Reviewed-by: Ilias Apalodimas > + efi_status_t ret; > + > + EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, agent_handle, > + controller_handle); > + > + ret = efi_close_protocol(handle, protocol, > + agent_handle, controller_handle); > + > + return EFI_EXIT(ret); > } > > /** > @@ -3213,11 +3238,10 @@ close_next: > if (info->info.agent_handle != > (efi_handle_t)image_obj) > continue; > - r = EFI_CALL(efi_close_protocol > - (efiobj, &protocol->guid, > - info->info.agent_handle, > - info->info.controller_handle > - )); > + r = efi_close_protocol( > + efiobj, &protocol->guid, > + info->info.agent_handle, > + info->info.controller_handle); > if (r != EFI_SUCCESS) > ret = r; > /* > @@ -3481,9 +3505,9 @@ static efi_status_t efi_bind_controller( > r = EFI_CALL(binding_protocol->start(binding_protocol, > controller_handle, > remain_device_path)); > - EFI_CALL(efi_close_protocol(driver_image_handle, > - &efi_guid_driver_binding_protocol, > - driver_image_handle, NULL)); > + efi_close_protocol(driver_image_handle, > + &efi_guid_driver_binding_protocol, > + driver_image_handle, NULL); > return r; > } > > @@ -3834,9 +3858,9 @@ static efi_status_t EFIAPI efi_disconnect_controller( > goto out; > } > } > - EFI_CALL(efi_close_protocol(driver_image_handle, > - &efi_guid_driver_binding_protocol, > - driver_image_handle, NULL)); > + efi_close_protocol(driver_image_handle, > + &efi_guid_driver_binding_protocol, > + driver_image_handle, NULL); > r = EFI_SUCCESS; > out: > if (!child_handle) > @@ -3883,7 +3907,7 @@ static struct efi_boot_services efi_boot_services = { > .connect_controller = efi_connect_controller, > .disconnect_controller = efi_disconnect_controller, > .open_protocol = efi_open_protocol, > - .close_protocol = efi_close_protocol, > + .close_protocol = efi_close_protocol_ext, > .open_protocol_information = efi_open_protocol_information, > .protocols_per_handle = efi_protocols_per_handle, > .locate_handle_buffer = efi_locate_handle_buffer, > -- > 2.37.2 >