Message ID | 20230307165359.225361-12-miquel.raynal@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2543037wrd; Tue, 7 Mar 2023 09:02:32 -0800 (PST) X-Google-Smtp-Source: AK7set+1uC1l799zIMVpndR0oJs1sf5Uj9ZtkD/PciPuNjLZ9pz22mnzLavD8oQ+gjaxFx96HsWW X-Received: by 2002:a50:ee18:0:b0:4a0:e31a:434 with SMTP id g24-20020a50ee18000000b004a0e31a0434mr13370921eds.27.1678208552746; Tue, 07 Mar 2023 09:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678208552; cv=none; d=google.com; s=arc-20160816; b=cWIpc4fmBzRJvaG++RIvpq9GpHEHol2rE/ighDumfF+c1UOmOrRxNcWoag93DsAGrz YWOXr65qLlSlhVJ+ofTtey/RBIlVIRDQUizZSdrrycSfadQxIOB4F1qv9b9nxLqGwQh7 frsw4FKktFnxV7ysNkAs1rlEiCoDUOiQ5iIYq855vuPoxiLTiay5JlrbHJShC7xGMoCJ NQxKF5QlVNQe4xEieoFusV9IvwOmm1km+VkpxztFnm1uXDGCtpWUuOSZQhjiXAsKiN/t CdPEaRCLbhh0iFVJpcOfsuuYaRd962u0vVBG07qkA2eY/wqSPgtpCSwi4NcRB3rDJVG3 iyPA== 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=7KeyBQUfcV1ky8pfB8UN0PcucnmwJo4XrlM30Q7JJvc=; b=UcvlkkB0Mj2diZnOUONiYHVBCyzrEpZtYbWFGMvWB3vTDI8qW+N04Sytw4PNkJgSb2 Vi+fpWU0Gyqy0iqJRbRP6ZHxxyTMHIp2uVPei8OuL4PjZkOp3N21DojkHa6/oETqt4U1 69ALa3hQbaKMJTccyEu3zYpBiqXfYy5P6TEDPy2T71sq5QPmGfSn9tupbJlvtWpBGhLj +1hI9pc349vV/2tecVTb3+LFVLZz/iOFT4V0wBKMUKRaHVsdy21AtC8z+oQy6uBDYjHf 7jsdI1mcpHJScj/XQB5SFSk+KM89TYUUAW8AZhPzbL9m7qzTr3dReQnPpdykYLvNXM8i 7JQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YH8LjfQK; 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 i2-20020aa7c702000000b004acc6c7a631si14723135edq.179.2023.03.07.09.02.06; Tue, 07 Mar 2023 09:02:32 -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=YH8LjfQK; 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 S230355AbjCGQ7j (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 7 Mar 2023 11:59:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbjCGQ6J (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Mar 2023 11:58:09 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F141943A4; Tue, 7 Mar 2023 08:54:38 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id C58F9C0005; Tue, 7 Mar 2023 16:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678208076; 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=7KeyBQUfcV1ky8pfB8UN0PcucnmwJo4XrlM30Q7JJvc=; b=YH8LjfQKOD4APKo2dXxpQh5JpBZKiHnVtOecfGa8P53v+ZmDgbTRI0chH0QkBhnsgtDA28 g0KQh4E43YVWufPcsgOI3zZowESs1t/LrjUhW9fqYY+rnTthXoaqqvRMbOAHBK5qwpfKzr dLb9otb88omqLU97X51cyPKVfPf5PzcUHiCnQilM7fiRmTpHYpHCHqWTznihvFhend7tLa mWEDrfzwrBGb+jsbqn89WUlMt+20hzq04m0hb3lthlmxHFKHSfNvFQcV3CXLPSaP/kGJU9 mPf05zbQLyWxf8/B+d7ULAcwjdAnRZzGmHwXgGVwHzeM0WkXqMqaBDsKCvl+EQ== From: Miquel Raynal <miquel.raynal@bootlin.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, <linux-kernel@vger.kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Michael Walle <michael@walle.cc>, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= <rafal@milecki.pl>, Robert Marko <robert.marko@sartura.hr>, Luka Perkov <luka.perkov@sartura.hr>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, devicetree@vger.kernel.org, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH v2 11/21] nvmem: core: handle the absence of expected layouts Date: Tue, 7 Mar 2023 17:53:49 +0100 Message-Id: <20230307165359.225361-12-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307165359.225361-1-miquel.raynal@bootlin.com> References: <20230307165359.225361-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759729211421559130?= X-GMAIL-MSGID: =?utf-8?q?1759729211421559130?= |
Series |
nvmem: Layouts support
|
|
Commit Message
Miquel Raynal
March 7, 2023, 4:53 p.m. UTC
Make nvmem_layout_get() return -EPROBE_DEFER while the expected layout is not available. This condition cannot be triggered today as nvmem layout drivers are initialed as part of an early init call, but soon these drivers will be converted into modules and be initialized with a standard priority, so the unavailability of the drivers might become a reality that must be taken care of. Let's anticipate this by telling the caller the layout might not yet be available. A probe deferral is requested in this case. Please note this does not affect any nvmem device not using layouts, because an early check against the "nvmem-layout" container presence will return NULL in this case. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Michael Walle <michael@walle.cc> --- drivers/nvmem/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Comments
On 07/03/2023 16:53, Miquel Raynal wrote: > Make nvmem_layout_get() return -EPROBE_DEFER while the expected layout > is not available. This condition cannot be triggered today as nvmem > layout drivers are initialed as part of an early init call, but soon > these drivers will be converted into modules and be initialized with a > standard priority, so the unavailability of the drivers might become a > reality that must be taken care of. > > Let's anticipate this by telling the caller the layout might not yet be > available. A probe deferral is requested in this case. > > Please note this does not affect any nvmem device not using layouts, > because an early check against the "nvmem-layout" container presence > will return NULL in this case. > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > Tested-by: Michael Walle <michael@walle.cc> > --- > drivers/nvmem/core.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index b9be1faeb7be..51fd792b8d70 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -755,7 +755,7 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregister); > static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) > { Any reason why this is not part of 10/21? kernel doc for nvmem_layout_get needs updating with this behavior. --srini > struct device_node *layout_np, *np = nvmem->dev.of_node; > - struct nvmem_layout *l, *layout = NULL; > + struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER); > > layout_np = of_get_child_by_name(np, "nvmem-layout"); > if (!layout_np) > @@ -938,6 +938,13 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) > * pointer will be NULL and nvmem_layout_put() will be a noop. > */ > nvmem->layout = config->layout ?: nvmem_layout_get(nvmem); > + if (IS_ERR(nvmem->layout)) { > + rval = PTR_ERR(nvmem->layout); > + nvmem->layout = NULL; > + > + if (rval == -EPROBE_DEFER) > + goto err_teardown_compat; > + } > > if (config->cells) { > rval = nvmem_add_cells(nvmem, config->cells, config->ncells); > @@ -970,6 +977,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) > err_remove_cells: > nvmem_device_remove_all_cells(nvmem); > nvmem_layout_put(nvmem->layout); > +err_teardown_compat: > if (config->compat) > nvmem_sysfs_remove_compat(nvmem, config); > err_put_device:
Hi Srinivas, srinivas.kandagatla@linaro.org wrote on Fri, 10 Mar 2023 10:30:14 +0000: > On 07/03/2023 16:53, Miquel Raynal wrote: > > Make nvmem_layout_get() return -EPROBE_DEFER while the expected layout > > is not available. This condition cannot be triggered today as nvmem > > layout drivers are initialed as part of an early init call, but soon > > these drivers will be converted into modules and be initialized with a > > standard priority, so the unavailability of the drivers might become a > > reality that must be taken care of. > > > > Let's anticipate this by telling the caller the layout might not yet be > > available. A probe deferral is requested in this case. > > > > Please note this does not affect any nvmem device not using layouts, > > because an early check against the "nvmem-layout" container presence > > will return NULL in this case. > > > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > > Tested-by: Michael Walle <michael@walle.cc> > > --- > > drivers/nvmem/core.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > > index b9be1faeb7be..51fd792b8d70 100644 > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -755,7 +755,7 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregister); > > static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) > > { > > Any reason why this is not part of 10/21? Yes, I would like to credit everybody for his work, so Michael for the base implementation and myself for the module sitaution handling, arguing this is two different features. May we keep these separated? > kernel doc for nvmem_layout_get needs updating with this behavior. There is no kdoc for nvmem_layout_get, do you want one ? I thought the comment where this function is called would be more descriptive (and read by interested people). Thanks, Miquèl
On 10/03/2023 10:45, Miquel Raynal wrote: > Hi Srinivas, > > srinivas.kandagatla@linaro.org wrote on Fri, 10 Mar 2023 10:30:14 +0000: > >> On 07/03/2023 16:53, Miquel Raynal wrote: >>> Make nvmem_layout_get() return -EPROBE_DEFER while the expected layout >>> is not available. This condition cannot be triggered today as nvmem >>> layout drivers are initialed as part of an early init call, but soon >>> these drivers will be converted into modules and be initialized with a >>> standard priority, so the unavailability of the drivers might become a >>> reality that must be taken care of. >>> >>> Let's anticipate this by telling the caller the layout might not yet be >>> available. A probe deferral is requested in this case. >>> >>> Please note this does not affect any nvmem device not using layouts, >>> because an early check against the "nvmem-layout" container presence >>> will return NULL in this case. >>> >>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> >>> Tested-by: Michael Walle <michael@walle.cc> >>> --- >>> drivers/nvmem/core.c | 10 +++++++++- >>> 1 file changed, 9 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c >>> index b9be1faeb7be..51fd792b8d70 100644 >>> --- a/drivers/nvmem/core.c >>> +++ b/drivers/nvmem/core.c >>> @@ -755,7 +755,7 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregister); >>> static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) >>> { >> >> Any reason why this is not part of 10/21? > > Yes, I would like to credit everybody for his work, so Michael for the > base implementation and myself for the module sitaution handling, > arguing this is two different features. May we keep these separated? Thanks for clarifying this, that should be fine. --srini
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b9be1faeb7be..51fd792b8d70 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -755,7 +755,7 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregister); static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) { struct device_node *layout_np, *np = nvmem->dev.of_node; - struct nvmem_layout *l, *layout = NULL; + struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER); layout_np = of_get_child_by_name(np, "nvmem-layout"); if (!layout_np) @@ -938,6 +938,13 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) * pointer will be NULL and nvmem_layout_put() will be a noop. */ nvmem->layout = config->layout ?: nvmem_layout_get(nvmem); + if (IS_ERR(nvmem->layout)) { + rval = PTR_ERR(nvmem->layout); + nvmem->layout = NULL; + + if (rval == -EPROBE_DEFER) + goto err_teardown_compat; + } if (config->cells) { rval = nvmem_add_cells(nvmem, config->cells, config->ncells); @@ -970,6 +977,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) err_remove_cells: nvmem_device_remove_all_cells(nvmem); nvmem_layout_put(nvmem->layout); +err_teardown_compat: if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); err_put_device: