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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06D10C433F5 for ; Wed, 13 Apr 2022 05:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232349AbiDMFCY (ORCPT ); Wed, 13 Apr 2022 01:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiDMFCW (ORCPT ); Wed, 13 Apr 2022 01:02:22 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D77225E1 for ; Tue, 12 Apr 2022 22:00:02 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 6C12F68B05; Wed, 13 Apr 2022 06:59:58 +0200 (CEST) Date: Wed, 13 Apr 2022 06:59:58 +0200 From: Christoph Hellwig To: Chao Gao Cc: Robin Murphy , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, m.szyprowski@samsung.com, hch@lst.de, Wang Zhaoyang1 , Gao Liang , Kevin Tian Subject: Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb Message-ID: <20220413045958.GA31209@lst.de> References: <20220412113805.3210-1-chao.gao@intel.com> <20220413010157.GA10502@gao-cwp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220413010157.GA10502@gao-cwp> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 13, 2022 at 09:02:02AM +0800, Chao Gao wrote: > dma_direct_sync_single_for_cpu() also calls arch_sync_dma_for_cpu_all() > and arch_dma_mark_clean() in some cases. if SWIOTLB does sync internally, > should these two functions be called by SWIOTLB? > > Personally, it might be better if swiotlb can just focus on bounce buffer > alloc/free. Adding more DMA coherence logic into swiotlb will make it > a little complicated. > > How about an open-coded version of dma_direct_sync_single_for_cpu > in dma_direct_unmap_page with swiotlb_sync_single_for_cpu replaced by > swiotlb_tbl_unmap_single? I don't think the swiotlb and non-coherent case ever fully worked. Before the merge of swiotlb into dma-direct they obviously were mutally exclusive, and even now all the cache maintainance is done on the physical address of the original data, not the swiotlb buffer. If we want to fix that properly all the arch dma calls will need to move into swiotlb, but that is a much bigger patch. So for now I'd be happy with the one liner presented here, but eventually the whole area could use an overhaul.