Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp481860pxt; Thu, 12 Aug 2021 03:04:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLcUehqFIPYV+sLxamadAgEtTBkMjr3wzIPSsOFl3qRm17k3SHVepFZ4pRMqkySnL5hDkz X-Received: by 2002:a05:6402:4243:: with SMTP id g3mr4664388edb.254.1628762698388; Thu, 12 Aug 2021 03:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628762698; cv=none; d=google.com; s=arc-20160816; b=r49TtEfvFQ6oqNAyfZtNzNzQxgQQEwS54cLjlqbZ2lt/TfZcOgOUsPljcOJVL5BwTn obF2Sle2NfaYXsjU/t4UOMx1WxiZsqi2KDMlesw/woKVZ5r+8JXrmtlgv+WM6KVZYTdA QL3KY5Oqx+GAIHBohPzlPLz99/uE2u6vIp4YQmG5Ymzl0B4BfRGClehUmIkCljp1lkYz 0bkn/gll0DnIdykFoYPWH2QUa19NlOvBw+Mowy3IMbUSMC+/KL5W0PDBLuc9vnffRowv 4u4H+xxePP3oQV4RDoUjWxYObKL6B9+fpPjImA60xrYZbdTScigzj0k9F40oDqOwNnyq PP/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SmZ+/nyBNyi7W1OAT4slsmhGWuIvjhgj8UeehGa0k/Y=; b=ZSBfUVLt0M6vVl0toJEHDHvx8Ci9u7nB1wFSb0dVJCPfs6Hx6MzBwFiD8TRM9D3qrj hICQ48iA9BDbWIVoMEiAXfYngpPPehYaSWkgnqCWhxsBaSdkpPZhdra0+gE+E9EqZKB+ 8HMp2nm1iHrvSH9l6QX+7mnoJqf1qTmd69//UbEXCbav2uepmt7q0qpn2W4sH4WfJiSB ++1mrRhrhREO9lyLPtjkjpGVqEGo8+Noy6lmN/k2mCryzdfOAM5C+SXIP5g88Ii0oSa/ cmKEoTm+trQuB2OWAQ22iYsqg9Uiz4ZagRu1QRPlQkqSXW6wFjc4XRgc65bMBmTvUfiT GnjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hVjYySTS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e21si1979837ejb.96.2021.08.12.03.04.34; Thu, 12 Aug 2021 03:04:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hVjYySTS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235695AbhHLJWC (ORCPT + 99 others); Thu, 12 Aug 2021 05:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236005AbhHLJWB (ORCPT ); Thu, 12 Aug 2021 05:22:01 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB3CFC061765 for ; Thu, 12 Aug 2021 02:21:28 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id x12so2722966qvo.12 for ; Thu, 12 Aug 2021 02:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SmZ+/nyBNyi7W1OAT4slsmhGWuIvjhgj8UeehGa0k/Y=; b=hVjYySTSr0mjWPr6vJnVDO+D69tCC702LiCJ7rDBEZ8U0jtHIsGHwHbhAUChGNDAQT OSReT1EQFc2WwI8Cf0k/ghW7OzOe19N/C1NkQCb0SsByX0aMrEBtVsUdHa+2KoC/+SF+ dnayMuuUuEmRW/in/Hyw2px4iqdls/d/ae7u8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SmZ+/nyBNyi7W1OAT4slsmhGWuIvjhgj8UeehGa0k/Y=; b=XRRu+2sr+OYEPNpsxrOBaDHWR6XOaI0YKiigm8r3UXfQup6rtulkWeVD4S4XOIZCCX loa0FV4n97HADkVemnZkXI1j1erUpP9daSigomt/TqMNbvoacHyNg6siDzJMvgDN1Fly u5vWl6wBTX+9tZ9dyYjMCPwHfCyjdo3wZgGKSEOg/j+n0YhvP8Lus8QRi1ayAsjzrgzQ EFMRYuoCALgO1OX4kzAccgMoFyqDGJZ/jRTMfGe9uWQaquMZ4hw6YY0It8SRl22z/zRO Ah1EGqtnGUS4P2C3YzX2ouew0k9xOaDIN2vGBiVNNDNW/Xhv0//a812/fYwdv1lLxinT 07RQ== X-Gm-Message-State: AOAM532GwgTY3XNyBDwXuHxPaZRzue2vcG8RHIoFoWLfpDSxL8ePcGI+ lpqi8fqUNisSZbyZquQx7KVbhgGYl3TiQHLNkP9qPg0zh4YMOA== X-Received: by 2002:a05:6214:2247:: with SMTP id c7mr2902170qvc.52.1628760087852; Thu, 12 Aug 2021 02:21:27 -0700 (PDT) MIME-Version: 1.0 References: <20210811024247.1144246-1-stevensd@google.com> <20210811024247.1144246-3-stevensd@google.com> <5b4fd891-a86a-42cd-5b69-bc08d351dd3a@arm.com> In-Reply-To: <5b4fd891-a86a-42cd-5b69-bc08d351dd3a@arm.com> From: David Stevens Date: Thu, 12 Aug 2021 18:21:16 +0900 Message-ID: Subject: Re: [PATCH v3 2/5] dma-iommu: fix arch_sync_dma for map To: Robin Murphy Cc: Will Deacon , Joerg Roedel , Lu Baolu , Tom Murphy , iommu@lists.linux-foundation.org, open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 12, 2021 at 3:47 AM Robin Murphy wrote: > > On 2021-08-11 03:42, David Stevens wrote: > > From: David Stevens > > > > When calling arch_sync_dma, we need to pass it the memory that's > > actually being used for dma. When using swiotlb bounce buffers, this is > > the bounce buffer. Move arch_sync_dma into the __iommu_dma_map_swiotlb > > helper, so it can use the bounce buffer address if necessary. This also > > means it is no longer necessary to call iommu_dma_sync_sg_for_device in > > iommu_dma_map_sg for untrusted devices. > > > > Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers") > > Signed-off-by: David Stevens > > --- > > drivers/iommu/dma-iommu.c | 16 +++++++--------- > > 1 file changed, 7 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > > index 54e103b989d9..4f0cc4a0a61f 100644 > > --- a/drivers/iommu/dma-iommu.c > > +++ b/drivers/iommu/dma-iommu.c > > @@ -576,6 +576,9 @@ static dma_addr_t __iommu_dma_map_swiotlb(struct device *dev, phys_addr_t phys, > > memset(padding_start, 0, padding_size); > > } > > > > + if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) > > Make that an "else if" - otherwise you're just reintroducing the same > thing that the third hunk is trying to clean up. swiotlb_tbl_map_single only copies into the swiotlb buffer, it doesn't do any architectural syncing. So this block is necessary in the swiotlb case as well, for iommu_dma_map_page to work properly. The third chunk is a separate optimization, so I'll split it out into its own patch. -David