Skip to content

Commit 47a5528

Browse files
dlibemanogabbay
authored andcommitted
accel/habanalabs: expose module id through sysfs
Module ID exposes the physical location of the device in the server, from the pov of the devices in regard to how they are connected by internal fabric. This information is already exposed in our INFO ioctl, but there are utilities and scripts running in data-center which are already accessing sysfs for topology information and it is easier for them to continue getting that information from sysfs instead of opening a file descriptor. Signed-off-by: Dani Liberman <dliberman@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
1 parent c9f9d0e commit 47a5528

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Documentation/ABI/testing/sysfs-driver-habanalabs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ Contact: ogabbay@kernel.org
149149
Description: Displays the current clock frequency, in Hz, of the MME compute
150150
engine. This property is valid only for the Goya ASIC family
151151

152+
What: /sys/class/accel/accel<n>/device/module_id
153+
Date: Nov 2023
154+
KernelVersion: not yet upstreamed
155+
Contact: ogabbay@kernel.org
156+
Description: Displays the device's module id
157+
152158
What: /sys/class/accel/accel<n>/device/pci_addr
153159
Date: Jan 2019
154160
KernelVersion: 5.1

drivers/accel/habanalabs/common/sysfs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ static ssize_t security_enabled_show(struct device *dev,
386386
return sprintf(buf, "%d\n", hdev->asic_prop.fw_security_enabled);
387387
}
388388

389+
static ssize_t module_id_show(struct device *dev,
390+
struct device_attribute *attr, char *buf)
391+
{
392+
struct hl_device *hdev = dev_get_drvdata(dev);
393+
394+
return sprintf(buf, "%u\n", le32_to_cpu(hdev->asic_prop.cpucp_info.card_location));
395+
}
396+
389397
static DEVICE_ATTR_RO(armcp_kernel_ver);
390398
static DEVICE_ATTR_RO(armcp_ver);
391399
static DEVICE_ATTR_RO(cpld_ver);
@@ -405,6 +413,7 @@ static DEVICE_ATTR_RO(thermal_ver);
405413
static DEVICE_ATTR_RO(uboot_ver);
406414
static DEVICE_ATTR_RO(fw_os_ver);
407415
static DEVICE_ATTR_RO(security_enabled);
416+
static DEVICE_ATTR_RO(module_id);
408417

409418
static struct bin_attribute bin_attr_eeprom = {
410419
.attr = {.name = "eeprom", .mode = (0444)},
@@ -430,6 +439,7 @@ static struct attribute *hl_dev_attrs[] = {
430439
&dev_attr_uboot_ver.attr,
431440
&dev_attr_fw_os_ver.attr,
432441
&dev_attr_security_enabled.attr,
442+
&dev_attr_module_id.attr,
433443
NULL,
434444
};
435445

0 commit comments

Comments
 (0)