From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 692F7C432BE for ; Tue, 31 Aug 2021 03:55:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28A676102A for ; Tue, 31 Aug 2021 03:55:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 28A676102A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6Moksay3v9W7f02lolGvDPehmS1ExVfkYKeW6/9V7+s=; b=STA+TBftqciLr3 0KMwN0hUt8eV6ndEZSxd+KPmzGWmze5SLlrtQSo6ZBbK6cL1n3oaABgaGzHBaJfZ3RpD6y3z//PoX jUf//K8X/yHIV/YDgTHGQCcPLX8ey2Yb9APmGRdJGVWBVQEAVoWQE7RPf4lJ86o99yMptG6+orR9e 7t/toYjF0qe61GInR98WpPx/vrPcZ1Lk7LIZ8xu/Is7wGqD7pA0FS+dikf/Di0dxvftn3pb9acMzT l0pb25Xr1xy8Rg0rtVufAdXn+CR7gLSyuo9/sHoimmNzMlIkUattnp2xgVlCIcc50KpH1ckQHLD/e u0qgTeb0iN63xDBZenNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKuqM-001Gm9-6m; Tue, 31 Aug 2021 03:53:50 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKuqC-001GkN-7p; Tue, 31 Aug 2021 03:53:45 +0000 X-UUID: 18d39a8935644af59212fa88ca7ec5d9-20210830 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=JCdRt+uZc+mwIztiZuv3cr7/l1oRjxzYihOKX3FYxpM=; b=c/QrTw6WazkqCSCxAazRvmKCeOcBdXzHikajsNvXif/uOwN0X+AyVQ+y2a2sOYgxnQxx9Z0qLXnYh5wEbGTOasQlLuSFUTpDBMI3fTnoWxYvORJzbYe8AiUNgfqiCcu01B3/a6a8dhh0kY/rFAODJQSI9QIarqdHNdybia8myok=; X-UUID: 18d39a8935644af59212fa88ca7ec5d9-20210830 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 888466023; Mon, 30 Aug 2021 20:53:36 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 30 Aug 2021 20:43:33 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 11:43:32 +0800 Received: from mszswglt01.gcn.mediatek.inc (10.16.20.20) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 31 Aug 2021 11:43:31 +0800 From: To: CC: , , , , , , , , , , , , , , , Guangming Cao Subject: Re: [PATCH] dma-buf: heaps: remove duplicated cache sync Date: Tue, 31 Aug 2021 11:44:05 +0800 Message-ID: <20210831034405.41916-1-guangming.cao@mediatek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210830_205340_336242_49C3AD45 X-CRM114-Status: GOOD ( 21.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Guangming Cao > Am 30.08.21 um 12:01 schrieb guangming.cao@mediatek.com: > > From: Guangming Cao > > > > Current flow, one dmabuf maybe call cache sync many times if > > it has beed mapped more than one time. > > Well I'm not an expert on DMA heaps, but this will most likely not work > correctly. > All attachments of one dmabuf will add into a list, I think it means dmabuf supports map more than one time. Could you tell me more about it? > > Is there any case that attachments of one dmabuf will points to > > different memory? If not, seems do sync only one time is more better. > > I think that this can happen, yes. > > Christian. > Seems it's a very special case on Android, if you don't mind, could you tell me more about it? > > > > > Signed-off-by: Guangming Cao > > --- > > drivers/dma-buf/heaps/system_heap.c | 14 ++++++++------ > > 1 file changed, 8 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c > > index 23a7e74ef966..909ef652a8c8 100644 > > --- a/drivers/dma-buf/heaps/system_heap.c > > +++ b/drivers/dma-buf/heaps/system_heap.c > > @@ -162,9 +162,10 @@ static int system_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, > > invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); > > > > list_for_each_entry(a, &buffer->attachments, list) { > > - if (!a->mapped) > > - continue; > > - dma_sync_sgtable_for_cpu(a->dev, a->table, direction); > > + if (a->mapped) { > > + dma_sync_sgtable_for_cpu(a->dev, a->table, direction); > > + break; > > + } > > } > > mutex_unlock(&buffer->lock); > > > > @@ -183,9 +184,10 @@ static int system_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf, > > flush_kernel_vmap_range(buffer->vaddr, buffer->len); > > > > list_for_each_entry(a, &buffer->attachments, list) { > > - if (!a->mapped) > > - continue; > > - dma_sync_sgtable_for_device(a->dev, a->table, direction); > > + if (!a->mapped) { > > + dma_sync_sgtable_for_device(a->dev, a->table, direction); > > + break; > > + } > > } > > mutex_unlock(&buffer->lock); > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel