Linux CXL
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: [PATCH 2/2] cxl/region: Unregister auto-created region when assembly fails
Date: Thu, 29 Jan 2026 20:23:11 -0800	[thread overview]
Message-ID: <2a613604c0cdda6d9f838ae9b47ea6d936c5e4ce.1769746294.git.alison.schofield@intel.com> (raw)
In-Reply-To: <3bcc5143777acc6d45675d78dd8c57079406bc53.1769746294.git.alison.schofield@intel.com>

When auto-created region assembly fails the region remains registered
but disabled. The region continues to reserve its memory resource,
preventing DAX from registering the memory.

Unregister the region on assembly failure to release the resource.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 drivers/cxl/core/region.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 183cb0b49d8b..f222aa9cbda7 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -3714,6 +3714,8 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 	return cxlr;
 }
 
+static void unregister_region(void *dev);
+
 static struct cxl_region *
 cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa)
 {
@@ -3754,7 +3756,17 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
 	if (rc)
 		return rc;
 
-	attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE);
+	rc = attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE);
+	if (rc) {
+		struct cxl_port *root_port = cxlrd_to_port(cxlrd);
+
+		/* Messages at the point of failure offer more detail */
+		dev_err(&cxlr->dev,
+			"assembly failed %d, unregistering region\n", rc);
+		devm_release_action(root_port->uport_dev, unregister_region,
+				    cxlr);
+		return rc;
+	}
 
 	scoped_guard(rwsem_read, &cxl_rwsem.region) {
 		p = &cxlr->params;
-- 
2.37.3


  reply	other threads:[~2026-01-30  4:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30  4:23 [PATCH 1/2] cxl/region: Timeout auto region assembly waiting for endpoints Alison Schofield
2026-01-30  4:23 ` Alison Schofield [this message]
2026-01-30 17:45   ` [PATCH 2/2] cxl/region: Unregister auto-created region when assembly fails dan.j.williams
2026-01-31  1:04     ` Alison Schofield
2026-01-31 15:49       ` Gregory Price
2026-02-05  0:32         ` Alison Schofield
2026-02-05  4:22           ` Gregory Price
2026-02-03  3:07       ` dan.j.williams
2026-02-05  0:20         ` Alison Schofield
2026-02-05  1:03           ` dan.j.williams
2026-01-30  4:58 ` [PATCH 1/2] cxl/region: Timeout auto region assembly waiting for endpoints dan.j.williams
2026-01-30 17:42   ` Gregory Price
2026-01-30 18:26     ` dan.j.williams
2026-01-30 19:03       ` Gregory Price
2026-01-30 22:46         ` dan.j.williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a613604c0cdda6d9f838ae9b47ea6d936c5e4ce.1769746294.git.alison.schofield@intel.com \
    --to=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox