All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Kelley <mhklinux@outlook.com>
To: Will Deacon <will@kernel.org>,
	Petr Tesarik <petrtesarik@huaweicloud.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Petr Tesarik <petr.tesarik1@huawei-partners.com>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:DMA MAPPING HELPERS" <iommu@lists.linux.dev>,
	Roberto Sassu <roberto.sassu@huaweicloud.com>,
	Petr Tesarik <petr@tesarici.cz>
Subject: RE: [PATCH v3 0/2] swiotlb: allocate padding slots if necessary
Date: Fri, 22 Mar 2024 18:11:50 +0000	[thread overview]
Message-ID: <SN6PR02MB41574F4837E875F3D158B329D4312@SN6PR02MB4157.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20240322150941.GA5634@willie-the-truck>

From: Will Deacon <will@kernel.org> Sent: Friday, March 22, 2024 8:10 AM
> 
> Hi Petr,
> 
> On Thu, Mar 21, 2024 at 06:19:00PM +0100, Petr Tesarik wrote:
> > From: Petr Tesarik <petr.tesarik1@huawei-partners.com>
> >
> > If the allocation alignment is bigger than IO_TLB_SIZE and min_align_mask
> > covers some bits in the original address between IO_TLB_SIZE and
> > alloc_align_mask, preserve these bits by allocating additional padding
> > slots before the actual swiotlb buffer.
> 
> Thanks for fixing this! I was out at a conference last week, so I didn't
> get very far with it myself, but I ended up in a pickle trying to avoid
> extending 'struct io_tlb_slot'. Your solution is much better than the
> crazy avenue I started going down...
> 
> With your changes, can we now simplify swiotlb_align_offset() to ignore
> dma_get_min_align_mask() altogether and just:
> 
> 	return addr & (IO_TLB_SIZE - 1);
> 
> ?
> 

I don't think such a change is correct, since we want to allow the
DMA min_align_mask to work if it is set to 0x3FF or 0x1FF or
something else smaller than IO_TLB_SIZE - 1.

Petr's new offset calculation in swiotlb_tbl_map_single() is this:

offset = orig_addr & dma_get_min_align_mask(dev) &
                (alloc_align_mask | (IO_TLB_SIZE - 1));

In the normal stream mapping case, where alloc_align_mask is
zero, Petr's new statement is equivalent to swiotlb_align_offset().
And I think it needs to continue to be equivalent so that
swiotlb_search_pool_area(), swiotlb_bounce()  and
swiotlb_release_slots() calculate the same offset as
swiotlb_tbl_map_single() uses after it separately processes
the padding slots.

Perhaps a better approach to maintaining the equivalence is
to modify swiotlb_align_offset() to be Petr's new calculation,
with alloc_align_mask passed as an argument.
swiotlb_search_pool_area(), swiotlb_bounce(), and
swiotlb_release_slots() would all pass 0 as the alloc_align_mask
argument.

Michael

  parent reply	other threads:[~2024-03-22 18:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 17:19 [PATCH v3 0/2] swiotlb: allocate padding slots if necessary Petr Tesarik
2024-03-21 17:19 ` [PATCH v3 1/2] swiotlb: extend buffer pre-padding to alloc_align_mask " Petr Tesarik
2024-03-22  4:29   ` Michael Kelley
2024-03-22 10:29     ` Petr Tesarik
2024-03-21 17:19 ` [PATCH v3 2/2] bug: introduce ASSERT_VAR_CAN_HOLD() Petr Tesarik
2024-03-22  4:33   ` Michael Kelley
2024-03-22 15:37   ` Will Deacon
2024-03-22 17:33     ` Petr Tesařík
2024-03-22 15:09 ` [PATCH v3 0/2] swiotlb: allocate padding slots if necessary Will Deacon
2024-03-22 17:51   ` Petr Tesařík
2024-03-27 19:42     ` Will Deacon
2024-03-22 18:11   ` Michael Kelley [this message]
2024-03-22 19:31     ` 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=SN6PR02MB41574F4837E875F3D158B329D4312@SN6PR02MB4157.namprd02.prod.outlook.com \
    --to=mhklinux@outlook.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=petr.tesarik1@huawei-partners.com \
    --cc=petr@tesarici.cz \
    --cc=petrtesarik@huaweicloud.com \
    --cc=roberto.sassu@huaweicloud.com \
    --cc=robin.murphy@arm.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 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.