From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796382621; b=1V1OBhi7IdCrEQWexoGWWPTPNGrbZQiQXzFjxwugpJibP4X95VKDYvOdRUA5/9hBP7l/ O5NIxZ9XvM1kTxu0pdXUhJVzD5+o5bXCfCQ1Q1x+jIznz8+a0WoAQCWjh2QkVkmO2nSKM 4IiqQPBzhLZL7yajVq8jPJXGdPdDqWGPKqxsKqjFu3W9JX4GrBY1muUYrZeZdqohqiBDW KkVVeLSyD+l7kwW6vlBsX2bVCq14wWc5bZP+owzv8peAvgRQ2OYF5m4ioMPySVaEwkAHf UvNGIpe8VUxQaTkub3t96r2lTJQeK0K4hnh2aaOwI6pcdJ3eD5lEPJ0Mlrrn7o409SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382621; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=YAgBQUDasVnp61HxhS1nkiSX9UUd4FcjSPJwFWLla88=; b=bVcdTXswdyO0nRD0dvAxvnn2SRxoP3MMOVl6vv1u+4VAcpKapkGOhHd6bwDpN2IBGgj3 jhaUAqUDTXhg8TmL0oejEP5PnrTwkEXSg+Ydn1g+sSAny2WJCo/RNwMwc7PbO++2FkAiU dEY3ffLMX2d/Y2O2bh/CbAbB6NoeX4ZBB19FFYceCdp/1dWuZitkiEYuHp5qveV5R5qBi BWf+PB0iB+3a/v17dKcEAGIP2eAW7UrUqdMDqxbXeKN2bwu6vQ60d3JRfRN9MXFDadjUC X453QZ9e30rq+F+tJ+S23LDcKLH7oi35E6njfherrMd8vCwal8l95lH5fvmZ7BhtpVw== 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=G3zaSCbI; 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 B7790606A32D; Fri, 4 Dec 2026 11:10:21 +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=G3zaSCbI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B8D11F000CE; Fri, 4 Dec 2026 11:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796382621; bh=YAgBQUDasVnp61HxhS1nkiSX9UUd4FcjSPJwFWLla88=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=G3zaSCbIGikQ28AbXNO4mZPMPY7TsacMUeX1byRr7fKsrxwNUM6RtVRvTJeIfiDEU mAxCQUXQUX+ok0bGBaO9E9lJ4LUaM5joSbWTIoV6QMYRdbhLXrxNw+x5PPz+ly19VA VDb6c8x32lNVRQy+FPEPOwvMSYKT4zOiKtyn6uJs7T++YhRDHeineXDzLjI3vlTZSz fIi3UtLr00ibwU1T4Zat98PAVVg4nHf0+lxy2kYbF6s6bOXPl6baW9bQB8yikuQBT2 3VgzTiGIHZclh5Vj+qYawyhclPjyIQFd5c/C2jWvI9pY4GYAbkBz5BGIV0XwlcrG7t V3q4IQ1Z/mFvw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v10 2/2] usb: typec: tipd: Add sn201202x support Reply-To: sashiko-reviews@lists.linux.dev To: "Sasha Finkelstein" Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204-tipd-ace3-v10-2-1b85a2c8501d@chaosmail.tech> References: <20261204-tipd-ace3-v10-0-1b85a2c8501d@chaosmail.tech> <20261204-tipd-ace3-v10-2-1b85a2c8501d@chaosmail.tech> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 11:10:19 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] usb: typec: tipd: leaked IRQ disable and wake state in sn201202x_resume() - [Medium] usb: typec: tipd: missing reinit_completion() in sn201202x_probe() - [Low] usb: typec: tipd: off-by-one retry loop in regmap_sn201202x_select_reg() -- commit bb02d4985a811e3da44335c3016f25058f67a24e Author: Sasha Finkelstein usb: typec: tipd: Add sn201202x support This commit adds support for the TI SN201202x (ACE3) USB Power Delivery controller, exposing its register map over SPMI and wiring it into the tipd core driver. > diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c > new file mode 100644 > index 0000000000000..8c6c97b0b3e2f > --- /dev/null > +++ b/drivers/usb/typec/tipd/spmi.c > @@ -0,0 +1,303 @@ [ ... ] > +static int regmap_sn201202x_select_reg(struct spmi_device *sdev, u8 reg) > +{ > + int err; > + u8 val; > + bool warned =3D false; > + int attempts =3D 5; [ ... ] > + while (--attempts) { > + err =3D spmi_register_read(sdev, 0, &val); > + if (err) > + return err; > + if (val =3D=3D (reg | 0x80)) { > + if (!warned) { > + dev_warn(tps->dev, > + "Got interrupt but selection not complete?\n"); > + warned =3D true; > + } > + msleep(20); > + continue; > + } > + if (val =3D=3D reg) > + return 0; > + return -EIO; > + } > + > + return -EIO; > +} [Severity: Low] Should this loop use attempts-- instead of --attempts? With prefix decrement, the loop only reads register 0 four times instead of five, and on the last iteration it sleeps for 20 ms before returning -EIO without checking register 0 again. [ ... ] > + init_completion(&sn->select_completion); > + init_completion(&sn->sleep_completion); > + init_completion(&sn->wake_completion); > + > + ret =3D devm_request_irq(&device->dev, irq_select, sn201202x_irq, > + 0, NULL, &sn->select_completion); > + if (ret) > + return ret; > + ret =3D devm_request_irq(&device->dev, irq_sleep, sn201202x_irq, > + 0, NULL, &sn->sleep_completion); > + if (ret) > + return ret; > + ret =3D devm_request_irq(&device->dev, irq_wake, sn201202x_irq, > + 0, NULL, &sn->wake_completion); > + if (ret) > + return ret; > + > + spmi_device_set_drvdata(device, tps); > + tps->regmap =3D devm_regmap_init_sn201202x(device, &tps6598x_regmap_con= fig); > + if (IS_ERR(tps->regmap)) > + return PTR_ERR(tps->regmap); > + > + ret =3D spmi_command_wakeup(device); > + if (ret) > + return ret; > + if (!wait_for_completion_timeout(&sn->wake_completion, msecs_to_jiffies= (100))) > + return -ETIMEDOUT; > + > + ret =3D tipd_init(tps); > + if (ret) > + if (!spmi_command_sleep(device)) > + wait_for_completion_timeout(&sn->sleep_completion, msecs_to_jiffies(1= 00)); > + return ret; > +} [Severity: Medium] Can wait_for_completion_timeout() consume a stale wake_completion or sleep_completion here? Both irq_sleep and irq_wake are enabled by devm_request_irq() before the SPMI commands are sent. If an edge-triggered IRQ is already latched pending from boot firmware or a prior unbind, sn201202x_irq() marks the completion done early. Because sn201202x_probe() omits reinit_completion() before spmi_command_wakeup() and spmi_command_sleep() (unlike the other command sites in this file), tipd_init() can race against chip wakeup and the error path can return before the chip finishes entering sleep. [ ... ] > +static int __maybe_unused sn201202x_resume(struct device *dev) > +{ > + struct tps6598x *tps =3D dev_get_drvdata(dev); > + struct sn201202x *sn =3D tps_to_sn(tps); > + int err; > + > + reinit_completion(&sn->wake_completion); > + err =3D spmi_command_wakeup(sn->sdev); > + if (err) > + return err; > + if (!wait_for_completion_timeout(&sn->wake_completion, msecs_to_jiffies= (100))) > + return -ETIMEDOUT; > + return tipd_resume(tps); > +} [Severity: Medium] Do these early returns leak the disable_irq() and enable_irq_wake() calls made by tipd_suspend()? During suspend, sn201202x_suspend() calls tipd_suspend(), which calls disable_irq(tps->irq) and, when wakeup-source is set, enable_irq_wake(tps->irq). Because tps->irq is requested with IRQF_SHARED in tipd_init(), tipd_resume() explicitly unwinds both on all error paths. If spmi_command_wakeup() fails or wake_completion times out, returning before tipd_resume() leaves the IRQ disable depth permanently imbalanced, masking the shared line for every device on it with no recovery on later resumes. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-tipd-ace3-= v10-0-1b85a2c8501d@chaosmail.tech?part=3D2