DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rasesh Mody <rasesh.mody@cavium.com>
To: dev@dpdk.org
Cc: Rasesh Mody <rasesh.mody@cavium.com>,
	ferruh.yigit@intel.com, Dept-EngDPDKDev@cavium.com
Subject: [dpdk-dev] [PATCH 02/14] net/qede/base: protect DMAE transactions
Date: Sat, 31 Mar 2018 22:46:52 -0700	[thread overview]
Message-ID: <1522561624-15817-3-git-send-email-rasesh.mody@cavium.com> (raw)
In-Reply-To: <1522561624-15817-1-git-send-email-rasesh.mody@cavium.com>

Protect DMAE transactions with a spinlock instead of a mutex

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
 drivers/net/qede/base/ecore.h     |    6 ++++--
 drivers/net/qede/base/ecore_dev.c |    6 +++---
 drivers/net/qede/base/ecore_hw.c  |   30 +++++++++++++++++++-----------
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/net/qede/base/ecore.h b/drivers/net/qede/base/ecore.h
index ce5f3a9..7c642af 100644
--- a/drivers/net/qede/base/ecore.h
+++ b/drivers/net/qede/base/ecore.h
@@ -432,8 +432,10 @@ struct ecore_hw_info {
 #define DMAE_MAX_RW_SIZE	0x2000
 
 struct ecore_dmae_info {
-	/* Mutex for synchronizing access to functions */
-	osal_mutex_t	mutex;
+	/* Spinlock for synchronizing access to functions */
+	osal_spinlock_t lock;
+
+	bool b_mem_ready;
 
 	u8 channel;
 
diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c
index cd274c3..b15af03 100644
--- a/drivers/net/qede/base/ecore_dev.c
+++ b/drivers/net/qede/base/ecore_dev.c
@@ -423,9 +423,9 @@ void ecore_init_struct(struct ecore_dev *p_dev)
 		p_hwfn->b_active = false;
 
 #ifdef CONFIG_ECORE_LOCK_ALLOC
-		OSAL_MUTEX_ALLOC(p_hwfn, &p_hwfn->dmae_info.mutex);
+		OSAL_SPIN_LOCK_ALLOC(p_hwfn, &p_hwfn->dmae_info.lock);
 #endif
-		OSAL_MUTEX_INIT(&p_hwfn->dmae_info.mutex);
+		OSAL_SPIN_LOCK_INIT(&p_hwfn->dmae_info.lock);
 	}
 
 	/* hwfn 0 is always active */
@@ -4238,7 +4238,7 @@ void ecore_hw_remove(struct ecore_dev *p_dev)
 		ecore_mcp_free(p_hwfn);
 
 #ifdef CONFIG_ECORE_LOCK_ALLOC
-		OSAL_MUTEX_DEALLOC(&p_hwfn->dmae_info.mutex);
+		OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->dmae_info.lock);
 #endif
 	}
 
diff --git a/drivers/net/qede/base/ecore_hw.c b/drivers/net/qede/base/ecore_hw.c
index 84f273b..34e2e5f 100644
--- a/drivers/net/qede/base/ecore_hw.c
+++ b/drivers/net/qede/base/ecore_hw.c
@@ -592,7 +592,8 @@ enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn *p_hwfn)
 		goto err;
 	}
 
-	p_hwfn->dmae_info.channel = p_hwfn->rel_pf_id;
+		p_hwfn->dmae_info.channel = p_hwfn->rel_pf_id;
+		p_hwfn->dmae_info.b_mem_ready = true;
 
 	return ECORE_SUCCESS;
 err:
@@ -604,8 +605,9 @@ void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn)
 {
 	dma_addr_t p_phys;
 
-	/* Just make sure no one is in the middle */
-	OSAL_MUTEX_ACQUIRE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_LOCK(&p_hwfn->dmae_info.lock);
+	p_hwfn->dmae_info.b_mem_ready = false;
+	OSAL_SPIN_UNLOCK(&p_hwfn->dmae_info.lock);
 
 	if (p_hwfn->dmae_info.p_completion_word != OSAL_NULL) {
 		p_phys = p_hwfn->dmae_info.completion_word_phys_addr;
@@ -630,8 +632,6 @@ void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn)
 				       p_phys, sizeof(u32) * DMAE_MAX_RW_SIZE);
 		p_hwfn->dmae_info.p_intermediate_buffer = OSAL_NULL;
 	}
-
-	OSAL_MUTEX_RELEASE(&p_hwfn->dmae_info.mutex);
 }
 
 static enum _ecore_status_t ecore_dmae_operation_wait(struct ecore_hwfn *p_hwfn)
@@ -777,6 +777,14 @@ static enum _ecore_status_t ecore_dmae_operation_wait(struct ecore_hwfn *p_hwfn)
 	enum _ecore_status_t ecore_status = ECORE_SUCCESS;
 	u32 offset = 0;
 
