Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp856507imu; Tue, 20 Nov 2018 08:00:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/V20rcUmrHSi9Y3dDoTOhkdenEJNGI8d5sKlL4CtMV549VwXAXETn9o8Zo3iTVvGUIu9Tqf X-Received: by 2002:a63:3d03:: with SMTP id k3mr2382075pga.191.1542729657233; Tue, 20 Nov 2018 08:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542729657; cv=none; d=google.com; s=arc-20160816; b=m2vHVAMHI3/tsK97JSiJEfZpO2k2ZSHi4Tf4v+uEfO6BZ8k4KTvsV2FKNATEzX/uYS zyfXD1mHT3duQDCfEZmMKrTQ+KcC2XYI5+JmwgtXEXU/QyusExnl6LxyZkLiciwuU2Lb riEKfy43li5BWtj6nPw217EaEavpeaB5BznXw2gFoe1iR6gq2B6qqTvf5aqAxTyAaK0M Krmal7GGg6l8mKS/Xr6IeB8Dj9XFGbuNAEljN6CxYBJtQRsHZv5BQCZSmehDNVkzMqUh 0WjYMNdiBp4UwuzlcC62KRlhw7URfqduzskyXSedBPqlmQ2kKWblzEw8iKAmTfFdPWHB bTLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xARdDvKXKf2h2wqBYnjBquOUrLDwtc4DCZuwqi66wXI=; b=w0CyBkIhL5YKRjGD2/BhFH7xnMEo8A0xLBF+F2TJn2XlvtYuaBTXlAquoNt8hRYzs8 zLjf5SkOYbX5AA2ZqvIAiA8qAROwvGWV3vytPXwmcG/Ch3FzCoQSh6zDsnUxApcvtHCF NnmKi4+mvEHKn+qvT+7RTRAieaM7tuktGA0oxbKzbYaERAddY1F/aa27oC8UwiedQTnK Mn/lHqOEi8maKWnc7z17hMtlFSgKbv0J8uxUwTAyMWQAY2bwnRgdK3AilNE9TakFx1NA 7E6DRnVtRjQ7+wBsTBrfwgnt9pPNVTnb2orB3Lf7sNiCEYi4OUcVXgQiM4TZ+gWidd3g crtA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32-v6si46322752pld.70.2018.11.20.08.00.41; Tue, 20 Nov 2018 08:00:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729270AbeKUAjc (ORCPT + 99 others); Tue, 20 Nov 2018 19:39:32 -0500 Received: from foss.arm.com ([217.140.101.70]:49432 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbeKUAjc (ORCPT ); Tue, 20 Nov 2018 19:39:32 -0500 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 84E9115BE; Tue, 20 Nov 2018 06:10:12 -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 261053F5A0; Tue, 20 Nov 2018 06:10:11 -0800 (PST) From: Robin Murphy To: hch@lst.de, konrad.wilk@oracle.com Cc: m.szyprowski@samsung.com, john.stultz@linaro.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] swiotlb: Skip cache maintenance on map error Date: Tue, 20 Nov 2018 14:09:53 +0000 Message-Id: X-Mailer: git-send-email 2.19.1.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If swiotlb_bounce_page() failed, calling arch_sync_dma_for_device() may lead to such delights as performing cache maintenance on whatever address phys_to_virt(SWIOTLB_MAP_ERROR) looks like, which is typically outside the kernel memory map and goes about as well as expected. Don't do that. Fixes: a4a4330db46a ("swiotlb: add support for non-coherent DMA") Signed-off-by: Robin Murphy --- kernel/dma/swiotlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 5731daa09a32..045930e32c0e 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -679,7 +679,8 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, } if (!dev_is_dma_coherent(dev) && - (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) + (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0 && + dev_addr != DIRECT_MAPPING_ERROR) arch_sync_dma_for_device(dev, phys, size, dir); return dev_addr; -- 2.19.1.dirty