From 1bec9d64374c8ff98560aaf3ca8bd0d318985d87 Mon Sep 17 00:00:00 2001 From: Kernel Build Daemon Date: May 10 2023 05:27:00 +0000 Subject: Merge branch 'SLE12-SP5' into SLE12-SP5-AZURE --- diff --git a/blacklist.conf b/blacklist.conf index c63f83e..77fcdce 100644 --- a/blacklist.conf +++ b/blacklist.conf @@ -2797,3 +2797,4 @@ a157802359f7451ed8046b2b6dbaca187797e062 # build cleanup b648ab487f31bc4c38941bc770ea97fe394304bb # we don't have the original commit, nor do we care for 32bit a1ae8d4d9be0178132df7c4931a1ba77d0e76039 # no nvme core/fabric fixes to missing infrastructure 2a587b9ad052e7e92e508aea90c1e2ae433c1908 # ARCH_ASPEED=n +5d3d01ae15d2f37ed0325c99ab47ef0ae5d05f3c # a change of a name must break kABI diff --git a/patches.suse/Documentation-Document-sysfs-interfaces-purr-spurr-i.patch b/patches.suse/Documentation-Document-sysfs-interfaces-purr-spurr-i.patch new file mode 100644 index 0000000..6b589bd --- /dev/null +++ b/patches.suse/Documentation-Document-sysfs-interfaces-purr-spurr-i.patch @@ -0,0 +1,70 @@ +From bde752c3d6dbe9f6ca346560198e66bc3d7d7238 Mon Sep 17 00:00:00 2001 +From: "Gautham R. Shenoy" +Date: Tue, 7 Apr 2020 14:17:43 +0530 +Subject: [PATCH] Documentation: Document sysfs interfaces purr, spurr, + idle_purr, idle_spurr + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v5.8-rc1 +Git-commit: bde752c3d6dbe9f6ca346560198e66bc3d7d7238 + +Add documentation for the following sysfs interfaces: +/sys/devices/system/cpu/cpuX/purr +/sys/devices/system/cpu/cpuX/spurr +/sys/devices/system/cpu/cpuX/idle_purr +/sys/devices/system/cpu/cpuX/idle_spurr + +Signed-off-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/1586249263-14048-6-git-send-email-ego@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + .../ABI/testing/sysfs-devices-system-cpu | 39 +++++++++++++++++++ + 1 file changed, 39 insertions(+) + +diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu +--- a/Documentation/ABI/testing/sysfs-devices-system-cpu ++++ b/Documentation/ABI/testing/sysfs-devices-system-cpu +@@ -439,3 +439,42 @@ Description: Umwait control + or C0.2 state. The time is an unsigned 32-bit number. + Note that a value of zero means there is no limit. + Low order two bits must be zero. ++ ++What: /sys/devices/system/cpu/cpuX/purr ++Date: Apr 2005 ++Contact: Linux for PowerPC mailing list ++Description: PURR ticks for this CPU since the system boot. ++ ++ The Processor Utilization Resources Register (PURR) is ++ a 64-bit counter which provides an estimate of the ++ resources used by the CPU thread. The contents of this ++ register increases monotonically. This sysfs interface ++ exposes the number of PURR ticks for cpuX. ++ ++What: /sys/devices/system/cpu/cpuX/spurr ++Date: Dec 2006 ++Contact: Linux for PowerPC mailing list ++Description: SPURR ticks for this CPU since the system boot. ++ ++ The Scaled Processor Utilization Resources Register ++ (SPURR) is a 64-bit counter that provides a frequency ++ invariant estimate of the resources used by the CPU ++ thread. The contents of this register increases ++ monotonically. This sysfs interface exposes the number ++ of SPURR ticks for cpuX. ++ ++What: /sys/devices/system/cpu/cpuX/idle_purr ++Date: Apr 2020 ++Contact: Linux for PowerPC mailing list ++Description: PURR ticks for cpuX when it was idle. ++ ++ This sysfs interface exposes the number of PURR ticks ++ for cpuX when it was idle. ++ ++What: /sys/devices/system/cpu/cpuX/idle_spurr ++Date: Apr 2020 ++Contact: Linux for PowerPC mailing list ++Description: SPURR ticks for cpuX when it was idle. ++ ++ This sysfs interface exposes the number of SPURR ticks ++ for cpuX when it was idle. diff --git a/patches.suse/cpuidle-powernv-Fix-promotion-from-snooze-if-next-st.patch b/patches.suse/cpuidle-powernv-Fix-promotion-from-snooze-if-next-st.patch index c25bdc9..e9c0d11 100644 --- a/patches.suse/cpuidle-powernv-Fix-promotion-from-snooze-if-next-st.patch +++ b/patches.suse/cpuidle-powernv-Fix-promotion-from-snooze-if-next-st.patch @@ -1,9 +1,12 @@ +From 0a4ec6aa035a52c422eceb2ed51ed88392a3d6c2 Mon Sep 17 00:00:00 2001 From: "Gautham R. Shenoy" Date: Thu, 31 May 2018 17:45:09 +0530 -Subject: cpuidle: powernv: Fix promotion from snooze if next state disabled +Subject: [PATCH] cpuidle: powernv: Fix promotion from snooze if next state + disabled + +References: bsc#1100884 Patch-mainline: v4.18-rc1 Git-commit: 0a4ec6aa035a52c422eceb2ed51ed88392a3d6c2 -References: bsc#1100884 The commit 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of snooze to deeper idle state") introduced a timeout for the snooze idle @@ -80,18 +83,20 @@ Reviewed-by: Balbir Singh Signed-off-by: Michael Ellerman Acked-by: Giovanni Gherdovich --- - drivers/cpuidle/cpuidle-powernv.c | 32 ++++++++++++++++++++++++++------ + drivers/cpuidle/cpuidle-powernv.c | 32 +++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c +index 1a8234e706bc..d29e4f041efe 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c -@@ -42,9 +42,31 @@ struct stop_psscr_table { +@@ -43,9 +43,31 @@ struct stop_psscr_table { - static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX]; + static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly; --static u64 snooze_timeout; -+static u64 default_snooze_timeout; - static bool snooze_timeout_en; +-static u64 snooze_timeout __read_mostly; ++static u64 default_snooze_timeout __read_mostly; + static bool snooze_timeout_en __read_mostly; +static u64 get_snooze_timeout(struct cpuidle_device *dev, + struct cpuidle_driver *drv, @@ -118,16 +123,16 @@ Acked-by: Giovanni Gherdovich static int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) -@@ -54,7 +76,7 @@ static int snooze_loop(struct cpuidle_de +@@ -56,7 +78,7 @@ static int snooze_loop(struct cpuidle_device *dev, + local_irq_enable(); - set_thread_flag(TIF_POLLING_NRFLAG); - snooze_exit_time = get_tb() + snooze_timeout; + snooze_exit_time = get_tb() + get_snooze_timeout(dev, drv, index); ppc64_runlatch_off(); HMT_very_low(); while (!need_resched()) { -@@ -453,11 +475,9 @@ static int powernv_idle_probe(void) +@@ -465,11 +487,9 @@ static int powernv_idle_probe(void) cpuidle_state_table = powernv_states; /* Device tree can indicate more idle states */ max_idle_state = powernv_add_idle_states(); @@ -141,3 +146,6 @@ Acked-by: Giovanni Gherdovich } else return -ENODEV; +-- +2.40.0 + diff --git a/patches.suse/cpuidle-powernv-avoid-double-irq-enable-coming-out-o.patch b/patches.suse/cpuidle-powernv-avoid-double-irq-enable-coming-out-o.patch new file mode 100644 index 0000000..9f854b6 --- /dev/null +++ b/patches.suse/cpuidle-powernv-avoid-double-irq-enable-coming-out-o.patch @@ -0,0 +1,63 @@ +From ced54c08d8e4060d59c10629ea5a4ccdaed6898e Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Fri, 17 Nov 2017 02:00:52 +1000 +Subject: [PATCH] cpuidle/powernv: avoid double irq enable coming out of idle + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v4.16-rc1 +Git-commit: ced54c08d8e4060d59c10629ea5a4ccdaed6898e + +Since e1689795a7 ("cpuidle: Add common time keeping and irq enabling"), +cpuidle drivers are expected to return from ->enter with irqs disabled. + +Update the cpuidle-powernv snooze and cede loops to disable irqs before +returning. + +Signed-off-by: Nicholas Piggin +Signed-off-by: Michael Ellerman +Acked-by: Michal Suchanek +--- + drivers/cpuidle/cpuidle-pseries.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index a187a39fb866..0f2b697cbb27 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -51,8 +51,6 @@ static inline void idle_loop_epilog(unsigned long in_purr) + get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); + get_lppaca()->idle = 0; + +- if (irqs_disabled()) +- local_irq_enable(); + ppc64_runlatch_on(); + } + +@@ -87,6 +85,8 @@ static int snooze_loop(struct cpuidle_device *dev, + HMT_medium(); + clear_thread_flag(TIF_POLLING_NRFLAG); + ++ local_irq_disable(); ++ + idle_loop_epilog(in_purr); + + return index; +@@ -121,6 +121,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, + HMT_medium(); + check_and_cede_processor(); + ++ local_irq_disable(); + get_lppaca()->donate_dedicated_cpu = 0; + + idle_loop_epilog(in_purr); +@@ -145,6 +146,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, + */ + check_and_cede_processor(); + ++ local_irq_disable(); + idle_loop_epilog(in_purr); + + return index; +-- +2.40.0 + diff --git a/patches.suse/cpuidle-powerpc-cpuidle-set-polling-before-enabling-.patch b/patches.suse/cpuidle-powerpc-cpuidle-set-polling-before-enabling-.patch new file mode 100644 index 0000000..5af7736 --- /dev/null +++ b/patches.suse/cpuidle-powerpc-cpuidle-set-polling-before-enabling-.patch @@ -0,0 +1,68 @@ +From 3fc5ee927ff4ffed6aa2fcd44d2fbf07ac893cdc Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Wed, 14 Jun 2017 23:02:39 +1000 +Subject: [PATCH] cpuidle: powerpc: cpuidle set polling before enabling irqs + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v4.13-rc1 +Git-commit: 3fc5ee927ff4ffed6aa2fcd44d2fbf07ac893cdc + +local_irq_enable can cause interrupts to be taken which could +take significant amount of processing time. The idle process +should set its polling flag before this, so another process that +wakes it during this time will not have to send an IPI. + +Expand the TIF_POLLING_NRFLAG coverage to as large as possible. + +Reviewed-by: Gautham R. Shenoy +Signed-off-by: Nicholas Piggin +Signed-off-by: Michael Ellerman +Acked-by: Michal Suchanek +--- + drivers/cpuidle/cpuidle-powernv.c | 4 +++- + drivers/cpuidle/cpuidle-pseries.c | 3 ++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c +index 79152676f62b..50b3c2e0306f 100644 +--- a/drivers/cpuidle/cpuidle-powernv.c ++++ b/drivers/cpuidle/cpuidle-powernv.c +@@ -51,9 +51,10 @@ static int snooze_loop(struct cpuidle_device *dev, + { + u64 snooze_exit_time; + +- local_irq_enable(); + set_thread_flag(TIF_POLLING_NRFLAG); + ++ local_irq_enable(); ++ + snooze_exit_time = get_tb() + snooze_timeout; + ppc64_runlatch_off(); + HMT_very_low(); +@@ -66,6 +67,7 @@ static int snooze_loop(struct cpuidle_device *dev, + ppc64_runlatch_on(); + clear_thread_flag(TIF_POLLING_NRFLAG); + smp_mb(); ++ + return index; + } + +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index 166ccd711ec9..7b12bb2ea70f 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -62,9 +62,10 @@ static int snooze_loop(struct cpuidle_device *dev, + unsigned long in_purr; + u64 snooze_exit_time; + ++ set_thread_flag(TIF_POLLING_NRFLAG); ++ + idle_loop_prolog(&in_purr); + local_irq_enable(); +- set_thread_flag(TIF_POLLING_NRFLAG); + snooze_exit_time = get_tb() + snooze_timeout; + + while (!need_resched()) { +-- +2.40.0 + diff --git a/patches.suse/cpuidle-powerpc-no-memory-barrier-after-break-from-i.patch b/patches.suse/cpuidle-powerpc-no-memory-barrier-after-break-from-i.patch new file mode 100644 index 0000000..36e6a00 --- /dev/null +++ b/patches.suse/cpuidle-powerpc-no-memory-barrier-after-break-from-i.patch @@ -0,0 +1,81 @@ +From 7ded429152e84831f6696585755f318fb351e67f Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Wed, 14 Jun 2017 23:02:41 +1000 +Subject: [PATCH] cpuidle: powerpc: no memory barrier after break from idle + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v4.13-rc1 +Git-commit: 7ded429152e84831f6696585755f318fb351e67f + +A memory barrier is not required after the task wakes up, +only if we clear the polling flag before waking. The case +where we have work to do is the important one, so optimise +for it. + +Reviewed-by: Vaidyanathan Srinivasan +Signed-off-by: Nicholas Piggin +Signed-off-by: Michael Ellerman +Acked-by: Michal Suchanek +--- + drivers/cpuidle/cpuidle-powernv.c | 11 +++++++++-- + drivers/cpuidle/cpuidle-pseries.c | 11 +++++++++-- + 2 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c +index 9d03326ac05e..37b0698b7193 100644 +--- a/drivers/cpuidle/cpuidle-powernv.c ++++ b/drivers/cpuidle/cpuidle-powernv.c +@@ -59,14 +59,21 @@ static int snooze_loop(struct cpuidle_device *dev, + ppc64_runlatch_off(); + HMT_very_low(); + while (!need_resched()) { +- if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) ++ if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { ++ /* ++ * Task has not woken up but we are exiting the polling ++ * loop anyway. Require a barrier after polling is ++ * cleared to order subsequent test of need_resched(). ++ */ ++ clear_thread_flag(TIF_POLLING_NRFLAG); ++ smp_mb(); + break; ++ } + } + + HMT_medium(); + ppc64_runlatch_on(); + clear_thread_flag(TIF_POLLING_NRFLAG); +- smp_mb(); + + return index; + } +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index a404f352d284..e9b3853d93ea 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -71,13 +71,20 @@ static int snooze_loop(struct cpuidle_device *dev, + while (!need_resched()) { + HMT_low(); + HMT_very_low(); +- if (snooze_timeout_en && get_tb() > snooze_exit_time) ++ if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { ++ /* ++ * Task has not woken up but we are exiting the polling ++ * loop anyway. Require a barrier after polling is ++ * cleared to order subsequent test of need_resched(). ++ */ ++ clear_thread_flag(TIF_POLLING_NRFLAG); ++ smp_mb(); + break; ++ } + } + + HMT_medium(); + clear_thread_flag(TIF_POLLING_NRFLAG); +- smp_mb(); + + idle_loop_epilog(in_purr); + +-- +2.40.0 + diff --git a/patches.suse/cpuidle-powerpc-read-mostly-for-common-globals.patch b/patches.suse/cpuidle-powerpc-read-mostly-for-common-globals.patch new file mode 100644 index 0000000..1608463 --- /dev/null +++ b/patches.suse/cpuidle-powerpc-read-mostly-for-common-globals.patch @@ -0,0 +1,71 @@ +From 624e46d03576dd4d5667bad9d2ef814135d0075c Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Wed, 14 Jun 2017 23:02:40 +1000 +Subject: [PATCH] cpuidle: powerpc: read mostly for common globals + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v4.13-rc1 +Git-commit: 624e46d03576dd4d5667bad9d2ef814135d0075c + +Ensure these don't get put into bouncing cachelines. + +Reviewed-by: Vaidyanathan Srinivasan +Reviewed-by: Gautham R. Shenoy +Signed-off-by: Nicholas Piggin +Signed-off-by: Michael Ellerman +Acked-by: Michal Suchanek +--- + drivers/cpuidle/cpuidle-powernv.c | 10 +++++----- + drivers/cpuidle/cpuidle-pseries.c | 8 ++++---- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c +index 50b3c2e0306f..9d03326ac05e 100644 +--- a/drivers/cpuidle/cpuidle-powernv.c ++++ b/drivers/cpuidle/cpuidle-powernv.c +@@ -32,18 +32,18 @@ static struct cpuidle_driver powernv_idle_driver = { + .owner = THIS_MODULE, + }; + +-static int max_idle_state; +-static struct cpuidle_state *cpuidle_state_table; ++static int max_idle_state __read_mostly; ++static struct cpuidle_state *cpuidle_state_table __read_mostly; + + struct stop_psscr_table { + u64 val; + u64 mask; + }; + +-static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX]; ++static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly; + +-static u64 snooze_timeout; +-static bool snooze_timeout_en; ++static u64 snooze_timeout __read_mostly; ++static bool snooze_timeout_en __read_mostly; + + static int snooze_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index 7b12bb2ea70f..a404f352d284 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -25,10 +25,10 @@ struct cpuidle_driver pseries_idle_driver = { + .owner = THIS_MODULE, + }; + +-static int max_idle_state; +-static struct cpuidle_state *cpuidle_state_table; +-static u64 snooze_timeout; +-static bool snooze_timeout_en; ++static int max_idle_state __read_mostly; ++static struct cpuidle_state *cpuidle_state_table __read_mostly; ++static u64 snooze_timeout __read_mostly; ++static bool snooze_timeout_en __read_mostly; + + static inline void idle_loop_prolog(unsigned long *in_purr) + { +-- +2.40.0 + diff --git a/patches.suse/fotg210-udc-Add-missing-completion-handler.patch b/patches.suse/fotg210-udc-Add-missing-completion-handler.patch new file mode 100644 index 0000000..891e90a --- /dev/null +++ b/patches.suse/fotg210-udc-Add-missing-completion-handler.patch @@ -0,0 +1,58 @@ +From e55f67391fa986f7357edba0ca59e668d99c3a5f Mon Sep 17 00:00:00 2001 +From: Fabian Vogt +Date: Mon, 23 Jan 2023 08:35:06 +0100 +Subject: [PATCH] fotg210-udc: Add missing completion handler +Git-commit: e55f67391fa986f7357edba0ca59e668d99c3a5f +References: git-fixes +Patch-mainline: v6.3-rc1 + +This is used when responding to GET_STATUS requests. Without this, it +crashes on completion. + +Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") +Signed-off-by: Fabian Vogt +Signed-off-by: Linus Walleij +Link: https://lore.kernel.org/r/20230123073508.2350402-2-linus.walleij@linaro.org +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Oliver Neukum +--- + drivers/usb/fotg210/fotg210-udc.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c +index 4334504fccc8..53b7d078a54d 100644 +--- a/drivers/usb/gadget/udc/fotg210-udc.c ++++ b/drivers/usb/gadget/udc/fotg210-udc.c +@@ -709,6 +709,20 @@ static int fotg210_is_epnstall(struct fotg210_ep *ep) + return value & INOUTEPMPSR_STL_EP ? 1 : 0; + } + ++/* For EP0 requests triggered by this driver (currently GET_STATUS response) */ ++static void fotg210_ep0_complete(struct usb_ep *_ep, struct usb_request *req) ++{ ++ struct fotg210_ep *ep; ++ struct fotg210_udc *fotg210; ++ ++ ep = container_of(_ep, struct fotg210_ep, ep); ++ fotg210 = ep->fotg210; ++ ++ if (req->status || req->actual != req->length) { ++ dev_warn(&fotg210->gadget.dev, "EP0 request failed: %d\n", req->status); ++ } ++} ++ + static void fotg210_get_status(struct fotg210_udc *fotg210, + struct usb_ctrlrequest *ctrl) + { +@@ -1253,6 +1267,8 @@ int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg) + if (fotg210->ep0_req == NULL) + goto err_map; + ++ fotg210->ep0_req->complete = fotg210_ep0_complete; ++ + fotg210_init(fotg210); + + fotg210_disable_unplug(fotg210); +-- +2.40.1 + diff --git a/patches.suse/platform-x86-alienware-wmi-Adjust-instance-of-wmi_ev.patch b/patches.suse/platform-x86-alienware-wmi-Adjust-instance-of-wmi_ev.patch new file mode 100644 index 0000000..6669fb5 --- /dev/null +++ b/patches.suse/platform-x86-alienware-wmi-Adjust-instance-of-wmi_ev.patch @@ -0,0 +1,59 @@ +From c0e4aa78716401e8d7d5434b69bbf6596b55a936 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +Date: Wed, 21 Jun 2017 17:01:35 -0500 +Subject: [PATCH] platform/x86: alienware-wmi: Adjust instance of + wmi_evaluate_method calls to 0 +Git-commit: c0e4aa78716401e8d7d5434b69bbf6596b55a936 +References: git-fixes +Patch-mainline: v4.13-rc1 + +Pali recently noticed that WMI instances are zero indexed. + +The only reason that these calls all worked properly is because the ASL +didn't verify the instance number. + +Signed-off-by: Mario Limonciello +Signed-off-by: Darren Hart (VMware) +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/alienware-wmi.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c +index d6b34923fb4e..9866fec78c1c 100644 +--- a/drivers/platform/x86/alienware-wmi.c ++++ b/drivers/platform/x86/alienware-wmi.c +@@ -303,7 +303,7 @@ static int alienware_update_led(struct platform_zone *zone) + } + pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id); + +- status = wmi_evaluate_method(guid, 1, method_id, &input, NULL); ++ status = wmi_evaluate_method(guid, 0, method_id, &input, NULL); + if (ACPI_FAILURE(status)) + pr_err("alienware-wmi: zone set failure: %u\n", status); + return ACPI_FAILURE(status); +@@ -352,7 +352,7 @@ static int wmax_brightness(int brightness) + }; + input.length = (acpi_size) sizeof(args); + input.pointer = &args; +- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1, ++ status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + WMAX_METHOD_BRIGHTNESS, &input, NULL); + if (ACPI_FAILURE(status)) + pr_err("alienware-wmi: brightness set failure: %u\n", status); +@@ -506,10 +506,10 @@ static acpi_status alienware_wmax_command(struct wmax_basic_args *in_args, + if (out_data != NULL) { + output.length = ACPI_ALLOCATE_BUFFER; + output.pointer = NULL; +- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1, ++ status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, &output); + } else +- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1, ++ status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, NULL); + + if (ACPI_SUCCESS(status) && out_data != NULL) { +-- +2.40.1 + diff --git a/patches.suse/platform-x86-alienware-wmi-constify-attribute_group-.patch b/patches.suse/platform-x86-alienware-wmi-constify-attribute_group-.patch new file mode 100644 index 0000000..6f87c0f --- /dev/null +++ b/patches.suse/platform-x86-alienware-wmi-constify-attribute_group-.patch @@ -0,0 +1,62 @@ +From 4b7942d8d1ced3c82495953cb0bb90e7de6dbba6 Mon Sep 17 00:00:00 2001 +From: Arvind Yadav +Date: Tue, 11 Jul 2017 16:18:17 +0530 +Subject: [PATCH] platform/x86: alienware-wmi: constify attribute_group + structures. +Git-commit: 4b7942d8d1ced3c82495953cb0bb90e7de6dbba6 +References: git-fixes +Patch-mainline: v4.13-rc1 + +attribute_groups are not supposed to change at runtime. All functions +working with attribute_groups provided by work +with const attribute_group. So mark the non-const structs as const. + +File size before: + text data bss dec hex filename + 6932 1016 48 7996 1f3c drivers/platform/x86/alienware-wmi.o + +File size After adding 'const': + text data bss dec hex filename + 7060 888 48 7996 1f64 drivers/platform/x86/alienware-wmi.o + +Signed-off-by: Arvind Yadav +Signed-off-by: Darren Hart (VMware) +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/alienware-wmi.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c +index 9866fec78c1c..0831b428c217 100644 +--- a/drivers/platform/x86/alienware-wmi.c ++++ b/drivers/platform/x86/alienware-wmi.c +@@ -604,7 +604,7 @@ static struct attribute *hdmi_attrs[] = { + NULL, + }; + +-static struct attribute_group hdmi_attribute_group = { ++static const struct attribute_group hdmi_attribute_group = { + .name = "hdmi", + .attrs = hdmi_attrs, + }; +@@ -660,7 +660,7 @@ static struct attribute *amplifier_attrs[] = { + NULL, + }; + +-static struct attribute_group amplifier_attribute_group = { ++static const struct attribute_group amplifier_attribute_group = { + .name = "amplifier", + .attrs = amplifier_attrs, + }; +@@ -741,7 +741,7 @@ static struct attribute *deepsleep_attrs[] = { + NULL, + }; + +-static struct attribute_group deepsleep_attribute_group = { ++static const struct attribute_group deepsleep_attribute_group = { + .name = "deepsleep", + .attrs = deepsleep_attrs, + }; +-- +2.40.1 + diff --git a/patches.suse/platform-x86-alienware-wmi-fix-format-string-overflo.patch b/patches.suse/platform-x86-alienware-wmi-fix-format-string-overflo.patch new file mode 100644 index 0000000..f769bf1 --- /dev/null +++ b/patches.suse/platform-x86-alienware-wmi-fix-format-string-overflo.patch @@ -0,0 +1,122 @@ +From 22ff1a362df262dcc56ce282d9d658350c1fc036 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Thu, 20 Jul 2017 18:00:51 +0200 +Subject: [PATCH] platform/x86: alienware-wmi: fix format string overflow + warning +Git-commit: 22ff1a362df262dcc56ce282d9d658350c1fc036 +References: git-fixes +Patch-mainline: v4.14-rc1 + +gcc points out a possible format string overflow for a large value of 'zone': + +drivers/platform/x86/alienware-wmi.c: In function 'alienware_wmi_init': +drivers/platform/x86/alienware-wmi.c:461:24: error: '%02X' directive writing between 2 and 8 bytes into a region of size 6 [-Werror=format-overflow=] + sprintf(buffer, "zone%02X", i); + ^~~~ +drivers/platform/x86/alienware-wmi.c:461:19: note: directive argument in the range [0, 2147483646] + sprintf(buffer, "zone%02X", i); + ^~~~~~~~~~ +drivers/platform/x86/alienware-wmi.c:461:3: note: 'sprintf' output between 7 and 13 bytes into a destination of size 10 + +This replaces the 'int' variable with an 'u8' to make sure +it always fits, renaming the variable to 'zone' for clarity. + +Unfortunately, gcc-7.1.1 still warns about it with that change, which +seems to be unintended by the gcc developers. I have opened a bug +against gcc with a reduced test case. As a workaround, I also +change the format string to use "%02hhX", which shuts up the +warning in that version. + +Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483 +Link: https://patchwork.ozlabs.org/patch/788415/ +Suggested-by: Andy Shevchenko +Signed-off-by: Arnd Bergmann +[andy: added empty lines after u8 zone; definitions] +Signed-off-by: Andy Shevchenko +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/alienware-wmi.c | 40 +++++++++++++++------------- + 1 file changed, 21 insertions(+), 19 deletions(-) + +diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c +index 0831b428c217..4eb8e1a472b2 100644 +--- a/drivers/platform/x86/alienware-wmi.c ++++ b/drivers/platform/x86/alienware-wmi.c +@@ -255,12 +255,13 @@ static int parse_rgb(const char *buf, struct platform_zone *zone) + + static struct platform_zone *match_zone(struct device_attribute *attr) + { +- int i; +- for (i = 0; i < quirks->num_zones; i++) { +- if ((struct device_attribute *)zone_data[i].attr == attr) { ++ u8 zone; ++ ++ for (zone = 0; zone < quirks->num_zones; zone++) { ++ if ((struct device_attribute *)zone_data[zone].attr == attr) { + pr_debug("alienware-wmi: matched zone location: %d\n", +- zone_data[i].location); +- return &zone_data[i]; ++ zone_data[zone].location); ++ return &zone_data[zone]; + } + } + return NULL; +@@ -420,7 +421,7 @@ static DEVICE_ATTR(lighting_control_state, 0644, show_control_state, + + static int alienware_zone_init(struct platform_device *dev) + { +- int i; ++ u8 zone; + char buffer[10]; + char *name; + +@@ -457,19 +458,19 @@ static int alienware_zone_init(struct platform_device *dev) + if (!zone_data) + return -ENOMEM; + +- for (i = 0; i < quirks->num_zones; i++) { +- sprintf(buffer, "zone%02X", i); ++ for (zone = 0; zone < quirks->num_zones; zone++) { ++ sprintf(buffer, "zone%02hhX", zone); + name = kstrdup(buffer, GFP_KERNEL); + if (name == NULL) + return 1; +- sysfs_attr_init(&zone_dev_attrs[i].attr); +- zone_dev_attrs[i].attr.name = name; +- zone_dev_attrs[i].attr.mode = 0644; +- zone_dev_attrs[i].show = zone_show; +- zone_dev_attrs[i].store = zone_set; +- zone_data[i].location = i; +- zone_attrs[i] = &zone_dev_attrs[i].attr; +- zone_data[i].attr = &zone_dev_attrs[i]; ++ sysfs_attr_init(&zone_dev_attrs[zone].attr); ++ zone_dev_attrs[zone].attr.name = name; ++ zone_dev_attrs[zone].attr.mode = 0644; ++ zone_dev_attrs[zone].show = zone_show; ++ zone_dev_attrs[zone].store = zone_set; ++ zone_data[zone].location = zone; ++ zone_attrs[zone] = &zone_dev_attrs[zone].attr; ++ zone_data[zone].attr = &zone_dev_attrs[zone]; + } + zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr; + zone_attribute_group.attrs = zone_attrs; +@@ -481,12 +482,13 @@ static int alienware_zone_init(struct platform_device *dev) + + static void alienware_zone_exit(struct platform_device *dev) + { ++ u8 zone; ++ + sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group); + led_classdev_unregister(&global_led); + if (zone_dev_attrs) { +- int i; +- for (i = 0; i < quirks->num_zones; i++) +- kfree(zone_dev_attrs[i].attr.name); ++ for (zone = 0; zone < quirks->num_zones; zone++) ++ kfree(zone_dev_attrs[zone].attr.name); + } + kfree(zone_dev_attrs); + kfree(zone_data); +-- +2.40.1 + diff --git a/patches.suse/platform-x86-alienware-wmi-fix-kfree-on-potentially-.patch b/patches.suse/platform-x86-alienware-wmi-fix-kfree-on-potentially-.patch new file mode 100644 index 0000000..6c52479 --- /dev/null +++ b/patches.suse/platform-x86-alienware-wmi-fix-kfree-on-potentially-.patch @@ -0,0 +1,64 @@ +From 98e2630284ab741804bd0713e932e725466f2f84 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Sat, 30 Mar 2019 00:17:12 +0000 +Subject: [PATCH] platform/x86: alienware-wmi: fix kfree on potentially + uninitialized pointer +Git-commit: 98e2630284ab741804bd0713e932e725466f2f84 +References: git-fixes +Patch-mainline: v5.2-rc1 + +Currently the kfree of output.pointer can be potentially freeing +an uninitalized pointer in the case where out_data is NULL. Fix this +by reworking the case where out_data is not-null to perform the +ACPI status check and also the kfree of outpoint.pointer in one block +and hence ensuring the pointer is only freed when it has been used. + +Also replace the if (ptr != NULL) idiom with just if (ptr). + +Fixes: ff0e9f26288d ("platform/x86: alienware-wmi: Correct a memory leak") +Signed-off-by: Colin Ian King +Signed-off-by: Darren Hart (VMware) +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/alienware-wmi.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c +index f10af5c383c5..c0d1555735cd 100644 +--- a/drivers/platform/x86/alienware-wmi.c ++++ b/drivers/platform/x86/alienware-wmi.c +@@ -522,23 +522,22 @@ static acpi_status alienware_wmax_command(struct wmax_basic_args *in_args, + + input.length = (acpi_size) sizeof(*in_args); + input.pointer = in_args; +- if (out_data != NULL) { ++ if (out_data) { + output.length = ACPI_ALLOCATE_BUFFER; + output.pointer = NULL; + status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, &output); +- } else ++ if (ACPI_SUCCESS(status)) { ++ obj = (union acpi_object *)output.pointer; ++ if (obj && obj->type == ACPI_TYPE_INTEGER) ++ *out_data = (u32)obj->integer.value; ++ } ++ kfree(output.pointer); ++ } else { + status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, NULL); +- +- if (ACPI_SUCCESS(status) && out_data != NULL) { +- obj = (union acpi_object *)output.pointer; +- if (obj && obj->type == ACPI_TYPE_INTEGER) +- *out_data = (u32) obj->integer.value; + } +- kfree(output.pointer); + return status; +- + } + + /* +-- +2.40.1 + diff --git a/patches.suse/platform-x86-dell-laptop-fix-rfkill-functionality.patch b/patches.suse/platform-x86-dell-laptop-fix-rfkill-functionality.patch new file mode 100644 index 0000000..68d5d45 --- /dev/null +++ b/patches.suse/platform-x86-dell-laptop-fix-rfkill-functionality.patch @@ -0,0 +1,60 @@ +From 6cc13c28da5beee0f706db6450e190709700b34a Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +Date: Wed, 27 Mar 2019 09:25:34 -0500 +Subject: [PATCH] platform/x86: dell-laptop: fix rfkill functionality +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 6cc13c28da5beee0f706db6450e190709700b34a +REferences: git-fixes +Patch-mainline: v5.2-rc1 + +When converting the driver two arguments were transposed leading +to rfkill not working. + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=201427 +Reported-by: Pepijn de Vos +Fixes: 549b49 ("platform/x86: dell-smbios: Introduce dispatcher for SMM calls") +Signed-off-by: Mario Limonciello +Acked-by: Pali Rohár +Cc: # 4.14.x +Signed-off-by: Darren Hart (VMware) +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/dell-laptop.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c +index 95e6ca116e00..a561f653cf13 100644 +--- a/drivers/platform/x86/dell-laptop.c ++++ b/drivers/platform/x86/dell-laptop.c +@@ -531,7 +531,7 @@ static void dell_rfkill_query(struct rfkill *rfkill, void *data) + return; + } + +- dell_fill_request(&buffer, 0, 0x2, 0, 0); ++ dell_fill_request(&buffer, 0x2, 0, 0, 0); + ret = dell_send_request(&buffer, CLASS_INFO, SELECT_RFKILL); + hwswitch = buffer.output[1]; + +@@ -562,7 +562,7 @@ static int dell_debugfs_show(struct seq_file *s, void *data) + return ret; + status = buffer.output[1]; + +- dell_fill_request(&buffer, 0, 0x2, 0, 0); ++ dell_fill_request(&buffer, 0x2, 0, 0, 0); + hwswitch_ret = dell_send_request(&buffer, CLASS_INFO, SELECT_RFKILL); + if (hwswitch_ret) + return hwswitch_ret; +@@ -647,7 +647,7 @@ static void dell_update_rfkill(struct work_struct *ignored) + if (ret != 0) + return; + +- dell_fill_request(&buffer, 0, 0x2, 0, 0); ++ dell_fill_request(&buffer, 0x2, 0, 0, 0); + ret = dell_send_request(&buffer, CLASS_INFO, SELECT_RFKILL); + + if (ret == 0 && (status & BIT(0))) +-- +2.40.1 + diff --git a/patches.suse/platform-x86-dell-smbios-wmi-Add-missing-kfree-in-er.patch b/patches.suse/platform-x86-dell-smbios-wmi-Add-missing-kfree-in-er.patch new file mode 100644 index 0000000..849bb7d --- /dev/null +++ b/patches.suse/platform-x86-dell-smbios-wmi-Add-missing-kfree-in-er.patch @@ -0,0 +1,32 @@ +From 0487d4fc42d7f31a56cfd9e2237f9ebd889e6112 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 26 Aug 2021 16:08:22 +0200 +Subject: [PATCH] platform/x86: dell-smbios-wmi: Add missing kfree in + error-exit from run_smbios_call +Git-commit: 0487d4fc42d7f31a56cfd9e2237f9ebd889e6112 +References: git-fixes +Patch-mainline: v5.15-rc1 + +As pointed out be Kees Cook if we return -EIO because the +obj->type != ACPI_TYPE_BUFFER, then we must kfree the +output buffer before the return. + +Fixes: 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver") +Reported-by: Kees Cook +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20210826140822.71198-1-hdegoede@redhat.com +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/dell-smbios-wmi.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/platform/x86/dell-smbios-wmi.c ++++ b/drivers/platform/x86/dell-smbios-wmi.c +@@ -72,6 +72,7 @@ static int run_smbios_call(struct wmi_de + if (obj->type == ACPI_TYPE_INTEGER) + dev_dbg(&wdev->dev, "SMBIOS call failed: %llu\n", + obj->integer.value); ++ kfree(output.pointer); + return -EIO; + } + memcpy(&priv->buf->std, obj->buffer.pointer, obj->buffer.length); diff --git a/patches.suse/platform-x86-dell-smbios-wmi-Fix-oops-on-rmmod-dell_.patch b/patches.suse/platform-x86-dell-smbios-wmi-Fix-oops-on-rmmod-dell_.patch new file mode 100644 index 0000000..4475e25 --- /dev/null +++ b/patches.suse/platform-x86-dell-smbios-wmi-Fix-oops-on-rmmod-dell_.patch @@ -0,0 +1,47 @@ +From 3a53587423d25c87af4b4126a806a0575104b45e Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 18 May 2021 14:50:27 +0200 +Subject: [PATCH] platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios +Git-commit: 3a53587423d25c87af4b4126a806a0575104b45e +References: git-fixes +Patch-mainline: v5.13-rc3 + +init_dell_smbios_wmi() only registers the dell_smbios_wmi_driver on systems +where the Dell WMI interface is supported. While exit_dell_smbios_wmi() +unregisters it unconditionally, this leads to the following oops: + +[ 175.722921] ------------[ cut here ]------------ +[ 175.722925] Unexpected driver unregister! +[ 175.722939] WARNING: CPU: 1 PID: 3630 at drivers/base/driver.c:194 driver_unregister+0x38/0x40 +... +[ 175.723089] Call Trace: +[ 175.723094] cleanup_module+0x5/0xedd [dell_smbios] +... +[ 175.723148] ---[ end trace 064c34e1ad49509d ]--- + +Make the unregister happen on the same condition the register happens +to fix this. + +Cc: Mario Limonciello +Fixes: 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver") +Signed-off-by: Hans de Goede +Reviewed-by: Mario Limonciello +Reviewed-by: Mark Gross +Link: https://lore.kernel.org/r/20210518125027.21824-1-hdegoede@redhat.com +Signed-off-by: Oliver Neukum +--- + drivers/platform/x86/dell-smbios-wmi.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/platform/x86/dell-smbios-wmi.c ++++ b/drivers/platform/x86/dell-smbios-wmi.c +@@ -274,7 +274,8 @@ int init_dell_smbios_wmi(void) + + void exit_dell_smbios_wmi(void) + { +- wmi_driver_unregister(&dell_smbios_wmi_driver); ++ if (wmi_supported) ++ wmi_driver_unregister(&dell_smbios_wmi_driver); + } + + MODULE_ALIAS("wmi:" DELL_WMI_SMBIOS_GUID); diff --git a/patches.suse/powerpc-Move-idle_loop_prolog-epilog-functions-to-he.patch b/patches.suse/powerpc-Move-idle_loop_prolog-epilog-functions-to-he.patch new file mode 100644 index 0000000..63b3ae5 --- /dev/null +++ b/patches.suse/powerpc-Move-idle_loop_prolog-epilog-functions-to-he.patch @@ -0,0 +1,210 @@ +From e4a884cc28fa3f5d8b81de46998ffe29b4ad169e Mon Sep 17 00:00:00 2001 +From: "Gautham R. Shenoy" +Date: Tue, 7 Apr 2020 14:17:39 +0530 +Subject: [PATCH] powerpc: Move idle_loop_prolog()/epilog() functions to header + file + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v5.8-rc1 +Git-commit: e4a884cc28fa3f5d8b81de46998ffe29b4ad169e + +Currently prior to entering an idle state on a Linux Guest, the +pseries cpuidle driver implement an idle_loop_prolog() and +idle_loop_epilog() functions which ensure that idle_purr is correctly +computed, and the hypervisor is informed that the CPU cycles have been +donated. + +These prolog and epilog functions are also required in the default +idle call, i.e pseries_lpar_idle(). Hence move these accessor +functions to a common header file and call them from +pseries_lpar_idle(). Since the existing header files such as +asm/processor.h have enough clutter, create a new header file +asm/idle.h. Finally rename idle_loop_prolog() and idle_loop_epilog() +to pseries_idle_prolog() and pseries_idle_epilog() as they are only +relavent for on pseries guests. + +Signed-off-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/1586249263-14048-2-git-send-email-ego@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/idle.h | 31 ++++++++++++++++++++++ + arch/powerpc/platforms/pseries/setup.c | 7 +++-- + drivers/cpuidle/cpuidle-pseries.c | 36 +++++--------------------- + 3 files changed, 43 insertions(+), 31 deletions(-) + create mode 100644 arch/powerpc/include/asm/idle.h + +diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h +new file mode 100644 +index 000000000000..32064a4c0dd7 +--- /dev/null ++++ b/arch/powerpc/include/asm/idle.h +@@ -0,0 +1,31 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++#ifndef _ASM_POWERPC_IDLE_H ++#define _ASM_POWERPC_IDLE_H ++#include ++#include ++ ++#ifdef CONFIG_PPC_PSERIES ++static inline void pseries_idle_prolog(unsigned long *in_purr) ++{ ++ ppc64_runlatch_off(); ++ *in_purr = mfspr(SPRN_PURR); ++ /* ++ * Indicate to the HV that we are idle. Now would be ++ * a good time to find other work to dispatch. ++ */ ++ get_lppaca()->idle = 1; ++} ++ ++static inline void pseries_idle_epilog(unsigned long in_purr) ++{ ++ u64 wait_cycles; ++ ++ wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); ++ wait_cycles += mfspr(SPRN_PURR) - in_purr; ++ get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); ++ get_lppaca()->idle = 0; ++ ++ ppc64_runlatch_on(); ++} ++#endif /* CONFIG_PPC_PSERIES */ ++#endif +diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c +--- a/arch/powerpc/platforms/pseries/setup.c ++++ b/arch/powerpc/platforms/pseries/setup.c +@@ -68,6 +68,7 @@ + #include + #include + #include ++#include + + #include "pseries.h" + #include "../../../../drivers/pci/pci.h" +@@ -319,6 +320,8 @@ machine_early_initcall(pseries, alloc_dispatch_log_kmem_cache); + + static void pseries_lpar_idle(void) + { ++ unsigned long in_purr; ++ + /* + * Default handler to go into low thread priority and possibly + * low power mode by ceding processor to hypervisor +@@ -328,7 +331,7 @@ static void pseries_lpar_idle(void) + return; + + /* Indicate to hypervisor that we are idle. */ +- get_lppaca()->idle = 1; ++ pseries_idle_prolog(&in_purr); + + /* + * Yield the processor to the hypervisor. We return if +@@ -339,7 +342,7 @@ static void pseries_lpar_idle(void) + */ + cede_processor(); + +- get_lppaca()->idle = 0; ++ pseries_idle_epilog(in_purr); + } + + /* +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index 74c247972bb3..46d5e05fcf97 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + + struct cpuidle_driver pseries_idle_driver = { +@@ -31,29 +32,6 @@ static struct cpuidle_state *cpuidle_state_table __read_mostly; + static u64 snooze_timeout __read_mostly; + static bool snooze_timeout_en __read_mostly; + +-static inline void idle_loop_prolog(unsigned long *in_purr) +-{ +- ppc64_runlatch_off(); +- *in_purr = mfspr(SPRN_PURR); +- /* +- * Indicate to the HV that we are idle. Now would be +- * a good time to find other work to dispatch. +- */ +- get_lppaca()->idle = 1; +-} +- +-static inline void idle_loop_epilog(unsigned long in_purr) +-{ +- u64 wait_cycles; +- +- wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); +- wait_cycles += mfspr(SPRN_PURR) - in_purr; +- get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); +- get_lppaca()->idle = 0; +- +- ppc64_runlatch_on(); +-} +- + static int snooze_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) +@@ -63,7 +41,7 @@ static int snooze_loop(struct cpuidle_device *dev, + + set_thread_flag(TIF_POLLING_NRFLAG); + +- idle_loop_prolog(&in_purr); ++ pseries_idle_prolog(&in_purr); + local_irq_enable(); + snooze_exit_time = get_tb() + snooze_timeout; + +@@ -87,7 +65,7 @@ static int snooze_loop(struct cpuidle_device *dev, + + local_irq_disable(); + +- idle_loop_epilog(in_purr); ++ pseries_idle_epilog(in_purr); + + return index; + } +@@ -115,7 +93,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, + { + unsigned long in_purr; + +- idle_loop_prolog(&in_purr); ++ pseries_idle_prolog(&in_purr); + get_lppaca()->donate_dedicated_cpu = 1; + + HMT_medium(); +@@ -124,7 +102,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, + local_irq_disable(); + get_lppaca()->donate_dedicated_cpu = 0; + +- idle_loop_epilog(in_purr); ++ pseries_idle_epilog(in_purr); + + return index; + } +@@ -135,7 +113,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, + { + unsigned long in_purr; + +- idle_loop_prolog(&in_purr); ++ pseries_idle_prolog(&in_purr); + + /* + * Yield the processor to the hypervisor. We return if +@@ -147,7 +125,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, + check_and_cede_processor(); + + local_irq_disable(); +- idle_loop_epilog(in_purr); ++ pseries_idle_epilog(in_purr); + + return index; + } +-- +2.40.0 + diff --git a/patches.suse/powerpc-idle-Store-PURR-snapshot-in-a-per-cpu-global.patch b/patches.suse/powerpc-idle-Store-PURR-snapshot-in-a-per-cpu-global.patch new file mode 100644 index 0000000..df381f2 --- /dev/null +++ b/patches.suse/powerpc-idle-Store-PURR-snapshot-in-a-per-cpu-global.patch @@ -0,0 +1,196 @@ +From c4019198cfa81224d32846915cd401e981f81b81 Mon Sep 17 00:00:00 2001 +From: "Gautham R. Shenoy" +Date: Tue, 7 Apr 2020 14:17:40 +0530 +Subject: [PATCH] powerpc/idle: Store PURR snapshot in a per-cpu global + variable + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v5.8-rc1 +Git-commit: c4019198cfa81224d32846915cd401e981f81b81 + +Currently when CPU goes idle, we take a snapshot of PURR via +pseries_idle_prolog() which is used at the CPU idle exit to compute +the idle PURR cycles via the function pseries_idle_epilog(). Thus, +the value of idle PURR cycle thus read before pseries_idle_prolog() and +after pseries_idle_epilog() is always correct. + +However, if we were to read the idle PURR cycles from an interrupt +context between pseries_idle_prolog() and pseries_idle_epilog() (this +will be done in a future patch), then, the value of the idle PURR thus +read will not include the cycles spent in the most recent idle period. +Thus, in that interrupt context, we will need access to the snapshot +of the PURR before going idle, in order to compute the idle PURR +cycles for the latest idle duration. + +In this patch, we save the snapshot of PURR in pseries_idle_prolog() +in a per-cpu variable, instead of on the stack, so that it can be +accessed from an interrupt context. + +Signed-off-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/1586249263-14048-3-git-send-email-ego@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/idle.h | 31 ++++++++++++++++++-------- + arch/powerpc/platforms/pseries/setup.c | 7 +++--- + drivers/cpuidle/cpuidle-pseries.c | 15 +++++-------- + 3 files changed, 31 insertions(+), 22 deletions(-) + +diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h +index 32064a4c0dd7..b90d75aa1f9e 100644 +--- a/arch/powerpc/include/asm/idle.h ++++ b/arch/powerpc/include/asm/idle.h +@@ -5,10 +5,27 @@ + #include + + #ifdef CONFIG_PPC_PSERIES +-static inline void pseries_idle_prolog(unsigned long *in_purr) ++DECLARE_PER_CPU(u64, idle_entry_purr_snap); ++ ++static inline void snapshot_purr_idle_entry(void) ++{ ++ *this_cpu_ptr(&idle_entry_purr_snap) = mfspr(SPRN_PURR); ++} ++ ++static inline void update_idle_purr_accounting(void) ++{ ++ u64 wait_cycles; ++ u64 in_purr = *this_cpu_ptr(&idle_entry_purr_snap); ++ ++ wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); ++ wait_cycles += mfspr(SPRN_PURR) - in_purr; ++ get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); ++} ++ ++static inline void pseries_idle_prolog(void) + { + ppc64_runlatch_off(); +- *in_purr = mfspr(SPRN_PURR); ++ snapshot_purr_idle_entry(); + /* + * Indicate to the HV that we are idle. Now would be + * a good time to find other work to dispatch. +@@ -16,16 +33,12 @@ static inline void pseries_idle_prolog(unsigned long *in_purr) + get_lppaca()->idle = 1; + } + +-static inline void pseries_idle_epilog(unsigned long in_purr) ++static inline void pseries_idle_epilog(void) + { +- u64 wait_cycles; +- +- wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); +- wait_cycles += mfspr(SPRN_PURR) - in_purr; +- get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); ++ update_idle_purr_accounting(); + get_lppaca()->idle = 0; +- + ppc64_runlatch_on(); + } ++ + #endif /* CONFIG_PPC_PSERIES */ + #endif +diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c +index 2f53e6b031a7..4905c965e111 100644 +--- a/arch/powerpc/platforms/pseries/setup.c ++++ b/arch/powerpc/platforms/pseries/setup.c +@@ -318,10 +318,9 @@ static int alloc_dispatch_log_kmem_cache(void) + } + machine_early_initcall(pseries, alloc_dispatch_log_kmem_cache); + ++DEFINE_PER_CPU(u64, idle_entry_purr_snap); + static void pseries_lpar_idle(void) + { +- unsigned long in_purr; +- + /* + * Default handler to go into low thread priority and possibly + * low power mode by ceding processor to hypervisor +@@ -331,7 +330,7 @@ static void pseries_lpar_idle(void) + return; + + /* Indicate to hypervisor that we are idle. */ +- pseries_idle_prolog(&in_purr); ++ pseries_idle_prolog(); + + /* + * Yield the processor to the hypervisor. We return if +@@ -342,7 +341,7 @@ static void pseries_lpar_idle(void) + */ + cede_processor(); + +- pseries_idle_epilog(in_purr); ++ pseries_idle_epilog(); + } + + /* +diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c +index 46d5e05fcf97..6513ef2af66a 100644 +--- a/drivers/cpuidle/cpuidle-pseries.c ++++ b/drivers/cpuidle/cpuidle-pseries.c +@@ -36,12 +36,11 @@ static int snooze_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) + { +- unsigned long in_purr; + u64 snooze_exit_time; + + set_thread_flag(TIF_POLLING_NRFLAG); + +- pseries_idle_prolog(&in_purr); ++ pseries_idle_prolog(); + local_irq_enable(); + snooze_exit_time = get_tb() + snooze_timeout; + +@@ -65,7 +64,7 @@ static int snooze_loop(struct cpuidle_device *dev, + + local_irq_disable(); + +- pseries_idle_epilog(in_purr); ++ pseries_idle_epilog(); + + return index; + } +@@ -91,9 +90,8 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) + { +- unsigned long in_purr; + +- pseries_idle_prolog(&in_purr); ++ pseries_idle_prolog(); + get_lppaca()->donate_dedicated_cpu = 1; + + HMT_medium(); +@@ -102,7 +100,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, + local_irq_disable(); + get_lppaca()->donate_dedicated_cpu = 0; + +- pseries_idle_epilog(in_purr); ++ pseries_idle_epilog(); + + return index; + } +@@ -111,9 +109,8 @@ static int shared_cede_loop(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int index) + { +- unsigned long in_purr; + +- pseries_idle_prolog(&in_purr); ++ pseries_idle_prolog(); + + /* + * Yield the processor to the hypervisor. We return if +@@ -125,7 +122,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, + check_and_cede_processor(); + + local_irq_disable(); +- pseries_idle_epilog(in_purr); ++ pseries_idle_epilog(); + + return index; + } +-- +2.40.0 + diff --git a/patches.suse/powerpc-pseries-Account-for-SPURR-ticks-on-idle-CPUs.patch b/patches.suse/powerpc-pseries-Account-for-SPURR-ticks-on-idle-CPUs.patch new file mode 100644 index 0000000..3d6bf29 --- /dev/null +++ b/patches.suse/powerpc-pseries-Account-for-SPURR-ticks-on-idle-CPUs.patch @@ -0,0 +1,95 @@ +From dc8afce5f45b099e3ea52a16b2f90e92f90f3af0 Mon Sep 17 00:00:00 2001 +From: "Gautham R. Shenoy" +Date: Tue, 7 Apr 2020 14:17:41 +0530 +Subject: [PATCH] powerpc/pseries: Account for SPURR ticks on idle CPUs + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v5.8-rc1 +Git-commit: dc8afce5f45b099e3ea52a16b2f90e92f90f3af0 + +On Pseries LPARs, to calculate utilization, we need to know the +[S]PURR ticks when the CPUs were busy or idle. + +Via pseries_idle_prolog(), pseries_idle_epilog(), we track the idle +PURR ticks in the VPA variable "wait_state_cycles". This patch extends +the support to account for the idle SPURR ticks. + +Signed-off-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/1586249263-14048-4-git-send-email-ego@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/idle.h | 17 +++++++++++++++++ + arch/powerpc/platforms/pseries/setup.c | 2 ++ + 2 files changed, 19 insertions(+) + +diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h +index b90d75aa1f9e..0efb25071d87 100644 +--- a/arch/powerpc/include/asm/idle.h ++++ b/arch/powerpc/include/asm/idle.h +@@ -5,13 +5,20 @@ + #include + + #ifdef CONFIG_PPC_PSERIES ++DECLARE_PER_CPU(u64, idle_spurr_cycles); + DECLARE_PER_CPU(u64, idle_entry_purr_snap); ++DECLARE_PER_CPU(u64, idle_entry_spurr_snap); + + static inline void snapshot_purr_idle_entry(void) + { + *this_cpu_ptr(&idle_entry_purr_snap) = mfspr(SPRN_PURR); + } + ++static inline void snapshot_spurr_idle_entry(void) ++{ ++ *this_cpu_ptr(&idle_entry_spurr_snap) = mfspr(SPRN_SPURR); ++} ++ + static inline void update_idle_purr_accounting(void) + { + u64 wait_cycles; +@@ -22,10 +29,19 @@ static inline void update_idle_purr_accounting(void) + get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); + } + ++static inline void update_idle_spurr_accounting(void) ++{ ++ u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); ++ u64 in_spurr = *this_cpu_ptr(&idle_entry_spurr_snap); ++ ++ *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; ++} ++ + static inline void pseries_idle_prolog(void) + { + ppc64_runlatch_off(); + snapshot_purr_idle_entry(); ++ snapshot_spurr_idle_entry(); + /* + * Indicate to the HV that we are idle. Now would be + * a good time to find other work to dispatch. +@@ -36,6 +52,7 @@ static inline void pseries_idle_prolog(void) + static inline void pseries_idle_epilog(void) + { + update_idle_purr_accounting(); ++ update_idle_spurr_accounting(); + get_lppaca()->idle = 0; + ppc64_runlatch_on(); + } +diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c +index 4905c965e111..1b55e804927d 100644 +--- a/arch/powerpc/platforms/pseries/setup.c ++++ b/arch/powerpc/platforms/pseries/setup.c +@@ -318,7 +318,9 @@ static int alloc_dispatch_log_kmem_cache(void) + } + machine_early_initcall(pseries, alloc_dispatch_log_kmem_cache); + ++DEFINE_PER_CPU(u64, idle_spurr_cycles); + DEFINE_PER_CPU(u64, idle_entry_purr_snap); ++DEFINE_PER_CPU(u64, idle_entry_spurr_snap); + static void pseries_lpar_idle(void) + { + /* +-- +2.40.0 + diff --git a/patches.suse/powerpc-sysfs-Show-idle_purr-and-idle_spurr-for-ever.patch b/patches.suse/powerpc-sysfs-Show-idle_purr-and-idle_spurr-for-ever.patch new file mode 100644 index 0000000..a3cf68b --- /dev/null +++ b/patches.suse/powerpc-sysfs-Show-idle_purr-and-idle_spurr-for-ever.patch @@ -0,0 +1,197 @@ +From 6909f179ca7a73f243dca7c829facca1cc1d4ff5 Mon Sep 17 00:00:00 2001 +From: "Gautham R. Shenoy" +Date: Tue, 7 Apr 2020 14:17:42 +0530 +Subject: [PATCH] powerpc/sysfs: Show idle_purr and idle_spurr for every CPU + +References: PED-3947 bsc#1210544 ltc#202303 +Patch-mainline: v5.8-rc1 +Git-commit: 6909f179ca7a73f243dca7c829facca1cc1d4ff5 + +On Pseries LPARs, to calculate utilization, we need to know the +[S]PURR ticks when the CPUs were busy or idle. + +The total PURR and SPURR ticks are already exposed via the per-cpu +sysfs files "purr" and "spurr". This patch adds support for exposing +the idle PURR and SPURR ticks via new per-cpu sysfs files named +"idle_purr" and "idle_spurr". + +This patch also adds helper functions to accurately read the values of +idle_purr and idle_spurr especially from an interrupt context between +when the interrupt has occurred between the pseries_idle_prolog() and +pseries_idle_epilog(). This will ensure that the idle purr/spurr +values corresponding to the latest idle period is accounted for before +these values are read. + +Signed-off-by: Gautham R. Shenoy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/1586249263-14048-5-git-send-email-ego@linux.vnet.ibm.com +Acked-by: Michal Suchanek +--- + arch/powerpc/include/asm/idle.h | 32 +++++++++++++ + arch/powerpc/kernel/sysfs.c | 82 +++++++++++++++++++++++++++++++-- + 2 files changed, 111 insertions(+), 3 deletions(-) + +diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h +index 0efb25071d87..accd1f50085a 100644 +--- a/arch/powerpc/include/asm/idle.h ++++ b/arch/powerpc/include/asm/idle.h +@@ -57,5 +57,37 @@ static inline void pseries_idle_epilog(void) + ppc64_runlatch_on(); + } + ++static inline u64 read_this_idle_purr(void) ++{ ++ /* ++ * If we are reading from an idle context, update the ++ * idle-purr cycles corresponding to the last idle period. ++ * Since the idle context is not yet over, take a fresh ++ * snapshot of the idle-purr. ++ */ ++ if (unlikely(get_lppaca()->idle == 1)) { ++ update_idle_purr_accounting(); ++ snapshot_purr_idle_entry(); ++ } ++ ++ return be64_to_cpu(get_lppaca()->wait_state_cycles); ++} ++ ++static inline u64 read_this_idle_spurr(void) ++{ ++ /* ++ * If we are reading from an idle context, update the ++ * idle-spurr cycles corresponding to the last idle period. ++ * Since the idle context is not yet over, take a fresh ++ * snapshot of the idle-spurr. ++ */ ++ if (get_lppaca()->idle == 1) { ++ update_idle_spurr_accounting(); ++ snapshot_spurr_idle_entry(); ++ } ++ ++ return *this_cpu_ptr(&idle_spurr_cycles); ++} ++ + #endif /* CONFIG_PPC_PSERIES */ + #endif +diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c +--- a/arch/powerpc/kernel/sysfs.c ++++ b/arch/powerpc/kernel/sysfs.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + #include "cacheinfo.h" + +@@ -760,6 +761,74 @@ static void create_svm_file(void) + #endif /* HAS_PPC_PMC_PA6T */ + #endif /* HAS_PPC_PMC_CLASSIC */ + ++#ifdef CONFIG_PPC_PSERIES ++static void read_idle_purr(void *val) ++{ ++ u64 *ret = val; ++ ++ *ret = read_this_idle_purr(); ++} ++ ++static ssize_t idle_purr_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct cpu *cpu = container_of(dev, struct cpu, dev); ++ u64 val; ++ ++ smp_call_function_single(cpu->dev.id, read_idle_purr, &val, 1); ++ return sprintf(buf, "%llx\n", val); ++} ++static DEVICE_ATTR(idle_purr, 0400, idle_purr_show, NULL); ++ ++static void create_idle_purr_file(struct device *s) ++{ ++ if (firmware_has_feature(FW_FEATURE_LPAR)) ++ device_create_file(s, &dev_attr_idle_purr); ++} ++ ++static void remove_idle_purr_file(struct device *s) ++{ ++ if (firmware_has_feature(FW_FEATURE_LPAR)) ++ device_remove_file(s, &dev_attr_idle_purr); ++} ++ ++static void read_idle_spurr(void *val) ++{ ++ u64 *ret = val; ++ ++ *ret = read_this_idle_spurr(); ++} ++ ++static ssize_t idle_spurr_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct cpu *cpu = container_of(dev, struct cpu, dev); ++ u64 val; ++ ++ smp_call_function_single(cpu->dev.id, read_idle_spurr, &val, 1); ++ return sprintf(buf, "%llx\n", val); ++} ++static DEVICE_ATTR(idle_spurr, 0400, idle_spurr_show, NULL); ++ ++static void create_idle_spurr_file(struct device *s) ++{ ++ if (firmware_has_feature(FW_FEATURE_LPAR)) ++ device_create_file(s, &dev_attr_idle_spurr); ++} ++ ++static void remove_idle_spurr_file(struct device *s) ++{ ++ if (firmware_has_feature(FW_FEATURE_LPAR)) ++ device_remove_file(s, &dev_attr_idle_spurr); ++} ++ ++#else /* CONFIG_PPC_PSERIES */ ++#define create_idle_purr_file(s) ++#define remove_idle_purr_file(s) ++#define create_idle_spurr_file(s) ++#define remove_idle_spurr_file(s) ++#endif /* CONFIG_PPC_PSERIES */ ++ + static int register_cpu_online(unsigned int cpu) + { + struct cpu *c = &per_cpu(cpu_devices, cpu); +@@ -823,10 +892,13 @@ static int register_cpu_online(unsigned int cpu) + if (!firmware_has_feature(FW_FEATURE_LPAR)) + add_write_permission_dev_attr(&dev_attr_purr); + device_create_file(s, &dev_attr_purr); ++ create_idle_purr_file(s); + } + +- if (cpu_has_feature(CPU_FTR_SPURR)) ++ if (cpu_has_feature(CPU_FTR_SPURR)) { + device_create_file(s, &dev_attr_spurr); ++ create_idle_spurr_file(s); ++ } + + if (cpu_has_feature(CPU_FTR_DSCR)) + device_create_file(s, &dev_attr_dscr); +@@ -910,11 +982,15 @@ static int unregister_cpu_online(unsigned int cpu) + if (cpu_has_feature(CPU_FTR_MMCRA)) + device_remove_file(s, &dev_attr_mmcra); + +- if (cpu_has_feature(CPU_FTR_PURR)) ++ if (cpu_has_feature(CPU_FTR_PURR)) { + device_remove_file(s, &dev_attr_purr); ++ remove_idle_purr_file(s); ++ } + +- if (cpu_has_feature(CPU_FTR_SPURR)) ++ if (cpu_has_feature(CPU_FTR_SPURR)) { + device_remove_file(s, &dev_attr_spurr); ++ remove_idle_spurr_file(s); ++ } + + if (cpu_has_feature(CPU_FTR_DSCR)) + device_remove_file(s, &dev_attr_dscr); +-- +2.40.0 + diff --git a/patches.suse/usb-dwc3-Fix-race-between-dwc3_set_mode-and-__dwc3_s.patch b/patches.suse/usb-dwc3-Fix-race-between-dwc3_set_mode-and-__dwc3_s.patch new file mode 100644 index 0000000..3d99ec9 --- /dev/null +++ b/patches.suse/usb-dwc3-Fix-race-between-dwc3_set_mode-and-__dwc3_s.patch @@ -0,0 +1,103 @@ +From 62c73bfea048e66168df09da6d3e4510ecda40bb Mon Sep 17 00:00:00 2001 +From: Sven Peter +Date: Mon, 28 Nov 2022 17:15:26 +0100 +Subject: [PATCH] usb: dwc3: Fix race between dwc3_set_mode and __dwc3_set_mode +Git-commit: 62c73bfea048e66168df09da6d3e4510ecda40bb +References: git-fixes +Patch-mainline: v6.2-rc1 + +dwc->desired_dr_role is changed by dwc3_set_mode inside a spinlock but +then read by __dwc3_set_mode outside of that lock. This can lead to a +race condition when very quick successive role switch events happen: + +CPU A + dwc3_set_mode(DWC3_GCTL_PRTCAP_HOST) // first role switch event + spin_lock_irqsave(&dwc->lock, flags); + dwc->desired_dr_role = mode; // DWC3_GCTL_PRTCAP_HOST + spin_unlock_irqrestore(&dwc->lock, flags); + queue_work(system_freezable_wq, &dwc->drd_work); + +CPU B + __dwc3_set_mode + // .... + spin_lock_irqsave(&dwc->lock, flags); + // desired_dr_role is DWC3_GCTL_PRTCAP_HOST + dwc3_set_prtcap(dwc, dwc->desired_dr_role); + spin_unlock_irqrestore(&dwc->lock, flags); + +CPU A + dwc3_set_mode(DWC3_GCTL_PRTCAP_DEVICE) // second event + spin_lock_irqsave(&dwc->lock, flags); + dwc->desired_dr_role = mode; // DWC3_GCTL_PRTCAP_DEVICE + spin_unlock_irqrestore(&dwc->lock, flags); + +CPU B (continues running __dwc3_set_mode) + switch (dwc->desired_dr_role) { // DWC3_GCTL_PRTCAP_DEVICE + // .... + case DWC3_GCTL_PRTCAP_DEVICE: + // .... + ret = dwc3_gadget_init(dwc); + +We then have DWC3_GCTL.DWC3_GCTL_PRTCAPDIR = DWC3_GCTL_PRTCAP_HOST and +dwc->current_dr_role = DWC3_GCTL_PRTCAP_HOST but initialized the +controller in device mode. It's also possible to get into a state +where both host and device are intialized at the same time. +Fix this race by creating a local copy of desired_dr_role inside +__dwc3_set_mode while holding dwc->lock. + +Fixes: 41ce1456e1db ("usb: dwc3: core: make dwc3_set_mode() work properly") +Cc: stable +Acked-by: Thinh Nguyen +Signed-off-by: Sven Peter +Link: https://lore.kernel.org/r/20221128161526.79730-1-sven@svenpeter.dev +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Oliver Neukum +--- + drivers/usb/dwc3/core.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -118,17 +118,22 @@ static void __dwc3_set_mode(struct work_ + struct dwc3 *dwc = work_to_dwc(work); + unsigned long flags; + int ret; ++ u32 desired_dr_role; + +- if (!dwc->desired_dr_role) ++ spin_lock_irqsave(&dwc->lock, flags); ++ desired_dr_role = dwc->desired_dr_role; ++ spin_unlock_irqrestore(&dwc->lock, flags); ++ ++ if (!desired_dr_role) + return; + +- if (dwc->desired_dr_role == dwc->current_dr_role) ++ if (desired_dr_role == dwc->current_dr_role) + return; + + if (dwc->dr_mode != USB_DR_MODE_OTG) + return; + +- if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG) ++ if (desired_dr_role == DWC3_GCTL_PRTCAP_OTG) + return; + + switch (dwc->current_dr_role) { +@@ -145,13 +150,13 @@ static void __dwc3_set_mode(struct work_ + + spin_lock_irqsave(&dwc->lock, flags); + +- dwc3_set_prtcap(dwc, dwc->desired_dr_role); ++ dwc3_set_prtcap(dwc, desired_dr_role); + +- dwc->current_dr_role = dwc->desired_dr_role; ++ dwc->current_dr_role = desired_dr_role; + + spin_unlock_irqrestore(&dwc->lock, flags); + +- switch (dwc->desired_dr_role) { ++ switch (desired_dr_role) { + case DWC3_GCTL_PRTCAP_HOST: + ret = dwc3_host_init(dwc); + if (ret) diff --git a/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch b/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch new file mode 100644 index 0000000..c6d02e7 --- /dev/null +++ b/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch @@ -0,0 +1,41 @@ +From a4a97ab3db5c081eb6e7dba91306adefb461e0bd Mon Sep 17 00:00:00 2001 +From: Christophe JAILLET +Date: Sun, 29 Jan 2023 19:23:08 +0100 +Subject: [PATCH] usb: early: xhci-dbc: Fix a potential out-of-bound memory + access +Git-commit: a4a97ab3db5c081eb6e7dba91306adefb461e0bd +References: git-fixes +Patch-mainline: v6.3-rc1 + +If xdbc_bulk_write() fails, the values in 'buf' can be anything. So the +string is not guaranteed to be NULL terminated when xdbc_trace() is called. + +Reserve an extra byte, which will be zeroed automatically because 'buf' is +a static variable, in order to avoid troubles, should it happen. + +Fixes: aeb9dd1de98c ("usb/early: Add driver for xhci debug capability") +Signed-off-by: Christophe JAILLET +Link: https://lore.kernel.org/r/d6a7562c5e839a195cee85db6dc81817f9372cb1.1675016180.git.christophe.jaillet@wanadoo.fr +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Oliver Neukum +--- + drivers/usb/early/xhci-dbc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c +index 797047154820..f3e23be227d4 100644 +--- a/drivers/usb/early/xhci-dbc.c ++++ b/drivers/usb/early/xhci-dbc.c +@@ -874,7 +874,8 @@ static int xdbc_bulk_write(const char *bytes, int size) + + static void early_xdbc_write(struct console *con, const char *str, u32 n) + { +- static char buf[XDBC_MAX_PACKET]; ++ /* static variables are zeroed, so buf is always NULL terminated */ ++ static char buf[XDBC_MAX_PACKET + 1]; + int chunk, ret; + int use_cr = 0; + +-- +2.40.1 + diff --git a/series.conf b/series.conf index 9db07e4..8eb2840 100644 --- a/series.conf +++ b/series.conf @@ -3540,6 +3540,7 @@ patches.suse/platform-x86-ideapad-laptop-Add-Y520-15IKBN-to-no_hw patches.suse/platform-x86-ideapad-laptop-Add-Y720-15IKBN-to-no_hw patches.suse/platform-x86-dell-laptop-Fix-bogus-keyboard-backligh.patch + patches.suse/platform-x86-alienware-wmi-Adjust-instance-of-wmi_ev.patch patches.suse/platform-x86-dell-wmi-led-Adjust-instance-of-wmi_eva.patch patches.suse/KVM-Tidy-the-whitespace-in-nested_svm_check_permissi.patch patches.suse/KVM-white-space-cleanup-in-nested_vmx_setup_ctls_msr.patch @@ -3848,6 +3849,9 @@ patches.suse/powerpc-fadump-avoid-holes-in-boot-memory-area-when-fadump-is-registered.patch patches.suse/powerpc-fadump-provide-a-helpful-error-message.patch patches.suse/powerpc-fadump-add-reschedule-point-while-releasing-memory.patch + patches.suse/cpuidle-powerpc-cpuidle-set-polling-before-enabling-.patch + patches.suse/cpuidle-powerpc-read-mostly-for-common-globals.patch + patches.suse/cpuidle-powerpc-no-memory-barrier-after-break-from-i.patch patches.suse/powerpc-powernv-idle-Clear-r12-on-wakeup-from-stop-lite.patch patches.suse/0001-spin-loop-primitives-for-busy-waiting.patch patches.suse/0001-powerpc-use-spin-loop-primitives-in-some-functions.patch @@ -5503,6 +5507,7 @@ patches.suse/0017-rtc-Remove-wrong-deprecation-comment.patch patches.suse/platform-x86-ideapad-laptop-Add-IdeaPad-V510-15IKB-t patches.suse/platform-x86-ideapad-laptop-Add-several-models-to-no + patches.suse/platform-x86-alienware-wmi-constify-attribute_group-.patch patches.suse/platform-x86-asus-wmi-constify-attribute_group-struc.patch patches.suse/include-linux-dcache.h-use-unsigned-chars-in-struct-.patch patches.suse/kernel.h-handle-pointers-to-arrays-better-in-contain.patch @@ -10222,6 +10227,7 @@ patches.suse/pci-mark-amd-stoney-gpu-ats-as-broken patches.suse/PCI-Add-ACS-quirk-for-APM-X-Gene-devices.patch patches.suse/pci-disable-vf-decoding-before-pcibios_sriov_disable-updates-resources + patches.suse/platform-x86-alienware-wmi-fix-format-string-overflo.patch patches.suse/platform-x86-dell-wmi-Fix-driver-interface-version-q.patch patches.suse/platform-x86-asus-wmi-Evaluate-wmi-method-with-insta.patch patches.suse/platform-x86-intel_pmc_core-Make-the-driver-PCH-fami.patch @@ -23792,6 +23798,7 @@ patches.suse/powerpc-pseries-radix-is-not-subject-to-RMA-limit-re.patch patches.suse/powerpc-pseries-lift-RTAS-limit-for-radix.patch patches.suse/powerpc-64s-Relax-PACA-address-limitations.patch + patches.suse/cpuidle-powernv-avoid-double-irq-enable-coming-out-o.patch patches.suse/powerpc-pseries-cpuidle-add-polling-idle-for-shared-.patch patches.suse/powerpc-initial-pkey-plumbing.patch patches.suse/powerpc-track-allocation-status-of-all-pkeys.patch @@ -50141,6 +50148,8 @@ patches.suse/platform-x86-dell-rbtn-Add-missing-include.patch patches.suse/platform-x86-intel_pmc_ipc-adding-error-handling.patch patches.suse/platform-x86-intel_pmc_core-Mark-local-function-stat.patch + patches.suse/platform-x86-dell-laptop-fix-rfkill-functionality.patch + patches.suse/platform-x86-alienware-wmi-fix-kfree-on-potentially-.patch patches.suse/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch patches.suse/platform-mellanox-Add-TmFifo-driver-for-Mellanox-Blu.patch patches.suse/platform-x86-mlx-platform-Add-support-for-tachometer.patch @@ -56761,6 +56770,11 @@ patches.suse/firmware-imx-scu-fix-corruption-of-header.patch patches.suse/firmware-imx-scu-Fix-possible-memory-leak-in-imx_scu.patch patches.suse/drivers-soc-ti-knav_qmss_queue-Make-knav_gp_range_op.patch + patches.suse/powerpc-Move-idle_loop_prolog-epilog-functions-to-he.patch + patches.suse/powerpc-idle-Store-PURR-snapshot-in-a-per-cpu-global.patch + patches.suse/powerpc-pseries-Account-for-SPURR-ticks-on-idle-CPUs.patch + patches.suse/powerpc-sysfs-Show-idle_purr-and-idle_spurr-for-ever.patch + patches.suse/Documentation-Document-sysfs-interfaces-purr-spurr-i.patch patches.suse/powerpc-eeh-Fix-pseries_eeh_configure_bridge.patch patches.suse/powerpc-pseries-ras-Avoid-calling-rtas_token-in-NMI-.patch patches.suse/powerpc-pseries-ras-Fix-FWNMI_VALID-off-by-one.patch @@ -60641,6 +60655,7 @@ patches.suse/msft-hv-2317-uio_hv_generic-Fix-another-memory-leak-in-error-hand.patch patches.suse/platform-mellanox-mlxbf-tmfifo-Fix-a-memory-barrier-.patch patches.suse/platform-x86-hp-wireless-add-AMD-s-hardware-id-to-th.patch + patches.suse/platform-x86-dell-smbios-wmi-Fix-oops-on-rmmod-dell_.patch patches.suse/platform-x86-intel_punit_ipc-Append-MODULE_DEVICE_TA.patch patches.suse/ALSA-hda-realtek-reset-eapd-coeff-to-default-value-f.patch patches.suse/ALSA-bebob-oxfw-fix-Kconfig-entry-for-Mackie-d.2-Pro.patch @@ -61445,6 +61460,7 @@ patches.suse/xen-blkfront-read-response-from-backend-only-once.patch patches.suse/xen-blkfront-don-t-take-local-copy-of-a-request-from.patch patches.suse/xen-blkfront-don-t-trust-the-backend-response-data-b.patch + patches.suse/platform-x86-dell-smbios-wmi-Add-missing-kfree-in-er.patch patches.suse/mailbox-sti-quieten-kernel-doc-warnings.patch patches.suse/clk-at91-clk-generated-Limit-the-requested-rate-to-o.patch patches.suse/clk-kirkwood-Fix-a-clocking-boot-regression.patch @@ -63149,6 +63165,7 @@ patches.suse/crypto-arm64-Fix-unused-variable-compilation-warnings-of-cpu_feature.patch patches.suse/tracing-Fix-infinite-loop-in-tracing_read_pipe-on-overflowed-print_trace_line.patch patches.suse/usb-typec-Check-for-ops-exit-instead-of-ops-enter-in.patch + patches.suse/usb-dwc3-Fix-race-between-dwc3_set_mode-and-__dwc3_s.patch patches.suse/usb-storage-Add-check-for-kcalloc.patch patches.suse/x86-mm-Randomize-per-cpu-entry-area.patch patches.suse/powerpc-xive-add-missing-iounmap-in-error-path-in-xi.patch @@ -63228,6 +63245,8 @@ patches.suse/scsi-qla2xxx-remove-the-unused-variable-wwn.patch patches.suse/nfsd-fix-race-to-check-ls_layouts.patch patches.suse/tracing-Add-NULL-checks-for-buffer-in-ring_buffer_free_read_page.patch + patches.suse/fotg210-udc-Add-missing-completion-handler.patch + patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch patches.suse/applicom-Fix-PCI-device-refcount-leak-in-applicom_in.patch patches.suse/powerpc-powernv-ioda-Skip-unallocated-resources-when.patch patches.suse/powerpc-pseries-lpar-add-missing-RTAS-retry-status-h.patch