From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A59F229CA for ; Mon, 19 Apr 2021 05:03:12 +0000 (UTC) Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by gw.atmark-techno.com (Postfix) with ESMTPS id C5692804BF for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-vk1-f200.google.com with SMTP id l185-20020a1f57c20000b02901d909b5e911so4695115vkb.15 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=PWUw4Q/4DosRTd5TEp9yY3mdnhMEYRq43jkwFT2CylrItFjsbzm7nGVf0GYKeqekHq dcnOIgSy/svR9+QJmSQnRVGolTGYTDY1qkVxA/oSsEP8nGdhNGBLnbozoYXqod/Eanyn GDxpE2y7AFieyTAAWd+RERWAcnKgxyfFHp6w7W9bSMUWZyWZlJ9M/JB4IYy2FbiQ+ZxB uKJW9KSaZh424cXIh59aW3JmfaJHBZCUHvob4sy2/U7g1dpC8YGUs/J7H+d6YZMutM65 g0/ErIM4326RVYuE/1HDQ/qFRO8+n3tqZXZotO9gbdGWpO5qjAc5Kwp3mhQ2rXetMqzt NlRg== X-Gm-Message-State: AOAM5303RbVM4f6HCzgkYoVgXfvl1gTgtFWeSUiRiaEyYUVHrE1oEJJB CNHw6Wx22n9ROaOUll5m9iPujSfdyMHoXP4vVn7bMAxlMWEdhXT8co9GFxgtxa7YeJZzRRfk4vs BgJdotIuQEBTXbDO62D0KjkoAnKV4YQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074825plh.47.1618808579512; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Cc: gregkh@linuxfoundation.org, rafael@kernel.org, horia.geanta@nxp.com, aymen.sghaier@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, tony@atomide.com, geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, vkoul@kernel.org, peter.ujfalusi@gmail.com, a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, airlied@linux.ie, daniel@ffwll.ch, khilman@baylibre.com, tomba@kernel.org, jyri.sarha@iki.fi, joro@8bytes.org, will@kernel.org, mchehab@kernel.org, ulf.hansson@linaro.org, adrian.hunter@intel.com, kishon@ti.com, kuba@kernel.org, linus.walleij@linaro.org, Roy.Pledge@nxp.com, leoyang.li@nxp.com, ssantosh@kernel.org, matthias.bgg@gmail.com, edubezval@gmail.com, j-keerthy@ti.com, balbi@kernel.org, linux@prisktech.co.nz, stern@rowland.harvard.edu, wim@linux-watchdog.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-staging@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADC67C433ED for ; Mon, 19 Apr 2021 06:25:20 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DFB061104 for ; Mon, 19 Apr 2021 06:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DFB061104 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FNxdB4mhyz3c9M for ; Mon, 19 Apr 2021 16:25:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=atmark-techno.com (client-ip=13.115.124.170; helo=gw.atmark-techno.com; envelope-from=dominique.martinet@atmark-techno.com; receiver=) Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by lists.ozlabs.org (Postfix) with ESMTP id 4FNvpS1PZ4z2ypn for ; Mon, 19 Apr 2021 15:03:12 +1000 (AEST) Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by gw.atmark-techno.com (Postfix) with ESMTPS id 1F3688048F for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-ua1-f69.google.com with SMTP id u3-20020ab069c30000b02901ebe1c8da33so1688944uaq.7 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=n+LpgNbIx6wos1mpiFQV/gxXHiNB9iNy5LfOnGXj4iEnlOazmsg3bkJMqOVCgB59iS /7VNgJ4qt0oPdfvmLbXBB5rhjZuAbJeswuQmcduCDJwG9iiOsdA+0DxTExaJHGIf8n+W hWQVk+WZLjWFngwYyD0IrWQFhdc0fDdBYdMQpy0huB4oPr8CM4qJM+NNq//zWfkG74xQ gnrdQowhdi/Z2C3gXpg11ID7LnAKAXksLb9iqfQ2xmegwSJU9G3cxO/z1KhtN2vOd1H2 U+9UUXUbg6NPwmTnBKTAZVuewbR2Z4xyx2/fSbvCalfZYzu6ezYCHTGWIGfUnJ3KPDNy 7/uA== X-Gm-Message-State: AOAM530hv4XfRJjvqtHa591J8GJ+EK+RyQsrTa8uXyA+eOQsLq18QwRn I+3OC5roH+v4vU1gBbkVMoA7lQr7CwNjCQd207khTPOIGFAZ3cfrc246q8S/S0dK4DXKCoLnOmW 2oYkpxuSUculQLhEsE3Z9pWqMW7dWJg== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074827plh.47.1618808579511; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-Mailman-Approved-At: Mon, 19 Apr 2021 16:21:18 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, aymen.sghaier@nxp.com, geert+renesas@glider.be, rafael@kernel.org, airlied@linux.ie, mturquette@baylibre.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, a.hajda@samsung.com, netdev@vger.kernel.org, linux-phy@lists.infradead.org, will@kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org, wim@linux-watchdog.org, herbert@gondor.apana.org.au, horia.geanta@nxp.com, khilman@baylibre.com, joro@8bytes.org, narmstrong@baylibre.com, linux-staging@lists.linux.dev, iommu@lists.linux-foundation.org, peter.ujfalusi@gmail.com, kishon@ti.com, tony@atomide.com, linux-omap@vger.kernel.org, stern@rowland.harvard.edu, kuba@kernel.org, linus.walleij@linaro.org, linux@roeck-us.net, linux-media@vger.kernel.org, linux-watchdog@vger.kernel.org, Roy.Pledge@nxp.com, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, edubezval@gmail.com, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, ssantosh@kernel.org, matthias.bgg@gmail.com, linux-amlogic@lists.infradead.org, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org, balbi@kernel.org, tomba@kernel.org, sboyd@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org, adrian.hunter@intel.com, robert.foss@linaro.org, leoyang.li@nxp.com, linux@prisktech.co.nz, vkoul@kernel.org, linux-crypto@vger.kernel.org, daniel@ffwll.ch, j-keerthy@ti.com, dmaengine@vger.kernel.org, jyri.sarha@iki.fi, davem@davemloft.net Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC2E7C43461 for ; Mon, 19 Apr 2021 07:07:26 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2183C6101D for ; Mon, 19 Apr 2021 07:07:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2183C6101D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 568A4403CD; Mon, 19 Apr 2021 07:07:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K692AAUvaHvU; Mon, 19 Apr 2021 07:07:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTP id 8AE3B403A4; Mon, 19 Apr 2021 07:07:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 19E24C0019; Mon, 19 Apr 2021 07:07:23 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 20163C000B for ; Mon, 19 Apr 2021 05:03:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EFBA9607A4 for ; Mon, 19 Apr 2021 05:03:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0qeFOTDDC2EN for ; Mon, 19 Apr 2021 05:03:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by smtp3.osuosl.org (Postfix) with ESMTP id D4AB9607A2 for ; Mon, 19 Apr 2021 05:03:12 +0000 (UTC) Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by gw.atmark-techno.com (Postfix) with ESMTPS id DC9D6804C6 for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-ua1-f72.google.com with SMTP id o9-20020ab054490000b02901ec47f004b2so76382uaa.17 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=toOQ4ntlG0GbVZ7MTmv4ERbe2jTSpygWx24eEj/MBvhE4yIwhirA3PsVMNiZwSrUeO uJPLYbCqciZ4YdL/2FdglqMtyLnpdeXiLg52BuC7SYjJAkX/3XabhBLT0Sxw4YTMRk/c AJjCCYKRm+4mCKHNcJtqyVfMqxspaDKVsFFz4odaieKk2yZwEnhOjXKj0icGH1cPQEFm OMibiunuHGYrpEApRQGe0sREH/cFuBpii/wDGYTwC0bFmRdqWKS4n3rEMr+Rm0tQn7CF 6xUS19Jgs+lPxNgZE1mymiNkV8SdV9aYLgBms4jZiEwLh4NvP2qhoQP5fApInVjHr13s bYEg== X-Gm-Message-State: AOAM531Od3lFnJXUb5UDuLq9NT08ZJNorYSCzYuLikCAUQ+cSn6rccEb F+wglXfF8sSXkubnYrffwwl/X3jxiuXEJ45673UtIUIfui25LaAQ1FufTkmYwyJjz3+xgJtqbGh pzPU8oZgJtl2bXpKX8410fd/+2Pds5GccHg== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074789plh.47.1618808579507; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-Mailman-Approved-At: Mon, 19 Apr 2021 07:07:20 +0000 Cc: ulf.hansson@linaro.org, aymen.sghaier@nxp.com, geert+renesas@glider.be, rafael@kernel.org, airlied@linux.ie, mturquette@baylibre.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, a.hajda@samsung.com, netdev@vger.kernel.org, linux-phy@lists.infradead.org, will@kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org, wim@linux-watchdog.org, herbert@gondor.apana.org.au, horia.geanta@nxp.com, khilman@baylibre.com, narmstrong@baylibre.com, linux-staging@lists.linux.dev, iommu@lists.linux-foundation.org, peter.ujfalusi@gmail.com, kishon@ti.com, tony@atomide.com, linux-omap@vger.kernel.org, stern@rowland.harvard.edu, kuba@kernel.org, linus.walleij@linaro.org, linux@roeck-us.net, linux-media@vger.kernel.org, linux-watchdog@vger.kernel.org, Roy.Pledge@nxp.com, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, edubezval@gmail.com, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, ssantosh@kernel.org, matthias.bgg@gmail.com, linux-amlogic@lists.infradead.org, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org, balbi@kernel.org, tomba@kernel.org, sboyd@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org, adrian.hunter@intel.com, robert.foss@linaro.org, leoyang.li@nxp.com, linux@prisktech.co.nz, vkoul@kernel.org, linux-crypto@vger.kernel.org, daniel@ffwll.ch, j-keerthy@ti.com, dmaengine@vger.kernel.org, jyri.sarha@iki.fi, davem@davemloft.net X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26B07C433B4 for ; Mon, 19 Apr 2021 05:03:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75ECB6113C for ; Mon, 19 Apr 2021 05:03:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75ECB6113C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Tbv3dO0SU5ZbI89Xm8sq64a9JK4AYEkJLZje9vucafk=; b=UBmLLKKSR7fOv4gQvOzWMe9Ko MPYFOUU8YtqjQS/kFl/RFCswIkwr0TAQHdBqcyPdBhGSI2IjlIaALC3sG1EYfp+n0hHQziMltTW0U cvN5311MAh18SjD8bc09SFmOZfn2kfbTgCozGZrK6XRIHURlvt4r2jBdS5zrpBtZvacNvMiZx8EaP usKseWNtN0RV1NPrSU5dvQLacTT+h5vEYv9tUHS7SFJRL/bpXFrYSg/S1S2ahj5TNlDc/xjG31bab K89QBRsROqd2eg6z1spMy68bAuTgs3WfN9OWxOH4WaBABmoEtCLd3GEPebyCT9kRVM6jVBdVhNK2C C06Piv5EQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM4B-0097Rf-2A; Mon, 19 Apr 2021 05:03:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYM45-0097Qj-VQ for linux-mediatek@desiato.infradead.org; Mon, 19 Apr 2021 05:03:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=FqCUaH/m4o36EybObw8kYfxjc3 jM8bp7G1PfxE3kdBhTXbhnbTcUUY3ZeohBhZf/hE6bILLoB+A4Lyk2cTPdPbR18wJtxm01rRpL4d0 QrKLjig1TqarAcBJwKm22Xlf7obXxgVgXFa0sx2HonPUr+GWSHWu9eVnMsh2HdFJnXg5QbeYWTb3A 2OJhJpMuTns2elyGngOnkEmVhSmj6tVP8u8PGzhCq3e7nDX4zyEc0HsQIgV9jaav/XfwNEGBURHln 2UukyNl7wS6OKLxWQpXVvdGP9luQnMgy7W6BnVTQNHm3O9t1Z0mTBI36tqz0FTTNphxJruM4UCqnO /rhRPZjw==; Received: from gw.atmark-techno.com ([13.115.124.170]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM40-00B029-F3 for linux-mediatek@lists.infradead.org; Mon, 19 Apr 2021 05:03:16 +0000 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by gw.atmark-techno.com (Postfix) with ESMTPS id AD121804AF for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-qv1-f69.google.com with SMTP id w20-20020a0562140b34b029019c9674180fso8569907qvj.0 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=kb6OPUs4gHy9F5umBV94cq9Myh5ypFNo9XTBAvd0O6MUB2yObNDZWEXAu0WLyBmwfr mr5PvCEtmCY2Sj504bijH76yxCXD/7qLiFK5sb7tMJcNKepgw5CBg/t/Q3TL+XY8ydDq PzhgMup6RcL8/X718hwkbber7HCVNluhfUEf6xpRjaTOKKU2aaxueynLJvj81gVasn0e QgGUIePNSHLHwdIMw5vX75xWjErLP31uGRrTmN+FeqtJPOKyfW45VA3Ul81xxvc4aJ36 cK8X43VxC8YTfpVi0G1x72ii7SZwvJJNqYOPxPN8ZAGjTOzFBYLmvx2ASOdXvWahK5lY abMA== X-Gm-Message-State: AOAM533eS8WnNbCws5eJH2ehEYdAithxftemjYgw28fEx+jSRvZrovhe qQ75bUPzgq+ZHb/W44E7e+Vp9Pbk/KGmSVxAAlCwYmi58ZmmtBUtysPYLRcg5dRu041kSLAqXVr WIhgBhZ+jgp8700KKFIOxf7ubkXaPw21Uj6o2 X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074831plh.47.1618808579511; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Cc: gregkh@linuxfoundation.org, rafael@kernel.org, horia.geanta@nxp.com, aymen.sghaier@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, tony@atomide.com, geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, vkoul@kernel.org, peter.ujfalusi@gmail.com, a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, airlied@linux.ie, daniel@ffwll.ch, khilman@baylibre.com, tomba@kernel.org, jyri.sarha@iki.fi, joro@8bytes.org, will@kernel.org, mchehab@kernel.org, ulf.hansson@linaro.org, adrian.hunter@intel.com, kishon@ti.com, kuba@kernel.org, linus.walleij@linaro.org, Roy.Pledge@nxp.com, leoyang.li@nxp.com, ssantosh@kernel.org, matthias.bgg@gmail.com, edubezval@gmail.com, j-keerthy@ti.com, balbi@kernel.org, linux@prisktech.co.nz, stern@rowland.harvard.edu, wim@linux-watchdog.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-staging@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_220312_629579_3A11DBF9 X-CRM114-Status: GOOD ( 28.99 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72C6AC433B4 for ; Mon, 19 Apr 2021 06:43:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F25146101C for ; Mon, 19 Apr 2021 06:43:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F25146101C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C45E66E1A7; Mon, 19 Apr 2021 06:42:57 +0000 (UTC) Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by gabe.freedesktop.org (Postfix) with ESMTP id BB4AC89FDB for ; Mon, 19 Apr 2021 05:03:11 +0000 (UTC) Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by gw.atmark-techno.com (Postfix) with ESMTPS id 18D638048E for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-pj1-f71.google.com with SMTP id j9-20020a17090aeb09b029014e8f7a3d5bso11301233pjz.9 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=g4gNBfqEk/rUI2Qtx8MdTJcLifPGEzuqjUtCJM3p5b3EKfbuXy45/jR1cSkqVmHqVc 5jZbcrrCRhK1tbg+QWpQyvA3uDRYQ3LBcVcLWYshDgBqe05pxcguHlEz5O5qh39pU//m /vzezTInMMt24D35C0lkhuIZOwOIH63QD5Z1mOihiuvOK6ivK9JTYWGBP1zoxaxFyLSI Bs/0vmGAOjz9EqiwKTmfIvS1iYSjGGr5TB93e5pd4Z8jyAkp0GIzYiLSd8zvwC5qktmC NCdL6tfLTLiTAIRHH5wLtOJ4Ms8kbUdnUVdgXXLOG0lklZ7tgVxKldk5sKi2QfKeuv57 jICA== X-Gm-Message-State: AOAM530iAwMZdRqZEf8JpVSapl5GGH+nesgY6SBMIEzoItsAwcqI9aSB ngaCuU9D6extJjPrBwkPGw68VSO/+Gr0NMrh9syg2ba9g0cUKNWomYwcmA0lup1d1WDV8UnjP+V 0BeCnlnnmmfSzUIElcPnEKFS2gY+hEdvD X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074813plh.47.1618808579511; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-Mailman-Approved-At: Mon, 19 Apr 2021 06:42:50 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, aymen.sghaier@nxp.com, geert+renesas@glider.be, rafael@kernel.org, airlied@linux.ie, mturquette@baylibre.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, a.hajda@samsung.com, netdev@vger.kernel.org, linux-phy@lists.infradead.org, will@kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org, wim@linux-watchdog.org, herbert@gondor.apana.org.au, horia.geanta@nxp.com, khilman@baylibre.com, joro@8bytes.org, narmstrong@baylibre.com, linux-staging@lists.linux.dev, iommu@lists.linux-foundation.org, peter.ujfalusi@gmail.com, kishon@ti.com, tony@atomide.com, linux-omap@vger.kernel.org, stern@rowland.harvard.edu, kuba@kernel.org, linux@roeck-us.net, linux-media@vger.kernel.org, linux-watchdog@vger.kernel.org, Roy.Pledge@nxp.com, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, edubezval@gmail.com, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, ssantosh@kernel.org, matthias.bgg@gmail.com, linux-amlogic@lists.infradead.org, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org, balbi@kernel.org, tomba@kernel.org, sboyd@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org, adrian.hunter@intel.com, robert.foss@linaro.org, leoyang.li@nxp.com, linux@prisktech.co.nz, vkoul@kernel.org, linux-crypto@vger.kernel.org, j-keerthy@ti.com, dmaengine@vger.kernel.org, jyri.sarha@iki.fi, davem@davemloft.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFF49C433B4 for ; Mon, 19 Apr 2021 05:03:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B40761151 for ; Mon, 19 Apr 2021 05:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B40761151 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8AKVPzHMioluCtzNVu5ozG6W6yYY13LQoV8QnacOJTk=; b=eBx6c6VsfYfKktU2I4fgbQbCw tSG2ntgoZKhDjRny8+XK9y67A+ERqIrl0GNQezs4m2WOUsZz70v3zMOOYExV7UyNujlz2BdcRGcmh LljD/kTqX9NoKvoWFVev5+HWjrBbY782YTFlNt5+Yk9OESrugD8Fnxfkkv6KQvNJ+9j+KX2fLpiYw 9QimrMrP5+C27hcg3CP2EUPuCtiI4H4SUZGfsQcRGGAcuit2pl040UKiwrnpb9WrDm5W2pYiOZ1ql usvO8djop4zgvYreps0aHUOhYeF1fphjquMgqZ8TpB8o1OcHF12AlNuFpdyvRDh6h8NeSi8EpwSnB IrkLebUmg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM49-0097RA-QZ; Mon, 19 Apr 2021 05:03:21 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYM45-0097Qi-S2 for linux-amlogic@desiato.infradead.org; Mon, 19 Apr 2021 05:03:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=FqCUaH/m4o36EybObw8kYfxjc3 jM8bp7G1PfxE3kdBhTXbhnbTcUUY3ZeohBhZf/hE6bILLoB+A4Lyk2cTPdPbR18wJtxm01rRpL4d0 QrKLjig1TqarAcBJwKm22Xlf7obXxgVgXFa0sx2HonPUr+GWSHWu9eVnMsh2HdFJnXg5QbeYWTb3A 2OJhJpMuTns2elyGngOnkEmVhSmj6tVP8u8PGzhCq3e7nDX4zyEc0HsQIgV9jaav/XfwNEGBURHln 2UukyNl7wS6OKLxWQpXVvdGP9luQnMgy7W6BnVTQNHm3O9t1Z0mTBI36tqz0FTTNphxJruM4UCqnO /rhRPZjw==; Received: from gw.atmark-techno.com ([13.115.124.170]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM40-00B028-Be for linux-amlogic@lists.infradead.org; Mon, 19 Apr 2021 05:03:16 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by gw.atmark-techno.com (Postfix) with ESMTPS id AE229804B1 for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-pg1-f199.google.com with SMTP id x12-20020a63f70c0000b0290202e04d4af8so5546010pgh.1 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=Gc+W015NVQxBGUS4rgOSbO28tcc3KFDLtnUtFtxnKXcLbL+h93xqEyRTzW7wRFONSQ Et3+0OM0ZAtwC3+zvSGVhwAnZO4VLyQyo6QRi5hLdBRGhr461EC7J1gFinW975dQlECl QAoV6y41SZjJdO+4zTsz8zX3NDBR747vYvT+EiYhBqZm2uoRrW65qU549jNtDrNVkXxn tXcXEsHsFjZ4X84vFoZ1h1OsDrNa0y8/DRp1meRRKRkAqgTA7ch72Uc+Oyao5wJqrlGB qqAmRUeBBFrCNjP3kq+1C+tePxSbpPVlc7KY+eEj9Gy0o/1pCn/42Bg2imnHP8yW1pPu RsQQ== X-Gm-Message-State: AOAM532o27iakvRiKFO+lQLQeLEtA99qmY0D6GBGCbYYapUcQCJikNij i5t8Bq1W4az7nbCKrzB/5OC05+jBL3+vvUWUDhLsX6yqKKne3oazXVVZbvvXWs91qpu2HvJYiE+ GrLi95vIuBAZV5WriXvmlIMifdbPk0l0VfIQ= X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074787plh.47.1618808579507; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Cc: gregkh@linuxfoundation.org, rafael@kernel.org, horia.geanta@nxp.com, aymen.sghaier@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, tony@atomide.com, geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, vkoul@kernel.org, peter.ujfalusi@gmail.com, a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, airlied@linux.ie, daniel@ffwll.ch, khilman@baylibre.com, tomba@kernel.org, jyri.sarha@iki.fi, joro@8bytes.org, will@kernel.org, mchehab@kernel.org, ulf.hansson@linaro.org, adrian.hunter@intel.com, kishon@ti.com, kuba@kernel.org, linus.walleij@linaro.org, Roy.Pledge@nxp.com, leoyang.li@nxp.com, ssantosh@kernel.org, matthias.bgg@gmail.com, edubezval@gmail.com, j-keerthy@ti.com, balbi@kernel.org, linux@prisktech.co.nz, stern@rowland.harvard.edu, wim@linux-watchdog.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-staging@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_220312_525983_D7C5265B X-CRM114-Status: GOOD ( 28.81 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic 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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3605C433ED for ; Mon, 19 Apr 2021 05:03:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21F2E6113C for ; Mon, 19 Apr 2021 05:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21F2E6113C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atmark-techno.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NdVfXOYTVSXONzvnQLx523IMnX16CpMTZuxb3SYfytY=; b=oNIffKL4emLlGcagvLZk1jITh /tSbnQYbe1gbSC0qtaOJTh2SS4qgMNDGsugXEjuBjP2pN7Nq/xnfN5vzop7b+SywZ5gKC8hFbdFXz oj/Ria/IVy/kk20MDc9fbg7i9la0p5+/XzTZGDWS9vujIgEU9TOLH68PCEfy0NEkAeD3FITvrgm5p vlQW3TKFo2DM+/zkIVZ6MeU9vmDew6eoZXsNdypErd2Jv9uLyCubJqTZ2BTMeAtAEmIKG4LVRw5TF 29HKQ0/qNgnVWez7J4p9fd5sDjOoBfEaTRZKDLVnpHjTE3rKEu4d7eB6dxSWjC3NfAkzzVluiMbUL Rn/9JspUw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM4C-0097S9-Hm; Mon, 19 Apr 2021 05:03:24 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYM49-0097R9-Rp for linux-phy@desiato.infradead.org; Mon, 19 Apr 2021 05:03:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=FqCUaH/m4o36EybObw8kYfxjc3 jM8bp7G1PfxE3kdBhTXbhnbTcUUY3ZeohBhZf/hE6bILLoB+A4Lyk2cTPdPbR18wJtxm01rRpL4d0 QrKLjig1TqarAcBJwKm22Xlf7obXxgVgXFa0sx2HonPUr+GWSHWu9eVnMsh2HdFJnXg5QbeYWTb3A 2OJhJpMuTns2elyGngOnkEmVhSmj6tVP8u8PGzhCq3e7nDX4zyEc0HsQIgV9jaav/XfwNEGBURHln 2UukyNl7wS6OKLxWQpXVvdGP9luQnMgy7W6BnVTQNHm3O9t1Z0mTBI36tqz0FTTNphxJruM4UCqnO /rhRPZjw==; Received: from gw.atmark-techno.com ([13.115.124.170]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYM40-00B02A-Jy for linux-phy@lists.infradead.org; Mon, 19 Apr 2021 05:03:20 +0000 Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by gw.atmark-techno.com (Postfix) with ESMTPS id C88A1804C0 for ; Mon, 19 Apr 2021 14:03:11 +0900 (JST) Received: by mail-vk1-f198.google.com with SMTP id s186-20020a1f5ec30000b02901cfa330b3f9so4693998vkb.5 for ; Sun, 18 Apr 2021 22:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bLr973ENjFZQNNz5/z+BmoCFuTDVovYaAYguOO0YOc4=; b=lSNoC6xqn+aA6amNWPW0EXi15b2A8dTkHnKvHVphj57HbaDfIzCoOPQALhZ1QG7CHP q8xcOxUzKgjMcnvuUFhaE2ykuCtIoapU90MwiV32IiCXKuv3BzIXW6Oll5GdN551MfyT 7gLUBbgvpDhjpj2jzTbk07yHmckFdsvCUxWOByBpAvMbIABcN/zV5M7IEpxk714R/r5Q yJK+Vqui5e6fUppxA7smOVk4Do9Kulc3Kjaovfr3cA/YJnFywB89ai0F0fNPe2dkjk9h w/iHtLqwLiS1uUxDX5SvN+QTQeBZF5LvfyGLY8kaq/grBWOkXe3qlcLcCe728NjFFm2B JwfA== X-Gm-Message-State: AOAM533C/h0F9dm1vM09OexZ7yjDxW1dEd7ZCGB84IkGA1nRW00SgE+M fkV02ynX9Dczl2DWR+wM2VSCZwyRzrSo34EyQGSkeGIQpmCJ8T63eA1NmUcFXvCDKa0PFZL9Ad5 el5Y7ohMWSr83anm2whVVJMLmbU1rYg== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074803plh.47.1618808579510; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1MeNQhpXnytM5xmVsw3ZCkrTxMPyrxhKroAVtmGUaPe01xpWL31HOX4hl1pxmvtORo+KDQ== X-Received: by 2002:a17:902:d645:b029:e8:ec90:d097 with SMTP id y5-20020a170902d645b02900e8ec90d097mr21074765plh.47.1618808579243; Sun, 18 Apr 2021 22:02:59 -0700 (PDT) Received: from pc-0115 (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id ga21sm2553351pjb.5.2021.04.18.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Apr 2021 22:02:58 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lYM3l-0016Ra-6N; Mon, 19 Apr 2021 14:02:57 +0900 Date: Mon, 19 Apr 2021 14:02:47 +0900 From: Dominique MARTINET To: "Alice Guo (OSS)" Cc: gregkh@linuxfoundation.org, rafael@kernel.org, horia.geanta@nxp.com, aymen.sghaier@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, tony@atomide.com, geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, vkoul@kernel.org, peter.ujfalusi@gmail.com, a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, airlied@linux.ie, daniel@ffwll.ch, khilman@baylibre.com, tomba@kernel.org, jyri.sarha@iki.fi, joro@8bytes.org, will@kernel.org, mchehab@kernel.org, ulf.hansson@linaro.org, adrian.hunter@intel.com, kishon@ti.com, kuba@kernel.org, linus.walleij@linaro.org, Roy.Pledge@nxp.com, leoyang.li@nxp.com, ssantosh@kernel.org, matthias.bgg@gmail.com, edubezval@gmail.com, j-keerthy@ti.com, balbi@kernel.org, linux@prisktech.co.nz, stern@rowland.harvard.edu, wim@linux-watchdog.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-staging@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [RFC v1 PATCH 3/3] driver: update all the code that use soc_device_match Message-ID: References: <20210419042722.27554-1-alice.guo@oss.nxp.com> <20210419042722.27554-4-alice.guo@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210419042722.27554-4-alice.guo@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_220312_781218_8A8412A4 X-CRM114-Status: GOOD ( 28.81 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:22PM +0800: > From: Alice Guo > > Update all the code that use soc_device_match A single patch might be difficult to accept for all components, a each maintainer will probably want to have a say on their subsystem? I would suggest to split these for a non-RFC version; a this will really need to be case-by-case handling. > because add support for soc_device_match returning -EPROBE_DEFER. (English does not parse here for me) I've only commented a couple of places in the code itself, but this doesn't seem to add much support for errors, just sweep the problem under the rug. > Signed-off-by: Alice Guo > --- > > diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c > index 5fae60f8c135..00c59aa217c1 100644 > --- a/drivers/bus/ti-sysc.c > +++ b/drivers/bus/ti-sysc.c > @@ -2909,7 +2909,7 @@ static int sysc_init_soc(struct sysc *ddata) > } > > match = soc_device_match(sysc_soc_feat_match); > - if (!match) > + if (!match || IS_ERR(match)) > return 0; This function handles errors, I would recommend returning the error as is if soc_device_match returned one so the probe can be retried later. > > if (match->data) > diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c > index c32d2c678046..90a18336a4c3 100644 > --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c > +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c > @@ -439,6 +439,7 @@ static const unsigned int r8a7795es2_mod_nullify[] __initconst = { > > static int __init r8a7795_cpg_mssr_init(struct device *dev) > { > + const struct soc_device_attribute *match; > const struct rcar_gen3_cpg_pll_config *cpg_pll_config; > u32 cpg_mode; > int error; > @@ -453,7 +454,8 @@ static int __init r8a7795_cpg_mssr_init(struct device *dev) > return -EINVAL; > } > > - if (soc_device_match(r8a7795es1)) { > + match = soc_device_match(r8a7795es1); > + if (!IS_ERR(match) && match) { Same, return the error. Assuming an error means no match will just lead to hard to debug problems because the driver potentially assumed the wrong device when it's just not ready yet. > cpg_core_nullify_range(r8a7795_core_clks, > ARRAY_SIZE(r8a7795_core_clks), > R8A7795_CLK_S0D2, R8A7795_CLK_S0D12); > [...] > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index eaaec0a55cc6..13a06b613379 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -757,17 +757,20 @@ static const char * const devices_allowlist[] = { > > static bool ipmmu_device_is_allowed(struct device *dev) > { > + const struct soc_device_attribute *match1, *match2; > unsigned int i; > > /* > * R-Car Gen3 and RZ/G2 use the allow list to opt-in devices. > * For Other SoCs, this returns true anyway. > */ > - if (!soc_device_match(soc_needs_opt_in)) > + match1 = soc_device_match(soc_needs_opt_in); > + if (!IS_ERR(match1) && !match1) I'm not sure what you intended to do, but !match1 already means there is no error so the original code is identical. In this case ipmmu_device_is_allowed does not allow errors so this is one of the "difficult" drivers that require slightly more thinking. It is only called in ipmmu_of_xlate which does return errors properly, so in this case the most straightforward approach would be to make ipmmu_device_is_allowed return an int and forward errors as well. ... This is going to need quite some more work to be acceptable, in my opinion, but I think it should be possible. Thanks, -- Dominique -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy