Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10778848rwp; Fri, 21 Jul 2023 05:02:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlH67W+rH4lw7JD0gNoVfWbxzWMxmpfGyX2p57upDYr0vlNTjf3a8DpFYfcneD5lTpFtyZ2K X-Received: by 2002:a17:906:8466:b0:997:6729:5f4b with SMTP id hx6-20020a170906846600b0099767295f4bmr1736665ejc.11.1689940956173; Fri, 21 Jul 2023 05:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689940956; cv=none; d=google.com; s=arc-20160816; b=DJZOrNFHtraTHcogFKqONfgGItFQ87GrSYbvoCekyhIGjqccaLfY+zjzdNnqWm71fJ RzxqB1qAit/IGNDDiXOu3Q8zXKCPbShfr5qDsQu8M5z0dXVhcv7820dZN9XWhfjGHt5J ekt1Hr0oVODAgq6EFG6rp1UopNwuRe7Iw86e1oRMozW2hm5oulNhE2mojE3K1Fm7mKJC oIQATukKGVaI2yRk/Euqzw7OdR+VqMTK/PEBtFQTOmjrPP+7QnXxLDr0eq8VzjZZ7nRG 31dwEXXlqLgAN1ifX+yKQ2QemBW0r1GGX6E2P2UgpQIzM4Oc+blwQj7XAYS6KhlxPEni uaPA== 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:dkim-signature; bh=TnctFnyqauJ9TdNQAcH2ZCz06Gk3WR072wmFUmoIhlM=; fh=bqkUYTZy3S3vC+IQQYu1RC7W+KCnOLWt8J9ca+c8aKE=; b=GckkVK2hJfCb8vJCc+PsS4pym23ZnB00NsYd5bOUjPRci2oIBSgTyzrEj/NXLpQcGx i6IuI/SQI4P0WSwmp+HlxNmP+Nnfy8jL1uQZYk24luWcQ6WUHRlFjWUa1PgOJO+W5WcI bk3uoM7xUYHTVciPF35R/OIF+/N1acOie/rixL1giQrbR7NLpnUyBr2lwypH7NnRb1IM wnLQ7aXnPk7CfbY9/J9N0qkUQuc87OpE6gCSEsHoafVe305ZHD7QbdB98zfeG0AvN7hy SRWNYw4+u6RvZ3BmONHrq29WdWwucudqeklEtPKUL+JFLOP4POuLXM7Y3s03ZNCCjUN1 M7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eqx2QmBQ; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a17090606c100b00993320628absi2215574ejb.675.2023.07.21.05.01.46; Fri, 21 Jul 2023 05:02:36 -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=@linuxfoundation.org header.s=korg header.b=eqx2QmBQ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjGULj0 (ORCPT + 99 others); Fri, 21 Jul 2023 07:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjGULjY (ORCPT ); Fri, 21 Jul 2023 07:39:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFEC2130; Fri, 21 Jul 2023 04:39:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3BF116195D; Fri, 21 Jul 2023 11:39:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 021E2C433C8; Fri, 21 Jul 2023 11:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689939561; bh=PMNh2QFy+gw37kYrRWosLj1slA/IC/7XBzvdMwf52B4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eqx2QmBQR+y2S043or4uUfKmBOjKkAmdOcHbqjtBnd/3stvhl36OkglbVW17JgX/g 1y+ZwDLnRh2Wfc9UD6HFSBbyCFUR0FDsQNd/SerHhQpQ+2d+K0BzUTjq3IJ0lw4RNt GmfrZWmklx1RQKj44L1bK0Szg3dKZb1pEkQ7xekQ= Date: Fri, 21 Jul 2023 13:39:18 +0200 From: Greg Kroah-Hartman To: Daniel Golle Cc: Christoph Hellwig , 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 , Hannes Reinecke , Jack Wang , Florian Fainelli , Yeqi Fu , Avri Altman , Hans de Goede , Ye Bin , =?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 6/6] block: implement NVMEM provider Message-ID: <2023072106-partly-thank-8657@gregkh> References: <2023072128-shadow-system-1903@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Fri, Jul 21, 2023 at 12:30:10PM +0100, Daniel Golle wrote: > On Fri, Jul 21, 2023 at 01:11:40PM +0200, Greg Kroah-Hartman wrote: > > On Fri, Jul 21, 2023 at 11:40:51AM +0100, Daniel Golle wrote: > > > On Thu, Jul 20, 2023 at 11:31:06PM -0700, Christoph Hellwig wrote: > > > > On Thu, Jul 20, 2023 at 05:02:32PM +0100, Daniel Golle wrote: > > > > > On Thu, Jul 20, 2023 at 12:04:43AM -0700, Christoph Hellwig wrote: > > > > > > The layering here is exactly the wrong way around. This block device > > > > > > as nvmem provide has not business sitting in the block layer and being > > > > > > keyed ff the gendisk registration. Instead you should create a new > > > > > > nvmem backed that opens the block device as needed if it fits your > > > > > > OF description without any changes to the core block layer. > > > > > > > > > > > > > > > > Ok. I will use a class_interface instead. > > > > > > > > I'm not sure a class_interface makes much sense here. Why does the > > > > block layer even need to know about you using a device a nvmem provider? > > > > > > It doesn't. But it has to notify the nvmem providing driver about the > > > addition of new block devices. This is what I'm using class_interface > > > for, simply to hook into .add_dev of the block_class. > > > > Why is this single type of block device special to require this, yet all > > others do not? Encoding this into the block layer feels like a huge > > layering violation to me, why not do it how all other block drivers do > > it instead? > > I was thinkng of this as a generic solution in no way tied to one specific > type of block device. *Any* internal block device which can be used to > boot from should also be usable as NVMEM provider imho. Define "internal" :) And that's all up to the boot process in userspace, the kernel doesn't care about this. > > > > As far as I can tell your provider should layer entirely above the > > > > block layer and not have to be integrated with it. > > > > > > My approach using class_interface doesn't require any changes to be > > > made to existing block code. However, it does use block_class. If > > > you see any other good option to implement matching off and usage of > > > block devices by in-kernel users, please let me know. > > > > Do not use block_class, again, that should only be for the block core to > > touch. Individual block drivers should never be poking around in it. > > Do I have any other options to coldplug and be notified about newly > added block devices, so the block-device-consuming driver can know > about them? What other options do you need? > This is not a rhetoric question, I've been looking for other ways > and haven't found anything better than class_find_device or > class_interface. Never use that, sorry, that's not for a driver to touch. > Using those also prevents blk-nvmem to be built as > a module, so I'd really like to find alternatives. > E.g. for MTD we got struct mtd_notifier and register_mtd_user(). Your storage/hardware driver should be the thing that "finds block devices" and registers them with the block class core, right? After that, what matters? confused, greg k-h