lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230121002059.mpiqavemelnntxd7@synopsys.com>
Date:   Sat, 21 Jan 2023 00:21:10 +0000
From:   Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To:     Elson Serrao <quic_eserrao@...cinc.com>
CC:     Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "balbi@...nel.org" <balbi@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "quic_wcheng@...cinc.com" <quic_wcheng@...cinc.com>,
        "quic_jackp@...cinc.com" <quic_jackp@...cinc.com>
Subject: Re: [PATCH v2 1/5] usb: gadget: Add remote wakeup capable flag

On Fri, Jan 20, 2023, Elson Serrao wrote:
> 
> 
> On 1/19/2023 5:15 PM, Thinh Nguyen wrote:
> > On Thu, Jan 19, 2023, Elson Serrao wrote:
> > > 
> > > 
> > > On 1/18/2023 5:44 PM, Thinh Nguyen wrote:
> > > > On Tue, Jan 17, 2023, Elson Roy Serrao wrote:
> > > > > Add a flag to indicate whether the gadget is capable
> > > > > of sending remote wakeup to the host.
> > > > > 
> > > > > Signed-off-by: Elson Roy Serrao <quic_eserrao@...cinc.com>
> > > > > ---
> > > > >    drivers/usb/gadget/composite.c | 3 +++
> > > > >    include/linux/usb/gadget.h     | 2 ++
> > > > >    2 files changed, 5 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> > > > > index 403563c..b83963a 100644
> > > > > --- a/drivers/usb/gadget/composite.c
> > > > > +++ b/drivers/usb/gadget/composite.c
> > > > > @@ -965,6 +965,9 @@ static int set_config(struct usb_composite_dev *cdev,
> > > > >    	else
> > > > >    		usb_gadget_clear_selfpowered(gadget);
> > > > > +	if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes)
> > > > > +		gadget->rw_capable = 1;
> > > > 
> > > > Some device may not support remote wakeup. gadget->rw_capable should be
> > > > set and reported by the UDC. May need a gadget ops to enable remote
> > > > wakeup here.
> > > > 
> > > > Thanks,
> > > > Thinh
> > > > 
> > > Not exactly clear on which parameter in UDC decides whether a device
> > > supports remote wakeup. Here I have this flag just to indicate whether the
> > > connected device is rw capable based on the bmAttributes populated in the
> > > config descriptor. If the UDC doesnt have a callback for remote wakeup we
> > > have that check when calling the gadget op in udc/core.c (have added a
> > > similar check in usb_func_wakeup() also ).
> > 
> > That flag describes the gadget's capability, not the device
> > configuration. However, it's being used as a configuration flag.
> > 
> > Thanks,
> > Thinh
> > 
> 
> Thank you for the clarification. Please let me know if below approach where
> we consider both gadget's capability and device configuration fine?
> 
> if (gadget->ops->wakeup || gadget->ops->func_wakeup)
>    gadget->rw_capable = USB_CONFIG_ATT_WAKEUP & c->bmAttributes ? 1: 0;
> 

The way gadget->rw_capable is named and described, it's a capability
flag. That is, its value shouldn't change from the user config. Perhaps
we don't need that in the usb_gadget, and we can have something that
looks like this:

if (gadget->ops->wakeup && (c->bmAttributes & USB_CONFIG_ATT_WAKEUP))
	usb_gadget_enable_remote_wakeup(g);
else
	usb_gadget_disable_remote_wakeup(g);

The setting of the remote wakeup configuration can be tracked internally
by the dwc3 driver based on the usb_gadget_enable_remote_wakeup call.

Thanks,
Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