Message ID | 96510d925cb0ca1a3a132f8f8affd4bbdafd8fc9.1689802933.git.daniel@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2738174vqt; Wed, 19 Jul 2023 15:13:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEPHsHKs5umzWt9kzQ9SHQP4on/+DvM3cWnpLm1gHS1Ct2ni5sCw3cMlwYl7fojewIDVOQF X-Received: by 2002:a17:907:2d23:b0:978:90cc:bf73 with SMTP id gs35-20020a1709072d2300b0097890ccbf73mr4074105ejc.48.1689804823778; Wed, 19 Jul 2023 15:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689804823; cv=none; d=google.com; s=arc-20160816; b=scWeG9H/Hwu50UogHcVw7aJk5I01k9go4NbBnV62ifC91+tFKH4kckO6ulkiJ4ONGl kX+sIo2Hvkf4h0066z7yppk+q8Hdec/UblqMCiDTGJb8wxvP6Wnb+3ZgtnS/iitaKGQW DqBt16Msxefen4Hk30ZLW2UYiHtcrIHQ/vH4O7fJwNfrZOFlukK8gZAh8Zqz4EES4nRZ BkHGS8ETIrudALToJyDJsxkW3nGrfSoZUnDtNlW+UZ+qV48DiFE27Dz0J4efQfbYwNG6 jpttm7mHVV+7ugXfj0vDb7AZwWqOuMdpHMqkfiX9IgkQIh52QdT+KRjhHWw++SC6SRIb Qy3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=aI+oONGaegupJ0seogiMq5KOugYmjBNwpl7+MkGhXeY=; fh=O/hjEvlM0nIN8LC6WbIQ4s0L6nmnRMOzajXXMF81As0=; b=rySUH0T8WAcV+Jgdb2O+AgQJIHYktjKMUkBKP8XLB0pl5J7lJz9U/U2kw/UgfxP/Lp H6Vdnx0rlg2Zs6fYjHWS81E0ZFK0xGy1EiInC6aw1d6a9WLG0AMt1/7DPpLxzmQ5kWED jhI6FhIn5YLYvyzhmHcJOXTqxK91QIS7bZeFOb8PzUmzs4OlvwFHkhJ/utL3TvuqfIVl bOPFzcZdjv8UwJ4wqz6PjAeV64e85LAflO2dz93U+xrwCK5mclt0iC5FzophF4tJIj6N F813yZ1fqSBAmAHbGaKK8hOg5Rql+D0P79X3TtXN3mgu0JX/1vAu/ClpCP2H/0vkCuAm t7JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa23-20020a170907b9d700b009938248d370si3652266ejc.2.2023.07.19.15.13.19; Wed, 19 Jul 2023 15:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbjGSWDr (ORCPT <rfc822;daweilics@gmail.com> + 99 others); Wed, 19 Jul 2023 18:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjGSWDp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Jul 2023 18:03:45 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBB2213D; Wed, 19 Jul 2023 15:03:29 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1qMFGL-0008Kc-1x; Wed, 19 Jul 2023 22:03:13 +0000 Date: Wed, 19 Jul 2023 23:03:05 +0100 From: Daniel Golle <daniel@makrotopia.org> To: Jens Axboe <axboe@kernel.dk>, Ulf Hansson <ulf.hansson@linaro.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Dave Chinner <dchinner@redhat.com>, Matthew Wilcox <willy@infradead.org>, Thomas =?iso-8859-1?q?Wei=DFschuh?= <linux@weissschuh.net>, Jan Kara <jack@suse.cz>, Daniel Golle <daniel@makrotopia.org>, Damien Le Moal <dlemoal@kernel.org>, Ming Lei <ming.lei@redhat.com>, Min Li <min15.li@samsung.com>, Christian Loehle <CLoehle@hyperstone.com>, Adrian Hunter <adrian.hunter@intel.com>, Hannes Reinecke <hare@suse.de>, Jack Wang <jinpu.wang@ionos.com>, Florian Fainelli <f.fainelli@gmail.com>, Yeqi Fu <asuk4.q@gmail.com>, Avri Altman <avri.altman@wdc.com>, Hans de Goede <hdegoede@redhat.com>, Ye Bin <yebin10@huawei.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?b?Y2tp?= <rafal@milecki.pl>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [RFC PATCH 3/6] block: add new genhd flag GENHD_FL_NO_NVMEM Message-ID: <96510d925cb0ca1a3a132f8f8affd4bbdafd8fc9.1689802933.git.daniel@makrotopia.org> References: <cover.1689802933.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <cover.1689802933.git.daniel@makrotopia.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771888782752038240 X-GMAIL-MSGID: 1771888782752038240 |
Series |
nvmem: add block device NVMEM provider
|
|
Commit Message
Daniel Golle
July 19, 2023, 10:03 p.m. UTC
Add new flag to destinguish block devices which should not act as an
NVMEM provider, such as for example an emulated block device on top of
an MTD partition which already acts as an NVMEM provider itself.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
include/linux/blkdev.h | 3 +++
1 file changed, 3 insertions(+)
Comments
On 7/20/23 00:03, Daniel Golle wrote: > Add new flag to destinguish block devices which should not act as an > NVMEM provider, such as for example an emulated block device on top of > an MTD partition which already acts as an NVMEM provider itself. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > include/linux/blkdev.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 2f5371b8482c0..e853d1815be15 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -80,11 +80,14 @@ struct partition_meta_info { > * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not > * scan for partitions from add_disk, and users can't add partitions manually. > * > + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not > + * emulate an NVMEM device on top of this disk. > */ > enum { > GENHD_FL_REMOVABLE = 1 << 0, > GENHD_FL_HIDDEN = 1 << 1, > GENHD_FL_NO_PART = 1 << 2, > + GENHD_FL_NO_NVMEM = 1 << 3, > }; > > enum { Please reverse this flag. Most of the devices will not have an NVMEM partition, and we shouldn't require each and every driver to tag their devices. So please use GENHD_FL_NVMEM and only set this flag on devices which really have an NVMEM partition. Cheers, Hannes
On Thu, Jul 20, 2023 at 10:24:18AM +0200, Hannes Reinecke wrote: > On 7/20/23 00:03, Daniel Golle wrote: > > Add new flag to destinguish block devices which should not act as an > > NVMEM provider, such as for example an emulated block device on top of > > an MTD partition which already acts as an NVMEM provider itself. > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > include/linux/blkdev.h | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > > index 2f5371b8482c0..e853d1815be15 100644 > > --- a/include/linux/blkdev.h > > +++ b/include/linux/blkdev.h > > @@ -80,11 +80,14 @@ struct partition_meta_info { > > * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not > > * scan for partitions from add_disk, and users can't add partitions manually. > > * > > + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not > > + * emulate an NVMEM device on top of this disk. > > */ > > enum { > > GENHD_FL_REMOVABLE = 1 << 0, > > GENHD_FL_HIDDEN = 1 << 1, > > GENHD_FL_NO_PART = 1 << 2, > > + GENHD_FL_NO_NVMEM = 1 << 3, > > }; > > enum { > Please reverse this flag. Most of the devices will not have an NVMEM > partition, and we shouldn't require each and every driver to tag their > devices. > So please use GENHD_FL_NVMEM and only set this flag on devices which really > have an NVMEM partition. The idea here was to exclude all those devices which already implement an NVMEM provider on a lower layer themselves, such as MTD. In this cases it would be ambigous if the OF node represents the NVMEM device registered by the MTD framework or if blk-nvmem should be used. In all other cases device tree can unambigously indicate whether a block device should serve as NVMEM provider (and right, most of them never will). However, reversing the logic seems fine just as well.
On 7/20/23 15:47, Daniel Golle wrote: > On Thu, Jul 20, 2023 at 10:24:18AM +0200, Hannes Reinecke wrote: >> On 7/20/23 00:03, Daniel Golle wrote: >>> Add new flag to destinguish block devices which should not act as an >>> NVMEM provider, such as for example an emulated block device on top of >>> an MTD partition which already acts as an NVMEM provider itself. >>> >>> Signed-off-by: Daniel Golle <daniel@makrotopia.org> >>> --- >>> include/linux/blkdev.h | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >>> index 2f5371b8482c0..e853d1815be15 100644 >>> --- a/include/linux/blkdev.h >>> +++ b/include/linux/blkdev.h >>> @@ -80,11 +80,14 @@ struct partition_meta_info { >>> * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not >>> * scan for partitions from add_disk, and users can't add partitions manually. >>> * >>> + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not >>> + * emulate an NVMEM device on top of this disk. >>> */ >>> enum { >>> GENHD_FL_REMOVABLE = 1 << 0, >>> GENHD_FL_HIDDEN = 1 << 1, >>> GENHD_FL_NO_PART = 1 << 2, >>> + GENHD_FL_NO_NVMEM = 1 << 3, >>> }; >>> enum { >> Please reverse this flag. Most of the devices will not have an NVMEM >> partition, and we shouldn't require each and every driver to tag their >> devices. >> So please use GENHD_FL_NVMEM and only set this flag on devices which really >> have an NVMEM partition. > > The idea here was to exclude all those devices which already implement > an NVMEM provider on a lower layer themselves, such as MTD. > In this cases it would be ambigous if the OF node represents the > NVMEM device registered by the MTD framework or if blk-nvmem should be > used. > Hmm; not sure if I follow. In the end, it doesn't really matter whether you check for GENHD_FL_NO_NVMEM or !GENHD_FL_NVMEM. With the difference being that in the former case you have to tag 99% of all existing block devices, and in the latter you have to tag 1%. > In all other cases device tree can unambigously indicate whether a > block device should serve as NVMEM provider (and right, most of them > never will). > > However, reversing the logic seems fine just as well. Thanks. Please do. Cheers, Hannes
On Thu, Jul 20, 2023 at 04:03:22PM +0200, Hannes Reinecke wrote: > On 7/20/23 15:47, Daniel Golle wrote: > > On Thu, Jul 20, 2023 at 10:24:18AM +0200, Hannes Reinecke wrote: > > > On 7/20/23 00:03, Daniel Golle wrote: > > > > Add new flag to destinguish block devices which should not act as an > > > > NVMEM provider, such as for example an emulated block device on top of > > > > an MTD partition which already acts as an NVMEM provider itself. > > > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > > --- > > > > include/linux/blkdev.h | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > > > > index 2f5371b8482c0..e853d1815be15 100644 > > > > --- a/include/linux/blkdev.h > > > > +++ b/include/linux/blkdev.h > > > > @@ -80,11 +80,14 @@ struct partition_meta_info { > > > > * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not > > > > * scan for partitions from add_disk, and users can't add partitions manually. > > > > * > > > > + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not > > > > + * emulate an NVMEM device on top of this disk. > > > > */ > > > > enum { > > > > GENHD_FL_REMOVABLE = 1 << 0, > > > > GENHD_FL_HIDDEN = 1 << 1, > > > > GENHD_FL_NO_PART = 1 << 2, > > > > + GENHD_FL_NO_NVMEM = 1 << 3, > > > > }; > > > > enum { > > > Please reverse this flag. Most of the devices will not have an NVMEM > > > partition, and we shouldn't require each and every driver to tag their > > > devices. > > > So please use GENHD_FL_NVMEM and only set this flag on devices which really > > > have an NVMEM partition. > > > > The idea here was to exclude all those devices which already implement > > an NVMEM provider on a lower layer themselves, such as MTD. > > In this cases it would be ambigous if the OF node represents the > > NVMEM device registered by the MTD framework or if blk-nvmem should be > > used. > > > Hmm; not sure if I follow. > In the end, it doesn't really matter whether you check for > GENHD_FL_NO_NVMEM or !GENHD_FL_NVMEM. > With the difference being that in the former case you have to > tag 99% of all existing block devices, and in the latter you > have to tag 1%. That's not exactly true. In the current case I only have to flag MTD (and UBI in future, I'm working on a UBI NVMEM provider as well) with GENHD_FL_NO_NVMEM, so a 'compatible = "nvmem-cells"' in the corresponding device tree node should not result in blk-nvmem creating an NVMEM device based on the (mtd/ubi)block device, simply because the MTD framework (and UBI in future) will already have created their own NVMEM device attached to the very same device tree node. In all other cases of block devices, the compatible string can be used to unambigously decide whether an NVMEM device should be created or not. blk-nvmem is opt-in, so unless the device is flagged by 'compatible = "nvmem-cells"' it will not do anything. For all devices which anyway do not have any device tree representation it won't do anything (think: loop, nbd, ...), we would not need to opt them out using GENHD_FL_NO_NVMEM. Also all other drivers which do not already bring their own NVMEM implementation won't need GENHD_FL_NO_NVMEM, the absence of 'compatible = "nvmem-cells"' is enough to indicate that they should not be considered as NVMEM providers. The way you are suggesting will require that, in addition to selecting the targetted block device in device tree, the block driver will also have to set GENHD_FL_NVMEM. Hence we will need changes in MMC, NVMe and potentially also SATA disk drivers setting GENHD_FL_NVMEM when registering the disk. > > > In all other cases device tree can unambigously indicate whether a > > block device should serve as NVMEM provider (and right, most of them > > never will). > > > > However, reversing the logic seems fine just as well. > > Thanks. Please do. Either way is fine with me, just 99% vs. 1% is not the right argument in this case.
On 7/20/23 16:28, Daniel Golle wrote: > On Thu, Jul 20, 2023 at 04:03:22PM +0200, Hannes Reinecke wrote: >> On 7/20/23 15:47, Daniel Golle wrote: >>> On Thu, Jul 20, 2023 at 10:24:18AM +0200, Hannes Reinecke wrote: >>>> On 7/20/23 00:03, Daniel Golle wrote: >>>>> Add new flag to destinguish block devices which should not act as an >>>>> NVMEM provider, such as for example an emulated block device on top of >>>>> an MTD partition which already acts as an NVMEM provider itself. >>>>> >>>>> Signed-off-by: Daniel Golle <daniel@makrotopia.org> >>>>> --- >>>>> include/linux/blkdev.h | 3 +++ >>>>> 1 file changed, 3 insertions(+) >>>>> >>>>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >>>>> index 2f5371b8482c0..e853d1815be15 100644 >>>>> --- a/include/linux/blkdev.h >>>>> +++ b/include/linux/blkdev.h >>>>> @@ -80,11 +80,14 @@ struct partition_meta_info { >>>>> * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not >>>>> * scan for partitions from add_disk, and users can't add partitions manually. >>>>> * >>>>> + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not >>>>> + * emulate an NVMEM device on top of this disk. >>>>> */ >>>>> enum { >>>>> GENHD_FL_REMOVABLE = 1 << 0, >>>>> GENHD_FL_HIDDEN = 1 << 1, >>>>> GENHD_FL_NO_PART = 1 << 2, >>>>> + GENHD_FL_NO_NVMEM = 1 << 3, >>>>> }; >>>>> enum { >>>> Please reverse this flag. Most of the devices will not have an NVMEM >>>> partition, and we shouldn't require each and every driver to tag their >>>> devices. >>>> So please use GENHD_FL_NVMEM and only set this flag on devices which really >>>> have an NVMEM partition. >>> >>> The idea here was to exclude all those devices which already implement >>> an NVMEM provider on a lower layer themselves, such as MTD. >>> In this cases it would be ambigous if the OF node represents the >>> NVMEM device registered by the MTD framework or if blk-nvmem should be >>> used. >>> >> Hmm; not sure if I follow. >> In the end, it doesn't really matter whether you check for >> GENHD_FL_NO_NVMEM or !GENHD_FL_NVMEM. >> With the difference being that in the former case you have to >> tag 99% of all existing block devices, and in the latter you >> have to tag 1%. > > That's not exactly true. In the current case I only have to flag MTD > (and UBI in future, I'm working on a UBI NVMEM provider as well) with > GENHD_FL_NO_NVMEM, so a 'compatible = "nvmem-cells"' in the > corresponding device tree node should not result in blk-nvmem creating > an NVMEM device based on the (mtd/ubi)block device, simply because the > MTD framework (and UBI in future) will already have created their own > NVMEM device attached to the very same device tree node. > > In all other cases of block devices, the compatible string can be used > to unambigously decide whether an NVMEM device should be created or > not. blk-nvmem is opt-in, so unless the device is flagged by > 'compatible = "nvmem-cells"' it will not do anything. > > For all devices which anyway do not have any device tree representation > it won't do anything (think: loop, nbd, ...), we would not need to opt > them out using GENHD_FL_NO_NVMEM. Also all other drivers which do not > already bring their own NVMEM implementation won't need GENHD_FL_NO_NVMEM, > the absence of 'compatible = "nvmem-cells"' is enough to indicate that > they should not be considered as NVMEM providers. > > The way you are suggesting will require that, in addition to selecting > the targetted block device in device tree, the block driver will also > have to set GENHD_FL_NVMEM. Hence we will need changes in MMC, NVMe > and potentially also SATA disk drivers setting GENHD_FL_NVMEM when > registering the disk. > That is absolutely correct, and was my intention all along. Drivers which can (and do) supply an NVMEM partition should be required to set this flag, yes. Cheers, Hannes
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2f5371b8482c0..e853d1815be15 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -80,11 +80,14 @@ struct partition_meta_info { * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not * scan for partitions from add_disk, and users can't add partitions manually. * + * ``GENHD_FL_NO_NVMEM``: NVMEM emulation is disabled. The kernel will not + * emulate an NVMEM device on top of this disk. */ enum { GENHD_FL_REMOVABLE = 1 << 0, GENHD_FL_HIDDEN = 1 << 1, GENHD_FL_NO_PART = 1 << 2, + GENHD_FL_NO_NVMEM = 1 << 3, }; enum {