All of lore.kernel.org
 help / color / mirror / Atom feed
From: 自己 <ccc194101@163.com>
To: "Alan Stern" <stern@rowland.harvard.edu>
Cc: gregkh@linuxfoundation.org, jannh@google.com,
	rex.nie@jaguarmicro.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	chenchangcheng <chenchangcheng@kylinos.cn>
Subject: Re:Re: Re: [PATCH] usb: usbfs: Add reset_resume callback to usbfs.
Date: Mon, 25 Aug 2025 10:19:56 +0800 (CST)	[thread overview]
Message-ID: <23f1c6c2.2011.198df066c15.Coremail.ccc194101@163.com> (raw)
In-Reply-To: <379c80f7-aa01-4575-aa0b-d64ef01c1346@rowland.harvard.edu>

At 2025-08-25 10:01:44, "Alan Stern" <stern@rowland.harvard.edu> wrote:
>On Mon, Aug 25, 2025 at 09:36:49AM +0800, 自己 wrote:
>> At 2025-08-23 04:30:18, "Alan Stern" <stern@rowland.harvard.edu> wrote:
>> >On Fri, Aug 22, 2025 at 10:46:02AM +0800, ccc194101@163.com wrote:
>> >> From: chenchangcheng <chenchangcheng@kylinos.cn>
>> >> 
>> >> When an Apple device is inserted into the host, and the host
>> >> wakes up from S3/S4 power states, if the reset_resume process
>> >> is triggered, the absence of a reset_resume callback in usbfs will
>> >> cause the device to unbind.
>> >> By adding a reset_resume callback to usbfs and reporting REMOVE and ADD
>> >> uevents in reset_resume, the userspace is prompted to reissue commands
>> >> to re-establish the binding with usbfs.
>> >
>> >usbfs has no way to inform userspace when the device is reset.  This is 
>> >true for normal resets as well as for reset-resumes (no pre_reset, 
>> >post_reset, or reset_resume callbacks).  I don't see any point in trying 
>> >to add support for the latter but not the former.
>> >
>> >Unbinding the device forces userspace to re-open the device file and 
>> >establish a new binding.  How does adding REMOVE and ADD uevents make 
>> >the situation any better than it already is?
>> >
>> 
>> >Alan Stern
>> 
>> Here is my reasoning: 
>> Currently, for Apple devices after S3/S4 states, since the USB hub loses power, 
>> the reset-resume process is triggered during resume. If the original 
>> reset_resume process is followed, the device would be forcibly unbound,
>> and the device_attach function would be used to rebind the driver.
>> However, usbfs is different in that it cannot automatically rebind
>> after unbinding and requires a userspace ioctl to re-establish the binding.
>> 
>> If we assume that the reset_resume callback of usbfs does nothing
>> and simply returns 0, the USB device would still be reset. When userspace
>> uses the previous file descriptor handle to issue a command, it would result
>> in an error: "PTP_OC 0x1007 receiving resp failed: PTP Session Not Open (0x2003)."
>> 
>> Therefore, by adding REMOVE and ADD uevents in the reset_resume process,
>> userspace is notified to first unbind and then rebind. This approach avoids the aforementioned issue.
>
>Doesn't the "PTP Session Not Open" error notify userspace to unbind and 
>rebind?  Why is adding REMOVE and ADD uevents any better?
>
>In the current kernel there is no reset_resume callback for usbfs.  
>Consequently, when userspace uses the previous file descriptor handle to 
>issue an ioctl command after a resume, it gets a -ENODEV error.  Doesn't 
>this also notify userspace that it should unbind and rebind?  Why is 
>adding a reset_resume callback any better?
>
>Alan Stern

According to the current experimental findings, when userspace encounters
an error while using the previous file descriptor (fd), it does not proceed to unbind
and rebind automatically. Therefore, the two uevents were added in the kernel to explicitly
notify userspace to unbind and rebind.

Chen Changcheng

  reply	other threads:[~2025-08-25  2:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  2:46 [PATCH] usb: usbfs: Add reset_resume callback to usbfs ccc194101
2025-08-22  4:49 ` Greg KH
2025-08-22 20:30 ` Alan Stern
2025-08-25  1:36   ` 自己
2025-08-25  2:01     ` Alan Stern
2025-08-25  2:19       ` 自己 [this message]
2025-08-25  9:50         ` Oliver Neukum
2025-08-25 14:04         ` Re: " Alan Stern

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=23f1c6c2.2011.198df066c15.Coremail.ccc194101@163.com \
    --to=ccc194101@163.com \
    --cc=chenchangcheng@kylinos.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rex.nie@jaguarmicro.com \
    --cc=stern@rowland.harvard.edu \
    /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.