From patchwork Tue Mar 7 18:12:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 9609605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 062E96046A for ; Tue, 7 Mar 2017 18:13:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26FD27FA7 for ; Tue, 7 Mar 2017 18:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E47E928501; Tue, 7 Mar 2017 18:13:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79E7427FA7 for ; Tue, 7 Mar 2017 18:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=mCeCwxBp2cV62GbEK4c9KObCTpwIO10tbj5d9emh2us=; b=jwB 6pU3R1Dt37HsN9h9SBsqJSuQ4C4BAWWxBnD5NpUgcsRzJ6QyR39WjyaD4S/KYUH0qQlbXzHuqbzVO /8UUn5abVcGNA73dbUzqpW+SrRj66tlukYJKNV28fEjTXJ9cF+TTB+VJZJHP9q0C93jT6EP9AQYLU zg2FwB670Focps7GEpCGWfcvXuwGF114KHQ9d7h0wk5yLRbNpPAAXV+ifgnkYi6aFQOCls/PNYD5s xurcdZgn3MdygSfNWRk+D8JCWM6CTUZzpI6X4rgB4iHQUHi33sROf6nyr1N/nr7CdEkrB1jIDKZJt 6XyQcr3oXIpIxCJi2CeJRLlfKtT1otg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clJc7-0004TN-2k; Tue, 07 Mar 2017 18:13:35 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clJc2-0004LZ-5W for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2017 18:13:32 +0000 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 B44D014FF; Tue, 7 Mar 2017 10:13:09 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.210.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 98A4E3F220; Tue, 7 Mar 2017 10:13:08 -0800 (PST) From: Robin Murphy To: robh+dt@kernel.org, frowand.list@gmail.com Subject: [PATCH] of: Fix DMA mask assignment Date: Tue, 7 Mar 2017 18:12:51 +0000 Message-Id: <94ede94e98502a7948085fba5a16994d3805010c.1488910224.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.11.0.dirty X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170307_101330_265769_2FE1AA42 X-CRM114-Status: UNSURE ( 8.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Murali Karicheri , Arnd Bergmann , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As we start moving towards mandating that device DMA addressing capabilities are correctly described in DT for platforms like arm64, it turns out that actually assigning DMA masks wider than 32 bits from "dma-ranges" is made largely impossible by the current code. New PCI devices are passed in with 32-bit masks, while new platform devices are passed in with their masks unset, so we install default 32-bit masks for them. As a result, subsequently taking the minimum between any existing mask and the size given by "dma-ranges" means that we can never exceed 32 bits for the vast majority of devices. Since the DT can be assumed to describe the hardware appropriately, and the device's driver is expected by the DMA API to explicitly set a mask later when it probes, we can safely let "dma-ranges" unconditionally override any initial mask from device creation (and as a small bonus deduplicate the calculation in the process). CC: Arnd Bergmann CC: Murali Karicheri Fixes: 9a6d7298b083 ("of: Calculate device DMA masks based on DT dma-range size") Signed-off-by: Robin Murphy --- drivers/of/device.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index b1e6bebda3f3..9bb8518b28f2 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -129,15 +129,8 @@ void of_dma_configure(struct device *dev, struct device_node *np) } dev->dma_pfn_offset = offset; - - /* - * Limit coherent and dma mask based on size and default mask - * set by the driver. - */ - dev->coherent_dma_mask = min(dev->coherent_dma_mask, - DMA_BIT_MASK(ilog2(dma_addr + size))); - *dev->dma_mask = min((*dev->dma_mask), - DMA_BIT_MASK(ilog2(dma_addr + size))); + dev->coherent_dma_mask = DMA_BIT_MASK(ilog2(dma_addr + size)); + *dev->dma_mask = dev->coherent_dma_mask; coherent = of_dma_is_coherent(np); dev_dbg(dev, "device is%sdma coherent\n",