public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] swiotlb: allocate padding slots if necessary
@ 2024-03-25  8:31 Petr Tesarik
  2024-03-25  8:31 ` [PATCH v4 1/2] swiotlb: extend buffer pre-padding to alloc_align_mask " Petr Tesarik
  2024-03-25  8:31 ` [PATCH v4 2/2] bug: introduce ASSERT_VAR_CAN_HOLD() Petr Tesarik
  0 siblings, 2 replies; 7+ messages in thread
From: Petr Tesarik @ 2024-03-25  8:31 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Petr Tesarik,
	Michael Kelley, Will Deacon, open list,
	open list:DMA MAPPING HELPERS
  Cc: Roberto Sassu, Petr Tesarik

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.

Changes from v3
---------------
* Add a parameter to swiotlb_align_offset(), so it is not open-coded in
  swiotlb_tbl_map_single().
* Extend the description of swiotlb_align_offset() and convert it to the
  kernel-doc format.
* Use bit operations to calculate number of padding slots and the padding
  inside a slot. This matches all other such calculations in swiotlb.c.

Changes from v2
---------------
* Fix assignment of an uninitialized variable to pad_slots.
* Improve commit message wrt INVALID_PHYS_ADDR.

Changes from v1
---------------
* Rename padding to pad_slots.
* Set pad_slots only for the first allocated non-padding slot.
* Do not bother initializing orig_addr to INVALID_PHYS_ADDR.
* Change list and pad_slots to unsigned short to avoid growing
  struct io_tlb_slot on 32-bit targets.
* Add build-time check that list and pad_slots can hold the maximum
  allowed value of IO_TLB_SEGSIZE.


Petr Tesarik (2):
  swiotlb: extend buffer pre-padding to alloc_align_mask if necessary
  bug: introduce ASSERT_VAR_CAN_HOLD()

 include/linux/build_bug.h | 10 +++++++
 kernel/dma/swiotlb.c      | 61 ++++++++++++++++++++++++++++++---------
 2 files changed, 58 insertions(+), 13 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-02 15:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25  8:31 [PATCH v4 0/2] swiotlb: allocate padding slots if necessary Petr Tesarik
2024-03-25  8:31 ` [PATCH v4 1/2] swiotlb: extend buffer pre-padding to alloc_align_mask " Petr Tesarik
2024-03-25 19:16   ` Michael Kelley
2024-04-02 15:10   ` Christoph Hellwig
2024-03-25  8:31 ` [PATCH v4 2/2] bug: introduce ASSERT_VAR_CAN_HOLD() Petr Tesarik
2024-03-26  7:56   ` Christoph Hellwig
2024-03-26 11:55     ` Petr Tesařík

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox