Skip to contentSkip to conversation

common/sfc_efx/base: remove VQ index check during VQ start

PATCH In review [email protected] 5 participants 6 messages Jul 8, 2022 – Jul 12, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/sfc_efx/base: remove VQ index check during VQ start

From: Abhimanyu Saini <[email protected]>

The used/avail queue indexes are not bound by queue size, because the descriptor entry index is calculated by a simple modulo between queue index and queue_size

So, do not check initial used and avail queue indexes against queue size because it is possible for these indexes to be greater than queue size in the following cases:
1) The queue is created to be migrated into, or
2) The client issues a qstop/qstart after running datapath

Fixes 4dda72dbdeab3 ("common/sfc_efx/base: add base virtio support for vDPA")
---
 drivers/common/sfc_efx/base/rhead_virtio.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/common/sfc_efx/base/rhead_virtio.c +1 -11
index 335cb74..7f08717 100644
@@ -47,14 +47,6 @@
 		goto fail2;
 	}
 
-	if (evvdp != NULL) {
-		if ((evvdp->evvd_vq_cidx > evvcp->evvc_vq_size) ||
-		    (evvdp->evvd_vq_pidx > evvcp->evvc_vq_size)) {
-			rc = EINVAL;
-			goto fail3;
-		}
-	}
-
 	req.emr_cmd = MC_CMD_VIRTIO_INIT_QUEUE;
 	req.emr_in_buf = payload;
 	req.emr_in_length = MC_CMD_VIRTIO_INIT_QUEUE_REQ_LEN;
@@ -116,15 +108,13 @@
 
 	if (req.emr_rc != 0) {
 		rc = req.emr_rc;
-		goto fail4;
+		goto fail3;
 	}
 
 	evvp->evv_vi_index = vi_index;
 
 	return (0);
 
-fail4:
-	EFSYS_PROBE(fail4);
 fail3:
 	EFSYS_PROBE(fail3);
 fail2:
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): SA0PR12MB43523906A4BF7F13DF9B9D0FE3829@SA0PR12MB4352.namprd12.prod.outlook.com

Acked-by Vijay Srivastava
#2 lore raw
Quoted 56 lines

From: Abhimanyu Saini <[email protected]>

The used/avail queue indexes are not bound by queue size, because the descriptor entry index is calculated by a simple modulo between queue index and queue_size

So, do not check initial used and avail queue indexes against queue size because it is possible for these indexes to be greater than queue size in the following cases:
1) The queue is created to be migrated into, or
2) The client issues a qstop/qstart after running datapath

Fixes 4dda72dbdeab3 ("common/sfc_efx/base: add base virtio support for

vDPA")
Cc: [email protected]

---
drivers/common/sfc_efx/base/rhead_virtio.c | 12 +-----------

1 file changed, 1 insertion(+), 11 deletions(-)
drivers/common/sfc_efx/base/rhead_virtio.c +0 -8
index 335cb74..7f08717 100644
@@ -47,14 +47,6 @@
 		goto fail2;
 	}
 
-	if (evvdp != NULL) {
-		if ((evvdp->evvd_vq_cidx > evvcp->evvc_vq_size) ||
-		    (evvdp->evvd_vq_pidx > evvcp->evvc_vq_size)) {
-			rc = EINVAL;
-			goto fail3;
-		}
-	}
-
 	req.emr_cmd = MC_CMD_VIRTIO_INIT_QUEUE;
 	req.emr_in_buf = payload;
 	req.emr_in_length = MC_CMD_VIRTIO_INIT_QUEUE_REQ_LEN; @@ -

116,15 +108,13 @@

	if (req.emr_rc != 0) {
		rc = req.emr_rc;
drivers/common/sfc_efx/base/rhead_virtio.c +1 -1
-		goto fail4;
+		goto fail3;
	}

	evvp->evv_vi_index = vi_index;

	return (0);
drivers/common/sfc_efx/base/rhead_virtio.c +0 -2
-fail4:
-	EFSYS_PROBE(fail4);

fail3:

Quoted 4 lines
	EFSYS_PROBE(fail3);

fail2:
--
1.8.3.1

#4 lore raw

Hello,

Quoted 7 lines · Andrew Rybchenko
Quoted 1 line · Vijay

Please, send a patch to MAINTAINERS to update your E-mail address from Xilinx to AMD domain.

