Skip to content

Commit

Permalink
Merge tag 'csky-for-linus-5.6-rc3' of git://github.com/c-sky/csky-linux
Browse files Browse the repository at this point in the history
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
  ...
  • Loading branch information
torvalds committed Feb 23, 2020
2 parents dca132a + 99db590 commit c6188df
Show file tree
Hide file tree
Showing 34 changed files with 663 additions and 164 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,7 @@ F: sound/pci/oxygen/

C-SKY ARCHITECTURE
M: Guo Ren <[email protected]>
L: [email protected]
T: git https://github.com/c-sky/csky-linux.git
S: Supported
F: arch/csky/
Expand Down
51 changes: 48 additions & 3 deletions arch/csky/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ config CSKY
select ARCH_USE_QUEUED_RWLOCKS if NR_CPUS>2
select COMMON_CLK
select CLKSRC_MMIO
select CLKSRC_OF
select CSKY_MPINTC if CPU_CK860
select CSKY_MP_TIMER if CPU_CK860
select CSKY_APB_INTC
Expand Down Expand Up @@ -37,6 +36,7 @@ config CSKY
select GX6605S_TIMER if CPU_CK610
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_AUDITSYSCALL
select HAVE_COPY_THREAD_TLS
select HAVE_DYNAMIC_FTRACE
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
Expand All @@ -47,8 +47,8 @@ config CSKY
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select HAVE_DMA_API_DEBUG
select HAVE_DMA_CONTIGUOUS
select HAVE_STACKPROTECTOR
select HAVE_SYSCALL_TRACEPOINTS
select MAY_HAVE_SPARSE_IRQ
select MODULES_USE_ELF_RELA if MODULES
Expand All @@ -59,6 +59,11 @@ config CSKY
select TIMER_OF
select USB_ARCH_HAS_EHCI
select USB_ARCH_HAS_OHCI
select GENERIC_PCI_IOMAP
select HAVE_PCI
select PCI_DOMAINS_GENERIC if PCI
select PCI_SYSCALL if PCI
select PCI_MSI if PCI

config CPU_HAS_CACHEV2
bool
Expand All @@ -75,7 +80,7 @@ config CPU_HAS_TLBI
config CPU_HAS_LDSTEX
bool
help
For SMP, CPU needs "ldex&stex" instrcutions to atomic operations.
For SMP, CPU needs "ldex&stex" instructions for atomic operations.

config CPU_NEED_TLBSYNC
bool
Expand Down Expand Up @@ -188,6 +193,40 @@ config CPU_PM_STOP
bool "stop"
endchoice

menuconfig HAVE_TCM
bool "Tightly-Coupled/Sram Memory"
select GENERIC_ALLOCATOR
help
The implementation are not only used by TCM (Tightly-Coupled Meory)
but also used by sram on SOC bus. It follow existed linux tcm
software interface, so that old tcm application codes could be
re-used directly.

if HAVE_TCM
config ITCM_RAM_BASE
hex "ITCM ram base"
default 0xffffffff

config ITCM_NR_PAGES
int "Page count of ITCM size: NR*4KB"
range 1 256
default 32

config HAVE_DTCM
bool "DTCM Support"

config DTCM_RAM_BASE
hex "DTCM ram base"
depends on HAVE_DTCM
default 0xffffffff

config DTCM_NR_PAGES
int "Page count of DTCM size: NR*4KB"
depends on HAVE_DTCM
range 1 256
default 32
endif

config CPU_HAS_VDSP
bool "CPU has VDSP coprocessor"
depends on CPU_HAS_FPU && CPU_HAS_FPUV2
Expand All @@ -196,6 +235,10 @@ config CPU_HAS_FPU
bool "CPU has FPU coprocessor"
depends on CPU_CK807 || CPU_CK810 || CPU_CK860

config CPU_HAS_ICACHE_INS
bool "CPU has Icache invalidate instructions"
depends on CPU_HAS_CACHEV2

config CPU_HAS_TEE
bool "CPU has Trusted Execution Environment"
depends on CPU_CK810
Expand Down Expand Up @@ -235,4 +278,6 @@ config HOTPLUG_CPU
Say N if you want to disable CPU hotplug.
endmenu

source "arch/csky/Kconfig.platforms"

source "kernel/Kconfig.hz"
9 changes: 9 additions & 0 deletions arch/csky/Kconfig.platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu "Platform drivers selection"

config ARCH_CSKY_DW_APB_ICTL
bool "Select dw-apb interrupt controller"
select DW_APB_ICTL
default y
help
This enables support for snps dw-apb-ictl
endmenu
5 changes: 2 additions & 3 deletions arch/csky/abiv1/inc/abi/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, u

#define flush_icache_page(vma, page) do {} while (0);
#define flush_icache_range(start, end) cache_wbinv_range(start, end)

#define flush_icache_user_range(vma,page,addr,len) \
flush_dcache_page(page)
#define flush_icache_mm_range(mm, start, end) cache_wbinv_range(start, end)
#define flush_icache_deferred(mm) do {} while (0);

#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
do { \
Expand Down
19 changes: 14 additions & 5 deletions arch/csky/abiv1/inc/abi/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
#define LSAVE_A4 40
#define LSAVE_A5 44

#define usp ss1

.macro USPTOKSP
mtcr sp, ss1
mtcr sp, usp
mfcr sp, ss0
.endm

.macro KSPTOUSP
mtcr sp, ss0
mfcr sp, ss1
mfcr sp, usp
.endm

.macro SAVE_ALL epc_inc
Expand All @@ -45,7 +47,13 @@
add lr, r13
stw lr, (sp, 8)

mov lr, sp
addi lr, 32
addi lr, 32
addi lr, 16
bt 2f
mfcr lr, ss1
2:
stw lr, (sp, 16)

stw a0, (sp, 20)
Expand Down Expand Up @@ -79,9 +87,10 @@
ldw a0, (sp, 12)
mtcr a0, epsr
btsti a0, 31
bt 1f
ldw a0, (sp, 16)
mtcr a0, ss1

1:
ldw a0, (sp, 24)
ldw a1, (sp, 28)
ldw a2, (sp, 32)
Expand All @@ -102,9 +111,9 @@
addi sp, 32
addi sp, 8

bt 1f
bt 2f
KSPTOUSP
1:
2:
rte
.endm

Expand Down
84 changes: 59 additions & 25 deletions arch/csky/abiv2/cacheflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,80 @@
#include <linux/mm.h>
#include <asm/cache.h>

void flush_icache_page(struct vm_area_struct *vma, struct page *page)
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
pte_t *pte)
{
unsigned long start;
unsigned long addr;
struct page *page;

start = (unsigned long) kmap_atomic(page);
page = pfn_to_page(pte_pfn(*pte));
if (page == ZERO_PAGE(0))
return;

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

kunmap_atomic((void *)start);
}
addr = (unsigned long) kmap_atomic(page);

void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
unsigned long vaddr, int len)
{
unsigned long kaddr;
dcache_wb_range(addr, addr + PAGE_SIZE);

kaddr = (unsigned long) kmap_atomic(page) + (vaddr & ~PAGE_MASK);
if (vma->vm_flags & VM_EXEC)
icache_inv_range(addr, addr + PAGE_SIZE);

kunmap_atomic((void *) addr);
}

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

kunmap_atomic((void *)kaddr);
if (cpumask_test_cpu(cpu, mask)) {
cpumask_clear_cpu(cpu, mask);
/*
* Ensure the remote hart's writes are visible to this hart.
* This pairs with a barrier in flush_icache_mm.
*/
smp_mb();
local_icache_inv_all(NULL);
}
}

void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
pte_t *pte)
void flush_icache_mm_range(struct mm_struct *mm,
unsigned long start, unsigned long end)
{
unsigned long addr, pfn;
struct page *page;
unsigned int cpu;
cpumask_t others, *mask;

pfn = pte_pfn(*pte);
if (unlikely(!pfn_valid(pfn)))
return;
preempt_disable();

page = pfn_to_page(pfn);
if (page == ZERO_PAGE(0))
#ifdef CONFIG_CPU_HAS_ICACHE_INS
if (mm == current->mm) {
icache_inv_range(start, end);
preempt_enable();
return;
}
#endif

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

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

kunmap_atomic((void *) addr);
/*
* Flush the I$ of other harts concurrently executing, and mark them as
* flushed.
*/
cpumask_andnot(&others, mm_cpumask(mm), cpumask_of(cpu));

if (mm != current->active_mm || !cpumask_empty(&others)) {
on_each_cpu_mask(&others, local_icache_inv_all, NULL, 1);
cpumask_clear(mask);
}

preempt_enable();
}
33 changes: 21 additions & 12 deletions arch/csky/abiv2/inc/abi/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,41 @@
#define flush_cache_all() do { } while (0)
#define flush_cache_mm(mm) do { } while (0)
#define flush_cache_dup_mm(mm) do { } while (0)
#define flush_cache_range(vma, start, end) do { } while (0)
#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)

#define flush_cache_range(vma, start, end) \
do { \
if (vma->vm_flags & VM_EXEC) \
icache_inv_all(); \
} while (0)
#define PG_dcache_clean PG_arch_1

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
static inline void flush_dcache_page(struct page *page)
{
if (test_bit(PG_dcache_clean, &page->flags))
clear_bit(PG_dcache_clean, &page->flags);
}

#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
#define flush_dcache_page(page) do { } while (0)
#define flush_dcache_mmap_lock(mapping) do { } while (0)
#define flush_dcache_mmap_unlock(mapping) do { } while (0)
#define flush_icache_page(vma, page) do { } while (0)

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

void flush_icache_page(struct vm_area_struct *vma, struct page *page);
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
unsigned long vaddr, int len);
void flush_icache_mm_range(struct mm_struct *mm,
unsigned long start, unsigned long end);
void flush_icache_deferred(struct mm_struct *mm);

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

#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
do { \
memcpy(dst, src, len); \
cache_wbinv_range((unsigned long)dst, (unsigned long)dst + len); \
if (vma->vm_flags & VM_EXEC) { \
dcache_wb_range((unsigned long)dst, \
(unsigned long)dst + len); \
flush_icache_mm_range(current->mm, \
(unsigned long)dst, \
(unsigned long)dst + len); \
} \
} while (0)
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
memcpy(dst, src, len)
Expand Down
11 changes: 11 additions & 0 deletions arch/csky/abiv2/inc/abi/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@

mfcr lr, epsr
stw lr, (sp, 12)
btsti lr, 31
bf 1f
addi lr, sp, 152
br 2f
1:
mfcr lr, usp
2:
stw lr, (sp, 16)

stw a0, (sp, 20)
Expand Down Expand Up @@ -64,8 +70,10 @@
mtcr a0, epc
ldw a0, (sp, 12)
mtcr a0, epsr
btsti a0, 31
ldw a0, (sp, 16)
mtcr a0, usp
mtcr a0, ss0

#ifdef CONFIG_CPU_HAS_HILO
ldw a0, (sp, 140)
Expand All @@ -86,6 +94,9 @@
addi sp, 40
ldm r16-r30, (sp)
addi sp, 72
bf 1f
mfcr sp, ss0
1:
rte
.endm

Expand Down
Loading

0 comments on commit c6188df

Please sign in to comment.