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 0E788C433EF for ; Thu, 14 Apr 2022 07:13:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C420881CA4; Thu, 14 Apr 2022 09:13:36 +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="j9HXQMBl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECD7083E60; Thu, 14 Apr 2022 09:13:34 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 2F2C0811A6 for ; Thu, 14 Apr 2022 09:13:31 +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=1649920404; bh=LGi6NiGHRM2Ik6ZHPQBf6wZL3x6dDyKIfX3b0FGsOIk=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=j9HXQMBlc+kcrmyckxCfI1XvjMqur8GQADlk72SLn3lgmUFvhQQ7QC/PNpuo1Wnla 7Q22MOkFBnF8Z9hXixIS/zD7q4ojkk+FB0R7q3xSk10FPFoVrvYjad6q1RxyfCIf+q HRSPtRR92iE9BcDtOWFiPnuHP9kMjMbDi2QcdHLg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([88.152.144.107]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MBm1e-1nopIm1eIu-00C8d7; Thu, 14 Apr 2022 09:13:24 +0200 Message-ID: <4af1598c-b05a-ca7c-2d3b-5130f25fd26d@gmx.de> Date: Thu, 14 Apr 2022 09:13:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v3 11/19] dm: disk: add UCLASS_PARTITION Content-Language: en-US To: AKASHI Takahiro , sjg@chromium.org, masami.hiramatsu@linaro.org, u-boot@lists.denx.de, lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, sr@denx.de, ilias.apalodimas@linaro.org References: <20220308113657.221101-1-takahiro.akashi@linaro.org> <20220308113657.221101-12-takahiro.akashi@linaro.org> <20220413031600.GA74827@laputa> <20220414061738.GC32435@laputa> From: Heinrich Schuchardt In-Reply-To: <20220414061738.GC32435@laputa> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:yX5P73VFAGopL0uV6TZSYV6DQrN0kT629so6B9DZIqLOtXzj3wA yZqxhA+bB3ihMcMeiDGS7Fjkv2jVdv3EJvuFL1sgflnKbel3ahsXkryXZJQHmufA+xaYu6C PFkbjtT6mTo4cL//LMr8VHATPyCXaUkgLo3M6Fpgr6CS/IyY2rcmmfk8TgvKvD/wxTCHTZv R7zc4+pzcmplP8ppC740A== X-UI-Out-Filterresults: notjunk:1;V03:K0:jiZkC92xq1Y=:3ebYhKi0J7RT98QEqgDjFP QMesyGahRJlM6KelKZvVDZpj0ggizRM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c 3ELXizAYulBsAY= 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.5 at phobos.denx.de X-Virus-Status: Clean On 4/14/22 08:17, AKASHI Takahiro wrote: > On Wed, Apr 13, 2022 at 12:16:00PM +0900, AKASHI Takahiro wrote: >> Heinrich, >> (and Simon) >> >> On Sat, Apr 09, 2022 at 09:05:07PM +0200, Heinrich Schuchardt wrote: >>> On 3/8/22 12:36, AKASHI Takahiro wrote: >>>> With this new function, UCLASS_PARTITION devices will be created as >>>> child nodes of UCLASS_BLK device. >>>> >>>> Signed-off-by: AKASHI Takahiro >>>> --- >>>> disk/Makefile | 3 + >>>> disk/disk-uclass.c | 153 +++++++++++++++++++++++++++++++++++++= ++++ >>>> include/dm/uclass-id.h | 1 + >>>> include/part.h | 11 +++ >>>> 4 files changed, 168 insertions(+) >>>> create mode 100644 disk/disk-uclass.c >>>> >>>> diff --git a/disk/Makefile b/disk/Makefile >>>> index 6ce5a687b36c..ec37b74f5f40 100644 >>>> --- a/disk/Makefile >>>> +++ b/disk/Makefile >>>> @@ -6,6 +6,9 @@ >>>> #ccflags-y +=3D -DET_DEBUG -DDEBUG >>>> >>>> obj-$(CONFIG_PARTITIONS) +=3D part.o >>>> +ifdef CONFIG_$(SPL_)BLK >>>> +obj-$(CONFIG_PARTITIONS) +=3D disk-uclass.o >>> >>> phycore-rk3288_defconfig has CONFIG_SPL_LIBDISK_SUPPORT=3Dn ("Support = disk >>> partitions"). >> >> I think that SPL_LIBDISK_SUPPORT no longer make any sense and is obsole= te. >> >>> But spl/disk/disk-uclass is built. >> >> Right, but what is strange is: >> - SPL_PARTITION is enabled by "default y if PARTITONS", while >> - none of any particular partition types is enabled for spl >> due to *explicit* disablement of >> # CONFIG_SPL_DOS_PARTITION is not set >> # CONFIG_SPL_EFI_PARTITION is not set >> in phycore-rk3288_defconfig. >> >> I think that disk/Kconfig should be revised. > > I still believe so, but we can also fix the issue specifically on rk3288 > by adding > # CONFIG_SPL_PARTITIONS is not set > # CONFIG_TPL_PARTITIONS is not set > to phycore-rk3288_defconfig. > > Are you satisfied with this solution? I don't care too much about that specific board. We should avoid unnecessary SPL size increase for all boards. The fix should be on the Kconfig level and not on the board level. Best regards Heinrich > > -Takahiro Akashi > >> -Takahiro Akashi >> >>> This leads to an unnecessary size increase of the SPL image. >>> With this size increase building fails. >>> >>> Best regards >>> >>> Heinrich >>> >>>> +endif >>>> obj-$(CONFIG_$(SPL_)MAC_PARTITION) +=3D part_mac.o >>>> obj-$(CONFIG_$(SPL_)DOS_PARTITION) +=3D part_dos.o >>>> obj-$(CONFIG_$(SPL_)ISO_PARTITION) +=3D part_iso.o >>>> diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c >>>> new file mode 100644 >>>> index 000000000000..4918a2f72d1e >>>> --- /dev/null >>>> +++ b/disk/disk-uclass.c >>>> @@ -0,0 +1,153 @@ >>>> +// SPDX-License-Identifier: GPL-2.0+ >>>> +/* >>>> + * Software partition device (UCLASS_PARTITION) >>>> + * >>>> + * Copyright (c) 2021 Linaro Limited >>>> + * Author: AKASHI Takahiro >>>> + */ >>>> + >>>> +#define LOG_CATEGORY UCLASS_PARTITION >>>> + >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> + >>>> +int part_create_block_devices(struct udevice *blk_dev) >>>> +{ >>>> + int part, count; >>>> + struct blk_desc *desc =3D dev_get_uclass_plat(blk_dev); >>>> + struct disk_partition info; >>>> + struct disk_part *part_data; >>>> + char devname[32]; >>>> + struct udevice *dev; >>>> + int ret; >>>> + >>>> + if (!CONFIG_IS_ENABLED(PARTITIONS) || >>>> + !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE)) >>>> + return 0; >>>> + >>>> + if (device_get_uclass_id(blk_dev) !=3D UCLASS_BLK) >>>> + return 0; >>>> + >>>> + /* Add devices for each partition */ >>>> + for (count =3D 0, part =3D 1; part <=3D MAX_SEARCH_PARTITIONS; part= ++) { >>>> + if (part_get_info(desc, part, &info)) >>>> + continue; >>>> + snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name, >>>> + part); >>>> + >>>> + ret =3D device_bind_driver(blk_dev, "blk_partition", >>>> + strdup(devname), &dev); >>>> + if (ret) >>>> + return ret; >>>> + >>>> + part_data =3D dev_get_uclass_plat(dev); >>>> + part_data->partnum =3D part; >>>> + part_data->gpt_part_info =3D info; >>>> + count++; >>>> + >>>> + ret =3D device_probe(dev); >>>> + if (ret) { >>>> + debug("Can't probe\n"); >>>> + count--; >>>> + device_unbind(dev); >>>> + >>>> + continue; >>>> + } >>>> + } >>>> + debug("%s: %d partitions found in %s\n", __func__, count, >>>> + blk_dev->name); >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static ulong blk_part_read(struct udevice *dev, lbaint_t start, >>>> + lbaint_t blkcnt, void *buffer) >>>> +{ >>>> + struct udevice *parent; >>>> + struct disk_part *part; >>>> + const struct blk_ops *ops; >>>> + >>>> + parent =3D dev_get_parent(dev); >>>> + ops =3D blk_get_ops(parent); >>>> + if (!ops->read) >>>> + return -ENOSYS; >>>> + >>>> + part =3D dev_get_uclass_plat(dev); >>>> + if (start >=3D part->gpt_part_info.size) >>>> + return 0; >>>> + >>>> + if ((start + blkcnt) > part->gpt_part_info.size) >>>> + blkcnt =3D part->gpt_part_info.size - start; >>>> + start +=3D part->gpt_part_info.start; >>>> + >>>> + return ops->read(parent, start, blkcnt, buffer); >>>> +} >>>> + >>>> +static ulong blk_part_write(struct udevice *dev, lbaint_t start, >>>> + lbaint_t blkcnt, const void *buffer) >>>> +{ >>>> + struct udevice *parent; >>>> + struct disk_part *part; >>>> + const struct blk_ops *ops; >>>> + >>>> + parent =3D dev_get_parent(dev); >>>> + ops =3D blk_get_ops(parent); >>>> + if (!ops->write) >>>> + return -ENOSYS; >>>> + >>>> + part =3D dev_get_uclass_plat(dev); >>>> + if (start >=3D part->gpt_part_info.size) >>>> + return 0; >>>> + >>>> + if ((start + blkcnt) > part->gpt_part_info.size) >>>> + blkcnt =3D part->gpt_part_info.size - start; >>>> + start +=3D part->gpt_part_info.start; >>>> + >>>> + return ops->write(parent, start, blkcnt, buffer); >>>> +} >>>> + >>>> +static ulong blk_part_erase(struct udevice *dev, lbaint_t start, >>>> + lbaint_t blkcnt) >>>> +{ >>>> + struct udevice *parent; >>>> + struct disk_part *part; >>>> + const struct blk_ops *ops; >>>> + >>>> + parent =3D dev_get_parent(dev); >>>> + ops =3D blk_get_ops(parent); >>>> + if (!ops->erase) >>>> + return -ENOSYS; >>>> + >>>> + part =3D dev_get_uclass_plat(dev); >>>> + if (start >=3D part->gpt_part_info.size) >>>> + return 0; >>>> + >>>> + if ((start + blkcnt) > part->gpt_part_info.size) >>>> + blkcnt =3D part->gpt_part_info.size - start; >>>> + start +=3D part->gpt_part_info.start; >>>> + >>>> + return ops->erase(parent, start, blkcnt); >>>> +} >>>> + >>>> +static const struct blk_ops blk_part_ops =3D { >>>> + .read =3D blk_part_read, >>>> + .write =3D blk_part_write, >>>> + .erase =3D blk_part_erase, >>>> +}; >>>> + >>>> +U_BOOT_DRIVER(blk_partition) =3D { >>>> + .name =3D "blk_partition", >>>> + .id =3D UCLASS_PARTITION, >>>> + .ops =3D &blk_part_ops, >>>> +}; >>>> + >>>> +UCLASS_DRIVER(partition) =3D { >>>> + .id =3D UCLASS_PARTITION, >>>> + .per_device_plat_auto =3D sizeof(struct disk_part), >>>> + .name =3D "partition", >>>> +}; >>>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h >>>> index 0e26e1d13824..230b1ea528cf 100644 >>>> --- a/include/dm/uclass-id.h >>>> +++ b/include/dm/uclass-id.h >>>> @@ -83,6 +83,7 @@ enum uclass_id { >>>> UCLASS_P2SB, /* (x86) Primary-to-Sideband Bus */ >>>> UCLASS_PANEL, /* Display panel, such as an LCD */ >>>> UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */ >>>> + UCLASS_PARTITION, /* Logical disk partition device */ >>>> UCLASS_PCH, /* x86 platform controller hub */ >>>> UCLASS_PCI, /* PCI bus */ >>>> UCLASS_PCI_EP, /* PCI endpoint device */ >>>> diff --git a/include/part.h b/include/part.h >>>> index 53cfbdd87671..95e30e60af10 100644 >>>> --- a/include/part.h >>>> +++ b/include/part.h >>>> @@ -253,6 +253,17 @@ void part_set_generic_name(const struct blk_desc= *dev_desc, >>>> int part_num, char *name); >>>> >>>> extern const struct block_drvr block_drvr[]; >>>> + >>>> +struct udevice; >>>> +/** >>>> + * part_create_block_devices - Create block devices for disk partiti= ons >>>> + * >>>> + * Create UCLASS_PARTITION udevices for each of disk partitions in @= parent >>>> + * >>>> + * @blk_dev: Whole disk device >>>> + */ >>>> +int part_create_block_devices(struct udevice *blk_dev); >>>> + >>>> #else >>>> static inline struct blk_desc *blk_get_dev(const char *ifname, int= dev) >>>> { return NULL; } >>>