From nobody Sun Nov 01 18:35:43 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jHk6l4hFNz6xjK7 for ; Sun, 01 Nov 2026 18:35:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jHk6l1ht4z3Kbw for ; Sun, 01 Nov 2026 18:35:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793558143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X+HDxeowpjSQgz0tb09hQI0bb0aRl5hsUzYfO7da5js=; b=M7NM+wth+uAIG2aKT2yg6XGtNmI8IVgn6kJAFv6nQKSvhglw06mrrJBWdhllz42Xp1+ueE kryCHYgdd1k0bsclva0N0wp4rlBvTKO7p5xk0IzbMdKSBiaoVEsVgi248wlZknOK9Y65rs j6i6jhQ+1QpsaTmiHACOCfl9pVw3sg2o/7eJFYKF+6kgjkrAuPC3kIgChiwipc9gou7RZp 9cXzn3PIGb3VBEOaCFVJ+uguH7BihC1gcNFqhNhNcSEY76Csyc89rIXV8mPKUcq+zi2dxa /r1bhbl5gq7jmiXqjMmfRN4FB4jx/1mcDijukLv1NYXN98ZBv/VawhyKfnyThw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793558143; b=u2lvkb435LsvtwFKAI5PfC2ntM65bJnIePA/fKdLobzPYxMKHmnb6ev4q8ouzOAfnVXXtB blgMejGaV+ZrQlFRQVHIpnZQdVxY70lHOA/tsofvaXzbxAoUL45frEsK4seojFmyBE0P8O AbVecEbJm8Fycn13JE/QOVlvnJ1BfsYRFLKE5MUngtjLpt0fr0pD0zaY6Uohdv00Wf2QyP btTNSkyHHSP8Z4bZO/el/j2xwBZA/DxCVB2GXPkcWGq/lXh5VRKr7WVq074yhU8sK53iYG 6WX5WRRPAio+bU4QiAgQDKoC5o/72J9jsIJ4ZUJ/oNTQt9mXOY2rR/cBc8wmew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793558143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X+HDxeowpjSQgz0tb09hQI0bb0aRl5hsUzYfO7da5js=; b=GENIFIK/Tl8vDy+cz8xMCkBxmnjWvnpQUHtCGJfhvyxS2071ys3TA1Sy84INn+BLA07Lhc e9sxmmJIoScpxWWU3uqP87j8w4qPELb/lIXKZ5YGrbD/A4R8cVQByCBwE9vDFEPRvuzzr2 xgUZ0qxo0tzyBPWAjt268HsJwUdqUOYt6d0hZHnSaWzvRk8qLgiHOMWZU2Y/r8o9uYbSWT 3QPalH5PoVNpNDp4waB6KzE8epdKk6M+pg8hvInJ3+hWseGykFo8cjgwDrAOrPpXtDlHr3 Xm3LEVBpahi1Cc6ExGKBSw9UAXiWcn8AuUkjcyU1ReEL/Gw0dgF88UWUmq8d/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jHk6l1LwMz19Kj for ; Sun, 01 Nov 2026 18:35:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 23c0d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 01 Nov 2026 18:35:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Abdelkader Boudih Subject: git: 384bf143fee1 - stable/15 - fwohci: fix LPS delay, PHY_INT storm, and SID timeout recovery List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: seuros X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 384bf143fee1df7b2b6cdb0202465208b381f5ae Auto-Submitted: auto-generated Date: Sun, 01 Nov 2026 18:35:43 +0000 Message-Id: <6ae7867f.23c0d.4df11c01@gitrepo.freebsd.org> The branch stable/15 has been updated by seuros: URL: https://cgit.FreeBSD.org/src/commit/?id=384bf143fee1df7b2b6cdb0202465208b381f5ae commit 384bf143fee1df7b2b6cdb0202465208b381f5ae Author: Abdelkader Boudih AuthorDate: 2026-07-08 05:30:44 +0000 Commit: Abdelkader Boudih CommitDate: 2026-11-01 17:01:42 +0000 fwohci: fix LPS delay, PHY_INT storm, and SID timeout recovery Fixed the post-LPS delay from 500us to the IEEE 1394a-2000 s6.1 mandated 10ms ceiling. Handled PHY_INT by clearing W1C status bits in register 5 (masked ISBR to avoid spurious bus resets). Added a SID timeout callout that recovers the state machine when a remote device fails to complete self-ID. Fixed FW_PHY_SPD operator precedence and gated noisy messages behind bootverbose/firewire_debug. Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D58033 (cherry picked from commit 4b3d035668211c19fc6fd5d4d207c2e8f96e7ad3) --- sys/dev/firewire/fwohci.c | 59 ++++++++++++++++++++++++++++++++++++++------ sys/dev/firewire/fwohcivar.h | 3 +++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index eeb35bb94b42..245edb1f8fe4 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -155,6 +155,7 @@ void fwohci_txbufdb (struct fwohci_softc *, int , struct fw_bulkxfer *); static void fwohci_task_busreset(void *, int); static void fwohci_task_sid(void *, int); static void fwohci_task_dma(void *, int); +static void fwohci_sid_timeout(void *); /* * memory allocated for DMA programs @@ -427,17 +428,20 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) * It is not actually available port on your PC . */ OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_LPS); - DELAY(500); + /* IEEE 1394a-2000 s6.1: PHY reset completes within 10 ms of LPS. */ + DELAY(10000); reg = fwphy_rddata(sc, FW_PHY_SPD_REG); if ((reg >> 5) != 7) { sc->fc.mode &= ~FWPHYASYST; sc->fc.nport = reg & FW_PHY_NP; - sc->fc.speed = reg & FW_PHY_SPD >> 6; + sc->fc.speed = (reg & FW_PHY_SPD) >> 6; if (sc->fc.speed > MAX_SPEED) { - device_printf(dev, "invalid speed %d (fixed to %d).\n", - sc->fc.speed, MAX_SPEED); + if (bootverbose) + device_printf(dev, + "invalid speed %d (fixed to %d).\n", + sc->fc.speed, MAX_SPEED); sc->fc.speed = MAX_SPEED; } device_printf(dev, @@ -449,8 +453,10 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) sc->fc.nport = reg & FW_PHY_NP; sc->fc.speed = (reg2 & FW_PHY_ESPD) >> 5; if (sc->fc.speed > MAX_SPEED) { - device_printf(dev, "invalid speed %d (fixed to %d).\n", - sc->fc.speed, MAX_SPEED); + if (bootverbose) + device_printf(dev, + "invalid speed %d (fixed to %d).\n", + sc->fc.speed, MAX_SPEED); sc->fc.speed = MAX_SPEED; } device_printf(dev, @@ -762,6 +768,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) TASK_INIT(&sc->fwohci_task_busreset, 2, fwohci_task_busreset, sc); TASK_INIT(&sc->fwohci_task_sid, 1, fwohci_task_sid, sc); TASK_INIT(&sc->fwohci_task_dma, 0, fwohci_task_dma, sc); + callout_init_mtx(&sc->sid_timeout_callout, FW_GMTX(&sc->fc), 0); fw_init(&sc->fc); fwohci_reset(sc, dev); @@ -804,6 +811,7 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev) fwohci_db_free(&sc->it[i]); fwohci_db_free(&sc->ir[i]); } + callout_drain(&sc->sid_timeout_callout); if (sc->fc.taskqueue != NULL) { taskqueue_drain(sc->fc.taskqueue, &sc->fwohci_task_busreset); taskqueue_drain(sc->fc.taskqueue, &sc->fwohci_task_sid); @@ -1824,7 +1832,8 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) /* Disable bus reset interrupt until sid recv. */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - device_printf(fc->dev, "%s: BUS reset\n", __func__); + if (sc->sid_timeout_count == 0 || firewire_debug) + device_printf(fc->dev, "%s: BUS reset\n", __func__); OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); @@ -1835,6 +1844,10 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) if (!kdb_active) taskqueue_enqueue(sc->fc.taskqueue, &sc->fwohci_task_busreset); + + /* SID watchdog: recover if self-ID never completes. */ + callout_reset(&sc->sid_timeout_callout, hz / 2, + fwohci_sid_timeout, sc); } if (stat & OHCI_INT_PHY_SID) { /* Enable bus reset interrupt */ @@ -1902,6 +1915,8 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) } fc->status = FWBUSINIT; + callout_stop(&sc->sid_timeout_callout); + sc->sid_timeout_count = 0; if (!kdb_active) taskqueue_enqueue(sc->fc.taskqueue, &sc->fwohci_task_sid); @@ -1982,7 +1997,13 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) device_printf(fc->dev, "unrecoverable error\n"); } if (stat & OHCI_INT_PHY_INT) { - device_printf(fc->dev, "phy int\n"); + uint32_t r5; + + /* Clear W1C interrupt bits; mask ISBR(6) to avoid bus reset. */ + r5 = fwphy_rddata(sc, 5); + if (firewire_debug) + device_printf(fc->dev, "phy int: reg5=0x%02x\n", r5); + fwphy_wrdata(sc, 5, (r5 & ~(1 << 6)) | 0x3c); } } @@ -2039,6 +2060,28 @@ fwohci_task_sid(void *arg, int pending) fw_drain_txq(fc); fw_sidrcv(fc, buf, plen); free(buf, M_FW); + +} + +/* SelfID timeout: called with FW_GLOCK held (callout_init_mtx). */ +static void +fwohci_sid_timeout(void *arg) +{ + struct fwohci_softc *sc = arg; + struct firewire_comm *fc = &sc->fc; + + FW_GLOCK_ASSERT(fc); + if (fc->status != FWBUSRESET) + return; + + sc->sid_timeout_count++; + if (sc->sid_timeout_count == 1) + device_printf(fc->dev, "SelfID timeout, retrying\n"); + + /* Reset state machine so next bus reset is recognized. */ + fc->status = FWBUSINIT; + OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_PHY_BUS_R); + OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_PHY_BUS_R); } static void diff --git a/sys/dev/firewire/fwohcivar.h b/sys/dev/firewire/fwohcivar.h index 754d61bb3513..a9e7e06b5590 100644 --- a/sys/dev/firewire/fwohcivar.h +++ b/sys/dev/firewire/fwohcivar.h @@ -36,6 +36,7 @@ * */ +#include #include typedef struct fwohci_softc { @@ -71,6 +72,8 @@ typedef struct fwohci_softc { struct task fwohci_task_busreset; struct task fwohci_task_sid; struct task fwohci_task_dma; + struct callout sid_timeout_callout; /* fires if SID phase doesn't complete */ + int sid_timeout_count; /* consecutive SID timeouts */ int cycle_lost; } fwohci_softc_t;