From patchwork Wed Mar 1 15:22:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 62962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3694040wrd; Wed, 1 Mar 2023 07:28:00 -0800 (PST) X-Google-Smtp-Source: AK7set8V+foWzeWIlqetSPIbOTOG+ekBZB9rN6yEn34Y/3vypo+JRdBF7TnOzdaE0eGyq/TSQWYb X-Received: by 2002:a17:907:6f11:b0:8b1:7de3:cfb4 with SMTP id sy17-20020a1709076f1100b008b17de3cfb4mr6998010ejc.4.1677684480759; Wed, 01 Mar 2023 07:28:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677684480; cv=none; d=google.com; s=arc-20160816; b=s4skaYGsp0KKGsk3FXH66wHN15Tqp2/vP84FaCiyzO17hRU+rH/6fx4H0ZCWy0lJVC JUVduXa28ZB8z5vflNPlpxQ35PbVIsAj0K0C9utbGK7/9f4hsG2yZhQGta2iQCIlKza4 rTCnLSY8Hfnnh+SS1if50Qfzy0u54kgBpAv8gJPxYI+kV1AiHkwXonCsSxcSoG6ECZCN wDH/G1ZWbZe8lIOjDfJ4flMMexhHvGG1GiUO13Yj6/rGqiJ33eyA9c4MvXehCpxQ//Gb 5XmH9PknJSiEFoePnXksDjRqkmFbGPwBs4rI929HE+wA/ILgUnRnDgc81o2w4wsNTiwr RKZw== 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=veHqp22wWolx6RiZnbbvLOutWer672c27ajS/GJmogc=; b=tNlEeqDid1vlUXGBDBmQggXw4ODZQffntwEC6Ix1hUqRvuFsJEp8PLlDxX7/95rnhE dAQuCrI6cfsPFyJ+r9o9mS9ib/f4pGSq4FoLGmPwIeT6eTUjFDBqz9Aw3K9S40z4bl7S SGm6HBV6NGfXDV3sqjyz1IkFS7TPnnXHnGXolstBMOql7ygdS2LtjTNlSS6etFfk2rdG 3AwUZs14Krm/L9rG23WKPj4ppxHHw4y6WH+3fWk8RHzaStHxsQnWZlcrteHlCIe0/oL5 +zDVOOCLq7pxJF61kT41IFV96UvKzKkvmDBwxjEKCgqKgRjiUmWAhxeQ16VQasPxg/Dx vFlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QVakPxE5; 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 gh12-20020a170906e08c00b008d28622c8dcsi824323ejb.566.2023.03.01.07.27.37; Wed, 01 Mar 2023 07:28:00 -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=QVakPxE5; 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 S230369AbjCAPXK (ORCPT + 99 others); Wed, 1 Mar 2023 10:23:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbjCAPWv (ORCPT ); Wed, 1 Mar 2023 10:22:51 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13D69457FB; Wed, 1 Mar 2023 07:22:49 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CAE8D60006; Wed, 1 Mar 2023 15:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1677684168; 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=veHqp22wWolx6RiZnbbvLOutWer672c27ajS/GJmogc=; b=QVakPxE5LSVc9MxAkGBRSgmdbC2BCKTsWJTp+wDGqvTdkral5N3TNtKgiCFRSWhXG5WMjo y5voAUtX7dUaNEoz4+v3cznCrhhQUHj8r+Ed+5ErLy9xmAp1vlWxuXEhg04OX5ugK0GPyL 93jz84NT+MnJKYx0T9USiBDJoi7S4iw6u7cmM6iPY92N3I/kvUAGX1Y26ffb3X/Qgvl4mk BL1KrYcQhG+YUtNzK0hnsspmRuDzPDGIoxqb3wLc4zluZpbfKsjgRE5xRJjgfI/8p+w8hj ulvz8jQkBfFn67nqFORPXj3LqTsHOh7WddcKfqG3YTc1At9Sa30cswQW36Anpw== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , devicetree@vger.kernel.org, Rob Herring , Frank Rowand , Robert Marko , Luka Perkov , Thomas Petazzoni , rafal@milecki.pl, Miquel Raynal Subject: [PATCH 6/8] nvmem: core: Request layout modules loading Date: Wed, 1 Mar 2023 16:22:37 +0100 Message-Id: <20230301152239.531194-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301152239.531194-1-miquel.raynal@bootlin.com> References: <20230301152239.531194-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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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?1759179682338105805?= X-GMAIL-MSGID: =?utf-8?q?1759179682338105805?= 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 --- drivers/nvmem/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index a66c37a03a36..8e07b9df3221 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include struct nvmem_device { @@ -768,6 +769,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_device_node_request_module(layout_np); + spin_lock(&nvmem_layout_lock); list_for_each_entry(l, &nvmem_layouts, node) {