From patchwork Wed Nov 7 16:30:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10672627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3C051751 for ; Wed, 7 Nov 2018 16:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1050288E4 for ; Wed, 7 Nov 2018 16:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8F422CBAD; Wed, 7 Nov 2018 16:30:57 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 1DD9F2CB09 for ; Wed, 7 Nov 2018 16:30:57 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=WfWMThjujgj8menc2/GcOIVRrY3Hi0PZgMsDZk2ebYM=; b=WPm49gQJkzdEKk 1iYTJki1Tq7Asbwc+UKMHjkdGr8v5eDELIoH8t8Xrv3ZvFMWw3O1ZeLoWhIkWbmpaSl8u29WBhe5A TXQ1XozZsK80VqoB9jLuI0vAw5JU6Z/WOiUqwMyp0/m24DhNj+/nzJfK7SnXaDSPFGrZcyCJblG4z 6FCsekXgEqMQviUZJpcCyi/38xGFZmuFRCIUG8lF38iC5xi2zmMWFiZ1IA0SUPbgpcCe4P/CCEUVa uKiVj1mLTYskM+Qtm7SrcrWTUUCl+FU8lrHWcEe5JS9esjTavZhlbQD6uxaMjnw8cYosKXMzIz+Le r81TwvF+s20LDPD8PZeQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKQjG-0000fU-K7; Wed, 07 Nov 2018 16:30:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKQjE-0000fN-JS for linux-arm-kernel@bombadil.infradead.org; Wed, 07 Nov 2018 16:30:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RvRFLXqxcfsm4O0KokrnxjN6Sq6hVJOmt7N9sT+OPrM=; b=jvC29Fr/X59SvKGPGCb3ZFLUs0 H4/AgmEZX/uaY1hUgxvRCGlAp1zGmywC34FKKKIX+VCUGSnD+6qVxLkZWUeWz5slcTj80N62iY5Cz BVoykl+dxBnCbMiNw7uiIibQ9OGUyfO0Jojo105sQLgPOeMS5a2TQBT1xDMrjYzHlIl5UOe1rcyOf 0WOmzA71YQ0GDVsAGXTW5fmS4aB7xA3V27UdeNBo1A76LHpWWqVAgEkW2cVAnYNfXXYrNQoUrxYRD WZ6slj30G5cDvAhPqEVzZ1EhCqZ0qViZFF8mAXE/0fIvBBuj/V1YxCfZkzu8ld/JoGyIDCxHgjq3f VNPZG1Ww==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKQjB-0000qL-I0 for linux-arm-kernel@lists.infradead.org; Wed, 07 Nov 2018 16:30:51 +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 CFA2380D; Wed, 7 Nov 2018 08:30:38 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C01433F5BD; Wed, 7 Nov 2018 08:30:37 -0800 (PST) From: Robin Murphy To: robh+dt@kernel.org Subject: [PATCH v2] of/device: Really only set bus DMA mask when appropriate Date: Wed, 7 Nov 2018 16:30:32 +0000 Message-Id: <43b231d67abf2dc589af1c3b9d4f01211cda0b89.1541608043.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.19.1.dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181107_163049_729312_7559681E X-CRM114-Status: GOOD ( 11.82 ) 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, iommu@lists.linux-foundation.org, hch@lst.de, linux-arm-kernel@lists.infradead.org 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 of_dma_configure() was *supposed* to be following the same logic as acpi_dma_configure() and only setting bus_dma_mask if some range was specified by the firmware. However, it seems that subtlety got lost in the process of fitting it into the differently-shaped control flow, and as a result the force_dma==true case ends up always setting the bus mask to the 32-bit default, which is not what anyone wants. Make sure we only touch it if the DT actually said so. Fixes: 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate") Reported-by: Aaro Koskinen Reported-by: Jean-Philippe Brucker Tested-by: Aaro Koskinen Tested-by: John Stultz Tested-by: Geert Uytterhoeven Tested-by: Robert Richter Signed-off-by: Robin Murphy --- v2: Add comment, collect tested-by tags drivers/of/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 0f27fad9fe94..5592437bb3d1 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -149,9 +149,11 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) * set by the driver. */ mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1); - dev->bus_dma_mask = mask; dev->coherent_dma_mask &= mask; *dev->dma_mask &= mask; + /* ...but only set bus mask if we found valid dma-ranges earlier */ + if (!ret) + dev->bus_dma_mask = mask; coherent = of_dma_is_coherent(np); dev_dbg(dev, "device is%sdma coherent\n",