Linux CXL
 help / color / mirror / Atom feed
* [PATCH v3] cxl: Add cxl_region_rwsem around commit_end write during decoder enumeration
@ 2023-11-17 20:18 Dave Jiang
  2023-11-20 16:04 ` Davidlohr Bueso
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Jiang @ 2023-11-17 20:18 UTC (permalink / raw)
  To: linux-cxl
  Cc: dan.j.williams, ira.weiny, vishal.l.verma, alison.schofield,
	Jonathan.Cameron, dave, peterz

init_hdm_decoder() modifies port->commit_end without taking the
cxl_region_rwsem. An assert splat emitted by cxl_num_decoders_committed().
However looking at the code, it looks like the write version of the rwsem
needs to be taken due to the modification of commit_end. Wrap the write
version of the rwsem around reading and writing of commit_end.

Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
v3:
- Just do the one line change. (Dan)
v2:
- Add changes from Ira and moving the lock block
- Add suggestion from Dan on using guard()
---
 drivers/cxl/core/hdm.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index 1cc9be85ba4c..529baa8a1759 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -839,6 +839,8 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
 			cxld->target_type = CXL_DECODER_HOSTONLYMEM;
 		else
 			cxld->target_type = CXL_DECODER_DEVMEM;
+
+		guard(rwsem_write)(&cxl_region_rwsem);
 		if (cxld->id != cxl_num_decoders_committed(port)) {
 			dev_warn(&port->dev,
 				 "decoder%d.%d: Committed out of order\n",



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

end of thread, other threads:[~2023-11-30 16:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 20:18 [PATCH v3] cxl: Add cxl_region_rwsem around commit_end write during decoder enumeration Dave Jiang
2023-11-20 16:04 ` Davidlohr Bueso
2023-11-20 17:04   ` Dave Jiang
2023-11-22 21:43   ` Dan Williams
2023-11-23  1:02     ` Dan Williams
2023-11-27 17:09       ` Dave Jiang
2023-11-27 17:39       ` Davidlohr Bueso
2023-11-30  1:01         ` Dan Williams
2023-11-30 16:15           ` Davidlohr Bueso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox