From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759436AbcILOe5 (ORCPT ); Mon, 12 Sep 2016 10:34:57 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:52825 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759374AbcILOey (ORCPT ); Mon, 12 Sep 2016 10:34:54 -0400 From: Arnd Bergmann To: Alan Stern Cc: Roger Quadros , gregkh@linuxfoundation.org, ssantosh@kernel.org, grygorii.strashko@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: core: setup dma_pfn_offset for USB devices and, interfaces Date: Mon, 12 Sep 2016 16:34:40 +0200 Message-ID: <3375606.ofT8N3j4Qu@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:+PGLLRogb8DqeN0CDy9XjlP0fucFpQKHsP5saxh40EWTQ5xhk05 Sn8bBOn5zBH0CdtM78u2KGgG6J7WhYhhoD+SALR6TpMVfs5DUSPbbChTulwnn2QT27Yh1Bd CE1TnvqMUg4rWPsIhLqG9hcTDza0LHqoYG5O9MrSthrhWR9ZJXLH5z/mRFt72+6uutBWqlU +i5Je7bL2wRwu89yTxRzQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:jBJ323fYgys=:OxZs1BLCaaE/qs7PjJasMB 7pqfhquCYn91UN7o/W0utpvxWyYKB0H/4ABo2R3YtKt0unvy4hzs3u1YINP3f8YrkPOpQ0UlV jK1COGz/gsM4sOHO6K4ysh7L1s/XdAYIu37c7likwl7qW5pTaIEJ3FMZz5zitcLjpiYzJrgNq GMtWclQv5apamyx5BXv3MQD85Kvg4ojM45yv9E6ZfXebo2JVkQn9XhAtH6FsBM1jX+0PM9Lmr N1sR6+r0OFTZYHqGoiDUtE7CRVjfmqTLihBh3nfzFlVZ7aE79O6OHQYR7rCVQkdvNpeeIB2Oh Iicc8kcqZl4UFbbIqITUFZ+BQ4uGkwTsrIOoM2nczSHyvGKZOsAM0fHOiNLMFb2+ow79IOIdO It0LzIHAgCPHwOpYOc8ypRHVXnPjCahnO1k0MDGuY2pGZzoMR7fXXIU8lDxrqkSXN9VWSSVVX opD8y/C00DXjIRg5LhZnv+lzxQL035LaSD3MfyQUYcH89wHLf/WbC2EJYw4SXM4MQLb1p+VTu AkaKK1s0Usl98soN8zxS+R52AVUHvyUrb81OcVYv0en4M/gzMqsSptoj5DyLyrlFyOGrFmo26 2CP+69xioNsw+o/y1jqjC7mLWl9bC5BQskrkEfX87Do77Ic/c5r2gKzB9zDNMXCCjqpFzkGKJ rweb/KUapxnYfoMJwy5AhHm0OHfkr2cx5DHOvZUSoJlHjblnpsQOMrUWuunDohhArjqfBtpuU qWVLXgoT2nlLlfgB Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, September 12, 2016 9:09:16 AM CEST Alan Stern wrote: > > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > > index 0406a59..66364ea 100644 > > --- a/drivers/usb/core/message.c > > +++ b/drivers/usb/core/message.c > > @@ -1863,6 +1863,12 @@ free_interfaces: > > intf->dev.type = &usb_if_device_type; > > intf->dev.groups = usb_interface_groups; > > intf->dev.dma_mask = dev->dev.dma_mask; > > + /* Propagate dma_pfn_offset to USB interface. > > + * This is especially required by mass storage interface > > + * which relies on SCSI layer and scsi_calculate_bounce_limit() > > + * to set the bounce buffer limit based on dma_pfn_offset. > > + */ > > + intf->dev.dma_pfn_offset = dev->dev.dma_pfn_offset; > > I really think this comment isn't necessary. It seems pretty obvious > that if you're copying DMA-related fields from one device to another > then you'll want to copy the dma_pfn_offset along with everything else. > No? > > The explanation in the Changelog is enough, IMO. I asked for a code comment here as what we are doing here is a bit fishy, but the comment (evidently) doesn't quite capture it. I would add (above the dma_mask assignment) something like /* * Fake a dma_mask/offset for the USB device: * We cannot really use the dma-mapping API (dma_alloc_* and * dma_map_*) for USB devices but instead need to use * usb_alloc_coherent and pass data in 'urb's, but some subsystems * manually look into the mask/offset pair to determine whether * they need bounce buffers. * Note: calling dma_set_mask() on a USB device would set the * mask for the entire HCD, so don't do that. */ Arnd