Skip to content
/ linux Public

Commit 738fba2

Browse files
Yuxiong WangSasha Levin
authored andcommitted
cxl: Fix premature commit_end increment on decoder commit failure
[ Upstream commit 7b6f9d9 ] In cxl_decoder_commit(), commit_end is incremented before verifying whether the commit succeeded, and the CXL_DECODER_F_ENABLE bit in cxld->flags is only set after a successful commit. As a result, if the commit fails, commit_end has been incremented and cxld->reset() has no effect since the flag is not set, so commit_end remains incorrectly incremented. The inconsistency between commit_end and CXL_DECODER_F_ENABLE causes failure during subsequent either commit or reset operations. Fix this by incrementing commit_end only after confirming the commit succeeded. Also, remove the ineffective cxld->reset() call. According to CXL Spec r4.0 8.2.4.20.12 Committing Decoder Programming, since cxld_await_commit() has cleared the decoder commit bit on failure, no additional reset is required. [dj: Fixed commit log 80 char wrapping. ] [dj: Fix "Fixes" tag to correct hash length. ] [dj: Change spec to r4.0. ] Fixes: 176baef ("cxl/hdm: Commit decoder state to hardware") Signed-off-by: Yuxiong Wang <yuxiong.wang@linux.alibaba.com> Acked-by: Huang Ying <ying.huang@linux.alibaba.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20260129064552.31180-1-yuxiong.wang@linux.alibaba.com Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 97a907b commit 738fba2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/cxl/core/hdm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,14 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)
628628
writel(ctrl, hdm + CXL_HDM_DECODER0_CTRL_OFFSET(id));
629629
up_read(&cxl_dpa_rwsem);
630630

631-
port->commit_end++;
632631
rc = cxld_await_commit(hdm, cxld->id);
633632
err:
634633
if (rc) {
635634
dev_dbg(&port->dev, "%s: error %d committing decoder\n",
636635
dev_name(&cxld->dev), rc);
637-
cxld->reset(cxld);
638636
return rc;
639637
}
638+
port->commit_end++;
640639
cxld->flags |= CXL_DECODER_F_ENABLE;
641640

642641
return 0;

0 commit comments

Comments
 (0)