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: <1556548362.20085.17.camel@suse.com> Date: Mon, 29 Apr 2019 16:32:42 +0200 To: David Laight , "gregKH@linuxfoundation.org" , "linux-usb@vger.kernel.org" List-ID: T24gTW8sIDIwMTktMDQtMjkgYXQgMTQ6MTkgKzAwMDAsIERhdmlkIExhaWdodCB3cm90ZToKPiBG cm9tOiBPbGl2ZXIgTmV1a3VtCj4gPiBTZW50OiAyOSBBcHJpbCAyMDE5IDE0OjM4Cj4gPiBPbiBN bywgMjAxOS0wNC0yOSBhdCAxMzozMSArMDAwMCwgRGF2aWQgTGFpZ2h0IHdyb3RlOgo+ID4gPiBG cm9tOiBPbGl2ZXIgTmV1a3VtCj4gPiA+ID4gCj4gPiA+ID4gKwkgKiBVU0IgaGFzIHVudXN1YWwg c2NhdHRlci1nYXRoZXIgcmVxdWlyZW1lbnRzOiB0aGUgbGVuZ3RoIG9mIGVhY2gKPiA+ID4gPiAr CSAqIHNjYXR0ZXJsaXN0IGVsZW1lbnQgZXhjZXB0IHRoZSBsYXN0IG11c3QgYmUgZGl2aXNpYmxl IGJ5IHRoZQo+ID4gPiA+ICsJICogQnVsayBtYXhwYWNrZXQgdmFsdWUuICBGb3J0dW5hdGVseSB0 aGlzIHZhbHVlIGlzIGFsd2F5cyBhCj4gPiA+ID4gKwkgKiBwb3dlciBvZiAyLiAgSW5mb3JtIHRo ZSBibG9jayBsYXllciBhYm91dCB0aGlzIHJlcXVpcmVtZW50Lgo+ID4gPiA+ICsJICovCj4gPiA+ IAo+ID4gPiBUaGF0IGlzbid0IHRoZSBjb3JyZWN0IHJlc3RyaWN0aW9uIGZvciBYSENJLgo+ID4g PiBJdCBoYXMgaXRzIG93biBwZXJ2ZXJzZSByZXN0cmljdGlvbnMuCj4gPiA+IEkgdGhpbmsgdGhl eSBhcm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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 2BCB8C43219 for ; Mon, 29 Apr 2019 14:32:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08244205ED for ; Mon, 29 Apr 2019 14:32:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728258AbfD2Oc4 (ORCPT ); Mon, 29 Apr 2019 10:32:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:51580 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725838AbfD2Oc4 (ORCPT ); Mon, 29 Apr 2019 10:32:56 -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 9093EAF22; Mon, 29 Apr 2019 14:32:55 +0000 (UTC) Message-ID: <1556548362.20085.17.camel@suse.com> Subject: Re: [PATCH] UAS: fix alignment of scatter/gather segments From: Oliver Neukum To: David Laight , "gregKH@linuxfoundation.org" , "linux-usb@vger.kernel.org" Date: Mon, 29 Apr 2019 16:32:42 +0200 In-Reply-To: References: <20190429122026.4249-1-oneukum@suse.com> <1556545099.20085.14.camel@suse.com> 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: <20190429143242.2EbhBHZUh9b98MfeUFCrFvbMZ7OdLiG5i2daMTm0bcg@z> On Mo, 2019-04-29 at 14:19 +0000, David Laight wrote: > From: Oliver Neukum > > Sent: 29 April 2019 14:38 > > On Mo, 2019-04-29 at 13:31 +0000, David Laight wrote: > > > From: Oliver Neukum > > > > > > > > + * USB has unusual scatter-gather requirements: the length of each > > > > + * scatterlist element except the last must be divisible by the > > > > + * Bulk maxpacket value. Fortunately this value is always a > > > > + * power of 2. Inform the block layer about this requirement. > > > > + */ > > > > > > That isn't the correct restriction for XHCI. > > > It has its own perverse restrictions. > > > I think they are all handled within the xhci driver. > > > > Yes, but that does not matter. You just cannot assume that only > > XHCI will be used with UAS. In particular virtual drivers will > > be used. > > True, but there is no need to enforce a 2k (IIRC) alignment for XHCI. > Perhaps you need a different property from the controller. AFAICT controllers do not export that property. > Even if you decide the code is 'good enough' (I don't know what the > cost is of enforcing a 2k alignment instead of 512 bytes) > the comment is just plain wrong. Usually block IO will be pages. They are 4K aligned. In terms of performance this code is unlikely to matter. But it is needed for correctness. What would you want for the comment? Regards Oliver