Commit 0a70b7cd authored by Alison Schofield's avatar Alison Schofield Committed by Dave Jiang
Browse files

cxl: Test CXL_DECODER_F_LOCK as a bitmask



The CXL decoder flags are defined as bitmasks, not bit indices.
Using test_bit() to check them interprets the mask value as a bit
index, which is the wrong test.

For CXL_DECODER_F_LOCK the test reads beyond the defined bits, causing
the test to always return false and allowing resets that should have
been blocked.

Replace test_bit() with a bitmask check.

Fixes: 2230c4bd ("cxl: Add handling of locked CXL decoder")
Signed-off-by: default avatarAlison Schofield <alison.schofield@intel.com>
Reviewed-by: default avatarGregory Price <gourry@gourry.net>
Tested-by: default avatarGregory Price <gourry@gourry.net>
Link: https://patch.msgid.link/98851c4770e4631753cf9f75b58a3a6daeca2ea2.1771873256.git.alison.schofield@intel.com


Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
parent 60b5d1f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -904,7 +904,7 @@ static void cxl_decoder_reset(struct cxl_decoder *cxld)
	if ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)
		return;

	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags))
	if (cxld->flags & CXL_DECODER_F_LOCK)
		return;

	if (port->commit_end == id)
+1 −1
Original line number Diff line number Diff line
@@ -1100,7 +1100,7 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
static void cxl_region_setup_flags(struct cxl_region *cxlr,
				   struct cxl_decoder *cxld)
{
	if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) {
	if (cxld->flags & CXL_DECODER_F_LOCK) {
		set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
		clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags);
	}