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 0130EC433F5 for ; Wed, 13 Apr 2022 03:16:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3C0883E43; Wed, 13 Apr 2022 05:16:13 +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="uvEBnTlJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 194C183E63; Wed, 13 Apr 2022 05:16:12 +0200 (CEST) Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 3DB0083E41 for ; Wed, 13 Apr 2022 05:16:08 +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=takahiro.akashi@linaro.org Received: by mail-pl1-x632.google.com with SMTP id v12so819940plv.4 for ; Tue, 12 Apr 2022 20:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=1idi+eiH0icxtz/vsq4TMzvYtIjO4+DUP5p5jj8LhEw=; b=uvEBnTlJwswk7Ry5yNOF24V+ofA2jAE60Vd71JPEeperKF1Q2+BrbocfQG0BB60LE1 HPBv8chWJRu+pfuatkkolE5KDH088/AQWX7ZuaYya6ZXuCjO5aSOx9f7FpczIVrnudF3 vdnTUZBTMCgLOZ7EWFe8VB8XeR4yfOjLJ1l0hPeX9xYkGu9/LzfwHy8CBa/zzE5/gq9C VxjR2xfaQTTg1oDk0X/1+eCEbkTWcf+OTXsdsscIrgYcsfwjoMYWrnoUeWrR+XZDndRe IlosCFW+vGVvozU2tZ+sxMEeM02Xr2ee0nEjRSfCggRpzBmi5phBiFfAyUOAHXDgrjGI m7Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=1idi+eiH0icxtz/vsq4TMzvYtIjO4+DUP5p5jj8LhEw=; b=Xjuz4QYV2qMKc2Mp3XFvhrERRFwtvtNNm8ypWbt8sftERPk83k89aAwYqN8jcoJyCd wKkJw+avx+eF7oRjwBTURiV9DV4Hym6Qzep/lTESSJdaoDGusyRymSMz882thg3hrEAx 4R81fdqDwNRn7XLEvO7LI/BMhLsdCyKbWXBu8I5kYZ13Ot68YS8XgjO3fXFqc/6EFjCb TrnB6SV/l7oQymRAH0YMtgMP1hkxP0JDMMEjhHiQLomFB4cSxF+udqcZXXIeaftkjokv guOoVa8GzjeLf67geFgsJKE8ri4yXkKKMXH3LusxvDRNHxpefCDTx/hfEEB/2MOEE2Ox zApA== X-Gm-Message-State: AOAM531fkbyEk2LHhyHeqhWULrE3A7aeM4ziJqbRErV2z++BReO99iG8 QLBIVK5/Fx4fbyzmRUdpNLqMVA== X-Google-Smtp-Source: ABdhPJyXClF2K2EfAm7x27wF4GGmGqNIjWaE0dk9nNmLhstwqBeJs/r9GkmyV7dSsWaThLHKaFQxFg== X-Received: by 2002:a17:903:1212:b0:156:3ddc:84bd with SMTP id l18-20020a170903121200b001563ddc84bdmr39649277plh.70.1649819766503; Tue, 12 Apr 2022 20:16:06 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:18ba:fbb1:88b:4642]) by smtp.gmail.com with ESMTPSA id a9-20020a056a000c8900b004fb37ecc6bbsm41900301pfv.65.2022.04.12.20.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 20:16:05 -0700 (PDT) Date: Wed, 13 Apr 2022 12:16:00 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: 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 Subject: Re: [PATCH v3 11/19] dm: disk: add UCLASS_PARTITION Message-ID: <20220413031600.GA74827@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 += -DET_DEBUG -DDEBUG > > > > obj-$(CONFIG_PARTITIONS) += part.o > > +ifdef CONFIG_$(SPL_)BLK > > +obj-$(CONFIG_PARTITIONS) += disk-uclass.o > > phycore-rk3288_defconfig has CONFIG_SPL_LIBDISK_SUPPORT=n ("Support disk > partitions"). I think that SPL_LIBDISK_SUPPORT no longer make any sense and is obsolete. > 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. -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) += part_mac.o > > obj-$(CONFIG_$(SPL_)DOS_PARTITION) += part_dos.o > > obj-$(CONFIG_$(SPL_)ISO_PARTITION) += 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 = 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) != UCLASS_BLK) > > + return 0; > > + > > + /* Add devices for each partition */ > > + for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { > > + if (part_get_info(desc, part, &info)) > > + continue; > > + snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name, > > + part); > > + > > + ret = device_bind_driver(blk_dev, "blk_partition", > > + strdup(devname), &dev); > > + if (ret) > > + return ret; > > + > > + part_data = dev_get_uclass_plat(dev); > > + part_data->partnum = part; > > + part_data->gpt_part_info = info; > > + count++; > > + > > + ret = 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 = dev_get_parent(dev); > > + ops = blk_get_ops(parent); > > + if (!ops->read) > > + return -ENOSYS; > > + > > + part = dev_get_uclass_plat(dev); > > + if (start >= part->gpt_part_info.size) > > + return 0; > > + > > + if ((start + blkcnt) > part->gpt_part_info.size) > > + blkcnt = part->gpt_part_info.size - start; > > + start += 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 = dev_get_parent(dev); > > + ops = blk_get_ops(parent); > > + if (!ops->write) > > + return -ENOSYS; > > + > > + part = dev_get_uclass_plat(dev); > > + if (start >= part->gpt_part_info.size) > > + return 0; > > + > > + if ((start + blkcnt) > part->gpt_part_info.size) > > + blkcnt = part->gpt_part_info.size - start; > > + start += 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 = dev_get_parent(dev); > > + ops = blk_get_ops(parent); > > + if (!ops->erase) > > + return -ENOSYS; > > + > > + part = dev_get_uclass_plat(dev); > > + if (start >= part->gpt_part_info.size) > > + return 0; > > + > > + if ((start + blkcnt) > part->gpt_part_info.size) > > + blkcnt = part->gpt_part_info.size - start; > > + start += part->gpt_part_info.start; > > + > > + return ops->erase(parent, start, blkcnt); > > +} > > + > > +static const struct blk_ops blk_part_ops = { > > + .read = blk_part_read, > > + .write = blk_part_write, > > + .erase = blk_part_erase, > > +}; > > + > > +U_BOOT_DRIVER(blk_partition) = { > > + .name = "blk_partition", > > + .id = UCLASS_PARTITION, > > + .ops = &blk_part_ops, > > +}; > > + > > +UCLASS_DRIVER(partition) = { > > + .id = UCLASS_PARTITION, > > + .per_device_plat_auto = sizeof(struct disk_part), > > + .name = "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 partitions > > + * > > + * 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; } >