From patchwork Mon Feb 16 01:52:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5830991 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1D0349F373 for ; Mon, 16 Feb 2015 01:53:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C74820219 for ; Mon, 16 Feb 2015 01:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67BDF201FB for ; Mon, 16 Feb 2015 01:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754490AbbBPBxN (ORCPT ); Sun, 15 Feb 2015 20:53:13 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:51790 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751476AbbBPBxL (ORCPT ); Sun, 15 Feb 2015 20:53:11 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 16 Feb 2015 10:53:10 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 12C7E46AD6; Mon, 16 Feb 2015 10:53:10 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id EC11518070; Mon, 16 Feb 2015 10:53:09 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id E7F7F1800A; Mon, 16 Feb 2015 10:53:09 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id LAR28500; Mon, 16 Feb 2015 10:53:09 +0900 X-IronPort-AV: E=Sophos;i="5.09,584,1418050800"; d="scan'208";a="179891081" Received: from mail-hk1lp0126.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.126]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 16 Feb 2015 10:53:09 +0900 Received: from HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) by HKNPR06MB004.apcprd06.prod.outlook.com (10.242.119.154) with Microsoft SMTP Server (TLS) id 15.1.87.18; Mon, 16 Feb 2015 01:53:08 +0000 Received: from localhost (211.11.155.147) by HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) with Microsoft SMTP Server (TLS) id 15.1.87.18; Mon, 16 Feb 2015 01:53:06 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , , Yoshihiro Shimoda Subject: [PATCH v2 1/4] usb: renesas_usbhs: fix spinlock suspected in a gadget complete function Date: Mon, 16 Feb 2015 10:52:56 +0900 Message-ID: <1424051579-5060-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1424051579-5060-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1424051579-5060-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR03CA0049.apcprd03.prod.outlook.com (10.141.129.39) To HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) Authentication-Results: linuxfoundation.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB323; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:HKNPR06MB323; X-Forefront-PRVS: 0489CFBAC9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(76506005)(77156002)(50226001)(78352002)(92566002)(77096005)(46102003)(42186005)(33646002)(42382002)(62966003)(40100003)(36756003)(2950100001)(87976001)(47776003)(19580395003)(50986999)(76176999)(66066001)(229853001)(19580405001)(48376002)(122386002)(50466002); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB323; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB323; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2015 01:53:06.5704 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKNPR06MB323 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB004; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the gadget.h, a "complete" function will always be called with interrupts disabled. However, sometimes usbhsg_queue_pop() function is called with interrupts enabled. So, this function should calls local_irq_save() before this calls the usb_gadget_giveback_request(). Otherwise, there is possible to cause a spinlock suspected in a gadget complete function. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/mod_gadget.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index e0384af..104bddf 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -126,11 +126,22 @@ static void usbhsg_queue_pop(struct usbhsg_uep *uep, struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); struct device *dev = usbhsg_gpriv_to_dev(gpriv); + unsigned long flags; dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe)); ureq->req.status = status; + /* + * According to the gadget.h, a "complete" function will always be + * called with interrupts disabled. However, sometimes this function + * is called with interrupts enabled. (e.g. complete a DMAC transfer or + * write data and done is set immediately when PIO.) So, this function + * should calls local_irq_save() before this calls the + * usb_gadget_giveback_request(). + */ + local_irq_save(flags); usb_gadget_giveback_request(&uep->ep, &ureq->req); + local_irq_restore(flags); } static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)