diff mbox series

[v2,3/5] cxl/acpi: Add platform flag for HPA address translation

Message ID 20240701174754.967954-4-rrichter@amd.com
State New, archived
Headers show
Series Address translation for HDM decoding | expand

Commit Message

Robert Richter July 1, 2024, 5:47 p.m. UTC
Adding an early check to detect platform specifics to (later) enable
HPA address translation. The cxl_root structure is used to store that
information.

Note: The platform check will be added later when enabling address
translation.

Link: https://lore.kernel.org/all/65c68969903b1_afa429460@dwillia2-xfh.jf.intel.com.notmuch/
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
---
 drivers/cxl/acpi.c | 7 +++++++
 drivers/cxl/cxl.h  | 2 ++
 2 files changed, 9 insertions(+)

Comments

Dan Williams July 12, 2024, 1:27 a.m. UTC | #1
Robert Richter wrote:
> Adding an early check to detect platform specifics to (later) enable
> HPA address translation. The cxl_root structure is used to store that
> information.
> 
> Note: The platform check will be added later when enabling address
> translation.

It feels odd to have a flag at the root for this because the translation
is at the host-bridge level, right?

I was more thinking of a solution that does:

spa = cxld_hpa_to_spa(cxld);

...and then internal to that the code walks the port hierarchy from it's
host port to the host bridge. Then does something like

hb->hpa_to_spa(hb, hpa)

Where @hb is:

struct cxl_hb {
	struct cxl_port port;
	u64 (*hpa_to_spa)(struct cxl_hb *, u64);
}
Robert Richter July 13, 2024, 7:41 a.m. UTC | #2
On 11.07.24 18:27:30, Dan Williams wrote:
> Robert Richter wrote:
> > Adding an early check to detect platform specifics to (later) enable
> > HPA address translation. The cxl_root structure is used to store that
> > information.
> > 
> > Note: The platform check will be added later when enabling address
> > translation.
> 
> It feels odd to have a flag at the root for this because the translation
> is at the host-bridge level, right?
> 
> I was more thinking of a solution that does:
> 
> spa = cxld_hpa_to_spa(cxld);
> 
> ...and then internal to that the code walks the port hierarchy from it's
> host port to the host bridge. Then does something like
> 
> hb->hpa_to_spa(hb, hpa)
> 
> Where @hb is:
> 
> struct cxl_hb {
> 	struct cxl_port port;
> 	u64 (*hpa_to_spa)(struct cxl_hb *, u64);
> }

Ok, will consider that for the rework.

-Robert
diff mbox series

Patch

diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index 571069863c62..67f73a831bd3 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -536,6 +536,11 @@  static int cxl_get_chbs(struct device *dev, struct acpi_device *hb,
 	return 0;
 }
 
+static void setup_platform_quirks(struct cxl_root *root)
+{
+	root->hpa_xlat_enable = 0;
+}
+
 static int get_genport_coordinates(struct device *dev, struct cxl_dport *dport)
 {
 	struct acpi_device *hb = to_cxl_host_bridge(NULL, dev);
@@ -838,6 +843,8 @@  static int cxl_acpi_probe(struct platform_device *pdev)
 		return PTR_ERR(cxl_root);
 	root_port = &cxl_root->port;
 
+	setup_platform_quirks(cxl_root);
+
 	rc = bus_for_each_dev(adev->dev.bus, NULL, root_port,
 			      add_host_bridge_dport);
 	if (rc < 0)
diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index 603c0120cff8..95d054dc1af0 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -627,10 +627,12 @@  struct cxl_port {
  *
  * @port: cxl_port member
  * @ops: cxl root operations
+ * @hpa_xlat_enable: enable HPA translation
  */
 struct cxl_root {
 	struct cxl_port port;
 	const struct cxl_root_ops *ops;
+	bool hpa_xlat_enable;
 };
 
 static inline struct cxl_root *