All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chao Gao <chao.gao@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Wang Zhaoyang1 <zhaoyang1.wang@intel.com>,
	linux-kernel@vger.kernel.org, Gao Liang <liang.gao@intel.com>,
	iommu@lists.linux-foundation.org,
	Robin Murphy <robin.murphy@arm.com>,
	hch@lst.de
Subject: Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb
Date: Wed, 13 Apr 2022 06:59:58 +0200	[thread overview]
Message-ID: <20220413045958.GA31209@lst.de> (raw)
In-Reply-To: <20220413010157.GA10502@gao-cwp>

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.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Chao Gao <chao.gao@intel.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	m.szyprowski@samsung.com, hch@lst.de,
	Wang Zhaoyang1 <zhaoyang1.wang@intel.com>,
	Gao Liang <liang.gao@intel.com>,
	Kevin Tian <kevin.tian@intel.com>
Subject: Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb
Date: Wed, 13 Apr 2022 06:59:58 +0200	[thread overview]
Message-ID: <20220413045958.GA31209@lst.de> (raw)
In-Reply-To: <20220413010157.GA10502@gao-cwp>

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.

  reply	other threads:[~2022-04-13  5:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 11:38 [PATCH] dma-direct: avoid redundant memory sync for swiotlb Chao Gao
2022-04-12 11:38 ` Chao Gao
2022-04-12 13:21 ` Chao Gao
2022-04-12 13:21   ` Chao Gao
2022-04-12 13:33 ` Robin Murphy
2022-04-12 13:33   ` Robin Murphy
2022-04-13  1:02   ` Chao Gao
2022-04-13  1:02     ` Chao Gao
2022-04-13  4:59     ` Christoph Hellwig [this message]
2022-04-13  4:59       ` Christoph Hellwig
2022-04-13  5:46       ` Chao Gao
2022-04-13  5:46         ` Chao Gao
2022-04-13  5:49         ` Christoph Hellwig
2022-04-13  5:49           ` Christoph Hellwig
2022-04-13 13:10       ` Robin Murphy
2022-04-13 13:10         ` Robin Murphy
2022-04-13 16:44         ` Christoph Hellwig
2022-04-13 16:44           ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220413045958.GA31209@lst.de \
    --to=hch@lst.de \
    --cc=chao.gao@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kevin.tian@intel.com \
    --cc=liang.gao@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=zhaoyang1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.