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=-16.8 required=3.0 tests=BAYES_00, 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 1E46EC4320E for ; Tue, 31 Aug 2021 03:43:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02EAE6103A for ; Tue, 31 Aug 2021 03:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239736AbhHaDod (ORCPT ); Mon, 30 Aug 2021 23:44:33 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:47734 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S239719AbhHaDoa (ORCPT ); Mon, 30 Aug 2021 23:44:30 -0400 X-UUID: 4a0dc76cfe024ee08efc38d92901c77a-20210831 X-UUID: 4a0dc76cfe024ee08efc38d92901c77a-20210831 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1749306869; Tue, 31 Aug 2021 11:43:33 +0800 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 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); > >