From: Adrian Hunter <adrian.hunter@intel.com>
To: Elad Nachman <enachman@marvell.com>,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
conor+dt@kernel.org, andrew@lunn.ch, gregory.clement@bootlin.com,
sebastian.hesselbarth@gmail.com, huziji@marvell.com,
ulf.hansson@linaro.org, catalin.marinas@arm.com, will@kernel.org,
thunder.leizhen@huawei.com, bhe@redhat.com,
akpm@linux-foundation.org, yajun.deng@linux.dev,
chris.zjh@huawei.com, linux-mmc@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: cyuval@marvell.com
Subject: Re: [PATCH 4/4] mmc: xenon: Add ac5 support via bounce buffer
Date: Thu, 4 Jan 2024 12:50:34 +0200 [thread overview]
Message-ID: <d3208fee-9784-4dee-994d-ac1f7c526e74@intel.com> (raw)
In-Reply-To: <20231227123257.1170590-5-enachman@marvell.com>
On 27/12/23 14:32, Elad Nachman wrote:
> From: Elad Nachman <enachman@marvell.com>
>
> AC5/X/IM SOCs has a variant of the Xenon eMMC controller,
> in which only 31-bit of addressing pass from the controller
> on the AXI bus.
> Since we cannot guarantee that only buffers from the first 2GB
> of memory will reach the driver, the driver is configured for
> SDMA mode, without 64-bit mode, overriding the DMA mask to 34-bit
> to support the DDR memory mapping, which starts at offset 8GB.
>
> Signed-off-by: Elad Nachman <enachman@marvell.com>
One minor comment below otherwise:
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> drivers/mmc/host/sdhci-xenon.c | 33 ++++++++++++++++++++++++++++++++-
> drivers/mmc/host/sdhci-xenon.h | 3 ++-
> 2 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
> index 25ba7aecc3be..4d6df1815da1 100644
> --- a/drivers/mmc/host/sdhci-xenon.c
> +++ b/drivers/mmc/host/sdhci-xenon.c
> @@ -18,6 +18,8 @@
> #include <linux/of.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> +#include <linux/mm.h>
> +#include <linux/dma-mapping.h>
>
> #include "sdhci-pltfm.h"
> #include "sdhci-xenon.h"
> @@ -422,6 +424,7 @@ 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 sysinfo si;
>
> /* Disable HS200 on Armada AP806 */
> if (priv->hw_version == XENON_AP806)
> @@ -450,6 +453,23 @@ static int xenon_probe_params(struct platform_device *pdev)
> }
> priv->tuning_count = tuning_count;
>
> + /*
> + * AC5/X/IM HW has only 31-bits passed in the crossbar switch.
> + * If we have more than 2GB of memory, this means we might pass
> + * memory pointers which are above 2GB and which cannot be properly
> + * represented. In this case, disable ADMA, 64-bit DMA and allow only SDMA.
> + * This effectively will enable bounce buffer quirk in the
> + * generic SDHCI driver, which will make sure DMA is only done
> + * from supported memory regions:
> + */
> + if (priv->hw_version == XENON_AC5) {
> + si_meminfo(&si);
> + if (si.totalram * si.mem_unit > SZ_2G) {
> + host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
> + host->quirks2 |= SDHCI_QUIRK2_BROKEN_64_BIT_DMA;
> + }
> + }
> +
> return xenon_phy_parse_params(dev, host);
> }
>
> @@ -562,7 +582,17 @@ static int xenon_probe(struct platform_device *pdev)
> goto remove_sdhc;
>
> pm_runtime_put_autosuspend(&pdev->dev);
> -
> + /*
> + * If we previously detected AC5 with over 2GB of memory,
> + * then we disable ADMA and 64-bit DMA.
> + * This means generic SDHCI driver has set the DMA mask to
> + * 32-bit. Since DDR starts at 0x2_0000_0000, we must use
> + * 34-bit DMA mask to access this DDR memory:
> + */
> + if (priv->hw_version == XENON_AC5) {
> + if (host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA)
Kernel style is to avoid nested if-statements i.e.
if (priv->hw_version == XENON_AC5 &&
host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA)
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
> + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
> + }
> return 0;
>
> remove_sdhc:
> @@ -680,6 +710,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_AC5},
> {}
> };
> MODULE_DEVICE_TABLE(of, sdhci_xenon_dt_ids);
> diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h
> index 3e9c6c908a79..0460d97aad26 100644
> --- a/drivers/mmc/host/sdhci-xenon.h
> +++ b/drivers/mmc/host/sdhci-xenon.h
> @@ -57,7 +57,8 @@ enum xenon_variant {
> XENON_A3700,
> XENON_AP806,
> XENON_AP807,
> - XENON_CP110
> + XENON_CP110,
> + XENON_AC5
> };
>
> struct xenon_priv {
next prev parent reply other threads:[~2024-01-04 10:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-27 12:32 [PATCH 0/4] mmc: xenon: add AC5 support Elad Nachman
2023-12-27 12:32 ` [PATCH 1/4] arm64: mm: Fix SOCs with DDR starting above zero Elad Nachman
2023-12-27 12:32 ` [PATCH 2/4] dt-bindings: mmc: add Marvell ac5 Elad Nachman
2023-12-27 12:38 ` Krzysztof Kozlowski
2023-12-27 12:41 ` Krzysztof Kozlowski
2023-12-27 12:32 ` [PATCH 3/4] arm64: dts: ac5: add mmc node and clock Elad Nachman
2023-12-27 12:40 ` Krzysztof Kozlowski
2023-12-27 12:32 ` [PATCH 4/4] mmc: xenon: Add ac5 support via bounce buffer Elad Nachman
2024-01-04 10:50 ` Adrian Hunter [this message]
2023-12-29 21:56 ` [PATCH 0/4] mmc: xenon: add AC5 support Andrew Lunn
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=d3208fee-9784-4dee-994d-ac1f7c526e74@intel.com \
--to=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andrew@lunn.ch \
--cc=bhe@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=chris.zjh@huawei.com \
--cc=conor+dt@kernel.org \
--cc=cyuval@marvell.com \
--cc=devicetree@vger.kernel.org \
--cc=enachman@marvell.com \
--cc=gregory.clement@bootlin.com \
--cc=huziji@marvell.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=thunder.leizhen@huawei.com \
--cc=ulf.hansson@linaro.org \
--cc=will@kernel.org \
--cc=yajun.deng@linux.dev \
/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).