From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934688AbcIGOjM (ORCPT ); Wed, 7 Sep 2016 10:39:12 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60887 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933447AbcIGOjH (ORCPT ); Wed, 7 Sep 2016 10:39:07 -0400 From: Arnd Bergmann To: Roger Quadros Cc: linux-arm-kernel@lists.infradead.org, Alan Stern , Felipe Balbi , Grygorii Strashko , Stuart Yoder , Catalin Marinas , Yoshihiro Shimoda , "linux-usb@vger.kernel.org" , Sekhar Nori , Russell King - ARM Linux , lkml , Scott Wood , David Fisher , "Thang Q. Nguyen" , Leo Li , Greg Kroah-Hartman Subject: Re: [PATCH] usb: dwc3: host: inherit dma configuration from parent dev Date: Wed, 07 Sep 2016 16:38:40 +0200 Message-ID: <4842968.834OEr0s9G@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <632cd67b-34de-2177-529f-e1437924bae2@ti.com> References: <8802454.xFheq55hVP@wuerfel> <632cd67b-34de-2177-529f-e1437924bae2@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:0Tg2gxc1vzVCCBOc50PSDKaXcfWY1eAYLf+wwmGVwrJDee/wFpP iFgot8t/8aElDKqrAtO8Wm3jUc2OL1LPlnKDG6+hOvGreBY4rPiNgAf42YW9El3rJmLogQJ u2X8zkht6BjHkKh3wuD+NQ8/mhsdCTSb9kzYpWXDBEpQ9fiOPMgjajisFP/Ep2pLt7JOhnS v7RwNVKtQWwGuSJ2+DxCg== X-UI-Out-Filterresults: notjunk:1;V01:K0:qXkvD9uf1YM=:sc1qGkYzW5i45MMZAF9t1p yStK3Lqgxp1846wlf1gGdatZ0NUorSJhIh9fw7j+AszBqtzWdrdCiAWlt0PUg+aadF86J3kmH 73gad2BbijLajzvmGTxQdWcMi/rXeURL7DZUxJ7Q1w96KcsKSmOpKWwnG3KJOpWWFKbZ0ahEC 2T2KV0HB5loUlBCdVhhNy7c25r6IAKrL7JmhAc8Va1EaVsj2lA8q4i4nXVWlfJzClZgKQItyz wQyjjj4LteCj9ANUiMIYs4nKPbd5v31B5u20d2oxpb2hEi6xHoNv+3sDIn2PDU0OujTdvD8AL 1eSCeAL1y4uaz9s+dRCxgdOt+7J0o44QlhyYDz6fjnwdDX/m8oNkS0Sux9ddqwGp5YGDg4Aqk RidpvSyliH6beY9OpVNtBXQmYSi/4+9kqM9czlgaO4qsXelasXzwSc5BrU2vgjMnuG9QyPSsD sevNJXVBtiR8odDhmWdMh4HgzakAlHV3hJpIeQ4KAECJEse7GIgD5pw/CW77AZZ2M7DoFTjAL gFbPKef/y26LZvWILJCBMq1+1e0Aeyh9H6vYpROPLnIZh695vxUxlvqL1Wy7exZKqMcTgnAZE mvm3wK/l7wdQ6/PjAFLCdcq+YsXdiOImtuTOcsXz84XQtlglq+9Me9+Jsg0O6kh7BfnTdBfTE us8ljr8RRXKpdkaZPiJHv8hnM4lVqLTDUbT+GThdEGJKvYlMAqQFRswpMopYVG0UJULFwo1Ze x1BKnGkwafDyuKbb Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, September 7, 2016 4:04:52 PM CEST Roger Quadros wrote: > > The main use for it is to let you specify a MAC address for on-board > > ethernet devices that lack an EPROM, but any other information can be > > added that way too. > > > >> There is a bug in the USB core because of which the ISB device and interfaces > >> do not inherit dma_pfn_offset correctly for which I've sent a patch > >> https://lkml.org/lkml/2016/8/17/275 > > > > I'm a bit skeptical about this. Clearly if we set the dma_mask, we should > > also set the dma_pfn_offset, but what exactly is this used for in USB > > devices? > > Consider the mass storage device case. > USB storage driver creates a scsi host for the mass storage interface in > drivers/usb/storage/usb.c > The scsi host parent device is nothing but the the USB interface device. > > Now, __scsi_init_queue() calls scsi_calculate_bounce_limit() to find out > and set the block layer bounce limit. > > scsi_calculate_bounce_limit() uses dma_max_pfn(host_dev) to get the bounce_limit. > > host_dev is nothing but the device representing the mass storage interface. > > If that device doesn't have the right dma_pfn_offset, then dma_max_pfn() > is messed up and the bounce buffer limit is wrong. I see. The same thing probably happens in the network and mmc subsystems, which have similar code. This shows the inconsistencies we have in the handling for bounce buffers in the kernel, which are sometimes handled by subsystems but sometimes rely on swiotlb instead. I don't have any better idea than your patch here, but maybe we should add a comment explaining that next to the code. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Wed, 07 Sep 2016 16:38:40 +0200 Subject: [PATCH] usb: dwc3: host: inherit dma configuration from parent dev In-Reply-To: <632cd67b-34de-2177-529f-e1437924bae2@ti.com> References: <8802454.xFheq55hVP@wuerfel> <632cd67b-34de-2177-529f-e1437924bae2@ti.com> Message-ID: <4842968.834OEr0s9G@wuerfel> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wednesday, September 7, 2016 4:04:52 PM CEST Roger Quadros wrote: > > The main use for it is to let you specify a MAC address for on-board > > ethernet devices that lack an EPROM, but any other information can be > > added that way too. > > > >> There is a bug in the USB core because of which the ISB device and interfaces > >> do not inherit dma_pfn_offset correctly for which I've sent a patch > >> https://lkml.org/lkml/2016/8/17/275 > > > > I'm a bit skeptical about this. Clearly if we set the dma_mask, we should > > also set the dma_pfn_offset, but what exactly is this used for in USB > > devices? > > Consider the mass storage device case. > USB storage driver creates a scsi host for the mass storage interface in > drivers/usb/storage/usb.c > The scsi host parent device is nothing but the the USB interface device. > > Now, __scsi_init_queue() calls scsi_calculate_bounce_limit() to find out > and set the block layer bounce limit. > > scsi_calculate_bounce_limit() uses dma_max_pfn(host_dev) to get the bounce_limit. > > host_dev is nothing but the device representing the mass storage interface. > > If that device doesn't have the right dma_pfn_offset, then dma_max_pfn() > is messed up and the bounce buffer limit is wrong. I see. The same thing probably happens in the network and mmc subsystems, which have similar code. This shows the inconsistencies we have in the handling for bounce buffers in the kernel, which are sometimes handled by subsystems but sometimes rely on swiotlb instead. I don't have any better idea than your patch here, but maybe we should add a comment explaining that next to the code. Arnd