On Thu, Jun 10, 2021 at 7:52 AM Horia Geantă wrote: > > Documentation/core-api/dma-api.rst explicitly allows for partial syncs: > Synchronise a single contiguous or scatter/gather mapping for the CPU > and device. With the sync_sg API, all the parameters must be the same > as those passed into the single mapping API. With the sync_single API, > you can use dma_handle and size parameters that aren't identical to > those passed into the single mapping API to do a partial sync. > > AFAICS commit 16fc3cef33a0 ("swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single") > is breaking this functionality. How about a patch like the attached? Does that fix things for you. Christoph? Comments - that commit removed the offset calculation entirely, because the old (unsigned long)tlb_addr & (IO_TLB_SIZE - 1) was wrong, but instead of removing it, I think it should have just fixed it to be (tlb_addr - mem->start) & (IO_TLB_SIZE - 1); instead. That way the slot offset always matches the slot index calculation. I also made it then take the offset into account for the alloc_size checks. Does this UNTESTED patch perhaps do the right thing? Linus