Commit adfe1973 authored by Dan Williams's avatar Dan Williams

cxl/region: Fix state transitions after reset failure

Jonathan reports that failed attempts to reset a region (teardown its
HDM decoder configuration) mistakenly advance the state of the region
to "not committed". Revert to the previous state of the region on reset
failure so that the reset can be re-attempted.
Reported-by: default avatarJonathan Cameron <Jonathan.Cameron@Huawei.com>
Closes: http://lore.kernel.org/r/20230316171441.0000205b@Huawei.com
Fixes: 176baefb ("cxl/hdm: Commit decoder state to hardware")
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/168696507968.3590522.14484000711718573626.stgit@dwillia2-xfh.jf.intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 2ab47045
...@@ -296,9 +296,11 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr, ...@@ -296,9 +296,11 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr,
if (rc) if (rc)
return rc; return rc;
if (commit) if (commit) {
rc = cxl_region_decode_commit(cxlr); rc = cxl_region_decode_commit(cxlr);
else { if (rc == 0)
p->state = CXL_CONFIG_COMMIT;
} else {
p->state = CXL_CONFIG_RESET_PENDING; p->state = CXL_CONFIG_RESET_PENDING;
up_write(&cxl_region_rwsem); up_write(&cxl_region_rwsem);
device_release_driver(&cxlr->dev); device_release_driver(&cxlr->dev);
...@@ -308,18 +310,20 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr, ...@@ -308,18 +310,20 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr,
* The lock was dropped, so need to revalidate that the reset is * The lock was dropped, so need to revalidate that the reset is
* still pending. * still pending.
*/ */
if (p->state == CXL_CONFIG_RESET_PENDING) if (p->state == CXL_CONFIG_RESET_PENDING) {
rc = cxl_region_decode_reset(cxlr, p->interleave_ways); rc = cxl_region_decode_reset(cxlr, p->interleave_ways);
/*
* Revert to committed since there may still be active
* decoders associated with this region, or move forward
* to active to mark the reset successful
*/
if (rc)
p->state = CXL_CONFIG_COMMIT;
else
p->state = CXL_CONFIG_ACTIVE;
}
} }
if (rc)
goto out;
if (commit)
p->state = CXL_CONFIG_COMMIT;
else if (p->state == CXL_CONFIG_RESET_PENDING)
p->state = CXL_CONFIG_ACTIVE;
out: out:
up_write(&cxl_region_rwsem); up_write(&cxl_region_rwsem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment