mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Youn <John.Youn@synopsys.com>
To: Douglas Anderson <dianders@chromium.org>,
	John Youn <John.Youn@synopsys.com>, "balbi@ti.com" <balbi@ti.com>
Cc: "Yunzhi Li" <lyz@rock-chips.com>,
	"Heiko Stübner" <heiko@sntech.de>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"Julius Werner" <jwerner@chromium.org>,
	"gregory.herrero@intel.com" <gregory.herrero@intel.com>,
	"yousaf.kaukab@intel.com" <yousaf.kaukab@intel.com>,
	"dinguyen@opensource.altera.com" <dinguyen@opensource.altera.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc2: host: Protect PCGCTL with lock in dwc2_port_resume()
Date: Fri, 16 Oct 2015 18:06:01 +0000	[thread overview]
Message-ID: <2B3535C5ECE8B5419E3ECBE30077290901DC39AF5F@US01WEMBX2.internal.synopsys.com> (raw)
In-Reply-To: <1444863507-27463-1-git-send-email-dianders@chromium.org>

On 10/14/2015 3:58 PM, Douglas Anderson wrote:
> From code inspection, it appears to be unsafe to do a read-modify-write
> of PCGCTL in dwc2_port_resume().  Let's make sure the spinlock is held
> around this operation.
> 
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>  drivers/usb/dwc2/hcd.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index af4e4a2..e79baf7 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -1500,6 +1500,8 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
>  	u32 hprt0;
>  	u32 pcgctl;
>  
> +	spin_lock_irqsave(&hsotg->lock, flags);
> +
>  	/*
>  	 * If hibernation is supported, Phy clock is already resumed
>  	 * after registers restore.
> @@ -1508,10 +1510,11 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
>  		pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
>  		pcgctl &= ~PCGCTL_STOPPCLK;
>  		dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
> +		spin_unlock_irqrestore(&hsotg->lock, flags);
>  		usleep_range(20000, 40000);
> +		spin_lock_irqsave(&hsotg->lock, flags);
>  	}
>  
> -	spin_lock_irqsave(&hsotg->lock, flags);
>  	hprt0 = dwc2_read_hprt0(hsotg);
>  	hprt0 |= HPRT0_RES;
>  	hprt0 &= ~HPRT0_SUSP;
> 


Acked-by: John Youn <johnyoun@synopsys.com>


John


      reply	other threads:[~2015-10-16 18:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 22:58 Douglas Anderson
2015-10-16 18:06 ` John Youn [this message]

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=2B3535C5ECE8B5419E3ECBE30077290901DC39AF5F@US01WEMBX2.internal.synopsys.com \
    --to=john.youn@synopsys.com \
    --cc=balbi@ti.com \
    --cc=dianders@chromium.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.herrero@intel.com \
    --cc=heiko@sntech.de \
    --cc=jwerner@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lyz@rock-chips.com \
    --cc=yousaf.kaukab@intel.com \
    /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

all inboxes | Powered by JetHome®