From patchwork Wed Nov 2 09:54:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Maheshwari X-Patchwork-Id: 119407 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C3346A00C2; Wed, 2 Nov 2022 11:24:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63E7840693; Wed, 2 Nov 2022 11:24:43 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 814BD40223; Wed, 2 Nov 2022 11:24:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667384681; x=1698920681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aDzlTnLxjKNXEax6hzx5FW0hdp9rDS86UpD952kl9p4=; b=iemx5VD2hVSwzBiCEyscD8vuQv1uR/uveoECMljZ4yvEhSuntJbv25Jj mUmoxIoZTXwnny5q4p5MMtvvr8D0srYBr60az2tq8Kk2k81wwc5E4w6Zn H4iCWAr538MR5lWbHv+sowCBY1nJLoKVGHoAWNCE83UkKAAeOy1loLozN wwczA95h926wdl4h61puhXT9jc95orFqfEVrKlZxQ7XT7raAnIByJ7j/u x4sqQmxZwH/u5MzFtFAWreGxdWKpJR8fMgUXPErrgCszaH78Vh0VZBxot p38o8dFYnzU94Sjg7wPlPMpTylp8Ixqp69ID6I9zb3S2sEDs0tZEXKoKv A==; X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="289756460" X-IronPort-AV: E=Sophos;i="5.95,232,1661842800"; d="scan'208";a="289756460" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 03:24:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="634211259" X-IronPort-AV: E=Sophos;i="5.95,232,1661842800"; d="scan'208";a="634211259" Received: from unknown (HELO localhost.localdomain) ([10.190.193.12]) by orsmga002.jf.intel.com with ESMTP; 02 Nov 2022 03:24:21 -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, andy.pei@intel.com, Abhishek Maheshwari Subject: [PATCH v3] vdpa/ifc/base: wait for queue disable before saving q-state Date: Wed, 2 Nov 2022 15:24:58 +0530 Message-Id: <20221102095458.2165448-1-abhishek.maheshwari@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221102032215.2108558-1-abhishek.maheshwari@intel.com> References: <20221102032215.2108558-1-abhishek.maheshwari@intel.com> MIME-Version: 1.0 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: andy.pei@intel.com Cc: stable@dpdk.org Signed-off-by: Abhishek Maheshwari Acked-by: Andy Pei --- v2: * Fixing the styling issues * Addressing comment to avoid reading the register again after exhausting the tries v3: * Fixing warning condition --- drivers/vdpa/ifc/base/ifcvf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c index f1e1474447..06996fd5d7 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,21 @@ 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 Q:%d disable, Saved state invalid\n", + i); + if (hw->device_type == IFCVF_BLK) ring_state = *(u32 *)(hw->lm_cfg + IFCVF_LM_RING_STATE_OFFSET +