Re: [PATCH] swiotlb: ensure io_tlb_default_mem spinlock always initialised

From: Ben Dooks
Date: Mon Jul 11 2022 - 07:13:15 EST


On 11/07/2022 11:21, Christoph Hellwig wrote:
On Mon, Jul 11, 2022 at 11:07:17AM +0100, Robin Murphy wrote:
If none of your peripherals should need SWIOTLB, then the fact that
you're ending up in swiotlb_map() at all is a clear sign that
something's wrong. Most likely someone's forgotten to set their DMA
masks correctly.

Yes.

Possibly, we had at least one driver which attempted to set a 32 bit
DMA mask which had to be removed as the DMA layer accepts this but
since there is no DMA32 memory the allocator then just fails.

I expect the above may need to be a separate discussion(s) of how to
default the DMA mask and how to stop the implicit acceptance of setting
a 32-bit DMA mask.

However, by inspection it seems we do have a bug here as well, for which
the correct fix should be as below. The fireworks you're *supposed* to
get in that situation are considerably louder and more obvious than a
DEBUG_SPINLOCK complaint ;)

This looks sensible, I'll pick it up.