Skip to content

Commit c6188df

Browse files
committed
Merge tag 'csky-for-linus-5.6-rc3' of git://github.com/c-sky/csky-linux
Pull csky updates from Guo Ren: "Sorry, I missed 5.6-rc1 merge window, but in this pull request the most are the fixes and the rests are between fixes and features. The only outside modification is the MAINTAINERS file update with our mailing list. - cache flush implementation fixes - ftrace modify panic fix - CONFIG_SMP boot problem fix - fix pt_regs saving for atomic.S - fix fixaddr_init without highmem. - fix stack protector support - fix fake Tightly-Coupled Memory code compile and use - fix some typos and coding convention" * tag 'csky-for-linus-5.6-rc3' of git://github.com/c-sky/csky-linux: (23 commits) csky: Replace <linux/clk-provider.h> by <linux/of_clk.h> csky: Implement copy_thread_tls csky: Add PCI support csky: Minimize defconfig to support buildroot config.fragment csky: Add setup_initrd check code csky: Cleanup old Kconfig options arch/csky: fix some Kconfig typos csky: Fixup compile warning for three unimplemented syscalls csky: Remove unused cache implementation csky: Fixup ftrace modify panic csky: Add flush_icache_mm to defer flush icache all csky: Optimize abiv2 copy_to_user_page with VM_EXEC csky: Enable defer flush_dcache_page for abiv2 cpus (807/810/860) csky: Remove unnecessary flush_icache_* implementation csky: Support icache flush without specific instructions csky/Kconfig: Add Kconfig.platforms to support some drivers csky/smp: Fixup boot failed when CONFIG_SMP csky: Set regs->usp to kernel sp, when the exception is from kernel csky/mm: Fixup export invalid_pte_table symbol csky: Separate fixaddr_init from highmem ...
2 parents dca132a + 99db590 commit c6188df

34 files changed

+663
-164
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,6 +3649,7 @@ F: sound/pci/oxygen/
36493649

36503650
C-SKY ARCHITECTURE
36513651
M: Guo Ren <[email protected]>
3652+
36523653
T: git https://github.com/c-sky/csky-linux.git
36533654
S: Supported
36543655
F: arch/csky/

arch/csky/Kconfig

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ config CSKY
99
select ARCH_USE_QUEUED_RWLOCKS if NR_CPUS>2
1010
select COMMON_CLK
1111
select CLKSRC_MMIO
12-
select CLKSRC_OF
1312
select CSKY_MPINTC if CPU_CK860
1413
select CSKY_MP_TIMER if CPU_CK860
1514
select CSKY_APB_INTC
@@ -37,6 +36,7 @@ config CSKY
3736
select GX6605S_TIMER if CPU_CK610
3837
select HAVE_ARCH_TRACEHOOK
3938
select HAVE_ARCH_AUDITSYSCALL
39+
select HAVE_COPY_THREAD_TLS
4040
select HAVE_DYNAMIC_FTRACE
4141
select HAVE_FUNCTION_TRACER
4242
select HAVE_FUNCTION_GRAPH_TRACER
@@ -47,8 +47,8 @@ config CSKY
4747
select HAVE_PERF_EVENTS
4848
select HAVE_PERF_REGS
4949
select HAVE_PERF_USER_STACK_DUMP
50-
select HAVE_DMA_API_DEBUG
5150
select HAVE_DMA_CONTIGUOUS
51+
select HAVE_STACKPROTECTOR
5252
select HAVE_SYSCALL_TRACEPOINTS
5353
select MAY_HAVE_SPARSE_IRQ
5454
select MODULES_USE_ELF_RELA if MODULES
@@ -59,6 +59,11 @@ config CSKY
5959
select TIMER_OF
6060
select USB_ARCH_HAS_EHCI
6161
select USB_ARCH_HAS_OHCI
62+
select GENERIC_PCI_IOMAP
63+
select HAVE_PCI
64+
select PCI_DOMAINS_GENERIC if PCI
65+
select PCI_SYSCALL if PCI
66+
select PCI_MSI if PCI
6267

6368
config CPU_HAS_CACHEV2
6469
bool
@@ -75,7 +80,7 @@ config CPU_HAS_TLBI
7580
config CPU_HAS_LDSTEX
7681
bool
7782
help
78-
For SMP, CPU needs "ldex&stex" instrcutions to atomic operations.
83+
For SMP, CPU needs "ldex&stex" instructions for atomic operations.
7984

8085
config CPU_NEED_TLBSYNC
8186
bool
@@ -188,6 +193,40 @@ config CPU_PM_STOP
188193
bool "stop"
189194
endchoice
190195

196+
menuconfig HAVE_TCM
197+
bool "Tightly-Coupled/Sram Memory"
198+
select GENERIC_ALLOCATOR
199+
help
200+
The implementation are not only used by TCM (Tightly-Coupled Meory)
201+
but also used by sram on SOC bus. It follow existed linux tcm
202+
software interface, so that old tcm application codes could be
203+
re-used directly.
204+
205+
if HAVE_TCM
206+
config ITCM_RAM_BASE
207+
hex "ITCM ram base"
208+
default 0xffffffff
209+
210+
config ITCM_NR_PAGES
211+
int "Page count of ITCM size: NR*4KB"
212+
range 1 256
213+
default 32
214+
215+
config HAVE_DTCM
216+
bool "DTCM Support"
217+
218+
config DTCM_RAM_BASE
219+
hex "DTCM ram base"
220+
depends on HAVE_DTCM
221+
default 0xffffffff
222+
223+
config DTCM_NR_PAGES
224+
int "Page count of DTCM size: NR*4KB"
225+
depends on HAVE_DTCM
226+
range 1 256
227+
default 32
228+
endif
229+
191230
config CPU_HAS_VDSP
192231
bool "CPU has VDSP coprocessor"
193232
depends on CPU_HAS_FPU && CPU_HAS_FPUV2
@@ -196,6 +235,10 @@ config CPU_HAS_FPU
196235
bool "CPU has FPU coprocessor"
197236
depends on CPU_CK807 || CPU_CK810 || CPU_CK860
198237

238+
config CPU_HAS_ICACHE_INS
239+
bool "CPU has Icache invalidate instructions"
240+
depends on CPU_HAS_CACHEV2
241+
199242
config CPU_HAS_TEE
200243
bool "CPU has Trusted Execution Environment"
201244
depends on CPU_CK810
@@ -235,4 +278,6 @@ config HOTPLUG_CPU
235278
Say N if you want to disable CPU hotplug.
236279
endmenu
237280

281+
source "arch/csky/Kconfig.platforms"
282+
238283
source "kernel/Kconfig.hz"

arch/csky/Kconfig.platforms

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
menu "Platform drivers selection"
2+
3+
config ARCH_CSKY_DW_APB_ICTL
4+
bool "Select dw-apb interrupt controller"
5+
select DW_APB_ICTL
6+
default y
7+
help
8+
This enables support for snps dw-apb-ictl
9+
endmenu

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, u
4848

4949
#define flush_icache_page(vma, page) do {} while (0);
5050
#define flush_icache_range(start, end) cache_wbinv_range(start, end)
51-
52-
#define flush_icache_user_range(vma,page,addr,len) \
53-
flush_dcache_page(page)
51+
#define flush_icache_mm_range(mm, start, end) cache_wbinv_range(start, end)
52+
#define flush_icache_deferred(mm) do {} while (0);
5453

