vdpa/ifc/base: wait for queue disable before saving q-state

Message ID 20221025072302.1683505-1-abhishek.maheshwari@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/ifc/base: wait for queue disable before saving q-state |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Abhishek Maheshwari Oct. 25, 2022, 7:23 a.m. UTC
  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 <abhishek.maheshwari@intel.com>
---
 drivers/vdpa/ifc/base/ifcvf.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
  

Patch

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index f1e1474447..fb51c793a2 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 +