public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* DMA mapping fill dma_address to 0
@ 2021-04-28  8:42 Corentin Labbe
  2021-04-28 10:06 ` Robin Murphy
  0 siblings, 1 reply; 3+ messages in thread
From: Corentin Labbe @ 2021-04-28  8:42 UTC (permalink / raw)
  To: hch, m.szyprowski, robin.murphy, iommu; +Cc: linux-kernel

Hello

I work on the crypto offloader driver of cortina/gemini SL3516 SoC.
I test it by filling a LUKS2 partition.
I got a reproductible problem when handling skcipher requests.
I use dma_map_sg() and when iterating other the result, sg_dma_address(sg) return 0.
But sg_dma_len(sg) is still correct (4096 in my case).

Below is a simplified view of my code:
nr_sgs = dma_map_sg(ce->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE);
(nr_sgs = 1 in my case)
sg = areq->src;
if (!sg_dma_address(sg))
	FAIL

I have digged to find what do dma_map_sg() and I have added some debug.
sg_page(sg) return c7efb000 for example so sg_page() works.
But it seems the problem is that page_to_phys(sg_page(sg)) return 0.

This problem does not appear immediatly, luksOpen and subsequent fsck always work.
But it appears fast after, when mouting or rsync files in it.

I have added CONFIG_DEBUG_SG, CONFIG_DMA_API_DEBUG, CONFIG_DMA_API_DEBUG_SG but they didnt bringed any more hints.
Only "DMA-API: cacheline tracking ENOMEM, dma-debug disabled" appears but always with some "time" between my problem and its display.
So I am not sure it is related.

Regards

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

* Re: DMA mapping fill dma_address to 0
  2021-04-28  8:42 DMA mapping fill dma_address to 0 Corentin Labbe
@ 2021-04-28 10:06 ` Robin Murphy
  2021-04-28 10:25   ` Corentin Labbe
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Murphy @ 2021-04-28 10:06 UTC (permalink / raw)
  To: Corentin Labbe, hch, m.szyprowski, iommu; +Cc: linux-kernel

On 2021-04-28 09:42, Corentin Labbe wrote:
> Hello
> 
> I work on the crypto offloader driver of cortina/gemini SL3516 SoC.
> I test it by filling a LUKS2 partition.
> I got a reproductible problem when handling skcipher requests.
> I use dma_map_sg() and when iterating other the result, sg_dma_address(sg) return 0.
> But sg_dma_len(sg) is still correct (4096 in my case).
> 
> Below is a simplified view of my code:
> nr_sgs = dma_map_sg(ce->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE);
> (nr_sgs = 1 in my case)
> sg = areq->src;
> if (!sg_dma_address(sg))
> 	FAIL

What is this check supposed to be for in the first place? 0 is a valid 
DMA address, because it's also a valid physical address, and I recall 
RAM at PA 0 on Hikey 960 flushing out some bugs in the past when we 
tried to use 0 for DMA_MAPPING_ERROR. All the Gemini DTs appear to show 
RAM starting at PA 0 too, so I'd have to guess that it's simply the case 
that your DMA buffer happened to end up using that particular page.

Robin.

> I have digged to find what do dma_map_sg() and I have added some debug.
> sg_page(sg) return c7efb000 for example so sg_page() works.
> But it seems the problem is that page_to_phys(sg_page(sg)) return 0.
> 
> This problem does not appear immediatly, luksOpen and subsequent fsck always work.
> But it appears fast after, when mouting or rsync files in it.
> 
> I have added CONFIG_DEBUG_SG, CONFIG_DMA_API_DEBUG, CONFIG_DMA_API_DEBUG_SG but they didnt bringed any more hints.
> Only "DMA-API: cacheline tracking ENOMEM, dma-debug disabled" appears but always with some "time" between my problem and its display.
> So I am not sure it is related.
> 
> Regards
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 

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

* Re: DMA mapping fill dma_address to 0
  2021-04-28 10:06 ` Robin Murphy
@ 2021-04-28 10:25   ` Corentin Labbe
  0 siblings, 0 replies; 3+ messages in thread
From: Corentin Labbe @ 2021-04-28 10:25 UTC (permalink / raw)
  To: Robin Murphy; +Cc: hch, m.szyprowski, iommu, linux-kernel

Le Wed, Apr 28, 2021 at 11:06:10AM +0100, Robin Murphy a écrit :
> On 2021-04-28 09:42, Corentin Labbe wrote:
> > Hello
> > 
> > I work on the crypto offloader driver of cortina/gemini SL3516 SoC.
> > I test it by filling a LUKS2 partition.
> > I got a reproductible problem when handling skcipher requests.
> > I use dma_map_sg() and when iterating other the result, sg_dma_address(sg) return 0.
> > But sg_dma_len(sg) is still correct (4096 in my case).
> > 
> > Below is a simplified view of my code:
> > nr_sgs = dma_map_sg(ce->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE);
> > (nr_sgs = 1 in my case)
> > sg = areq->src;
> > if (!sg_dma_address(sg))
> > 	FAIL
> 
> What is this check supposed to be for in the first place? 0 is a valid 
> DMA address, because it's also a valid physical address, and I recall 
> RAM at PA 0 on Hikey 960 flushing out some bugs in the past when we 
> tried to use 0 for DMA_MAPPING_ERROR. All the Gemini DTs appear to show 
> RAM starting at PA 0 too, so I'd have to guess that it's simply the case 
> that your DMA buffer happened to end up using that particular page.
> 
> Robin.
> 

Yes, 0 is a valid DMA address.
I just find it by going further and printing mem_map value and testing it against sg_page() return.

So my original problem was not related to this.
Sorry for the noise.
Thanks

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

end of thread, other threads:[~2021-04-28 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-28  8:42 DMA mapping fill dma_address to 0 Corentin Labbe
2021-04-28 10:06 ` Robin Murphy
2021-04-28 10:25   ` Corentin Labbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox