Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs

From: Christoph Hellwig
Date: Tue Nov 20 2018 - 04:23:00 EST


On Mon, Nov 19, 2018 at 07:36:44PM +0000, Robin Murphy wrote:
> OK, having brought my Hikey to life and reproduced John's stall with rc1,
> what's going on is that at some point dma_map_sg() returns 0, which causes
> the SCSI/UFS layer to go round in circles repeatedly trying to map the same
> list(s) equally unsuccessfully.
>
> Why does dma_map_sg() fail? Turns out what we all managed to overlook is
> that this patch *does* introduce a subtle change in behaviour, in that
> previously the non-bounced case assigned dev_addr to sg->dma_address
> without looking at it; now with the swiotlb_map_page() call we check the
> return value against DIRECT_MAPPING_ERROR regardless of whether it was
> bounced or not.
>
> Flash back to the other thread when I said "...but I suspect there may well
> be non-IOMMU platforms where DMA to physical address 0 is a thing :("? I
> have the 3GB Hikey where all the RAM is below 32 bits so SWIOTLB never ever
> bounces, but sure enough, guess where that RAM starts...

What is PAGE_OFFSET on that machine? We usually don't use kernel
virtual address 0 so that we can deal with 0 pointer derferences sanely,
but I guess we can get to physical address 0.

I guess the quick fix would be to move DMA_DIRECT_MAPPING_ERROR to all-F
ASAP..