C-SKY(csky) Linux Kernel Port
Subsystems (6)
v8 cover C-SKY(csky) Linux Kernel Port
Because I've sent to Stephen Roth with the linux-4.19-rc3 git-tree for linux-next, I shouldn't rebase any more.
https://github.com/c-sky/csky-linux.git#linux-next
This patchset include mptimer and mpintc drivers and fixup:
- Fixup smp IPI's problems found by Marc Zyngier
- Add irq-csky-mpintc.c patch in this patchset
- Add mptimer.c patch in this patchset
- Fixup dma_sync_for_cpu/device in dma-mapping.c
Guo Ren (6):
csky/dma: bugfix dma_sync_for_cpu/device
csky: remove irq_mapping from smp.c
irqchip: add C-SKY SMP interrupt controller
dt-bindings: interrupt-controller: C-SKY SMP intc
clocksource: add C-SKY SMP timer
dt-bindings: timer: C-SKY Multi-processor timer
.../bindings/interrupt-controller/csky,mpintc.txt | 40 +++++ .../devicetree/bindings/timer/csky,mptimer.txt | 46 +++++ arch/csky/include/asm/smp.h | 4 +- arch/csky/kernel/smp.c | 27 ++- arch/csky/mm/dma-mapping.c | 5 +- drivers/clocksource/Kconfig | 8 + drivers/clocksource/Makefile | 1 + drivers/clocksource/csky_mptimer.c | 178 +++++++++++++++++++ drivers/irqchip/Kconfig | 8 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-csky-mpintc.c | 195 +++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 12 files changed, 503 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt create mode 100644 drivers/clocksource/csky_mptimer.c create mode 100644 drivers/irqchip/irq-csky-mpintc.c
Signature · 1 line
2.7.4
PATCH v8 1/6 csky/dma: bugfix dma_sync_for_cpu/device
ref: https://lkml.org/lkml/2018/5/18/1068
map for_cpu for_device unmap TO_DEV writeback none writeback none TO_CPU invalidate invalidate* invalidate invalidate* BIDIR writeback invalidate writeback invalidate
--- arch/csky/mm/dma-mapping.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/csky/mm/dma-mapping.c +3 -2
@@ -217,7 +217,8 @@ void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,break ;case DMA_FROM_DEVICE :case DMA_BIDIRECTIONAL : -BUG (); +dma_wbinv_range (vaddr + offset, vaddr + offset + size); +break ;default :BUG (); }
@@ -240,7 +241,7 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,switch (dir) {case DMA_TO_DEVICE : -BUG (); +break ;case DMA_FROM_DEVICE :case DMA_BIDIRECTIONAL :dma_wbinv_range (vaddr + offset, vaddr + offset + size);
Signature · 1 line
2.7.4
PATCH v8 2/6 csky: remove irq_mapping from smp.c
In reply to Guo Ren - Add irq_mapping return check
- Move IPI_IRQ into irq-driver
- remove irq_mapping from smp.c to irq-driver
- Add set_ipi_irq_mapping api to irq-driver
- update asm/smp.h
--- arch/csky/include/asm/smp.h | 4 +++- arch/csky/kernel/smp.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-)
arch/csky/include/asm/smp.h +3 -1
@@ -17,7 +17,9 @@ void arch_send_call_function_ipi_mask(struct cpumask *mask);void arch_send_call_function_single_ipi (int cpu); -void __init set_send_ipi (void (*func)(const unsigned long *,unsigned long )); +void __init set_send_ipi (void (*func)(const unsigned long *)); + +void __init set_ipi_irq_mapping (int (*func)(void ));#define raw_smp_processor_id () (current_thread_info()->cpu)
arch/csky/kernel/smp.c +19 -8
@@ -20,8 +20,6 @@#include <asm/mmu_context.h> #include <asm/pgalloc.h> -#define IPI_IRQ 15 -static struct {unsigned long bits____cacheline_aligned ; } ipi_data[NR_CPUS] __cacheline_aligned;
@@ -56,9 +54,9 @@ static irqreturn_t handle_ipi(int irq, void *dev)return IRQ_HANDLED ; } -static void (*send_arch_ipi)(const unsigned long *mask,unsigned long irq) =NULL ; +static void (*send_arch_ipi)(const unsigned long *mask) =NULL ; -void __init set_send_ipi (void (*func)(const unsigned long *,unsigned long )) +void __init set_send_ipi (void (*func)(const unsigned long *)) {if (send_arch_ipi)return ;
@@ -75,7 +73,7 @@ send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation)set_bit (operation, &ipi_data[i].bits);smp_mb (); -send_arch_ipi (cpumask_bits (to_whom),IPI_IRQ ); +send_arch_ipi (cpumask_bits (to_whom)); }void arch_send_call_function_ipi_mask (struct cpumask *mask)
@@ -115,19 +113,32 @@ void __init smp_prepare_cpus(unsigned int max_cpus) }static int ipi_dummy_dev; +static int ipi_irq;void __init enable_smp_ipi (void ) { -enable_percpu_irq (IPI_IRQ ,0 ); +enable_percpu_irq (ipi_irq,0 ); +} + +static int (*arch_ipi_irq_mapping)(void ) =NULL ; + +void __init set_ipi_irq_mapping (int (*func)(void )) +{ +if (arch_ipi_irq_mapping) +return ; + + arch_ipi_irq_mapping = func; }void __init setup_smp_ipi (void ) {int rc; -irq_create_mapping (NULL ,IPI_IRQ ); + ipi_irq =arch_ipi_irq_mapping (); +if (ipi_irq ==0 ) +panic ("%s IRQ mapping failed\n" , __func__); - rc =request_percpu_irq (IPI_IRQ , handle_ipi,"IPI Interrupt" , &ipi_dummy_dev); + rc =request_percpu_irq (ipi_irq, handle_ipi,"IPI Interrupt" , &ipi_dummy_dev);if (rc)panic ("%s IRQ request failed\n" , __func__);
Signature · 1 line
2.7.4
PATCH v8 3/6 irqchip: add C-SKY SMP interrupt controller
In reply to Guo Ren- Irq-csky-mpintc is C-SKY smp system interrupt controller and it could support 16 soft irqs, 16 private irqs, and 992 max common irqs.
Changelog:
- Move IPI_IRQ into the driver
- Remove irq_set_default_host() and use set_ipi_irq_mapping()
- Change name with upstream feed-back
- Change irq map, reserve soft_irq & private_irq space
- Add License and Copyright
- Support set_affinity for irq balance in SMP
--- drivers/irqchip/Kconfig | 8 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-csky-mpintc.c | 195 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 drivers/irqchip/irq-csky-mpintc.c
drivers/irqchip/Kconfig +8 -0
@@ -371,6 +371,14 @@ config QCOM_PDC Power Domain Controller driver to manage and configure wakeup IRQs for Qualcomm Technologies Inc (QTI) mobile chips. +config CSKY_MPINTC + bool "C-SKY Multi Processor Interrupt Controller" + depends on CSKY + help + Say yes here to enable C-SKY SMP interrupt controller driver used + for C-SKY SMP system. In fact it's not mmio map and it use ld/st + to visit the controller's register inside CPU. + endmenu config SIFIVE_PLIC
drivers/irqchip/Makefile +1 -0
@@ -87,4 +87,5 @@ obj-$(CONFIG_MESON_IRQ_GPIO) += irq-meson-gpio.o obj-$(CONFIG_GOLDFISH_PIC) += irq-goldfish-pic.o obj-$(CONFIG_NDS32) += irq-ativic32.o obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o +obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o
drivers/irqchip/irq-csky-mpintc.c new file +195 -0
195 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v8 4/6 dt-bindings: interrupt-controller: C-SKY SMP intc
In reply to Guo Ren- Dt-bindings doc about C-SKY Multi-processors interrupt controller.
--- .../bindings/interrupt-controller/csky,mpintc.txt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt new file +40 -0
@@ -0,0 +1,40 @@ +=========================================== +C-SKY Multi-processors Interrupt Controller +=========================================== + +C-SKY Multi-processors Interrupt Controller is designed for ck807/ck810/ck860 +SMP soc, and it also could be used in non-SMP system. + +Interrupt number definition: + + 0-15 : software irq, and we use 15 as our IPI_IRQ. + 16-31 : private irq, and we use 16 as the co-processor timer. + 31-1024: common irq for soc ip. + +============================= +intc node bindings definition +============================= + + Description: Describes SMP interrupt controller + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,mpintc" + - interrupt-cells + Usage: required + Value type: <u32> + Definition: must be <1> + - interrupt-controller: + Usage: required + +Examples: +--------- + + intc: interrupt-controller { + compatible = "csky,mpintc"; + #interrupt-cells = <1>; + interrupt-controller; + };
Signature · 1 line
2.7.4
PATCH v8 5/6 clocksource: add C-SKY SMP timer
In reply to Guo RenThis timer is used by SMP system and use mfcr/mtcr instruction to access the regs.
Changelog:
- Add CPUHP_AP_CSKY_TIMER_STARTING in cpuhotplug.h
- Support csky mp timer alpha version.
- Just use low-counter with 32bit width as clocksource.
- Coding convention with upstream feed-back.
--- drivers/clocksource/Kconfig | 8 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/csky_mptimer.c | 178 +++++++++++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + 4 files changed, 188 insertions(+) create mode 100644 drivers/clocksource/csky_mptimer.c
drivers/clocksource/Kconfig +8 -0
@@ -609,6 +609,14 @@ config ATCPIT100_TIMER help This option enables support for the Andestech ATCPIT100 timers. +config CSKY_MPTIMER + bool "C-SKY Multi Processor Timer" + depends on CSKY + select TIMER_OF + help + Say yes here to enable C-SKY SMP timer driver used for C-SKY SMP + system. + config RISCV_TIMER bool "Timer for the RISC-V platform" depends on RISCV
drivers/clocksource/Makefile +1 -0
@@ -79,3 +79,4 @@ obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o obj-$(CONFIG_X86_NUMACHIP) += numachip.o obj-$(CONFIG_ATCPIT100_TIMER) += timer-atcpit100.o obj-$(CONFIG_RISCV_TIMER) += riscv_timer.o +obj-$(CONFIG_CSKY_MPTIMER) += csky_mptimer.o
drivers/clocksource/csky_mptimer.c new file +178 -0
178 lines not on this page · raw message
include/linux/cpuhotplug.h +1 -0
@@ -126,6 +126,7 @@ enum cpuhp_state {CPUHP_AP_MIPS_GIC_TIMER_STARTING ,CPUHP_AP_ARC_TIMER_STARTING ,CPUHP_AP_RISCV_TIMER_STARTING , +CPUHP_AP_CSKY_TIMER_STARTING ,CPUHP_AP_KVM_STARTING ,CPUHP_AP_KVM_ARM_VGIC_INIT_STARTING , CPUHP_AP_KVM_ARM_VGIC_STARTING,
Signature · 1 line
2.7.4
Re: [PATCH V8 5/6] clocksource: add C-SKY SMP timer
drivers/clocksource/csky_mptimer.c line 119
Quoted 9 lines · Guo Ren
drivers/clocksource/csky_mptimer.c new file +9
-0+struct clocksource csky_clocksource = { + .name ="csky" , + .rating =400 , + .mask =CLOCKSOURCE_MASK (32 ), + .flags =CLOCK_SOURCE_IS_CONTINUOUS , + .read = clksrc_read, +}; + +#define CPUHP_AP_CSKY_TIMER_STARTING CPUHP_AP_RISCV_TIMER_STARTING
My fault, forget delete the line above.
Guo Ren
PATCH v8 6/6 dt-bindings: timer: C-SKY Multi-processor timer
In reply to Guo Ren- Dt-bingdings doc for C-SKY SMP system setting.
--- .../devicetree/bindings/timer/csky,mptimer.txt | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt
Documentation/devicetree/bindings/timer/csky,mptimer.txt new file +46 -0
@@ -0,0 +1,46 @@ +============================ +C-SKY Multi-processors Timer +============================ + +C-SKY multi-processors timer is designed for C-SKY SMP system and the +regs is accessed by cpu co-processor 4 registers with mtcr/mfcr. + + - PTIM_CTLR "cr<0, 14>" Control reg to start reset timer. + - PTIM_TSR "cr<1, 14>" Interrupt cleanup status reg. + - PTIM_CCVR "cr<3, 14>" Current counter value reg. + - PTIM_LVR "cr<6, 14>" Window value reg to triger next event. + +============================== +timer node bindings definition +============================== + + Description: Describes SMP timer + + PROPERTIES + + - compatible + Usage: required + Value type: <string> + Definition: must be "csky,mptimer" + - clocks + Usage: required + Value type: <node> + Definition: must be input clk node + - interrupts + Usage: required + Value type: <u32> + Definition: must be timer irq num defined by soc + - interrupt-parent: + Usage: required + Value type: <node> + Definition: must be interrupt controller node + +Examples: +--------- + + timer: timer { + compatible = "csky,mptimer"; + clocks = <&dummy_apb_clk>; + interrupts = <16>; + interrupt-parent = <&intc>; + };
Signature · 1 line
2.7.4