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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACC2FC433EF for ; Sat, 23 Oct 2021 12:26:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6B6E560EB8 for ; Sat, 23 Oct 2021 12:26:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6B6E560EB8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 850108320D; Sat, 23 Oct 2021 14:26:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="aD0hWY+k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC36883303; Sat, 23 Oct 2021 14:26:12 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 863C380C72 for ; Sat, 23 Oct 2021 14:26:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634991964; bh=kzZ3HzFuWG1G+dYCLcWHspK2nFa8be8I+Vc2IANX7c8=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=aD0hWY+kR2rTIxaQ1lJMTyUl9wjfXWrLw6whag1/Nhg+fwwe3Ne88l9iDc9KQNB4P S72ZTRVQFYT2s9q8U99VEbGqFGoMQHv47lcMIDoCWM2D0PDbCGy3ctnrknMfbryE1O HhavjTZM3hOw5t0YF10eCFFvaLHE9iEx0bE1jTyw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MtOKc-1myO0o0Jtm-00usvW; Sat, 23 Oct 2021 14:26:04 +0200 Message-ID: Date: Sat, 23 Oct 2021 14:26:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH v2 15/39] efi: Add EFI uclass for media Content-Language: en-US To: Simon Glass Cc: Bin Meng , Christian Melki , Tom Rini , Ilias Apalodimas , Alexander Graf , U-Boot Mailing List References: <20210925003055.759305-1-sjg@chromium.org> <20210924183029.v2.15.I50ca59e389adf282bbff50eecc593f010a89c0f7@changeid> From: Heinrich Schuchardt In-Reply-To: <20210924183029.v2.15.I50ca59e389adf282bbff50eecc593f010a89c0f7@changeid> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:8mxnFa/vAcajdewoB7N/p8Ho4Z18XMgpFVK0NJRnYGZBCuPurzC hrVxZeZREuj4A27iNVVwjsStaQRGpNXEXEzKqVxZoTk7Lenu8/wYqj8LvAe8BP6aD+DQWpW 2djJ/eflw6lG1FIorQgae2+7LtEPXtGkAU2zOvYi0SKj0cibaKw4Mt+Men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gjV7o0Xt6e0fe+OsUyw4K2feq/srnmv2+WJQDoQP7cYnxW tzkGSuzog5y+8WrhSOC4/QDlsi54yrpe2W0O+nRNRuP0/drzBfG7A4+FhnnII9/fXS3jmWXC3 7Nkh5QERF0oxlw= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 9/25/21 02:30, Simon Glass wrote: > At present UCLASS_EFI is used to represent an EFI filesystem among other UCLASS_EFI is for UEFI drivers that provide the driver binding protocol. Your new UCLASS seems to be for U-Boot drivers consuming the EFI_BLOCK_IO_PROTOCOL. I agree that lib/efi_driver/efi_block_device.c is to much intertwined with the UEFI subsystem to easily merge it with your requirement. But it at least can serve as a template. > things. The description of this uclass is "EFI managed devices" which is > pretty vague. The only driver that uses this uclass is in fact not a rea= l > U-Boot driver, since its operations do not include a struct udevice. > > Rather than mess with this, create a new UCLASS_EFI_MEDIA uclass to hand= le > EFI media such as disks. Make this the uclass to use for EFI media so th= at In UEFI speak MEDIA relates to: * block devices * firmware files * Bluetooth * REST services * etc Do you only mean block devices? Why can't you use UCLASS_BLK for your new driver? Best regards Heinrich > it can be used with 'part list', for example. > > The existing implementation using UCLASS_EFI remains as is, for > discussion. > > Signed-off-by: Simon Glass > --- > > Changes in v2: > - Add MAINTAINERS entry > - Show the correct interface type with 'part list' > - Update the commit message to explain things better > > MAINTAINERS | 3 +++ > arch/sandbox/dts/test.dts | 4 ++++ > disk/part.c | 5 ++++- > drivers/block/Kconfig | 23 +++++++++++++++++++++++ > drivers/block/Makefile | 3 +++ > drivers/block/blk-uclass.c | 2 +- > drivers/block/efi-media-uclass.c | 15 +++++++++++++++ > drivers/block/sb_efi_media.c | 20 ++++++++++++++++++++ > include/dm/uclass-id.h | 1 + > test/dm/Makefile | 1 + > test/dm/efi_media.c | 24 ++++++++++++++++++++++++ > 11 files changed, 99 insertions(+), 2 deletions(-) > create mode 100644 drivers/block/efi-media-uclass.c > create mode 100644 drivers/block/sb_efi_media.c > create mode 100644 test/dm/efi_media.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index a254b705e73..0c1cbff7d01 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -708,8 +708,11 @@ W: https://u-boot.readthedocs.io/en/latest/develop/= uefi/u-boot_on_efi.html > F: board/efi/efi-x86_app > F: configs/efi-x86_app* > F: doc/develop/uefi/u-boot_on_efi.rst > +F: drivers/block/efi-media-uclass.c > +F: drivers/block/sb_efi_media.c > F: lib/efi/efi_app.c > F: scripts/build-efi.sh > +F: test/dm/efi_media.c > > EFI PAYLOAD > M: Heinrich Schuchardt > diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts > index b36447c4a79..23b8435a92a 100644 > --- a/arch/sandbox/dts/test.dts > +++ b/arch/sandbox/dts/test.dts > @@ -495,6 +495,10 @@ > compatible =3D "sandbox,clk-ccf"; > }; > > + efi-media { > + compatible =3D "sandbox,efi-media"; > + }; > + > eth@10002000 { > compatible =3D "sandbox,eth"; > reg =3D <0x10002000 0x1000>; > diff --git a/disk/part.c b/disk/part.c > index a6a8f7052bd..2560f6a50bc 100644 > --- a/disk/part.c > +++ b/disk/part.c > @@ -296,8 +296,11 @@ static void print_part_header(const char *type, str= uct blk_desc *dev_desc) > case IF_TYPE_VIRTIO: > puts("VirtIO"); > break; > + case IF_TYPE_EFI: > + puts("EFI"); > + break; > default: > - puts ("UNKNOWN"); > + puts("UNKNOWN"); > break; > } > printf (" device %d -- Partition Type: %s\n\n", > diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig > index 56a4eec05ac..755fdccb574 100644 > --- a/drivers/block/Kconfig > +++ b/drivers/block/Kconfig > @@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE > help > This option enables the disk-block cache in TPL > > +config EFI_MEDIA > + bool "Support EFI media drivers" > + default y if EFI || SANDBOX > + help > + Enable this to support media devices on top of UEFI. This enables > + just the uclass so you also need a specific driver to make this do > + anything. > + > + For sandbox there is a test driver. > + > +if EFI_MEDIA > + > +config EFI_MEDIA_SANDBOX > + bool "Sandbox EFI media driver" > + depends on SANDBOX > + default y > + help > + Enables a simple sandbox media driver, used for testing just the > + EFI_MEDIA uclass. It does not do anything useful, since sandbox does > + not actually support running on top of UEFI. > + > +endif # EFI_MEDIA > + > config IDE > bool "Support IDE controllers" > select HAVE_BLOCK_DEVICE > diff --git a/drivers/block/Makefile b/drivers/block/Makefile > index 94ab5c6f906..3778633da1d 100644 > --- a/drivers/block/Makefile > +++ b/drivers/block/Makefile > @@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) +=3D ide.o > endif > obj-$(CONFIG_SANDBOX) +=3D sandbox.o > obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) +=3D blkcache.o > + > +obj-$(CONFIG_EFI_MEDIA) +=3D efi-media-uclass.o > +obj-$(CONFIG_EFI_MEDIA_SANDBOX) +=3D sb_efi_media.o > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c > index 83682dcc181..2db7ce5de20 100644 > --- a/drivers/block/blk-uclass.c > +++ b/drivers/block/blk-uclass.c > @@ -44,7 +44,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT]= =3D { > [IF_TYPE_SATA] =3D UCLASS_AHCI, > [IF_TYPE_HOST] =3D UCLASS_ROOT, > [IF_TYPE_NVME] =3D UCLASS_NVME, > - [IF_TYPE_EFI] =3D UCLASS_EFI, UCLASS_EFI_MEDIA is only relevant for the EFI app and should not be compiled into normal U-Boot. This change is bound to break the UEFI sub-system. Why don't you define a new if_type for your use case? blk_get_devnum_by_typename() uses if_type to check if the corresponding uclass exists. Why is this check needed? If we remove it, we can drop if_type_uclass_id[] completely. This would be my preferred solution. Best regards Heinrich > + [IF_TYPE_EFI] =3D UCLASS_EFI_MEDIA, > [IF_TYPE_VIRTIO] =3D UCLASS_VIRTIO, > [IF_TYPE_PVBLOCK] =3D UCLASS_PVBLOCK, > }; > diff --git a/drivers/block/efi-media-uclass.c b/drivers/block/efi-media-= uclass.c > new file mode 100644 > index 00000000000..e012f6f2f4c > --- /dev/null > +++ b/drivers/block/efi-media-uclass.c > @@ -0,0 +1,15 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Uclass for EFI media devices > + * > + * Copyright 2021 Google LLC > + */ > + > +#include > +#include > + > +UCLASS_DRIVER(efi_media) =3D { > + .id =3D UCLASS_EFI_MEDIA, > + .name =3D "efi_media", > + .flags =3D DM_UC_FLAG_SEQ_ALIAS, > +}; > diff --git a/drivers/block/sb_efi_media.c b/drivers/block/sb_efi_media.c > new file mode 100644 > index 00000000000..52af155a600 > --- /dev/null > +++ b/drivers/block/sb_efi_media.c > @@ -0,0 +1,20 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * EFI_MEDIA driver for sandbox > + * > + * Copyright 2021 Google LLC > + */ > + > +#include > +#include > + > +static const struct udevice_id sandbox_efi_media_ids[] =3D { > + { .compatible =3D "sandbox,efi-media" }, > + { } > +}; > + > +U_BOOT_DRIVER(sandbox_efi_media) =3D { > + .name =3D "sandbox_efi_media", > + .id =3D UCLASS_EFI_MEDIA, > + .of_match =3D sandbox_efi_media_ids, > +}; > diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h > index 3768432b680..34f5e6689d3 100644 > --- a/include/dm/uclass-id.h > +++ b/include/dm/uclass-id.h > @@ -49,6 +49,7 @@ enum uclass_id { > UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ > UCLASS_ECDSA, /* Elliptic curve cryptographic device */ > UCLASS_EFI, /* EFI managed devices */ > + UCLASS_EFI_MEDIA, /* EFI media (e.g. a disk) */ > UCLASS_ETH, /* Ethernet device */ > UCLASS_ETH_PHY, /* Ethernet PHY device */ > UCLASS_FIRMWARE, /* Firmware */ > diff --git a/test/dm/Makefile b/test/dm/Makefile > index 55162e9499d..e24679eb640 100644 > --- a/test/dm/Makefile > +++ b/test/dm/Makefile > @@ -37,6 +37,7 @@ obj-$(CONFIG_DMA) +=3D dma.o > obj-$(CONFIG_VIDEO_MIPI_DSI) +=3D dsi_host.o > obj-$(CONFIG_DM_DSA) +=3D dsa.o > obj-$(CONFIG_ECDSA_VERIFY) +=3D ecdsa.o > +obj-$(CONFIG_EFI_MEDIA_SANDBOX) +=3D efi_media.o > obj-$(CONFIG_DM_ETH) +=3D eth.o > ifneq ($(CONFIG_EFI_PARTITION),) > obj-$(CONFIG_FASTBOOT_FLASH_MMC) +=3D fastboot.o > diff --git a/test/dm/efi_media.c b/test/dm/efi_media.c > new file mode 100644 > index 00000000000..e343a0e9c85 > --- /dev/null > +++ b/test/dm/efi_media.c > @@ -0,0 +1,24 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Test for EFI_MEDIA uclass > + * > + * Copyright 2021 Google LLC > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Test that we can use the EFI_MEDIA uclass */ > +static int dm_test_efi_media(struct unit_test_state *uts) > +{ > + struct udevice *dev; > + > + ut_assertok(uclass_first_device_err(UCLASS_EFI_MEDIA, &dev)); > + > + return 0; > +} > +DM_TEST(dm_test_efi_media, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); >