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

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

Checks

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

Commit Message

Abhishek Maheshwari Nov. 3, 2022, 9:35 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.

Fixes: 5d75517beffe ("vdpa/ifc/base: access block device registers")

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

v3:
* Fixing warning condition

v4:
* Fixing print argument format to %u in warning

v5:
* Addressing comments based on input that line length limit is 100
---
 drivers/vdpa/ifc/base/ifcvf.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
  

Comments

Chenbo Xia Nov. 4, 2022, 2:31 a.m. UTC | #1
> -----Original Message-----
> From: Maheshwari, Abhishek <abhishek.maheshwari@intel.com>
> Sent: Thursday, November 3, 2022 5:35 PM
> To: maxime.coquelin@redhat.com; Wang, Xiao W <xiao.w.wang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>;
> Mandal, Purna Chandra <purna.chandra.mandal@intel.com>; Maheshwari,
> Abhishek <abhishek.maheshwari@intel.com>
> Subject: [PATCH v5] vdpa/ifc/base: wait for queue disable before saving q-
> state
> 
> 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")
> 

Will remove above blank line and add Andy's A-By when applying

For this patch:

Reviewed-by: Chenbo Xia <chenbo.xia@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
> 
> v3:
> * Fixing warning condition
> 
> v4:
> * Fixing print argument format to %u in warning
> 
> v5:
> * Addressing comments based on input that line length limit is 100
> ---
>  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..60555a6786 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,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_try = 10;
> +		while (q_disable_try-- && IFCVF_READ_REG16(&cfg->queue_enable))
> +			msec_delay(10);
> +
> +		if (!q_disable_try)
> +			WARNINGOUT("Failed to disable Q:%u, Saved state could be
> invalid\n", i);
> +
>  		if (hw->device_type == IFCVF_BLK)
>  			ring_state = *(u32 *)(hw->lm_cfg +
>  					IFCVF_LM_RING_STATE_OFFSET +
> --
> 2.31.1
  
Mandal, Purna Chandra Nov. 4, 2022, 2:38 a.m. UTC | #2
-----Original Message-----
From: Maheshwari, Abhishek <abhishek.maheshwari@intel.com> 
Sent: Thursday, November 3, 2022 3:05 PM
To: maxime.coquelin@redhat.com; Wang, Xiao W <xiao.w.wang@intel.com>
Cc: dev@dpdk.org; stable@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Mandal, Purna Chandra <purna.chandra.mandal@intel.com>; Maheshwari, Abhishek <abhishek.maheshwari@intel.com>
Subject: [PATCH v5] vdpa/ifc/base: wait for queue disable before saving q-state

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: 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

v3:
* Fixing warning condition

v4:
* Fixing print argument format to %u in warning

v5:
* Addressing comments based on input that line length limit is 100
---
 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..60555a6786 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,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_try = 10;
+		while (q_disable_try-- && IFCVF_READ_REG16(&cfg->queue_enable))
+			msec_delay(10);
+
+		if (!q_disable_try)
+			WARNINGOUT("Failed to disable Q:%u, Saved state could be invalid\n", 
+i);
+
 		if (hw->device_type == IFCVF_BLK)
 			ring_state = *(u32 *)(hw->lm_cfg +
 					IFCVF_LM_RING_STATE_OFFSET +
--
2.31.1
Ack. Reviewed by Purna Chandra Mandal <purna.chandra,mandal@intel.com>
  
Chenbo Xia Nov. 10, 2022, 7:02 a.m. UTC | #3
> -----Original Message-----
> From: Maheshwari, Abhishek <abhishek.maheshwari@intel.com>
> Sent: Thursday, November 3, 2022 5:35 PM
> To: maxime.coquelin@redhat.com; Wang, Xiao W <xiao.w.wang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>;
> Mandal, Purna Chandra <purna.chandra.mandal@intel.com>; Maheshwari,
> Abhishek <abhishek.maheshwari@intel.com>
> Subject: [PATCH v5] vdpa/ifc/base: wait for queue disable before saving q-
> state
> 
> 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: 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
> 
> v3:
> * Fixing warning condition
> 
> v4:
> * Fixing print argument format to %u in warning
> 
> v5:
> * Addressing comments based on input that line length limit is 100
> ---
>  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..60555a6786 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,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_try = 10;
> +		while (q_disable_try-- && IFCVF_READ_REG16(&cfg->queue_enable))
> +			msec_delay(10);
> +
> +		if (!q_disable_try)
> +			WARNINGOUT("Failed to disable Q:%u, Saved state could be
> invalid\n", i);
> +
>  		if (hw->device_type == IFCVF_BLK)
>  			ring_state = *(u32 *)(hw->lm_cfg +
>  					IFCVF_LM_RING_STATE_OFFSET +
> --
> 2.31.1

Applied to next-virtio/main, thanks
  

Patch

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index f1e1474447..60555a6786 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,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_try = 10;
+		while (q_disable_try-- && IFCVF_READ_REG16(&cfg->queue_enable))
+			msec_delay(10);
+
+		if (!q_disable_try)
+			WARNINGOUT("Failed to disable Q:%u, Saved state could be invalid\n", i);
+
 		if (hw->device_type == IFCVF_BLK)
 			ring_state = *(u32 *)(hw->lm_cfg +
 					IFCVF_LM_RING_STATE_OFFSET +