RE: staging: r8188eu: how to handle nested mutex under spinlock

From: David Laight
Date: Mon Apr 04 2022 - 04:51:06 EST


From: Pavel Skripkin
> Sent: 03 April 2022 22:15
>
> Hi Michael,
>
> On 4/3/22 23:51, Michael Straube wrote:
> >>
> >> IMO, the best answer is just remove this loop, since it does nothing. Or
> >> redesign it to be more sane
> >>
> >> It waits for ps_processing to become 0 for 3000 ms, but if 3000 ms
> >> expires... execution goes forward like as ps_processing was 0 from the
> >> beginning
> >>
> >> Maybe it's something hw related, like wait for 3000 ms and all will be
> >> ok. Can't say...
> >>
> >
> > Hi Pavel,
> >
> > same with the loop that follows:
> >
> > /* System suspend is not allowed to wakeup */
> > if (pwrpriv->bInSuspend) {
>
> ^^^^
>
> btw, this part is useless to
>
>
> > while (pwrpriv->bInSuspend &&
>
> I've looked into what gcc11 produced from this function and looks like
> my compiler is smart enough to not cache that value, but I am afraid not
> all compilers are that smart.

The compiler can't cache the value because of the function call.

Quite whether the code is in any way sane in another matter.

You definitely cannot sleep with a spinlock held.
Imagine what happens if another process tries to acquire the
spinlock while you are sleeping.
It will spin forever.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)