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: <1556553445.20085.21.camel@suse.com> Date: Mon, 29 Apr 2019 17:57:25 +0200 To: David Laight , "gregKH@linuxfoundation.org" , "linux-usb@vger.kernel.org" List-ID: T24gTW8sIDIwMTktMDQtMjkgYXQgMTU6MDYgKzAwMDAsIERhdmlkIExhaWdodCB3cm90ZToKPiBG cm9tOiBPbGl2ZXIgTmV1a3VtCj4gPiBPbiBNbywgMjAxOS0wNC0yOSBhdCAxNDoxOSArMDAwMCwg RGF2aWQgTGFpZ2h0IHdyb3RlOgoKPiA+IEFGQUlDVCBjb250cm9sbGVycyBkbyBub3QgZXhwb3J0 IHRoYXQgcHJvcGVydHkuCj4gCj4gUGVyaGFwcyB0aGV5IG5lZWQgdG8gLi4uLgoKRmVlbCBmcmVl IHRvIG1ha2UgYSBwYXRjaC4KCj4gPiA+IEV2ZW4gaWYgeW91IGRlY2lkZSB0aGUgY29kZSBpcyAn Z29vZCBlbm91Z2gnIChJIGRvbid0IGtub3cgd2hhdCB0aGUKPiA+ID4gY29zdCBpcyBvZiBlbmZv cmNpbmcgYSAyayBhbGlnbm1lbnQgaW5zdGVhZCBvZiA1MTIgYnl0ZXMpCj4gPiA+IHRoZSBjb21t ZW50IGlzIGp1c3QgcGxhaW4gd3JvbmcuCj4gPiAKPiA+IFVzdWFsbHkgYmxvY2sgSU8gd2lsbCBi ZSBwYWdlcy4gVGhleSBhcmUgNEsgYWxpZ25lZC4KPiA+IEluIHRlcm1zIG9mIHBlcmZvcm1hbmNl IHRoaXMgY29kZSBpcyB1bmxpa2VseSB0byBtYXR0ZXIuCj4gCj4gUHJlc3VtYWJseSB0aGVyZSBh cmUgc29tZSBjYXNlcyB3aGVyZSB0aGUgYnVmZmVyIGlzbid0IDRrIGFsaWduZWQuCj4gSSdtIGd1 ZXNzaW5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1vcmUgc3BlY2lm aWMgYWJvdXQgdGhlIGFsaWdubWVudCByZXF1aXJlbWVudHMgdGhhbgo+IHRoZSBvbGQgY29tbWVu dCwgbm90IGZhciBsZXNzIHNwZWNpZmljLgoKQnV0IHRoZSBzdGF0ZW1lbnQgdGhlIG9sZCBjb21t ZW50IG1hZGUgYXJlIG5vIGxvbmdlciBjb3JyZWN0LgoKCVJlZ2FyZHMKCQlPbGl2ZXIK 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 7689EC43219 for ; Mon, 29 Apr 2019 15:57:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 466712064A for ; Mon, 29 Apr 2019 15:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728702AbfD2P5i (ORCPT ); Mon, 29 Apr 2019 11:57:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:44602 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728516AbfD2P5i (ORCPT ); Mon, 29 Apr 2019 11:57:38 -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 6E259AD45; Mon, 29 Apr 2019 15:57:37 +0000 (UTC) Message-ID: <1556553445.20085.21.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 17:57:25 +0200 In-Reply-To: References: <20190429122026.4249-1-oneukum@suse.com> <1556545099.20085.14.camel@suse.com> <1556548362.20085.17.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: <20190429155725.y8wzHvoqNE5l5TcSVFGLfReVzDPAR8g486dOCsimHa8@z> On Mo, 2019-04-29 at 15:06 +0000, David Laight wrote: > From: Oliver Neukum > > On Mo, 2019-04-29 at 14:19 +0000, David Laight wrote: > > AFAICT controllers do not export that property. > > Perhaps they need to .... Feel free to make a patch. > > > 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. > > Presumably there are some cases where the buffer isn't 4k aligned. > I'm guessing things like 'dd' of raw disks? Possibly. > If the buffer has the wrong alignment then I presume a bounce buffer > has to be allocated? > The USB controller drivers are likely to need to be able to do that > anyway because buffers from the network stack can have almost > arbitrary alignment (I remember that code being horrid, I don't > remember a data copy in the TX path). You can ask the network layer to undo scatter/gather. I don't see an issue. > > But it is needed for correctness. > > If you are doing it for 'correctness' then you need the correct size. Why? Any larger size will do. > If you are doing it because you've seen too small an alignment you > should be mentioning the failing system. Why? > > What would you want for the comment? > > You need to be more specific about the alignment requirements than > the old comment, not far less specific. But the statement the old comment made are no longer correct. Regards Oliver