From patchwork Mon Jul 14 07:20:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuelin Shi X-Patchwork-Id: 4543281 X-Patchwork-Delegate: dan.j.williams@gmail.com Return-Path: X-Original-To: patchwork-dmaengine@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 EEAED9F295 for ; Mon, 14 Jul 2014 08:06:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24DB02015E for ; Mon, 14 Jul 2014 08:06:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B62320158 for ; Mon, 14 Jul 2014 08:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbaGNIGr (ORCPT ); Mon, 14 Jul 2014 04:06:47 -0400 Received: from mail-bn1blp0184.outbound.protection.outlook.com ([207.46.163.184]:31705 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752574AbaGNIGq (ORCPT ); Mon, 14 Jul 2014 04:06:46 -0400 Received: from BY2PR03CA038.namprd03.prod.outlook.com (10.141.249.11) by BL2PR03MB148.namprd03.prod.outlook.com (10.255.230.27) with Microsoft SMTP Server (TLS) id 15.0.985.8; Mon, 14 Jul 2014 08:06:42 +0000 Received: from BN1AFFO11FD006.protection.gbl (2a01:111:f400:7c10::191) by BY2PR03CA038.outlook.office365.com (2a01:111:e400:2c5d::11) with Microsoft SMTP Server (TLS) id 15.0.985.8 via Frontend Transport; Mon, 14 Jul 2014 08:06:41 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD006.mail.protection.outlook.com (10.58.52.66) with Microsoft SMTP Server (TLS) id 15.0.980.11 via Frontend Transport; Mon, 14 Jul 2014 08:06:41 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s6E86Zf8027647; Mon, 14 Jul 2014 01:06:39 -0700 From: To: , CC: , , Xuelin Shi , Xuelin Shi Subject: [PATCH] dmaengine: fix potential race condition in fsl raid Date: Mon, 14 Jul 2014 15:20:28 +0800 Message-ID: <1405322428-20461-1-git-send-email-xuelin.shi@freescale.com> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(199002)(189002)(4396001)(50226001)(107046002)(229853001)(86362001)(93916002)(104166001)(83322001)(76482001)(99396002)(87936001)(104016003)(64706001)(85852003)(47776003)(20776003)(83072002)(19580405001)(26826002)(88136002)(97736001)(68736004)(31966008)(36756003)(6806004)(69596002)(19580395003)(44976005)(92726001)(74662001)(102836001)(74502001)(50986999)(86152002)(92566001)(21056001)(89996001)(87286001)(85306003)(46102001)(76506005)(79102001)(77156001)(50466002)(95666004)(57986006)(81156004)(84676001)(77982001)(33646001)(105606002)(81542001)(106466001)(80022001)(62966002)(48376002)(81342001); DIR:OUT; SFP:; SCL:1; SRVR:BL2PR03MB148; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 02723F29C4 Received-SPF: Fail (: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=xuelin.shi@freescale.com; X-OriginatorOrg: freescale.com Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 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 From: Xuelin Shi checking available slots in HW should be under the lock. Signed-off-by: Xuelin Shi --- drivers/dma/fsl_raid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c index 935d05a..fccad86 100644 --- a/drivers/dma/fsl_raid.c +++ b/drivers/dma/fsl_raid.c @@ -112,11 +112,11 @@ static void re_jr_issue_pending(struct dma_chan *chan) jr = container_of(chan, struct re_jr, chan); + spin_lock_irqsave(&jr->desc_lock, flags); avail = RE_JR_INB_SLOT_AVAIL(in_be32(&jr->jrregs->inbring_slot_avail)); if (!avail) - return; + goto out; - spin_lock_irqsave(&jr->desc_lock, flags); list_for_each_entry_safe(desc, _desc, &jr->submit_q, node) { if (!avail) break; @@ -132,6 +132,7 @@ static void re_jr_issue_pending(struct dma_chan *chan) out_be32(&jr->jrregs->inbring_add_job, RE_JR_INB_JOB_ADD(1)); avail--; } +out: spin_unlock_irqrestore(&jr->desc_lock, flags); }