Hello, On Thu, Nov 05, 2026 at 02:38:09PM +0000, Lee Jones wrote: > ehrpwm_pwm_probe() calls pwmchip_add() before setting driver data and > enabling runtime PM. Because pwmchip_add() immediately exposes the PWM > channels to consumers, a consumer can invoke ehrpwm_pwm_apply() before > pm_runtime_enable() runs, causing registers to be accessed while the > device remains runtime-suspended. Is this correct? Until pm_runtime_enable() is called the device doesn't go into suspend, does it? > Set driver data and enable runtime PM before calling pwmchip_add(), and > disable runtime PM on the error path. > > Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM") > Closes: https://sashiko.dev/#/bug/linux-28b36a80-e4a9-4bb6-97bc-7ca02895570a > Cc: stable@vger.kernel.org > Signed-off-by: Lee Jones > --- > drivers/pwm/pwm-tiehrpwm.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c > index e3407d0a1f7f..f9dd3b91c73a 100644 > --- a/drivers/pwm/pwm-tiehrpwm.c > +++ b/drivers/pwm/pwm-tiehrpwm.c > @@ -461,18 +461,19 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev) > return ret; > } > > - ret = pwmchip_add(chip); > - if (ret < 0) { > - dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); > - goto err_clk_unprepare; > - } > - > platform_set_drvdata(pdev, chip); > pm_runtime_enable(&pdev->dev); > > + ret = pwmchip_add(chip); > + if (ret < 0) { > + dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); > + goto err_pm_disable; > + } > + If you switch the order here, it would be awesome to also switch in the .remove() callback to have the order match. > return 0; > > -err_clk_unprepare: > +err_pm_disable: > + pm_runtime_disable(&pdev->dev); > clk_unprepare(pc->tbclk); > > return ret; > Cc: "Philip, Avinash" > -- > 2.56.0.398.g882cbad275-goog >