Please register this mail address to the mailing list, too. Your recent messages from @amd.com were waiting in the moderation queue.

Signature · 1 line
David Marchand
#5 lore raw
In reply to [email protected]
Quoted 5 lines · On 7/8/22 10:37, [email protected] wrote:

From: Abhimanyu Saini <[email protected]>

The used/avail queue indexes are not bound by queue size, because the descriptor entry index is calculated by a simple modulo between queue index and queue_size

"is calculated" is a bit vague since looking at the code I've failed to find the place where modulo operation is done. Don't we need to apply it these values are put into MCDI message?

Quoted 52 lines

So, do not check initial used and avail queue indexes against queue size because it is possible for these indexes to be greater than queue size in the following cases:
1) The queue is created to be migrated into, or
2) The client issues a qstop/qstart after running datapath

Fixes 4dda72dbdeab3 ("common/sfc_efx/base: add base virtio support for vDPA")
---
  drivers/common/sfc_efx/base/rhead_virtio.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
drivers/common/sfc_efx/base/rhead_virtio.c +1 -11
index 335cb74..7f08717 100644
@@ -47,14 +47,6 @@
  		goto fail2;
  	}
 
-	if (evvdp != NULL) {
-		if ((evvdp->evvd_vq_cidx > evvcp->evvc_vq_size) ||
-		    (evvdp->evvd_vq_pidx > evvcp->evvc_vq_size)) {
-			rc = EINVAL;
-			goto fail3;
-		}
-	}
-
  	req.emr_cmd = MC_CMD_VIRTIO_INIT_QUEUE;
  	req.emr_in_buf = payload;
  	req.emr_in_length = MC_CMD_VIRTIO_INIT_QUEUE_REQ_LEN;
@@ -116,15 +108,13 @@
 
  	if (req.emr_rc != 0) {
  		rc = req.emr_rc;
-		goto fail4;
+		goto fail3;
  	}
 
  	evvp->evv_vi_index = vi_index;
 
  	return (0);
 
-fail4:
-	EFSYS_PROBE(fail4);
  fail3:
  	EFSYS_PROBE(fail3);
  fail2:
#6 lore raw

[AMD Official Use Only - General]

Quoted 11 lines · On 7/8/22 10:37, [email protected] wrote:
Quoted 5 lines

From: Abhimanyu Saini <[email protected]>

The used/avail queue indexes are not bound by queue size, because the descriptor entry index is calculated by a simple modulo between queue index and queue_size

"is calculated" is a bit vague since looking at the code I've failed to find the place where modulo operation is done. Don't we need to apply it these values are put into MCDI message?

The values are added to the MCDI as is and,
the modulo is performed by the hardware.

I can append the commit message to reflect the same?

Quoted 54 lines
Quoted 9 lines

So, do not check initial used and avail queue indexes against queue size because it is possible for these indexes to be greater than queue size in the following cases:
1) The queue is created to be migrated into, or
2) The client issues a qstop/qstart after running datapath

Fixes 4dda72dbdeab3 ("common/sfc_efx/base: add base virtio support for

vDPA")

Review

Quoted 8 lines
---
  drivers/common/sfc_efx/base/rhead_virtio.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/common/sfc_efx/base/rhead_virtio.c

Quoted 35 lines

index 335cb74..7f08717 100644

drivers/common/sfc_efx/base/rhead_virtio.c +1 -11
@@ -47,14 +47,6 @@
              goto fail2;
      }
 
-     if (evvdp != NULL) {
-             if ((evvdp->evvd_vq_cidx > evvcp->evvc_vq_size) ||
-                 (evvdp->evvd_vq_pidx > evvcp->evvc_vq_size)) {
-                     rc = EINVAL;
-                     goto fail3;
-             }
-     }
-
      req.emr_cmd = MC_CMD_VIRTIO_INIT_QUEUE;
      req.emr_in_buf = payload;
      req.emr_in_length = MC_CMD_VIRTIO_INIT_QUEUE_REQ_LEN;
@@ -116,15 +108,13 @@
 
      if (req.emr_rc != 0) {
              rc = req.emr_rc;
-             goto fail4;
+             goto fail3;
      }
 
      evvp->evv_vi_index = vi_index;
 
      return (0);
 
-fail4:
-     EFSYS_PROBE(fail4);
  fail3:
      EFSYS_PROBE(fail3);
  fail2: