linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhuyinbo <zhuyinbo@loongson.cn>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jiri Kosina <jikos@kernel.org>,
	benjamin.tissoires@redhat.com, gregkh@linuxfoundation.org,
	Thinh.Nguyen@synopsys.com, mathias.nyman@linux.intel.com,
	rajatja@google.com, chris.chiu@canonical.com,
	linux-usb@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, zhuyinbo@loongson.cn,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Rajat Jain <rajatja@google.com>,
	Chris Chiu <chris.chiu@canonical.com>,
	linux-usb@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] usb: core: enable remote wakeup function for usb controller
Date: Fri, 10 Dec 2021 17:27:30 +0800	[thread overview]
Message-ID: <fbd46e52-054c-8aea-2f06-3af74c95e5e0@loongson.cn> (raw)
In-Reply-To: <YbEsCSwYLgQefQxU@rowland.harvard.edu>



在 2021/12/9 上午6:04, Alan Stern 写道:
> On Wed, Dec 08, 2021 at 05:39:51PM +0800, Yinbo Zhu wrote:
>> The remote wake up function is a regular function on usb device and
>> I think keeping it enabled by default will make the usb application
>> more convenient and usb device remote wake up function keep enabled
>> that ask usb controller remote wake up was enabled at first.
>>
>> This patch only enable wake up on usb root hub device, among which,
> 
> You say the patch only affects root hub devices, but this doesn't appear
> to be true.
> 
>> usb3.0 root hub doesn't be set wakeup node property but use command
>> USB_INTRF_FUNC_SUSPEND to enable remote wake up function.
>>
>> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
>> ---
>>   drivers/usb/core/hub.c | 20 ++++++++++++++++++--
>>   include/linux/usb.h    |  4 +++-
>>   2 files changed, 21 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> index 86658a8..cb4b956 100644
>> --- a/drivers/usb/core/hub.c
>> +++ b/drivers/usb/core/hub.c
>> @@ -2509,6 +2509,8 @@ static void set_usb_port_removable(struct usb_device *udev)
>>    */
>>   int usb_new_device(struct usb_device *udev)
>>   {
>> +	struct usb_host_config *config;
>> +	int ncfg;
>>   	int err;
>>   
>>   	if (udev->parent) {
>> @@ -2540,6 +2542,18 @@ int usb_new_device(struct usb_device *udev)
>>   	udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
>>   			(((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
>>   
>> +	for (ncfg = 0; ncfg < udev->descriptor.bNumConfigurations; ncfg++) {
>> +		config = &udev->config[ncfg];
>> +		if ((config->desc.bmAttributes & (1 << 5)) == 0)
>> +			break;
>> +		if (ncfg + 1 == udev->descriptor.bNumConfigurations) {
>> +			err = usb_enable_remote_wakeup(udev);
>> +			if (err)
>> +				dev_dbg(&udev->dev,
>> +				      "won't remote wakeup, err %d\n", err);
>> +		}
>> +	}
> 
> I don't see anything in there which treats root hubs differently from
> other devices.
> 
Hi Alan Stern,

You can find following code, non-root-hub had removed Wakeup sysfs 
attributes and disabled wakeup and root-hub had added wakeup sysfs 
attibutes before call usb_new_device, so this patch was only enabled
remote wakeup for root-hub device.
int usb_new_device(struct usb_device *udev)
{
         if (udev->parent) {
                 /* Initialize non-root-hub device wakeup to disabled;
                  * device (un)configuration controls wakeup capable
                  * sysfs power/wakeup controls wakeup enabled/disabled
                  */
                 device_init_wakeup(&udev->dev, 0);
         }

> Besides, enabling wakeup for root hubs is generally a bad idea.  Suppose
> you closed a laptop's lid and then unplugged a USB device -- with wakeup
> enabled, the unplug would cause the laptop to wake up again without your
> knowledge.
> 
> Alan Stern
when closed laptop's lid and then unplugged a non-hid usb device it 
doesn't cause laptop to wakeup. and if that usb device is hid type and 
cause laptop into wakeup state then system will continue into suspend 
state becuase system ask that need accepted a acpi lid open event.
and for laptop usb wakeup that as general ask bios to enable usb wakeup 
then if need do more things to enable usb wakeup I think this usb wakeup 
function isn't friendly and inconveient, so enable it by default.
after add this patch, if want to use usb wakeup function it only need 
enable bios configure it think it is appropriate.

BRs,
Yinbo.
> 


  reply	other threads:[~2021-12-10  9:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08  9:39 [PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device Yinbo Zhu
2021-12-08  9:39 ` [PATCH v1 2/2] usb: core: enable remote wakeup function for usb controller Yinbo Zhu
2021-12-08 14:10   ` kernel test robot
2021-12-08 22:04   ` Alan Stern
2021-12-10  9:27     ` zhuyinbo [this message]
2021-12-10 16:35       ` Alan Stern
2021-12-08 10:03 ` [PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device Oliver Neukum
2021-12-10  9:50   ` zhuyinbo
2021-12-14 14:21     ` Oliver Neukum
2021-12-16 10:59       ` zhuyinbo
2021-12-16 12:42         ` Oliver Neukum
2022-01-04 11:44           ` zhuyinbo
2021-12-08 11:55 ` Greg Kroah-Hartman
2021-12-10  9:54   ` zhuyinbo
2021-12-10 10:45     ` Greg Kroah-Hartman
2021-12-16 11:40       ` zhuyinbo

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=fbd46e52-054c-8aea-2f06-3af74c95e5e0@loongson.cn \
    --to=zhuyinbo@loongson.cn \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=chris.chiu@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=rajatja@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).