From patchwork Mon Nov 25 17:18:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 3233481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 42AC29F3A0 for ; Mon, 25 Nov 2013 17:19:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13C32201BD for ; Mon, 25 Nov 2013 17:19:56 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C41352018B for ; Mon, 25 Nov 2013 17:19:54 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vkzp9-0005WZ-4k; Mon, 25 Nov 2013 17:19:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vkzp6-0008N5-D3; Mon, 25 Nov 2013 17:19:48 +0000 Received: from [2002:4e20:1eda::1] (helo=caramon.arm.linux.org.uk) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vkzp1-0008MK-Is for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2013 17:19:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=rshrIP+rV4nwH6fXnVp+hYynfJbIif10tUy6Q37NQKs=; b=cQOIkgthp0OIClxqmuS7PBHgKeWx2GPhOesXtiGDCbRuO5yYpjaUT3RsplotKqFhhM3qQ8EGZ3HteFADYcY/yEv88ztkui3et3uv++iw8hX15mYJYZEy+hmxx6AEKtZaKqxYrO8yuAHFbhsBDRyCEWmfTtZlLlhLT/3wtw292ss=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:60941) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1VkzoH-00016P-RI; Mon, 25 Nov 2013 17:18:58 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1VkzoE-0003dS-FF; Mon, 25 Nov 2013 17:18:54 +0000 Date: Mon, 25 Nov 2013 17:18:53 +0000 From: Russell King - ARM Linux To: Aaro Koskinen Subject: Re: ARM: v3.13-rc1: USB regression Message-ID: <20131125171853.GF25039@n2100.arm.linux.org.uk> References: <20131124222247.GC24645@blackmetal.musicnaut.iki.fi> <20131124224359.GE25039@n2100.arm.linux.org.uk> <20131125163302.GD24645@blackmetal.musicnaut.iki.fi> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131125163302.GD24645@blackmetal.musicnaut.iki.fi> User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131125_121944_452229_815E78B7 X-CRM114-Status: GOOD ( 23.18 ) X-Spam-Score: -1.2 (-) Cc: linux-omap@vger.kernel.org, linux-usb@vger.kernel.org, Alan Stern , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Nov 25, 2013 at 06:33:02PM +0200, Aaro Koskinen wrote: > Hi, > > On Sun, Nov 24, 2013 at 10:43:59PM +0000, Russell King - ARM Linux wrote: > > On Mon, Nov 25, 2013 at 12:22:47AM +0200, Aaro Koskinen wrote: > > > [ 33.967324] ohci ohci: Coherent DMA mask 0xffffffff (pfn 0xe0000-0xe0000) covers a smaller range of system memory than the DMA zone pfn 0x0-0x100000 > > > > > > I bisected this to 4dcfa60071b3d23f0181f27d8519f12e37cefbb9 (ARM: DMA-API: > > > better handing of DMA masks for coherent allocations). Reverting that > > > commit makes the USB work again fine. > > [...] > > > Better would be: > > > > #define __arch_dma_to_pfn(dev, addr) \ > > ({ unsigned long pfn = (addr) >> PAGE_SHIFT; \ > > if (is_lbus_device(dev)) \ > > pfn += PHYS_PFN_OFFSET - \ > > (OMAP1510_LB_OFFSET >> PAGE_SHIFT); \ > > pfn; \ > > }) > > > > Can you try that in arch/arm/mach-omap1/include/mach/memory.h please? > > Still doesn't work: > > [ 33.878790] ohci ohci: Coherent DMA mask 0xffffffff (pfn 0xfffe0000-0xe0000) covers a smaller range of system memory than the DMA zone pfn 0x0-0x100000 > [ 33.894019] ohci ohci: can't setup: -12 Well, that looks technically better, rather unfortunate that we end up going to negative PFNs though. Without that change, could you try this instead please: arch/arm/mm/dma-mapping.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index f0ea0134e5a3..a18cfc53f445 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -9,6 +9,7 @@ * * DMA uncached mapping support. */ +#include #include #include #include @@ -162,6 +163,8 @@ static u64 get_coherent_dma_mask(struct device *dev) u64 mask = (u64)DMA_BIT_MASK(32); if (dev) { + unsigned long max_dma_pfn; + mask = dev->coherent_dma_mask; /* @@ -173,6 +176,8 @@ static u64 get_coherent_dma_mask(struct device *dev) return 0; } + max_dma_pfn = min(max_pfn, arm_dma_pfn_limit); + /* * If the mask allows for more memory than we can address, * and we actually have that much memory, then fail the @@ -180,7 +185,7 @@ static u64 get_coherent_dma_mask(struct device *dev) */ if (sizeof(mask) != sizeof(dma_addr_t) && mask > (dma_addr_t)~0 && - dma_to_pfn(dev, ~0) > arm_dma_pfn_limit) { + dma_to_pfn(dev, ~0) > max_dma_pfn) { dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n", mask); dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n"); @@ -192,7 +197,7 @@ static u64 get_coherent_dma_mask(struct device *dev) * fits within the allowable addresses which we can * allocate. */ - if (dma_to_pfn(dev, mask) < arm_dma_pfn_limit) { + if (dma_to_pfn(dev, mask) < max_dma_pfn) { dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n", mask, dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,