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 73FDEC433EF for ; Sat, 5 Feb 2022 09:35:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1BFD83A90; Sat, 5 Feb 2022 10:35:17 +0100 (CET) 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="HNvVBxQy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44F1883A9A; Sat, 5 Feb 2022 10:35:15 +0100 (CET) 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 C9A0083A8D for ; Sat, 5 Feb 2022 10:35:11 +0100 (CET) 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=1644053698; bh=nE0H4go5AjzTaEorNwOLTUrtO4Qo/fVjtyhr2Crw/m0=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=HNvVBxQyWi063Lpu6HX9vTyO/MS2DLwjlwMHyI3D6LKM2TsYgG0EJOCIqhdCjrHI7 zVsL+NgmNozUAtLrNfITxA7QdMvo6VUtL49rY9GCcxuueTOaUOttAg65jLlZB36AgA 08ey7RDu++ePml9I/3S4valls/2QxOh9I5to3A10= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([88.152.144.107]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTRMi-1mmYJi0ITU-00ToDt; Sat, 05 Feb 2022 10:34:58 +0100 Message-ID: <1da5bba0-01eb-4dbf-44ef-90a0a5da8acb@gmx.de> Date: Sat, 5 Feb 2022 10:34:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 09/19] dm: add tag support Content-Language: en-US To: AKASHI Takahiro Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, lukma@denx.de, peng.fan@nxp.com, peng.ma@nxp.com, bmeng.cn@gmail.com, sjg@chromium.org, ilias.apalodimas@linaro.org, jh80.chung@samsung.com, sr@denx.de References: <20220202010853.40405-1-takahiro.akashi@linaro.org> <20220202010853.40405-10-takahiro.akashi@linaro.org> From: Heinrich Schuchardt In-Reply-To: <20220202010853.40405-10-takahiro.akashi@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:I+2LJayOHfaytOITr3n9PCHnTsQQghxriPU/0o8H8hGp26pPBwr UKdOl3WnBUpJwPbxjitz96JTIRQBjzNEF9leAAdN6Sp65DI8tGVdX1GOZfDhQxY/r7d55N3 qWEMEek4VP9KTi3KrCotZZIFddHnCystLbDotKh3LcEXxaOaUdugx+CBK5VPGTw2EhteDC1 EMtR8o8ApoQ2m1YIBsvJA== X-UI-Out-Filterresults: notjunk:1;V03:K0:3HJnSg5E55A=:NGvkVZs9yy4RhgbOTWMGs/ db6sOl386G1FAJKgEH8INWRkzMF5SU6ft1jZR2CXWUtNv0GCdiSOnaTyeGC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x.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.5 at phobos.denx.de X-Virus-Status: Clean On 2/2/22 02:08, AKASHI Takahiro wrote: > With dm-tag feature, any U-Boot subsystem is allowed to associate > arbitrary number of data with a particular udevice. This can been > see as expanding "struct udevice" without modifying the definition. > > As a first user, UEFI subsystem makes use of tags to associate > an efi_disk object with a block device. > > Signed-off-by: AKASHI Takahiro > --- > drivers/core/Makefile | 2 +- > drivers/core/root.c | 2 + > drivers/core/tag.c | 139 ++++++++++++++++++++++++++++++ > include/asm-generic/global_data.h | 1 + > include/dm/tag.h | 110 +++++++++++++++++++++++ > 5 files changed, 253 insertions(+), 1 deletion(-) > create mode 100644 drivers/core/tag.c > create mode 100644 include/dm/tag.h > > diff --git a/drivers/core/Makefile b/drivers/core/Makefile > index 5edd4e413576..3742e7574525 100644 > --- a/drivers/core/Makefile > +++ b/drivers/core/Makefile > @@ -2,7 +2,7 @@ > # > # Copyright (c) 2013 Google, Inc > > -obj-y +=3D device.o fdtaddr.o lists.o root.o uclass.o util.o > +obj-y +=3D device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o > obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) +=3D acpi.o > obj-$(CONFIG_DEVRES) +=3D devres.o > obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) +=3D device-remove.o > diff --git a/drivers/core/root.c b/drivers/core/root.c > index e3f87956d866..1aa4819ceb6c 100644 > --- a/drivers/core/root.c > +++ b/drivers/core/root.c > @@ -199,6 +199,8 @@ int dm_init(bool of_live) > return ret; > } > > + INIT_LIST_HEAD((struct list_head *)&gd->dmtag_list); > + > return 0; > } > > diff --git a/drivers/core/tag.c b/drivers/core/tag.c > new file mode 100644 > index 000000000000..6829bcd8806c > --- /dev/null > +++ b/drivers/core/tag.c > @@ -0,0 +1,139 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (c) 2021 Linaro Limited > + * Author: AKASHI Takahiro > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct udevice; > + > +DECLARE_GLOBAL_DATA_PTR; > + > +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr) > +{ > + struct dmtag_node *node; > + > + if (!dev || tag >=3D DM_TAG_COUNT) > + return -EINVAL; > + > + list_for_each_entry(node, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev && node->tag =3D=3D tag) > + return -EEXIST; > + } > + > + node =3D calloc(sizeof(*node), 1); > + if (!node) > + return -ENOSPC; > + > + node->dev =3D dev; > + node->tag =3D tag; > + node->ptr =3D ptr; > + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); > + > + return 0; > +} > + > +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val) > +{ > + struct dmtag_node *node; > + > + if (!dev || tag >=3D DM_TAG_COUNT) > + return -EINVAL; > + > + list_for_each_entry(node, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev && node->tag =3D=3D tag) > + return -EEXIST; > + } > + > + node =3D calloc(sizeof(*node), 1); > + if (!node) > + return -ENOSPC; > + > + node->dev =3D dev; > + node->tag =3D tag; > + node->val =3D val; > + list_add_tail(&node->sibling, (struct list_head *)&gd->dmtag_list); > + > + return 0; > +} > + > +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp= ) > +{ > + struct dmtag_node *node; > + > + if (!dev || tag >=3D DM_TAG_COUNT) > + return -EINVAL; > + > + list_for_each_entry(node, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev && node->tag =3D=3D tag) { > + *ptrp =3D node->ptr; > + return 0; > + } > + } > + > + return -ENOENT; > +} > + > +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp= ) > +{ > + struct dmtag_node *node; > + > + if (!dev || tag >=3D DM_TAG_COUNT) > + return -EINVAL; > + > + list_for_each_entry(node, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev && node->tag =3D=3D tag) { > + *valp =3D node->val; > + return 0; > + } > + } > + > + return -ENOENT; > +} > + > +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag) > +{ > + struct dmtag_node *node, *tmp; > + > + if (!dev || tag >=3D DM_TAG_COUNT) > + return -EINVAL; > + > + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev && node->tag =3D=3D tag) { > + list_del(&node->sibling); > + free(node); > + > + return 0; > + } > + } > + > + return -ENOENT; > +} > + > +int dev_tag_del_all(struct udevice *dev) > +{ > + struct dmtag_node *node, *tmp; > + bool found =3D false; > + > + if (!dev) > + return -EINVAL; > + > + list_for_each_entry_safe(node, tmp, &gd->dmtag_list, sibling) { > + if (node->dev =3D=3D dev) { > + list_del(&node->sibling); > + free(node); > + found =3D true; > + } > + } > + > + if (found) > + return 0; > + > + return -ENOENT; > +} > diff --git a/include/asm-generic/global_data.h b/include/asm-generic/glo= bal_data.h > index 9f4598f09ee5..b887bef6deef 100644 > --- a/include/asm-generic/global_data.h > +++ b/include/asm-generic/global_data.h > @@ -470,6 +470,7 @@ struct global_data { > #if CONFIG_IS_ENABLED(EVENT) > struct event_state *event_state; > #endif > + struct list_head dmtag_list; This breaks 'make htmldocs'. You have to describe the new element. Best regards Heinrich > }; > #ifndef DO_DEPS_ONLY > static_assert(sizeof(struct global_data) =3D=3D GD_SIZE); > diff --git a/include/dm/tag.h b/include/dm/tag.h > new file mode 100644 > index 000000000000..54fc31eb1539 > --- /dev/null > +++ b/include/dm/tag.h > @@ -0,0 +1,110 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +/* > + * Copyright (c) 2021 Linaro Limited > + * Author: AKASHI Takahiro > + */ > + > +#ifndef _DM_TAG_H > +#define _DM_TAG_H > + > +#include > +#include > + > +struct udevice; > + > +enum dm_tag_t { > + /* EFI_LOADER */ > + DM_TAG_EFI =3D 0, > + > + DM_TAG_COUNT, > +}; > + > +/** > + * dmtag_node > + * > + * @sibling: List of dm-tag nodes > + * @dev: Associated udevice > + * @tag: Tag type > + * @ptr: Pointer as a value > + * @val: Value > + */ > +struct dmtag_node { > + struct list_head sibling; > + struct udevice *dev; > + enum dm_tag_t tag; > + union { > + void *ptr; > + ulong val; > + }; > +}; > + > +/** > + * dev_tag_set_ptr() - set a tag's value as a pointer > + * @dev: Device to operate > + * @tag: Tag type > + * @ptr: Pointer to set > + * > + * Set the value, @ptr, as of @tag associated with the device, @dev > + * > + * Return: 0 on success, -ve on error > + */ > +int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr); > + > +/** > + * dev_tag_set_val() set a tag's value as an integer > + * @dev: Device to operate > + * @tag: Tag type > + * @val: Value to set > + * > + * Set the value, @val, as of @tag associated with the device, @dev > + * > + * Return: on success, -ve on error > + */ > +int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val); > + > +/** > + * dev_tag_get_ptr() - get a tag's value as a pointer > + * @dev: Device to operate > + * @tag: Tag type > + * @ptrp: Pointer to tag's value (pointer) > + * > + * Get a tag's value as a pointer > + * > + * Return: on success, -ve on error > + */ > +int dev_tag_get_ptr(struct udevice *dev, enum dm_tag_t tag, void **ptrp= ); > + > +/** > + * dev_tag_get_val() - get a tag's value as an integer > + * @dev: Device to operate > + * @tag: Tag type > + * @valp: Pointer to tag's value (ulong) > + * > + * Get a tag's value as an integer > + * > + * Return: 0 on success, -ve on error > + */ > +int dev_tag_get_val(struct udevice *dev, enum dm_tag_t tag, ulong *valp= ); > + > +/** > + * dev_tag_del() - delete a tag > + * @dev: Device to operate > + * @tag: Tag type > + * > + * Delete a tag of @tag associated with the device, @dev > + * > + * Return: 0 on success, -ve on error > + */ > +int dev_tag_del(struct udevice *dev, enum dm_tag_t tag); > + > +/** > + * dev_tag_del_all() - delete all tags > + * @dev: Device to operate > + * > + * Delete all the tags associated with the device, @dev > + * > + * Return: 0 on success, -ve on error > + */ > +int dev_tag_del_all(struct udevice *dev); > + > +#endif /* _DM_TAG_H */