From 33ed698cea297d78625e6b5a5a2e0e91e804168d Mon Sep 17 00:00:00 2001 From: Longfang Liu Date: Mon, 11 Sep 2023 18:22:16 +0800 Subject: [PATCH 1/3] xhci:fix USB xhci controller issue ANBZ: #28492 commit 5923d73e9d9f54d1999e9e30998578c3998e3949 openeuler driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZPUX CVE: NA ---------------------------------------------------------------------- When the current HiSilicon USB xhci controller formats the faulty U disk, it will trigger a controller exception error. This will cause errors in the control logic of the xhci controller and driver software. In the end, all USB devices on the xhci controller cannot be used. By introducing a noop command operation, restore the logic of the xhci controller and driver software, and restore all USB devices on the xhci controller to normal. Signed-off-by: Longfang Liu Signed-off-by: JiangShui Yang Signed-off-by: Wanhan He --- drivers/usb/host/xhci-pci.c | 4 ++++ drivers/usb/host/xhci-ring.c | 6 +++++- drivers/usb/host/xhci.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 1a0ea2fba96f..bb0b89500575 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -603,6 +603,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) if (xhci->quirks & XHCI_RESET_ON_RESUME) xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, "QUIRK: Resetting on resume"); + + if (pdev->vendor == PCI_VENDOR_ID_HUAWEI && + (pdev->device == 0xa23c || pdev->device == 0xa23d)) + xhci->quirks |= XHCI_USB3_NOOP; } #ifdef CONFIG_ACPI diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0ac7254793de..87e46884af28 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1815,7 +1815,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, * Check whether the completion event is for our internal kept * command. */ - if (!cmd_dequeue_dma || cmd_dma != (u64)cmd_dequeue_dma) { + if (!cmd_dequeue_dma || ((cmd_dma != (u64)cmd_dequeue_dma) && + !((xhci->quirks & XHCI_USB3_NOOP) && (cmd_comp_code == + COMP_COMMAND_RING_STOPPED)))) { xhci_warn(xhci, "ERROR mismatched command completion event\n"); return; @@ -1840,6 +1842,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, if (cmd_comp_code == COMP_COMMAND_ABORTED) { xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; if (cmd->status == COMP_COMMAND_ABORTED) { + if (xhci->quirks & XHCI_USB3_NOOP) + trb_to_noop(cmd->command_trb, TRB_CMD_NOOP); if (xhci->current_cmd == cmd) xhci->current_cmd = NULL; goto event_handled; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 808f2ee43b94..874ba4eace42 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1598,6 +1598,7 @@ struct xhci_hcd { #define XHCI_STATE_HALTED (1 << 1) #define XHCI_STATE_REMOVING (1 << 2) unsigned long long quirks; +#define XHCI_USB3_NOOP BIT_ULL(63) #define XHCI_LINK_TRB_QUIRK BIT_ULL(0) #define XHCI_RESET_EP_QUIRK BIT_ULL(1) /* Deprecated */ #define XHCI_NEC_HOST BIT_ULL(2) -- Gitee From c35015072915e507e82c8147392acb24537721b2 Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Mon, 21 Jul 2025 19:26:22 +0800 Subject: [PATCH 2/3] Fixed the wrong debugfs node name in hisi_spi debugfs initialization ANBZ: #28797 commit 9c04e8a224613f439d43cda9afe487e6a0702040 openeuler driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICOAO3 CVE: NA -------------------------------- in hisi_spi_debugfs_init, spi controller pointer is calculated by container_of macro, and the member is hs->dev. But the host pointer cannot be calculated offset directly by this, because hs->dev points to the device in platform device(pdev->dev), and the host->dev points to the pdev->dev.parent. In this patch, this issues is fixed by getting the controller data from pdev->dev.driver_data directly, driver_data points to the spi controller data in the probe stage. Fixes: 20af5164c223 ("spi: hisi-kunpeng: switch to use modern name") Signed-off-by: lujunhua Signed-off-by: Devyn Liu Signed-off-by: Wanhan He --- drivers/spi/spi-hisi-kunpeng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c index 16054695bdb0..241630589c62 100644 --- a/drivers/spi/spi-hisi-kunpeng.c +++ b/drivers/spi/spi-hisi-kunpeng.c @@ -164,7 +164,7 @@ static int hisi_spi_debugfs_init(struct hisi_spi *hs) struct spi_controller *host; - host = container_of(hs->dev, struct spi_controller, dev); + host = hs->dev->driver_data; snprintf(name, 32, "hisi_spi%d", host->bus_num); hs->debugfs = debugfs_create_dir(name, NULL); if (IS_ERR(hs->debugfs)) -- Gitee From 0b9ef1431ac5c3a41059538614a104f01bdbb2e4 Mon Sep 17 00:00:00 2001 From: Bowen Yu Date: Wed, 19 Nov 2025 15:53:37 +0800 Subject: [PATCH 3/3] Fix SPI registration failure logging level ANBZ: #28797 commit b4868a06e04e8012a92949439e4ad55da0911050 openeuler driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID7HUT ---------------------------------------------------------------------- When the SPI controller is registered before GPIO is fully available, the system may fail to acquire necessary resources for the SPI host. Previously, this condition was logged using dev_err(), which unnecessarily elevated the severity of the message, potentially triggering alerts or log analysis systems for what is a normal and expected race condition during device initialization. Fixes: 9f5890466e93 ("spi: hisi-kunpeng: switch to use modern name") Signed-off-by: Bowen Yu Signed-off-by: lujunhua Signed-off-by: Wanhan He --- drivers/spi/spi-hisi-kunpeng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c index 241630589c62..78a35a75fc6e 100644 --- a/drivers/spi/spi-hisi-kunpeng.c +++ b/drivers/spi/spi-hisi-kunpeng.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Register offsets */ #define HISI_SPI_CSCR 0x00 /* cs control register */ @@ -510,10 +511,8 @@ static int hisi_spi_probe(struct platform_device *pdev) } ret = spi_register_controller(host); - if (ret) { - dev_err(dev, "failed to register spi host, ret=%d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to register spi host\n"); if (hisi_spi_debugfs_init(hs)) dev_info(dev, "failed to create debugfs dir\n"); -- Gitee