mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Straube <straube.linux@gmail.com>
To: Pavel Skripkin <paskripkin@gmail.com>,
	"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	"open list:STAGING SUBSYSTEM" <linux-staging@lists.linux.dev>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: staging: r8188eu: how to handle nested mutex under spinlock
Date: Sun, 3 Apr 2022 22:51:39 +0200	[thread overview]
Message-ID: <942c0fbd-f8b2-4cae-dd21-79bc55c54902@gmail.com> (raw)
In-Reply-To: <7d3d23c3-1839-3e6a-27bf-85bad384e5e4@gmail.com>

On 4/3/22 15:02, Pavel Skripkin wrote:
> Hi Fabio,
> 
> On 4/3/22 15:55, Fabio M. De Francesco wrote:
>> On domenica 3 aprile 2022 14:45:49 CEST Pavel Skripkin wrote:
>>> Hi Fabio,
>>>
>>> On 4/3/22 15:37, Fabio M. De Francesco wrote:
>>> >> > >> > drivers/staging/r8188eu/core/rtw_pwrctrl.c:379
>>> >> > >> >        if (pwrpriv->ps_processing) {
>>> >> >            while (pwrpriv->ps_processing && 
>>> rtw_get_passing_time_ms(start) <= 3000)
>>> >> >                msleep(10);
>>> >> >        }
>>> >> > >> >> Hm, just wondering, shouldn't we annotate load from >> 
>>> pwrpriv->ps_processing with READ_ONCE() inside while loop?
>>> >> IIUC compiler might want to cache first load into register and we 
>>> will >> stuck here forever.
>>> > > You're right. This can be cached. In situations like these one 
>>> should use
>>> > barriers or other API that use barriers implicitly (completions, 
>>> for example).
>>> >
>>> Not sure about completions, since they may sleep.
>>
>> No completions in this special context. They for _sure_ might sleep. I 
>> was
>> talking about general cases when you are in a loop and wait for status 
>> change.
>>
>>>
>>> Also, don't think that barriers are needed here, since this code just 
>>> waiting for observing value 1. Might be barrier will slightly speed 
>>> up waiting thread, but will also slow down other thread
>>
>> Here, I cannot help with a 100% good answer. Maybe Greg wants to say 
>> something
>> about it?
>>
> 
> 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) {
		while (pwrpriv->bInSuspend &&
		       (rtw_get_passing_time_ms(start) <= 3000 ||
		       (rtw_get_passing_time_ms(start) <= 500)))
				msleep(10);
	}

I just waits 500ms if pwrpriv->bInSuspend is true. Additionaly the
<= 3000 has no effect here because of the ored <= 500.

Even worse the comment seems misleading because pwrpriv->bInSuspend 
indicates usb autosuspend but not system suspend.

regards,
Michael

  reply	other threads:[~2022-04-03 21:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02 20:47 Michael Straube
2022-04-02 21:13 ` Pavel Skripkin
2022-04-02 21:32 ` Larry Finger
2022-04-03  8:44   ` Michael Straube
     [not found] ` <4389354.LvFx2qVVIh@leap>
     [not found]   ` <1813843.tdWV9SEqCh@leap>
2022-04-03 11:08     ` Michael Straube
     [not found]       ` <7365301.EvYhyI6sBW@leap>
2022-04-03 11:41         ` Michael Straube
2022-04-03 11:48           ` Pavel Skripkin
     [not found]             ` <1817830.CQOukoFCf9@leap>
2022-04-03 12:14               ` Michael Straube
2022-04-03 12:19             ` Pavel Skripkin
     [not found]               ` <4412825.cEBGB3zze1@leap>
2022-04-03 12:45                 ` Pavel Skripkin
     [not found]                   ` <2029549.KlZ2vcFHjT@leap>
2022-04-03 13:02                     ` Pavel Skripkin
2022-04-03 20:51                       ` Michael Straube [this message]
2022-04-03 21:15                         ` Pavel Skripkin
2022-04-04  8:50                           ` David Laight
2022-04-04 16:38                             ` Pavel Skripkin
2022-04-04 16:59                               ` David Laight
2022-04-04 17:12                                 ` Pavel Skripkin
     [not found]           ` <1858641.taCxCBeP46@leap>
     [not found]             ` <2366209.jE0xQCEvom@leap>
2022-04-03 12:18               ` Michael Straube
2022-04-04 13:33                 ` Dan Carpenter
2022-04-04 14:16                   ` Michael Straube
     [not found]         ` <3097543.5fSG56mABF@leap>
2022-04-03 11:44           ` Michael Straube

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=942c0fbd-f8b2-4cae-dd21-79bc55c54902@gmail.com \
    --to=straube.linux@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=fmdefrancesco@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®