Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7276641imu; Wed, 14 Nov 2018 14:42:43 -0800 (PST) X-Google-Smtp-Source: AJdET5cKIZxLA4yyDSdnqlZh72gLv3kWk9Siq/SEaMa/WJLyzXi2CLcB5Vsu+macbIs85aeiGKep X-Received: by 2002:a17:902:da8:: with SMTP id 37-v6mr3830196plv.12.1542235362948; Wed, 14 Nov 2018 14:42:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542235362; cv=none; d=google.com; s=arc-20160816; b=uZ+IbngklcEhyjhIRENRFESoZpGq2bIqTf5GbJiIi9nt3MW5kItmbnlevTIPKFUq7j O+v87FQd6kYi6zC9HccAmLTQ7p9DQw9q3JV2pCE+uVwKOSESi2JwqwgKYW09eKcPdNN6 uKdY9YzYlxf/cN2s15RO5UF07O78dsDV2Op3kRc+W/b2tJOk/SCrKFlZJLeUiIH8ujL+ C8gUyKyB9GVltD6vh01NDH4xwkbXbInwqIiuRP8kA42oGJoqsPJLyZ5uk/9E4hiVnzyV GI5B9JNNZpEG0vC7bOlVxPastgAUGCP0mqU4MMwAl8Fe/JH/Zb4Xvn9/FLk2OlOH4GJd FsSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=YG+q6CEAg5mZkP4v8EYbWqyLUnmsGjW1V5cyHFapXGs=; b=b+nY4b7eeYYe2JZ5p0NvqlrnTef2RvYulXJzSb9+9zcAVD58AVOhwTM30mbsvwcsA5 0K0Opf/+cfMuyXp4e9xl0xw8s1Q0HR+V8r84FkJzgHcBI4Au1JqaUxyTqlDNqAT3TOfd VcqzI+LHOIG/6TRaZSZ9xbu/h2hztlHmFa0EChvmFlLVYcZpzCo1nWnwB2SFAl5a9jse tXcgLe5LVj3/BCyvPsRYVHKz6I0SV7PEhP2G3jq5isJctvUmiAmZMQt7nqZWQcBKvDVY 6u2zu4hLmQ4Efd2qgDVT+j4geL7mv9kd07CFH++aACgy5sjpBCWX0aQD4/KsEUitAwFU QHXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYLhixoL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14si13401238pgg.44.2018.11.14.14.42.28; Wed, 14 Nov 2018 14:42:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYLhixoL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387706AbeKOIrD (ORCPT + 99 others); Thu, 15 Nov 2018 03:47:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:34416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728859AbeKOI1X (ORCPT ); Thu, 15 Nov 2018 03:27:23 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B139722520; Wed, 14 Nov 2018 22:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234139; bh=5lI+K5NSyp7s4MwR6HKE1/hXONzq412IaY/HDK6pCYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYLhixoLdxYSt7IngROGVS4+Rf6WPdCNUSGCepuzAjfDPJllcrQKeOa7xktE7eBNY pvuJxTdNYyFpXH+XEsxfaSsk3garcm6CytAQorZs2z+WA7tUQAtAc3bTSdUbnwo+OU BgUnXBBqUGLK1A7B1UpJx9i8i0EUhEA8MJzOCZlM= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Robin Murphy , Rob Herring , Sasha Levin Subject: [PATCH AUTOSEL 4.19 48/73] of/device: Really only set bus DMA mask when appropriate Date: Wed, 14 Nov 2018 17:21:42 -0500 Message-Id: <20181114222207.98701-48-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robin Murphy [ Upstream commit 6778be4e520959659b27a441c06a84c9cb009085 ] 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 Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- 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 5957cd4fa262..40b9051a7fce 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", -- 2.17.1