mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hongyu Xie <xy521521@gmail.com>
To: stern@rowland.harvard.edu, xy521521@gmail.com, oneukum@suse.com
Cc: gregkh@linuxfoundation.org, brauner@kernel.org,
	jlayton@kernel.org, jack@suse.cz, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, xiehongyu1@kylinos.cn
Subject: Re: [PATCH next] usb: usbfs: Add reset_resume for usbfs
Date: Wed, 17 Jul 2024 09:43:38 +0800	[thread overview]
Message-ID: <6419a4e9-e084-4eb6-8376-9202930ea8be@kylinos.cn> (raw)
In-Reply-To: <3073c8ce-1923-4816-a442-41b4cc333af9@suse.com>

From: Hongyu Xie <xiehongyu1@kylinos.cn>



On 2024/7/16 20:44, Oliver Neukum wrote:
> On 15.07.24 16:22, Alan Stern wrote:
>> On Mon, Jul 15, 2024 at 10:53:14AM +0200, Oliver Neukum wrote:
>>>
>>>
>>> On 11.07.24 16:41, Alan Stern wrote:
> 
>>>> Agreed, but the solution is pretty simple.  Because the device was
>>>> suspended, the userspace driver must have enabled suspend via the
>>>> USBDEVFS_ALLOW_SUSPEND ioctl.
>>>
>>> The whole system could have been suspended, in particularly to S4.
>>
>> You are right.  I was thinking of runtime suspend, not system suspend.
>> My mistake.
> 
> This is at the intersection of several scenarios. That is a good part of
> what makes this difficult.
> In principal I think we could get away with checking for a flag to be set
> at reset_resume() before each operation. Elegant this is not. Yet, it seems
> to me like the race necessarily exists and is unsolvable in user space.
> 

 From what I know, that CONFIG_USB_DEFAULT_PERSIST is enabled by 
default. Then udev->persist_enabled is set to 1 and this causing 
udev->reset_resume set to 1 during init2 in hub_activate.
During resume,
usb_resume_both
   usb_resume_device
     generic_resume
       usb_port_resume
         finish_port_resume
           usb_reset_and_verify_device (if udev->reset_resume is 1)
             hub_port_init
               hub_port_reset
   usb_resume_interface (udev->reset_resume is 1 but usbfs doesn't have 
reset_resume implementation so set intf->needs_binding to 1, and it will 
be rebind in usb_resume_complete)

Even before usbfs->reset_resume is called (if there is one), the USB 
device has already been reset and in a good state.

After all that thaw_processes is called and user-space application runs 
again.

So I still don't understand why "the race necessarily exists". Can you 
show me an example that usbfs->reset_resume causes race?

> Furthermore in the long run, if we want to use D3cold in runtime power
> management, it looks to me like we would want a second permission ioctl
> for that.
> 
>      Regards
>          Oliver
> 
Regards
Hongyu Xie

  reply	other threads:[~2024-07-17  1:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11  8:43 Hongyu Xie
2024-07-11  8:59 ` Oliver Neukum
2024-07-11 14:41   ` Alan Stern
2024-07-15  8:53     ` Oliver Neukum
2024-07-15 14:22       ` Alan Stern
2024-07-16 12:44         ` Oliver Neukum
2024-07-17  1:43           ` Hongyu Xie [this message]
2024-07-17  2:05             ` Alan Stern
2024-07-17  3:13               ` Hongyu Xie
2024-07-17  7:52                 ` Oliver Neukum
2024-07-17 13:44                 ` Alan Stern
2024-07-17 15:27                   ` Oliver Neukum
2024-07-17  7:42             ` Oliver Neukum
2024-07-18  3:23               ` Hongyu Xie
2024-07-12  3:10   ` Hongyu Xie
2024-07-13  2:22     ` Alan Stern
2024-07-15  1:13       ` Hongyu Xie
2024-07-15  8:40         ` Oliver Neukum

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=6419a4e9-e084-4eb6-8376-9202930ea8be@kylinos.cn \
    --to=xy521521@gmail.com \
    --cc=brauner@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=stern@rowland.harvard.edu \
    --cc=xiehongyu1@kylinos.cn \
    /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®