Re: [PATCH v6 4/6] swiotlb: Fix alignment checks when both allocation and DMA masks are present

From: Petr Tesařík
Date: Tue Mar 12 2024 - 06:44:19 EST


On Mon, 11 Mar 2024 17:52:31 -0700
Nicolin Chen <nicolinc@xxxxxxxxxx> wrote:

> On Mon, Mar 11, 2024 at 09:36:10PM +0000, Michael Kelley wrote:
> > From: Petr Tesařík <petr@xxxxxxxxxxx>
> > > I find it somewhat surprising that NVMe does not
> > > in fact require that the NVME_CTRL_PAGE_SHIFT low bits are preserved,
> > > as suggested by Nicolin's successful testing.
> > >
> > > Why is that?
> >
> > I saw only one stack trace from Nicolin, and it was file system buffer
> > flushing code that initiated the I/O. In such cases, it's very likely that the
> > original address is at least 4K aligned. Hence the offset is zero and
> > the low bits will typically be correct.
>
> Though I didn't dig any deeper here, I do see some unaligned
> original addresses passed in at the top level:
> fsck.ext4-286 [004] ..... 2.594190: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be750600
> fsck.ext4-286 [004] ..... 2.613032: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be780400
> fsck.ext4-286 [004] ..... 2.614096: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be7c0600
> fsck.ext4-286 [004] ..... 2.614103: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be7e0400
> mount-288 [005] ..... 2.615157: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be800400
> multipathd-405 [003] ..... 3.062878: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: bda40218
> multipathd-502 [002] ..... 3.231721: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: bd3107b8
> mount-525 [002] ..... 3.250281: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: bd340200
> multipathd-529 [004] ..... 3.259053: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be620478
> multipathd-571 [005] ..... 3.292893: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be900328
> multipathd-580 [005] ..... 3.318832: iommu_dma_map_page: calling swiotlb_tbl_map_single with phys: be9207c8

Thank you. Indeed, bit 11 of the physical address was zero in all the
above calls, and that's why it works.

Petr T