| From 119ff88ad7285cd133dd629c3102ec49d5f14425 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 29 Jan 2026 14:45:52 +0800 |
| Subject: cxl: Fix premature commit_end increment on decoder commit failure |
| |
| From: Yuxiong Wang <yuxiong.wang@linux.alibaba.com> |
| |
| [ Upstream commit 7b6f9d9b1ea05c9c22570126547c780e8c6c3f62 ] |
| |
| 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: 176baefb2eb5 ("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> |
| --- |
| drivers/cxl/core/hdm.c | 3 +-- |
| 1 file changed, 1 insertion(+), 2 deletions(-) |
| |
| diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c |
| index a7ad730763e85..bc4b0c8607258 100644 |
| --- a/drivers/cxl/core/hdm.c |
| +++ b/drivers/cxl/core/hdm.c |
| @@ -844,14 +844,13 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld) |
| scoped_guard(rwsem_read, &cxl_rwsem.dpa) |
| setup_hw_decoder(cxld, hdm); |
| |
| - port->commit_end++; |
| rc = cxld_await_commit(hdm, cxld->id); |
| if (rc) { |
| dev_dbg(&port->dev, "%s: error %d committing decoder\n", |
| dev_name(&cxld->dev), rc); |
| - cxld->reset(cxld); |
| return rc; |
| } |
| + port->commit_end++; |
| cxld->flags |= CXL_DECODER_F_ENABLE; |
| |
| return 0; |
| -- |
| 2.51.0 |
| |