Skip to content

Commit 384e624

Browse files
committed
cxl/region: Attach endpoint decoders
CXL regions (interleave sets) are made up of a set of memory devices where each device maps a portion of the interleave with one of its decoders (see CXL 2.0 8.2.5.12 CXL HDM Decoder Capability Structure). As endpoint decoders are identified by a provisioning tool they can be added to a region provided the region interleave properties are set (way, granularity, HPA) and DPA has been assigned to the decoder. The attach event triggers several validation checks, for example: - is the DPA sized appropriately for the region - is the decoder reachable via the host-bridges identified by the region's root decoder - is the device already active in a different region position slot - are there already regions with a higher HPA active on a given port (per CXL 2.0 8.2.5.12.20 Committing Decoder Programming) ...and the attach event affords an opportunity to collect data and resources relevant to later programming the target lists in switch decoders, for example: - allocate a decoder at each cxl_port in the decode chain - for a given switch port, how many the region's endpoints are hosted through the port - how many unique targets (next hops) does a port need to map to reach those endpoints The act of reconciling this information and deploying it to the decoder configuration is saved for a follow-on patch. Co-developed-by: Ben Widawsky <[email protected]> Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/165784337277.1758207.4108508181328528703.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent 6aa4114 commit 384e624

File tree

5 files changed

+394
-12
lines changed

5 files changed

+394
-12
lines changed

drivers/cxl/core/core.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
4141
resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
4242
extern struct rw_semaphore cxl_dpa_rwsem;
4343

44+
bool is_switch_decoder(struct device *dev);
45+
static inline struct cxl_ep *cxl_ep_load(struct cxl_port *port,
46+
struct cxl_memdev *cxlmd)
47+
{
48+
return xa_load(&port->endpoints, (unsigned long)&cxlmd->dev);
49+
}
50+
4451
int cxl_memdev_init(void);
4552
void cxl_memdev_exit(void);
4653
void cxl_mbox_init(void);

drivers/cxl/core/port.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ bool is_root_decoder(struct device *dev)
448448
}
449449
EXPORT_SYMBOL_NS_GPL(is_root_decoder, CXL);
450450

451-
static bool is_switch_decoder(struct device *dev)
451+
bool is_switch_decoder(struct device *dev)
452452
{
453453
return is_root_decoder(dev) || dev->type == &cxl_decoder_switch_type;
454454
}
@@ -504,6 +504,7 @@ static void cxl_port_release(struct device *dev)
504504
cxl_ep_remove(port, ep);
505505
xa_destroy(&port->endpoints);
506506
xa_destroy(&port->dports);
507+
xa_destroy(&port->regions);
507508
ida_free(&cxl_port_ida, port->id);
508509
kfree(port);
509510
}
@@ -635,6 +636,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport,
635636
port->hdm_end = -1;
636637
xa_init(&port->dports);
637638
xa_init(&port->endpoints);
639+
xa_init(&port->regions);
638640

639641
device_initialize(dev);
640642
lockdep_set_class_and_subclass(&dev->mutex, &cxl_port_key, port->depth);
@@ -1109,12 +1111,6 @@ static void reap_dports(struct cxl_port *port)
11091111
}
11101112
}
11111113

1112-
static struct cxl_ep *cxl_ep_load(struct cxl_port *port,
1113-
struct cxl_memdev *cxlmd)
1114-
{
1115-
return xa_load(&port->endpoints, (unsigned long)&cxlmd->dev);
1116-
}
1117-
11181114
int devm_cxl_add_endpoint(struct cxl_memdev *cxlmd,
11191115
struct cxl_dport *parent_dport)
11201116
{

0 commit comments

Comments
 (0)