habanalabs: add debugfs write64/read64
Subsystems (2)
PATCH 1/5 habanalabs: add debugfs write64/read64
From: Moti Haimovski <[email protected]>
Allow debug user to write/read 64-bit data through debugfs. This will expedite the dump process of the (large) internal memories of the device done during debug.
--- .../ABI/testing/debugfs-driver-habanalabs | 14 +++ drivers/misc/habanalabs/debugfs.c | 71 ++++++++++++++ drivers/misc/habanalabs/goya/goya.c | 92 +++++++++++++++++++ drivers/misc/habanalabs/habanalabs.h | 2 + 4 files changed, 179 insertions(+)
Documentation/ABI/testing/debugfs-driver-habanalabs +14 -0
@@ -43,6 +43,20 @@ Description: Allows the root user to read or write directly through the If the IOMMU is disabled, it also allows the root user to read or write from the host a device VA of a host mapped memory +What: /sys/kernel/debug/habanalabs/hl<n>/data64 +Date: Jan 2020 +KernelVersion: 5.6 +Contact: [email protected] +Description: Allows the root user to read or write 64 bit data directly + through the device's PCI bar. Writing to this file generates a + write transaction while reading from the file generates a read + transaction. This custom interface is needed (instead of using + the generic Linux user-space PCI mapping) because the DDR bar + is very small compared to the DDR memory and only the driver can + move the bar before and after the transaction. + If the IOMMU is disabled, it also allows the root user to read + or write from the host a device VA of a host mapped memory + What: /sys/kernel/debug/habanalabs/hl<n>/device Date: Jan 2019 KernelVersion: 5.1
drivers/misc/habanalabs/debugfs.c +71 -0
89 lines not on this page · raw message
drivers/misc/habanalabs/goya/goya.c +92 -0
104 lines not on this page · raw message
drivers/misc/habanalabs/habanalabs.h +2 -0
@@ -582,6 +582,8 @@ struct hl_asic_funcs {void (*restore_phase_topology)(struct hl_device *hdev);int (*debugfs_read32)(struct hl_device *hdev,u64 addr,u32 *val);int (*debugfs_write32)(struct hl_device *hdev,u64 addr,u32 val); +int (*debugfs_read64)(struct hl_device *hdev,u64 addr,u64 *val); +int (*debugfs_write64)(struct hl_device *hdev,u64 addr,u64 val);void (*add_device_attr)(struct hl_device *hdev,struct attribute_group *dev_attr_grp); void (*handle_eqe)(struct hl_device *hdev,
Signature · 1 line
2.17.1
PATCH 2/5 habanalabs: ratelimit error prints of IRQs
The compute engines can perform millions of transactions per second. If there is a bug in the S/W stack, we could get a lot of interrupts and spam the kernel log. Therefore, ratelimit these prints
--- drivers/misc/habanalabs/goya/goya.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/misc/habanalabs/goya/goya.c +7 -6
@@ -4480,22 +4480,22 @@ static void goya_get_event_desc(u16 event_type, char *desc, size_t size)static void goya_print_razwi_info (struct hl_device *hdev) {if (RREG32 (mmDMA_MACRO_RAZWI_LBW_WT_VLD)) { -dev_err (hdev->dev,"Illegal write to LBW\n" ); +dev_err_ratelimited (hdev->dev,"Illegal write to LBW\n" );WREG32 (mmDMA_MACRO_RAZWI_LBW_WT_VLD,0 ); }if (RREG32 (mmDMA_MACRO_RAZWI_LBW_RD_VLD)) { -dev_err (hdev->dev,"Illegal read from LBW\n" ); +dev_err_ratelimited (hdev->dev,"Illegal read from LBW\n" );WREG32 (mmDMA_MACRO_RAZWI_LBW_RD_VLD,0 ); }if (RREG32 (mmDMA_MACRO_RAZWI_HBW_WT_VLD)) { -dev_err (hdev->dev,"Illegal write to HBW\n" ); +dev_err_ratelimited (hdev->dev,"Illegal write to HBW\n" );WREG32 (mmDMA_MACRO_RAZWI_HBW_WT_VLD,0 ); }if (RREG32 (mmDMA_MACRO_RAZWI_HBW_RD_VLD)) { -dev_err (hdev->dev,"Illegal read from HBW\n" ); +dev_err_ratelimited (hdev->dev,"Illegal read from HBW\n" );WREG32 (mmDMA_MACRO_RAZWI_HBW_RD_VLD,0 ); } }
@@ -4515,7 +4515,8 @@ static void goya_print_mmu_error_info(struct hl_device *hdev) addr <<=32 ; addr |=RREG32 (mmMMU_PAGE_ERROR_CAPTURE_VA); -dev_err (hdev->dev,"MMU page fault on va 0x%llx\n" , addr); +dev_err_ratelimited (hdev->dev,"MMU page fault on va 0x%llx\n" , + addr);WREG32 (mmMMU_PAGE_ERROR_CAPTURE,0 ); }
@@ -4527,7 +4528,7 @@ static void goya_print_irq_info(struct hl_device *hdev, u16 event_type,char desc[20 ] ="" ;goya_get_event_desc (event_type, desc,sizeof (desc)); -dev_err (hdev->dev,"Received H/W interrupt %d [\"%s\"]\n" , +dev_err_ratelimited (hdev->dev,"Received H/W interrupt %d [\"%s\"]\n" , event_type, desc);if (razwi) {
Signature · 1 line
2.17.1
PATCH 3/5 habanalabs: support temperature offset via sysfs
In reply to Oded GabbayFrom: Moti Haimovski <[email protected]>
This commit adds support for offsetting the temperatures reading by a specified value as defined in
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
using the standard sysfs defined for hwmon.
This is required by system administrators to inject errors to test their monitoring applications in data centers.
--- drivers/misc/habanalabs/habanalabs.h | 2 ++ drivers/misc/habanalabs/hwmon.c | 37 ++++++++++++++++++++++ drivers/misc/habanalabs/include/armcp_if.h | 13 +++++++- 3 files changed, 51 insertions(+), 1 deletion(-)
drivers/misc/habanalabs/habanalabs.h +2 -0
@@ -1610,6 +1610,8 @@ int hl_pci_set_dma_mask(struct hl_device *hdev, u8 dma_mask);long hl_get_frequency (struct hl_device *hdev,u32 pll_index,bool curr);void hl_set_frequency (struct hl_device *hdev,u32 pll_index,u64 freq);long hl_get_temperature (struct hl_device *hdev,int sensor_index,u32 attr); +int hl_set_temperature (struct hl_device *hdev, +int sensor_index,u32 attr,long value);long hl_get_voltage (struct hl_device *hdev,int sensor_index,u32 attr);long hl_get_current (struct hl_device *hdev,int sensor_index,u32 attr);long hl_get_fan_speed (struct hl_device *hdev,int sensor_index,u32 attr);
drivers/misc/habanalabs/hwmon.c +37 -0
@@ -125,6 +125,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_temp_crit:case hwmon_temp_max_hyst:case hwmon_temp_crit_hyst: +case hwmon_temp_offset:break ;default :return -EINVAL ;
@@ -192,6 +193,15 @@ static int hl_write(struct device *dev, enum hwmon_sensor_types type,return -ENODEV ;switch (type) { +case hwmon_temp: +switch (attr) { +case hwmon_temp_offset: +break ; +default : +return -EINVAL ; + } +hl_set_temperature (hdev, channel, attr, val); +break ;case hwmon_pwm:switch (attr) {case hwmon_pwm_input:
@@ -220,6 +230,8 @@ static umode_t hl_is_visible(const void *data, enum hwmon_sensor_types type,case hwmon_temp_crit:case hwmon_temp_crit_hyst:return 0444 ; +case hwmon_temp_offset: +return 0644 ; }break ;case hwmon_in:
@@ -291,6 +303,31 @@ long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr)return result; } +int hl_set_temperature (struct hl_device *hdev, +int sensor_index,u32 attr,long value) +{ +struct armcp_packet pkt; +int rc; + +memset (&pkt,0 ,sizeof (pkt)); + + pkt.ctl =cpu_to_le32 (ARMCP_PACKET_TEMPERATURE_SET << +ARMCP_PKT_CTL_OPCODE_SHIFT ); + pkt.sensor_index =__cpu_to_le16 (sensor_index); + pkt.type =__cpu_to_le16 (attr); + pkt.value =__cpu_to_le64 (value); + + rc = hdev->asic_funcs->send_cpu_message (hdev, (u32 *) &pkt,sizeof (pkt), +SENSORS_PKT_TIMEOUT ,NULL ); + +if (rc) +dev_err (hdev->dev, +"Failed to set temperature of sensor %d, error %d\n" , + sensor_index, rc); + +return rc; +} +long hl_get_voltage (struct hl_device *hdev,int sensor_index,u32 attr) {struct armcp_packet pkt;
drivers/misc/habanalabs/include/armcp_if.h +12 -1
@@ -189,6 +189,10 @@ enum pq_init_status {* ArmCP to write to the structure, to prevent data corruption in case of * mismatched driver/FW versions. * +* ARMCP_PACKET_TEMPERATURE_SET - +* Set the value of the offset property of a specified thermal sensor. +* The packet's arguments specify the desired sensor and the field to +* set. */ enum armcp_packet_id {
@@ -214,6 +218,8 @@ enum armcp_packet_id {ARMCP_PACKET_MAX_POWER_GET ,/* sysfs */ ARMCP_PACKET_MAX_POWER_SET ,/* sysfs */ ARMCP_PACKET_EEPROM_DATA_GET ,/* sysfs */ +ARMCP_RESERVED , + ARMCP_PACKET_TEMPERATURE_SET, /* sysfs */ };#define ARMCP_PACKET_FENCE_VAL 0xFE8CE7A5
@@ -271,12 +277,17 @@ enum armcp_packet_rc {armcp_packet_fault }; +/* +* armcp_temp_type should adhere to hwmon_temp_attributes +* defined in Linux kernel hwmon.h file +*/ enum armcp_temp_type { armcp_temp_input, armcp_temp_max =6 , armcp_temp_max_hyst, armcp_temp_crit, - armcp_temp_crit_hyst + armcp_temp_crit_hyst, + armcp_temp_offset =19 };enum armcp_in_attributes {
Signature · 1 line
2.17.1
PATCH 4/5 habanalabs: modify the return values of hl_read/write routines
In reply to Oded GabbayFrom: Moti Haimovski <[email protected]>
The hl read and write routines implement the hwmon_ops read and write interface routines respectively.
These routines are expected to return a completion status when called, which was not the case until this commit.
This commit modifies these routines to return 0 upon success and a negative error value upon failure.
--- drivers/misc/habanalabs/habanalabs.h | 17 +++++--- drivers/misc/habanalabs/hwmon.c | 63 ++++++++++++++-------------- 2 files changed, 43 insertions(+), 37 deletions(-)
drivers/misc/habanalabs/habanalabs.h +11 -6
@@ -1609,13 +1609,18 @@ int hl_pci_set_dma_mask(struct hl_device *hdev, u8 dma_mask);long hl_get_frequency (struct hl_device *hdev,u32 pll_index,bool curr);void hl_set_frequency (struct hl_device *hdev,u32 pll_index,u64 freq); -long hl_get_temperature (struct hl_device *hdev,int sensor_index,u32 attr); +int hl_get_temperature (struct hl_device *hdev, +int sensor_index,u32 attr,long *value);int hl_set_temperature (struct hl_device *hdev, -int sensor_index,u32 attr,long value); -long hl_get_voltage (struct hl_device *hdev,int sensor_index,u32 attr); -long hl_get_current (struct hl_device *hdev,int sensor_index,u32 attr); -long hl_get_fan_speed (struct hl_device *hdev,int sensor_index,u32 attr); -long hl_get_pwm_info (struct hl_device *hdev,int sensor_index,u32 attr); +int sensor_index,u32 attr,long value); +int hl_get_voltage (struct hl_device *hdev, +int sensor_index,u32 attr,long *value); +int hl_get_current (struct hl_device *hdev, +int sensor_index,u32 attr,long *value); +int hl_get_fan_speed (struct hl_device *hdev, +int sensor_index,u32 attr,long *value); +int hl_get_pwm_info (struct hl_device *hdev, +int sensor_index,u32 attr,long *value);void hl_set_pwm_info (struct hl_device *hdev,int sensor_index,u32 attr,long value);u64 hl_get_max_power (struct hl_device *hdev);
drivers/misc/habanalabs/hwmon.c +32 -31
196 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 5/5 habanalabs: provide historical maximum of various sensors
In reply to Oded GabbayFrom: Christine Gharzuzi <[email protected]>
Add support for hwmon_in_highest, hwmon_temp_highest and hwmon_curr_highest attributes. These attributes retrieve the historical maximum voltage, temperature and current that were sampled, respectively.
--- drivers/misc/habanalabs/hwmon.c | 6 ++++++ drivers/misc/habanalabs/include/armcp_if.h | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/misc/habanalabs/hwmon.c +6 -0
@@ -127,6 +127,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_temp_max_hyst:case hwmon_temp_crit_hyst:case hwmon_temp_offset: +case hwmon_temp_highest:break ;default :return -EINVAL ;
@@ -139,6 +140,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_in_input:case hwmon_in_min:case hwmon_in_max: +case hwmon_in_highest:break ;default :return -EINVAL ;
@@ -151,6 +153,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_curr_input:case hwmon_curr_min:case hwmon_curr_max: +case hwmon_curr_highest:break ;default :return -EINVAL ;
@@ -230,6 +233,7 @@ static umode_t hl_is_visible(const void *data, enum hwmon_sensor_types type,case hwmon_temp_max_hyst:case hwmon_temp_crit:case hwmon_temp_crit_hyst: +case hwmon_temp_highest:return 0444 ;case hwmon_temp_offset:return 0644 ;
@@ -240,6 +244,7 @@ static umode_t hl_is_visible(const void *data, enum hwmon_sensor_types type,case hwmon_in_input:case hwmon_in_min:case hwmon_in_max: +case hwmon_in_highest:return 0444 ; }break ;
@@ -248,6 +253,7 @@ static umode_t hl_is_visible(const void *data, enum hwmon_sensor_types type,case hwmon_curr_input:case hwmon_curr_min:case hwmon_curr_max: +case hwmon_curr_highest:return 0444 ; }break ;
drivers/misc/habanalabs/include/armcp_if.h +6 -3
@@ -287,19 +287,22 @@ enum armcp_temp_type { armcp_temp_max_hyst, armcp_temp_crit, armcp_temp_crit_hyst, - armcp_temp_offset =19 + armcp_temp_offset =19 , + armcp_temp_highest =22 };enum armcp_in_attributes { armcp_in_input, armcp_in_min, - armcp_in_max + armcp_in_max, + armcp_in_highest =7 };enum armcp_curr_attributes { armcp_curr_input, armcp_curr_min, - armcp_curr_max + armcp_curr_max, + armcp_curr_highest =7 }; enum armcp_fan_attributes {
Signature · 1 line
2.17.1
RE: [PATCH 2/5] habanalabs: ratelimit error prints of IRQs
In reply to Oded GabbayQuoted 5 lines · Oded Gabbay
The compute engines can perform millions of transactions per second. If there is a bug in the S/W stack, we could get a lot of interrupts and spam the kernel log. Therefore, ratelimit these prints
Signed-off-by Oded Gabbay <[email protected]>