From patchwork Wed Mar 8 15:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 66312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp407125wrd; Wed, 8 Mar 2023 07:41:41 -0800 (PST) X-Google-Smtp-Source: AK7set889kxpqm1C1AHXFdYLsktoJb3rPAtbSWYuHfU3frqepnrS1CdTsLN0zHW3Dt33KoESz0vp X-Received: by 2002:aa7:8704:0:b0:594:1f1c:3d3a with SMTP id b4-20020aa78704000000b005941f1c3d3amr20140684pfo.15.1678290101159; Wed, 08 Mar 2023 07:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678290101; cv=none; d=google.com; s=arc-20160816; b=HfJgaysmANN4HWE1Jg6+lxzVWySsBK2iqy99YjUok5iILEKC06YXd/Z8IGH9XKxlqv P8iuqLkqbrANrobl7GRdLsnGsA6CNeDfw2ocGKAuthCGcup/rzR41+V+Fp0edJ5YE2I5 6S74Ue0T/+QP2nQcQfVXBs3P5PuSYbuxSE27kN1XquZvB8PRm+MpNA9+XR39vg2OAyDn 4F/48vvkoI+c0r/UPUMIrzi5TREbWz+NKjBoIS/EZT5P787TUMrCAHm/TRGEXjsXoMpS +BrR9ukWoTkS0hOf65M9mRuJNCYaVgbqiwNvCI7bs7EH0dhGmddfeqye66+47PF5eMEO rhiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tqDLaqZ1GuVBw64kENerPspXdR7LpiuTsQla1HFP/KA=; b=FS98tWWrkOohX8z3AgnPi1WTplACL8sbCh8Quqn2PneD9ylRXKYBHBLwUNC+PfbaIY OthNrNK/8g6zQ/jhW0WsaevKY02CplT5VgDv2odKqJDBJi+CtXPbqMA+UDDuilY1HxlS nL/CYsypG1g/lQ5uaDX+vZ1dRf0y2a+IDUDLXHeYqon42F3tZBQY0YfF7wPjGHfNOclo SXtmDaWb054dabh6oemk84S6MAidtbIpBH61rAV8f9YjkxON4UdQ6z0BbwPGuspyqT1U CB5IbEa7JVwxBThAaUSrE4NjCwtPdJ+OjJaBPIqqLdj8CNArl0ei5HFDPZGTwcUFByro 3WRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cQ7VnWXm; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a625f03000000b005a9dd8ef30csi14567988pfb.216.2023.03.08.07.41.25; Wed, 08 Mar 2023 07:41:41 -0800 (PST) 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=@bootlin.com header.s=gm1 header.b=cQ7VnWXm; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbjCHPdU (ORCPT + 99 others); Wed, 8 Mar 2023 10:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232259AbjCHPcv (ORCPT ); Wed, 8 Mar 2023 10:32:51 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ADE7D6EAE; Wed, 8 Mar 2023 07:32:25 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B3B59FF813; Wed, 8 Mar 2023 15:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678289544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tqDLaqZ1GuVBw64kENerPspXdR7LpiuTsQla1HFP/KA=; b=cQ7VnWXm4rso7T5LFef6267qVl+4QhYqUFxU2isjgqiCwTqInek/KLy579lEji53gzli+B LrRilpvHwlhDCk3wz8+DKlOP+agaoxKT6CW8A49mBvQ+gFCcRI1b3w9RNVz1huEa9TIHfY yVX1CYkCnv3yL/cEPhmYuzI0uQ/wfFKE/eKIYy78/5pAsEQQefspKaHACG8aBN1z2RMtuc ypwOGfNgqyqv5ed1rZvjdpDIEFM1+W62NOjoaksmStTAf/fb6uouhXZxBjntlfv2AAKBYj SvISjtXfSImrrbkD8BuOaqqGZj6okeHftP9g4md7hRBYeXqcqDqV0YTCRLLBsw== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Robert Marko , Luka Perkov , Thomas Petazzoni , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Miquel Raynal Subject: [PATCH v3 11/20] nvmem: core: request layout modules loading Date: Wed, 8 Mar 2023 16:31:51 +0100 Message-Id: <20230308153200.682248-12-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308153200.682248-1-miquel.raynal@bootlin.com> References: <20230308153200.682248-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759814720830990247?= X-GMAIL-MSGID: =?utf-8?q?1759814720830990247?= When a storage device like an eeprom or an mtd device probes, it registers an nvmem device if the nvmem subsystem has been enabled (bool symbol). During nvmem registration, if the device is using layouts to expose dynamic nvmem cells, the core will first try to get a reference over the layout driver callbacks. In practice there is not relationship that can be described between the storage driver and the nvmem layout. So there is no way we can enforce both drivers will be built-in or both will be modules. If the storage device driver is built-in but the layout is built as a module, instead of badly failing with an endless probe deferral loop, lets just make a modprobe call in case the driver was made available in an initramfs with of_device_node_request_module(), and offer a fully functional system to the user. Signed-off-by: Miquel Raynal Tested-by: Michael Walle --- drivers/nvmem/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 51fd792b8d70..49b4bbaf59e8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include struct nvmem_device { @@ -761,6 +762,13 @@ static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) if (!layout_np) return NULL; + /* + * In case the nvmem device was built-in while the layout was built as a + * module, we shall manually request the layout driver loading otherwise + * we'll never have any match. + */ + of_request_module(layout_np); + spin_lock(&nvmem_layout_lock); list_for_each_entry(l, &nvmem_layouts, node) {