Skip to content

Commit a84d2d2

Browse files
committed
Merge tag 'csky-for-linus-5.3-rc1' of git://github.com/c-sky/csky-linux
Pull arch/csky pupdates from Guo Ren: "This round of csky subsystem gives two features (ASID algorithm update, Perf pmu record support) and some fixups. ASID updates: - Revert mmu ASID mechanism - Add new asid lib code from arm - Use generic asid algorithm to implement switch_mm - Improve tlb operation with help of asid Perf pmu record support: - Init pmu as a device - Add count-width property for csky pmu - Add pmu interrupt support - Fix perf record in kernel/user space - dt-bindings: Add csky PMU bindings Fixes: - Fixup no panic in kernel for some traps - Fixup some error count in 810 & 860. - Fixup abiv1 memset error" * tag 'csky-for-linus-5.3-rc1' of git://github.com/c-sky/csky-linux: csky: Fixup abiv1 memset error csky: Improve tlb operation with help of asid csky: Use generic asid algorithm to implement switch_mm csky: Add new asid lib code from arm csky: Revert mmu ASID mechanism dt-bindings: csky: Add csky PMU bindings dt-bindings: interrupt-controller: Update csky mpintc csky: Fixup some error count in 810 & 860. csky: Fix perf record in kernel/user space csky: Add pmu interrupt support csky: Add count-width property for csky pmu csky: Init pmu as a device csky: Fixup no panic in kernel for some traps csky: Select intc & timer drivers
2 parents b5d72dd + bdfeb0c commit a84d2d2

File tree

20 files changed

+861
-329
lines changed

20 files changed

+861
-329
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
===============================
2+
C-SKY Performance Monitor Units
3+
===============================
4+
5+
C-SKY Performance Monitor is designed for ck807/ck810/ck860 SMP soc and
6+
it could count cpu's events for helping analysis performance issues.
7+
8+
============================
9+
PMU node bindings definition
10+
============================
11+
12+
Description: Describes PMU
13+
14+
PROPERTIES
15+
16+
- compatible
17+
Usage: required
18+
Value type: <string>
19+
Definition: must be "csky,csky-pmu"
20+
- interrupts
21+
Usage: required
22+
Value type: <u32 IRQ_TYPE_XXX>
23+
Definition: must be pmu irq num defined by soc
24+
- count-width
25+
Usage: optional
26+
Value type: <u32>
27+
Definition: the width of pmu counter
28+
29+
Examples:
30+
---------
31+
#include <dt-bindings/interrupt-controller/irq.h>
32+
33+
pmu: performace-monitor {
34+
compatible = "csky,csky-pmu";
35+
interrupts = <23 IRQ_TYPE_EDGE_RISING>;
36+
interrupt-parent = <&intc>;
37+
count-width = <48>;
38+
};

arch/csky/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ config CSKY
1010
select COMMON_CLK
1111
select CLKSRC_MMIO
1212
select CLKSRC_OF
13+
select CSKY_MPINTC if CPU_CK860
14+
select CSKY_MP_TIMER if CPU_CK860
15+
select CSKY_APB_INTC
1316
select DMA_DIRECT_REMAP
1417
select IRQ_DOMAIN
1518
select HANDLE_DOMAIN_IRQ
@@ -30,6 +33,7 @@ config CSKY
3033
select GENERIC_IRQ_MULTI_HANDLER
3134
select GENERIC_SCHED_CLOCK
3235
select GENERIC_SMP_IDLE_THREAD
36+
select GX6605S_TIMER if CPU_CK610
3337
select HAVE_ARCH_TRACEHOOK
3438
select HAVE_ARCH_AUDITSYSCALL
3539
select HAVE_DYNAMIC_FTRACE

arch/csky/abiv1/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ obj-y += bswapsi.o
55
obj-y += cacheflush.o
66
obj-y += mmap.o
77
obj-y += memcpy.o
8-
obj-y += memset.o
98
obj-y += strksyms.o

arch/csky/abiv1/inc/abi/ckmmu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ static inline void tlb_invalid_all(void)
7878
cpwcr("cpcr8", 0x04000000);
7979
}
8080

