Skip to contentSkip to conversation

UAS: fix alignment of scatter/gather segments

DISCUSSION Oliver Neukum 1 participant 1 message Apr 29, 2019 USB

lore
Share & tools
lore
#0 lore raw
Quoted 13 lines · Alan Stern
Quoted 11 lines · Oliver Neukum
Quoted 9 lines · Alan Stern
Quoted 3 lines · Oliver Neukum

On Mo, 2019-04-29 at 15:06 +0000, David Laight wrote:

But the statement the old comment made are no longer correct.

Perhaps David would be satisfied if the comment were changed to say that _some_ USB controller drivers have this unusual alignment requirement.

Quoted 7 lines
Quoted 5 lines

It would seem to me that every controller that does not do scatter/gather has this requirement. In other words, this is the true requirement of USB. It does not come from the controller. It comes from the protocol's need to not send a short package.

Are you sure that xHCI has this requirement? I haven't checked the

I am sure that it has not. UAS would never have worked. Like in the case of storage this patch is necessary for virtual controllers.

Quoted 5 lines

spec. I know that UHCI, OHCI, and EHCI do need this alignment (and OHCI and EHCI do in fact have hardware support for scatter-gather).

More precisely, what matters is whether the controller is able to merge two different DMA segments into a single packet. UHCI can't. OHCI and

Correct. However, we cannot blindly assume in a class driver that certain controllers will be used.

Quoted 10 lines

EHCI can, but only if the first segment ends at a page boundary and the second begins at a page boundary -- it's easier just to say that the segments have to be maxpacket-aligned.

Quoted 1 line

The second, old, comment is about controllers.

Well, if the drivers would use bounce buffers to work around the controllers' issues then they wouldn't have this special requirement. So it really is a combination of what the hardware can do and what the driver can do.

Yes, but the point of using an API to specify restrictions to the upper layer is to avoid using bounce buffers. Besides, bounce buffers in block IO is interesting in terms of VM implications.

Regards
Oliver