From patchwork Wed Jul 26 05:36:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9864201 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 91BCF6038C for ; Wed, 26 Jul 2017 05:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8998E28554 for ; Wed, 26 Jul 2017 05:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B1E32866A; Wed, 26 Jul 2017 05:38:56 +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 22DA928554 for ; Wed, 26 Jul 2017 05:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751413AbdGZFhp (ORCPT ); Wed, 26 Jul 2017 01:37:45 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:38430 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbdGZFhn (ORCPT ); Wed, 26 Jul 2017 01:37:43 -0400 Received: by mail-wm0-f49.google.com with SMTP id m85so57818569wma.1 for ; Tue, 25 Jul 2017 22:37:42 -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=vjLNb62Cnh9eJR3eBWcXJTxcKGR6Qg7IuUA1XOL0ySA=; b=RAPBAYWpXWlciR0qR31OXP3QnDbxQ0iqL1LDJutqZFdGQQ6E1rVf4Q4+f5vdouib0A GLzZT/4ZwoGC8JJ6+VQ3tlu37n2HT2L8ocltDPYFWeXvNZV2PR+hmQRm5FkYdqcXrUox kGcHJvF7zMUJ/2wt2S7AGaBEmO+ViOkEsARRs= 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=vjLNb62Cnh9eJR3eBWcXJTxcKGR6Qg7IuUA1XOL0ySA=; b=ktNnX2Hu7cQK8kB2MKzhME4sHJbznp30gHusFTi+XP+5uiLHy1y9GyxDv40g+eTIX/ vDhwonemTUFgu4FZZiM8zvBYPuczqqVxvF8VTk+EydjS4K1v+11l3fz9VaAYDQBLc7Oo hSVpkJsKCouQyJDC1TLZlPKfrDVSDDtXvvK1EiCakoqPXSQtSN+kO3xlYx8wcgIdWATY Cxwr4DbQgnqmvb/NYT5SDMhiruUtN7XiChimEOqjlqLapQ/wWICqPsDTMWtkH2defgvR scQ9fmCZFsgnTLVbBqLnlOVC9P+sL4Z/aUc881U54yiBx+usLR1/x+FTczOlvD5/cgvc dOrQ== X-Gm-Message-State: AIVw110g8pkWLamv+c72hqrvyExD+podsIRuX9WCrh4UiYISY1YIySNS uhY2Be6wB6EGuseX X-Received: by 10.28.140.67 with SMTP id o64mr10085482wmd.68.1501047461663; Tue, 25 Jul 2017 22:37:41 -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 34sm17417595wrt.36.2017.07.25.22.37.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 22:37:41 -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 2/6] dma: bcm-sba-raid: Peek mbox when we are left with no free requests Date: Wed, 26 Jul 2017 11:06:40 +0530 Message-Id: <1501047404-14456-3-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501047404-14456-1-git-send-email-anup.patel@broadcom.com> References: <1501047404-14456-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 should peek mbox channels when we are left with no free sba_requests in sba_alloc_request() 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 6d15fed..321420b 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -199,6 +199,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; @@ -210,8 +218,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; @@ -558,17 +575,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); }