Skip to content

Commit d4b048c

Browse files
willdeaconctmarinas
authored andcommitted
arm64: mm: Inline __TLBI_VADDR_RANGE() into __tlbi_range()
The __TLBI_VADDR_RANGE() macro is only used in one place and isn't something that's generally useful outside of the low-level range invalidation gubbins. Inline __TLBI_VADDR_RANGE() into the __tlbi_range() function so that the macro can be removed entirely. Signed-off-by: Will Deacon <will@kernel.org> Reviewed-by: Linu Cherian <linu.cherian@arm.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent a371003 commit d4b048c

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

arch/arm64/include/asm/tlbflush.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,6 @@ static inline void __tlbi_level(tlbi_op op, u64 addr, u32 level)
186186
#define TLBIR_TTL_MASK GENMASK_ULL(38, 37)
187187
#define TLBIR_BADDR_MASK GENMASK_ULL(36, 0)
188188

189-
#define __TLBI_VADDR_RANGE(baddr, asid, scale, num, ttl) \
190-
({ \
191-
unsigned long __ta = 0; \
192-
unsigned long __ttl = (ttl >= 1 && ttl <= 3) ? ttl : 0; \
193-
__ta |= FIELD_PREP(TLBIR_BADDR_MASK, baddr); \
194-
__ta |= FIELD_PREP(TLBIR_TTL_MASK, __ttl); \
195-
__ta |= FIELD_PREP(TLBIR_NUM_MASK, num); \
196-
__ta |= FIELD_PREP(TLBIR_SCALE_MASK, scale); \
197-
__ta |= FIELD_PREP(TLBIR_TG_MASK, get_trans_granule()); \
198-
__ta |= FIELD_PREP(TLBIR_ASID_MASK, asid); \
199-
__ta; \
200-
})
201-
202189
/* These macros are used by the TLBI RANGE feature. */
203190
#define __TLBI_RANGE_PAGES(num, scale) \
204191
((unsigned long)((num) + 1) << (5 * (scale) + 1))
@@ -498,8 +485,19 @@ static __always_inline void ripas2e1is(u64 arg)
498485
__tlbi(ripas2e1is, arg);
499486
}
500487

501-
static __always_inline void __tlbi_range(tlbi_op op, u64 arg)
488+
static __always_inline void __tlbi_range(tlbi_op op, u64 addr,
489+
u16 asid, int scale, int num,
490+
u32 level, bool lpa2)
502491
{
492+
u64 arg = 0;
493+
494+
arg |= FIELD_PREP(TLBIR_BADDR_MASK, addr >> (lpa2 ? 16 : PAGE_SHIFT));
495+
arg |= FIELD_PREP(TLBIR_TTL_MASK, level > 3 ? 0 : level);
496+
arg |= FIELD_PREP(TLBIR_NUM_MASK, num);
497+
arg |= FIELD_PREP(TLBIR_SCALE_MASK, scale);
498+
arg |= FIELD_PREP(TLBIR_TG_MASK, get_trans_granule());
499+
arg |= FIELD_PREP(TLBIR_ASID_MASK, asid);
500+
503501
op(arg);
504502
}
505503

@@ -510,8 +508,6 @@ do { \
510508
typeof(pages) __flush_pages = pages; \
511509
int num = 0; \
512510
int scale = 3; \
513-
int shift = lpa2 ? 16 : PAGE_SHIFT; \
514-
unsigned long addr; \
515511
\
516512
while (__flush_pages > 0) { \
517513
if (!system_supports_tlb_range() || \
@@ -525,9 +521,7 @@ do { \
525521
\
526522
num = __TLBI_RANGE_NUM(__flush_pages, scale); \
527523
if (num >= 0) { \
528-
addr = __TLBI_VADDR_RANGE(__flush_start >> shift, asid, \
529-
scale, num, tlb_level); \
530-
__tlbi_range(r##op, addr); \
524+
__tlbi_range(r##op, __flush_start, asid, scale, num, tlb_level, lpa2); \
531525
__flush_start += __TLBI_RANGE_PAGES(num, scale) << PAGE_SHIFT; \
532526
__flush_pages -= __TLBI_RANGE_PAGES(num, scale);\
533527
} \

0 commit comments

Comments
 (0)