linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	linux-usb@vger.kernel.org
Cc: John Youn <John.Youn@synopsys.com>
Subject: Re: [PATCH 1/4] usb: dwc3: gadget: Don't send unintended link state change
Date: Wed, 23 Oct 2019 09:21:20 +0300	[thread overview]
Message-ID: <87blu8j82n.fsf@gmail.com> (raw)
In-Reply-To: <c493e890dc8f02500fa1356353b5ab6c830b9cf1.1571770732.git.thinhn@synopsys.com>

[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]


Hi Thinh,

Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
> DCTL.ULSTCHNGREQ is a write-only field. When doing a read-modify-write
> to DCTL, the driver must make sure that there's no unintended link state
> change request from whatever is read from DCTL.ULSTCHNGREQ. Set link
> state change to no-action when the driver writes to DCTL.
>
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>

WHAT A GREAT CATCH!!! However, let's do one small change here:

> ---
>  drivers/usb/dwc3/gadget.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 86dc1db788a9..24178b4b9d46 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -57,6 +57,8 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
>  		return -EINVAL;
>  	}
>  
> +	/* Don't send link state change request */
> +	reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK;
>  	dwc3_writel(dwc->regs, DWC3_DCTL, reg);

Let's a small macro or a little function to wrap this. Something
dwc3_dctl_write_safe() or something long those line.

Then that macro/function will make sure to clear those bits.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-10-23  6:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22 19:09 [PATCH 0/4] usb: gadget: Link state changes Thinh Nguyen
2019-10-22 19:09 ` [PATCH 1/4] usb: dwc3: gadget: Don't send unintended link state change Thinh Nguyen
2019-10-23  6:21   ` Felipe Balbi [this message]
2019-10-24  2:10     ` Thinh Nguyen
2019-10-22 19:09 ` [PATCH 2/4] usb: dwc3: gadget: Set link state to RX_Detect on disconnect Thinh Nguyen
2019-10-22 19:10 ` [PATCH 3/4] usb: dwc3: gadget: Clear DCTL.ULSTCHNGREQ before set Thinh Nguyen
2019-10-22 19:10 ` [PATCH 4/4] usb: dwc3: debug: Remove newline printout Thinh Nguyen

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=87blu8j82n.fsf@gmail.com \
    --to=balbi@kernel.org \
    --cc=John.Youn@synopsys.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=linux-usb@vger.kernel.org \
    /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).