Skip to content

Commit 6835130

Browse files
djbwdavejiang
authored andcommitted
cxl/mbox: Convert poison list mutex to ACQUIRE()
Towards removing all explicit unlock calls in the CXL subsystem, convert the conditional poison list mutex to use a conditional lock guard. Rename the lock to have the compiler validate that all existing call sites are converted. Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Alison Schofield <[email protected]> Cc: Vishal Verma <[email protected]> Cc: Ira Weiny <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Signed-off-by: Dan Williams <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent 857d18f commit 6835130

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

drivers/cxl/core/mbox.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,8 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
14011401
int nr_records = 0;
14021402
int rc;
14031403

1404-
rc = mutex_lock_interruptible(&mds->poison.lock);
1405-
if (rc)
1404+
ACQUIRE(mutex_intr, lock)(&mds->poison.mutex);
1405+
if ((rc = ACQUIRE_ERR(mutex_intr, &lock)))
14061406
return rc;
14071407

14081408
po = mds->poison.list_out;
@@ -1437,7 +1437,6 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
14371437
}
14381438
} while (po->flags & CXL_POISON_FLAG_MORE);
14391439

1440-
mutex_unlock(&mds->poison.lock);
14411440
return rc;
14421441
}
14431442
EXPORT_SYMBOL_NS_GPL(cxl_mem_get_poison, "CXL");
@@ -1473,7 +1472,7 @@ int cxl_poison_state_init(struct cxl_memdev_state *mds)
14731472
return rc;
14741473
}
14751474

1476-
mutex_init(&mds->poison.lock);
1475+
mutex_init(&mds->poison.mutex);
14771476
return 0;
14781477
}
14791478
EXPORT_SYMBOL_NS_GPL(cxl_poison_state_init, "CXL");

drivers/cxl/cxlmem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ enum security_cmd_enabled_bits {
254254
* @max_errors: Maximum media error records held in device cache
255255
* @enabled_cmds: All poison commands enabled in the CEL
256256
* @list_out: The poison list payload returned by device
257-
* @lock: Protect reads of the poison list
257+
* @mutex: Protect reads of the poison list
258258
*
259259
* Reads of the poison list are synchronized to ensure that a reader
260260
* does not get an incomplete list because their request overlapped
@@ -265,7 +265,7 @@ struct cxl_poison_state {
265265
u32 max_errors;
266266
DECLARE_BITMAP(enabled_cmds, CXL_POISON_ENABLED_MAX);
267267
struct cxl_mbox_poison_out *list_out;
268-
struct mutex lock; /* Protect reads of poison list */
268+
struct mutex mutex; /* Protect reads of poison list */
269269
};
270270

271271
/*

0 commit comments

Comments
 (0)