From patchwork Wed Apr 27 13:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 66794 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2205215qge; Wed, 27 Apr 2016 06:59:21 -0700 (PDT) X-Received: by 10.66.248.163 with SMTP id yn3mr12097145pac.86.1461765561168; Wed, 27 Apr 2016 06:59:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t188si4347943pfb.52.2016.04.27.06.59.20; Wed, 27 Apr 2016 06:59:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbcD0N7H (ORCPT + 29 others); Wed, 27 Apr 2016 09:59:07 -0400 Received: from foss.arm.com ([217.140.101.70]:35247 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752403AbcD0N7F (ORCPT ); Wed, 27 Apr 2016 09:59:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0298B3A; Wed, 27 Apr 2016 06:59:05 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (e104818-lin.cambridge.arm.com [10.1.203.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8ED8B3F42B; Wed, 27 Apr 2016 06:59:02 -0700 (PDT) Date: Wed, 27 Apr 2016 14:59:00 +0100 From: Catalin Marinas To: Felipe Balbi Cc: Grygorii Strashko , Greg Kroah-Hartman , Yoshihiro Shimoda , linux-usb@vger.kernel.org, Sekhar Nori , linux-kernel@vger.kernel.org, David Fisher , "Thang Q. Nguyen" , linux-arm-kernel@lists.infradead.org, Arnd Bergmann Subject: Re: [PATCH] usb: dwc3: host: inherit dma configuration from parent dev Message-ID: <20160427135859.GC20646@e104818-lin.cambridge.arm.com> References: <1461612094-30939-1-git-send-email-grygorii.strashko@ti.com> <87d1pcrj0t.fsf@intel.com> <571F2357.9080509@ti.com> <878tzzpq19.fsf@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <878tzzpq19.fsf@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2016 at 08:41:06AM +0300, Felipe Balbi wrote: > Grygorii Strashko writes: > > On 04/26/2016 09:17 AM, Felipe Balbi wrote: > >> Grygorii Strashko writes: > >>> Now not all DMA paremters configured properly for "xhci-hcd" platform > >>> device which is created manually. For example: dma_pfn_offset, dam_ops > >>> and iommu configuration will not corresponds "dwc3" devices > >>> configuration. As result, this will cause problems like wrong DMA > >>> addresses translation on platforms with LPAE enabled like Keystone 2. > >>> > >>> When platform is using DT boot mode the DMA configuration will be > >>> parsed and applied from DT, so, to fix this issue, reuse > >>> of_dma_configure() API and retrieve DMA configuartion for "xhci-hcd" > >>> from DWC3 device node. > >> > >> patch is incomplete. You left out non-DT users which might suffer from > >> the same problem. > > > > Honestly, I don't know how to fix it gracefully for non-DT case. > > I can update commit message to mention that this is fix for DT case only. > > no, that won't do :-) There are other users for this driver and they are > all "out-of-compliance" when it comes to DMA usage. Apparently, the > desired behavior is to pass correct device to DMA API which the gadget > side is already doing (see below). For the host side, the fix has to be > more involved. > > Frankly, I'd prefer that DMA setup could be inherited from parent > device, then it wouldn't really matter and a bunch of this could be > simplified. Some sort of dma_inherit(struct device *dev, struct device > *parent) would go a long way, IMHO. I would be in favour of a dma_inherit() function as well. We could hack something up in the arch code (like below) but I would rather prefer an explicit dma_inherit() call by drivers creating such devices. -- Catalin diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index ba437f090a74..ea6fb9b0e8fa 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h @@ -29,8 +29,11 @@ extern struct dma_map_ops dummy_dma_ops; static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) { - if (dev && dev->archdata.dma_ops) - return dev->archdata.dma_ops; + while (dev) { + if (dev->archdata.dma_ops) + return dev->archdata.dma_ops; + dev = dev->parent; + } /* * We expect no ISA devices, and all other DMA masters are expected to