Skip to content

Commit 695d945

Browse files
djbwdavejiang
authored andcommitted
cxl/region: Move ready-to-probe state check to a helper
Rather than unlocking the region rwsem in the middle of cxl_region_probe() create a helper for determining when the region is ready-to-probe. Cc: Davidlohr Bueso <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Alison Schofield <[email protected]> Cc: Vishal Verma <[email protected]> Cc: Ira Weiny <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Dan Williams <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Fabio M. De Francesco <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent a235d7d commit 695d945

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/cxl/core/region.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,9 +3572,8 @@ static void shutdown_notifiers(void *_cxlr)
35723572
unregister_mt_adistance_algorithm(&cxlr->adist_notifier);
35733573
}
35743574

3575-
static int cxl_region_probe(struct device *dev)
3575+
static int cxl_region_can_probe(struct cxl_region *cxlr)
35763576
{
3577-
struct cxl_region *cxlr = to_cxl_region(dev);
35783577
struct cxl_region_params *p = &cxlr->params;
35793578
int rc;
35803579

@@ -3597,15 +3596,28 @@ static int cxl_region_probe(struct device *dev)
35973596
goto out;
35983597
}
35993598

3600-
/*
3601-
* From this point on any path that changes the region's state away from
3602-
* CXL_CONFIG_COMMIT is also responsible for releasing the driver.
3603-
*/
36043599
out:
36053600
up_read(&cxl_region_rwsem);
36063601

36073602
if (rc)
36083603
return rc;
3604+
return 0;
3605+
}
3606+
3607+
static int cxl_region_probe(struct device *dev)
3608+
{
3609+
struct cxl_region *cxlr = to_cxl_region(dev);
3610+
struct cxl_region_params *p = &cxlr->params;
3611+
int rc;
3612+
3613+
rc = cxl_region_can_probe(cxlr);
3614+
if (rc)
3615+
return rc;
3616+
3617+
/*
3618+
* From this point on any path that changes the region's state away from
3619+
* CXL_CONFIG_COMMIT is also responsible for releasing the driver.
3620+
*/
36093621

36103622
cxlr->memory_notifier.notifier_call = cxl_region_perf_attrs_callback;
36113623
cxlr->memory_notifier.priority = CXL_CALLBACK_PRI;

0 commit comments

Comments
 (0)