From: Junjie Cao <junjie.cao@intel.com>
To: qemu-devel@nongnu.org
Cc: Jonathan Cameron <jic23@kernel.org>,
linux-cxl@vger.kernel.org, junjie.cao@intel.com
Subject: [PATCH 3/6] hw/cxl: convert cxl-type3 to three-phase reset
Date: Fri, 26 Jun 2026 14:21:46 +0800 [thread overview]
Message-ID: <20260626062149.1844334-4-junjie.cao@intel.com> (raw)
In-Reply-To: <20260626062149.1844334-1-junjie.cao@intel.com>
Replace the deprecated device_class_set_legacy_reset() registration
with the three-phase resettable interface, following the pattern
already established by the CXL root port (cxl_rp_reset_hold).
Only the hold phase is needed; enter and exit are left NULL. The
parent hold phase is chained for correctness: TYPE_PCI_DEVICE installs
no hold phase today, so parent_phases.hold is currently NULL and the
chained call is a no-op, but capturing and invoking it is the correct
forward-compatible pattern and mirrors cxl_rp_reset_hold().
No functional change — the reset body is identical; only the
registration path and function signature change.
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
---
hw/mem/cxl_type3.c | 16 ++++++++++++----
include/hw/cxl/cxl_device.h | 2 ++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index 4ac6eaa950..b842e71c66 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -1326,13 +1326,18 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data,
return address_space_write(as, dpa_offset, attrs, &data, size);
}
-static void ct3d_reset(DeviceState *dev)
+static void ct3d_reset_hold(Object *obj, ResetType type)
{
- CXLType3Dev *ct3d = CXL_TYPE3(dev);
+ CXLType3Dev *ct3d = CXL_TYPE3(obj);
+ CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(obj);
uint32_t *reg_state = ct3d->cxl_cstate.crb.cache_mem_registers;
uint32_t *write_msk = ct3d->cxl_cstate.crb.cache_mem_regs_write_mask;
- pcie_cap_fill_link_ep_usp(PCI_DEVICE(dev), ct3d->width, ct3d->speed,
+ if (cvc->parent_phases.hold) {
+ cvc->parent_phases.hold(obj, type);
+ }
+
+ pcie_cap_fill_link_ep_usp(PCI_DEVICE(obj), ct3d->width, ct3d->speed,
ct3d->flitmode);
cxl_component_register_init_common(reg_state, write_msk,
CXL2_TYPE3_DEVICE, ct3d->hdmdb);
@@ -2464,6 +2469,7 @@ static void ct3_class_init(ObjectClass *oc, const void *data)
DeviceClass *dc = DEVICE_CLASS(oc);
PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
CXLType3Class *cvc = CXL_TYPE3_CLASS(oc);
+ ResettableClass *rc = RESETTABLE_CLASS(oc);
pc->realize = ct3_realize;
pc->exit = ct3_exit;
@@ -2477,9 +2483,11 @@ static void ct3_class_init(ObjectClass *oc, const void *data)
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->desc = "CXL Memory Device (Type 3)";
- device_class_set_legacy_reset(dc, ct3d_reset);
device_class_set_props(dc, ct3_props);
+ resettable_class_set_parent_phases(rc, NULL, ct3d_reset_hold, NULL,
+ &cvc->parent_phases);
+
cvc->get_lsa_size = get_lsa_size;
cvc->get_lsa = get_lsa;
cvc->set_lsa = set_lsa;
diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
index ba551fa5f9..b7e20e3fe4 100644
--- a/include/hw/cxl/cxl_device.h
+++ b/include/hw/cxl/cxl_device.h
@@ -805,6 +805,8 @@ struct CXLType3Class {
/* Private */
PCIDeviceClass parent_class;
+ ResettablePhases parent_phases;
+
/* public */
uint64_t (*get_lsa_size)(CXLType3Dev *ct3d);
--
2.43.0
next prev parent reply other threads:[~2026-06-26 6:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 6:21 [PATCH 0/6] hw/cxl: fix Type-3 device reset resource leaks and convert to three-phase Junjie Cao
2026-06-26 6:21 ` [PATCH 1/6] hw/cxl: fix timer leak in cxl_destroy_cci() Junjie Cao
2026-07-21 1:03 ` Jonathan Cameron
2026-06-26 6:21 ` [PATCH 2/6] hw/cxl: destroy primary CCI before re-initialization on reset Junjie Cao
2026-06-26 6:21 ` Junjie Cao [this message]
2026-06-26 6:21 ` [PATCH 4/6] hw/cxl: free in-flight sanitize state " Junjie Cao
2026-06-26 6:21 ` [PATCH 5/6] hw/cxl: clear event logs, scan media and interrupt policy " Junjie Cao
2026-06-26 6:21 ` [PATCH 6/6] hw/cxl: clear poison lists and feature transfer state " Junjie Cao
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=20260626062149.1844334-4-junjie.cao@intel.com \
--to=junjie.cao@intel.com \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=qemu-devel@nongnu.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