From patchwork Tue Aug 22 09:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9914749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E65F60381 for ; Tue, 22 Aug 2017 10:01:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B9222883F for ; Tue, 22 Aug 2017 10:01:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EAF028854; Tue, 22 Aug 2017 10:01:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0B1F2883F for ; Tue, 22 Aug 2017 10:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932505AbdHVJ5n (ORCPT ); Tue, 22 Aug 2017 05:57:43 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:35145 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932478AbdHVJ5k (ORCPT ); Tue, 22 Aug 2017 05:57:40 -0400 Received: by mail-wr0-f175.google.com with SMTP id k46so45868445wre.2 for ; Tue, 22 Aug 2017 02:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mft8FLB1SCGwE+Kln+RLbf9IETTCJ+gyc45xF5RJN94=; b=P9FMwuYBa80aXW5HFwj25iITKcRkAaf5qDB7BiLnbNE380qt6rxLQSXeaAFYdfEhQI ssODLPK/MVjx7PDrluJmNhF3JdrYlbQ5rZKKzxJv5HbzPmpkrjK2GbUsEAjQbHmOLKmD yxSiI/m7zK4lqhsKq0Ndz25q+6NSQLaakRIxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Mft8FLB1SCGwE+Kln+RLbf9IETTCJ+gyc45xF5RJN94=; b=eO2tNWiTMcN0ZdXqnHr0qXx/1a3GgAbBqPnQxleKo5Ae6ZJLuisN9Z4jrltzsbwWJE mp+01wGfxu6GHFOPHaG/6VZVx870SHWvyuyQrkudx5Oni7TArGu2ELdKRdlDPvj7PFKp BLLd7H3DMokvUjjSngE+M8LR+vy/iAqlUvV70MOcneCwNidVV5OA13KYPJIgxkwOIVDj TZ5pyS4TrtCmja9eYzH/qZNWqEAujkeTl8APW6kbGdKpbWxZOs0MT0JAxd4ea/0I8k+L W7EtKK+ykrQs3VgjgKYxNUAzNKirz6RFp2dAR3lIowxTdQ044dKNuGvwctZM11RQNJxB RMZQ== X-Gm-Message-State: AHYfb5hMLEjCjHbUhBv/ax0ORwAN1V89eUvHtoL1brVIlShPL1iGqN0c dPbyO9+C5PzEdjvm X-Received: by 10.28.62.200 with SMTP id l191mr57850wma.57.1503395858792; Tue, 22 Aug 2017 02:57:38 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id e137sm12257913wma.29.2017.08.22.02.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 02:57:38 -0700 (PDT) From: Anup Patel To: Vinod Koul , Dan Williams Cc: Florian Fainelli , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Anup Patel Subject: [PATCH v3 02/17] dmaengine: bcm-sba-raid: Reduce locking context in sba_alloc_request() Date: Tue, 22 Aug 2017 15:26:51 +0530 Message-Id: <1503395827-19428-3-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> References: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We don't require to hold "sba->reqs_lock" for long-time in sba_alloc_request() because lock protection is not required when initializing members of "struct sba_request". Signed-off-by: Anup Patel --- drivers/dma/bcm-sba-raid.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index 76999b7..f81d5ac 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -207,24 +207,24 @@ static struct sba_request *sba_alloc_request(struct sba_device *sba) struct sba_request *req = NULL; spin_lock_irqsave(&sba->reqs_lock, flags); - req = list_first_entry_or_null(&sba->reqs_free_list, struct sba_request, node); if (req) { list_move_tail(&req->node, &sba->reqs_alloc_list); - req->state = SBA_REQUEST_STATE_ALLOCED; - req->fence = false; - req->first = req; - INIT_LIST_HEAD(&req->next); - req->next_count = 1; - atomic_set(&req->next_pending_count, 1); - sba->reqs_free_count--; - - dma_async_tx_descriptor_init(&req->tx, &sba->dma_chan); } - spin_unlock_irqrestore(&sba->reqs_lock, flags); + if (!req) + return NULL; + + req->state = SBA_REQUEST_STATE_ALLOCED; + req->fence = false; + req->first = req; + INIT_LIST_HEAD(&req->next); + req->next_count = 1; + atomic_set(&req->next_pending_count, 1); + + dma_async_tx_descriptor_init(&req->tx, &sba->dma_chan); return req; }