diff mbox series

[1/4,1/4] mmc: core: expose MMC_CAP2_CQE* to dt

Message ID 1581921111-24172-2-git-send-email-chun-hung.wu@mediatek.com (mailing list archive)
State New, archived
Headers show
Series mmc: mediatek: add mmc cqhci support | expand

Commit Message

Chun-Hung Wu (巫駿宏) Feb. 17, 2020, 6:31 a.m. UTC
Expose MMC_CAP2_CQE and MMC_CAP2_CQE_DCMD
to host->caps2 if
1. "supports-cqe" is defined in dt and
2. "disable-cqe-dcmd" is not defined in dt.

---
 drivers/mmc/core/host.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Linus Walleij Feb. 21, 2020, 2:33 p.m. UTC | #1
On Mon, Feb 17, 2020 at 7:32 AM Chun-Hung Wu <chun-hung.wu@mediatek.com> wrote:

> Expose MMC_CAP2_CQE and MMC_CAP2_CQE_DCMD
> to host->caps2 if
> 1. "supports-cqe" is defined in dt and
> 2. "disable-cqe-dcmd" is not defined in dt.
>
> ---
>  drivers/mmc/core/host.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 105b7a7..efb0dbe 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -319,6 +319,14 @@ int mmc_of_parse(struct mmc_host *host)
>                 host->caps2 |= MMC_CAP2_NO_SD;
>         if (device_property_read_bool(dev, "no-mmc"))
>                 host->caps2 |= MMC_CAP2_NO_MMC;
> +       if (device_property_read_bool(dev, "supports-cqe"))
> +               host->caps2 |= MMC_CAP2_CQE;

I don't understand why this is even a DT property as it should
be clear from the hosts compatible whether it supports CQE or
not. But it's too late to do anything about that I suppose, and
I just assume there is something I don't understand here.

> +       /* Must be after "supports-cqe" check */
> +       if (!device_property_read_bool(dev, "disable-cqe-dcmd")) {
> +               if (host->caps2 & MMC_CAP2_CQE)
> +                       host->caps2 |= MMC_CAP2_CQE_DCMD;
> +       }

This is the right place to do this I suppose. Disabling CQE
selectively is something you might wanna do for debugging.
Acked-by: Linus Walleij <linus.walleij@linaro.org>

I see that some drivers are already parsing this DT property
on their own, should we follow up with patches so that these:

$ git grep 'supports-cqe'
drivers/mmc/host/sdhci-brcmstb.c:       if
(device_property_read_bool(&pdev->dev, "supports-cqe")) {
drivers/mmc/host/sdhci-msm.c:   if (of_property_read_bool(node, "supports-cqe"))
drivers/mmc/host/sdhci-tegra.c: if
(device_property_read_bool(host->mmc->parent, "supports-cqe"))

Make use of the central parsing instead?

Yours,
Linus Walleij
Chun-Hung Wu (巫駿宏) March 9, 2020, 11:21 p.m. UTC | #2
On Fri, 2020-02-21 at 15:33 +0100, Linus Walleij wrote:
> On Mon, Feb 17, 2020 at 7:32 AM Chun-Hung Wu <chun-hung.wu@mediatek.com> wrote:
> 
> > Expose MMC_CAP2_CQE and MMC_CAP2_CQE_DCMD
> > to host->caps2 if
> > 1. "supports-cqe" is defined in dt and
> > 2. "disable-cqe-dcmd" is not defined in dt.
> >
> > ---
> >  drivers/mmc/core/host.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> > index 105b7a7..efb0dbe 100644
> > --- a/drivers/mmc/core/host.c
> > +++ b/drivers/mmc/core/host.c
> > @@ -319,6 +319,14 @@ int mmc_of_parse(struct mmc_host *host)
> >                 host->caps2 |= MMC_CAP2_NO_SD;
> >         if (device_property_read_bool(dev, "no-mmc"))
> >                 host->caps2 |= MMC_CAP2_NO_MMC;
> > +       if (device_property_read_bool(dev, "supports-cqe"))
> > +               host->caps2 |= MMC_CAP2_CQE;
> 
> I don't understand why this is even a DT property as it should
> be clear from the hosts compatible whether it supports CQE or
> not. But it's too late to do anything about that I suppose, and
> I just assume there is something I don't understand here.
"supports-cqe" as my understanding is like HS400 HS200 is a host
capability.
> 
> > +       /* Must be after "supports-cqe" check */
> > +       if (!device_property_read_bool(dev, "disable-cqe-dcmd")) {
> > +               if (host->caps2 & MMC_CAP2_CQE)
> > +                       host->caps2 |= MMC_CAP2_CQE_DCMD;
> > +       }
> 
> This is the right place to do this I suppose. Disabling CQE
> selectively is something you might wanna do for debugging.
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> 
> I see that some drivers are already parsing this DT property
> on their own, should we follow up with patches so that these:
> 
> $ git grep 'supports-cqe'
> drivers/mmc/host/sdhci-brcmstb.c:       if
> (device_property_read_bool(&pdev->dev, "supports-cqe")) {
> drivers/mmc/host/sdhci-msm.c:   if (of_property_read_bool(node, "supports-cqe"))
> drivers/mmc/host/sdhci-tegra.c: if
> (device_property_read_bool(host->mmc->parent, "supports-cqe"))
> 
> Make use of the central parsing instead?
In v4, I will remove the vendor driver dt setting and use central
parsing instead.
> 
> Yours,
> Linus Walleij
diff mbox series

Patch

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 105b7a7..efb0dbe 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -319,6 +319,14 @@  int mmc_of_parse(struct mmc_host *host)
 		host->caps2 |= MMC_CAP2_NO_SD;
 	if (device_property_read_bool(dev, "no-mmc"))
 		host->caps2 |= MMC_CAP2_NO_MMC;
+	if (device_property_read_bool(dev, "supports-cqe"))
+		host->caps2 |= MMC_CAP2_CQE;
+
+	/* Must be after "supports-cqe" check */
+	if (!device_property_read_bool(dev, "disable-cqe-dcmd")) {
+		if (host->caps2 & MMC_CAP2_CQE)
+			host->caps2 |= MMC_CAP2_CQE_DCMD;
+	}
 
 	/* Must be after "non-removable" check */
 	if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) {