[PATCH v3 3/3] mmc: sdhci-of-dwcmshc: Add host software queue support

Ulf Hansson ulf.hansson at linaro.org
Tue Feb 14 03:31:13 PST 2023


On Thu, 2 Feb 2023 at 01:35, Shawn Lin <shawn.lin at rock-chips.com> wrote:
>

Please elaborate a bit to share some more information to the commit message.

Perhaps you have some performance numbers too, that would be nice to
share in the commit message.

> Signed-off-by: Shawn Lin <shawn.lin at rock-chips.com>
>
> ---
>
> Changes in v2:
> - fix Kconfig error
>
>  drivers/mmc/host/Kconfig            |  1 +
>  drivers/mmc/host/sdhci-of-dwcmshc.c | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index e96b302..e060bab 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -233,6 +233,7 @@ config MMC_SDHCI_OF_DWCMSHC
>         depends on MMC_SDHCI_PLTFM
>         depends on OF
>         depends on COMMON_CLK
> +       select MMC_HSQ
>         help
>           This selects Synopsys DesignWare Cores Mobile Storage Controller
>           support.
> diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
> index fc917ed..e90fa69 100644
> --- a/drivers/mmc/host/sdhci-of-dwcmshc.c
> +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
> @@ -20,6 +20,7 @@
>  #include <linux/sizes.h>
>
>  #include "sdhci-pltfm.h"
> +#include "mmc_hsq.h"
>
>  #define SDHCI_DWCMSHC_ARG2_STUFF       GENMASK(31, 16)
>
> @@ -331,6 +332,14 @@ static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask)
>         sdhci_reset(host, mask);
>  }
>
> +static void sdhci_dwcmshc_request_done(struct sdhci_host *host, struct mmc_request *mrq)
> +{
> +       if (mmc_hsq_finalize_request(host->mmc, mrq))
> +               return;
> +
> +       mmc_request_done(host->mmc, mrq);
> +}
> +
>  static const struct sdhci_ops sdhci_dwcmshc_ops = {
>         .set_clock              = sdhci_set_clock,
>         .set_bus_width          = sdhci_set_bus_width,
> @@ -347,6 +356,7 @@ static const struct sdhci_ops sdhci_dwcmshc_rk35xx_ops = {
>         .get_max_clock          = sdhci_pltfm_clk_get_max_clock,
>         .reset                  = rk35xx_sdhci_reset,
>         .adma_write_desc        = dwcmshc_adma_write_desc,
> +       .request_done           = sdhci_dwcmshc_request_done,
>  };
>
>  static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = {
> @@ -462,6 +472,7 @@ static int dwcmshc_probe(struct platform_device *pdev)
>         struct dwcmshc_priv *priv;
>         struct rk35xx_priv *rk_priv = NULL;
>         const struct sdhci_pltfm_data *pltfm_data;
> +       struct mmc_hsq *hsq;
>         int err;
>         u32 extra;
>
> @@ -515,6 +526,16 @@ static int dwcmshc_probe(struct platform_device *pdev)
>         host->mmc_host_ops.request = dwcmshc_request;
>         host->mmc_host_ops.hs400_enhanced_strobe = dwcmshc_hs400_enhanced_strobe;
>
> +       hsq = devm_kzalloc(&pdev->dev, sizeof(*hsq), GFP_KERNEL);
> +       if (!hsq) {
> +               err = -ENOMEM;
> +               goto err_clk;
> +       }
> +
> +       err = mmc_hsq_init(hsq, host->mmc);
> +       if (err)
> +               goto err_clk;
> +
>         if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata) {
>                 rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk35xx_priv), GFP_KERNEL);
>                 if (!rk_priv) {
> @@ -607,6 +628,8 @@ static int dwcmshc_suspend(struct device *dev)
>         struct rk35xx_priv *rk_priv = priv->priv;
>         int ret;
>
> +       mmc_hsq_suspend(host->mmc);
> +
>         ret = sdhci_suspend_host(host);
>         if (ret)
>                 return ret;
> @@ -647,7 +670,11 @@ static int dwcmshc_resume(struct device *dev)
>                         return ret;
>         }
>
> -       return sdhci_resume_host(host);
> +       ret = sdhci_resume_host(host);
> +       if (ret)
> +               return ret;
> +
> +       return mmc_hsq_resume(host->mmc);
>  }
>  #endif

If I understand correctly, you need to also inform sdhci and the mmc
core, whether you support atomic request management or not. For
sdhci-sprd, the following part below, is done during ->probe() - and I
assume we need something similar for the sdhci-of-dwcmshc, right?

if (!mmc_card_is_removable(host->mmc))
    host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
else
    host->always_defer_done = true;

Kind regards
Uffe



More information about the Linux-rockchip mailing list