From patchwork Tue Aug 1 10:37:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9874173 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 E5E7760365 for ; Tue, 1 Aug 2017 10:42:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F01DF28643 for ; Tue, 1 Aug 2017 10:42:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4E63286A0; Tue, 1 Aug 2017 10:42:06 +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 6C78C28643 for ; Tue, 1 Aug 2017 10:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751937AbdHAKk2 (ORCPT ); Tue, 1 Aug 2017 06:40:28 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:33539 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbdHAKkZ (ORCPT ); Tue, 1 Aug 2017 06:40:25 -0400 Received: by mail-qk0-f174.google.com with SMTP id a77so6510037qkb.0 for ; Tue, 01 Aug 2017 03:40:25 -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=Y0y9jpzw58PpVyosE0WDt5A96VyjFpw7XjwMzVTOsErRIakd4uSZGWgOqx89O4pNij SpaUS7U7uLzwahecYHqoZzLTu+JnrMG5nDhgw8ENc8BsKEqxzzJnxgXgjJcEvpMnQTqv K6XRuqbeZ2stKBG7cj9S31VkcidJdZzholVts= 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=mbc939y1v+kLwW0CfZm8WqW7bGu5EpVOZcQn0M/qSUPNxqr84x7vzlXq+EVUzcwxvM Kndc+BLz047Yrf8V9NV4SQal5v9pat6Ya6xJtL42XnStM1hiUSuibJWQnQ1Vj8u0cvp9 2oFcRLe4K9218xirMzpdF3Ci5v37/c80GzBMGE7PUOezVlpkHPvaB/0xfcWs3jJfRK82 znpwSGSZFJv70KhIhnTDFGaVQBt/5NP1ZffupIzfePTWrxsoaFudYPJAEJDk7H6Gd5oj ZftM8WSF9lSs7hBzvb61nvJWIA0/nGLNqdH4lI+NRfvuQZ5i4fuw1RfZdwaEmSH73P8V +IYA== X-Gm-Message-State: AIVw110lMFttCgJ+BCrg2NhKnHHHfwo+xl57TsK/Ye4MLKOtwM7/MLlF QphKYLwIa1h2Tell X-Received: by 10.55.11.211 with SMTP id 202mr23287520qkl.305.1501584024504; Tue, 01 Aug 2017 03:40:24 -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.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Aug 2017 03:40:24 -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 11/16] dmaengine: bcm-sba-raid: Peek mbox when we have no free requests Date: Tue, 1 Aug 2017 16:07:55 +0530 Message-Id: <1501583880-32072-12-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 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); }