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 <h...@lst.de>
> 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'm not sure this is a correct way, but the issue disappears if I applied a 
patch below
to USB storage driver. Especially, WARNING happened on 
blk_queue_max_segment_size().
Maybe we need to expand the argument "struct device *" of 
blk_queue_virt_boundary() to
call dma_max_mapping_size()?
---
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 59190d8..fa37b39 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -28,6 +28,7 @@
  * status of a command.
  */
 
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 
@@ -83,6 +84,15 @@ static int slave_alloc (struct scsi_device *sdev)
        maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0);
        blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
 
+{
+       struct device *dev = us->pusb_dev->bus->controller;
+
+       dev_info(dev, "%s: size = %zu\n", __func__, dma_max_mapping_size(dev));
+       blk_queue_max_segment_size(sdev->request_queue,
+                                  dma_max_mapping_size(dev));
+}
+
+
        /*
         * Some host controllers may have alignment requirements.
         * We'll play it safe by requiring 512-byte alignment always.
---

Best regards,
Yoshihiro Shimoda

Reply via email to