Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Nicolas Ferre <nicolas.ferre@microchip.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	<linux-pwm@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/2] pwm: atmel-tcb: Fix race condition and convert to guards
Date: Wed, 10 Jul 2024 18:13:40 +0200	[thread overview]
Message-ID: <f03471e7-a4e5-483a-b6b1-71a7d9b54b82@microchip.com> (raw)
In-Reply-To: <i3d3x7rzqphcjhagmdfenqxrzq72k5qdmdv2dh3tjvwmbrcub2@nfkck2zyjbzf>

On 10/07/2024 at 17:31, Uwe Kleine-König wrote:
> Hello Nicolas,
> 
> On Wed, Jul 10, 2024 at 04:17:09PM +0200, Nicolas Ferre wrote:
>> On 09/07/2024 at 12:18, Uwe Kleine-König wrote:
>>> The hardware only supports a single period length for both PWM outputs. So
>>> atmel_tcb_pwm_config() checks the configuration of the other output if it's
>>> compatible with the currently requested setting. The register values are
>>> then actually updated in atmel_tcb_pwm_enable(). To make this race free
>>> the lock must be held during the whole process, so grab the lock in
>>> .apply() instead of individually in atmel_tcb_pwm_disable() and
>>> atmel_tcb_pwm_enable() which then also covers atmel_tcb_pwm_config().
>>>
>>> To simplify handling, use the guard helper to let the compiler care for
>>> unlocking. Otherwise unlocking would be more difficult as there is more
>>> than one exit path in atmel_tcb_pwm_apply().
>>>
>>> Fixes: 9421bade0765 ("pwm: atmel: add Timer Counter Block PWM driver")
>>> Signed-off-by: Uwe Kleine-König<u.kleine-koenig@baylibre.com>
>> Acked-by: Nicolas Ferre<nicolas.ferre@microchip.com>
>>
>> And I like the conversion to the "guard" lock helper.
> I hesitated a bit to add it because it will make backporting to stable
> harder. But I guess we will just not backport it, the problem doesn't
> seem to matter in practise given that it was found by looking at code
> and not hit in real life more more than 11 years after its introduction.

Fair indeed: +1.

> Best regards and thanks for your Acks,
> Uwe


      reply	other threads:[~2024-07-10 16:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 10:18 [PATCH 1/2] pwm: atmel-tcb: Fix race condition and convert to guards Uwe Kleine-König
2024-07-09 10:18 ` [PATCH 2/2] pwm: atmel-tcb: Simplify checking the companion output Uwe Kleine-König
2024-07-10 14:17   ` Nicolas Ferre
2024-07-10 15:58     ` Uwe Kleine-König
2024-07-10 14:17 ` [PATCH 1/2] pwm: atmel-tcb: Fix race condition and convert to guards Nicolas Ferre
2024-07-10 15:31   ` Uwe Kleine-König
2024-07-10 16:13     ` Nicolas Ferre [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=f03471e7-a4e5-483a-b6b1-71a7d9b54b82@microchip.com \
    --to=nicolas.ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=boris.brezillon@collabora.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox