DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dma/idxd: fix burst capacity calculation
@ 2021-12-20 17:05 Bruce Richardson
  2022-01-04 17:16 ` Kevin Laatz
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Bruce Richardson @ 2021-12-20 17:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, kevin.laatz, stable

When the maximum burst size supported by HW is less than the available
ring space, incorrect capacity was returned when there was already some
jobs queued up for submission. This was because the capacity calculation
failed to subtract the number of already-enqueued jobs from the max
burst size. After subtraction is done, ensure that any negative values
(which should never occur if the user respects the reported limits), are
clamped to zero.

Fixes: 9459de4edc99 ("dma/idxd: add burst capacity")
Cc: kevin.laatz@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/dma/idxd/idxd_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/idxd/idxd_common.c b/drivers/dma/idxd/idxd_common.c
index fc11b11337..4442d1cbbd 100644
--- a/drivers/dma/idxd/idxd_common.c
+++ b/drivers/dma/idxd/idxd_common.c
@@ -485,7 +485,9 @@ idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused)
 		write_idx += idxd->desc_ring_mask + 1;
 	used_space = write_idx - idxd->ids_returned;

-	return RTE_MIN((idxd->desc_ring_mask - used_space), idxd->max_batch_size);
+	const int ret = RTE_MIN((idxd->desc_ring_mask - used_space),
+			(idxd->max_batch_size - idxd->batch_size));
+	return ret < 0 ? 0 : (uint16_t)ret;
 }

 int
--
2.32.0


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

end of thread, other threads:[~2022-01-20 13:07 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 17:05 [PATCH] dma/idxd: fix burst capacity calculation Bruce Richardson
2022-01-04 17:16 ` Kevin Laatz
2022-01-05  1:32   ` Hu, Jiayu
2022-01-10 13:09 ` Pai G, Sunil
2022-01-10 13:25   ` Bruce Richardson
2022-01-10 13:44     ` Pai G, Sunil
2022-01-10 16:18       ` Bruce Richardson
2022-01-11 13:41 ` [PATCH v2 0/4] fixes for dma/idxd Bruce Richardson
2022-01-11 13:41   ` [PATCH v2 1/4] dma/idxd: fix burst capacity calculation Bruce Richardson
2022-01-11 13:41   ` [PATCH v2 2/4] dma/idxd: fix paths to driver sysfs directory Bruce Richardson
2022-01-11 16:50     ` Kevin Laatz
2022-01-11 13:41   ` [PATCH v2 3/4] dma/idxd: fix wrap-around in burst capacity calculation Bruce Richardson
2022-01-11 13:45     ` Pai G, Sunil
2022-01-11 16:50     ` Kevin Laatz
2022-01-11 13:41   ` [PATCH v2 4/4] test_dmadev: increase iterations of capacity test case Bruce Richardson
2022-01-11 16:50     ` Kevin Laatz
2022-01-20 13:06   ` [PATCH v2 0/4] fixes for dma/idxd Thomas Monjalon

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).