Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1274470
| Path | csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod |
|---|---|
| From | John Youn <John.Youn@synopsys.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v5 1/2] usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func() |
| Date | Fri, 20 Nov 2015 23:50:01 +0100 |
| Message-ID | <qx2Fb-53P-17@gated-at.bofh.it> (permalink) |
| References | <qwXm9-1Fh-15@gated-at.bofh.it> |
| X-Original-To | Douglas Anderson <dianders@chromium.org>, John Youn <John.Youn@synopsys.com>, "balbi@ti.com" <balbi@ti.com> |
| Thread-Topic | [PATCH v5 1/2] usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func() |
| Thread-Index | AQHRI7XS5Lfp+NL0sEWMKh8kMNeYmg== |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-Originating-IP | [10.10.161.90] |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7BIT |
| MIME-Version | 1.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 58 |
| Organization | linux.* mail to news gateway |
| X-Original-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> |
| X-Original-Date | Fri, 20 Nov 2015 22:44:08 +0000 |
| X-Original-Message-ID | <2B3535C5ECE8B5419E3ECBE30077290901DC3DAFB7@US01WEMBX2.internal.synopsys.com> |
| X-Original-References | <1448039188-14296-1-git-send-email-dianders@chromium.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1274470 |
Show key headers only | View raw
On 11/20/2015 9:06 AM, Douglas Anderson wrote:
> The dwc2_hcd_reset_func() function is only ever called directly by a
> delayed work function. As such no locks are already held when the
> function is called.
>
> Doing a read-modify-write of CPU registers and setting fields in the
> main hsotg data structure is a bad idea without locks. Let's add
> locks.
>
> The bug was found by code inspection only. It turns out that the
> dwc2_hcd_reset_func() is only ever called today if the
> "host_support_fs_ls_low_power" parameter is enabled and no code in
> mainline enables that parameter. Thus no known issues in mainline are
> fixed by this patch, but it's still probably wise to fix the function.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> Changes in v5:
> - New for v5 of the series
>
> drivers/usb/dwc2/hcd.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index 42b6c5127618..e8924cecc83a 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -2357,13 +2357,19 @@ static void dwc2_hcd_reset_func(struct work_struct *work)
> {
> struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
> reset_work.work);
> + unsigned long flags;
> u32 hprt0;
>
> dev_dbg(hsotg->dev, "USB RESET function called\n");
> +
> + spin_lock_irqsave(&hsotg->lock, flags);
> +
> hprt0 = dwc2_read_hprt0(hsotg);
> hprt0 &= ~HPRT0_RST;
> dwc2_writel(hprt0, hsotg->regs + HPRT0);
> hsotg->flags.b.port_reset_change = 1;
> +
> + spin_unlock_irqrestore(&hsotg->lock, flags);
> }
>
> /*
>
Acked-by: John Youn <johnyoun@synopsys.com>
John
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v5 1/2] usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func() Douglas Anderson <dianders@chromium.org> - 2015-11-20 18:10 +0100
[PATCH v5 2/2] usb: dwc2: host: Clear interrupts before handling them Douglas Anderson <dianders@chromium.org> - 2015-11-20 18:10 +0100
Re: [PATCH v5 2/2] usb: dwc2: host: Clear interrupts before handling them John Youn <John.Youn@synopsys.com> - 2015-11-20 23:50 +0100
Re: [PATCH v5 1/2] usb: dwc2: host: Add missing spinlock in dwc2_hcd_reset_func() John Youn <John.Youn@synopsys.com> - 2015-11-20 23:50 +0100
csiph-web