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 CE2ACA00C2; Thu, 3 Nov 2022 11:04:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6F3C40694; Thu, 3 Nov 2022 11:04:34 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 0BD3B40693; Thu, 3 Nov 2022 11:04:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667469873; x=1699005873; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dH/9qwPT9Pi6hmkDPdknA5HAtR42DvTOxlkUuYX0/0w=; b=JYsf8o+AgSdmBGqAbAjdjN5ekfKwoy+f0fOs2ZZwtLS1jXPjUoBRqlVz pJrHHmU8D58UTr9SSVBKS62RRfkmWzGnl9nAJ5sv9zO5oreWDlixbqNF1 ucS1ZQGEst92/D+Cju89scqgp7UWGe8fAObHDMFIlZH0g/KD8kHphuXQJ rDHhAUN7PZxoptFV4iVuKMT2VNtNMUAa3DT3w/dj9fFINd/ED9muGxp30 CU6+hzgLzz9r+I2ajYSC6BKpD4QmSKoSb+1WqmC2fTE5xpDv61Aav73Kr GnCZgtPq/Vfc87EEI8r5sHTUMtq8NEKnuACGRQRZHhY6OoQ+1OEeTB7D0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="336332723" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="336332723" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 03:04:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="629287670" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="629287670" Received: from unknown (HELO localhost.localdomain) ([10.190.193.12]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2022 03:04:29 -0700 From: Abhishek Maheshwari To: maxime.coquelin@redhat.com, xiao.w.wang@intel.com Cc: dev@dpdk.org, stable@dpdk.org, chenbo.xia@intel.com, purna.chandra.mandal@intel.com, Abhishek Maheshwari Subject: [PATCH v5] vdpa/ifc/base: wait for queue disable before saving q-state Date: Thu, 3 Nov 2022 15:05:00 +0530 Message-Id: <20221103093500.2337873-1-abhishek.maheshwari@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221103043635.2334541-1-abhishek.maheshwari@intel.com> References: <20221103043635.2334541-1-abhishek.maheshwari@intel.com> 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 Some ifc hardware require synchronization between disabling a queue and saving queue-state from LM registers. When queue is disabled from vDPA driver, ifc device stops executing new virtio-cmds and then updates LM registers with used/avail index. Before saving the queue-state, vDPA driver should wait until the queue is disabled from backend. Fixes: 5d75517beffe ("vdpa/ifc/base: access block device registers") Cc: stable@dpdk.org Signed-off-by: Abhishek Maheshwari --- v2: * Fixing the styling issues * Addressing comment to avoid reading the register again after exhausting the tries v3: * Fixing warning condition v4: * Fixing print argument format to %u in warning v5: * Addressing comments based on input that line length limit is 100 --- drivers/vdpa/ifc/base/ifcvf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c index f1e1474447..60555a6786 100644 --- a/drivers/vdpa/ifc/base/ifcvf.c +++ b/drivers/vdpa/ifc/base/ifcvf.c @@ -257,6 +257,7 @@ ifcvf_hw_disable(struct ifcvf_hw *hw) u32 i; struct ifcvf_pci_common_cfg *cfg; u32 ring_state; + int q_disable_try; cfg = hw->common_cfg; if (!cfg) { @@ -275,6 +276,20 @@ ifcvf_hw_disable(struct ifcvf_hw *hw) continue; } + /* Some ifc hardware require synchronization between disabling a + * queue and saving queue-state from LM registers. When queue is + * disabled from vDPA driver, ifc device stops executing new + * virtio-cmds and then updates LM registers with used/avail + * index. Before saving the queue-state, vDPA driver waits until + * the queue is disabled from backend. + */ + q_disable_try = 10; + while (q_disable_try-- && IFCVF_READ_REG16(&cfg->queue_enable)) + msec_delay(10); + + if (!q_disable_try) + WARNINGOUT("Failed to disable Q:%u, Saved state could be invalid\n", i); + if (hw->device_type == IFCVF_BLK) ring_state = *(u32 *)(hw->lm_cfg + IFCVF_LM_RING_STATE_OFFSET + -- 2.31.1