On 6/13/2024 3:40 PM, Johannes Berg wrote: > On Thu, 2024-06-13 at 15:10 +0800, Baochen Qiang wrote: >> >> On 6/13/2024 3:15 AM, Fabio Estevam wrote: >>> Hi Johannes, >>> >>> On Wed, Jun 12, 2024 at 4:10 PM Johannes Berg <johannes@xxxxxxxxxxxxxxxx> wrote: >>> >>>> Strange. Is there an IOMMU involved on this platform? >>> >>> IOMMU isn't available on i.MX8M as far as I know. >> If IOMMU not present, likely the buffer is mapped by SWIOTLB. > > Why? The device can do 64-bit DMA, so should be able to just access any > page in the system. Even older devices can do 36-bit DMA, but this is a > newer one. And if IOMMU isn't present, you have no protection anyway. Then no idea :( > >> The iova 4215433216, aka 0xFB426800, is 2K aligned, which also supports such guessing. See definition of IO_TLB_SIZE. > > Not sure that means anything though, I really would have expected a 4k > buffer to be 4k aligned - why would you even want to map it across two > pages? IMO SWIOTLB manages buffers in a unit of IO_TLB_SIZE, it does not care about whether or not we are crossing page boundaries, no? > > If it is SWIOTLB, shouldn't we get into this condition? > > /* > * Historically, swiotlb allocations >= PAGE_SIZE were guaranteed to be > * page-aligned in the absence of any other alignment requirements. > * 'alloc_align_mask' was later introduced to specify the alignment > * explicitly, however this is passed as zero for streaming mappings > * and so we preserve the old behaviour there in case any drivers are > * relying on it. > */ > if (!alloc_align_mask && !iotlb_align_mask && alloc_size >= PAGE_SIZE) > alloc_align_mask = PAGE_SIZE - 1; > This is not present in 6.6.32 stable kernel. > > Otherwise, not sure though how we could possibly fix this in the driver, > we really shouldn't do dma_set_min_align_mask() since on the TX side we > really have no alignment requirements, and swiotlb_map() uses 0 as > alignment. > > johannes