From patchwork Tue Nov 6 11:54:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10670177 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 2DF7E15E9 for ; Tue, 6 Nov 2018 11:54:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2BB2A332 for ; Tue, 6 Nov 2018 11:54:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1FA92A33C; Tue, 6 Nov 2018 11:54:43 +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 7559E2A332 for ; Tue, 6 Nov 2018 11:54:43 +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=mdQTpBLLg4IHTcRQeA9dhX+BB0zRI2IouOkXnyuc/gU=; b=PerUdJQ1RfIfNK VZv2cLDJtCnpSb9lHaZbiD0PGkvGCeM0W2gdcecxwl6bNCWtEfxac1nEi+sCsgNFvdGPgdbNqJY6V 8dXpTghAjsojgp+7goj5noGavootUuP4I9hiC3KgJGBmaGvP1wJ+L4Y5FolPi2egXMVnogMzQda70 VZhzmswpCuUKyOHNeg5gbopcEXXHBqrsY+FDwbFLEfTFPg/NDa3s2xtlHmd3SuuTbh70uBRZ2cMmC 1hgUXMdgatDMVohcxxvOSYOodDLlZ4RIl+0fI7ubq4QO90+rKHqf199EZ5JkceaysSVKjuwmojJ3r cZMKtwT35qybMHhzBoIA==; 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 1gJzwL-0005ZN-9O; Tue, 06 Nov 2018 11:54:37 +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 1gJzwK-0005ZH-3V for linux-arm-kernel@bombadil.infradead.org; Tue, 06 Nov 2018 11:54:36 +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=xim4pPtUTPVEVENYFJMhSsMCD1mjnh41/dS6tCF6pss=; b=PkPlv2l5WDsAh1jcHgt7gQWx6G WXYqWMwc6S0usC7A1kGthM15RDENLp/+HndZ5svnTeHqMxyVoHVoH8lh+NIF292guTRXJE7+v9ssd jkNC8jP9uPRv4zztiZLc46J3lOYEfl91+bxP/GbBBJhVa5Vv1d0W/gEJVnhwSsy7l0nZWKAkfomYt IGAbI+yIXDiwEib9lNra650obGIW+3hnz6FayGiglXXfCZiTPxmsXXvMieehhPiubM0jEm8cYooue wMb3SH/+ws4eyrXgrUsFKX4TzzWWHdN40kRSHqADCVZML4kdwSq+ikKCm634UDlXUdMsMBU6zK9QI cQuNx1CA==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJzwG-0007Qe-T9 for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2018 11:54:34 +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 12A70A78; Tue, 6 Nov 2018 03:54:21 -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 468323F5CF; Tue, 6 Nov 2018 03:54:19 -0800 (PST) From: Robin Murphy To: hch@lst.de, robh+dt@kernel.org Subject: [PATCH] of/device: Really only set bus DMA mask when appropriate Date: Tue, 6 Nov 2018 11:54:15 +0000 Message-Id: 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-20181106_115433_074897_0D4B2776 X-CRM114-Status: GOOD ( 12.58 ) 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, aaro.koskinen@iki.fi, jean-philippe.brucker@arm.com, linux-mips@linux-mips.org, iommu@lists.linux-foundation.org, john.stultz@linaro.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com 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 Signed-off-by: Robin Murphy Tested-by: Aaro Koskinen Tested-by: John Stultz Tested-by: Geert Uytterhoeven Tested-by: Robert Richter --- Sorry about that... I guess I only have test setups that either have dma-ranges or where a 32-bit bus mask goes unnoticed :( The Octeon and SMMU issues sound like they're purely down to this, and it's probably related to at least one of John's Hikey woes. Robin. drivers/of/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 0f27fad9fe94..757ae867674f 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -149,7 +149,8 @@ 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; + if (!ret) + dev->bus_dma_mask = mask; dev->coherent_dma_mask &= mask; *dev->dma_mask &= mask;