Hi Joel, On Tue, Dec 07, 2021 at 02:46:03AM +0000, Joel Stanley wrote: > On Tue, 7 Dec 2021 at 01:23, Gabriel L. Somlo <gsomlo@xxxxxxxxx> wrote: > > > > [...] > > > > + > > > > + ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); > > > > > > Is this going to be true on all platforms? How do we handle those > > > where it's not true? > > > > I'll need to do a bit of digging here, unless anyone has ideas ready > > to go... > > I'm not an expert either, so let's consult the docs: > > Documentation/core-api/dma-api-howto.rst > > This suggests we should be using dma_set_mask_and_coherent? > > But we're setting the mask to 32, which is the default, so perhaps we > don't need this call at all? > > (I was thinking of the microwatt soc, which is a 64 bit soc but the > peripherals are on a 32 bit bus, and some of the devices are behind a > smaller bus again. But I think we're ok, as the DMA wishbone is > 32-bit). So I did a bit of digging, and as it turns out the LiteX DMA base registers are 64-bit wide, which I think means that they can essentially do `xlen` bits of DMA addressing, at least when used as part of a LiteX SoC (no idea what additional quirks occur if/when LiteSDCard, or any other 64-bit-DMA-capable LiteX IP block would be used as a standalone component in a different system). Does this mean that, depending on maybe CONFIG_ARCH_DMA_ADDR_T_64BIT or something similar, we should actually set DMA_BIT_MASK(64)? Maybe something like: #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (ret) goto err; #endif Leave it to the default 32 unless we're on a 64-bit-DMA capable system, in which case it's safe to assume we need the above setting? What do you think, does that make sense? Thanks, --Gabriel