lkml.org 
[lkml]   [2014]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 1/4] mfd: add support for Diolan DLN-2 devices
On Thu, Sep 25, 2014 at 01:41:16PM +0300, Octavian Purdila wrote:
> On Thu, Sep 25, 2014 at 1:30 PM, Johan Hovold <johan@kernel.org> wrote:
> > On Thu, Sep 25, 2014 at 01:25:24PM +0300, Octavian Purdila wrote:
> >
> >> Johan, I think we don't really need the spinlock, the disconnect flag
> >> and an atomic counter should work. Do you see any issues with that?
> >
> > No, you need to test and increment atomically so the lock is needed.
> >
> > Consider what could happen if you get a disconnect after testing but
> > before incrementing.
>
> I am still not seeing the problem. We would continue with the
> increment, we will try to send which will fail and go on the error
> path where we will decrement and wake_up. What am I missing?

The whole point of the counter and flag is to make sure that no
transfers are started after the flag is set. If you remove the lock you
cannot guarantee that.

Disconnect sets the flag (after you test it in transfer() but before
incrementing the counter), checks the counter which is 0 and proceeds
with deregistration and deallocation. Then transfer() gets to run...

Johan


\
 
 \ /
  Last update: 2014-09-25 13:21    [W:0.338 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site