Skip to content

Commit 538831f

Browse files
Ben Widawskydjbw
authored andcommitted
cxl/hdm: Add sysfs attributes for interleave ways + granularity
The region provisioning flow involves selecting interleave ways + granularity settings for a region, and then programming the decoder topology to meet those constraints, if possible. For example, root decoders set the minimum interleave ways + granularity for any hosted regions. Given decoder programming is not atomic and collisions can occur between multiple requesting regions userspace will be responsible for conflict resolution and it needs these attributes to make those decisions. Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/165784332235.1758207.7185062713652694607.stgit@dwillia2-xfh.jf.intel.com [djbw: reword changelog, make read-only, add sysfs ABI documentaion] Signed-off-by: Dan Williams <[email protected]>
1 parent 3917858 commit 538831f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

Documentation/ABI/testing/sysfs-bus-cxl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,30 @@ Description:
241241
allocations are enforced to occur in increasing 'decoderX.Y/id'
242242
order and frees are enforced to occur in decreasing
243243
'decoderX.Y/id' order.
244+
245+
246+
What: /sys/bus/cxl/devices/decoderX.Y/interleave_ways
247+
Date: May, 2022
248+
KernelVersion: v5.20
249+
250+
Description:
251+
(RO) The number of targets across which this decoder's host
252+
physical address (HPA) memory range is interleaved. The device
253+
maps every Nth block of HPA (of size ==
254+
'interleave_granularity') to consecutive DPA addresses. The
255+
decoder's position in the interleave is determined by the
256+
device's (endpoint or switch) switch ancestry. For root
257+
decoders their interleave is specified by platform firmware and
258+
they only specify a downstream target order for host bridges.
259+
260+
261+
What: /sys/bus/cxl/devices/decoderX.Y/interleave_granularity
262+
Date: May, 2022
263+
KernelVersion: v5.20
264+
265+
Description:
266+
(RO) The number of consecutive bytes of host physical address
267+
space this decoder claims at address N before the decode rotates
268+
to the next target in the interleave at address N +
269+
interleave_granularity (assuming N is aligned to
270+
interleave_granularity).

drivers/cxl/core/port.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,33 @@ static ssize_t dpa_size_store(struct device *dev, struct device_attribute *attr,
260260
}
261261
static DEVICE_ATTR_RW(dpa_size);
262262

263+
static ssize_t interleave_granularity_show(struct device *dev,
264+
struct device_attribute *attr,
265+
char *buf)
266+
{
267+
struct cxl_decoder *cxld = to_cxl_decoder(dev);
268+
269+
return sysfs_emit(buf, "%d\n", cxld->interleave_granularity);
270+
}
271+
272+
static DEVICE_ATTR_RO(interleave_granularity);
273+
274+
static ssize_t interleave_ways_show(struct device *dev,
275+
struct device_attribute *attr, char *buf)
276+
{
277+
struct cxl_decoder *cxld = to_cxl_decoder(dev);
278+
279+
return sysfs_emit(buf, "%d\n", cxld->interleave_ways);
280+
}
281+
282+
static DEVICE_ATTR_RO(interleave_ways);
283+
263284
static struct attribute *cxl_decoder_base_attrs[] = {
264285
&dev_attr_start.attr,
265286
&dev_attr_size.attr,
266287
&dev_attr_locked.attr,
288+
&dev_attr_interleave_granularity.attr,
289+
&dev_attr_interleave_ways.attr,
267290
NULL,
268291
};
269292

0 commit comments

Comments
 (0)