Re: [PATCH] cxl/region: Hold memdev lock during region poison injection/clear
From: Li Ming
Date: Fri Mar 20 2026 - 08:53:47 EST
在 2026/3/19 22:47, Dave Jiang 写道:
On 3/19/26 7:12 AM, Li Ming wrote:
cxl_dpa_to_region() has expectations that cxlmd->endpoint remains validThis is the patch I dropped right? I see the review tags are dropped. Does it need to be re-reviewed? Are there new changes?
for the duration of the call. When userspace performs poison injection
or clearing on a region via debugfs, holding cxl_rwsem.region and
cxl_rwsem.dpa alone is insufficient, these locks do not prevent the
retrieved CXL memdev from being destroyed, nor do they protect against
concurrent driver detachment. Therefore, hold CXL memdev lock in the
debugfs callbacks to ensure the cxlmd->dev.driver remains stable for the
entire execution of the callback functions.
To keep lock sequence(cxlmd.dev -> cxl_rwsem.region -> cxl_rwsem.dpa)
for avoiding deadlock. the interfaces have to find out the correct CXL
memdev at first, holding lock in the sequence then checking if the DPA
data has been changed before holding locks.
Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx>
Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
DJ
It is not, the patch you dropped is for ensuring memdev poison injection/clearing would not access an invalid cxlmd->endpoint.
The changes in this patch is for region poison injection/clearing.
But you can keep dropping the patch you mentioned at present, I will tell you after confirming the solution.
Thanks
Ming