Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3468328pxb; Mon, 30 Aug 2021 03:04:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4Ep6S9Ts/5Rg3kEHRWp+7w6YLs3+MSHIbtGNRzn3gorM6weP6fWPqP067L7H6widceFEL X-Received: by 2002:a17:907:2492:: with SMTP id zg18mr24011052ejb.233.1630317840759; Mon, 30 Aug 2021 03:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630317840; cv=none; d=google.com; s=arc-20160816; b=UaYK+35srCBOJptI2NecuiaAaFpidX6dG0QIeZnqWl3BSWMogYcnlhKX4gwUL//YRc uVTDvmUrvVFA69fWQ09Z/zqGNCbmSgNa3u7v71OP/Dy9vzzxXzXGx1StG/mns+w7804g JVk4rIvojf24WzJj4w6cUhlpjgOD6qGtW10IdmnmGdNHu4Jo1D4Ju5p7KeonE0djArYK 2eBZ78cQuTGFuiQ/os3/qA1X9JIC2IraQG1IudhRxP4bA+2i/ZkNNTHNrwe7DhuIp0/4 G+JdV5XnFZ6TtTcFfUbX+nEa181ORwQgsfyvyE4pb/S5D2BRVSYupgTYDQv3p7NX0MQD FlBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=zWipbgvhzQG5ErmPtaWfHsuejEJrpN/8NHdX8M41wug=; b=FjOEUF1gZ4MIQAhsCo1zaQknoUm7bNorB2cwoigq60MYa7FMb2iNYwKcZKZGqJB/g0 XN3l9jSjew98qdwTPFVGkE/2KcxsHC7Juqz+xvdp6yrcDRWru7mdnCa6idgjIl3iesFZ D3wTz40oCrJOxOox1ajta2gQKBIPHFiaR5iVgNiHR03PKjXZqRuvs1fyOuILwvZgnM1P THGzxTM7pJPhkz7nEH9Ih5AMgIzbxxWfvPqqrFZIsCu7TtR6lOqtN0LEDTHuBzn2dFX6 zvLHPd3XReB9fcaYhJ6l66+PNWfYPxArdsteunYkt791H33uWHxOnMEHHr6p7QLOhF3o w4kQ== 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 u21si14296608eds.43.2021.08.30.03.03.25; Mon, 30 Aug 2021 03:04:00 -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 S235604AbhH3KCE (ORCPT + 99 others); Mon, 30 Aug 2021 06:02:04 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:50626 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229901AbhH3KCD (ORCPT ); Mon, 30 Aug 2021 06:02:03 -0400 X-UUID: bd3f7cf9dd6f49a9be901ad15ee81456-20210830 X-UUID: bd3f7cf9dd6f49a9be901ad15ee81456-20210830 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1520126050; Mon, 30 Aug 2021 18:01:08 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 30 Aug 2021 18:01:07 +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; Mon, 30 Aug 2021 18:01:06 +0800 From: To: Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , =?UTF-8?q?Christian=20K=C3=B6nig?= , Matthias Brugger , "open list:DMA-BUF HEAPS FRAMEWORK" , "open list:DMA-BUF HEAPS FRAMEWORK" , "moderated list:DMA-BUF HEAPS FRAMEWORK" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" CC: , Guangming Cao Subject: [PATCH] dma-buf: heaps: remove duplicated cache sync Date: Mon, 30 Aug 2021 18:01:38 +0800 Message-ID: <20210830100139.15632-1-guangming.cao@mediatek.com> X-Mailer: git-send-email 2.17.1 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 Current flow, one dmabuf maybe call cache sync many times if it has beed mapped more than one time. 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. 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); -- 2.17.1