1 From 9a976949613132977098fc49510b46fa8678d864 Mon Sep 17 00:00:00 2001
2 From: Alan Stern <stern@rowland.harvard.edu>
3 Date: Mon, 21 Oct 2019 11:48:06 -0400
4 Subject: usb-storage: Revert commit 747668dbc061 ("usb-storage: Set virt_boundary_mask to avoid SG overflows")
6 From: Alan Stern <stern@rowland.harvard.edu>
8 commit 9a976949613132977098fc49510b46fa8678d864 upstream.
10 Commit 747668dbc061 ("usb-storage: Set virt_boundary_mask to avoid SG
11 overflows") attempted to solve a problem involving scatter-gather I/O
12 and USB/IP by setting the virt_boundary_mask for mass-storage devices.
14 However, it now turns out that this interacts badly with commit
15 09324d32d2a0 ("block: force an unlimited segment size on queues with a
16 virt boundary"), which was added later. A typical error message is:
18 ehci-pci 0000:00:13.2: swiotlb buffer is full (sz: 327680 bytes),
19 total 32768 (slots), used 97 (slots)
21 There is no longer any reason to keep the virt_boundary_mask setting
22 for usb-storage. It was needed in the first place only for handling
23 devices with a block size smaller than the maxpacket size and where
24 the host controller was not capable of fully general scatter-gather
25 operation (that is, able to merge two SG segments into a single USB
28 High-speed or slower connections never use a bulk maxpacket
29 value larger than 512;
31 The SCSI layer does not handle block devices with a block size
32 smaller than 512 bytes;
34 All the host controllers capable of SuperSpeed operation can
35 handle fully general SG;
37 Since commit ea44d190764b ("usbip: Implement SG support to
38 vhci-hcd and stub driver") was merged, the USB/IP driver can
41 Therefore all supported device/controller combinations should be okay
42 with no need for any special virt_boundary_mask. So in order to fix
43 the swiotlb problem, this patch reverts commit 747668dbc061.
45 Reported-and-tested-by: Piergiorgio Sartor <piergiorgio.sartor@nexgo.de>
46 Link: https://marc.info/?l=linux-usb&m=157134199501202&w=2
47 Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
48 CC: Seth Bollinger <Seth.Bollinger@digi.com>
49 CC: <stable@vger.kernel.org>
50 Fixes: 747668dbc061 ("usb-storage: Set virt_boundary_mask to avoid SG overflows")
51 Acked-by: Christoph Hellwig <hch@lst.de>
52 Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1910211145520.1673-100000@iolanthe.rowland.org
53 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
56 drivers/usb/storage/scsiglue.c | 10 ----------
57 1 file changed, 10 deletions(-)
59 --- a/drivers/usb/storage/scsiglue.c
60 +++ b/drivers/usb/storage/scsiglue.c
61 @@ -67,7 +67,6 @@ static const char* host_info(struct Scsi
62 static int slave_alloc (struct scsi_device *sdev)
64 struct us_data *us = host_to_us(sdev->host);
68 * Set the INQUIRY transfer length to 36. We don't use any of
69 @@ -77,15 +76,6 @@ static int slave_alloc (struct scsi_devi
70 sdev->inquiry_len = 36;
73 - * USB has unusual scatter-gather requirements: the length of each
74 - * scatterlist element except the last must be divisible by the
75 - * Bulk maxpacket value. Fortunately this value is always a
76 - * power of 2. Inform the block layer about this requirement.
78 - maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0);
79 - blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
82 * Some host controllers may have alignment requirements.
83 * We'll play it safe by requiring 512-byte alignment always.