From patchwork Tue Nov 20 14:09:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10690807 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 7F75815A7 for ; Tue, 20 Nov 2018 16:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D66F2A323 for ; Tue, 20 Nov 2018 16:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F1EE2A8DE; Tue, 20 Nov 2018 16:46:00 +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 E851F2A323 for ; Tue, 20 Nov 2018 16:45:59 +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:References:In-Reply-To: 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: List-Owner; bh=j6u1lEB1Pi3A2hpD1/snuZSh4V9pnz+VLCT2sfPfs/Y=; b=g73SBxV2DXqrBl emXDWtNeAZn3zRzN/qVcqNz+j6b2BqpPEGv0SJFoC0JxKtu/hVJ2w/U1jkYAlNGTsV9oaRU+ILcgt 66dkozf2U+iMPSG/y++FM6Pi1biWVitZI0MLxrhWXddsPQxeLA8lmliGuMJDbG/U6iaZKel4cAFtv MmXFSIhzxnqtCEnZw229/38qVdKWIKPh/Y4Y0y2xHSWXIDeV7+/wOHGAElNcCqGXeAYbvZfgQJi4+ 6vcD9wJJVuese+0Aq4dXJZNiaS8x6WAc1uVXwXAiuJJEII5nFDqGb2Xj+7Loh9ntsgFBuByRrzxab xZc4/sf5Oq0nBixHDlNQ==; 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 1gP99y-0004wG-Be; Tue, 20 Nov 2018 16:45:58 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8ku-0000yR-L3 for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Nov 2018 16:20:05 +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: References:In-Reply-To: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:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xARdDvKXKf2h2wqBYnjBquOUrLDwtc4DCZuwqi66wXI=; b=a5dK/dugRjskfYU1iyfY1JD/nW KJBUIEReEChI1kcvOs4Oc97zspp4jwWFUqc0yip19+g3u5to7I24cMb2HYA0hfca4SUjeCGRkfJmE vWNcJLZhWbyPlUZXj+hnIrOCqkyg8rmFn5RV8kYfrisWn5p1NVcGHf0sKPKcZkpjjcZQ55g3hEO5m H4sqUmH6PeQom7yz9Cyhvg7pYMzncolpc+MsaOrFLMBpgMffRaRQX6mmmRU40kxkZAlTqb+PLgpCx zAyMTwHHq938a75m5JSfRLyy79Y2NEmKBGcphjLG/2dQQt5Q6u0xdMHZduKLCaiOs04dCdidMl+Pf asrErVkg==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP6jP-0007wp-Vs for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 14:10:26 +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 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_141024_168414_3CE2768A X-CRM114-Status: UNSURE ( 9.88 ) 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: iommu@lists.linux-foundation.org, john.stultz@linaro.org, linux-kernel@vger.kernel.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 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;