DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2] vdpa/ifc/base: wait for queue disable before saving q-state
@ 2022-11-02  3:04 Abhishek Maheshwari
  0 siblings, 0 replies; 2+ messages in thread
From: Abhishek Maheshwari @ 2022-11-02  3:04 UTC (permalink / raw)
  To: maxime.coquelin, xiao.w.wang
  Cc: dev, stable, chenbo.xia, purna.chandra.mandal, andy.pei,
	Abhishek Maheshwari

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 <abhishek.maheshwari@intel.com>

---
v2:
* Fixing the styling issues
* Addressing comment to avoid reading the register again after
  exhausting the tries
---
 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..59d5ac765e 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 > 0)
+		    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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] vdpa/ifc/base: wait for queue disable before saving q-state
  2022-10-25  7:23 [PATCH] " Abhishek Maheshwari
@ 2022-11-02  3:22 ` Abhishek Maheshwari
  0 siblings, 0 replies; 2+ messages in thread
From: Abhishek Maheshwari @ 2022-11-02  3:22 UTC (permalink / raw)
  To: maxime.coquelin, xiao.w.wang
  Cc: dev, stable, chenbo.xia, purna.chandra.mandal, andy.pei,
	Abhishek Maheshwari

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 <abhishek.maheshwari@intel.com>

---
v2:
* Fixing the styling issues
* Addressing comment to avoid reading the register again after
  exhausting the tries
---
 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..281366f2a0 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 > 0)
+			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 +
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-02  3:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  3:04 [PATCH v2] vdpa/ifc/base: wait for queue disable before saving q-state Abhishek Maheshwari
  -- strict thread matches above, loose matches on Subject: below --
2022-10-25  7:23 [PATCH] " Abhishek Maheshwari
2022-11-02  3:22 ` [PATCH v2] " Abhishek Maheshwari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).