2021-05-05 12:09:13

by Greg KH

[permalink] [raw]
Subject: [PATCH 5.10 13/29] swiotlb: add a IO_TLB_SIZE define

From: Jianxiong Gao <[email protected]>

commit: b5d7ccb7aac3895c2138fe0980a109116ce15eff

Add a new IO_TLB_SIZE define instead open coding it using
IO_TLB_SHIFT all over.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Jianxiong Gao <[email protected]>
Tested-by: Jianxiong Gao <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
Signed-off-by: Jianxiong Gao <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
include/linux/swiotlb.h | 1 +
kernel/dma/swiotlb.c | 12 ++++++------
2 files changed, 7 insertions(+), 6 deletions(-)

--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -29,6 +29,7 @@ enum swiotlb_force {
* controllable.
*/
#define IO_TLB_SHIFT 11
+#define IO_TLB_SIZE (1 << IO_TLB_SHIFT)

extern void swiotlb_init(int verbose);
int swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -475,20 +475,20 @@ phys_addr_t swiotlb_tbl_map_single(struc

tbl_dma_addr &= mask;

- offset_slots = ALIGN(tbl_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
+ offset_slots = ALIGN(tbl_dma_addr, IO_TLB_SIZE) >> IO_TLB_SHIFT;

/*
* Carefully handle integer overflow which can occur when mask == ~0UL.
*/
max_slots = mask + 1
- ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT
+ ? ALIGN(mask + 1, IO_TLB_SIZE) >> IO_TLB_SHIFT
: 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);

/*
* For mappings greater than or equal to a page, we limit the stride
* (and hence alignment) to a page size.
*/
- nslots = ALIGN(alloc_size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
+ nslots = ALIGN(alloc_size, IO_TLB_SIZE) >> IO_TLB_SHIFT;
if (alloc_size >= PAGE_SIZE)
stride = (1 << (PAGE_SHIFT - IO_TLB_SHIFT));
else
@@ -582,7 +582,7 @@ void swiotlb_tbl_unmap_single(struct dev
enum dma_data_direction dir, unsigned long attrs)
{
unsigned long flags;
- int i, count, nslots = ALIGN(alloc_size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
+ int i, count, nslots = ALIGN(alloc_size, IO_TLB_SIZE) >> IO_TLB_SHIFT;
int index = (tlb_addr - io_tlb_start) >> IO_TLB_SHIFT;
phys_addr_t orig_addr = io_tlb_orig_addr[index];

@@ -633,7 +633,7 @@ void swiotlb_tbl_sync_single(struct devi

if (orig_addr == INVALID_PHYS_ADDR)
return;
- orig_addr += (unsigned long)tlb_addr & ((1 << IO_TLB_SHIFT) - 1);
+ orig_addr += (unsigned long)tlb_addr & (IO_TLB_SIZE - 1);

switch (target) {
case SYNC_FOR_CPU:
@@ -691,7 +691,7 @@ dma_addr_t swiotlb_map(struct device *de

size_t swiotlb_max_mapping_size(struct device *dev)
{
- return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
+ return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE;
}

bool is_swiotlb_active(void)



2021-05-05 22:12:21

by Pavel Machek

[permalink] [raw]
Subject: Yet another way to mark upstream commits was Re: [PATCH 5.10 13/29] swiotlb: add a IO_TLB_SIZE define

Hi!

> From: Jianxiong Gao <[email protected]>
>
> commit: b5d7ccb7aac3895c2138fe0980a109116ce15eff

This is 5th variant of marking upstream commits, and I need to update
my scripts again.

Could we please put this into Signed-off area, where it belongs, so it
is easy to see who touched the patch for mainline, and stop this
creativity?

> Add a new IO_TLB_SIZE define instead open coding it using
> IO_TLB_SHIFT all over.
>
> Signed-off-by: Christoph Hellwig <[email protected]>
> Acked-by: Jianxiong Gao <[email protected]>
> Tested-by: Jianxiong Gao <[email protected]>
> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>

I'd like to see

Upstream: b5d7ccb7aac3895c2138fe0980a109116ce15eff

here. Probably. Note that it has additional advantage that you can
easily marked who Acked/Tested the patch for mainline, and who tested
it in the stable context.

> Signed-off-by: Jianxiong Gao <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Best regards,
Pavel
--
http://www.livejournal.com/~pavelmachek


Attachments:
(No filename) (1.06 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments