From 43dcced80c491423f308df634a8712c058eb4063 Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Sun, 25 Aug 2019 00:03:31 -0700 Subject: [PATCH] Update out-of-tree patches for RISC-V (riscv64) - SECCOMP v2 was posted for review (one failing kernel selftest) - SiFive Ethernet driver is approved upstream and might land in 5.3 - SiFive CPUFreq support is WIP, but people reported it working Signed-off-by: David Abdurachmanov --- 0001-SiFive-Unleashed-Ethernet.patch | 61 ++++++++ 0002-SiFive-Unleashed-CPUFreq.patch | 140 ++++++++++++++++++ .../fedora/generic/riscv/CONFIG_CPUFREQ_DT | 1 + .../CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | 1 + .../CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE | 1 + kernel-riscv64-debug.config | 6 +- kernel-riscv64.config | 6 +- kernel.spec | 13 +- 8 files changed, 222 insertions(+), 7 deletions(-) create mode 100644 0001-SiFive-Unleashed-Ethernet.patch create mode 100644 0002-SiFive-Unleashed-CPUFreq.patch create mode 100644 configs/fedora/generic/riscv/CONFIG_CPUFREQ_DT create mode 100644 configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND create mode 100644 configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE diff --git a/0001-SiFive-Unleashed-Ethernet.patch b/0001-SiFive-Unleashed-Ethernet.patch new file mode 100644 index 000000000..91d6231df --- /dev/null +++ b/0001-SiFive-Unleashed-Ethernet.patch @@ -0,0 +1,61 @@ +From 0b2b2c260e4f6d088afe7940d036d154d3076ff5 Mon Sep 17 00:00:00 2001 +From: Fedora Kernel Team +Date: Sun, 25 Aug 2019 06:57:36 +0000 +Subject: [PATCH 1/2] SiFive Unleashed Ethernet + +--- + Documentation/devicetree/bindings/net/macb.txt | 4 ++-- + arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts | 9 +++++++++ + drivers/net/ethernet/cadence/macb_main.c | 2 +- + 3 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt +index 63c73fa..0b61a90 100644 +--- a/Documentation/devicetree/bindings/net/macb.txt ++++ b/Documentation/devicetree/bindings/net/macb.txt +@@ -15,10 +15,10 @@ Required properties: + Use "atmel,sama5d4-gem" for the GEM IP (10/100) available on Atmel sama5d4 SoCs. + Use "cdns,zynq-gem" Xilinx Zynq-7xxx SoC. + Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC. +- Use "sifive,fu540-macb" for SiFive FU540-C000 SoC. ++ Use "sifive,fu540-c000-gem" for SiFive FU540-C000 SoC. + Or the generic form: "cdns,emac". + - reg: Address and length of the register set for the device +- For "sifive,fu540-macb", second range is required to specify the ++ For "sifive,fu540-c000-gem", second range is required to specify the + address and length of the registers for GEMGXL Management block. + - interrupts: Should contain macb interrupt + - phy-mode: See ethernet.txt file in the same directory. +diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +index 93d68cb..54fc701 100644 +--- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts ++++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +@@ -85,3 +85,12 @@ + reg = <0>; + }; + }; ++ ++ð0 { ++ status = "okay"; ++ phy-mode = "gmii"; ++ phy-handle = <&phy1>; ++ phy1: ethernet-phy@0 { ++ reg = <0>; ++ }; ++}; +diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c +index 5ca17e6..35b59b5 100644 +--- a/drivers/net/ethernet/cadence/macb_main.c ++++ b/drivers/net/ethernet/cadence/macb_main.c +@@ -4154,7 +4154,7 @@ static const struct of_device_id macb_dt_ids[] = { + { .compatible = "cdns,emac", .data = &emac_config }, + { .compatible = "cdns,zynqmp-gem", .data = &zynqmp_config}, + { .compatible = "cdns,zynq-gem", .data = &zynq_config }, +- { .compatible = "sifive,fu540-macb", .data = &fu540_c000_config }, ++ { .compatible = "sifive,fu540-c000-gem", .data = &fu540_c000_config }, + { /* sentinel */ } + }; + MODULE_DEVICE_TABLE(of, macb_dt_ids); +-- +2.23.0 + diff --git a/0002-SiFive-Unleashed-CPUFreq.patch b/0002-SiFive-Unleashed-CPUFreq.patch new file mode 100644 index 000000000..79c25eb01 --- /dev/null +++ b/0002-SiFive-Unleashed-CPUFreq.patch @@ -0,0 +1,140 @@ +From 8d741d97eeb3a0c1b9aa09da15fbb1c5c7214fcd Mon Sep 17 00:00:00 2001 +From: Fedora Kernel Team +Date: Sun, 25 Aug 2019 06:58:34 +0000 +Subject: [PATCH 2/2] SiFive Unleashed CPUFreq + +Signed-off-by: Fedora Kernel Team +--- + arch/riscv/Kconfig | 8 +++++ + arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 5 +++ + .../boot/dts/sifive/hifive-unleashed-a00.dts | 34 +++++++++++++++++++ + arch/riscv/configs/defconfig | 5 +++ + 4 files changed, 52 insertions(+) + +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig +index 441e63f..ccd590c 100644 +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -298,6 +298,14 @@ endchoice + + endmenu + ++menu "CPU Power Management" ++ ++source "drivers/cpuidle/Kconfig" ++ ++source "drivers/cpufreq/Kconfig" ++ ++endmenu ++ + menu "Power management options" + + source "kernel/power/Kconfig" +diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi +index 42b5ec2..b07079f 100644 +--- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi ++++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi +@@ -29,6 +29,7 @@ + i-cache-size = <16384>; + reg = <0>; + riscv,isa = "rv64imac"; ++ clocks = <&prci PRCI_CLK_COREPLL>; + status = "disabled"; + cpu0_intc: interrupt-controller { + #interrupt-cells = <1>; +@@ -53,6 +54,7 @@ + reg = <1>; + riscv,isa = "rv64imafdc"; + tlb-split; ++ clocks = <&prci PRCI_CLK_COREPLL>; + cpu1_intc: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; +@@ -77,6 +79,7 @@ + reg = <2>; + riscv,isa = "rv64imafdc"; + tlb-split; ++ clocks = <&prci PRCI_CLK_COREPLL>; + cpu2_intc: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; +@@ -101,6 +104,7 @@ + reg = <3>; + riscv,isa = "rv64imafdc"; + tlb-split; ++ clocks = <&prci PRCI_CLK_COREPLL>; + cpu3_intc: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; +@@ -125,6 +129,7 @@ + reg = <4>; + riscv,isa = "rv64imafdc"; + tlb-split; ++ clocks = <&prci PRCI_CLK_COREPLL>; + cpu4_intc: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; +diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +index 54fc701..5b43bdf 100644 +--- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts ++++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +@@ -40,6 +40,40 @@ + clock-frequency = ; + clock-output-names = "rtcclk"; + }; ++ ++ fu540_c000_opp_table: opp-table { ++ compatible = "operating-points-v2"; ++ opp-shared; ++ ++ opp-350000000 { ++ opp-hz = /bits/ 64 <350000000>; ++ }; ++ opp-700000000 { ++ opp-hz = /bits/ 64 <700000000>; ++ }; ++ opp-999999999 { ++ opp-hz = /bits/ 64 <999999999>; ++ }; ++ opp-1400000000 { ++ opp-hz = /bits/ 64 <1400000000>; ++ }; ++ }; ++}; ++ ++&cpu0 { ++ operating-points-v2 = <&fu540_c000_opp_table>; ++}; ++&cpu1 { ++ operating-points-v2 = <&fu540_c000_opp_table>; ++}; ++&cpu2 { ++ operating-points-v2 = <&fu540_c000_opp_table>; ++}; ++&cpu3 { ++ operating-points-v2 = <&fu540_c000_opp_table>; ++}; ++&cpu4 { ++ operating-points-v2 = <&fu540_c000_opp_table>; + }; + + &uart0 { +diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig +index 3efff55..c9542a9 100644 +--- a/arch/riscv/configs/defconfig ++++ b/arch/riscv/configs/defconfig +@@ -16,6 +16,11 @@ CONFIG_EXPERT=y + CONFIG_BPF_SYSCALL=y + CONFIG_SOC_SIFIVE=y + CONFIG_SMP=y ++CONFIG_CPU_IDLE=y ++CONFIG_CPU_FREQ=y ++CONFIG_CPU_FREQ_STAT=y ++CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y ++CONFIG_CPUFREQ_DT=y + CONFIG_MODULES=y + CONFIG_MODULE_UNLOAD=y + CONFIG_NET=y +-- +2.23.0 + diff --git a/configs/fedora/generic/riscv/CONFIG_CPUFREQ_DT b/configs/fedora/generic/riscv/CONFIG_CPUFREQ_DT new file mode 100644 index 000000000..0c7667d7e --- /dev/null +++ b/configs/fedora/generic/riscv/CONFIG_CPUFREQ_DT @@ -0,0 +1 @@ +CONFIG_CPUFREQ_DT=y diff --git a/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND b/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND new file mode 100644 index 000000000..39bec5884 --- /dev/null +++ b/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND @@ -0,0 +1 @@ +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set diff --git a/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE b/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE new file mode 100644 index 000000000..90044ac60 --- /dev/null +++ b/configs/fedora/generic/riscv/CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE @@ -0,0 +1 @@ +CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y diff --git a/kernel-riscv64-debug.config b/kernel-riscv64-debug.config index 480edf3a6..e8b826185 100644 --- a/kernel-riscv64-debug.config +++ b/kernel-riscv64-debug.config @@ -770,12 +770,12 @@ CONFIG_CORTINA_PHY=m # CONFIG_CPU5_WDT is not set # CONFIG_CPU_BIG_ENDIAN is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set -CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set -# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set -# CONFIG_CPUFREQ_DT is not set +CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y +CONFIG_CPUFREQ_DT=y CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_CPU_FREQ_GOV_PERFORMANCE=y diff --git a/kernel-riscv64.config b/kernel-riscv64.config index dba435619..0d8300d44 100644 --- a/kernel-riscv64.config +++ b/kernel-riscv64.config @@ -769,12 +769,12 @@ CONFIG_CORTINA_PHY=m # CONFIG_CPU5_WDT is not set # CONFIG_CPU_BIG_ENDIAN is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set -CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set -# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set -# CONFIG_CPUFREQ_DT is not set +CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y +CONFIG_CPUFREQ_DT=y CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_CPU_FREQ_GOV_PERFORMANCE=y diff --git a/kernel.spec b/kernel.spec index 7c6904f40..09fb7210c 100644 --- a/kernel.spec +++ b/kernel.spec @@ -592,9 +592,20 @@ Patch507: 0001-Drop-that-for-now.patch # Submitted upstream at https://lkml.org/lkml/2019/4/23/89 Patch508: KEYS-Make-use-of-platform-keyring-for-module-signature.patch -# RISC-V SECCOMP support v2 (not posted on linux-riscv yet) +# RISC-V SECCOMP support v2 (posted on linux-riscv) +# http://lists.infradead.org/pipermail/linux-riscv/2019-August/006235.html Patch550: 0001-riscv-add-SECCOMP-support.patch +# RISC-V SiFive Unleashed Ethernet driver +# Posted upstream, might land in 5.3 +# https://patchwork.kernel.org/patch/11050003/ +Patch551: 0002-SiFive-Unleashed-CPUFreq.patch + +# RISC-V SiFive Unleashed CPUFreq support +# WIP, private dev branch +# https://github.com/sifive/riscv-linux/commits/dev/paulw/cpufreq-dt-aloe-v5.3-rc4 +Patch552: 0002-SiFive-Unleashed-CPUFreq.patch + # END OF PATCH DEFINITIONS %endif