habanalabs: generalize COMMS message sending procedure
PATCH 1/3 habanalabs: generalize COMMS message sending procedure
From: Alon Mizrahi <[email protected]>
Instead of having dedicated function per message that we want to send to the firmware in COMMS protocol, have a generic function that we can call to from other parts of the driver
--- drivers/misc/habanalabs/common/firmware_if.c | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/misc/habanalabs/common/firmware_if.c +18 -10
@@ -2162,18 +2162,17 @@ static void hl_fw_linux_update_state(struct hl_device *hdev, }/** -* hl_fw_dynamic_report_reset_cause - send a COMMS message with the cause -* of the newly triggered hard reset +* hl_fw_dynamic_send_msg - send a COMMS message with attached data * * @hdev: pointer to the habanalabs device structure * @fw_loader: managing structure for loading device's FW -* @reset_cause: enumerated cause for the recent hard reset +* @msg_type: message type +* @data: data to be sent * * @return 0 on success, otherwise non-zero error code */ -static int hl_fw_dynamic_report_reset_cause (struct hl_device *hdev, -struct fw_load_mgr *fw_loader, -enum comms_reset_cause reset_cause) +static int hl_fw_dynamic_send_msg (struct hl_device *hdev, +struct fw_load_mgr *fw_loader,u8 msg_type,void *data) {struct lkd_msg_comms msg;int rc;
@@ -2181,11 +2180,20 @@ static int hl_fw_dynamic_report_reset_cause(struct hl_device *hdev,memset (&msg,0 ,sizeof (msg));/* create message to be sent */ - msg.header.type =HL_COMMS_RESET_CAUSE_TYPE ; + msg.header.type = msg_type; msg.header.size =cpu_to_le16 (sizeof (struct comms_msg_header )); msg.header.magic =cpu_to_le32 (HL_COMMS_MSG_MAGIC ); - msg.reset_cause = reset_cause; +switch (msg_type) { +case HL_COMMS_RESET_CAUSE_TYPE : + msg.reset_cause = *(__u8 *) data; +break ; +default : +dev_err (hdev->dev, +"Send COMMS message - invalid message type %u\n" , + msg_type); +return -EINVAL ; + } rc =hl_fw_dynamic_request_descriptor (hdev, fw_loader,sizeof (struct lkd_msg_comms ));
@@ -2252,8 +2260,8 @@ static int hl_fw_dynamic_init_cpu(struct hl_device *hdev, goto protocol_err;if (hdev->curr_reset_cause) { - rc =hl_fw_dynamic_report_reset_cause (hdev, fw_loader, - hdev->curr_reset_cause); + rc =hl_fw_dynamic_send_msg (hdev, fw_loader, +HL_COMMS_RESET_CAUSE_TYPE , &hdev->curr_reset_cause);if (rc) goto protocol_err;
Signature · 1 line
2.17.1
PATCH 2/3 habanalabs: enable power info via HWMON framework
From: Rajaravi Krishna Katta <[email protected]>
Add support to retrieve following power info via HWMON:
- instantaneous power value
- highest value since last reset
- reset the highest place holder
--- drivers/misc/habanalabs/common/habanalabs.h | 4 + drivers/misc/habanalabs/common/hwmon.c | 94 +++++++++++++++++++ .../misc/habanalabs/include/common/cpucp_if.h | 10 ++ 3 files changed, 108 insertions(+)
drivers/misc/habanalabs/common/habanalabs.h +4 -0
@@ -2956,6 +2956,10 @@ int hl_set_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long value);int hl_set_current (struct hl_device *hdev,int sensor_index,u32 attr,long value); +int hl_set_power (struct hl_device *hdev, +int sensor_index,u32 attr,long value); +int hl_get_power (struct hl_device *hdev, +int sensor_index,u32 attr,long *value);void hw_sob_get (struct hl_hw_sob *hw_sob);void hw_sob_put (struct hl_hw_sob *hw_sob);void hl_encaps_handle_do_release (struct kref *ref);
drivers/misc/habanalabs/common/hwmon.c +94 -0
118 lines not on this page · raw message
drivers/misc/habanalabs/include/common/cpucp_if.h +10 -0
@@ -598,6 +598,16 @@ enum cpucp_pll_type_attributes { cpucp_pll_pci, }; +/* +* cpucp_power_type aligns with hwmon_power_attributes +* defined in Linux kernel hwmon.h file +*/ +enum cpucp_power_type { +CPUCP_POWER_INPUT =8 , +CPUCP_POWER_INPUT_HIGHEST =9 , +CPUCP_POWER_RESET_INPUT_HISTORY =11 +}; +/* * MSI type enumeration table for all ASICs and future SW versions. * For future ASIC-LKD compatibility, we can only add new enumerations.
Signature · 1 line
2.17.1
PATCH 3/3 habanalabs: remove redundant cs validity checks
In reply to Oded GabbayFrom: Ofir Bitton <[email protected]>
During TDR handling, we check multiple times if CS is valid. No need to perform this check as CS must be valid at all time during the TDR handling.
--- drivers/misc/habanalabs/common/command_submission.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/misc/habanalabs/common/command_submission.c +2 -3
@@ -431,11 +431,10 @@ static void cs_handle_tdr(struct hl_device *hdev, struct hl_cs *cs)/* Don't cancel TDR in case this CS was timedout because we might be * running from the TDR context */ -if (cs && (cs->timedout || - hdev->timeout_jiffies ==MAX_SCHEDULE_TIMEOUT )) +if (cs->timedout || hdev->timeout_jiffies ==MAX_SCHEDULE_TIMEOUT )return ; -if (cs && cs->tdr_active) +if (cs->tdr_active)cancel_delayed_work_sync (&cs->work_tdr);spin_lock (&hdev->cs_mirror_lock);
Signature · 1 line
2.17.1