Linux CXL
 help / color / mirror / Atom feed
From: Dan Williams <djbw@kernel.org>
To: linux-cxl@vger.kernel.org
Cc: dave.jiang@intel.com, alejandro.lucero-palau@amd.com, jic23@kernel.org
Subject: [PATCH 3/5] cxl/memdev: Pin parents for entire memdev lifetime
Date: Tue, 19 May 2026 14:01:56 -0700	[thread overview]
Message-ID: <20260519210158.1499795-4-djbw@kernel.org> (raw)
In-Reply-To: <20260519210158.1499795-1-djbw@kernel.org>

In order to be able to manage the driver that uses a memdev attach
mechanism the parent needs to stick around for the
device_release_driver(cxlmd->dev.parent) event.

Fixes: 29317f8dc6ed ("cxl/mem: Introduce cxl_memdev_attach for CXL-dependent operation")
Signed-off-by: Dan Williams <djbw@kernel.org>
---
 drivers/cxl/core/memdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index 80e65690eb77..91c99eeea92c 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -25,9 +25,11 @@ static DEFINE_IDA(cxl_memdev_ida);
 static void cxl_memdev_release(struct device *dev)
 {
 	struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
+	struct device *parent = dev->parent;
 
 	ida_free(&cxl_memdev_ida, cxlmd->id);
 	kfree(cxlmd);
+	put_device(parent);
 }
 
 static char *cxl_memdev_devnode(const struct device *dev, umode_t *mode, kuid_t *uid,
@@ -707,7 +709,7 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,
 	dev = &cxlmd->dev;
 	device_initialize(dev);
 	lockdep_set_class(&dev->mutex, &cxl_memdev_key);
-	dev->parent = cxlds->dev;
+	dev->parent = get_device(cxlds->dev);
 	dev->bus = &cxl_bus_type;
 	dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
 	dev->type = &cxl_memdev_type;
-- 
2.53.0


  parent reply	other threads:[~2026-05-19 21:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 21:01 [PATCH 0/5] cxl: Introduce devm_cxl_probe_mem() and fix region deletion Dan Williams
2026-05-19 21:01 ` [PATCH 1/5] cxl/region: Block region delete during region creation Dan Williams
2026-05-19 21:59   ` Dave Jiang
2026-05-21 14:32   ` Alejandro Lucero Palau
2026-05-19 21:01 ` [PATCH 2/5] cxl/region: Resolve region deletion races Dan Williams
2026-05-19 22:17   ` Dave Jiang
2026-05-21 14:33   ` Alejandro Lucero Palau
2026-05-19 21:01 ` Dan Williams [this message]
2026-05-19 22:24   ` [PATCH 3/5] cxl/memdev: Pin parents for entire memdev lifetime Dave Jiang
2026-05-21 14:33   ` Alejandro Lucero Palau
2026-05-19 21:01 ` [PATCH 4/5] cxl/memdev: Introduce cxl_class_memdev_type Dan Williams
2026-05-19 22:50   ` Dave Jiang
2026-05-21 14:33   ` Alejandro Lucero Palau
2026-05-19 21:01 ` [PATCH 5/5] cxl/region: Introduce devm_cxl_probe_mem() Dan Williams
2026-05-19 22:56   ` Dave Jiang
2026-05-20 17:37   ` Dave Jiang
2026-05-21 14:44   ` Alejandro Lucero Palau
2026-05-21 14:31 ` [PATCH 0/5] cxl: Introduce devm_cxl_probe_mem() and fix region deletion Alejandro Lucero Palau
2026-06-05  7:56   ` Alejandro Lucero Palau
2026-06-05 15:20     ` Dave Jiang
2026-06-06  6:48       ` Alejandro Lucero Palau
2026-06-08 19:30         ` Dave Jiang
2026-06-12 20:52 ` Dave Jiang

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=20260519210158.1499795-4-djbw@kernel.org \
    --to=djbw@kernel.org \
    --cc=alejandro.lucero-palau@amd.com \
    --cc=dave.jiang@intel.com \
    --cc=jic23@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    /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