+	if (!p_hwfn->dmae_info.b_mem_ready) {
+		DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
+			   "No buffers allocated. Avoid DMAE transaction [{src: addr 0x%lx, type %d}, {dst: addr 0x%lx, type %d}, size %d].\n",
+			   src_addr, src_type, dst_addr, dst_type,
+			   size_in_dwords);
+		return ECORE_NOMEM;
+	}
+
 	if (p_hwfn->p_dev->recov_in_prog) {
 		DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
 			   "Recovery is in progress. Avoid DMAE transaction [{src: addr 0x%lx, type %d}, {dst: addr 0x%lx, type %d}, size %d].\n",
@@ -870,7 +878,7 @@ enum _ecore_status_t
 	OSAL_MEMSET(&params, 0, sizeof(struct ecore_dmae_params));
 	params.flags = flags;
 
-	OSAL_MUTEX_ACQUIRE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_LOCK(&p_hwfn->dmae_info.lock);
 
 	rc = ecore_dmae_execute_command(p_hwfn, p_ptt, source_addr,
 					grc_addr_in_dw,
@@ -878,7 +886,7 @@ enum _ecore_status_t
 					ECORE_DMAE_ADDRESS_GRC,
 					size_in_dwords, &params);
 
-	OSAL_MUTEX_RELEASE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_UNLOCK(&p_hwfn->dmae_info.lock);
 
 	return rc;
 }
@@ -896,14 +904,14 @@ enum _ecore_status_t
 	OSAL_MEMSET(&params, 0, sizeof(struct ecore_dmae_params));
 	params.flags = flags;
 
-	OSAL_MUTEX_ACQUIRE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_LOCK(&p_hwfn->dmae_info.lock);
 
 	rc = ecore_dmae_execute_command(p_hwfn, p_ptt, grc_addr_in_dw,
 					dest_addr, ECORE_DMAE_ADDRESS_GRC,
 					ECORE_DMAE_ADDRESS_HOST_VIRT,
 					size_in_dwords, &params);
 
-	OSAL_MUTEX_RELEASE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_UNLOCK(&p_hwfn->dmae_info.lock);
 
 	return rc;
 }
@@ -917,7 +925,7 @@ enum _ecore_status_t
 {
 	enum _ecore_status_t rc;
 
-	OSAL_MUTEX_ACQUIRE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_LOCK(&p_hwfn->dmae_info.lock);
 
 	rc = ecore_dmae_execute_command(p_hwfn, p_ptt, source_addr,
 					dest_addr,
@@ -925,7 +933,7 @@ enum _ecore_status_t
 					ECORE_DMAE_ADDRESS_HOST_PHYS,
 					size_in_dwords, p_params);
 
-	OSAL_MUTEX_RELEASE(&p_hwfn->dmae_info.mutex);
+	OSAL_SPIN_UNLOCK(&p_hwfn->dmae_info.lock);
 
 	return rc;
 }
-- 
1.7.10.3

  parent reply	other threads:[~2018-04-01  5:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01  5:46 [dpdk-dev] [PATCH 00/14] net/qede/base: update PMD version to 2.8.0.1 Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 01/14] net/qede/base: use path ID for HW init Rasesh Mody
2018-04-01  5:46 ` Rasesh Mody [this message]
2018-04-01  5:46 ` [dpdk-dev] [PATCH 03/14] net/qede/base: add DMAE sanity check Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 04/14] net/qede/base: upgrade FW to 8.33.12.0 Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 05/14] net/qede/base: symantic changes Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 06/14] net/qede/base: add new chain API Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 07/14] net/qede/base: allow changing VF MAC address Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 08/14] net/qede/base: add MFW support for driver load timeout Rasesh Mody
2018-04-01  5:46 ` [dpdk-dev] [PATCH 09/14] net/qede/base: refine error handling Rasesh Mody
2018-04-01  5:47 ` [dpdk-dev] [PATCH 10/14] net/qede/base: add stats counter for link state Rasesh Mody
2018-04-01  5:47 ` [dpdk-dev] [PATCH 11/14] net/qede/base: add APIs for xcvr Rasesh Mody
2018-04-01  5:47 ` [dpdk-dev] [PATCH 12/14] net/qede/base: fix to support OVLAN mode Rasesh Mody
2018-04-01  5:47 ` [dpdk-dev] [PATCH 13/14] net/qede/base: add packet pacing support Rasesh Mody
2018-04-01  5:47 ` [dpdk-dev] [PATCH 14/14] net/qede: update PMD version to 2.8.0.1 Rasesh Mody
2018-04-06  9:03 ` [dpdk-dev] [PATCH 00/14] net/qede/base: " Ferruh Yigit
2018-04-09  4:49   ` Mody, Rasesh
2018-04-09  4:47 ` [dpdk-dev] [PATCH v2 " Rasesh Mody
2018-04-09 17:10   ` Ferruh Yigit
2018-04-09  4:47 ` [dpdk-dev] [PATCH v2 01/14] net/qede/base: use path ID for HW init Rasesh Mody
2018-04-09  4:47 ` [dpdk-dev] [PATCH v2 02/14] net/qede/base: protect DMAE transactions Rasesh Mody
2018-04-09  4:47 ` [dpdk-dev] [PATCH v2 03/14] net/qede/base: add DMAE sanity check Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 04/14] net/qede/base: upgrade FW to 8.33.12.0 Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 05/14] net/qede/base: symantic changes Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 06/14] net/qede/base: add new chain API Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 07/14] net/qede/base: allow changing VF MAC address Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 08/14] net/qede/base: add MFW support for driver load timeout Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 09/14] net/qede/base: refine error handling Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 10/14] net/qede/base: add stats counter for link state Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 11/14] net/qede/base: add APIs for xcvr Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 12/14] net/qede/base: fix to support OVLAN mode Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 13/14] net/qede/base: add packet pacing support Rasesh Mody
2018-04-09  4:48 ` [dpdk-dev] [PATCH v2 14/14] net/qede: update PMD version to 2.8.0.1 Rasesh Mody

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=1522561624-15817-3-git-send-email-rasesh.mody@cavium.com \
    --to=rasesh.mody@cavium.com \
    --cc=Dept-EngDPDKDev@cavium.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@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;
as well as URLs for NNTP newsgroup(s).