Hi Christoph, Alan, (add linux-usb ML on CC.) > From: Yoshihiro Shimoda, Sent: Friday, June 7, 2019 9:00 PM > > Hi Christoph, > > I think we should continue to discuss on this email thread instead of the fixed DMA-API.txt patch [1] > > [1] > https://marc.info/?t=155989412200001&r=1&w=2 > > > From: Yoshihiro Shimoda, Sent: Monday, June 3, 2019 3:42 PM > > > > Hi linux-block and iommu mailing lists, > > > > I have an issue that a USB SSD with xHCI on R-Car H3 causes "swiotlb is full" like below. > > > > [ 36.745286] xhci-hcd ee000000.usb: swiotlb buffer is full (sz: 524288 bytes), total 32768 (slots), used 1338 > (slots) > > > > I have investigated this issue by using git bisect, and then I found the following commit: > > > > --- > > commit 09324d32d2a0843e66652a087da6f77924358e62 > > Author: Christoph Hellwig <hch@xxxxxx> > > Date: Tue May 21 09:01:41 2019 +0200 > > > > block: force an unlimited segment size on queues with a virt boundary > > --- > > Thank you for your comment on other email thread [2] like below: > --- > Turns out it isn't as simple as I thought, as there doesn't seem to > be an easy way to get to the struct device used for DMA mapping > from USB drivers. I'll need to think a bit more how to handle that > best. > --- > > [2] > https://marc.info/?l=linux-doc&m=155989651620473&w=2 I have another way to avoid the issue. But it doesn't seem that a good way though... According to the commit that adding blk_queue_virt_boundary() [3], this is needed for vhci_hcd as a workaround so that if we avoid to call it on xhci-hcd driver, the issue disappeared. What do you think? JFYI, I pasted a tentative patch in the end of email [4]. --- [3] commit 747668dbc061b3e62bc1982767a3a1f9815fcf0e Author: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> Date: Mon Apr 15 13:19:25 2019 -0400 usb-storage: Set virt_boundary_mask to avoid SG overflows --- [4] diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 59190d8..277c6f7e 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -30,6 +30,8 @@ #include <linux/module.h> #include <linux/mutex.h> +#include <linux/usb.h> +#include <linux/usb/hcd.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -65,6 +67,7 @@ static const char* host_info(struct Scsi_Host *host) static int slave_alloc (struct scsi_device *sdev) { struct us_data *us = host_to_us(sdev->host); + struct usb_hcd *hcd = bus_to_hcd(us->pusb_dev->bus); int maxp; /* @@ -80,8 +83,10 @@ static int slave_alloc (struct scsi_device *sdev) * Bulk maxpacket value. Fortunately this value is always a * power of 2. Inform the block layer about this requirement. */ - maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0); - blk_queue_virt_boundary(sdev->request_queue, maxp - 1); + if (!strcmp(hcd->driver->description, "vhci_hcd")) { + maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0); + blk_queue_virt_boundary(sdev->request_queue, maxp - 1); + } /* * Some host controllers may have alignment requirements. --- Best regards, Yoshihiro Shimoda