All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size
@ 2018-09-13 14:47 Wolfram Sang
  2018-09-17 18:35 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2018-09-13 14:47 UTC (permalink / raw)
  To: linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund, Geert Uytterhoeven,
	Niklas Söderlund, Wolfram Sang, Geert Uytterhoeven

From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Fix warning when running with CONFIG_DMA_API_DEBUG_SG=y by allocating a
device_dma_parameters structure and filling in the max segment size. The
size used is the result of a discussion with Renesas hardware engineers
and unfortunately not found in the datasheet.

  renesas_sdhi_internal_dmac ee140000.sd: DMA-API: mapping sg segment
  longer than device claims to support [len=126976] [max=65536]

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
[wsa: simplified some logic after validating intended dma_parms life cycle
      and added comment]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

After discussing with DMA maintainers [1], this really seems the intended way
of using dma_parms. Took Niklas patch V2 and simplified the logic a bit more
given the information from above (but I'll still tackle the dangling pointer
issue in the DMA core seperately).

[1] https://www.spinics.net/lists/iommu/msg29861.html

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index ca0b43973769..e0823acaa3c2 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -309,12 +309,20 @@ static const struct soc_device_attribute gen3_soc_whitelist[] = {
 static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
 {
 	const struct soc_device_attribute *soc = soc_device_match(gen3_soc_whitelist);
+	struct device *dev = &pdev->dev;
 
 	if (!soc)
 		return -ENODEV;
 
 	global_flags |= (unsigned long)soc->data;
 
+	dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
+	if (!dev->dma_parms)
+		return -ENOMEM;
+
+	/* value is max of SD_SECCNT. Confirmed by HW engineers */
+	dma_set_max_seg_size(dev, 0xffffffff);
+
 	return renesas_sdhi_probe(pdev, &renesas_sdhi_internal_dmac_dma_ops);
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size
  2018-09-13 14:47 [PATCH v3] mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size Wolfram Sang
@ 2018-09-17 18:35 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2018-09-17 18:35 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-mmc, Linux-Renesas, Niklas Söderlund,
	Geert Uytterhoeven, Niklas Söderlund, Geert Uytterhoeven

On 13 September 2018 at 16:47, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> Fix warning when running with CONFIG_DMA_API_DEBUG_SG=y by allocating a
> device_dma_parameters structure and filling in the max segment size. The
> size used is the result of a discussion with Renesas hardware engineers
> and unfortunately not found in the datasheet.
>
>   renesas_sdhi_internal_dmac ee140000.sd: DMA-API: mapping sg segment
>   longer than device claims to support [len=126976] [max=65536]
>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> [wsa: simplified some logic after validating intended dma_parms life cycle
>       and added comment]
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied for next, thanks!

Kind regards
Uffe

> ---
>
> After discussing with DMA maintainers [1], this really seems the intended way
> of using dma_parms. Took Niklas patch V2 and simplified the logic a bit more
> given the information from above (but I'll still tackle the dangling pointer
> issue in the DMA core seperately).
>
> [1] https://www.spinics.net/lists/iommu/msg29861.html
>
>  drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
> index ca0b43973769..e0823acaa3c2 100644
> --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
> +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
> @@ -309,12 +309,20 @@ static const struct soc_device_attribute gen3_soc_whitelist[] = {
>  static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
>  {
>         const struct soc_device_attribute *soc = soc_device_match(gen3_soc_whitelist);
> +       struct device *dev = &pdev->dev;
>
>         if (!soc)
>                 return -ENODEV;
>
>         global_flags |= (unsigned long)soc->data;
>
> +       dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
> +       if (!dev->dma_parms)
> +               return -ENOMEM;
> +
> +       /* value is max of SD_SECCNT. Confirmed by HW engineers */
> +       dma_set_max_seg_size(dev, 0xffffffff);
> +
>         return renesas_sdhi_probe(pdev, &renesas_sdhi_internal_dmac_dma_ops);
>  }
>
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-18  0:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13 14:47 [PATCH v3] mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size Wolfram Sang
2018-09-17 18:35 ` Ulf Hansson

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.