devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Jun Nie <jun.nie@linaro.org>
Cc: "ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 4/4] mmc: sdhci: Add DMA memory boundary workaround
Date: Tue, 3 Dec 2019 02:47:13 +0000	[thread overview]
Message-ID: <20191203103320.273a7309@xhacker.debian> (raw)
In-Reply-To: <20191202144104.5069-5-jun.nie@linaro.org>

On Mon,  2 Dec 2019 22:41:04 +0800 Jun Nie wrote:


> 
> 
> DMA memory cannot cross specific boundary for some SDHCI controller,
> such as DesignWare SDHCI controller. Add DMA memory boundary dt
> property and workaround the limitation.

IMHO, the workaround could be implemented in each SDHCI host driver.

eg. drivers/mmc/host/sdhci-of-dwcmshc.c

thanks

> 
> Signed-off-by: Jun Nie <jun.nie@linaro.org>
> ---
>  drivers/mmc/host/sdhci.c | 20 +++++++++++++++++++-
>  drivers/mmc/host/sdhci.h |  1 +
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index d8a6c1c91448..56c53fbadd9d 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -763,9 +763,25 @@ static void sdhci_adma_table_pre(struct sdhci_host *host,
>                 BUG_ON(len > 65536);
> 
>                 /* tran, valid */
> -               if (len)
> +               if (len) {
> +                       unsigned int boundary = host->dma_mem_boundary;
> +                       /*
> +                        * work around for buffer across mem boundary, split
> +                        * the buffer.
> +                        */
> +                       if (boundary &&
> +                           ((addr & (boundary - 1)) + len) > boundary) {
> +                               offset = boundary - (addr & (boundary - 1));
> +                               __sdhci_adma_write_desc(host, &desc,
> +                                                       addr, offset,
> +                                                       ADMA2_TRAN_VALID);
> +                               addr += offset;
> +                               len -= offset;
> +                       }
> +
>                         __sdhci_adma_write_desc(host, &desc, addr, len,
>                                                 ADMA2_TRAN_VALID);
> +               }
> 
>                 /*
>                  * If this triggers then we have a calculation bug
> @@ -3634,6 +3650,8 @@ void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
>                              "sdhci-caps-mask", &dt_caps_mask);
>         of_property_read_u64(mmc_dev(host->mmc)->of_node,
>                              "sdhci-caps", &dt_caps);
> +       of_property_read_u32(mmc_dev(host->mmc)->of_node,
> +                            "sdhci-dma-mem-boundary", &host->dma_mem_boundary);
> 
>         if (of_property_read_u32(mmc_dev(host->mmc)->of_node,
>                                  "sdhci-ctrl-hs400", &host->sdhci_ctrl_hs400))
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index cac4d819f62c..954ac08c4fb0 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -608,6 +608,7 @@ struct sdhci_host {
> 
>         /* SDHCI_CTRL_HS400 value */
>         u32                     sdhci_ctrl_hs400;
> +       u32                     dma_mem_boundary;
> 
>         unsigned long private[0] ____cacheline_aligned;
>  };
> --
> 2.17.1
> 


  parent reply	other threads:[~2019-12-03  2:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 14:41 [PATCH 0/4] mmc: Add sdhci workaround stability enhencement Jun Nie
2019-12-02 14:41 ` [PATCH 1/4] mmc: sdhci: Add delay after power off Jun Nie
2019-12-03  7:26   ` Adrian Hunter
2019-12-02 14:41 ` [PATCH 2/4] mmc: sdhci: dt: Add DMA boundary and HS400 properties Jun Nie
2019-12-13 23:01   ` Rob Herring
2019-12-17 14:56     ` Jun Nie
2019-12-02 14:41 ` [PATCH 3/4] mmc: sdhci: Set ctrl_hs400 value in dts Jun Nie
2019-12-03  7:52   ` Adrian Hunter
2019-12-02 14:41 ` [PATCH 4/4] mmc: sdhci: Add DMA memory boundary workaround Jun Nie
2019-12-02 17:52   ` Christoph Hellwig
2019-12-03  3:29     ` Jun Nie
2019-12-03  7:36       ` Christoph Hellwig
2019-12-04  6:00         ` Jun Nie
2019-12-04  7:14           ` Jisheng Zhang
2019-12-10  9:36             ` Ulf Hansson
2019-12-03  2:47   ` Jisheng Zhang [this message]
2019-12-03  3:33     ` Jun Nie
2019-12-03  9:05       ` Jisheng Zhang
2019-12-03  9:18         ` Christoph Hellwig
2019-12-03  9:49           ` Jisheng Zhang
2019-12-03 13:06             ` Christoph Hellwig
2019-12-04  7:11               ` Jisheng Zhang
2019-12-03  9:49         ` Jisheng Zhang
2019-12-03 13:04           ` Christoph Hellwig

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=20191203103320.273a7309@xhacker.debian \
    --to=jisheng.zhang@synaptics.com \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jun.nie@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).