Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9647472rwp; Thu, 20 Jul 2023 07:53:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsZ1kVbROtHX6DJy3gVpZgolhWmiDTvqqSU/ES/59JSpxPdO+HjUXRVXn5+9trW1X9j4Cx X-Received: by 2002:a17:90b:23cd:b0:25b:c454:a366 with SMTP id md13-20020a17090b23cd00b0025bc454a366mr5232130pjb.5.1689864782691; Thu, 20 Jul 2023 07:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689864782; cv=none; d=google.com; s=arc-20160816; b=JvY49VGCzfXGRg8lR79K3oWViTyKO6Ww16DYQ1kzIzoizLJ1Mf5JmdLVJJPrSRuySX tSM3ogOWDdLBqPCf/+rSC7R7poj0TcCUR28JYgngI3vwsUm/qe1Q0oiLyjcWc4fY/DKF MJGTE1XKCl3KdpMQA7PXTzO3BZCS/AY7aFac2IFOQi0A5r8ihqZmpkbkTlILezfOBNLR aEtUpxiZI1j6kfR5GrWb2bPTyy1pWV/7Eac1qQhQYTW2Ww6E8S6PQpYO0tgkOEKlQupB jre/Bb+2Cb7n28cKLQXhihupwqNxYJXlZNK8zzgGF13teZCb8sYdwVqOliVuPX5gZWOt 3Uvw== 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:cc:to:from:date; bh=2v0UpK+jjPKaIiighIDEDm4dDFHKbY/qH3HYrAADh50=; fh=vrRrsce+l2loKPGjCqpEoJRrx+6L6my2rhKJs0+rIbQ=; b=gb4eOKAU7ZJq+6pu29DUoqZzwFCKngznmsq+L21axdupLU2ZV1+grWiA7+7At2w3iY Jr+ZuAGW8rp7r0EQNRizXSlkfWjfWeOyoLJRKCqY/gFZB86j3lG69BDlay0vlmgMVRG4 DB4018bkRljZ997BA0lwflSc4YkljbHx3LqPqPBmf7ioUfDWMvmWFj3fCJYpVzEmkNmh pdb9yE6VO1GuPGn4owf4WWM2W1bQ8IidI/3oCNYruzSvEZYl9ThR8DLv7jvinbSwYwF6 iuWrGxYjDVoGsDmlAEpIGg/EoJ86V5SxgnwsxAlRpSe9yWDQCMzIvtqD4vV2W12zrVvw mNzA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a17090acf0e00b00262f798c30csi3646526pju.186.2023.07.20.07.52.50; Thu, 20 Jul 2023 07:53:02 -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 S232234AbjGTO3E (ORCPT + 99 others); Thu, 20 Jul 2023 10:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231702AbjGTO3D (ORCPT ); Thu, 20 Jul 2023 10:29:03 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D231BF7; Thu, 20 Jul 2023 07:29:02 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1qMUds-0004Lw-39; Thu, 20 Jul 2023 14:28:33 +0000 Date: Thu, 20 Jul 2023 15:28:23 +0100 From: Daniel Golle To: Hannes Reinecke Cc: Jens Axboe , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Dave Chinner , Matthew Wilcox , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Jan Kara , Damien Le Moal , Ming Lei , Min Li , Christian Loehle , Adrian Hunter , Jack Wang , Florian Fainelli , Yeqi Fu , Avri Altman , Hans de Goede , Ye Bin , Greg Kroah-Hartman , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [RFC PATCH 3/6] block: add new genhd flag GENHD_FL_NO_NVMEM Message-ID: References: <96510d925cb0ca1a3a132f8f8affd4bbdafd8fc9.1689802933.git.daniel@makrotopia.org> <0592e021-237d-6d41-7faf-e5b93aefbeea@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > --- > > > > 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.