Messages in this thread | | | Date | Fri, 3 Apr 2020 21:44:25 +0200 | From | Thierry Reding <> | Subject | Re: [PATCH v2 REBASED] pwm: pca9685: fix pwm/gpio inter-operation |
| |
On Wed, Apr 01, 2020 at 07:01:06PM +0200, Clemens Gruber wrote: > From: Sven Van Asbroeck <TheSven73@gmail.com> > > This driver allows pwms to be requested as gpios via gpiolib. > Obviously, it should not be allowed to request a gpio when its > corresponding pwm is already requested (and vice versa). > So it requires some exclusion code. > > Given that the pwm and gpio cores are not synchronized with > respect to each other, this exclusion code will also require > proper synchronization. > > Such a mechanism was in place, but was inadvertently removed > by Uwe's clean-up patch. > > Upon revisiting the synchronization mechanism, we found that > theoretically, it could allow two threads to successfully > request conflicting pwms / gpios. > > Replace with a bitmap which tracks pwm in-use, plus a mutex. > As long as pwm and gpio's respective request/free functions > modify the in-use bitmap while holding the mutex, proper > synchronization will be guaranteed. > > Reported-by: YueHaibing <yuehaibing@huawei.com> > Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") > Cc: Mika Westerberg <mika.westerberg@linux.intel.com> > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Cc: YueHaibing <yuehaibing@huawei.com> > Link: https://lkml.org/lkml/2019/5/31/963 > Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> > Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> > Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com> > [cg: Tested on an i.MX6Q board with two NXP PCA9685 chips] > > --- > drivers/pwm/pwm-pca9685.c | 85 ++++++++++++++++++++++----------------- > 1 file changed, 48 insertions(+), 37 deletions(-)
Applied, thanks.
Thierry [unhandled content-type:application/pgp-signature] | |