5554
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
5655
do { \

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
#define LSAVE_A4 40
1717
#define LSAVE_A5 44
1818

19+
#define usp ss1
20+
1921
.macro USPTOKSP
20-
mtcr sp, ss1
22+
mtcr sp, usp
2123
mfcr sp, ss0
2224
.endm
2325

2426
.macro KSPTOUSP
2527
mtcr sp, ss0
26-
mfcr sp, ss1
28+
mfcr sp, usp
2729
.endm
2830

2931
.macro SAVE_ALL epc_inc
@@ -45,7 +47,13 @@
4547
add lr, r13
4648
stw lr, (sp, 8)
4749

50+
mov lr, sp
51+
addi lr, 32
52+
addi lr, 32
53+
addi lr, 16
54+
bt 2f
4855
mfcr lr, ss1
56+
2:
4957
stw lr, (sp, 16)
5058

5159
stw a0, (sp, 20)
@@ -79,9 +87,10 @@
7987
ldw a0, (sp, 12)
8088
mtcr a0, epsr
8189
btsti a0, 31
90+
bt 1f
8291
ldw a0, (sp, 16)
8392
mtcr a0, ss1
84-
93+
1:
8594
ldw a0, (sp, 24)
8695
ldw a1, (sp, 28)
8796
ldw a2, (sp, 32)
@@ -102,9 +111,9 @@
102111
addi sp, 32
103112
addi sp, 8
104113

105-
bt 1f
114+
bt 2f
106115
KSPTOUSP
107-
1:
116+
2:
108117
rte
109118
.endm
110119

arch/csky/abiv2/cacheflush.c

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,80 @@
66
#include <linux/mm.h>
77
#include <asm/cache.h>
88

9-
void flush_icache_page(struct vm_area_struct *vma, struct page *page)
9+
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
10+
pte_t *pte)
1011
{
11-
unsigned long start;
12+
unsigned long addr;
13+
struct page *page;
1214

13-
start = (unsigned long) kmap_atomic(page);
15+
page = pfn_to_page(pte_pfn(*pte));
16+
if (page == ZERO_PAGE(0))
17+
return;
1418

15-
cache_wbinv_range(start, start + PAGE_SIZE);
19+
if (test_and_set_bit(PG_dcache_clean, &page->flags))
20+
return;
1621

17-
kunmap_atomic((void *)start);
18-
}
22+
addr = (unsigned long) kmap_atomic(page);
1923

20-
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
21-
unsigned long vaddr, int len)
22-
{
23-
unsigned long kaddr;
24+
dcache_wb_range(addr, addr + PAGE_SIZE);
2425

25-
kaddr = (unsigned long) kmap_atomic(page) + (vaddr & ~PAGE_MASK);
26+
if (vma->vm_flags & VM_EXEC)
27+
icache_inv_range(addr, addr + PAGE_SIZE);
28+
29+
kunmap_atomic((void *) addr);
30+
}
2631

27-
cache_wbinv_range(kaddr, kaddr + len);
32+
void flush_icache_deferred(struct mm_struct *mm)
33+
{
34+
unsigned int cpu = smp_processor_id();
35+
cpumask_t *mask = &mm->context.icache_stale_mask;
2836

29-
kunmap_atomic((void *)kaddr);
37+
if (cpumask_test_cpu(cpu, mask)) {
38+
cpumask_clear_cpu(cpu, mask);
39+
/*
40+
* Ensure the remote hart's writes are visible to this hart.
41+
* This pairs with a barrier in flush_icache_mm.
42+
*/
43+
smp_mb();
44+
local_icache_inv_all(NULL);
45+
}
3046
}
3147

