public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jyan Chou [周芷安]" <jyanchou@realtek.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"jh80.chung@samsung.com" <jh80.chung@samsung.com>,
	"riteshh@codeaurora.org" <riteshh@codeaurora.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>
Cc: "conor+dt@kernel.org" <conor+dt@kernel.org>,
	"asutoshd@codeaurora.org" <asutoshd@codeaurora.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"briannorris@chromium.org" <briannorris@chromium.org>,
	"doug@schmorgal.com" <doug@schmorgal.com>,
	"tonyhuang.sunplus@gmail.com" <tonyhuang.sunplus@gmail.com>,
	"abel.vesa@linaro.org" <abel.vesa@linaro.org>,
	"william.qiu@starfivetech.com" <william.qiu@starfivetech.com>
Subject: RE: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver
Date: Tue, 28 Nov 2023 07:05:32 +0000	[thread overview]
Message-ID: <24b03128ab594363a29494c0171e9f5f@realtek.com> (raw)
In-Reply-To: <23011695aafca595c3c8722fda2a8e194c5318df.camel@pengutronix.de>

Hi Philipp,

>> We implemented cmdq feature on Synopsys DesignWare mmc driver.
>> The difference between dw_mmc.c and dw_mmc_cqe.c were distinct 
>> register definitions, mmc user flow and the addition of cmdq.
>>
>> New version of User Guide had modify mmc driver's usage flow, we may 
>> need to renew code to precisely follow user guide.
>>
>> More over, We added a wait status function to satisfy synopsys user 
>> guide's description, since this flow might be specific in synopsys 
>> host driver only.
>>
>> Signed-off-by: Jyan Chou <jyanchou@realtek.com>
>>
>> —--
> [...]
>> diff --git a/drivers/mmc/host/dw_mmc_cqe.c 
>> b/drivers/mmc/host/dw_mmc_cqe.c new file mode 100644 index 
>> 000000000000..eb00d6a474b2
>> --- /dev/null
>> +++ b/drivers/mmc/host/dw_mmc_cqe.c
>> @@ -0,0 +1,1467 @@
> [...]
>> +#ifdef CONFIG_OF
>> +static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
>> +{
>> +     struct dw_mci_board *pdata;
>> +     struct device *dev = host->dev;
>> +     const struct dw_mci_drv_data *drv_data = host->drv_data;
>> +     int ret;
>> +
>> +     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>> +     if (!pdata)
>> +             return ERR_PTR(-ENOMEM);
>> +
>> +     pdata->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
>> +     if (IS_ERR(pdata->rstc)) {
>> +             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
>> +                     return ERR_PTR(-EPROBE_DEFER);

> This should

>                return ERR_CAST(pdata->rstc);

> instead.

> There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value.
> devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

> Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().

Thanks for your advice, we will correct it in our next version.

> [...]
>> +int dw_mci_cqe_probe(struct dw_mci *host) {
> [...]
>> +     if (!IS_ERR(host->pdata->rstc)) {
>> +             reset_control_assert(host->pdata->rstc);
>> +             usleep_range(10, 50);
>> +             reset_control_deassert(host->pdata->rstc);
>> +     }

> This should be changed to

>        if (host->pdata->rstc) {
>                reset_control_assert(host->pdata->rstc);
>                usleep_range(10, 50);
>                reset_control_deassert(host->pdata->rstc);
>        }

[...]
> +     return 0;
> +
> +err_dmaunmap:
> +     if (!IS_ERR(host->pdata->rstc))
> +             reset_control_assert(host->pdata->rstc);

>This should be just

>        reset_control_assert(host->pdata->rstc);

> as reset_control_assert() is a no-op if host->pdata->rstc == NULL.

> [...]
>> +void dw_mci_cqe_remove(struct dw_mci *host) {
> [...]
>> +     if (!IS_ERR(host->pdata->rstc))
>> +             reset_control_assert(host->pdata->rstc);

>        reset_control_assert(host->pdata->rstc);

Also, we will correct this in our new version, thanks.

Best Regards, 
Jyan

-----Original Message-----
From: Philipp Zabel <p.zabel@pengutronix.de> 
Sent: Monday, November 27, 2023 8:51 PM
To: Jyan Chou [周芷安] <jyanchou@realtek.com>; ulf.hansson@linaro.org; adrian.hunter@intel.com; jh80.chung@samsung.com; riteshh@codeaurora.org; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org
Cc: conor+dt@kernel.org; asutoshd@codeaurora.org; linux-mmc@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; arnd@arndb.de; briannorris@chromium.org; doug@schmorgal.com; tonyhuang.sunplus@gmail.com; abel.vesa@linaro.org; william.qiu@starfivetech.com
Subject: Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver


External mail.



Hi,

On Di, 2023-11-21 at 17:10 +0800, Jyan Chou wrote:
> We implemented cmdq feature on Synopsys DesignWare mmc driver.
> The difference between dw_mmc.c and dw_mmc_cqe.c were distinct 
> register definitions, mmc user flow and the addition of cmdq.
>
> New version of User Guide had modify mmc driver's usage flow, we may 
> need to renew code to precisely follow user guide.
>
> More over, We added a wait status function to satisfy synopsys user 
> guide's description, since this flow might be specific in synopsys 
> host driver only.
>
> Signed-off-by: Jyan Chou <jyanchou@realtek.com>
>
> —--
[...]
> diff --git a/drivers/mmc/host/dw_mmc_cqe.c 
> b/drivers/mmc/host/dw_mmc_cqe.c new file mode 100644 index 
> 000000000000..eb00d6a474b2
> --- /dev/null
> +++ b/drivers/mmc/host/dw_mmc_cqe.c
> @@ -0,0 +1,1467 @@
[...]
> +#ifdef CONFIG_OF
> +static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
> +{
> +     struct dw_mci_board *pdata;
> +     struct device *dev = host->dev;
> +     const struct dw_mci_drv_data *drv_data = host->drv_data;
> +     int ret;
> +
> +     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +     if (!pdata)
> +             return ERR_PTR(-ENOMEM);
> +
> +     pdata->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
> +     if (IS_ERR(pdata->rstc)) {
> +             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
> +                     return ERR_PTR(-EPROBE_DEFER);

This should

                return ERR_CAST(pdata->rstc);

instead.

There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value.
devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().


[...]
> +int dw_mci_cqe_probe(struct dw_mci *host) {
[...]
> +     if (!IS_ERR(host->pdata->rstc)) {
> +             reset_control_assert(host->pdata->rstc);
> +             usleep_range(10, 50);
> +             reset_control_deassert(host->pdata->rstc);
> +     }

This should be changed to

        if (host->pdata->rstc) {
                reset_control_assert(host->pdata->rstc);
                usleep_range(10, 50);
                reset_control_deassert(host->pdata->rstc);
        }

[...]
> +     return 0;
> +
> +err_dmaunmap:
> +     if (!IS_ERR(host->pdata->rstc))
> +             reset_control_assert(host->pdata->rstc);

This should be just

        reset_control_assert(host->pdata->rstc);

as reset_control_assert() is a no-op if host->pdata->rstc == NULL.

[...]
> +void dw_mci_cqe_remove(struct dw_mci *host) {
[...]
> +     if (!IS_ERR(host->pdata->rstc))
> +             reset_control_assert(host->pdata->rstc);

        reset_control_assert(host->pdata->rstc);


regards
Philipp

  reply	other threads:[~2023-11-28  7:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21  9:10 [PATCH V7][0/4] Add DesignWare Mobile mmc driver Jyan Chou
2023-11-21  9:10 ` [PATCH v7][1/4] mmc: solve DMA boundary limitation of CQHCI driver Jyan Chou
2023-11-21  9:10 ` [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver Jyan Chou
2023-11-22  0:20   ` kernel test robot
2023-11-22 14:48   ` kernel test robot
2023-11-27 12:51   ` Philipp Zabel
2023-11-28  7:05     ` Jyan Chou [周芷安] [this message]
2023-11-28 10:53     ` Arnd Bergmann
2023-11-27 13:02   ` Christian Loehle
2023-11-28  6:58     ` Jyan Chou [周芷安]
2023-11-28 18:05   ` Adrian Hunter
2023-12-05  9:19     ` Jyan Chou [周芷安]
2023-12-05 11:26       ` Adrian Hunter
2023-12-11 10:37         ` Jyan Chou [周芷安]
2023-12-11 10:45           ` Adrian Hunter
2023-11-21  9:11 ` [PATCH v7][3/4] mmc: Add dw mobile mmc cmdq rtk driver Jyan Chou
2023-11-21  9:11 ` [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver Jyan Chou
2023-11-21  9:35   ` Krzysztof Kozlowski
2023-11-22  2:54     ` Jyan Chou [周芷安]
2023-11-22  7:36       ` Krzysztof Kozlowski
2023-11-22  8:33         ` Jyan Chou [周芷安]
2023-11-22  8:45           ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24b03128ab594363a29494c0171e9f5f@realtek.com \
    --to=jyanchou@realtek.com \
    --cc=abel.vesa@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=asutoshd@codeaurora.org \
    --cc=briannorris@chromium.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=doug@schmorgal.com \
    --cc=jh80.chung@samsung.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=riteshh@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=tonyhuang.sunplus@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=william.qiu@starfivetech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox