From: Vadym Kochan <vadym.kochan@plvision.eu>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Hu Ziji <huziji@marvell.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
Elad Nachman <enachman@marvell.com>
Subject: Re: [PATCH] mmc: sdhci-xenon: Fix 2G limitation on AC5 SoC
Date: Mon, 1 Aug 2022 12:30:44 +0300 [thread overview]
Message-ID: <20220801093044.GA22721@plvision.eu> (raw)
In-Reply-To: <20220727164532.GA19351@plvision.eu>
Hi Florian,
On Wed, Jul 27, 2022 at 07:45:32PM +0300, Vadym Kochan wrote:
> Hi Florian,
>
> On Tue, Jul 26, 2022 at 10:37:46AM -0700, Florian Fainelli wrote:
> > On 7/26/22 10:07, Vadym Kochan wrote:
> > > From: Elad Nachman <enachman@marvell.com>
> > >
> > > There is a limitation on AC5 SoC that mmc controller
> > > can't have DMA access over 2G memory.
> > >
> > > Signed-off-by: Elad Nachman <enachman@marvell.com>
> > > Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
> > > ---
> > > drivers/mmc/host/sdhci-xenon.c | 13 +++++++++++++
> > > 1 file changed, 13 insertions(+)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
> > > index 08e838400b52..666d06b58564 100644
> > > --- a/drivers/mmc/host/sdhci-xenon.c
> > > +++ b/drivers/mmc/host/sdhci-xenon.c
> > > @@ -18,6 +18,7 @@
> > > #include <linux/of.h>
> > > #include <linux/pm.h>
> > > #include <linux/pm_runtime.h>
> > > +#include <linux/mm.h>
> > >
> > > #include "sdhci-pltfm.h"
> > > #include "sdhci-xenon.h"
> > > @@ -422,6 +423,8 @@ static int xenon_probe_params(struct platform_device *pdev)
> > > struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
> > > u32 sdhc_id, nr_sdhc;
> > > u32 tuning_count;
> > > + struct device_node *np = pdev->dev.of_node;
> > > + struct sysinfo si;
> > >
> > > /* Disable HS200 on Armada AP806 */
> > > if (priv->hw_version == XENON_AP806)
> > > @@ -450,6 +453,15 @@ static int xenon_probe_params(struct platform_device *pdev)
> > > }
> > > priv->tuning_count = tuning_count;
> > >
> > > + si_meminfo(&si);
> > > +
> > > + if (of_device_is_compatible(np, "marvell,ac5-sdhci") &&
> > > + ((si.totalram * si.mem_unit) > 0x80000000 /*2G*/)) {
> >
> > Why not limit the DMA mask of the device and ensure, that bounce buffers get used so you can still do DMA?
> >
> > Also, you ought to be able to describe that limitation using Device Tree (assuming this is an option) and declaring a dedicated bus node for the SDHCI controller and providing a suitable dma-ranges property, see: arch/arm/boot/dts/bcm2711.dtsi and the 'soc' node for such examples.
> >
> >
>
I could use DMA only in 2 ways:
#1 Use sdhci bounce buffer with SDMA mode
But there was the issue that SDMA requires that SDHCI v4 mode should
be enabled, and when I enable it via sdhci_enable_v4_mode(host)
then I got error that EXT_CSD can't be recognized.
But if I comment this line in sdhci.c:
int sdhci_setup_host(struct sdhci_host *host)
{
...
/* SDMA does not support 64-bit DMA if v4 mode not set */
if ((host->flags & SDHCI_USE_64_BIT_DMA) && !host->v4_mode) {
pr_info("XXX SDMA does not support 64-bit DMA if v4 mode not set\n");
host->flags &= ~SDHCI_USE_SDMA;
}
...
}
then everything is OK.
#2 Use restricted-dma-pool in device-tree
But I am not sure if it is good solution compared to #1.
Setting only DMA mask did not help because after some time I got
"DMA overflow address" error stack-traces.
> Do I understand correctly that the swiotlb will be used in case DMA
> engine could not map the page in the specified range (limited by dma-ranges or
> dma-mask) ?
>
> >
> > > + host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
> > > + host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
> > > + dev_info(mmc_dev(mmc), "Disabling DMA because of 2GB DMA access limit.\n");
> > > + }
> > > +
> > > return xenon_phy_parse_params(dev, host);
> > > }
> > >
> > > @@ -682,6 +694,7 @@ static const struct of_device_id sdhci_xenon_dt_ids[] = {
> > > { .compatible = "marvell,armada-ap807-sdhci", .data = (void *)XENON_AP807},
> > > { .compatible = "marvell,armada-cp110-sdhci", .data = (void *)XENON_CP110},
> > > { .compatible = "marvell,armada-3700-sdhci", .data = (void *)XENON_A3700},
> > > + { .compatible = "marvell,ac5-sdhci", .data = (void *)XENON_AP806},
> > > {}
> > > };
> > > MODULE_DEVICE_TABLE(of, sdhci_xenon_dt_ids);
> >
> >
> > --
> > Florian
>
> Thanks,
>
Regards,
next prev parent reply other threads:[~2022-08-01 9:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 17:07 [PATCH] mmc: sdhci-xenon: Fix 2G limitation on AC5 SoC Vadym Kochan
2022-07-26 17:37 ` Florian Fainelli
2022-07-27 16:45 ` Vadym Kochan
2022-08-01 9:30 ` Vadym Kochan [this message]
2022-08-08 9:19 ` Adrian Hunter
2022-08-08 9:52 ` Vadym Kochan
2022-08-08 10:29 ` Vadym Kochan
2022-08-08 11:40 ` Adrian Hunter
2022-08-08 12:26 ` Vadym Kochan
2022-08-08 12:58 ` Adrian Hunter
2022-08-08 14:06 ` Robin Murphy
2022-08-16 20:51 ` Vadym Kochan
2022-08-17 13:43 ` Robin Murphy
2022-08-17 16:07 ` Vadym Kochan
2022-08-17 17:23 ` Robin Murphy
2022-08-18 12:07 ` Vadym Kochan
2022-08-21 6:17 ` Christoph Hellwig
2022-08-22 10:06 ` Robin Murphy
2022-09-06 9:22 ` Vadym Kochan
2022-10-13 6:40 ` Vadym Kochan
2022-11-08 19:05 ` Vadym Kochan
2022-11-09 7:50 ` Adrian Hunter
2022-11-09 8:40 ` Vadym Kochan
2022-11-09 9:29 ` Adrian Hunter
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=20220801093044.GA22721@plvision.eu \
--to=vadym.kochan@plvision.eu \
--cc=adrian.hunter@intel.com \
--cc=enachman@marvell.com \
--cc=f.fainelli@gmail.com \
--cc=huziji@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.