From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB8FC3DA7A for ; Thu, 5 Jan 2023 12:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233528AbjAEMwz (ORCPT ); Thu, 5 Jan 2023 07:52:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbjAEMwe (ORCPT ); Thu, 5 Jan 2023 07:52:34 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D22895BA3C; Thu, 5 Jan 2023 04:51:55 -0800 (PST) Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 8395C61; Thu, 5 Jan 2023 13:51:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672923113; h=from:from:reply-to:subject:subject: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=5ox2AHpCozB9D2AA+DmLS+FQ8YK9yjntjf01mZPEqQQ=; b=CbTHCYy/PpHg9tnJL40N0QyKfSBPMEuWodnDHIS2Q7bnFFNSiBHUO8kGYkCu4CqzxlvpMN OD4EUMcJSjPq9EfPoSPo9i5yFs8YqU91BDNZV584H0em1c0Pwhx2G9e3YjETGgGeCtJ+xM QQraL2B4cfCIigOQJMsKIgFWxhDzsvI9TrBAxlPDonU1Z2fHXehQ1J1ze2mHfg8DyYowJp N/dYi3TdxeyV2uoBowyNYdNWPNJ7fOTD4IO8b1IjyE/H0GhaWegBc+q969OAQ5Nd9GBtdZ L35+YPXFm/qu7vt8J20PtJANmzQOKqvDnkBeuQ/mIP96ETVkIs5j8n6m52NgsA== MIME-Version: 1.0 Date: Thu, 05 Jan 2023 13:51:53 +0100 From: Michael Walle To: Alexander Stein Cc: Miquel Raynal , Srinivas Kandagatla , Jonathan Corbet , Rob Herring , Frank Rowand , Sascha Hauer , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH v5 00/21] nvmem: core: introduce NVMEM layouts In-Reply-To: <5906091.UjTJXf6HLC@steina-w> References: <20221206200740.3567551-1-michael@walle.cc> <20230105123534.38a70640@xps-13> <34cddc1aa4f8a55c752a9565d1726127@walle.cc> <5906091.UjTJXf6HLC@steina-w> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <13fca55324d55f9d4e30ca7fcc930e15@walle.cc> X-Sender: michael@walle.cc Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org Hi, Am 2023-01-05 13:21, schrieb Alexander Stein: > Am Donnerstag, 5. Januar 2023, 13:11:37 CET schrieb Michael Walle: >> thanks for debugging. I'm not yet sure what is going wrong, so >> I have some more questions below. >> >> >> This causes the following errors on existing boards (imx8mq-tqma8mq- >> >> mba8mx.dtb): >> >> root@tqma8-common:~# uname -r >> >> 6.2.0-rc2-next-20230105 >> >> >> >> > OF: /soc@0: could not get #nvmem-cell-cells for /soc@0/bus@30000000/ >> >> >> >> efuse@30350000/soc-uid@4 >> >> >> >> > OF: /soc@0/bus@30800000/ethernet@30be0000: could not get >> >> > #nvmem-cell-cells >> >> >> >> for /soc@0/bus@30000000/efuse@30350000/mac-address@90 >> >> >> >> These are caused because '#nvmem-cell-cells = <0>;' is not explicitly >> >> set in >> >> DT. >> >> >> >> > TI DP83867 30be0000.ethernet-1:0e: error -EINVAL: failed to get nvmem >> >> > cell >> >> >> >> io_impedance_ctrl >> >> >> >> > TI DP83867: probe of 30be0000.ethernet-1:0e failed with error -22 >> >> >> >> These are caused because of_nvmem_cell_get() now returns -EINVAL >> >> instead of - >> >> ENODEV if the requested nvmem cell is not available. >> >> What do you mean with not available? Not yet available because of >> probe >> order? > > Ah, I was talking about there is no nvmem cell being used in my PHY > node, e.g. > no 'nvmem-cells' nor 'nvmem-cell-names' (set to 'io_impedance_ctrl'). > That's > why of_property_match_string returns -EINVAL. Ahh I see. You mean ENOENT instead of ENODEV, right? >> > Should we just assume #nvmem-cell-cells = <0> by default? I guess it's >> > a safe assumption. >> >> Actually, that's what patch 2/21 is for. >> >> Alexander, did you verify that the EINVAL is returned by >> of_parse_phandle_with_optional_args()? > > Yep. > > --8<-- > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 1b61c8bf0de4..f2a85a31d039 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -1339,9 +1339,11 @@ struct nvmem_cell *of_nvmem_cell_get(struct > device_node > *np, const char *id) > if (id) > index = of_property_match_string(np, > "nvmem-cell-names", id); > > + pr_info("%s: index: %d\n", __func__, index); > ret = of_parse_phandle_with_optional_args(np, "nvmem-cells", > "#nvmem-cell-cells", > index, &cell_spec); > + pr_info("%s: of_parse_phandle_with_optional_args: %d\n", > __func__, > ret); > if (ret) > return ERR_PTR(ret); > --8<-- > > Results in: >> [ 1.861896] of_nvmem_cell_get: index: -22 >> [ 1.865934] of_nvmem_cell_get: of_parse_phandle_with_optional_args: >> -22 >> [ 1.872595] TI DP83867 30be0000.ethernet-1:0e: error -EINVAL: >> failed to > get nvmem cell io_impedance_ctrl >> [ 2.402575] TI DP83867: probe of 30be0000.ethernet-1:0e failed with >> error > -22 > > So, the index is wrong in the first place, but this was no problem > until now. Thanks, could you try the following patch: diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 1b61c8bf0de4..1085abfcd9b1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1336,8 +1336,11 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) int ret; /* if cell name exists, find index to the name */ - if (id) + if (id) { index = of_property_match_string(np, "nvmem-cell-names", id); + if (index < 0) + return ERR_PTR(-ENOENT); + } ret = of_parse_phandle_with_optional_args(np, "nvmem-cells", "#nvmem-cell-cells", Before patch 6/21, the -EINVAL was passed as index to of_parse_phandle() which then returned NULL, which caused the nvmem core to return ENOENT. I have a vague memory, that I made sure, that of_parse_phandle_with_optional_args() will also propagate the wrong index to its return code. But now, it won't be converted to ENOENT. -michael From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16961C3DA7D for ; Thu, 5 Jan 2023 21:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:Cc:To:From :Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ERNOIoSygDcl8audYKpHWUiurfGqG0n9xno/zY+aXPc=; b=z/yO7gdMv18LQviPbjDzqsRm0U 92P1QBe2kE66AaN3JEXRRdaPj/8r3xE9sFcrUr5bNeYv9jYxtvc89IU0At9QuVtkM7eW/oFRl5blf hvYZ5Q/fXChlVvujuuBYqcRVseeEd2MtI3E3/yvvJXZc/1fyT7uc87cBoCMAc5X1YeW2vblrQnYPr Zvo8cF6nO2QGCoeXZmiTJxcL/aw3uhai1GaqJz+5nPUyzxeGVCEaIZr2gLvpPuvAIIO9yWzq3vhbQ yCzxpk01oPtBzLXy8vnVQLXV074zMeBIf9vqr3fzBNM/hLUKnm53OyOmzCKIPQZMABcbcqAOLhple MZElbajA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDXUX-00Ew3x-FA; Thu, 05 Jan 2023 21:09:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDUo7-00DTBS-4f for linux-arm-kernel@bombadil.infradead.org; Thu, 05 Jan 2023 18:17:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version: Sender:Reply-To:Content-ID:Content-Description; bh=5ox2AHpCozB9D2AA+DmLS+FQ8YK9yjntjf01mZPEqQQ=; b=fCDFHA5rbGPg0Qk0koHKNSah8R oS2JkwTt0IFzfqmCuUMxer6Ub2LPgx9b2FOHdAaxyJtxleqqY8BaKnjB6p1tbkUxt+BKkYWL040SN DTnLJ0MVQRTUZlPEkW3KTK4pE3FEOH0ONIONWYmFobQMmmX+ubupGHf64RafuswgwKChAnekW3HwA nzN63S5WPrB1VTNoaE06/VWUGWBFC85Z1KyqFYuwHcrZ/sbwrGeJ59isLune9IC6czVluaGuJ+Jas NDrYQ4BkgAn4vfrl7e4XWkR2JN114pY6tvDApknlqtWDl5Ey3SXBUkjV95vov7Ikj6ldW0bOdtxNR dQnE/p3g==; Received: from 0001.3ffe.de ([2a01:4f8:c0c:9d57::1] helo=mail.3ffe.de) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pDPiq-001Jwo-2I for linux-arm-kernel@lists.infradead.org; Thu, 05 Jan 2023 12:51:55 +0000 Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 8395C61; Thu, 5 Jan 2023 13:51:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672923113; h=from:from:reply-to:subject:subject: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=5ox2AHpCozB9D2AA+DmLS+FQ8YK9yjntjf01mZPEqQQ=; b=CbTHCYy/PpHg9tnJL40N0QyKfSBPMEuWodnDHIS2Q7bnFFNSiBHUO8kGYkCu4CqzxlvpMN OD4EUMcJSjPq9EfPoSPo9i5yFs8YqU91BDNZV584H0em1c0Pwhx2G9e3YjETGgGeCtJ+xM QQraL2B4cfCIigOQJMsKIgFWxhDzsvI9TrBAxlPDonU1Z2fHXehQ1J1ze2mHfg8DyYowJp N/dYi3TdxeyV2uoBowyNYdNWPNJ7fOTD4IO8b1IjyE/H0GhaWegBc+q969OAQ5Nd9GBtdZ L35+YPXFm/qu7vt8J20PtJANmzQOKqvDnkBeuQ/mIP96ETVkIs5j8n6m52NgsA== MIME-Version: 1.0 Date: Thu, 05 Jan 2023 13:51:53 +0100 From: Michael Walle To: Alexander Stein Cc: Miquel Raynal , Srinivas Kandagatla , Jonathan Corbet , Rob Herring , Frank Rowand , Sascha Hauer , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH v5 00/21] nvmem: core: introduce NVMEM layouts In-Reply-To: <5906091.UjTJXf6HLC@steina-w> References: <20221206200740.3567551-1-michael@walle.cc> <20230105123534.38a70640@xps-13> <34cddc1aa4f8a55c752a9565d1726127@walle.cc> <5906091.UjTJXf6HLC@steina-w> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <13fca55324d55f9d4e30ca7fcc930e15@walle.cc> X-Sender: michael@walle.cc X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230105_125153_004094_55549DD3 X-CRM114-Status: GOOD ( 28.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Am 2023-01-05 13:21, schrieb Alexander Stein: > Am Donnerstag, 5. Januar 2023, 13:11:37 CET schrieb Michael Walle: >> thanks for debugging. I'm not yet sure what is going wrong, so >> I have some more questions below. >> >> >> This causes the following errors on existing boards (imx8mq-tqma8mq- >> >> mba8mx.dtb): >> >> root@tqma8-common:~# uname -r >> >> 6.2.0-rc2-next-20230105 >> >> >> >> > OF: /soc@0: could not get #nvmem-cell-cells for /soc@0/bus@30000000/ >> >> >> >> efuse@30350000/soc-uid@4 >> >> >> >> > OF: /soc@0/bus@30800000/ethernet@30be0000: could not get >> >> > #nvmem-cell-cells >> >> >> >> for /soc@0/bus@30000000/efuse@30350000/mac-address@90 >> >> >> >> These are caused because '#nvmem-cell-cells = <0>;' is not explicitly >> >> set in >> >> DT. >> >> >> >> > TI DP83867 30be0000.ethernet-1:0e: error -EINVAL: failed to get nvmem >> >> > cell >> >> >> >> io_impedance_ctrl >> >> >> >> > TI DP83867: probe of 30be0000.ethernet-1:0e failed with error -22 >> >> >> >> These are caused because of_nvmem_cell_get() now returns -EINVAL >> >> instead of - >> >> ENODEV if the requested nvmem cell is not available. >> >> What do you mean with not available? Not yet available because of >> probe >> order? > > Ah, I was talking about there is no nvmem cell being used in my PHY > node, e.g. > no 'nvmem-cells' nor 'nvmem-cell-names' (set to 'io_impedance_ctrl'). > That's > why of_property_match_string returns -EINVAL. Ahh I see. You mean ENOENT instead of ENODEV, right? >> > Should we just assume #nvmem-cell-cells = <0> by default? I guess it's >> > a safe assumption. >> >> Actually, that's what patch 2/21 is for. >> >> Alexander, did you verify that the EINVAL is returned by >> of_parse_phandle_with_optional_args()? > > Yep. > > --8<-- > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 1b61c8bf0de4..f2a85a31d039 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -1339,9 +1339,11 @@ struct nvmem_cell *of_nvmem_cell_get(struct > device_node > *np, const char *id) > if (id) > index = of_property_match_string(np, > "nvmem-cell-names", id); > > + pr_info("%s: index: %d\n", __func__, index); > ret = of_parse_phandle_with_optional_args(np, "nvmem-cells", > "#nvmem-cell-cells", > index, &cell_spec); > + pr_info("%s: of_parse_phandle_with_optional_args: %d\n", > __func__, > ret); > if (ret) > return ERR_PTR(ret); > --8<-- > > Results in: >> [ 1.861896] of_nvmem_cell_get: index: -22 >> [ 1.865934] of_nvmem_cell_get: of_parse_phandle_with_optional_args: >> -22 >> [ 1.872595] TI DP83867 30be0000.ethernet-1:0e: error -EINVAL: >> failed to > get nvmem cell io_impedance_ctrl >> [ 2.402575] TI DP83867: probe of 30be0000.ethernet-1:0e failed with >> error > -22 > > So, the index is wrong in the first place, but this was no problem > until now. Thanks, could you try the following patch: diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 1b61c8bf0de4..1085abfcd9b1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1336,8 +1336,11 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) int ret; /* if cell name exists, find index to the name */ - if (id) + if (id) { index = of_property_match_string(np, "nvmem-cell-names", id); + if (index < 0) + return ERR_PTR(-ENOENT); + } ret = of_parse_phandle_with_optional_args(np, "nvmem-cells", "#nvmem-cell-cells", Before patch 6/21, the -EINVAL was passed as index to of_parse_phandle() which then returned NULL, which caused the nvmem core to return ENOENT. I have a vague memory, that I made sure, that of_parse_phandle_with_optional_args() will also propagate the wrong index to its return code. But now, it won't be converted to ENOENT. -michael _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel