From: Sasha Levin Date: Fri, 1 Nov 2024 03:01:32 +0000 (-0400) Subject: Fixes for 4.19 X-Git-Tag: v4.19.323~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e713d1416cdd1d2329f2bcebe20138edba624a1;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/cgroup-fix-potential-overflow-issue-when-checking-ma.patch b/queue-4.19/cgroup-fix-potential-overflow-issue-when-checking-ma.patch new file mode 100644 index 00000000000..e68b4846454 --- /dev/null +++ b/queue-4.19/cgroup-fix-potential-overflow-issue-when-checking-ma.patch @@ -0,0 +1,59 @@ +From a048427c3886f75f054335ffc3b0bdf19495a90a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 12 Oct 2024 07:22:46 +0000 +Subject: cgroup: Fix potential overflow issue when checking max_depth +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Xiu Jianfeng + +[ Upstream commit 3cc4e13bb1617f6a13e5e6882465984148743cf4 ] + +cgroup.max.depth is the maximum allowed descent depth below the current +cgroup. If the actual descent depth is equal or larger, an attempt to +create a new child cgroup will fail. However due to the cgroup->max_depth +is of int type and having the default value INT_MAX, the condition +'level > cgroup->max_depth' will never be satisfied, and it will cause +an overflow of the level after it reaches to INT_MAX. + +Fix it by starting the level from 0 and using '>=' instead. + +It's worth mentioning that this issue is unlikely to occur in reality, +as it's impossible to have a depth of INT_MAX hierarchy, but should be +be avoided logically. + +Fixes: 1a926e0bbab8 ("cgroup: implement hierarchy limits") +Signed-off-by: Xiu Jianfeng +Reviewed-by: Michal Koutný +Signed-off-by: Tejun Heo +Signed-off-by: Sasha Levin +--- + kernel/cgroup/cgroup.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c +index 30c0588067029..4ab74d06be194 100644 +--- a/kernel/cgroup/cgroup.c ++++ b/kernel/cgroup/cgroup.c +@@ -5104,7 +5104,7 @@ static bool cgroup_check_hierarchy_limits(struct cgroup *parent) + { + struct cgroup *cgroup; + int ret = false; +- int level = 1; ++ int level = 0; + + lockdep_assert_held(&cgroup_mutex); + +@@ -5112,7 +5112,7 @@ static bool cgroup_check_hierarchy_limits(struct cgroup *parent) + if (cgroup->nr_descendants >= cgroup->max_descendants) + goto fail; + +- if (level > cgroup->max_depth) ++ if (level >= cgroup->max_depth) + goto fail; + + level++; +-- +2.43.0 + diff --git a/queue-4.19/series b/queue-4.19/series index fd3bbb7979c..f5add71cb28 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -320,3 +320,7 @@ hv_netvsc-fix-vf-namespace-also-in-synthetic-nic-netdev_register-event.patch selinux-improve-error-checking-in-sel_write_load.patch arm64-uprobes-change-the-uprobe_opcode_t-typedef-to-fix-the-sparse-warning.patch xfrm-validate-new-sa-s-prefixlen-using-sa-family-whe.patch +usb-dwc3-remove-generic-phy-calibrate-calls.patch +usb-dwc3-add-splitdisable-quirk-for-hisilicon-kirin-.patch +usb-dwc3-core-stop-processing-of-pending-events-if-c.patch +cgroup-fix-potential-overflow-issue-when-checking-ma.patch diff --git a/queue-4.19/usb-dwc3-add-splitdisable-quirk-for-hisilicon-kirin-.patch b/queue-4.19/usb-dwc3-add-splitdisable-quirk-for-hisilicon-kirin-.patch new file mode 100644 index 00000000000..9260a51347e --- /dev/null +++ b/queue-4.19/usb-dwc3-add-splitdisable-quirk-for-hisilicon-kirin-.patch @@ -0,0 +1,127 @@ +From b74a37d0e980d05c0f9ae24dfa9e72342214db03 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 8 Sep 2020 09:20:56 +0200 +Subject: usb: dwc3: Add splitdisable quirk for Hisilicon Kirin Soc + +From: Yu Chen + +[ Upstream commit f580170f135af14e287560d94045624d4242d712 ] + +SPLIT_BOUNDARY_DISABLE should be set for DesignWare USB3 DRD Core +of Hisilicon Kirin Soc when dwc3 core act as host. + +[mchehab: dropped a dev_dbg() as only traces are now allowwed on this driver] + +Signed-off-by: Yu Chen +Signed-off-by: Mauro Carvalho Chehab +Signed-off-by: Felipe Balbi +Stable-dep-of: 0d410e8913f5 ("usb: dwc3: core: Stop processing of pending events if controller is halted") +Signed-off-by: Sasha Levin +--- + drivers/usb/dwc3/core.c | 25 +++++++++++++++++++++++++ + drivers/usb/dwc3/core.h | 7 +++++++ + 2 files changed, 32 insertions(+) + +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index 259eeb2f6ad53..f50b8bf22356b 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -116,6 +116,7 @@ static void __dwc3_set_mode(struct work_struct *work) + struct dwc3 *dwc = work_to_dwc(work); + unsigned long flags; + int ret; ++ u32 reg; + + if (dwc->dr_mode != USB_DR_MODE_OTG) + return; +@@ -167,6 +168,11 @@ static void __dwc3_set_mode(struct work_struct *work) + otg_set_vbus(dwc->usb2_phy->otg, true); + phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); + phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); ++ if (dwc->dis_split_quirk) { ++ reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); ++ reg |= DWC3_GUCTL3_SPLITDISABLE; ++ dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); ++ } + } + break; + case DWC3_GCTL_PRTCAP_DEVICE: +@@ -1314,6 +1320,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) + dwc->dis_metastability_quirk = device_property_read_bool(dev, + "snps,dis_metastability_quirk"); + ++ dwc->dis_split_quirk = device_property_read_bool(dev, ++ "snps,dis-split-quirk"); ++ + dwc->lpm_nyet_threshold = lpm_nyet_threshold; + dwc->tx_de_emphasis = tx_de_emphasis; + +@@ -1850,10 +1859,26 @@ static int dwc3_resume(struct device *dev) + + return 0; + } ++ ++static void dwc3_complete(struct device *dev) ++{ ++ struct dwc3 *dwc = dev_get_drvdata(dev); ++ u32 reg; ++ ++ if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST && ++ dwc->dis_split_quirk) { ++ reg = dwc3_readl(dwc->regs, DWC3_GUCTL3); ++ reg |= DWC3_GUCTL3_SPLITDISABLE; ++ dwc3_writel(dwc->regs, DWC3_GUCTL3, reg); ++ } ++} ++#else ++#define dwc3_complete NULL + #endif /* CONFIG_PM_SLEEP */ + + static const struct dev_pm_ops dwc3_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) ++ .complete = dwc3_complete, + SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume, + dwc3_runtime_idle) + }; +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h +index a1d65e36a4d41..7f8804e9e74c3 100644 +--- a/drivers/usb/dwc3/core.h ++++ b/drivers/usb/dwc3/core.h +@@ -135,6 +135,7 @@ + #define DWC3_GEVNTCOUNT(n) (0xc40c + ((n) * 0x10)) + + #define DWC3_GHWPARAMS8 0xc600 ++#define DWC3_GUCTL3 0xc60c + #define DWC3_GFLADJ 0xc630 + + /* Device Registers */ +@@ -362,6 +363,9 @@ + /* Global User Control Register 2 */ + #define DWC3_GUCTL2_RST_ACTBITLATER BIT(14) + ++/* Global User Control Register 3 */ ++#define DWC3_GUCTL3_SPLITDISABLE BIT(14) ++ + /* Device Configuration Register */ + #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3) + #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f) +@@ -1004,6 +1008,7 @@ struct dwc3_scratchpad_array { + * 2 - No de-emphasis + * 3 - Reserved + * @dis_metastability_quirk: set to disable metastability quirk. ++ * @dis_split_quirk: set to disable split boundary. + * @imod_interval: set the interrupt moderation interval in 250ns + * increments or 0 to disable. + */ +@@ -1175,6 +1180,8 @@ struct dwc3 { + + unsigned dis_metastability_quirk:1; + ++ unsigned dis_split_quirk:1; ++ + u16 imod_interval; + }; + +-- +2.43.0 + diff --git a/queue-4.19/usb-dwc3-core-stop-processing-of-pending-events-if-c.patch b/queue-4.19/usb-dwc3-core-stop-processing-of-pending-events-if-c.patch new file mode 100644 index 00000000000..128965d6cad --- /dev/null +++ b/queue-4.19/usb-dwc3-core-stop-processing-of-pending-events-if-c.patch @@ -0,0 +1,135 @@ +From cf8bd2d07304110118997f53ae753b6b2b4136d8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 17 Sep 2024 04:48:09 +0530 +Subject: usb: dwc3: core: Stop processing of pending events if controller is + halted + +From: Selvarasu Ganesan + +[ Upstream commit 0d410e8913f5cffebcca79ffdd596009d4a13a28 ] + +This commit addresses an issue where events were being processed when +the controller was in a halted state. To fix this issue by stop +processing the events as the event count was considered stale or +invalid when the controller was halted. + +Fixes: fc8bb91bc83e ("usb: dwc3: implement runtime PM") +Cc: stable@kernel.org +Signed-off-by: Selvarasu Ganesan +Suggested-by: Thinh Nguyen +Acked-by: Thinh Nguyen +Link: https://lore.kernel.org/r/20240916231813.206-1-selvarasu.g@samsung.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/dwc3/core.c | 22 +++++++++++++++++++--- + drivers/usb/dwc3/core.h | 4 ---- + drivers/usb/dwc3/gadget.c | 11 ----------- + 3 files changed, 19 insertions(+), 18 deletions(-) + +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index f50b8bf22356b..c10306234bb11 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -404,6 +404,7 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) + int dwc3_event_buffers_setup(struct dwc3 *dwc) + { + struct dwc3_event_buffer *evt; ++ u32 reg; + + if (!dwc->ev_buf) + return 0; +@@ -416,8 +417,10 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc) + upper_32_bits(evt->dma)); + dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), + DWC3_GEVNTSIZ_SIZE(evt->length)); +- dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); + ++ /* Clear any stale event */ ++ reg = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); ++ dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), reg); + return 0; + } + +@@ -444,7 +447,10 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc) + dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); + dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK + | DWC3_GEVNTSIZ_SIZE(0)); +- dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); ++ ++ /* Clear any stale event */ ++ reg = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); ++ dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), reg); + } + + static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) +@@ -1792,7 +1798,11 @@ static int dwc3_runtime_resume(struct device *dev) + + switch (dwc->current_dr_role) { + case DWC3_GCTL_PRTCAP_DEVICE: +- dwc3_gadget_process_pending_events(dwc); ++ if (dwc->pending_events) { ++ pm_runtime_put(dwc->dev); ++ dwc->pending_events = false; ++ enable_irq(dwc->irq_gadget); ++ } + break; + case DWC3_GCTL_PRTCAP_HOST: + default: +@@ -1879,6 +1889,12 @@ static void dwc3_complete(struct device *dev) + static const struct dev_pm_ops dwc3_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) + .complete = dwc3_complete, ++ ++ /* ++ * Runtime suspend halts the controller on disconnection. It relies on ++ * platforms with custom connection notification to start the controller ++ * again. ++ */ + SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume, + dwc3_runtime_idle) + }; +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h +index 7f8804e9e74c3..1115ed88f3571 100644 +--- a/drivers/usb/dwc3/core.h ++++ b/drivers/usb/dwc3/core.h +@@ -1430,7 +1430,6 @@ static inline void dwc3_otg_host_init(struct dwc3 *dwc) + #if !IS_ENABLED(CONFIG_USB_DWC3_HOST) + int dwc3_gadget_suspend(struct dwc3 *dwc); + int dwc3_gadget_resume(struct dwc3 *dwc); +-void dwc3_gadget_process_pending_events(struct dwc3 *dwc); + #else + static inline int dwc3_gadget_suspend(struct dwc3 *dwc) + { +@@ -1442,9 +1441,6 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc) + return 0; + } + +-static inline void dwc3_gadget_process_pending_events(struct dwc3 *dwc) +-{ +-} + #endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */ + + #if IS_ENABLED(CONFIG_USB_DWC3_ULPI) +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index e617a28aca436..c6610c15e03ed 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -3474,14 +3474,3 @@ int dwc3_gadget_resume(struct dwc3 *dwc) + err0: + return ret; + } +- +-void dwc3_gadget_process_pending_events(struct dwc3 *dwc) +-{ +- if (dwc->pending_events) { +- dwc3_interrupt(dwc->irq_gadget, dwc->ev_buf); +- dwc3_thread_interrupt(dwc->irq_gadget, dwc->ev_buf); +- pm_runtime_put(dwc->dev); +- dwc->pending_events = false; +- enable_irq(dwc->irq_gadget); +- } +-} +-- +2.43.0 + diff --git a/queue-4.19/usb-dwc3-remove-generic-phy-calibrate-calls.patch b/queue-4.19/usb-dwc3-remove-generic-phy-calibrate-calls.patch new file mode 100644 index 00000000000..d801db4c67f --- /dev/null +++ b/queue-4.19/usb-dwc3-remove-generic-phy-calibrate-calls.patch @@ -0,0 +1,51 @@ +From 6fa849fa574a91dcf93d688d491d016363088b7f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 29 Aug 2019 07:30:28 +0200 +Subject: usb: dwc3: remove generic PHY calibrate() calls + +From: Marek Szyprowski + +[ Upstream commit a0a465569b45e3690be155c96fb54603d6904f41 ] + +Calls to USB2 generic PHY calibrate() method has been moved to HCD core, +which now successfully handles generic PHYs and their calibration after +every HCD reset. This fixes all the timing issues related to PHY +calibration done directly from DWC3 driver: incorrect operation after +system suspend/resume or USB3.0 detection failure when XHCI-plat driver +compiled as separate module. + +Signed-off-by: Marek Szyprowski +Tested-by: Anand Moon +Tested-by: Jochen Sprickerhof +Acked-by: Felipe Balbi +Link: https://lore.kernel.org/r/20190829053028.32438-3-m.szyprowski@samsung.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 0d410e8913f5 ("usb: dwc3: core: Stop processing of pending events if controller is halted") +Signed-off-by: Sasha Levin +--- + drivers/usb/dwc3/core.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index 4002c6790be6e..259eeb2f6ad53 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -167,7 +167,6 @@ static void __dwc3_set_mode(struct work_struct *work) + otg_set_vbus(dwc->usb2_phy->otg, true); + phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); + phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); +- phy_calibrate(dwc->usb2_generic_phy); + } + break; + case DWC3_GCTL_PRTCAP_DEVICE: +@@ -1178,7 +1177,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) + dev_err(dev, "failed to initialize host\n"); + return ret; + } +- phy_calibrate(dwc->usb2_generic_phy); + break; + case USB_DR_MODE_OTG: + INIT_WORK(&dwc->drd_work, __dwc3_set_mode); +-- +2.43.0 +