81+
82+
static inline void local_tlb_invalid_all(void)
83+
{
84+
tlb_invalid_all();
85+
}
86+
8187
static inline void tlb_invalid_indexed(void)
8288
{
8389
cpwcr("cpcr8", 0x02000000);

arch/csky/abiv1/inc/abi/string.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@
77
#define __HAVE_ARCH_MEMCPY
88
extern void *memcpy(void *, const void *, __kernel_size_t);
99

10-
#define __HAVE_ARCH_MEMSET
11-
extern void *memset(void *, int, __kernel_size_t);
12-
1310
#endif /* __ABI_CSKY_STRING_H */

arch/csky/abiv1/memset.c

Lines changed: 0 additions & 37 deletions
This file was deleted.

arch/csky/abiv1/strksyms.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
#include <linux/module.h>
55

66
EXPORT_SYMBOL(memcpy);
7-
EXPORT_SYMBOL(memset);

arch/csky/abiv2/inc/abi/ckmmu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ static inline void tlb_invalid_all(void)
8585
#endif
8686
}
8787

88+
static inline void local_tlb_invalid_all(void)
89+
{
90+
#ifdef CONFIG_CPU_HAS_TLBI
91+
asm volatile("tlbi.all\n":::"memory");
92+
sync_is();
93+
#else
94+
tlb_invalid_all();
95+
#endif
96+
}
97+
8898
static inline void tlb_invalid_indexed(void)
8999
{
90100
mtcr("cr<8, 15>", 0x02000000);

arch/csky/include/asm/asid.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_ASM_ASID_H
3+
#define __ASM_ASM_ASID_H
4+
5+
#include <linux/atomic.h>
6+
#include <linux/compiler.h>
7+
#include <linux/cpumask.h>
8+
#include <linux/percpu.h>
9+
#include <linux/spinlock.h>
10+
11+
struct asid_info
12+
{
13+
atomic64_t generation;
14+
unsigned long *map;
15+
atomic64_t __percpu *active;
16+
u64 __percpu *reserved;
17+
u32 bits;
18+
/* Lock protecting the structure */
19+
raw_spinlock_t lock;
20+
/* Which CPU requires context flush on next call */
21+
cpumask_t flush_pending;
22+
/* Number of ASID allocated by context (shift value) */
23+
unsigned int ctxt_shift;
24+
/* Callback to locally flush the context. */
25+
void (*flush_cpu_ctxt_cb)(void);
26+
};
27+
28+
#define NUM_ASIDS(info) (1UL << ((info)->bits))
29+
#define NUM_CTXT_ASIDS(info) (NUM_ASIDS(info) >> (info)->ctxt_shift)
30+
31+
#define active_asid(info, cpu) *per_cpu_ptr((info)->active, cpu)
32+
33+
void asid_new_context(struct asid_info *info, atomic64_t *pasid,
34+
unsigned int cpu, struct mm_struct *mm);
35+
36+
/*
37+
* Check the ASID is still valid for the context. If not generate a new ASID.
38+
*
39+
* @pasid: Pointer to the current ASID batch
40+
* @cpu: current CPU ID. Must have been acquired throught get_cpu()
41+
*/
42+
static inline void asid_check_context(struct asid_info *info,
43+
atomic64_t *pasid, unsigned int cpu,
44+
struct mm_struct *mm)
45+
{
46+
u64 asid, old_active_asid;
47+
48+
asid = atomic64_read(pasid);
49+
50+
/*
51+
* The memory ordering here is subtle.
52+
* If our active_asid is non-zero and the ASID matches the current
53+
* generation, then we update the active_asid entry with a relaxed
54+
* cmpxchg. Racing with a concurrent rollover means that either:
55+
*
56+
* - We get a zero back from the cmpxchg and end up waiting on the
57+
* lock. Taking the lock synchronises with the rollover and so
58+
* we are forced to see the updated generation.
59+
*
60+
* - We get a valid ASID back from the cmpxchg, which means the
61+
* relaxed xchg in flush_context will treat us as reserved
62+
* because atomic RmWs are totally ordered for a given location.
63+
*/
64+
old_active_asid = atomic64_read(&active_asid(info, cpu));
65+
if (old_active_asid &&
66+
!((asid ^ atomic64_read(&info->generation)) >> info->bits) &&
67+
atomic64_cmpxchg_relaxed(&active_asid(info, cpu),
68+
old_active_asid, asid))
69+
return;
70+
71+
asid_new_context(info, pasid, cpu, mm);
72+
}
73+
74+
int asid_allocator_init(struct asid_info *info,
75+
u32 bits, unsigned int asid_per_ctxt,
76+
void (*flush_cpu_ctxt_cb)(void));
77+
78+
#endif

arch/csky/include/asm/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define __ASM_CSKY_MMU_H
66

77
typedef struct {
8-
unsigned long asid[NR_CPUS];
8+
atomic64_t asid;
99
void *vdso;
1010
} mm_context_t;
1111

0 commit comments

Comments
 (0)