Skip to content

Commit c745a8a

Browse files
arch/tile: Various cleanups.
This change rolls up random cleanups not representing any actual bugs. - Remove a stale CONFIG_ value from the default tile_defconfig - Remove unused tns_atomic_xxx() family of methods from <asm/atomic.h> - Optimize get_order() using Tile's "clz" instruction - Fix a bad hypervisor upcall name (not currently used in Linux anyway) - Use __copy_in_user_inatomic() name for consistency, and export it - Export some additional hypervisor driver I/O upcalls and some homecache calls - Remove the obfuscating MEMCPY_TEST_WH64 support code - Other stray comment cleanups, #if 0 removal, etc. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent 1fcbe02 commit c745a8a

11 files changed

Lines changed: 40 additions & 92 deletions

File tree

‎arch/tile/configs/tile_defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ CONFIG_HARDWALL=y
231231
CONFIG_MEMPROF=y
232232
CONFIG_XGBE=y
233233
CONFIG_NET_TILE=y
234-
CONFIG_PSEUDO_NAPI=y
235234
CONFIG_TILEPCI_ENDP=y
236235
CONFIG_TILEPCI_HOST_SUBSET=m
237236
CONFIG_TILE_IDE_GPIO=y

‎arch/tile/include/asm/atomic_32.h‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -255,43 +255,6 @@ static inline void atomic64_set(atomic64_t *v, u64 n)
255255
#define smp_mb__after_atomic_dec() do { } while (0)
256256
#define smp_mb__after_atomic_inc() do { } while (0)
257257

258-
259-
/*
260-
* Support "tns" atomic integers. These are atomic integers that can
261-
* hold any value but "1". They are more efficient than regular atomic
262-
* operations because the "lock" (aka acquire) step is a single "tns"
263-
* in the uncontended case, and the "unlock" (aka release) step is a
264-
* single "store" without an mf. (However, note that on tilepro the
265-
* "tns" will evict the local cache line, so it's not all upside.)
266-
*
267-
* Note that you can ONLY observe the value stored in the pointer
268-
* using these operations; a direct read of the value may confusingly
269-
* return the special value "1".
270-
*/
271-
272-
int __tns_atomic_acquire(atomic_t *);
273-
void __tns_atomic_release(atomic_t *p, int v);
274-
275-
static inline void tns_atomic_set(atomic_t *v, int i)
276-
{
277-
__tns_atomic_acquire(v);
278-
__tns_atomic_release(v, i);
279-
}
280-
281-
static inline int tns_atomic_cmpxchg(atomic_t *v, int o, int n)
282-
{
283-
int ret = __tns_atomic_acquire(v);
284-
__tns_atomic_release(v, (ret == o) ? n : ret);
285-
return ret;
286-
}
287-
288-
static inline int tns_atomic_xchg(atomic_t *v, int n)
289-
{
290-
int ret = __tns_atomic_acquire(v);
291-
__tns_atomic_release(v, n);
292-
return ret;
293-
}
294-
295258
#endif /* !__ASSEMBLY__ */
296259

297260
/*

‎arch/tile/include/asm/page.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ static inline u64 pmd_val(pmd_t pmd)
129129

130130
#endif
131131

132+
static inline __attribute_const__ int get_order(unsigned long size)
133+
{
134+
return BITS_PER_LONG - __builtin_clzl((size - 1) >> PAGE_SHIFT);
135+
}
136+
132137
#endif /* !__ASSEMBLY__ */
133138