32-
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
33-
pte_t *pte)
48+
void flush_icache_mm_range(struct mm_struct *mm,
49+
unsigned long start, unsigned long end)
3450
{
35-
unsigned long addr, pfn;
36-
struct page *page;
51+
unsigned int cpu;
52+
cpumask_t others, *mask;
3753

38-
pfn = pte_pfn(*pte);
39-
if (unlikely(!pfn_valid(pfn)))
40-
return;
54+
preempt_disable();
4155

42-
page = pfn_to_page(pfn);
43-
if (page == ZERO_PAGE(0))
56+
#ifdef CONFIG_CPU_HAS_ICACHE_INS
57+
if (mm == current->mm) {
58+
icache_inv_range(start, end);
59+
preempt_enable();
4460
return;
61+
}
62+
#endif
4563

46-
addr = (unsigned long) kmap_atomic(page);
64+
/* Mark every hart's icache as needing a flush for this MM. */
65+
mask = &mm->context.icache_stale_mask;
66+
cpumask_setall(mask);
4767

48-
cache_wbinv_range(addr, addr + PAGE_SIZE);
68+
/* Flush this hart's I$ now, and mark it as flushed. */
69+
cpu = smp_processor_id();
70+
cpumask_clear_cpu(cpu, mask);
71+
local_icache_inv_all(NULL);
4972

50-
kunmap_atomic((void *) addr);
73+
/*
74+
* Flush the I$ of other harts concurrently executing, and mark them as
75+
* flushed.
76+
*/
77+
cpumask_andnot(&others, mm_cpumask(mm), cpumask_of(cpu));
78+
79+
if (mm != current->active_mm || !cpumask_empty(&others)) {
80+
on_each_cpu_mask(&others, local_icache_inv_all, NULL, 1);
81+
cpumask_clear(mask);
82+
}
83+
84+
preempt_enable();
5185
}

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,41 @@
1313
#define flush_cache_all() do { } while (0)
1414
#define flush_cache_mm(mm) do { } while (0)
1515
#define flush_cache_dup_mm(mm) do { } while (0)
16+
#define flush_cache_range(vma, start, end) do { } while (0)
17+
#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
1618

17-
#define flush_cache_range(vma, start, end) \
18-
do { \
19-
if (vma->vm_flags & VM_EXEC) \
20-
icache_inv_all(); \
21-
} while (0)
19+
#define PG_dcache_clean PG_arch_1
20+
21+
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
22+
static inline void flush_dcache_page(struct page *page)
23+
{
24+
if (test_bit(PG_dcache_clean, &page->flags))
25+
clear_bit(PG_dcache_clean, &page->flags);
26+
}
2227

23-
#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
24-
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
25-
#define flush_dcache_page(page) do { } while (0)
2628
#define flush_dcache_mmap_lock(mapping) do { } while (0)
2729
#define flush_dcache_mmap_unlock(mapping) do { } while (0)
30+
#define flush_icache_page(vma, page) do { } while (0)
2831

2932
#define flush_icache_range(start, end) cache_wbinv_range(start, end)
3033

31-
void flush_icache_page(struct vm_area_struct *vma, struct page *page);
32-
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
33-
unsigned long vaddr, int len);
34+
void flush_icache_mm_range(struct mm_struct *mm,
35+
unsigned long start, unsigned long end);
36+
void flush_icache_deferred(struct mm_struct *mm);
3437

3538
#define flush_cache_vmap(start, end) do { } while (0)
3639
#define flush_cache_vunmap(start, end) do { } while (0)
3740

3841
#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
3942
do { \
4043
memcpy(dst, src, len); \
41-
cache_wbinv_range((unsigned long)dst, (unsigned long)dst + len); \
44+
if (vma->vm_flags & VM_EXEC) { \
45+
dcache_wb_range((unsigned long)dst, \
46+
(unsigned long)dst + len); \
47+
flush_icache_mm_range(current->mm, \
48+
(unsigned long)dst, \
49+
(unsigned long)dst + len); \
50+
} \
4251
} while (0)
4352
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
4453
memcpy(dst, src, len)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131

3232
mfcr lr, epsr
3333
stw lr, (sp, 12)
34+
btsti lr, 31
35+
bf 1f
36+
addi lr, sp, 152
37+
br 2f
38+
1:
3439
mfcr lr, usp
40+
2:
3541
stw lr, (sp, 16)
3642

3743
stw a0, (sp, 20)
@@ -64,8 +70,10 @@
6470
mtcr a0, epc
6571
ldw a0, (sp, 12)
6672
mtcr a0, epsr
73+
btsti a0, 31
6774
ldw a0, (sp, 16)
6875
mtcr a0, usp
76+
mtcr a0, ss0
6977

7078
#ifdef CONFIG_CPU_HAS_HILO
7179
ldw a0, (sp, 140)
@@ -86,6 +94,9 @@
8694
addi sp, 40
8795
ldm r16-r30, (sp)
8896
addi sp, 72
97+
bf 1f
98+
mfcr sp, ss0
99+
1:
89100
rte
90101
.endm
91102

0 commit comments

Comments
 (0)