From: Anup Patel <anup.patel@broadcom.com>
To: Vinod Koul <vinod.koul@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Scott Branden <sbranden@broadcom.com>,
Ray Jui <rjui@broadcom.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com,
Anup Patel <anup.patel@broadcom.com>
Subject: [PATCH v3 17/17] dmaengine: bcm-sba-raid: Remove redundant SBA_REQUEST_STATE_COMPLETED
Date: Tue, 22 Aug 2017 15:27:06 +0530 [thread overview]
Message-ID: <1503395827-19428-18-git-send-email-anup.patel@broadcom.com> (raw)
In-Reply-To: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com>
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 <anup.patel@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
---
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);
--
2.7.4
next prev parent reply other threads:[~2017-08-22 9:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 9:56 [PATCH v3 00/17] Broadcom SBA-RAID driver improvements Anup Patel
2017-08-22 9:56 ` [PATCH v3 01/17] dmaengine: bcm-sba-raid: Minor improvments in comments Anup Patel
2017-08-22 9:56 ` [PATCH v3 02/17] dmaengine: bcm-sba-raid: Reduce locking context in sba_alloc_request() Anup Patel
2017-08-22 9:56 ` [PATCH v3 03/17] dmaengine: bcm-sba-raid: Common flags for sba_request state and fence Anup Patel
2017-08-22 9:56 ` [PATCH v3 04/17] dmaengine: bcm-sba-raid: Remove redundant next_count from sba_request Anup Patel
2017-08-22 9:56 ` [PATCH v3 05/17] dmaengine: bcm-sba-raid: Remove redundant resp_dma " Anup Patel
2017-08-22 9:56 ` [PATCH v3 06/17] dmaengine: bcm-sba-raid: Remove reqs_free_count from sba_device Anup Patel
2017-08-22 9:56 ` [PATCH v3 07/17] dmaengine: bcm-sba-raid: Allow arbitrary number free sba_request Anup Patel
2017-08-22 9:56 ` [PATCH v3 08/17] dmaengine: bcm-sba-raid: Increase number of " Anup Patel
2017-08-22 9:56 ` [PATCH v3 09/17] dmaengine: bcm-sba-raid: Improve sba_issue_pending() run duration Anup Patel
2017-08-22 9:56 ` [PATCH v3 10/17] dmaengine: bcm-sba-raid: Alloc resources before registering DMA device Anup Patel
2017-08-22 9:57 ` [PATCH v3 11/17] dmaengine: bcm-sba-raid: Peek mbox when we have no free requests Anup Patel
2017-08-22 9:57 ` [PATCH v3 12/17] dmaengine: bcm-sba-raid: Pre-ack async tx descriptor Anup Patel
2017-08-22 9:57 ` [PATCH v3 13/17] dmaengine: bcm-sba-raid: Re-factor sba_process_deferred_requests() Anup Patel
2017-08-22 9:57 ` [PATCH v3 14/17] dmaengine: bcm-sba-raid: Remove redundant SBA_REQUEST_STATE_RECEIVED Anup Patel
2017-08-22 9:57 ` [PATCH v3 15/17] dmaengine: bcm-sba-raid: Add debugfs support Anup Patel
2017-08-22 9:57 ` [PATCH v3 16/17] dmaengine: bcm-sba-raid: Explicitly ACK mailbox message after sending Anup Patel
2017-08-22 9:57 ` Anup Patel [this message]
2017-08-28 11:14 ` [PATCH v3 00/17] Broadcom SBA-RAID driver improvements Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503395827-19428-18-git-send-email-anup.patel@broadcom.com \
--to=anup.patel@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®