From patchwork Fri Aug 22 11:14:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4763141 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9FD0C9F2E8 for ; Fri, 22 Aug 2014 11:14:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C08A520172 for ; Fri, 22 Aug 2014 11:14:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAE8220136 for ; Fri, 22 Aug 2014 11:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755967AbaHVLOJ (ORCPT ); Fri, 22 Aug 2014 07:14:09 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:18263 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753229AbaHVLOI (ORCPT ); Fri, 22 Aug 2014 07:14:08 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 22 Aug 2014 20:14:06 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id B7CFA4BECC; Fri, 22 Aug 2014 20:14:06 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id B4CBB180A1; Fri, 22 Aug 2014 20:14:06 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id A88B6180A0; Fri, 22 Aug 2014 20:14:06 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id WAK32736; Fri, 22 Aug 2014 20:14:06 +0900 X-IronPort-AV: E=Sophos;i="5.04,379,1406559600"; d="scan'208";a="168408697" Received: from mail-hk1lp0124.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.124]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 22 Aug 2014 20:14:06 +0900 Received: from [10.161.20.147] (211.11.155.147) by SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) with Microsoft SMTP Server (TLS) id 15.0.1010.18; Fri, 22 Aug 2014 11:14:04 +0000 Message-ID: <53F725F8.1040601@renesas.com> Date: Fri, 22 Aug 2014 20:14:00 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "linux-usb@vger.kernel.org" , Felipe Balbi CC: SH-Linux , Greg Kroah-Hartman , Kuninori Morimoto Subject: [PATCH 2/4] usb: renesas_usbhs: protect mod->irq_{bemp, brdy}sts by spin lock X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR02CA0027.apcprd02.prod.outlook.com (25.161.48.12) To SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019008)(6009001)(6049001)(189002)(199003)(79102001)(95666004)(106356001)(76482001)(64126003)(23756003)(20776003)(80316001)(19580405001)(551934003)(229853001)(64706001)(36756003)(46102001)(47776003)(77982001)(105586002)(107046002)(81342001)(92566001)(66066001)(74662001)(85852003)(83072002)(21056001)(81542001)(85306004)(31966008)(87976001)(77096002)(54356999)(74502001)(92726001)(101416001)(83322001)(65956001)(4396001)(102836001)(19580395003)(86362001)(83506001)(33656002)(50466002)(50986999)(65816999)(99396002)(87266999)(59896002)(80022001)(42186005)(90102001)(142933001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB333; H:[10.161.20.147]; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; LANG:en; 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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch protects the mod->irq_bempsts and mod->irq_brdysts by spin lock in the usbhs_status_get_each_irq() because other functions will write them during spin lock. Otherwise, the driver will clears the BRDYSTS and/or BEMPSTS wrongly, and then, the transaction will not finish. Also since the driver should use the INTSTS0 and BRDYSTS and BEMPSTS as the same timing, the patch protects them. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/mod.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 6a030b9..9a705b1 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c @@ -213,7 +213,10 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv, { struct usbhs_mod *mod = usbhs_mod_get_current(priv); u16 intenb0, intenb1; + unsigned long flags; + /******************** spin lock ********************/ + usbhs_lock(priv, flags); state->intsts0 = usbhs_read(priv, INTSTS0); state->intsts1 = usbhs_read(priv, INTSTS1); @@ -229,6 +232,8 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv, state->bempsts &= mod->irq_bempsts; state->brdysts &= mod->irq_brdysts; } + usbhs_unlock(priv, flags); + /******************** spin unlock ******************/ /* * Check whether the irq enable registers and the irq status are set