Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796117768; b=TnDgZ5J0qNCefqgESk0VD7gcqkU+7hkPpQvZalgbHdZ65WnvYvGylskdBrWEeE7cQeou nYZKY2ZBF0OYx1nG/1MIvdsqaLJ8b4ziWtUj+apIRgfvYmZV8rvuRDR02CJXVv4ZPjLqn 1eNbYqKyOM4nwEyP1PscN75p32xm9d46Wnc/M/0se09CHgKUHgUr0jmuh9jq338QAN0ly wISnk6NOVSSbfvdQ7yQA8xhvF+KXeH/1U/pktcWP0j6cmYqbds2Hlyf0lD3DZuo+f4Mwa r3phrE7kStGrPnOmMylitF7VGqwD6co22BYFi2+vqg2nV6WKdy2Dudtc52v2RZu3zow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796117768; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+X91mUpseCgYO0R7im+qrIZZnZQdizMUvUSymazc4g4=; b=k//5FdCylmd+rTRXbOPdre1x4kNIl1FXQTcHlCCYTPUmCnZtZy5L2pKwIqgizzoK76nY 49yPM1awW0xRNz55kobzCvWpXmUVSxlmujwW+T+V/fyuhyc4zGswt3RQ0545L9GqFtXUo IjloabJoJs+IvLEF4DrV+UUyfcjx5Pk7xAJSRee/Evu3Q4IrUQv1GSWAXpx3heBKuY41G dLc7/wAgO2be1YCySdJt+La4Bo67sqCoc7idKmblNR+2Nl0jQxl2Cgc98KGK2aw7dXN3K K3iGWXccJ0iEoefb3zzsBqWn+Uv3rEGsw9dJ8ww0j5U0MLB1Lifc78TehQXfnC+uGew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TCZ0tyef; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F64C606A320; Tue, 1 Dec 2026 09:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TCZ0tyef Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06B201F000C1; Tue, 1 Dec 2026 09:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796117768; bh=+X91mUpseCgYO0R7im+qrIZZnZQdizMUvUSymazc4g4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=TCZ0tyef9FTkBPIni2JuqxHeUmC4kyZgHvDv5yakNT+QkVZmf4P3ma06+QV4Y2yEF f7pZwPv/G8A58XgO2QbUCtbEON9ETQblVKqPLzuFquKxeMFZZ9kKTEbPwhU/1afBe7 h81qeXiduhI8PlFA4A5dsAblbXozPkaaZ+BhqcWzG0/du5ry0Z094RlTo95jknMgIG uguYJIUoJh/ayhi41MzlMAxEauyIrKurzFlLNyB54qSLs/r2B52Bso/XfnISVgFM7H UpTtc+cFpEklcl9lnRBBhchFd1LfTufGyW2Pp2CtR3HhIzk17VS6hHL+Hvqf67ev/N So0uwRZbnNgFQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] usb: chipidea: stop asynchronous work before destroying roles Reply-To: sashiko-reviews@lists.linux.dev To: "Xu Yang" Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org In-Reply-To: <20261201092430.2212461-1-xu.yang_2@oss.nxp.com> References: <20261201092430.2212461-1-xu.yang_2@oss.nxp.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 09:36:07 +0000 X-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] usb: chipidea: stale OTG event flags and teardown race in ci_hdrc_otg_destroy() -- commit 2edcac291a5d2ee72c3e18a7f2116a86d7b33779 Author: Xu Yang usb: chipidea: stop asynchronous work before destroying roles This commit reorders role teardown to disable power_lost_work and stop OTG interrupts, FSM processing, and ci->work before destroying the gadget and host roles. > diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c > index fecc7d7e2f0d7..ec11056dddfaf 100644 > --- a/drivers/usb/chipidea/otg.c > +++ b/drivers/usb/chipidea/otg.c > @@ -264,12 +264,21 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci) > */ > void ci_hdrc_otg_destroy(struct ci_hdrc *ci) > { > - if (ci->wq) > - destroy_workqueue(ci->wq); > + disable_irq(ci->irq); > + if (disable_work_sync(&ci->work)) { > + ci->id_event =3D false; > + ci->b_sess_valid_event =3D false; > + /* Balance disable_irq_nosync() performed in ci_otg_queue_work() */ > + enable_irq(ci->irq); > + } > + > + if (ci_otg_is_fsm_mode(ci)) > + ci_hdrc_otg_fsm_remove(ci); > =20 > /* Disable all OTG irq and clear status */ > hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS, > OTGSC_INT_STATUS_BITS); > - if (ci_otg_is_fsm_mode(ci)) > - ci_hdrc_otg_fsm_remove(ci); > + if (ci->wq) > + destroy_workqueue(ci->wq); > + enable_irq(ci->irq); > } [Severity: Medium] Can ci_hdrc_otg_destroy() leave ci->id_event or ci->b_sess_valid_event set when re-enabling ci->irq, causing a hardirq storm during role teardown? ci->id_event and ci->b_sess_valid_event are only cleared when disable_work_sync() cancels a pending work item, and hw_write_otgsc() does not clear cable->enabled until after disable_work_sync() returns: 1. In OTG FSM mode, ci_otg_fsm_work() only clears ci->id_event when the state machine remains in OTG_STATE_A_IDLE. If a completed work run transitioned to OTG_STATE_A_WAIT_VRISE, ci->id_event is still true when disable_work_sync() returns false. 2. disable_irq(ci->irq) does not block extcon notifications via ci_cable_notifier() -> ci_irq() -> ci_irq_handler(), which can still see cable->enabled =3D=3D true and set ci->id_event or ci->b_sess_valid_event before hw_write_otgsc() runs: CPU0 CPU1 ci_hdrc_otg_destroy() disable_irq(ci->irq) disable_work_sync(&ci->work) ci_cable_notifier() ci_irq(ci) ci_otg_irq(ci) ci->id_event =3D true ci_otg_queue_work(ci) hw_write_otgsc(...) enable_irq(ci->irq) ci_hdrc_gadget_destroy() ci_irq_handler() if (ci->id_event || ...) ci_otg_queue_work(ci) return IRQ_HANDLED; <-- skips ci_role(ci)->irq(ci), IRQ storm Because ci->work is now disabled, queue_work() in ci_otg_queue_work() always returns false and immediately calls enable_irq(ci->irq), while ci_irq_handler() returns IRQ_HANDLED before calling ci_role(ci)->irq(ci) to clear the device or host interrupt status. Calling ci_hdrc_otg_fsm_remove() and hw_write_otgsc() before disable_work_sync(&ci->work), and clearing ci->id_event and ci->b_sess_valid_event unconditionally afterwards, would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201092430.2212= 461-1-xu.yang_2@oss.nxp.com?part=3D1