mbox series

[v2,5.10,0/9] preserve DMA offsets when using swiotlb

Message ID 20210429173315.1252465-1-jxgao@google.com
Headers show
Series preserve DMA offsets when using swiotlb | expand

Message

Jianxiong Gao April 29, 2021, 5:33 p.m. UTC
We observed several NVMe failures when running with SWIOTLB. The root
cause of the issue is that when data is mapped via SWIOTLB, the address
offset is not preserved. Several device drivers including the NVMe
driver relies on this offset to function correctly.

Even though we discovered the error when running using AMD SEV, we have
reproduced the same error in Rhel 8 without SEV. By adding swiotlb=force
option to the boot command line parameter, NVMe funcionality is
impacted. For example formatting a disk into xfs format returns an
error.


----
Changes in v2:
Rebased patches to 5.10.33
Updated patch description to correct format.

Jianxiong Gao (9):
  driver core: add a min_align_mask field to struct
    device_dma_parameters
  swiotlb: add a IO_TLB_SIZE define
  swiotlb: factor out an io_tlb_offset helper
  swiotlb: factor out a nr_slots helper
  swiotlb: clean up swiotlb_tbl_unmap_single
  swiotlb: refactor swiotlb_tbl_map_single
  swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single
  swiotlb: respect min_align_mask
  nvme-pci: set min_align_mask

 drivers/nvme/host/pci.c     |   1 +
 include/linux/device.h      |   1 +
 include/linux/dma-mapping.h |  16 +++
 include/linux/swiotlb.h     |   1 +
 kernel/dma/swiotlb.c        | 259 ++++++++++++++++++++----------------
 5 files changed, 164 insertions(+), 114 deletions(-)

Comments

Marc Orr May 4, 2021, 8:22 p.m. UTC | #1
On Thu, Apr 29, 2021 at 10:34 AM Jianxiong Gao <jxgao@google.com> wrote:
>

> We observed several NVMe failures when running with SWIOTLB. The root

> cause of the issue is that when data is mapped via SWIOTLB, the address

> offset is not preserved. Several device drivers including the NVMe

> driver relies on this offset to function correctly.

>

> Even though we discovered the error when running using AMD SEV, we have

> reproduced the same error in Rhel 8 without SEV. By adding swiotlb=force

> option to the boot command line parameter, NVMe funcionality is

> impacted. For example formatting a disk into xfs format returns an

> error.


Christoph, are you OK with backporting this patch set to LTS, based on
the rationale in the cover letter above?
Thanks,
Marc
Christoph Hellwig May 5, 2021, 5:08 a.m. UTC | #2
On Tue, May 04, 2021 at 01:22:14PM -0700, Marc Orr wrote:
> Christoph, are you OK with backporting this patch set to LTS, based on

> the rationale in the cover letter above?


I don't object, but I really do not have time to review it in detail.
Greg KH May 5, 2021, 7:23 a.m. UTC | #3
On Thu, Apr 29, 2021 at 05:33:06PM +0000, Jianxiong Gao wrote:
> We observed several NVMe failures when running with SWIOTLB. The root

> cause of the issue is that when data is mapped via SWIOTLB, the address

> offset is not preserved. Several device drivers including the NVMe

> driver relies on this offset to function correctly.

> 

> Even though we discovered the error when running using AMD SEV, we have

> reproduced the same error in Rhel 8 without SEV. By adding swiotlb=force

> option to the boot command line parameter, NVMe funcionality is

> impacted. For example formatting a disk into xfs format returns an

> error.

> 

> 

> ----

> Changes in v2:

> Rebased patches to 5.10.33


It looks like if I were to take these now, we need to also have a
version for 5.11.y because you can not upgrade from an older kernel and
have a "regression" like this, right?

5.11.y will still be alive for at least a week or so, let me see if your
backports work there or not...

thanks,

greg k-h
Greg KH May 5, 2021, 7:44 a.m. UTC | #4
On Wed, May 05, 2021 at 09:23:28AM +0200, Greg KH wrote:
> On Thu, Apr 29, 2021 at 05:33:06PM +0000, Jianxiong Gao wrote:

> > We observed several NVMe failures when running with SWIOTLB. The root

> > cause of the issue is that when data is mapped via SWIOTLB, the address

> > offset is not preserved. Several device drivers including the NVMe

> > driver relies on this offset to function correctly.

> > 

> > Even though we discovered the error when running using AMD SEV, we have

> > reproduced the same error in Rhel 8 without SEV. By adding swiotlb=force

> > option to the boot command line parameter, NVMe funcionality is

> > impacted. For example formatting a disk into xfs format returns an

> > error.

> > 

> > 

> > ----

> > Changes in v2:

> > Rebased patches to 5.10.33

> 

> It looks like if I were to take these now, we need to also have a

> version for 5.11.y because you can not upgrade from an older kernel and

> have a "regression" like this, right?

> 

> 5.11.y will still be alive for at least a week or so, let me see if your

> backports work there or not...


Ok, looks like it worked, now queued up.

greg k-h