Smita Koralahalli wrote: > Refactor cxl_acpi_probe() to use a single exit path so that the fallback > DAX registration can be scheduled regardless of probe success or failure.
I do not understand why cxl_acpi needs to be responsible for this, especially in the cxl_acpi_probe() failure path. Certainly if cxl_acpi_probe() fails, that is a strong signal to give up on the CXL subsystem altogether and fallback to DAX vanilla discovery exclusively. Now, maybe the need for this becomes clearer in follow-on patches. However, I would have expected that DAX, which currently arranges for CXL to load first would just flush CXL discovery, make a decision about whether proceed with Soft Reserved, or not. Something like: DAX CXL Scan CXL Windows. Fail on any window parsing failures Launch a work item to flush PCI discovery and give a reaonable amount of time for cxl_pci and cxl_mem to quiesce <assumes CXL Windows are discovered by virtue of initcall order or MODULE_SOFTDEP("pre: cxl_acpi")> Calls a CXL flush routine to await probe completion (will always be racy) Evaluates if all Soft Reserve has cxl_region coverage if yes: skip publishing CXL intersecting Soft Reserve range in iomem, let dax_cxl attach to the cxl_region devices if no: decline the already published cxl_dax_regions, notify cxl_acpi to shutdown. Install Soft Reserved in iomem and create dax_hmem devices for the ranges per usual. Something like the above puts all the onus on device-dax to decide if CXL is meeting expectations. CXL is only responsible flagging when it thinks it has successfully completed init. If device-dax disagrees with what CXL has done it can tear down the world without ever attaching 'struct cxl_dax_region'. The success/fail is an "all or nothing" proposition. Either CXL understands everything or the user needs to work with their hardware vendor to fix whatever is giving the CXL driver indigestion. It needs to be coarse and simple because longer term the expectation is the Soft Reserved stops going to System RAM by default and instead becomes an isolated memory pool that requires opt-in. In many ways the current behavior is optimized for hardware validation not applications. > With CONFIG_CXL_ACPI enabled, future patches will bypass DAX device > registration via the HMAT and hmem drivers. To avoid missing DAX > registration for SOFT RESERVED regions, the fallback path must be > triggered regardless of probe outcome. > > No functional changes. A comment below in case something like this patch moves forward: > > Signed-off-by: Smita Koralahalli <smita.koralahallichannabasa...@amd.com> > --- > drivers/cxl/acpi.c | 30 ++++++++++++++++++------------ > 1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c > index a1a99ec3f12c..ca06d5acdf8f 100644 > --- a/drivers/cxl/acpi.c > +++ b/drivers/cxl/acpi.c > @@ -825,7 +825,7 @@ static int pair_cxl_resource(struct device *dev, void > *data) > > static int cxl_acpi_probe(struct platform_device *pdev) > { > - int rc; > + int rc = 0; > struct resource *cxl_res; > struct cxl_root *cxl_root; > struct cxl_port *root_port; > @@ -837,7 +837,7 @@ static int cxl_acpi_probe(struct platform_device *pdev) > rc = devm_add_action_or_reset(&pdev->dev, cxl_acpi_lock_reset_class, > &pdev->dev); > if (rc) > - return rc; > + goto out; No, new goto please. With cleanup.h the momentum is towards elimination of goto. If you need to do something like this, just wrap the function: diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index a1a99ec3f12c..b50d3aa45ad5 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -823,7 +823,7 @@ static int pair_cxl_resource(struct device *dev, void *data) return 0; } -static int cxl_acpi_probe(struct platform_device *pdev) +static int __cxl_acpi_probe(struct platform_device *pdev) { int rc; struct resource *cxl_res; @@ -900,6 +900,15 @@ static int cxl_acpi_probe(struct platform_device *pdev) return 0; } +static int cxl_acpi_probe(struct platform_device *pdev) +{ + int rc = __cxl_acpi_probe(pdev); + + /* do something */ + + return rc; +} + static const struct acpi_device_id cxl_acpi_ids[] = { { "ACPI0017" }, { },