All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Christoph Hellwig <hch@lst.de>
Cc: "Horia Geantă" <horia.geanta@nxp.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-imx@nxp.com
Subject: Re: [PATCH] swiotlb: sync buffer when mapping FROM_DEVICE
Date: Wed, 22 May 2019 14:25:38 +0100	[thread overview]
Message-ID: <fdfd7318-7999-1fe6-01b6-ae1fb7ba8c30@arm.com> (raw)
In-Reply-To: <20190522130921.GA26874@lst.de>

On 2019-05-22 2:09 pm, Christoph Hellwig wrote:
> On Wed, May 22, 2019 at 01:50:47PM +0100, Robin Murphy wrote:
>> Would that work out any different from the existing DMA_ATTR_SKIP_CPU_SYNC?
>>
>> If drivers are prepared to handle this issue from their end, they can
>> already do so for single mappings by using that attr along with explicit
>> partial syncs via dma_sync_single(). For page/sg mappings we'd still have
>> the problem of identifying what part of "partial" actually matters, and
>> probably having to add some additional new sync operations to cope.
> 
> Except that the same optimization we are tripping over here is also
> present in dma_sync_* - dma_sync_*_to_device with DMA_FROM_DEVICE is a
> no-op in swiotlb.

Sure, but that should be irrelevant since the effective problem here is 
in the sync_*_for_cpu direction, and it's the unmap which nobbles the 
buffer. If the driver does this:

	dma_map_single(whole buffer);
	<device writes to part of buffer>
	dma_unmap_single(whole buffer);
	<contents of rest of buffer now undefined>

then it could instead do this and be happy:

	dma_map_single(whole buffer, SKIP_CPU_SYNC);
	<device writes to part of buffer>
	dma_sync_single_for_cpu(updated part of buffer);
	dma_unmap_single(whole buffer, SKIP_CPU_SYNC);
	<contents of rest of buffer still valid>

Robin.

WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: Christoph Hellwig <hch@lst.de>
Cc: "Horia Geantă" <horia.geanta@nxp.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	linux-imx@nxp.com
Subject: Re: [PATCH] swiotlb: sync buffer when mapping FROM_DEVICE
Date: Wed, 22 May 2019 14:25:38 +0100	[thread overview]
Message-ID: <fdfd7318-7999-1fe6-01b6-ae1fb7ba8c30@arm.com> (raw)
In-Reply-To: <20190522130921.GA26874@lst.de>

On 2019-05-22 2:09 pm, Christoph Hellwig wrote:
> On Wed, May 22, 2019 at 01:50:47PM +0100, Robin Murphy wrote:
>> Would that work out any different from the existing DMA_ATTR_SKIP_CPU_SYNC?
>>
>> If drivers are prepared to handle this issue from their end, they can
>> already do so for single mappings by using that attr along with explicit
>> partial syncs via dma_sync_single(). For page/sg mappings we'd still have
>> the problem of identifying what part of "partial" actually matters, and
>> probably having to add some additional new sync operations to cope.
> 
> Except that the same optimization we are tripping over here is also
> present in dma_sync_* - dma_sync_*_to_device with DMA_FROM_DEVICE is a
> no-op in swiotlb.

Sure, but that should be irrelevant since the effective problem here is 
in the sync_*_for_cpu direction, and it's the unmap which nobbles the 
buffer. If the driver does this:

	dma_map_single(whole buffer);
	<device writes to part of buffer>
	dma_unmap_single(whole buffer);
	<contents of rest of buffer now undefined>

then it could instead do this and be happy:

	dma_map_single(whole buffer, SKIP_CPU_SYNC);
	<device writes to part of buffer>
	dma_sync_single_for_cpu(updated part of buffer);
	dma_unmap_single(whole buffer, SKIP_CPU_SYNC);
	<contents of rest of buffer still valid>

Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2019-05-22 13:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  7:20 [PATCH] swiotlb: sync buffer when mapping FROM_DEVICE Horia Geantă
2019-05-22  7:20 ` Horia Geantă
2019-05-22 12:32 ` Christoph Hellwig
2019-05-22 12:32   ` Christoph Hellwig
2019-05-22 12:50   ` Robin Murphy
2019-05-22 12:50     ` Robin Murphy
2019-05-22 13:09     ` Christoph Hellwig
2019-05-22 13:09       ` Christoph Hellwig
2019-05-22 13:25       ` Robin Murphy [this message]
2019-05-22 13:25         ` Robin Murphy
2019-05-22 13:34         ` Christoph Hellwig
2019-05-22 13:34           ` Christoph Hellwig
2019-05-22 13:55           ` Robin Murphy
2019-05-22 13:55             ` Robin Murphy
2019-05-23  5:35             ` Marek Szyprowski
2019-05-23  5:35               ` Marek Szyprowski
2019-05-23 16:25               ` Horia Geanta
2019-05-23 16:25                 ` Horia Geanta
2019-05-23 16:43               ` Christoph Hellwig
2019-05-23 16:43                 ` Christoph Hellwig
2019-05-23 17:53                 ` Horia Geanta
2019-05-23 17:53                   ` Horia Geanta
2019-05-23 18:05                 ` Robin Murphy
2019-05-23 18:05                   ` Robin Murphy

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=fdfd7318-7999-1fe6-01b6-ae1fb7ba8c30@arm.com \
    --to=robin.murphy@arm.com \
    --cc=hch@lst.de \
    --cc=horia.geanta@nxp.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.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.