]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xhci: dbc: add helper to set and clear DbC DCE enable bit
authorMathias Nyman <mathias.nyman@linux.intel.com>
Wed, 3 Jun 2026 09:11:26 +0000 (12:11 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jun 2026 17:23:29 +0000 (19:23 +0200)
Add xhci_dbc_enable_dce() helper to enable or disable DbC by manipulating
DCE bit correctly. It will be used for stuck DbC recovery attempts in
addition to normal DbC enable and disable functionality

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260603091132.1110849-10-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-dbgcap.c

index 49ae546c41037866f7e91eda1225661c0d78dc08..8cf0f0356bf1c018925eb786d05fe22199b768ca 100644 (file)
@@ -628,18 +628,30 @@ static void xhci_dbc_mem_cleanup(struct xhci_dbc *dbc)
        dbc->ring_evt = NULL;
 }
 
+static int xhci_dbc_enable_dce(struct xhci_dbc *dbc, bool enable)
+{
+       u32 done_state = 0;
+       u32 ctrl = 0;
+
+       if (enable) {
+               ctrl = readl(&dbc->regs->control);
+               ctrl |= DBC_CTRL_DBC_ENABLE | DBC_CTRL_PORT_ENABLE;
+               done_state =  DBC_CTRL_DBC_ENABLE;
+       }
+
+       writel(ctrl, &dbc->regs->control);
+       return xhci_handshake(&dbc->regs->control, DBC_CTRL_DBC_ENABLE,
+                             done_state, 1000);
+}
+
 static int xhci_do_dbc_start(struct xhci_dbc *dbc)
 {
        int                     ret;
-       u32                     ctrl;
 
        if (dbc->state != DS_DISABLED)
                return -EINVAL;
 
-       writel(0, &dbc->regs->control);
-       ret = xhci_handshake(&dbc->regs->control,
-                            DBC_CTRL_DBC_ENABLE,
-                            0, 1000);
+       ret = xhci_dbc_enable_dce(dbc, false);
        if (ret)
                return ret;
 
@@ -647,12 +659,7 @@ static int xhci_do_dbc_start(struct xhci_dbc *dbc)
        if (ret)
                return ret;
 
-       ctrl = readl(&dbc->regs->control);
-       writel(ctrl | DBC_CTRL_DBC_ENABLE | DBC_CTRL_PORT_ENABLE,
-              &dbc->regs->control);
-       ret = xhci_handshake(&dbc->regs->control,
-                            DBC_CTRL_DBC_ENABLE,
-                            DBC_CTRL_DBC_ENABLE, 1000);
+       ret = xhci_dbc_enable_dce(dbc, true);
        if (ret)
                return ret;