Re: [PATCH RFC 2/6] pwm: Add Rust driver for T-HEAD TH1520 SoC

Uwe Kleine-König
2025-05-27T13:57:07Z

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

Hello,

On Tue, May 27, 2025 at 02:44:57PM +0200, Michal Wilczynski/Kernel (PLT) /SRPOL/Engineer/Samsung Electronics wrote:
> W dniu 25.05.2025 o 14:03, Danilo Krummrich pisze:
> > On Sat, May 24, 2025 at 11:14:56PM +0200, Michal Wilczynski wrote:
> >> +impl pwm::PwmOps for Th1520PwmChipData {
> >> + // This driver implements get_state
> >> + fn apply(
> >> + pwm_chip_ref: &mut pwm::Chip,
> >> + pwm_dev: &mut pwm::Device,
> >> + target_state: &pwm::State,
> >> + ) -> Result {
> > I assume those callbacks can't race with pwmchip_remove() called from driver
> > remove()? I.e. the callbacks are guaranteed to complete before pwmchip_remove()
> > completes?
>
> Yeah this is my understanding as well - this is something that the PWM
> core should
> guarantee. Fairly recently there was a commit adding even more locking
> 1cc2e1faafb3 ("pwm: Add more locking")

I confirm that starting with that commit pwmchip_remove() and the driver
callbacks are properly serialized. Before that this an issue, even
though it was hard to hit. (Because if you triggered the callbacks via
sysfs the locking in sysfs code implicitly worked around the problems.)

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]