From 393bd4abe1b56e59e9c56e47ae2b2a33d82e3c6b Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Wed, 3 Dec 2025 18:58:20 +0800 Subject: [PATCH 1/2] Revert "EHCI: Clear wakeup signal locked in S0 state when device plug in" zhaoxin inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IDAIG5 CVE: NA -------------------- This reverts commit fbb10e33b67d8c61484900ae9c87f347d66cfa5b. This patch has been accepted by the mainline. Therefore, it is necessary this patch in order to update to the mainline version. Signed-off-by: LeoLiu-oc --- drivers/pci/pci-driver.c | 6 +----- drivers/usb/host/ehci-hcd.c | 21 --------------------- drivers/usb/host/ehci-pci.c | 4 ---- drivers/usb/host/ehci.h | 1 - 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index dc33bad9f106..3800a7540330 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -520,11 +520,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev) } pci_restore_state(pci_dev); - if (!(pci_dev->vendor == PCI_VENDOR_ID_ZHAOXIN && - pci_dev->device == 0x3104 && - (pci_dev->revision & 0xf0) == 0x90 && - pci_dev->class == PCI_CLASS_SERIAL_USB_EHCI)) - pci_pme_restore(pci_dev); + pci_pme_restore(pci_dev); return 0; } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 0daa6d98f9b9..8608ac513fb7 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1110,27 +1110,6 @@ int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) return -EBUSY; } - /* Clear wakeup signal locked in S0 state when device plug in */ - if (ehci->zx_wakeup_clear == 1) { - u32 __iomem *reg = &ehci->regs->port_status[4]; - u32 t1 = ehci_readl(ehci, reg); - - t1 &= (u32)~0xf0000; - t1 |= PORT_TEST_FORCE; - ehci_writel(ehci, t1, reg); - t1 = ehci_readl(ehci, reg); - usleep_range(1000, 2000); - t1 &= (u32)~0xf0000; - ehci_writel(ehci, t1, reg); - usleep_range(1000, 2000); - t1 = ehci_readl(ehci, reg); - ehci_writel(ehci, t1 | PORT_CSC, reg); - udelay(500); - t1 = ehci_readl(ehci, &ehci->regs->status); - ehci_writel(ehci, t1 & STS_PCD, &ehci->regs->status); - ehci_readl(ehci, &ehci->regs->status); - } - return 0; } EXPORT_SYMBOL_GPL(ehci_suspend); diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 357dc140e914..baae879dbddd 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -216,10 +216,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ehci_info(ehci, "applying MosChip frame-index workaround\n"); ehci->frame_index_bug = 1; break; - case PCI_VENDOR_ID_ZHAOXIN: - if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x90) - ehci->zx_wakeup_clear = 1; - break; } /* optional debug port, normally in the first BAR */ diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 9625b6030757..c8e9a48e1d51 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -218,7 +218,6 @@ struct ehci_hcd { /* one per controller */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ - unsigned zx_wakeup_clear:1; /* required for usb32 quirk */ #define OHCI_CTRL_HCFS (3 << 6) -- Gitee From 40803877dc7c6f382d53fd74422ddc8875e0cfea Mon Sep 17 00:00:00 2001 From: Weitao Wango Date: Thu, 24 Mar 2022 20:17:35 +0800 Subject: [PATCH 2/2] USB: Fix ehci infinite suspend-resume loop issue in zhaoxin mainline inclusion from mainline-v5.18-rc5 commit f085bd4bfe0907ce2fad2c787fc65871ec5ca6d6 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IDAIG5 CVE: NA ---------------------------- In zhaoxin platform, some ehci projects will latch a wakeup signal internal when plug in a device on port during system S0. This wakeup signal will turn on when ehci runtime suspend, which will trigger a system control interrupt that will resume ehci back to D0. As no device connect, ehci will be set to runtime suspend and turn on the internal latched wakeup signal again. It will cause a suspend-resume loop and generate system control interrupt continuously. Fixed this issue by clear wakeup signal latched in ehci internal when ehci resume callback is called. Acked-by: Alan Stern Signed-off-by: Weitao Wang Link: https://lore.kernel.org/r/20220324121735.3803-1-WeitaoWang-oc@zhaoxin.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-hcd.c | 23 +++++++++++++++++++++++ drivers/usb/host/ehci-pci.c | 4 ++++ drivers/usb/host/ehci.h | 1 + 3 files changed, 28 insertions(+) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 8608ac513fb7..ae0c24d18a4e 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1077,6 +1077,26 @@ static void ehci_remove_device(struct usb_hcd *hcd, struct usb_device *udev) #ifdef CONFIG_PM +/* Clear wakeup signal locked in zhaoxin platform when device plug in. */ +static void ehci_zx_wakeup_clear(struct ehci_hcd *ehci) +{ + u32 __iomem *reg = &ehci->regs->port_status[4]; + u32 t1 = ehci_readl(ehci, reg); + + t1 &= (u32)~0xf0000; + t1 |= PORT_TEST_FORCE; + ehci_writel(ehci, t1, reg); + t1 = ehci_readl(ehci, reg); + msleep(1); + t1 &= (u32)~0xf0000; + ehci_writel(ehci, t1, reg); + ehci_readl(ehci, reg); + msleep(1); + t1 = ehci_readl(ehci, reg); + ehci_writel(ehci, t1 | PORT_CSC, reg); + ehci_readl(ehci, reg); +} + /* suspend/resume, section 4.3 */ /* These routines handle the generic parts of controller suspend/resume */ @@ -1128,6 +1148,9 @@ int ehci_resume(struct usb_hcd *hcd, bool force_reset) if (ehci->shutdown) return 0; /* Controller is dead */ + if (ehci->zx_wakeup_clear_needed) + ehci_zx_wakeup_clear(ehci); + /* * If CF is still set and reset isn't forced * then we maintained suspend power. diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index baae879dbddd..a1eeb6d34fba 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -216,6 +216,10 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ehci_info(ehci, "applying MosChip frame-index workaround\n"); ehci->frame_index_bug = 1; break; + case PCI_VENDOR_ID_ZHAOXIN: + if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x90) + ehci->zx_wakeup_clear_needed = 1; + break; } /* optional debug port, normally in the first BAR */ diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index c8e9a48e1d51..df4a13733c40 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -218,6 +218,7 @@ struct ehci_hcd { /* one per controller */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ + unsigned zx_wakeup_clear_needed:1; /* required for usb32 quirk */ #define OHCI_CTRL_HCFS (3 << 6) -- Gitee