From patchwork Tue Aug 22 09:57:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9914769 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 05054603F9 for ; Tue, 22 Aug 2017 10:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05EEC287DC for ; Tue, 22 Aug 2017 10:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED4D22885C; Tue, 22 Aug 2017 10:15:58 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 588DF287DC for ; Tue, 22 Aug 2017 10:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YuSrKcggNa6CPfZbozx6P9BkZLapSVkJlCEbSqyILqQ=; b=se3fUrIldBtJ0mOkkEGq6Mxbcz 68jel+V7JW8radjv40qCstz9Fh/PxOtnYHd4xQ+J9tacaZFC80VxiISQvyGxq9+v9XTV6M0xECenl ZQQLkzfgDHf7oqDjbnH7GxdF4hg9K4zdZq2L197obfDxhyQAqYYpa0omXykUOoLARF4Gh0h92AR00 jgmGjyMn/ZM0FKfUZ1EwDZKJShoyXJPnQCohVl39LIqWDnSvR5AyQ31b2qVBbpUWTZQ0ZSXtx4OiC hOzeOmY/ENW+F0VbF8vFqNWU6ov1n7jde8HcRBavz6QmDz5anlmQCqLATwA6qsnzXje3xH9fFpjk1 yx2mw2Zg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dk6Dz-0004o2-07; Tue, 22 Aug 2017 10:15:55 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk6DG-0002yD-BY for linux-arm-kernel@bombadil.infradead.org; Tue, 22 Aug 2017 10:15:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LHcvQCygsBqQ7QzH1qK7YFlydPPVzJODhfzE1WvoFQ8=; b=G7wzAKAXjzmqJAVFwxRl6loIu p9iiDQg9fHtAG4q6ueyGrbdYJfZSJq5MCpvmLy+3QZGgpflZ4XLWpqTMmhl0B76wHxEFnscHtxFxA PSADj4czLDI/7hbK3fmbXSjXANyoe4sXKk0eWf6LsLWe2q/EwVxUW86t4oRdQK4A/nlh1obRodDmx M6JfVLoxGzCwOmcxUno68jPfZPhRdUgPdxzv5sGjUTDPsAhVY/8KUVkSQsibdeBEDdlEY2xjyfWFu g3zxx15tRteY6gKue2X6DZTtYzfEXtQvOT/13Hna4DBr1gIK7pgfch/BO/YppRuDyMVToq/VxX7sm fuUVr2VIw==; Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk5yG-0001td-Ai for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2017 09:59:42 +0000 Received: by mail-wr0-x22c.google.com with SMTP id p14so52018161wrg.1 for ; Tue, 22 Aug 2017 02:59:20 -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=LHcvQCygsBqQ7QzH1qK7YFlydPPVzJODhfzE1WvoFQ8=; b=ajr9lKEWFCLYGf7rKe99F0BWPMrhCyPG8D3aqkDe1Kd3XCcm1VAIeifyg6K8QuoNhF 8GjklKqQU0u07iB/23utdFCb1RnCNcB62PeVG7eiZR5iqjiRJPoATzWM4gE5mTkuCMEu x/R90rKjLuCN6np9tJTnKhYIQgtkOAFjeBiTY= 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=LHcvQCygsBqQ7QzH1qK7YFlydPPVzJODhfzE1WvoFQ8=; b=XOdOgrzjmq9y6L1eK0epej+lkcByVi6Jmps+nWIwV4LWAOS+WjKnPfJDQlV1+EuWhC Pkv6jIMTmK0A37l7I3gYzSZIFQTYwI8W77xZ+tqX9BYGo+j+7wqiSX9KQhQABZWn1Uux tMuNOu0a0PpMxejAef1xE3lvsmbQmzkMXOISW4MlSqa7aKXuR8UQeDKjsmY4/gPrvHc6 WBs033hMEEzAVG6td5oIWRNP8kMgEw9Xb1erNGTu/OQxRKPGu788poAtSPFldSMeoKld Wv653XZL5+Q67p9x3vnDxD+ZbPr1AG6A7vZLoKSHlBpS6S10hEg+vockbxcxiolp4Hqx JmEA== X-Gm-Message-State: AHYfb5jzZE6LkIWKflW4VXGg+Di5grzA1/ZBUEXNUclMJ9Mff49Z356a U0fzAt1BaYTIbhcv X-Received: by 10.28.218.75 with SMTP id r72mr64535wmg.172.1503395958927; Tue, 22 Aug 2017 02:59:18 -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.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 02:59:18 -0700 (PDT) From: Anup Patel To: Vinod Koul , Dan Williams Subject: [PATCH v3 17/17] dmaengine: bcm-sba-raid: Remove redundant SBA_REQUEST_STATE_COMPLETED Date: Tue, 22 Aug 2017 15:27:06 +0530 Message-Id: <1503395827-19428-18-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_105940_412660_FD418059 X-CRM114-Status: GOOD ( 17.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Anup Patel , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The SBA_REQUEST_STATE_COMPLETED state was added to keep track of sba_request which got completed but cannot be freed because underlying Async Tx descriptor was not ACKed by DMA client. Instead of above, we can free the sba_request with non-ACKed Async Tx descriptor and sba_alloc_request() will ensure that it always allocates sba_request with ACKed Async Tx descriptor. This alternate approach makes SBA_REQUEST_STATE_COMPLETED state redundant hence this patch removes it. Signed-off-by: Anup Patel Reviewed-by: Ray Jui Reviewed-by: Scott Branden --- drivers/dma/bcm-sba-raid.c | 63 +++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index 0c41136..5b1595f 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -99,8 +99,7 @@ enum sba_request_flags { SBA_REQUEST_STATE_ALLOCED = 0x002, SBA_REQUEST_STATE_PENDING = 0x004, SBA_REQUEST_STATE_ACTIVE = 0x008, - SBA_REQUEST_STATE_COMPLETED = 0x010, - SBA_REQUEST_STATE_ABORTED = 0x020, + SBA_REQUEST_STATE_ABORTED = 0x010, SBA_REQUEST_STATE_MASK = 0x0ff, SBA_REQUEST_FENCE = 0x100, }; @@ -160,7 +159,6 @@ struct sba_device { struct list_head reqs_alloc_list; struct list_head reqs_pending_list; struct list_head reqs_active_list; - struct list_head reqs_completed_list; struct list_head reqs_aborted_list; struct list_head reqs_free_list; /* DebugFS directory entries */ @@ -212,17 +210,21 @@ static void sba_peek_mchans(struct sba_device *sba) static struct sba_request *sba_alloc_request(struct sba_device *sba) { + bool found = false; unsigned long flags; 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); + list_for_each_entry(req, &sba->reqs_free_list, node) { + if (async_tx_test_ack(&req->tx)) { + list_move_tail(&req->node, &sba->reqs_alloc_list); + found = true; + break; + } + } spin_unlock_irqrestore(&sba->reqs_lock, flags); - if (!req) { + if (!found) { /* * We have no more free requests so, we peek * mailbox channels hoping few active requests @@ -297,18 +299,6 @@ static void _sba_free_request(struct sba_device *sba, sba->reqs_fence = false; } -/* Note: Must be called with sba->reqs_lock held */ -static void _sba_complete_request(struct sba_device *sba, - struct sba_request *req) -{ - lockdep_assert_held(&sba->reqs_lock); - req->flags &= ~SBA_REQUEST_STATE_MASK; - req->flags |= SBA_REQUEST_STATE_COMPLETED; - list_move_tail(&req->node, &sba->reqs_completed_list); - if (list_empty(&sba->reqs_active_list)) - sba->reqs_fence = false; -} - static void sba_free_chained_requests(struct sba_request *req) { unsigned long flags; @@ -350,10 +340,6 @@ static void sba_cleanup_nonpending_requests(struct sba_device *sba) list_for_each_entry_safe(req, req1, &sba->reqs_alloc_list, node) _sba_free_request(sba, req); - /* Freeup all completed request */ - list_for_each_entry_safe(req, req1, &sba->reqs_completed_list, node) - _sba_free_request(sba, req); - /* Set all active requests as aborted */ list_for_each_entry_safe(req, req1, &sba->reqs_active_list, node) _sba_abort_request(sba, req); @@ -472,20 +458,8 @@ static void sba_process_received_request(struct sba_device *sba, _sba_free_request(sba, nreq); INIT_LIST_HEAD(&first->next); - /* The client is allowed to attach dependent operations - * until 'ack' is set - */ - if (!async_tx_test_ack(tx)) - _sba_complete_request(sba, first); - else - _sba_free_request(sba, first); - - /* Cleanup completed requests */ - list_for_each_entry_safe(req, nreq, - &sba->reqs_completed_list, node) { - if (async_tx_test_ack(&req->tx)) - _sba_free_request(sba, req); - } + /* Free the first request */ + _sba_free_request(sba, first); /* Process pending requests */ _sba_process_pending_requests(sba); @@ -499,13 +473,14 @@ static void sba_write_stats_in_seqfile(struct sba_device *sba, { unsigned long flags; struct sba_request *req; - u32 free_count = 0, alloced_count = 0, pending_count = 0; - u32 active_count = 0, aborted_count = 0, completed_count = 0; + u32 free_count = 0, alloced_count = 0; + u32 pending_count = 0, active_count = 0, aborted_count = 0; spin_lock_irqsave(&sba->reqs_lock, flags); list_for_each_entry(req, &sba->reqs_free_list, node) - free_count++; + if (async_tx_test_ack(&req->tx)) + free_count++; list_for_each_entry(req, &sba->reqs_alloc_list, node) alloced_count++; @@ -519,9 +494,6 @@ static void sba_write_stats_in_seqfile(struct sba_device *sba, list_for_each_entry(req, &sba->reqs_aborted_list, node) aborted_count++; - list_for_each_entry(req, &sba->reqs_completed_list, node) - completed_count++; - spin_unlock_irqrestore(&sba->reqs_lock, flags); seq_printf(file, "maximum requests = %d\n", sba->max_req); @@ -530,7 +502,6 @@ static void sba_write_stats_in_seqfile(struct sba_device *sba, seq_printf(file, "pending requests = %d\n", pending_count); seq_printf(file, "active requests = %d\n", active_count); seq_printf(file, "aborted requests = %d\n", aborted_count); - seq_printf(file, "completed requests = %d\n", completed_count); } /* ====== DMAENGINE callbacks ===== */ @@ -1537,7 +1508,6 @@ static int sba_prealloc_channel_resources(struct sba_device *sba) INIT_LIST_HEAD(&sba->reqs_alloc_list); INIT_LIST_HEAD(&sba->reqs_pending_list); INIT_LIST_HEAD(&sba->reqs_active_list); - INIT_LIST_HEAD(&sba->reqs_completed_list); INIT_LIST_HEAD(&sba->reqs_aborted_list); INIT_LIST_HEAD(&sba->reqs_free_list); @@ -1565,6 +1535,7 @@ static int sba_prealloc_channel_resources(struct sba_device *sba) } memset(&req->msg, 0, sizeof(req->msg)); dma_async_tx_descriptor_init(&req->tx, &sba->dma_chan); + async_tx_ack(&req->tx); req->tx.tx_submit = sba_tx_submit; req->tx.phys = sba->resp_dma_base + i * sba->hw_resp_size; list_add_tail(&req->node, &sba->reqs_free_list);