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 B35DFA0543; Tue, 25 Oct 2022 10:20:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A867640A89; Tue, 25 Oct 2022 10:20:38 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 6021E400D5 for ; Tue, 25 Oct 2022 10:20:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666686037; x=1698222037; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ODY3ifBmrdYweR4u9RrbYGKMdGch9w4J1PP0SOCBlLk=; b=TJuja7WfORsj3yZwRoFO86whiqs4FVSg02TBzxvqk0aM2Zw8DdYN8WkG RS04R35wdjBEnANi/5v/mNtZcLwVHeHKmKNabDgOJ20ULKaTglNVy5gDy EzIQm15EOIq5AnYdbjHQzUpNiPkmaxsJur8JMyQIkN99Kkc4b8fCusar8 hsoFwwrdVmrp76HDgDSPBcZaztCYdHya941vcnw9Yrme4Kmu3Jb2Vk+Cw Foa124G+yeY+FFs3h8U9sDaeWObwR+4tbstnpTJi/sUlp7AwxMEc8Z6U+ ZsUL5Rir03GGqPWFuKKMGUhMoDkmbH/JoAdgtACI0Q6Z0lTZYZTvjzmkx Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="371834851" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="371834851" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2022 01:20:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="664831441" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="664831441" Received: from unknown (HELO localhost.localdomain) ([10.190.193.12]) by orsmga001.jf.intel.com with ESMTP; 25 Oct 2022 01:20:16 -0700 From: Abhishek Maheshwari To: xiao.w.wang@intel.com, chenbo.xia@intel.com Cc: abhishek.maheshwari@intel.com, dev@dpdk.org, purna.chandra.mandal@intel.com Subject: [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state Date: Tue, 25 Oct 2022 13:21:49 +0530 Message-Id: <20221025075149.1713006-1-abhishek.maheshwari@intel.com> X-Mailer: git-send-email 2.31.1 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. Signed-off-by: Abhishek Maheshwari --- 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..76690c1f55 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_tries; 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_tries = 10; + while (q_disable_tries-- && IFCVF_READ_REG16(&cfg->queue_enable)) + msec_delay(10); + + if (IFCVF_READ_REG16(&cfg->queue_enable)) + WARNINGOUT("Failed Q disable: %d. saved state is invalid\n", i); + if (hw->device_type == IFCVF_BLK) ring_state = *(u32 *)(hw->lm_cfg + IFCVF_LM_RING_STATE_OFFSET + -- 2.31.1