All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chi-Wen Weng <cwweng.linux@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	cwweng@nuvoton.com
Subject: Re: [PATCH v6 2/2] pwm: Add Nuvoton MA35D1 PWM controller support
Date: Wed, 16 Sep 2026 12:26:10 +0800	[thread overview]
Message-ID: <dfdddb60-d150-4d8a-9393-feb2f3e32805@gmail.com> (raw)
In-Reply-To: <20260914111742.85BF01F000FF@smtp.kernel.org>



sashiko-bot@kernel.org 於 2026/9/14 下午 07:17 寫道:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The driver relies on the bootloader-configured CLKPSC (prescaler) register but does not cache its value, which will cause incorrect period calculations after a system suspend/resume cycle.
> --
> 
> commit b9ac3c051c5908fe946a0ef1c7b809030aa32933
> Author: Chi-Wen Weng <cwweng@nuvoton.com>
> 
> pwm: Add Nuvoton MA35D1 PWM controller support
> 
> This commit adds a generic PWM framework driver for the Nuvoton MA35D1 PWM
> controller. The initial driver supports 6 channels in up-counting,
> auto-reload, independent output, and period loading modes.
> 
>> diff --git a/drivers/pwm/pwm-ma35d1.c b/drivers/pwm/pwm-ma35d1.c
>> new file mode 100644
>> --- /dev/null
>> +++ b/drivers/pwm/pwm-ma35d1.c
> [ ... ]
>> +static u32 nuvoton_pwm_get_prescale(struct nuvoton_pwm *nvtpwm,
>> +				    unsigned int ch)
>> +{
>> +	return nuvoton_pwm_readl(nvtpwm, MA35D1_REG_PWM_CLKPSC(ch)) &
>> +	       MA35D1_PWM_CLKPSC_MASK;
>> +}
> 
> [Severity: Medium]
> Does reading the hardware register directly here make the driver vulnerable
> to hardware state loss during system suspend?
> 
> If the controller loses power during suspend, the clock prescaler register
> might reset to its default value. When the system resumes and a consumer
> subsequently calls into the apply callback, this function will return the
> reset value instead of the bootloader-configured value. This could result
> in drastically altered PWM output frequencies.
> 
> Would it be safer to cache the prescaler value during probe?
> 
> [ ... ]
>> +static struct platform_driver nuvoton_pwm_driver = {
>> +	.probe = nuvoton_pwm_probe,
>> +	.driver = {
>> +		.name = "nuvoton-pwm",
>> +		.of_match_table = nuvoton_pwm_of_match,
>> +	},
>> +};
> 
> [Severity: Medium]
> Should this driver include PM callbacks to handle saving and restoring the
> hardware state?
> 
> Currently, there are no suspend/resume hooks provided. If the platform
> powers down the PWM domain during system suspend, the controller state
> will be lost upon resume and might not be appropriately reconfigured before
> the next state application.
> 

Hi,

Thanks for the review.

On MA35D1, the EPWM register context is retained across system suspend.
This includes CLKPSC as well as the other EPWM configuration registers
used by the driver.

Therefore, after resume, nuvoton_pwm_get_prescale() still reads the
same CLKPSC value that was present before suspend. The firmware-provided
prescaler value is not lost, so caching CLKPSC during probe would be
redundant.

For the same reason, suspend/resume callbacks are not required to save
and restore the EPWM register state on MA35D1.

So I don't think either of these issues requires a driver change.

Best regards,
Chi-Wen



      reply	other threads:[~2026-09-16  4:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 11:07 [PATCH v6 0/2] pwm: Add Nuvoton MA35D1 PWM controller support Chi-Wen Weng
2026-09-14 11:07 ` [PATCH v6 1/2] dt-bindings: pwm: Add Nuvoton MA35D1 PWM controller Chi-Wen Weng
2026-09-14 11:07 ` [PATCH v6 2/2] pwm: Add Nuvoton MA35D1 PWM controller support Chi-Wen Weng
2026-09-14 11:17   ` sashiko-bot
2026-09-16  4:26     ` Chi-Wen Weng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dfdddb60-d150-4d8a-9393-feb2f3e32805@gmail.com \
    --to=cwweng.linux@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=cwweng@nuvoton.com \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ukleinek@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.