From: Mathias Nyman Date: Wed, 3 Jun 2026 09:11:26 +0000 (+0300) Subject: xhci: dbc: add helper to set and clear DbC DCE enable bit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de58a7d374eb0caae801704c3e47400b41a53acf;p=thirdparty%2Fkernel%2Flinux.git xhci: dbc: add helper to set and clear DbC DCE enable bit 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 Link: https://patch.msgid.link/20260603091132.1110849-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 49ae546c4103..8cf0f0356bf1 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -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;