Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp192799ybv; Wed, 5 Feb 2020 03:59:11 -0800 (PST) X-Google-Smtp-Source: APXvYqz91+NaJw9pFyIhNCPvvv07H4IhO6k57q/4Ky2JAE4KrChZzG92v6d8gxGvUFmYRDg21/oX X-Received: by 2002:a9d:7b50:: with SMTP id f16mr25828788oto.18.1580903951810; Wed, 05 Feb 2020 03:59:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580903951; cv=none; d=google.com; s=arc-20160816; b=TiM6pTGJPWEcv6AyUFAsA8HoXC14H6M1wOkkdmHDno8jeiBia1NxPnEtY8OkuCIH8M gMMOSGkqDsMJgASmjh2N/LVIOcSjBLZNTENxxgbvOQ7k+dYMunJY9q53fqXrzWkZP/K/ WTzpQiS1frog/M7pFlA4r8gu3OjDCOlz1L+iBEGEkPTJlde7YsSkDw5BENi97uo/2uZn S2e4eCizJrx7uu42zjVGYdg5ANsZJihPprRkm+Y5Pc8TthwRLrhkkmafDhF7OingnAdJ WdKCQe5u9Ce3H0cw0qOCMA6gJzM4Q40q2PbNAFAkoCIIKAPsuL9pDtOSTN5OSV0h7g7Q A+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=AJBgGK3gDHDdKzwAHNdf1EuerfGQMWUfXNcnkjDhdjg=; b=rkXcLQsc4Cqz1b9wP9VXJezEaEuZethDCCtQsXZawGv6NL8kvrKuEnPtFFzkJrKSDm tKNnZb3vgKlGyrPuKvEr9OWsjLx5rtom4oEEzhJNKJaTd3Fyar7nbxx+eCvhWQ0glbQv DxrOmzVIDy8bJfKRHfV2QBrLoH/CwbJ9f2l4TrP/v/ckUqdYV66tokl806xKNkH+2Pur 6jUQoGekdK1qDJXjc7SnN6wYe20/V/5LttPrRkzvYrSscXCfGp0NXsjBu3yqUpdo5TVW aNtOuQ1jkskfGEaHQoyjC1sXdwsPCko07XUckX6cPhwKiw9XXELIIEd20vIhAiwWUbZ3 jmKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@metanate.com header.s=stronger header.b=pBDIT5N2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metanate.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si14392928otu.166.2020.02.05.03.58.59; Wed, 05 Feb 2020 03:59:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@metanate.com header.s=stronger header.b=pBDIT5N2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727922AbgBEL5E (ORCPT + 99 others); Wed, 5 Feb 2020 06:57:04 -0500 Received: from dougal.metanate.com ([90.155.101.14]:20693 "EHLO metanate.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727833AbgBEL5E (ORCPT ); Wed, 5 Feb 2020 06:57:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Content-Type:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description; bh=QIyjQ/REztIDNpy2jOk34jtYI7tAwWjPcGdUhfZavRk=; b=pBDIT5N2UMu5EENFL3Aj9/v5X KoYRuZfpCHcB/lOGydqgH2wb5j8sp5sj2Iz0OYjvCJDaGy+N/daqjvBAyiF3NV4iyAshxRFWxtb1x KYZrLnYYs+sXgrTq84bVhdhC+TQ57T1lFIT4U5o9k4BpmJA0H7J6z/Tne8QDpD3G1nXiKRh7pqqJa I7snvwoFf7Ng9W4pp7Ds9ZmoJ0YYZRCBoL4BjhRYOzGounUE597/nep5+sR+ywPHQOotgQazkPzR4 EKrGpge5oHOPXmIbSHgTpekIykjzih2JCjwtjz/ObFgxhjjKgT+834Eb2x7bqV31ven21LXUMWTWd 3j0ESHxQg==; Received: from dougal.metanate.com ([192.168.88.1] helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1izJIe-0006L1-Td; Wed, 05 Feb 2020 11:56:56 +0000 Date: Wed, 5 Feb 2020 11:56:56 +0000 From: John Keeping To: Minas Harutyunyan Cc: Felipe Balbi , Greg Kroah-Hartman , , Subject: Re: [PATCH] usb: dwc2: Implement set_selfpowered() Message-ID: <20200205115656.3c698385.john@metanate.com> In-Reply-To: <34b74e48-a3ea-f68f-540e-121ae98afb31@synopsys.com> References: <20200204152933.2216615-1-john@metanate.com> <34b74e48-a3ea-f68f-540e-121ae98afb31@synopsys.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authenticated: YES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Minas, On Wed, 5 Feb 2020 07:59:48 +0000 Minas Harutyunyan wrote: > On 2/4/2020 7:29 PM, John Keeping wrote: > > dwc2 always reports as self-powered in response to a device status > > request. Implement the set_selfpowered() operations so that the gadget > > can report as bus-powered when appropriate. > > > > This is modelled on the dwc3 implementation. > > > > Signed-off-by: John Keeping > > Good catch. Just one concern. Your patch partially fix my patch this is > why I think you need to add Fixes tag otherwise it can create merge > conflict if your patch will be merged to next earlier than my. I don't think this is actually a fix for your patch, it's a separate fix which happens to touch the same code. Since dwc2 has never supported the set_selfpowered() operation, I'm not really sure if this counts as a bugfix or a feature. I'm happy to re-send with a fixes tag if you think it's necessary, but I don't think it's accurate in this case - your patch did not introduce a bug here :-) Regards, John > > --- > > drivers/usb/dwc2/gadget.c | 24 +++++++++++++++++++++++- > > 1 file changed, 23 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > index 2717f4401b97..76c0a5242175 100644 > > --- a/drivers/usb/dwc2/gadget.c > > +++ b/drivers/usb/dwc2/gadget.c > > @@ -1646,7 +1646,8 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, > > > > switch (ctrl->bRequestType & USB_RECIP_MASK) { > > case USB_RECIP_DEVICE: > > - status = 1 << USB_DEVICE_SELF_POWERED; > > + status = hsotg->gadget.is_selfpowered << > > + USB_DEVICE_SELF_POWERED; > > status |= hsotg->remote_wakeup_allowed << > > USB_DEVICE_REMOTE_WAKEUP; > > reply = cpu_to_le16(status); > > @@ -4530,6 +4531,26 @@ static int dwc2_hsotg_gadget_getframe(struct usb_gadget *gadget) > > return dwc2_hsotg_read_frameno(to_hsotg(gadget)); > > } > > > > +/** > > + * dwc2_hsotg_set_selfpowered - set if device is self/bus powered > > + * @gadget: The usb gadget state > > + * @is_selfpowered: Whether the device is self-powered > > + * > > + * Set if the device is self or bus powered. > > + */ > > +static int dwc2_hsotg_set_selfpowered(struct usb_gadget *gadget, > > + int is_selfpowered) > > +{ > > + struct dwc2_hsotg *hsotg = to_hsotg(gadget); > > + unsigned long flags; > > + > > + spin_lock_irqsave(&hsotg->lock, flags); > > + gadget->is_selfpowered = !!is_selfpowered; > > + spin_unlock_irqrestore(&hsotg->lock, flags); > > + > > + return 0; > > +} > > + > > /** > > * dwc2_hsotg_pullup - connect/disconnect the USB PHY > > * @gadget: The usb gadget state > > @@ -4621,6 +4642,7 @@ static int dwc2_hsotg_vbus_draw(struct usb_gadget *gadget, unsigned int mA) > > > > static const struct usb_gadget_ops dwc2_hsotg_gadget_ops = { > > .get_frame = dwc2_hsotg_gadget_getframe, > > + .set_selfpowered = dwc2_hsotg_set_selfpowered, > > .udc_start = dwc2_hsotg_udc_start, > > .udc_stop = dwc2_hsotg_udc_stop, > > .pullup = dwc2_hsotg_pullup, > >