From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: UAS: fix alignment of scatter/gather segments From: Oliver Neukum Message-Id: <1556563340.20085.28.camel@suse.com> Date: Mon, 29 Apr 2019 20:42:20 +0200 To: Alan Stern Cc: David Laight , "gregKH@linuxfoundation.org" , "linux-usb@vger.kernel.org" List-ID: T24gTW8sIDIwMTktMDQtMjkgYXQgMTM6NTUgLTA0MDAsIEFsYW4gU3Rlcm4gd3JvdGU6Cj4gT24g TW9uLCAyOSBBcHIgMjAxOSwgT2xpdmVyIE5ldWt1bSB3cm90ZToKPiAKPiA+IE9uIE1vLCAyMDE5 LTA0LTI5IGF0IDEyOjA4IC0wNDAwLCBBbGFuIFN0ZXJuIHdyb3RlOgo+ID4gPiBPbiBNb24sIDI5 IEFwciAyMDE5LCBPbGl2ZXIgTmV1a3VtIHdyb3RlOgo+ID4gPiAKPiA+ID4gPiBPbiBNbywgMjAx OS0wNC0yOSBhdCAxNTowNiArMDAwMCwgRGF2aWQgTGFpZ2h0IHdyb3RlOgo+ID4gPiAKPiA+ID4g PiBCdXQgdGhlIHN0YXRlbWVudCB0aGUgb2xkIGNvbW1lbnQgbWFkZSBhcmUgbm8gbG9uZ2VyIGNv cnJlY3QuCj4gPiA+IAo+ID4gPiBQZXJoYXBzIERhdmlkIHdvdWxkIGJlIHNhdGlzZmllZCBpZiB0 aGUgY29tbWVudCB3ZXJlIGNoYW5nZWQgdG8gc2F5IAo+ID4gPiB0aGF0IF9zb21lXyBVU0IgY29u dHJvbGxlciBkcml2ZXJzIGhhdmUgdGhpcyB1bnVzdWFsIGFsaWdubWVudCAKPiA+ID4gcmVxdWly ZW1lbnQuCj4gPiAKPiA+IEl0IHdvdWxkIHNlZW0gdG8gbWUgdGhhdCBldmVyeSBjb250cm9sbGVy IHRoYXQgZG9lcyBub3QgZG8KPiA+IHNjYXR0ZXIvZ2F0aGVyIGhhcyB0aGlzIHJ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UhDSSBjYW4sIGJ1dCBvbmx5IGlmIHRoZSBm aXJzdCBzZWdtZW50IGVuZHMgYXQgYSBwYWdlIGJvdW5kYXJ5IGFuZCB0aGUKPiBzZWNvbmQgYmVn aW5zIGF0IGEgcGFnZSBib3VuZGFyeSAtLSBpdCdzIGVhc2llciBqdXN0IHRvIHNheSB0aGF0IHRo ZQo+IHNlZ21lbnRzIGhhdmUgdG8gYmUgbWF4cGFja2V0LWFsaWduZWQuCj4gCj4gPiBUaGUgc2Vj b25kLCBvbGQsIGNvbW1lbnQgaXMgYWJvdXQgY29udHJvbGxlcnMuCj4gCj4gV2VsbCwgaWYgdGhl IGRyaXZlcnMgd291bGQgdXNlIGJvdW5jZSBidWZmZXJzIHRvIHdvcmsgYXJvdW5kIHRoZSAKPiBj b250cm9sbGVycycgaXNzdWVzIHRoZW4gdGhleSB3b3VsZG4ndCBoYXZlIHRoaXMgc3BlY2lhbCBy ZXF1aXJlbWVudC4gIAo+IFNvIGl0IHJlYWxseSBpcyBhIGNvbWJpbmF0aW9uIG9mIHdoYXQgdGhl IGhhcmR3YXJlIGNhbiBkbyBhbmQgd2hhdCB0aGUgCj4gZHJpdmVyIGNhbiBkby4KClllcywgYnV0 IHRoZSBwb2ludCBvZiB1c2luZyBhbiBBUEkgdG8gc3BlY2lmeSByZXN0cmljdGlvbnMgdG8gdGhl CnVwcGVyIGxheWVyIGlzIHRvIGF2b2lkIHVzaW5nIGJvdW5jZSBidWZmZXJzLiBCZXNpZGVzLCBi b3VuY2UKYnVmZmVycyBpbiBibG9jayBJTyBpcyBpbnRlcmVzdGluZyBpbiB0ZXJtcyBvZiBWTSBp bXBsaWNhdGlvbnMuCgoJUmVnYXJkcwoJCU9saXZlcgo= From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EA57C43219 for ; Mon, 29 Apr 2019 18:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 178C52087B for ; Mon, 29 Apr 2019 18:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbfD2Smf (ORCPT ); Mon, 29 Apr 2019 14:42:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:41948 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728186AbfD2Smf (ORCPT ); Mon, 29 Apr 2019 14:42:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F1717AEBC; Mon, 29 Apr 2019 18:42:33 +0000 (UTC) Message-ID: <1556563340.20085.28.camel@suse.com> Subject: Re: [PATCH] UAS: fix alignment of scatter/gather segments From: Oliver Neukum To: Alan Stern Cc: David Laight , "gregKH@linuxfoundation.org" , "linux-usb@vger.kernel.org" Date: Mon, 29 Apr 2019 20:42:20 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Message-ID: <20190429184220.5i_NhRPY0E4MuavW1J0JhGBs_xLj_PcznZFQswbqAO0@z> On Mo, 2019-04-29 at 13:55 -0400, Alan Stern wrote: > On Mon, 29 Apr 2019, Oliver Neukum wrote: > > > On Mo, 2019-04-29 at 12:08 -0400, Alan Stern wrote: > > > On Mon, 29 Apr 2019, Oliver Neukum wrote: > > > > > > > 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. > > > > 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. > 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. > 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. > > > 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