From patchwork Fri Apr 15 10:44:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 65892 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1103216qge; Fri, 15 Apr 2016 03:45:10 -0700 (PDT) X-Received: by 10.98.12.154 with SMTP id 26mr9744570pfm.20.1460717110808; Fri, 15 Apr 2016 03:45:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sm10si4307519pab.78.2016.04.15.03.45.10; Fri, 15 Apr 2016 03:45:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753767AbcDOKoz (ORCPT + 4 others); Fri, 15 Apr 2016 06:44:55 -0400 Received: from foss.arm.com ([217.140.101.70]:48636 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753756AbcDOKoy (ORCPT ); Fri, 15 Apr 2016 06:44:54 -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 095403C; Fri, 15 Apr 2016 03:43:39 -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 A48C73F25F; Fri, 15 Apr 2016 03:44:52 -0700 (PDT) Date: Fri, 15 Apr 2016 11:44:50 +0100 From: Catalin Marinas To: Felipe Balbi Cc: David Fisher , "'linux-usb@vger.kernel.org'" , John Youn , "arnd@arndb.de" Subject: Re: dwc3 initiated xhci probe problem in arm64 4.4 kernel due to DMA setup Message-ID: <20160415104449.GM15182@e104818-lin.cambridge.arm.com> References: <20160415094800.GA28817@localhost.localdomain> <87potri4mc.fsf@intel.com> <20160415100107.GK15182@e104818-lin.cambridge.arm.com> <20160415100348.GL15182@e104818-lin.cambridge.arm.com> <87bn5bi2qe.fsf@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87bn5bi2qe.fsf@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Fri, Apr 15, 2016 at 01:30:01PM +0300, Felipe Balbi wrote: > Catalin Marinas writes: > > On Fri, Apr 15, 2016 at 11:01:08AM +0100, Catalin Marinas wrote: > >> On Fri, Apr 15, 2016 at 12:49:15PM +0300, Felipe Balbi wrote: > >> > Catalin Marinas writes: > >> > > On Thu, Apr 14, 2016 at 12:46:47PM +0000, David Fisher wrote: > >> > >> dwc3 is in dual-role, with "synopsys,dwc3" specified in DT. > >> > >> > >> > >> When xhci is probed, initiated from dwc3/host.c (not DT), we get : > >> > >> xhci-hcd: probe of xhci-hcd.7.auto failed with error -5 > >> > >> This -EIO error originated from inside dma_set_mask() down in include/asm-generic/dma-mapping-common.h > >> > >> > >> > >> If "generic-xhci" is specified in DT instead, it probes fine as a host-only dwc3 > >> > >> The difference between DT initiated probe and dwc3 initiated probe is that > >> > >> when DT initiated probe gets to dma_supported, dma_supported is > >> > >> implemented by swiotlb_dma_supported (previously set up by a DT call to arch_dma_setup_ops). > >> > >> Whereas when dwc3 initiated xhci probe gets to dma_supported, arch_dma_setup_ops has not been called > >> > >> and dma_supported is only implemented by __dummy_dma_supported, returning 0. > >> > >> > >> > >> Bisecting finds the "bad" commit as > >> > >> 1dccb598df549d892b6450c261da54cdd7af44b4 (inbetween 4.4-rc1 and 4.4-rc2) > >> > >> --- a/arch/arm64/include/asm/dma-mapping.h > >> > >> --- a/arch/arm64/mm/dma-mapping.c > >> > >> > >> > >> Previous to this commit, dma_ops = &swiotlb_dma_ops was done in arm64_dma_init > >> > >> After this commit, the assignment is only done in arch_dma_setup_ops. > >> > > > >> > > This restriction was added on purpose and the arm64 __generic_dma_ops() > >> > > now has a comment: > >> > > > >> > > /* > >> > > * We expect no ISA devices, and all other DMA masters are expected to > >> > > * have someone call arch_setup_dma_ops at device creation time. > >> > > */ > >> > > >> > how ? > >> > >> Usually by calling arch_setup_dma_ops(). > > > > Or of_dma_configure(), I forgot to mention this (see the > > pci_dma_configure() function as an example). > > the device is manually created, there's not OF/DT for it ;-) As for PCI, the created device doesn't have a node but the bridge does. Something like below, completely untested: -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index c679f63783ae..96d8babd7f23 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -32,7 +32,10 @@ int dwc3_host_init(struct dwc3 *dwc) return -ENOMEM; } - dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); + if (IS_ENABLED(CONFIG_OF) && dwc->dev->of_node) + of_dma_configure(&xhci->dev, dwc->dev->of_node); + else + dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); xhci->dev.parent = dwc->dev; xhci->dev.dma_mask = dwc->dev->dma_mask;