lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 8 Dec 2020 21:25:26 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Sven Van Asbroeck <thesven73@...il.com>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Clemens Gruber <clemens.gruber@...ruber.com>,
        linux-pwm@...r.kernel.org, Lee Jones <lee.jones@...aro.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        David Jander <david@...tonic.nl>
Subject: Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

Hello Sven,

On Tue, Dec 08, 2020 at 01:15:10PM -0500, Sven Van Asbroeck wrote:
> On Tue, Dec 8, 2020 at 11:57 AM Thierry Reding <thierry.reding@...il.com> wrote:
> >
> > Is this really that complicated? I sounds to me like the only thing that
> > you need is to have some sort of usage count for the prescaler. Whenever
> > you want to use the prescaler you check that usage count. If it is zero,
> > then you can just set it to whatever you need. If it isn't zero, that
> > means somebody else is already using it and you can't change it, which
> > means you have to check if you're trying to request the value that's
> > already set. If so, you can succeed, but otherwise you'll have to fail.
> 
> +1
> I think your suggestion is an elegant solution to get the required behaviour.
> 
> One possible complication is synchronization. The sysfs interface has a lock
> protecting against concurrent pwm_apply() calls. But the in-kernel
> API (e.g. pwm_apply_state()) doesn't seem to. This is not normally a problem
> when pwm bits are strictly separated. But in this case we have shared state
> (prescale value and use count), so we probably need to protect pwm_apply()
> with a mutex?

Right, you need a lock. You can look at pwm-imx-tpm.c which has a
similar limitation.
 
> Not sure if it is currently possible *in practice* for two regulator consumer
> drivers to call pwm_apply() from different threads. But Linux is slowly moving
> towards asynchronous probing.

You must assume that there is concurrent access to different channels of
your hardware.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