DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Subject: [PATCH v1 13/15] net/ixgbe/base: fix mailbox ACK handling
Date: Thu, 29 Aug 2024 10:00:18 +0100	[thread overview]
Message-ID: <442255ff84173d052cb454ac9ccc62b9868632a2.1724921977.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <a16bd1264adbd56fefbf1413f27cde338959f61c.1724921977.git.anatoly.burakov@intel.com>

From: NorbertX Ciosek <norbertx.ciosek@intel.com>

Check if CTS bit is set in the mailbox message before waiting for ACK.
Otherwise ACK will never be received causing the function to timeout. Add
a note for ixgbe_write_mbx that it should be called while holding a lock.

Signed-off-by: NorbertX Ciosek <norbertx.ciosek@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/ixgbe/base/ixgbe_mbx.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.c b/drivers/net/ixgbe/base/ixgbe_mbx.c
index 23659266d0..fb8ea8ca68 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.c
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.c
@@ -82,6 +82,9 @@ s32 ixgbe_poll_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
  *
  * returns SUCCESS if it successfully copied message into the buffer and
  * received an ACK to that message within specified period
+ *
+ * Note that the caller to this function must lock before calling, since
+ * multiple threads can destroy each other messages.
  **/
 s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 {
@@ -836,6 +839,11 @@ STATIC s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_id)
 	while (countdown--) {
 		/* Reserve mailbox for PF use */
 		pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id));
+
+		/* Check if other thread holds the PF lock already */
+		if (pf_mailbox & IXGBE_PFMAILBOX_PFU)
+			goto retry;
+
 		pf_mailbox |= IXGBE_PFMAILBOX_PFU;
 		IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox);
 
@@ -846,6 +854,7 @@ STATIC s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_id)
 			break;
 		}
 
+	retry:
 		/* Wait a bit before trying again */
 		usec_delay(mbx->usec_delay);
 	}
@@ -948,13 +957,14 @@ STATIC s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 	for (i = 0; i < size; i++)
 		IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i, msg[i]);
 
-	/* Interrupt VF to tell it a message has been sent */
+	/* interrupt VF to tell it a message has been sent */
 	pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id));
 	pf_mailbox |= IXGBE_PFMAILBOX_STS;
 	IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox);
 
 	/* if msg sent wait until we receive an ack */
-	ixgbe_poll_for_ack(hw, vf_id);
+	if (msg[0] & IXGBE_VT_MSGTYPE_CTS)
+		ixgbe_poll_for_ack(hw, vf_id);
 
 	/* update stats */
 	hw->mbx.stats.msgs_tx++;
-- 
2.43.5


  parent reply	other threads:[~2024-08-29  9:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29  9:00 [PATCH v1 01/15] net/ixgbe/base: remove minsrevs code from DPDK Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 02/15] net/ixgbe/base: add missing ACI definitions Anatoly Burakov
2024-09-03 10:32   ` Bruce Richardson
2024-08-29  9:00 ` [PATCH v1 03/15] net/ixgbe/base: add missing E610 definitions Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 04/15] net/ixgbe/base: add missing legacy mailbox API Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 05/15] net/ixgbe/base: add E610 VF HV macro Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 06/15] net/ixgbe/base: fix unchecked return value Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 07/15] net/ixgbe/base: fix media type handling for E610 Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 08/15] net/ixgbe/base: fix speed autonegotiation on E610 Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 09/15] net/ixgbe/base: FW API version update Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 10/15] net/ixgbe/base: handle 5G link speed for E610 Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 11/15] net/ixgbe/base: remove FW API version check Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 12/15] net/ixgbe/base: disable thermal sensor ops for E610 Anatoly Burakov
2024-08-29  9:00 ` Anatoly Burakov [this message]
2024-08-29  9:00 ` [PATCH v1 14/15] net/ixgbe/base: correct NVM access type for EEPROM writes on E610 Anatoly Burakov
2024-08-29  9:00 ` [PATCH v1 15/15] net/ixgbe: add PCI IDs for new device variants Anatoly Burakov
2024-09-03 14:08 ` [PATCH v1 01/15] net/ixgbe/base: remove minsrevs code from DPDK Bruce Richardson

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=442255ff84173d052cb454ac9ccc62b9868632a2.1724921977.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /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).