Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp810791imu; Tue, 20 Nov 2018 07:18:46 -0800 (PST) X-Google-Smtp-Source: AJdET5c7Lj74+6OqJiUCYbwudGNJnTz3cfi//zySgbEzq3sJScbSVC4wpzL31BDJhJXf6IW/b48d X-Received: by 2002:a62:29c4:: with SMTP id p187-v6mr2601307pfp.62.1542727126762; Tue, 20 Nov 2018 07:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542727126; cv=none; d=google.com; s=arc-20160816; b=JNI2zdz9OZcrUGcWMcpiGvjLYZIbZbb57KCkvcpfiQXeBsLM4w7ZJeQYs/NyF9YV2n xkIk+VbbdtgCjKj7x9dyaExkEc5yju/ninzMdjW5QfXYR+Ty8iaveuZMXT8uEBN8G9iB LVcRC+OBlGgZ8RdTEnr2ntBY26i4Rw2jYJ0vOJgGYw/8z3ZpSjmWTGEgE8OykBwAin2E LbYoA06rSKYhdO2/+Cafrot7/0hXuf/pEGJv5810Rt2H4dyHDUelrdw5J5mf2teAAsyO o+TvLXBKtlIaKv8KUbZxiY6Piz5qf73dqz7zZJ86M3Cuqrp1FWVWKGlq2on3YcwFCEN7 Z9hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aBxL7mnVL6jMWl1rhJvgZAnSP2ekQ2vOtmS4k1O300g=; b=xVm2FpKu+27eB0Z+qkCdw0O6hLkd58lIv++kCFW3pl8FJF+BgTTinKYpecfVYDUoKT 333ikiSELXJWqQz0qhWt73hyggQ+2Ld8VsdpqvNe5TDJe/Q8sTDAHitKl+n8fdQF3RIT wOghya+QF3fnN3H77ZQFYHdNwMZf/Y+ivW4ZJ5n6VSAbrfQEGcynl1sRogadLY9LlcX5 OqlYj3bkNoy48ISWFTHeA0G9Q0UU4ey/Ta98EmL/GpS3goFUOpytkcbN/iQKdayUDOkj mYiMljw9BD/cWlHkGeQhMY76PAF2u3TOtpMXkhM0nszF73CajwRGZpYYTqZnh/5eNecK qYJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Dm7o7QRV; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6-v6si50516007pfa.162.2018.11.20.07.18.31; Tue, 20 Nov 2018 07:18:46 -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=@oracle.com header.s=corp-2018-07-02 header.b=Dm7o7QRV; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbeKUBTr (ORCPT + 99 others); Tue, 20 Nov 2018 20:19:47 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:52930 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbeKUBTr (ORCPT ); Tue, 20 Nov 2018 20:19:47 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAKEhw8t194790; Tue, 20 Nov 2018 14:49:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=aBxL7mnVL6jMWl1rhJvgZAnSP2ekQ2vOtmS4k1O300g=; b=Dm7o7QRVjgUVpOqJKnSwAS89YYW/UpGsldILXXVEe7b55guqUPafCb9ZT+AJHjL0jKu0 JJdTw8vwGrILcT+Z6VEJmiwA7IwiMtxQhy6Xv28PTFUf0ntGN+XsWw1tegCIYelTszF7 EUy5eyCbYS+cshbjtzfnv8LuAH98+/+un67klUEwDymo/vj/qK+r0KI+y2oCDh5K3l+Y dCUFE+1oRKBUugdHbnFyrShbbrwKvVxlz5HzOSGfyBZ4xaBxfN2FfplwL6mkR12XCfo3 NuhOkjFH//N0gxIAfLXdJNjxb4Ft741t1ttMOy7utc5IFlpkDoTQjNjh5E86Lbzl3cP0 4w== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2ntadtvbx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 14:49:46 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAKEnjrN010619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 14:49:45 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAKEniPr005325; Tue, 20 Nov 2018 14:49:44 GMT Received: from char.us.oracle.com (/10.152.32.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Nov 2018 06:49:44 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 38D206A00D4; Tue, 20 Nov 2018 09:49:43 -0500 (EST) Date: Tue, 20 Nov 2018 09:49:43 -0500 From: Konrad Rzeszutek Wilk To: Robin Murphy , sstabellini@kernel.org Cc: hch@lst.de, 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: Re: [PATCH 2/2] swiotlb: Skip cache maintenance on map error Message-ID: <20181120144943.GI10917@char.us.oracle.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9082 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 02:09:53PM +0000, Robin Murphy wrote: > 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. +Stefano > > 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 >