From patchwork Tue Aug 22 09:57:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9914729 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 028D760381 for ; Tue, 22 Aug 2017 10:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 123082883F for ; Tue, 22 Aug 2017 10:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06F9928854; Tue, 22 Aug 2017 10:00:21 +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=unavailable 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 871B12883F for ; Tue, 22 Aug 2017 10:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932647AbdHVJ6m (ORCPT ); Tue, 22 Aug 2017 05:58:42 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:36784 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932646AbdHVJ6k (ORCPT ); Tue, 22 Aug 2017 05:58:40 -0400 Received: by mail-wr0-f180.google.com with SMTP id f8so84459238wrf.3 for ; Tue, 22 Aug 2017 02:58: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=Y0/JGs+wSDca0AzPTVCPwmKocIHR5msiQUhNUQeEmm8=; b=FHw4agmWlLP+FdvVFoHJOEs+ZnyJuxsTUJO8cPfowfc/DoKh0EPCoNsBFmWB9pmXHT aIH+7gknRIOUgAICG8BZVSWGHVo13tWG+RbNmVfUVNmwFy1/6H4Ao3QTTPt+nGW2Y8CT MxQFoNxnas36TwyxUpGfp8bJMZAD6oCGR7RAc= 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=Y0/JGs+wSDca0AzPTVCPwmKocIHR5msiQUhNUQeEmm8=; b=pZN4b0mqV34ITV1Aqov/V/jh1yH2nye0mqNNawWAhFIh6O8G798Ez73vFIUkAFUU+J kCcxBBmjFSmmNyEDupx06UxbITvMp1U63DWmj2oe9h/NCI+BZe1y354PEDiYkcub7Y1R VTV674geJKgghqCpjfmXFzrUjVqijwcuolS7SFtSIUns24AyMNyRE54NBF6dvOFTEs88 RosSD4PFoqtLBXQhudgvSC3HjJauZ/ySLPTcXav/WdBwkpb0WFXIPNDtd4wzxlU6LaPk +tqofPvJ++On5VDOSh1DsgjC3CltfzDXzYq/nsvlWHKMwAQqJYyrBd/ZMOQYCOj2GY40 1sDQ== X-Gm-Message-State: AHYfb5iTcPbznMrNlXdZV749EoR2mtKPIGMCwXq9/YUPCQmD45TDCMJE XFXvU6I1DVAKE1pY X-Received: by 10.28.30.77 with SMTP id e74mr27601wme.172.1503395918742; Tue, 22 Aug 2017 02:58: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.58.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 02:58: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 11/17] dmaengine: bcm-sba-raid: Peek mbox when we have no free requests Date: Tue, 22 Aug 2017 15:27:00 +0530 Message-Id: <1503395827-19428-12-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 When setting up RAID array on several NVMe disks we observed that sba_alloc_request() start failing (due to no free requests left) and RAID array setup becomes very slow. To improve performance, we do mbox channel peek when we have no free requests. This improves performance of RAID array setup because mbox requests that were completed but not processed by mbox completion worker will be processed immediately by mbox channel peek. Signed-off-by: Anup Patel Reviewed-by: Ray Jui Reviewed-by: Scott Branden --- drivers/dma/bcm-sba-raid.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index f14ed0a..399250e 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -200,6 +200,14 @@ static inline u32 __pure sba_cmd_pq_c_mdata(u32 d, u32 b1, u32 b0) /* ====== General helper routines ===== */ +static void sba_peek_mchans(struct sba_device *sba) +{ + int mchan_idx; + + for (mchan_idx = 0; mchan_idx < sba->mchans_count; mchan_idx++) + mbox_client_peek_data(sba->mchans[mchan_idx]); +} + static struct sba_request *sba_alloc_request(struct sba_device *sba) { unsigned long flags; @@ -211,8 +219,17 @@ static struct sba_request *sba_alloc_request(struct sba_device *sba) if (req) list_move_tail(&req->node, &sba->reqs_alloc_list); spin_unlock_irqrestore(&sba->reqs_lock, flags); - if (!req) + + if (!req) { + /* + * We have no more free requests so, we peek + * mailbox channels hoping few active requests + * would have completed which will create more + * room for new requests. + */ + sba_peek_mchans(sba); return NULL; + } req->flags = SBA_REQUEST_STATE_ALLOCED; req->first = req; @@ -560,17 +577,15 @@ static enum dma_status sba_tx_status(struct dma_chan *dchan, dma_cookie_t cookie, struct dma_tx_state *txstate) { - int mchan_idx; enum dma_status ret; struct sba_device *sba = to_sba_device(dchan); - for (mchan_idx = 0; mchan_idx < sba->mchans_count; mchan_idx++) - mbox_client_peek_data(sba->mchans[mchan_idx]); - ret = dma_cookie_status(dchan, cookie, txstate); if (ret == DMA_COMPLETE) return ret; + sba_peek_mchans(sba); + return dma_cookie_status(dchan, cookie, txstate); }