134139
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
@@ -332,7 +337,6 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
332337
(VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
333338

334339
#include <asm-generic/memory_model.h>
335-
#include <asm-generic/getorder.h>
336340

337341
#endif /* __KERNEL__ */
338342

‎arch/tile/include/asm/uaccess.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,14 @@ static inline unsigned long __must_check copy_from_user(void *to,
389389
* Returns number of bytes that could not be copied.
390390
* On success, this will be zero.
391391
*/
392-
extern unsigned long __copy_in_user_asm(
392+
extern unsigned long __copy_in_user_inatomic(
393393
void __user *to, const void __user *from, unsigned long n);
394394

395395
static inline unsigned long __must_check
396396
__copy_in_user(void __user *to, const void __user *from, unsigned long n)
397397
{
398398
might_sleep();
399-
return __copy_in_user_asm(to, from, n);
399+
return __copy_in_user_inatomic(to, from, n);
400400
}
401401

402402
static inline unsigned long __must_check

‎arch/tile/include/hv/hypervisor.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,11 @@ void hv_disable_intr(HV_IntrMask disab_mask);
532532
*/
533533
void hv_clear_intr(HV_IntrMask clear_mask);
534534

535-
/** Assert a set of device interrupts.
535+
/** Raise a set of device interrupts.
536536
*
537-
* @param assert_mask Bitmap of interrupts to clear.
537+
* @param raise_mask Bitmap of interrupts to raise.
538538
*/
539-
void hv_assert_intr(HV_IntrMask assert_mask);
539+
void hv_raise_intr(HV_IntrMask raise_mask);
540540

541541
/** Trigger a one-shot interrupt on some tile
542542
*
@@ -1712,7 +1712,7 @@ typedef struct
17121712
* @param cache_control This argument allows you to specify a length of
17131713
* physical address space to flush (maximum HV_FLUSH_MAX_CACHE_LEN).
17141714
* You can "or" in HV_FLUSH_EVICT_L2 to flush the whole L2 cache.
1715-
* You can "or" in HV_FLUSH_EVICT_LI1 to flush the whole LII cache.
1715+
* You can "or" in HV_FLUSH_EVICT_L1I to flush the whole L1I cache.
17161716
* HV_FLUSH_ALL flushes all caches.
17171717
* @param cache_cpumask Bitmask (in row-major order, supervisor-relative) of
17181718
* tile indices to perform cache flush on. The low bit of the first

‎arch/tile/lib/Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ lib-y = cacheflush.o checksum.o cpumask.o delay.o \
77
memcpy_$(BITS).o memchr_$(BITS).o memmove_$(BITS).o memset_$(BITS).o \
88
strchr_$(BITS).o strlen_$(BITS).o
99

10-
ifneq ($(CONFIG_TILEGX),y)
10+
ifeq ($(CONFIG_TILEGX),y)
11+
lib-y += memcpy_user_64.o
12+
else
1113
lib-y += atomic_32.o atomic_asm_32.o memcpy_tile64.o
1214
endif
1315

‎arch/tile/lib/exports.c‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,29 @@ EXPORT_SYMBOL(clear_user_asm);
3636
EXPORT_SYMBOL(current_text_addr);
3737
EXPORT_SYMBOL(dump_stack);
3838

39-
/* arch/tile/lib/__memcpy.S */
40-
/* NOTE: on TILE64, these symbols appear in arch/tile/lib/memcpy_tile64.c */
39+
/* arch/tile/lib/, various memcpy files */
4140
EXPORT_SYMBOL(memcpy);
4241
EXPORT_SYMBOL(__copy_to_user_inatomic);
4342
EXPORT_SYMBOL(__copy_from_user_inatomic);
4443
EXPORT_SYMBOL(__copy_from_user_zeroing);
44+
#ifdef __tilegx__
45+
EXPORT_SYMBOL(__copy_in_user_inatomic);
46+
#endif
4547

4648
/* hypervisor glue */
4749
#include <hv/hypervisor.h>
4850
EXPORT_SYMBOL(hv_dev_open);
4951
EXPORT_SYMBOL(hv_dev_pread);
5052
EXPORT_SYMBOL(hv_dev_pwrite);
53+
EXPORT_SYMBOL(hv_dev_preada);
54+
EXPORT_SYMBOL(hv_dev_pwritea);
55+
EXPORT_SYMBOL(hv_dev_poll);
56+
EXPORT_SYMBOL(hv_dev_poll_cancel);
5157
EXPORT_SYMBOL(hv_dev_close);
58+
EXPORT_SYMBOL(hv_sysconf);
59+
EXPORT_SYMBOL(hv_confstr);
5260

53-
/* -ltile-cc */
61+
/* libgcc.a */
5462
uint32_t __udivsi3(uint32_t dividend, uint32_t divisor);
5563
EXPORT_SYMBOL(__udivsi3);
5664
int32_t __divsi3(int32_t dividend, int32_t divisor);
@@ -70,8 +78,6 @@ EXPORT_SYMBOL(__moddi3);
7078
#ifndef __tilegx__
7179
uint64_t __ll_mul(uint64_t n0, uint64_t n1);
7280
EXPORT_SYMBOL(__ll_mul);
73-
#endif
74-
#ifndef __tilegx__
7581
int64_t __muldi3(int64_t, int64_t);
7682
EXPORT_SYMBOL(__muldi3);
7783
uint64_t __lshrdi3(uint64_t, unsigned int);

‎arch/tile/lib/memcpy_32.S‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
#include <arch/chip.h>
1919

20-
#if CHIP_HAS_WH64() || defined(MEMCPY_TEST_WH64)
21-
#define MEMCPY_USE_WH64
22-
#endif
23-
2420

2521
#include <linux/linkage.h>
2622

@@ -160,7 +156,7 @@ EX: { sw r0, r3; addi r0, r0, 4; addi r2, r2, -4 }
160156

161157
{ addi r3, r1, 60; andi r9, r9, -64 }
162158

163-
#ifdef MEMCPY_USE_WH64
159+
#if CHIP_HAS_WH64()
164160
/* No need to prefetch dst, we'll just do the wh64
165161
* right before we copy a line.
166162
*/
@@ -173,7 +169,7 @@ EX: { lw r6, r3; addi r3, r3, 64 }
173169
/* Intentionally stall for a few cycles to leave L2 cache alone. */
174170
{ bnzt zero, . }
175171
EX: { lw r7, r3; addi r3, r3, 64 }
176-
#ifndef MEMCPY_USE_WH64
172+
#if !CHIP_HAS_WH64()
177173
/* Prefetch the dest */
178174
/* Intentionally stall for a few cycles to leave L2 cache alone. */
179175
{ bnzt zero, . }
@@ -288,15 +284,7 @@ EX: { lw r7, r3; addi r3, r3, 64 }
288284
/* Fill second L1D line. */
289285
EX: { lw r17, r17; addi r1, r1, 48; mvz r3, r13, r1 } /* r17 = WORD_4 */
290286

291-
#ifdef MEMCPY_TEST_WH64
292-
/* Issue a fake wh64 that clobbers the destination words
293-
* with random garbage, for testing.
294-
*/
295-
{ movei r19, 64; crc32_32 r10, r2, r9 }
296-
.Lwh64_test_loop:
297-
EX: { sw r9, r10; addi r9, r9, 4; addi r19, r19, -4 }
298-
{ bnzt r19, .Lwh64_test_loop; crc32_32 r10, r10, r19 }
299-
#elif CHIP_HAS_WH64()
287+
#if CHIP_HAS_WH64()
300288
/* Prepare destination line for writing. */
301289
EX: { wh64 r9; addi r9, r9, 64 }
302290
#else
@@ -340,7 +328,7 @@ EX: { lw r18, r1; addi r1, r1, 4 } /* r18 = WORD_8 */
340328
EX: { sw r0, r16; addi r0, r0, 4; add r16, r0, r2 } /* store(WORD_0) */
341329
EX: { sw r0, r13; addi r0, r0, 4; andi r16, r16, -64 } /* store(WORD_1) */
342330
EX: { sw r0, r14; addi r0, r0, 4; slt_u r16, r9, r16 } /* store(WORD_2) */
343-
#ifdef MEMCPY_USE_WH64
331+
#if CHIP_HAS_WH64()
344332
EX: { sw r0, r15; addi r0, r0, 4; addi r13, sp, -64 } /* store(WORD_3) */
345333
#else
346334
/* Back up the r9 to a cache line we are already storing to

‎arch/tile/lib/memset_32.c‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ void *memset(void *s, int c, size_t n)
141141
*/
142142
__insn_prefetch(&out32[ahead32]);
143143

144-
#if 1
145144
#if CACHE_LINE_SIZE_IN_WORDS % 4 != 0
146145
#error "Unhandled CACHE_LINE_SIZE_IN_WORDS"
147146
#endif
@@ -157,30 +156,6 @@ void *memset(void *s, int c, size_t n)
157156
*out32++ = v32;
158157
*out32++ = v32;
159158
}
160-
#else
161-
/* Unfortunately, due to a code generator flaw this
162-
* allocates a separate register for each of these
163-
* stores, which requires a large number of spills,
164-
* which makes this procedure enormously bigger
165-
* (something like 70%)
166-
*/
167-
*out32++ = v32;
168-
*out32++ = v32;
169-
*out32++ = v32;
170-
*out32++ = v32;
171-
*out32++ = v32;
172-
*out32++ = v32;
173-
*out32++ = v32;
174-
*out32++ = v32;
175-
*out32++ = v32;
176-
*out32++ = v32;
177-
*out32++ = v32;
178-
*out32++ = v32;
179-
*out32++ = v32;
180-
*out32++ = v32;
181-
*out32++ = v32;
182-
n32 -= 16;
183-
#endif
184159

185160
/* To save compiled code size, reuse this loop even
186161
* when we run out of prefetching to do by dropping

‎arch/tile/mm/fault.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,14 @@ static int handle_page_fault(struct pt_regs *regs,
567567
* since that might indicate we have not yet squirreled the SPR
568568
* contents away and can thus safely take a recursive interrupt.
569569
* Accordingly, the hypervisor passes us the PC via SYSTEM_SAVE_1_2.
570+
*
571+
* Note that this routine is called before homecache_tlb_defer_enter(),
572+
* which means that we can properly unlock any atomics that might
573+
* be used there (good), but also means we must be very sensitive
574+
* to not touch any data structures that might be located in memory
575+
* that could migrate, as we could be entering the kernel on a dataplane
576+
* cpu that has been deferring kernel TLB updates. This means, for
577+
* example, that we can't migrate init_mm or its pgd.
570578
*/
571579
struct intvec_state do_page_fault_ics(struct pt_regs *regs, int fault_num,
572580
unsigned long address,

0 commit comments

Comments
 (0)