Skip to contentSkip to conversation

dmaengine: idxd: Fix default allowed read buffers value in group

PATCH Applied Fenghua Yu 3 participants 3 messages Jan 27, 2023 – Feb 10, 2023

Subsystems (2)
lore
Share & tools
lore

Fenghua Yu

author
#0 lore raw

PATCH 1/1 dmaengine: idxd: Fix default allowed read buffers value in group

Currently default read buffers that is allowed in a group is 0. grpcfg will be configured to max read buffers that IDXD can support if the group's allowed read buffers value is 0. But 0 is an invalid read buffers value and user may get confused when seeing the invalid initial value 0 through sysfs interface.

To show only valid allowed read buffers value and eliminate confusion, directly initialize the allowed read buffers to IDXD's max read buffers. User still can change the value through sysfs interface.

---
 drivers/dma/idxd/device.c | 12 ++++++------
 drivers/dma/idxd/init.c   |  5 +++++
 2 files changed, 11 insertions(+), 6 deletions(-)
drivers/dma/idxd/device.c +6 -6
index 29dbb0f52e18..8d0e3aab2ad2 100644
@@ -699,7 +699,11 @@ static void idxd_groups_clear_state(struct idxd_device *idxd)
 		group->num_engines = 0;
 		group->num_wqs = 0;
 		group->use_rdbuf_limit = false;
-		group->rdbufs_allowed = 0;
+		/*
+		 * The default value is the same as the value of
+		 * total read buffers in GRPCAP.
+		 */
+		group->rdbufs_allowed = idxd->max_rdbufs;
 		group->rdbufs_reserved = 0;
 		if (idxd->hw.version < DEVICE_VERSION_2 && !tc_override) {
 			group->tc_a = 1;
@@ -934,11 +938,7 @@ static void idxd_group_flags_setup(struct idxd_device *idxd)
 			group->grpcfg.flags.tc_b = group->tc_b;
 		group->grpcfg.flags.use_rdbuf_limit = group->use_rdbuf_limit;
 		group->grpcfg.flags.rdbufs_reserved = group->rdbufs_reserved;
-		if (group->rdbufs_allowed)
-			group->grpcfg.flags.rdbufs_allowed = group->rdbufs_allowed;
-		else
-			group->grpcfg.flags.rdbufs_allowed = idxd->max_rdbufs;
-
+		group->grpcfg.flags.rdbufs_allowed = group->rdbufs_allowed;
 		group->grpcfg.flags.desc_progress_limit = group->desc_progress_limit;
 		group->grpcfg.flags.batch_progress_limit = group->batch_progress_limit;
 	}
drivers/dma/idxd/init.c +5 -0
index 529ea09c9094..b2df604e8a5f 100644
@@ -302,6 +302,11 @@ static int idxd_setup_groups(struct idxd_device *idxd)
 			group->tc_a = -1;
 			group->tc_b = -1;
 		}
+		/*
+		 * The default value is the same as the value of
+		 * total read buffers in GRPCAP.
+		 */
+		group->rdbufs_allowed = idxd->max_rdbufs;
 	}
 
 	return 0;
Signature · 1 line
2.32.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Fenghua Yu

Currently default read buffers that is allowed in a group is 0. grpcfg will be configured to max read buffers that IDXD can support if the group's allowed read buffers value is 0. But 0 is an invalid read buffers value and user may get confused when seeing the invalid initial value 0 through sysfs interface.

Quoted 7 lines

To show only valid allowed read buffers value and eliminate confusion, directly initialize the allowed read buffers to IDXD's max read buffers. User still can change the value through sysfs interface.

Quoted 51 lines
---
  drivers/dma/idxd/device.c | 12 ++++++------
  drivers/dma/idxd/init.c   |  5 +++++
  2 files changed, 11 insertions(+), 6 deletions(-)
drivers/dma/idxd/device.c +6 -6
index 29dbb0f52e18..8d0e3aab2ad2 100644
@@ -699,7 +699,11 @@ static void idxd_groups_clear_state(struct idxd_device *idxd)
  		group->num_engines = 0;
  		group->num_wqs = 0;
  		group->use_rdbuf_limit = false;
-		group->rdbufs_allowed = 0;
+		/*
+		 * The default value is the same as the value of
+		 * total read buffers in GRPCAP.
+		 */
+		group->rdbufs_allowed = idxd->max_rdbufs;
  		group->rdbufs_reserved = 0;
  		if (idxd->hw.version < DEVICE_VERSION_2 && !tc_override) {
  			group->tc_a = 1;
@@ -934,11 +938,7 @@ static void idxd_group_flags_setup(struct idxd_device *idxd)
  			group->grpcfg.flags.tc_b = group->tc_b;
  		group->grpcfg.flags.use_rdbuf_limit = group->use_rdbuf_limit;
  		group->grpcfg.flags.rdbufs_reserved = group->rdbufs_reserved;
-		if (group->rdbufs_allowed)
-			group->grpcfg.flags.rdbufs_allowed = group->rdbufs_allowed;
-		else
-			group->grpcfg.flags.rdbufs_allowed = idxd->max_rdbufs;
-
+		group->grpcfg.flags.rdbufs_allowed = group->rdbufs_allowed;
  		group->grpcfg.flags.desc_progress_limit = group->desc_progress_limit;
  		group->grpcfg.flags.batch_progress_limit = group->batch_progress_limit;
  	}
drivers/dma/idxd/init.c +5 -0
index 529ea09c9094..b2df604e8a5f 100644
@@ -302,6 +302,11 @@ static int idxd_setup_groups(struct idxd_device *idxd)
  			group->tc_a = -1;
  			group->tc_b = -1;
  		}
+		/*
+		 * The default value is the same as the value of
+		 * total read buffers in GRPCAP.
+		 */
+		group->rdbufs_allowed = idxd->max_rdbufs;
  	}
 
  	return 0;
maintainer Applied
#2 lore raw
In reply to Fenghua Yu
Quoted 9 lines · Fenghua Yu

Currently default read buffers that is allowed in a group is 0. grpcfg will be configured to max read buffers that IDXD can support if the group's allowed read buffers value is 0. But 0 is an invalid read buffers value and user may get confused when seeing the invalid initial value 0 through sysfs interface.

To show only valid allowed read buffers value and eliminate confusion, directly initialize the allowed read buffers to IDXD's max read buffers. User still can change the value through sysfs interface.

Applied, thanks

Signature · 1 line
~Vinod