DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state
@ 2022-10-25  7:51 Abhishek Maheshwari
  2022-10-26  5:32 ` Maxime Coquelin
  0 siblings, 1 reply; 3+ messages in thread
From: Abhishek Maheshwari @ 2022-10-25  7:51 UTC (permalink / raw)
  To: xiao.w.wang, chenbo.xia; +Cc: abhishek.maheshwari, dev, purna.chandra.mandal

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(+)

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


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

* Re: [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state
  2022-10-25  7:51 [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state Abhishek Maheshwari
@ 2022-10-26  5:32 ` Maxime Coquelin
  0 siblings, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2022-10-26  5:32 UTC (permalink / raw)
  To: Abhishek Maheshwari, xiao.w.wang, chenbo.xia; +Cc: dev, purna.chandra.mandal

Hi Abhishek,

On 10/25/22 09:51, Abhishek Maheshwari wrote:
> 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.


I think it should be considered a fix, and so requires a Fixes tag and
stable@dpdk.org to be cc'ed.

> Signed-off-by: Abhishek Maheshwari <abhishek.maheshwari@intel.com>
> ---
>   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);

Maybe checking q_disable_tries > 0 is enough here.
Also, should we really continue the disablement if synchronization
failed?

> +
>   		if (hw->device_type == IFCVF_BLK)
>   			ring_state = *(u32 *)(hw->lm_cfg +
>   					IFCVF_LM_RING_STATE_OFFSET +


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

* [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state
@ 2022-10-25  7:23 Abhishek Maheshwari
  0 siblings, 0 replies; 3+ messages in thread
From: Abhishek Maheshwari @ 2022-10-25  7:23 UTC (permalink / raw)
  To: abhishek.maheshwari; +Cc: dev, chenbo.xia, purna.chandra.mandal

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(+)

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 +
-- 
2.31.1


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

end of thread, other threads:[~2022-10-26  5:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25  7:51 [PATCH] vdpa/ifc/base: wait for queue disable before saving q-state Abhishek Maheshwari
2022-10-26  5:32 ` Maxime Coquelin
  -- strict thread matches above, loose matches on Subject: below --
2022-10-25  7:23 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).