Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9647278rwp; Thu, 20 Jul 2023 07:52:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFD1FEUC5+gX0JOoeadbiCV8yljFf/OFN6fTKxsTXj7UnFI4/F7S39gor5APduL24rSwU3u X-Received: by 2002:a05:6870:d1c9:b0:1b0:2d25:f5ae with SMTP id b9-20020a056870d1c900b001b02d25f5aemr2376009oac.47.1689864772125; Thu, 20 Jul 2023 07:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689864772; cv=none; d=google.com; s=arc-20160816; b=Lb9VH0VDztcIxYivTcijfkObzfx8qW8cmklmdvuipmWmHqxPNEP2l7FVTgXgWw7ug4 ChF3BbjztzoyqD74Hr7VMEgdipcd4oIv48CpeUCqm1gz8o0hRKbQAD//HetS/vYEy5bO 1HfEHBFQp0TAgd7bTApEDAwtMZmnRx6Wf4sT4rP0SYiLV02FS9rGgLOEXaI9ZD8/E7CT r9nNehhY9xpiO/SnHk+nr2wYekVCQYYo3AlrVpwwZfA+85fRHp4H9ZIB3fMgtkurjHh7 aPoazsgtNmkLamd3CGXOsmyC3BhzlOFLaDW3CEx9kCHvXd1PuJPGjQtZXmpB1qg1dG2l tTNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=/6ff9/xbMepFzo0u5wSH1LXPdzZwFF8kXNP7KYOumW0=; fh=YOXfMHkq9e5ZT5iT908ByXCI3PzrwSDr9xzJ3bAyhmk=; b=yv2JJZKYTjGIStKKbSw1AKVbKl+5lU1uRYR9+DoUwYOnym1sV5KJJ0wjQ9p2rqZ0Mo EV/o/02YPkdABcEiuG+r6Q9bJGm1++/00GItlMqAZkDQCHbSDxHOePwEzM/DEvXLDYNd Muj1E6rwBaHLCBbo4LttIIwtIezpDwKueslw5ajf61cklMixEDhLt8thNt53nW4J9iqF zuoS3BxW3mqw8IgYDlOJqMlE0L72gDSIKTNup3otK0LxxqM4rYItq+WOCKeZA7iLcYMP /Qx4Cq6dt2xYnXmpkQQtZ6ejCLCBwRumZD1mtuCpxBOJ0nr1RRrFngO6G8+uPg15P9WK ElmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qJbxkSu+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=BfGCMyGU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a63574b000000b0055759bb6883si1012878pgm.63.2023.07.20.07.52.38; Thu, 20 Jul 2023 07:52:52 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qJbxkSu+; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=BfGCMyGU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232260AbjGTOen (ORCPT + 99 others); Thu, 20 Jul 2023 10:34:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbjGTOem (ORCPT ); Thu, 20 Jul 2023 10:34:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1270310FC; Thu, 20 Jul 2023 07:34:40 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AF67B22BD9; Thu, 20 Jul 2023 14:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689863679; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/6ff9/xbMepFzo0u5wSH1LXPdzZwFF8kXNP7KYOumW0=; b=qJbxkSu+Z/pld8ZDnozSN6/06j3CWTxvtPLYu9WNVqVnQYD1RI5PVainHToQGk4VJlA8o9 08RqGEh7TmfWw0zpKdWPzd5NQgcsjDUdsX7EP9Afe96ZipgSN96XINuxW2H1O0lYVpjW6B K1AfDAllBtV5XnZeo1WSkFqrE7Hl/g4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689863679; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/6ff9/xbMepFzo0u5wSH1LXPdzZwFF8kXNP7KYOumW0=; b=BfGCMyGUKemTNPoT/D7uFthLN/z5ova38Nj3q++Mq22svLYcCfPNhIS17nOKCvDfTHV4Hr d45COpmtTCV8NqDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 71F49138EC; Thu, 20 Jul 2023 14:34:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZBd0G/9FuWTBdwAAMHmgww (envelope-from ); Thu, 20 Jul 2023 14:34:39 +0000 Message-ID: <944562e5-1923-5f7d-6a2d-5f648389cadf@suse.de> Date: Thu, 20 Jul 2023 16:34:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH 3/6] block: add new genhd flag GENHD_FL_NO_NVMEM Content-Language: en-US To: Daniel Golle Cc: Jens Axboe , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Dave Chinner , Matthew Wilcox , =?UTF-8?Q?Thomas_Wei=c3=9fschuh?= , 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 References: <96510d925cb0ca1a3a132f8f8affd4bbdafd8fc9.1689802933.git.daniel@makrotopia.org> <0592e021-237d-6d41-7faf-e5b93aefbeea@suse.de> From: Hannes Reinecke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 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 >>>>> --- >>>>> 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