From: Yoshihiro Shimoda <email@example.com> To: Alan Stern <firstname.lastname@example.org>, Christoph Hellwig <email@example.com> Cc: Linux-Renesas <firstname.lastname@example.org>, "email@example.com" <firstname.lastname@example.org>, "email@example.com" <firstname.lastname@example.org>, "email@example.com" <firstname.lastname@example.org> Subject: RE: How to resolve an issue in swiotlb environment? Date: Tue, 11 Jun 2019 06:49:12 +0000 Message-ID: <OSAPR01MB30899F6EE0ABD554B4A21E7FD8ED0@OSAPR01MB3089.jpnprd01.prod.outlook.com> (raw) In-Reply-To: <Pine.LNX.4.44L0.email@example.com> Hi Christoph, Alan, > From: Alan Stern, Sent: Tuesday, June 11, 2019 3:46 AM > > On Mon, 10 Jun 2019, Christoph Hellwig wrote: > > > Hi Yoshihiro, > > > > sorry for not taking care of this earlier, today is a public holiday > > here and thus I'm not working much over the long weekend. To Christoph: No worries. > > On Mon, Jun 10, 2019 at 11:13:07AM +0000, Yoshihiro Shimoda wrote: > > > 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() , > > > 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 . > > > > Oh, I hadn't even look at why USB uses blk_queue_virt_boundary, and it > > seems like the usage is wrong, as it doesn't follow the same rules as > > all the others. I think your patch goes in the right direction, > > but instead of comparing a hcd name it needs to be keyed of a flag > > set by the driver (I suspect there is one indicating native SG support, > > but I can't quickly find it), and we need an alternative solution > > for drivers that don't see like vhci. I suspect just limiting the > > entire transfer size to something that works for a single packet > > for them would be fine. > > Christoph: > > In most of the different kinds of USB host controllers, the hardware is > not capable of assembling a packet out of multiple buffers at arbitrary > addresses. As a matter of fact, xHCI is the only kind that _can_ do > this. > > In some cases, the hardware can assemble packets provided each buffer > other than the last ends at a page boundary and each buffer other than > the first starts at a page boundary (Intel would say the buffers are > "virtually contiguous"), but this is a rather complex rule and we don't > want to rely on it. Plus, in other cases the hardware _can't_ do this. > > Instead, we want the SG buffers to be set up so that each one (except > the last) is an exact multiple of the maximum packet size. That way, > each packet can be assembled from the contents of a single buffer and > there's no problem. There is out of this topic though, if we prepare such an exact multiple of the maximum packet size (1024, 512 or 64), is it possible to cause trouble on IOMMU environment? IIUC, dma_map_sg() maps SG buffers as a single segment and then the segment buffer is not contiguous. > The maximum packet size depends on the type of USB connection. > Typical values are 1024, 512, or 64. It's always a power of two and > it's smaller than 4096. Therefore we simplify the problem even further > by requiring that each SG buffer in a scatterlist (except the last one) > be a multiple of the page size. (It doesn't need to be aligned on a > page boundary, as far as I remember.) > > That's why the blk_queue_virt_boundary usage was added to the USB code. > Perhaps it's not the right way of doing this; I'm not an expert on the > inner workings of the block layer. If you can suggest a better way to > express our requirement, that would be great. Since I'm also not familiar with the block layer, I could not find a better way... Best regards, Yoshihiro Shimoda > Alan Stern > > PS: There _is_ a flag saying whether an HCD supports SG. But what it > means is that the driver can handle an SG list that meets the > requirement above; it doesn't mean that the driver can reassemble the > data from an SG list into a series of bounce buffers in order to meet > the requirement. We very much want not to do that, especially since > the block layer should already be capable of doing it for us.
prev parent reply index Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-06-03 6:42 Yoshihiro Shimoda 2019-06-07 12:00 ` Yoshihiro Shimoda 2019-06-10 7:31 ` Biju Das 2019-06-10 11:13 ` Yoshihiro Shimoda 2019-06-10 12:32 ` Christoph Hellwig 2019-06-10 18:46 ` Alan Stern 2019-06-11 6:41 ` Christoph Hellwig 2019-06-11 14:51 ` Alan Stern 2019-06-12 7:30 ` Christoph Hellwig 2019-06-12 8:52 ` Yoshihiro Shimoda 2019-06-12 11:31 ` Christoph Hellwig 2019-06-13 4:52 ` Yoshihiro Shimoda 2019-06-12 11:46 ` Oliver Neukum 2019-06-12 12:06 ` Christoph Hellwig 2019-06-12 14:43 ` Alan Stern 2019-06-13 7:39 ` Christoph Hellwig 2019-06-13 16:57 ` Martin K. Petersen 2019-06-13 17:16 ` Alan Stern 2019-06-13 18:18 ` Greg KH 2019-06-13 23:01 ` shuah 2019-06-14 14:44 ` Alan Stern 2019-06-18 15:28 ` shuah 2019-06-19 20:23 ` shuah 2019-06-19 21:05 ` Alan Stern 2019-06-21 17:43 ` Suwan Kim 2019-06-11 6:49 ` Yoshihiro Shimoda [this message]
Reply instructions: You may reply publically to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=OSAPR01MB30899F6EE0ABD554B4A21E7FD8ED0@OSAPR01MB3089.jpnprd01.prod.outlook.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Block Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \ email@example.com firstname.lastname@example.org public-inbox-index linux-block Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block AGPL code for this site: git clone https://public-inbox.org/ public-inbox