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  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:   Sat, 29 Aug 2020 16:46:13 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <ardeleanalex@...il.com>
Cc:     Fabrice Gasnier <fabrice.gasnier@...com>,
        Alexandru Ardelean <alexandru.ardelean@...log.com>,
        linux-iio <linux-iio@...r.kernel.org>,
        linux-stm32@...md-mailman.stormreply.com,
        LKML <linux-kernel@...r.kernel.org>,
        linux-arm-kernel@...ts.infradead.org, alexandre.torgue@...com,
        Sergiu Cuciurean <sergiu.cuciurean@...log.com>
Subject: Re: [PATCH v2] iio: stm32-dac: Replace indio_dev->mlock with own
 device lock

On Thu, 27 Aug 2020 13:00:36 +0300
Alexandru Ardelean <ardeleanalex@...il.com> wrote:

> On Thu, Aug 27, 2020 at 12:03 PM Fabrice Gasnier <fabrice.gasnier@...com> wrote:
> >
> > On 8/27/20 10:55 AM, Alexandru Ardelean wrote:  
> > > On Wed, Aug 26, 2020 at 3:03 PM Alexandru Ardelean
> > > <alexandru.ardelean@...log.com> wrote:  
> > >> From: Sergiu Cuciurean <sergiu.cuciurean@...log.com>
> > >>
> > >> As part of the general cleanup of indio_dev->mlock, this change replaces
> > >> it with a local lock. The lock protects against potential races when
> > >> reading the CR reg and then updating, so that the state of pm_runtime
> > >> is consistent between the two operations.
> > >>
> > >> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@...log.com>
> > >> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
> > >> ---  
> > > Forgot the changelog here.
> > > Apologies.
> > >
> > > Changelog v1 -> v2:
> > > * removed whitespace change for 'common' field
> > > * updated comment about the lock usage  
> >
> > Hi Alexandru,
> >
> > Sorry if I missed it... is there an update on the comment :-) ?  
> 
> For a moment there, I thought I didn't.
> GMail's threading is confusing.
> 
> ----------------------------------------------------------------------------
> As part of the general cleanup of indio_dev->mlock, this change replaces
> it with a local lock. The lock protects against potential races when
> reading the CR reg and then updating, so that the state of pm_runtime
> is consistent between the two operations.
> ----------------------------------------------------------------------------
I think this got confused...

see below.


> 
> >
> > Best Regards,
> > Fabrice  
> > >  
> > >>  drivers/iio/dac/stm32-dac.c | 12 ++++++++----
> > >>  1 file changed, 8 insertions(+), 4 deletions(-)
> > >>
> > >> diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
> > >> index 092c796fa3d9..7a8aed476850 100644
> > >> --- a/drivers/iio/dac/stm32-dac.c
> > >> +++ b/drivers/iio/dac/stm32-dac.c
> > >> @@ -26,9 +26,11 @@
> > >>  /**
> > >>   * struct stm32_dac - private data of DAC driver
> > >>   * @common:            reference to DAC common data
> > >> + * @lock:              lock to protect the data buffer during regmap ops

The original comment was:


In this particular case I'm not sure that's what mlock was being used for.
I think it's about avoiding races around checking if powered down and
actually doing it.

And Fabrice's reply:

Hi Sergiu,

Indeed, purpose is to protect against a race here when reading CR, and
updating it via regmap (this also makes the subsequent pm_runtime calls
to be balanced based on this).
(Side note: there is no data buffer involved for the DAC.)
Could you please update the comment ?

Thanks,
Fabrice

> > >>   */
> > >>  struct stm32_dac {
> > >>         struct stm32_dac_common *common;
> > >> +       struct mutex            lock;
> > >>  };  

Powered by blists - more mailing lists