From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79C2645895; Thu, 29 Aug 2024 11:01:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A247D42DD5; Thu, 29 Aug 2024 11:00:47 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by mails.dpdk.org (Postfix) with ESMTP id 866B242DCB for ; Thu, 29 Aug 2024 11:00:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724922044; x=1756458044; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=j24MiqhhE/M65VI7odXn0qmfHmpj/JkixNu1r2JIztc=; b=bpcYwvRBhwu/+P0Kq3WCC7ciYl4AQ1faD+O9aWE9XGKGLqNmOGIxaiFd VNkAdqfIu7R21OAiaFV1yUNl6PbpUvY0sDU9aRExgIP6SQ+vaSdO9+qHn sV4+n9X9/d8+dJUgcTit71do8KRpNzJ9tyBB1Up/x7ieNnP1JaB1jntz0 U4UVHuVv8q6o1b8UIzDNJmWwLlzGxw2UHtlRv/nbJ6CDMxFF0loyNrzk+ 4sHivwrPEKMTMti+9n7HAMt5IdCx2hTXv3xMWvu7hYAZNZVvaqRgsO3x9 EqoLKtSeCdtrPm/mo6TIZyidpcoAb6jBv0BfFN8d6bqdjZrk3vG2Vd4tt g==; X-CSE-ConnectionGUID: uB580TXuTJ2+F1fXSZmuWQ== X-CSE-MsgGUID: qFcnC7M3QOKrZG12gtEj2w== X-IronPort-AV: E=McAfee;i="6700,10204,11178"; a="23663503" X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="23663503" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 02:00:40 -0700 X-CSE-ConnectionGUID: e1xq9hzAQt+fYZjVUe2L8w== X-CSE-MsgGUID: SS/099bDQzy8c6Wib8E9ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,185,1719903600"; d="scan'208";a="64202956" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa008.jf.intel.com with ESMTP; 29 Aug 2024 02:00:39 -0700 From: Anatoly Burakov 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 Message-ID: <442255ff84173d052cb454ac9ccc62b9868632a2.1724921977.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: NorbertX Ciosek 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 Signed-off-by: Anatoly Burakov --- 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