All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: linux-iio@vger.kernel.org, Michael.Hennerich@analog.com
Subject: Re: [PATCH V3] iio: ad9523: replace core mlock with local lock
Date: Mon, 16 Jul 2018 10:50:33 +0100	[thread overview]
Message-ID: <47C2A979-DD95-42AA-8DAF-AD349C45F271@jic23.retrosnub.co.uk> (raw)
In-Reply-To: <ea4c115c-341c-2631-ee86-7bb9c0afa19b@metafoo.de>



On 16 July 2018 09:46:38 BST, Lars-Peter Clausen <lars@metafoo.de> wrote:
>On 07/07/2018 07:11 PM, Jonathan Cameron wrote:
>> On Thu, 5 Jul 2018 15:34:22 +0300
>> Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
>> 
>>> From: Lars-Peter Clausen <lars@metafoo.de>
>>>
>>> This is also part of a long term effort to make the use of mlock
>opaque and
>>> single purpose.
>>>
>>> This lock is required for accessing device registers. The device may
>be
>>> accessed by multiple processes at the same time, and this can result
>in
>>> inconsistent data, where one device reads data before the other one
>has
>>> finished writing.
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
>>> ---
>>>
>>> V2 -> V3:
>>> * added description about the impact of the change
>>>
>>>  drivers/iio/frequency/ad9523.c | 33
>+++++++++++++++++++++++----------
>>>  1 file changed, 23 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/iio/frequency/ad9523.c
>b/drivers/iio/frequency/ad9523.c
>>> index ddb6a334ae68..8fb4e5890713 100644
>>> --- a/drivers/iio/frequency/ad9523.c
>>> +++ b/drivers/iio/frequency/ad9523.c
>>> @@ -274,6 +274,14 @@ struct ad9523_state {
>>>  	unsigned long		vco_out_freq[AD9523_NUM_CLK_SRC];
>>>  	unsigned char		vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC];
>>>  
>>> +	/*
>>> +	 * Lock for accessing device registers. The device may be accessed
>by
>>> +	 * multiple processes at the same time, and this can result in
>>> +	 * inconsistent data, where one device reads data before the other
>one
>>> +	 * has finished writing.
>>> +	 */
>> I'm not sure this is accurate.  This is an SPI device so there is
>locking on
>> the comms in the SPI layers.
>> 
>> The issue here is that we have state changes which involve multiple
>actions
>> that need to be done an atomic fashion (as seen from other threads).
>> In some cases because we have 'read modify write cycles' and in
>> others because we need to be in a particular state to write another
>register.
>> 
>> So a little more detail would make this clearer.  Perhaps as simple
>as saying
>> that some actions are a compound of multiple register writes and
>reads that
>> need to not be interrupted?
>
>The transfer buffers are shared between SPI transfers. So even if only
>one
>register is accessed this need locking.

Fair point.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

      reply	other threads:[~2018-07-16 10:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 12:34 [PATCH V3] iio: ad9523: replace core mlock with local lock Alexandru Ardelean
2018-07-07 17:11 ` Jonathan Cameron
2018-07-16  8:46   ` Lars-Peter Clausen
2018-07-16  9:50     ` Jonathan Cameron [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=47C2A979-DD95-42AA-8DAF-AD349C45F271@jic23.retrosnub.co.uk \
    --to=jic23@jic23.retrosnub.co.uk \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.