Skip to content

Commit 40cdc60

Browse files
stellarhopperdjbw
authored andcommitted
device-dax: Add a 'resource' attribute
device-dax based devices were missing a 'resource' attribute to indicate the physical address range contributed by the device in question. This information is desirable to userspace tooling that may want to use the dax device as system-ram, and wants to selectively hotplug and online the memory blocks associated with a given device. Without this, the tooling would have to parse /proc/iomem for the memory ranges contributed by dax devices, which can be a workaround, but it is far easier to provide this information in the sysfs hierarchy. Cc: Dave Hansen <[email protected]> Cc: Dan Williams <[email protected]> Signed-off-by: Vishal Verma <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 9e0babf commit 40cdc60

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/dax/bus.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,22 @@ static ssize_t target_node_show(struct device *dev,
295295
}
296296
static DEVICE_ATTR_RO(target_node);
297297

298+
static unsigned long long dev_dax_resource(struct dev_dax *dev_dax)
299+
{
300+
struct dax_region *dax_region = dev_dax->region;
301+
302+
return dax_region->res.start;
303+
}
304+
305+
static ssize_t resource_show(struct device *dev,
306+
struct device_attribute *attr, char *buf)
307+
{
308+
struct dev_dax *dev_dax = to_dev_dax(dev);
309+
310+
return sprintf(buf, "%#llx\n", dev_dax_resource(dev_dax));
311+
}
312+
static DEVICE_ATTR_RO(resource);
313+
298314
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
299315
char *buf)
300316
{
@@ -313,13 +329,16 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
313329

314330
if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
315331
return 0;
332+
if (a == &dev_attr_resource.attr)
333+
return 0400;
316334
return a->mode;
317335
}
318336

319337
static struct attribute *dev_dax_attributes[] = {
320338
&dev_attr_modalias.attr,
321339
&dev_attr_size.attr,
322340
&dev_attr_target_node.attr,
341+
&dev_attr_resource.attr,
323342
NULL,
324343
};
325344

0 commit comments

Comments
 (0)