cxl/memdev: Hold memdev lock during memdev poison injection/clear
Li Ming
reviewerPATCH v3 1/1 cxl/memdev: Hold memdev lock during memdev poison injection/clear
cxl_dpa_to_region() assumes that it is running a context where it is not racing changes to "cxlmd->dev.driver". Acquire the memdev device lock in the debugfs entry points to preclude debugfs usage racing cxl_mem driver detach.
---
This patch originally belonged to the patchset[1], but was not merged into mainline together with the rest of the patchset. Resend this patch individually.
Changes in v3:
- Update changelog. (Dan)
- Add review tag from Dan.
Changes in v2:
- Move hoding CXL memdev lock to cxl_debugfs_poison_inject/clear(). (Alison)
--- drivers/cxl/mem.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/cxl/mem.c +10 -0
@@ -48,6 +48,11 @@ static int cxl_mem_dpa_show(struct seq_file *file, void *data)static int cxl_debugfs_poison_inject (void *data,u64 dpa) {struct cxl_memdev *cxlmd = data; +int rc; + +ACQUIRE (device_intr, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +return rc;return cxl_inject_poison (cxlmd, dpa); }
@@ -58,6 +63,11 @@ DEFINE_DEBUGFS_ATTRIBUTE(cxl_poison_inject_fops, NULL,static int cxl_debugfs_poison_clear (void *data,u64 dpa) {struct cxl_memdev *cxlmd = data; +int rc; + +ACQUIRE (device_intr, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +return rc;return cxl_clear_poison (cxlmd, dpa); }
Signature · 1 line
2.43.0
Quoted 10 lines · Li Ming
cxl_dpa_to_region()assumes that it is running a context where it is not racing changes to "cxlmd->dev.driver". Acquire the memdev device lock in the debugfs entry points to preclude debugfs usage racingcxl_memdriver detach.Suggested-by Dan Williams <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Alison Schofield <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Li Ming <[email protected]>
Applied to cxl/nextc13052967873
Quoted 44 lines
---
This patch originally belonged to the patchset[1], but was not merged into mainline together with the rest of the patchset. Resend this patch individually.Changes in v3:
- Update changelog. (Dan)
- Add review tag from Dan.
Changes in v2:
- Move hoding CXL memdev lock to cxl_debugfs_poison_inject/clear(). (Alison)--- drivers/cxl/mem.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/cxl/mem.c +10
-0@@ -48,6 +48,11 @@ static int cxl_mem_dpa_show(struct seq_file *file, void *data)static int cxl_debugfs_poison_inject (void *data,u64 dpa) {struct cxl_memdev *cxlmd = data; +int rc; + +ACQUIRE (device_intr, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +return rc;return cxl_inject_poison (cxlmd, dpa); }@@ -58,6 +63,11 @@ DEFINE_DEBUGFS_ATTRIBUTE(cxl_poison_inject_fops, NULL,static int cxl_debugfs_poison_clear (void *data,u64 dpa) {struct cxl_memdev *cxlmd = data; +int rc; + +ACQUIRE (device_intr, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +return rc;return cxl_clear_poison (cxlmd, dpa); }