mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: "Linu Cherian" <lcherian@marvell.com>, "Petr Tesařík" <petr@tesarici.cz>
Cc: Petr Tesarik <petrtesarik@huaweicloud.com>,
	Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:DMA MAPPING HELPERS" <iommu@lists.linux.dev>,
	Will Deacon <will@kernel.org>,
	Michael Kelley <mhklinux@outlook.com>,
	Roberto Sassu <roberto.sassu@huaweicloud.com>
Subject: Re: [EXTERNAL] Re: [PATCH 1/1] swiotlb: add a KUnit test suite
Date: Wed, 3 Apr 2024 17:58:47 +0100	[thread overview]
Message-ID: <69d3bcc5-5b5b-4b52-93fe-4a095e7ccdc6@arm.com> (raw)
In-Reply-To: <PH0PR18MB50024739F4DCF8FCEB6F0CADCE3D2@PH0PR18MB5002.namprd18.prod.outlook.com>

On 2024-04-03 3:19 pm, Linu Cherian wrote:
[...]
>>> Should we not try this on a buffer that is mapped with DMA_FROM_DEVICE ?
>>
>> I'm afraid I don't follow.
>>
>> AFAICT the direction is a property of the sync operation. In fact,
>> swiotlb_tbl_map_single() does not even use its direction parameter at all.
>> Removing that parameter is already on my TODO list of cleanups.
>>
> 
> Okay. Got it.
> 
>> swiotlb_map() uses its direction parameter only to perform the initial arch
>> sync if DMA is non-coherent.
>>
>> OTOH I may be missing some high-level logical concepts which do not
>> correspond to any actual code in the swiotlb implementation, so my use is still
>> wrong.
>>
> 
> Just thought that the keeping the DMA direction consistent for the map and sync would be more aligned to typical use case.
> For example, a buffer used for transmit in case of networking. OTOH, since the API by itself doesn't have such constraints on the direction parameter, may be it makes sense to test those scenarios.

Right, SWIOTLB exists to serve the DMA API, so it makes more sense to me 
to test it in the context of valid DMA API usage than to make up 
scenarios that aren't representative of real-world usage. The direction 
is a property of the whole DMA mapping itself, and thus must be passed 
consistently for every operation on a given mapping.

Yes, there is some internal trickery once we get down to the level of 
calling swiotlb_bounce() itself, but if we're driving the tests through 
the higher-level public interface then I'd prefer to see that used as 
expected. Given the whole partial-write-transparency business, the most 
significant effect of direction should just be that of DMA_TO_DEVICE 
skipping the copy-out for unmap and sync_for_cpu, so for the sake of 
coverage you may as well just use DMA_BIDIRECTIONAL everywhere.

Thanks,
Robin.

  reply	other threads:[~2024-04-03 16:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  9:27 Petr Tesarik
2024-03-25 14:06 ` Petr Tesařík
2024-03-25 20:10   ` Michael Kelley
2024-03-26  3:08 ` Linu Cherian
2024-03-26 12:06   ` Petr Tesařík
2024-04-03 14:19     ` [EXTERNAL] " Linu Cherian
2024-04-03 16:58       ` Robin Murphy [this message]
2024-04-04  6:38         ` Petr Tesařík

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=69d3bcc5-5b5b-4b52-93fe-4a095e7ccdc6@arm.com \
    --to=robin.murphy@arm.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mhklinux@outlook.com \
    --cc=petr@tesarici.cz \
    --cc=petrtesarik@huaweicloud.com \
    --cc=roberto.sassu@huaweicloud.com \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®