linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl/mem: Disable suspend
@ 2022-04-03  0:58 Dan Williams
  2022-04-04 15:59 ` Rafael J. Wysocki
  2022-04-05 20:00 ` [PATCH v2] PM: CXL: " Dan Williams
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Williams @ 2022-04-03  0:58 UTC (permalink / raw)
  To: linux-cxl; +Cc: Rafael J. Wysocki, linux-pci, linux-acpi

The CXL specification claims S3 support at a hardware level, but at a
system software level there are some missing pieces. Section 9.4 rightly
claims that "CXL mem adapters may need aux power to retain memory
context across S3", but there is no enumeration mechanism for the OS to
determine if a given adapter has that support. Moreover the save state
and resume image for the system may inadvertantly end up in a CXL device
that needs to be restored before the save state is recoverable. I.e. a
circular dependency that is not resolvable without a third party
save-area.

Arrange for the cxl_mem driver to fail S3 attempts. This still nominaly
allows for suspend, but requires unbinding all CXL memory devices before
the suspend to ensure the typical DRAM flow is taken. The cxl_mem unbind
flow is intended to also tear down all CXL memory regions associated
with a given cxl_memdev.

It is reasonable to assume that any device participating in a System RAM
range published in the EFI memory map is covered by aux power and
save-area outside the device itself. So this restriction can be
minimized in the future once pre-existing region enumeration support
arrives, and perhaps a spec update to clarify if the EFI memory is
sufficent for determining the range of devices managed by
platform-firmware for S3 support.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/memdev.c |    1 -
 drivers/cxl/mem.c         |   26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index 1f76b28f9826..efe4d2e9bfef 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -251,7 +251,6 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,
 	dev->bus = &cxl_bus_type;
 	dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
 	dev->type = &cxl_memdev_type;
-	device_set_pm_not_required(dev);
 	INIT_WORK(&cxlmd->detach_work, detach_memdev);
 
 	cdev = &cxlmd->cdev;
diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 49a4b1c47299..0660bb1488cb 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -3,6 +3,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/pm.h>
 
 #include "cxlmem.h"
 #include "cxlpci.h"
@@ -210,10 +211,35 @@ static int cxl_mem_probe(struct device *dev)
 	return rc;
 }
 
+static int cxl_mem_suspend(struct device *dev)
+{
+	/*
+	 * The kernel may be operating out of CXL memory on this device,
+	 * there is no spec defined way to determine whether this device
+	 * preserves contents over suspend, and there is no simple way
+	 * to arrange for the suspend image to avoid CXL memory which
+	 * would setup a circular dependency between PCI resume and save
+	 * state restoration.
+	 */
+	dev_err(dev, "CXL memory suspend not supported\n");
+	return -EBUSY;
+}
+
+static int cxl_mem_resume(struct device *dev)
+{
+	/* nothing to do since suspend is prevented */
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(cxl_pm_ops, cxl_mem_suspend, cxl_mem_resume);
+
 static struct cxl_driver cxl_mem_driver = {
 	.name = "cxl_mem",
 	.probe = cxl_mem_probe,
 	.id = CXL_DEVICE_MEMORY_EXPANDER,
+	.drv = {
+		.pm = &cxl_pm_ops,
+	},
 };
 
 module_cxl_driver(cxl_mem_driver);


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-13  2:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03  0:58 [PATCH] cxl/mem: Disable suspend Dan Williams
2022-04-04 15:59 ` Rafael J. Wysocki
2022-04-04 18:16   ` Dan Williams
2022-04-04 18:24     ` Rafael J. Wysocki
2022-04-05 20:00 ` [PATCH v2] PM: CXL: " Dan Williams
2022-04-05 20:05   ` Brown, Len
2022-04-05 20:22     ` Dan Williams
2022-04-12 16:59   ` Rafael J. Wysocki
2022-04-12 23:27     ` Dan Williams
2022-04-13  2:22   ` [PATCH v3] " Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).