From patchwork Tue Aug 1 10:37:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9874189 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 6212A60365 for ; Tue, 1 Aug 2017 10:43:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FE892868B for ; Tue, 1 Aug 2017 10:43:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64F09286A4; Tue, 1 Aug 2017 10:43:08 +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 162412868B for ; Tue, 1 Aug 2017 10:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbdHAKig (ORCPT ); Tue, 1 Aug 2017 06:38:36 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:36055 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751999AbdHAKic (ORCPT ); Tue, 1 Aug 2017 06:38:32 -0400 Received: by mail-qk0-f174.google.com with SMTP id d136so6447427qkg.3 for ; Tue, 01 Aug 2017 03:38:31 -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=arEQmB0unvNUfwCBp5i5uhxu6t8OL8AlQ9uPcYvqOzxtKPJ+dZmr0pkBkBGcGwBIB1 zbTUljmDGJlXg7PRKqeKqIQIaMBgZ2lskfJ1Dw6c5WcLmvehDaOP12RiEQO93Z4X32vG 2mZmiRytzE/7UaTBkJjRIPhAJ/dM0XIIyQ7Io= 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=ebHESwOmS8aT+Xzqf5N0TufuTdebkvZCO/0tZkM+h4+gl+qFAnvQ1+KbldET3FEOd9 CWaFa5p3z3U4XDARoChr4qfHH2oXtJwiNEPB/n5eJHpXnxlNP46z82ODTqoCoinM1qjz 9yIYakDO8Zvk8w/L/tOpjlWGYufHALMrBSeSCEiBPy06wb5/RsIcoTrZ6hXaablcQb3Y Wj7/YUp2rmkqvRlXbDyPrO3pRgF7fePPxqODNjM63DqWquccepqXD8t6V62OjsYPLOdV 7v3UypTVRXwn3UxUTDOhY9uqXd1jRiSpYlbNeejD76ReoUrNhIdItVD/t7ihafu7N4+c 4OqQ== X-Gm-Message-State: AIVw112cKN+gGvKrVamCGaWRLnjaXYiqbqiYPrw1mScQX8B+2DEYbYB7 07ivdDRb1YPoBfiM X-Received: by 10.55.58.71 with SMTP id h68mr25388489qka.169.1501583911388; Tue, 01 Aug 2017 03:38:31 -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 e32sm21784162qtb.63.2017.08.01.03.38.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Aug 2017 03:38:30 -0700 (PDT) From: Anup Patel To: Rob Herring , Mark Rutland , Vinod Koul , Dan Williams Cc: Florian Fainelli , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dmaengine@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Anup Patel Subject: [PATCH v2 02/16] dmaengine: bcm-sba-raid: Reduce locking context in sba_alloc_request() Date: Tue, 1 Aug 2017 16:07:46 +0530 Message-Id: <1501583880-32072-3-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501583880-32072-1-git-send-email-anup.patel@broadcom.com> References: <1501583880-32072-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; }