Skip to content

Commit 9113b24

Browse files
author
John W. Linville
committed
cxl/edac: Fix the min_scrub_cycle of a region miscalculation
JIRA: https://issues.redhat.com/browse/RHEL-107284 commit fdc9be9 Author: Li Ming <ming.li@zohomail.com> Date: Tue Jun 3 18:43:13 2025 +0800 cxl/edac: Fix the min_scrub_cycle of a region miscalculation When trying to update the scrub_cycle value of a cxl region, which means updating the scrub_cycle value of each memdev under a cxl region. cxl driver needs to guarantee the new scrub_cycle value is greater than the min_scrub_cycle value of a memdev, otherwise the updating operation will fail(Per Table 8-223 in CXL r3.2 section 8.2.10.9.11.1). Current implementation logic of getting the min_scrub_cycle value of a cxl region is that getting the min_scrub_cycle value of each memdevs under the cxl region, then using the minimum min_scrub_cycle value as the region's min_scrub_cycle. Checking if the new scrub_cycle value is greater than this value. If yes, updating the new scrub_cycle value to each memdevs. The issue is that the new scrub_cycle value is possibly greater than the minimum min_scrub_cycle value of all memdevs but less than the maximum min_scrub_cycle value of all memdevs if memdevs have a different min_scrub_cycle value. The updating operation will always fail on these memdevs which have a greater min_scrub_cycle than the new scrub_cycle. The correct implementation logic is to get the maximum value of these memdevs' min_scrub_cycle, check if the new scrub_cycle value is greater than the value. If yes, the new scrub_cycle value is fit for the region. The change also impacts the result of cxl_patrol_scrub_get_min_scrub_cycle(), the interface returned the minimum min_scrub_cycle value among all memdevs under the region before the change. The interface will return the maximum min_scrub_cycle value among all memdevs under the region with the change. Signed-off-by: Li Ming <ming.li@zohomail.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Shiju Jose <shiju.jose@huawei.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://patch.msgid.link/20250603104314.25569-1-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: John W. Linville <linville@redhat.com>
1 parent 0f9ba88 commit 9113b24

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/cxl/core/edac.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ static int cxl_scrub_get_attrbs(struct cxl_patrol_scrub_context *cxl_ps_ctx,
102102
u8 *cap, u16 *cycle, u8 *flags, u8 *min_cycle)
103103
{
104104
struct cxl_mailbox *cxl_mbox;
105-
u8 min_scrub_cycle = U8_MAX;
106105
struct cxl_region_params *p;
107106
struct cxl_memdev *cxlmd;
108107
struct cxl_region *cxlr;
108+
u8 min_scrub_cycle = 0;
109109
int i, ret;
110110

111111
if (!cxl_ps_ctx->cxlr) {
@@ -132,8 +132,12 @@ static int cxl_scrub_get_attrbs(struct cxl_patrol_scrub_context *cxl_ps_ctx,
132132
if (ret)
133133
return ret;
134134

135+
/*
136+
* The min_scrub_cycle of a region is the max of minimum scrub
137+
* cycles supported by memdevs that back the region.
138+
*/
135139
if (min_cycle)
136-
min_scrub_cycle = min(*min_cycle, min_scrub_cycle);
140+
min_scrub_cycle = max(*min_cycle, min_scrub_cycle);
137141
}
138142

139143
if (min_cycle)

0 commit comments

Comments
 (0)