Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5328597pxv; Wed, 21 Jul 2021 02:47:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4oM9FRo5cAgKuRHszvEeimw7FrTq8fQ2/4dUhxDhOxocTqZQ7Iv2GLreHSPB17DfwZlmn X-Received: by 2002:a92:d303:: with SMTP id x3mr25179048ila.212.1626860864695; Wed, 21 Jul 2021 02:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626860864; cv=none; d=google.com; s=arc-20160816; b=J3rv8ruSXolTicAMeMwJBCPYHjpBHG4qxPCIAOVT9TYo+WwopcQN/l9yF2ROentxWA 0yMNwfeqYOX7YkhVH1R5hmLx70wNEgRkk7+FPPz2UNq7hzh6+HuyWl0No9SkOxPujCvI 8y7cP/RTxRFSBPUEb3qrCfTfhaJ3qEk7KEQRQqudjYyhfJJVebdmsIdenpKmxpEXF+lX 4UPu43PP5XlKylOXpJMrnX5toFIlxPLcxGmoVOEF6eAOL886XWbD9iQhHOL/yzThYcvF AEyKsWJmibomepo0VhbxK61lsd+KZdAsoUv2s0v162oY3UDsr/SgeFXO/8F61xP3/MID GqHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=hGJJ1XtG7v5McTQW6h3eppiGqQoHCNicT4iUur4kdyk=; b=j5/phj9vq04aLv/IeuN2BDdl2G2k9zbWSI7DxO6GQgOpNpIMMStBqkjostgYWcOSy2 QHjLO9/RbbR2leqoJ89u98xQtDe4iW19zcs9MPZYzfWVY3uJeHUO1fpMjx6y13UywPF3 UUjwzOkzVtOe6W3si4EoLb5bVGWHBLclM/sMI+rWhWM5e2WMFLe9JFqKTX2a+ggcwYni lbM6RvsQXd2LUAUOzQ6j0iAogQomhrA09y/p6akJv58fvlyC7ZImZjYvmrcWramwmcaF TLbBuIlz+vEr/QEq8hzSRAfvXkljDBtYq5XyLXaUIp9Kmf0nyphju5q1TAmavvYqrpk3 Otmw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si26860449ilo.17.2021.07.21.02.47.33; Wed, 21 Jul 2021 02:47:44 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237393AbhGUJFs (ORCPT + 99 others); Wed, 21 Jul 2021 05:05:48 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:35490 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S236891AbhGUJDH (ORCPT ); Wed, 21 Jul 2021 05:03:07 -0400 X-UUID: 82db7ebf1ab742f789ea29cbd51c6732-20210721 X-UUID: 82db7ebf1ab742f789ea29cbd51c6732-20210721 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1811651001; Wed, 21 Jul 2021 17:43:17 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jul 2021 17:43:15 +0800 Received: from mszswglt01.gcn.mediatek.inc (10.16.20.20) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 21 Jul 2021 17:43:15 +0800 From: To: , , , , , , , , , , , , , CC: , Guangming Cao Subject: [PATCH] dma-heap: Let dma heap use dma_map_attrs to map & unmap iova Date: Wed, 21 Jul 2021 17:43:14 +0800 Message-ID: <20210721094314.117413-1-guangming.cao@mediatek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210715062405.98932-1-guangming.cao@mediatek.com> References: <20210715062405.98932-1-guangming.cao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guangming Cao On Thu, 2021-07-15 at 14:24 +0800, guangming.cao@mediatek.com wrote: > From: Guangming Cao > > On Thu, 2021-07-08 at 18:14 +0800, guangming.cao@mediatek.com wrote: > > Hi Sumit, Christian, Matthias, > > gentle ping for this patch :) move receviers to '--to' list. gentle ping for this patch :) > > BRs! > Guangming > > > From: Guangming Cao > > > > For dma-heap users, they can't bypass cache sync when map/unmap > > iova > > with dma heap. But they can do it by adding DMA_ATTR_SKIP_CPU_SYNC > > into dma_alloc_attrs. > > > > To keep alignment, at dma_heap side, also use > > dma_buf_attachment.dma_map_attrs to do iova map & unmap. > > > > Signed-off-by: Guangming Cao > > --- > > drivers/dma-buf/heaps/cma_heap.c | 6 ++++-- > > drivers/dma-buf/heaps/system_heap.c | 6 ++++-- > > 2 files changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma- > > buf/heaps/cma_heap.c > > index 0c05b79870f9..2c9feb3bfc3e 100644 > > --- a/drivers/dma-buf/heaps/cma_heap.c > > +++ b/drivers/dma-buf/heaps/cma_heap.c > > @@ -99,9 +99,10 @@ static struct sg_table > > *cma_heap_map_dma_buf(struct dma_buf_attachment *attachme > > { > > struct dma_heap_attachment *a = attachment->priv; > > struct sg_table *table = &a->table; > > + int attrs = attachment->dma_map_attrs; > > int ret; > > > > - ret = dma_map_sgtable(attachment->dev, table, direction, 0); > > + ret = dma_map_sgtable(attachment->dev, table, direction, > > attrs); > > if (ret) > > return ERR_PTR(-ENOMEM); > > a->mapped = true; > > @@ -113,9 +114,10 @@ static void cma_heap_unmap_dma_buf(struct > > dma_buf_attachment *attachment, > > enum dma_data_direction direction) > > { > > struct dma_heap_attachment *a = attachment->priv; > > + int attrs = attachment->dma_map_attrs; > > > > a->mapped = false; > > - dma_unmap_sgtable(attachment->dev, table, direction, 0); > > + dma_unmap_sgtable(attachment->dev, table, direction, attrs); > > } > > > > static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf > > *dmabuf, > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma- > > buf/heaps/system_heap.c > > index 23a7e74ef966..fc7b1e02988e 100644 > > --- a/drivers/dma-buf/heaps/system_heap.c > > +++ b/drivers/dma-buf/heaps/system_heap.c > > @@ -130,9 +130,10 @@ static struct sg_table > > *system_heap_map_dma_buf(struct dma_buf_attachment *attac > > { > > struct dma_heap_attachment *a = attachment->priv; > > struct sg_table *table = a->table; > > + int attrs = attachment->dma_map_attrs; > > int ret; > > > > - ret = dma_map_sgtable(attachment->dev, table, direction, 0); > > + ret = dma_map_sgtable(attachment->dev, table, direction, > > attrs); > > if (ret) > > return ERR_PTR(ret); > > > > @@ -145,9 +146,10 @@ static void system_heap_unmap_dma_buf(struct > > dma_buf_attachment *attachment, > > enum dma_data_direction > > direction) > > { > > struct dma_heap_attachment *a = attachment->priv; > > + int attrs = attachment->dma_map_attrs; > > > > a->mapped = false; > > - dma_unmap_sgtable(attachment->dev, table, direction, 0); > > + dma_unmap_sgtable(attachment->dev, table, direction, attrs); > > } > > > > static int system_heap_dma_buf_begin_cpu_access(struct dma_buf > > *dmabuf, > > -- > > 2.17.1 > >