diff mbox series

[RESEND,2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API

Message ID b6c0c003d887bf7c272c493212f4f89d28097ad4.1583307441.git.baolin.wang7@gmail.com (mailing list archive)
State New, archived
Headers show
Series Introduce the request_atomic() for the host | expand

Commit Message

Baolin Wang March 4, 2020, 7:42 a.m. UTC
Implement the request_atomic() API for nonremovable cards, that means
we can submit next request in the irq hard handler context to reduce
latency.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

Comments

Ulf Hansson March 16, 2020, 11:47 a.m. UTC | #1
On Wed, 4 Mar 2020 at 08:42, Baolin Wang <baolin.wang7@gmail.com> wrote:
>
> Implement the request_atomic() API for nonremovable cards, that means
> we can submit next request in the irq hard handler context to reduce
> latency.
>
> Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
> ---
>  drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index 2ab42c5..bddf0f3 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
>         sdhci_request(mmc, mrq);
>  }
>
> +static void sdhci_sprd_request_atomic(struct mmc_host *mmc,
> +                                     struct mmc_request *mrq)
> +{
> +       struct sdhci_host *host = mmc_priv(mmc);
> +       struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
> +
> +       host->flags |= sprd_host->flags & SDHCI_AUTO_CMD23;
> +
> +       /*
> +        * From version 4.10 onward, ARGUMENT2 register is also as 32-bit
> +        * block count register which doesn't support stuff bits of
> +        * CMD23 argument on Spreadtrum's sd host controller.
> +        */
> +       if (host->version >= SDHCI_SPEC_410 &&
> +           mrq->sbc && (mrq->sbc->arg & SDHCI_SPRD_ARG2_STUFF) &&
> +           (host->flags & SDHCI_AUTO_CMD23))
> +               host->flags &= ~SDHCI_AUTO_CMD23;

Looks like the above code is a copy of what is done in
sdhci_sprd_request(). Perhaps add a helper function that deals with
this to avoid open coding?

> +
> +       sdhci_request_atomic(mmc, mrq);
> +}
> +
>  static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>  {
>         struct sdhci_host *host = mmc_priv(mmc);
> @@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
>         if (ret)
>                 goto pltfm_free;
>
> +       if (!mmc_card_is_removable(host->mmc))
> +               host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
> +       else
> +               host->always_defer_done = true;
> +
>         sprd_host = TO_SPRD_HOST(host);
>         sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node);
>
> @@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
>         if (ret)
>                 goto err_cleanup_host;
>
> -       host->always_defer_done = true;
> -
>         ret = __sdhci_add_host(host);
>         if (ret)
>                 goto err_cleanup_host;
> --
> 1.9.1
>

Kind regards
Uffe
Baolin Wang March 17, 2020, 2:02 a.m. UTC | #2
On Mon, Mar 16, 2020 at 7:47 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Wed, 4 Mar 2020 at 08:42, Baolin Wang <baolin.wang7@gmail.com> wrote:
> >
> > Implement the request_atomic() API for nonremovable cards, that means
> > we can submit next request in the irq hard handler context to reduce
> > latency.
> >
> > Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
> > ---
> >  drivers/mmc/host/sdhci-sprd.c | 28 ++++++++++++++++++++++++++--
> >  1 file changed, 26 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> > index 2ab42c5..bddf0f3 100644
> > --- a/drivers/mmc/host/sdhci-sprd.c
> > +++ b/drivers/mmc/host/sdhci-sprd.c
> > @@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
> >         sdhci_request(mmc, mrq);
> >  }
> >
> > +static void sdhci_sprd_request_atomic(struct mmc_host *mmc,
> > +                                     struct mmc_request *mrq)
> > +{
> > +       struct sdhci_host *host = mmc_priv(mmc);
> > +       struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
> > +
> > +       host->flags |= sprd_host->flags & SDHCI_AUTO_CMD23;
> > +
> > +       /*
> > +        * From version 4.10 onward, ARGUMENT2 register is also as 32-bit
> > +        * block count register which doesn't support stuff bits of
> > +        * CMD23 argument on Spreadtrum's sd host controller.
> > +        */
> > +       if (host->version >= SDHCI_SPEC_410 &&
> > +           mrq->sbc && (mrq->sbc->arg & SDHCI_SPRD_ARG2_STUFF) &&
> > +           (host->flags & SDHCI_AUTO_CMD23))
> > +               host->flags &= ~SDHCI_AUTO_CMD23;
>
> Looks like the above code is a copy of what is done in
> sdhci_sprd_request(). Perhaps add a helper function that deals with
> this to avoid open coding?

Sure. Will do in next version. Thanks.

>
> > +
> > +       sdhci_request_atomic(mmc, mrq);
> > +}
> > +
> >  static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> >  {
> >         struct sdhci_host *host = mmc_priv(mmc);
> > @@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
> >         if (ret)
> >                 goto pltfm_free;
> >
> > +       if (!mmc_card_is_removable(host->mmc))
> > +               host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
> > +       else
> > +               host->always_defer_done = true;
> > +
> >         sprd_host = TO_SPRD_HOST(host);
> >         sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node);
> >
> > @@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
> >         if (ret)
> >                 goto err_cleanup_host;
> >
> > -       host->always_defer_done = true;
> > -
> >         ret = __sdhci_add_host(host);
> >         if (ret)
> >                 goto err_cleanup_host;
> > --
> > 1.9.1
> >
>
> Kind regards
> Uffe
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 2ab42c5..bddf0f3 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -426,6 +426,27 @@  static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	sdhci_request(mmc, mrq);
 }
 
+static void sdhci_sprd_request_atomic(struct mmc_host *mmc,
+				      struct mmc_request *mrq)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
+
+	host->flags |= sprd_host->flags & SDHCI_AUTO_CMD23;
+
+	/*
+	 * From version 4.10 onward, ARGUMENT2 register is also as 32-bit
+	 * block count register which doesn't support stuff bits of
+	 * CMD23 argument on Spreadtrum's sd host controller.
+	 */
+	if (host->version >= SDHCI_SPEC_410 &&
+	    mrq->sbc && (mrq->sbc->arg & SDHCI_SPRD_ARG2_STUFF) &&
+	    (host->flags & SDHCI_AUTO_CMD23))
+		host->flags &= ~SDHCI_AUTO_CMD23;
+
+	sdhci_request_atomic(mmc, mrq);
+}
+
 static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
@@ -561,6 +582,11 @@  static int sdhci_sprd_probe(struct platform_device *pdev)
 	if (ret)
 		goto pltfm_free;
 
+	if (!mmc_card_is_removable(host->mmc))
+		host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
+	else
+		host->always_defer_done = true;
+
 	sprd_host = TO_SPRD_HOST(host);
 	sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node);
 
@@ -654,8 +680,6 @@  static int sdhci_sprd_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cleanup_host;
 
-	host->always_defer_done = true;
-
 	ret = __sdhci_add_host(host);
 	if (ret)
 		goto err_cleanup_host;