habanalabs: minor fixes to signals from graph
PATCH 1/4 habanalabs: minor fixes to signals from graph
From: farah kassabri <[email protected]>
- fix signals reservation flow when setting the next available signal value.
- fix how driver treats the wait offset, by decrement 1 from the user value before actually building the wait cs.
- fix debug logs to print in decimal the sob value instead of hex.
--- .../habanalabs/common/command_submission.c | 30 +++++++++---------- drivers/misc/habanalabs/common/hw_queue.c | 16 ++++++---- drivers/misc/habanalabs/gaudi/gaudi.c | 7 +++-- 3 files changed, 29 insertions(+), 24 deletions(-)
drivers/misc/habanalabs/common/command_submission.c +14 -16
@@ -556,7 +556,7 @@ static inline void cs_release_sob_reset_handler(struct hl_device *hdev, (hl_cs_cmpl->type == CS_TYPE_COLLECTIVE_WAIT) || (!!hl_cs_cmpl->encaps_signals)) { dev_dbg(hdev->dev, - "CS 0x%llx type %d finished, sob_id: %d, sob_val: 0x%x\n", + "CS 0x%llx type %d finished, sob_id: %d, sob_val: %u\n", hl_cs_cmpl->cs_seq, hl_cs_cmpl->type, hl_cs_cmpl->hw_sob->sob_id,
@@ -1694,7 +1694,15 @@ int hl_cs_signal_sob_wraparound_handler(struct hl_device *hdev, u32 q_idx,return -EINVAL ; } - prop->next_sob_val = count; +/* +* next_sob_val always points to the next available signal +* in the sob, so in encaps signals it will be the next one +* after reserving the required amount. +*/ +if (encaps_sig) + prop->next_sob_val = count +1 ; +else + prop->next_sob_val = count;/* only two SOBs are currently in use */ prop->curr_sob_offset = other_sob_offset;
@@ -1710,11 +1718,11 @@ int hl_cs_signal_sob_wraparound_handler(struct hl_device *hdev, u32 q_idx,* in addition, if we have combination of cs signal and * encaps, and at the point we need to reset the sob there was * no more reservations and only signal cs keep coming, -* in such case we need to signal_cs to put the refcount and +* in such case we need signal_cs to put the refcount and * reset the sob. */ if (other_sob->need_reset) -kref_put (&other_sob->kref, hl_sob_reset); +hw_sob_put (other_sob);if (encaps_sig) {/* set reset indication for the sob */
@@ -1946,16 +1954,6 @@ static int cs_ioctl_reserve_signals(struct hl_fpriv *hpriv,*/ handle->pre_sob_val = prop->next_sob_val - handle->count; -/* set the hw_sob to the handle after calling the sob wraparound handler -* since sob could have changed. -*/ - handle->hw_sob = hw_sob; - -/* store the current sob value for unreserve validity check, and -* signal offset support -*/ - handle->pre_sob_val = prop->next_sob_val - handle->count; - *signals_count = prop->next_sob_val; hdev->asic_funcs->hw_queues_unlock (hdev);
@@ -1963,9 +1961,9 @@ static int cs_ioctl_reserve_signals(struct hl_fpriv *hpriv, *handle_id = hdl_id;dev_dbg (hdev->dev, -"Signals reserved, sob_id: %d, sob addr: 0x%x, sob val: 0x%x, q_idx: %d, hdl_id: %d\n" , +"Signals reserved, sob_id: %d, sob addr: 0x%x, last sob_val: %u, q_idx: %d, hdl_id: %d\n" , hw_sob->sob_id, handle->hw_sob->sob_addr, - prop->next_sob_val, q_idx, hdl_id); + prop->next_sob_val -1 , q_idx, hdl_id); goto out; remove_idr:
drivers/misc/habanalabs/common/hw_queue.c +11 -5
@@ -416,7 +416,7 @@ static int init_signal_cs(struct hl_device *hdev, cs_cmpl->sob_val = prop->next_sob_val;dev_dbg (hdev->dev, -"generate signal CB, sob_id: %d, sob val: 0x%x, q_idx: %d, seq: %llu\n" , +"generate signal CB, sob_id: %d, sob val: %u, q_idx: %d, seq: %llu\n" , cs_cmpl->hw_sob->sob_id, cs_cmpl->sob_val, q_idx, cs_cmpl->cs_seq);
@@ -442,9 +442,13 @@ void hl_hw_queue_encaps_sig_set_sob_info(struct hl_device *hdev,/* Note that encaps_sig_wait_offset was validated earlier in the flow * for offset value which exceeds the max reserved signal count. +* always decrement 1 of the offset since when the user +* set offset 1 for example he mean to wait only for the first +* signal only, which will be pre_sob_val, and if he set offset 2 +* then the value required is (pre_sob_val + 1) and so on... */ cs_cmpl->sob_val = handle->pre_sob_val + - (job->encaps_sig_wait_offset); + (job->encaps_sig_wait_offset -1 ); } static int init_wait_cs(struct hl_device *hdev, struct hl_cs *cs,
@@ -469,7 +473,7 @@ static int init_wait_cs(struct hl_device *hdev, struct hl_cs *cs,*/ hl_hw_queue_encaps_sig_set_sob_info (hdev, cs, job, cs_cmpl); - dev_dbg(hdev->dev, "Wait for encaps signals handle, qidx(%u), CS sequence(%llu), sob val: %u, offset: %u\n", + dev_dbg(hdev->dev, "Wait for encaps signals handle, qidx(%u), CS sequence(%llu), sob val: 0x%x, offset: %u\n", cs->encaps_sig_hdl->q_idx, cs->encaps_sig_hdl->cs_seq, cs_cmpl->sob_val,
@@ -587,10 +591,12 @@ static int encaps_sig_first_staged_cs_handler cs_cmpl->sob_val = encaps_sig_hdl->pre_sob_val + encaps_sig_hdl->count; -dev_dbg (hdev->dev,"CS seq (%llu) added to encaps signal handler id (%u), count(%u), qidx(%u)\n" , +dev_dbg (hdev->dev,"CS seq (%llu) added to encaps signal handler id (%u), count(%u), qidx(%u), sob(%u), val(%u)\n" , cs->sequence, encaps_sig_hdl->id, encaps_sig_hdl->count, - encaps_sig_hdl->q_idx); + encaps_sig_hdl->q_idx, + cs_cmpl->hw_sob->sob_id, + cs_cmpl->sob_val); }else { dev_err(hdev->dev, "encaps handle id(%u) wasn't found!\n",
drivers/misc/habanalabs/gaudi/gaudi.c +4 -3
@@ -1223,9 +1223,10 @@ static void gaudi_collective_slave_init_job(struct hl_device *hdev,hl_hw_queue_encaps_sig_set_sob_info (hdev, job->cs, job, cs_cmpl); -dev_dbg (hdev->dev,"collective wait: Sequence %llu found, sob val incremented to: %u\n" , +dev_dbg (hdev->dev,"collective wait: Sequence %llu found, sob_id: %u, wait for sob_val: %u\n" , job->cs->sequence, - job->cs->encaps_sig_hdl->pre_sob_val); + cs_cmpl->hw_sob->sob_id, + cs_cmpl->sob_val); }/* Add to wait CBs using slave monitor */
@@ -1238,7 +1239,7 @@ static void gaudi_collective_slave_init_job(struct hl_device *hdev, wait_prop.size = cb_size;dev_dbg (hdev->dev, -"Generate slave wait CB, sob %d, val:0x%x, mon %d, q %d\n" , +"Generate slave wait CB, sob %d, val:%x, mon %d, q %d\n" , cs_cmpl->hw_sob->sob_id, cs_cmpl->sob_val, prop->collective_slave_mon_id, queue_id);
Signature · 1 line
2.25.1
PATCH 2/4 habanalabs: remove redundant warning message
This warning is redundant as we will print a notice in case the device is still in use after the FD was closed. No need to print the same message per context.
--- drivers/misc/habanalabs/common/context.c | 3 --- 1 file changed, 3 deletions(-)
drivers/misc/habanalabs/common/context.c +0 -3
@@ -184,9 +184,6 @@ void hl_ctx_free(struct hl_device *hdev, struct hl_ctx *ctx) {if (kref_put (&ctx->refcount, hl_ctx_do_release) ==1 )return ; - -dev_warn (hdev->dev, -"user process released device but its command submissions are still executing\n" ); }int hl_ctx_init (struct hl_device *hdev,struct hl_ctx *ctx,bool is_kernel_ctx)
Signature · 1 line
2.25.1
PATCH 3/4 habanalabs: expose server type in INFO IOCTL
In reply to Oded GabbayAdd the server type property to the hl_info_hw_ip_info structure that is exposed to the user via the INFO IOCTL.
This is needed by the userspace s/w stack to know the connections map of the internal links that connect the ASIC among themselves inside the server.
The F/W will tell us, as part of the NIC information, the server type that the GAUDI is located in.
--- drivers/misc/habanalabs/common/firmware_if.c | 2 +- drivers/misc/habanalabs/common/habanalabs.h | 3 ++ .../misc/habanalabs/common/habanalabs_ioctl.c | 2 + drivers/misc/habanalabs/gaudi/gaudi.c | 2 + drivers/misc/habanalabs/goya/goya.c | 2 + .../misc/habanalabs/include/common/cpucp_if.h | 11 +++++ include/uapi/misc/habanalabs.h | 49 +++++++++++++++++-- 7 files changed, 66 insertions(+), 5 deletions(-)
drivers/misc/habanalabs/common/firmware_if.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 /* -* Copyright 2016-2019 HabanaLabs, Ltd. +* Copyright 2016-2021 HabanaLabs, Ltd. * All Rights Reserved. */
drivers/misc/habanalabs/common/habanalabs.h +3 -0
@@ -489,6 +489,8 @@ struct hl_hints_range {* reserved for the user * @first_available_cq: first available CQ for the user. * @user_interrupt_count: number of user interrupts. +* @server_type: Server type that the ASIC is currently installed in. +* The value is according to enum hl_server_type in uapi file. * @tpc_enabled_mask: which TPCs are enabled. * @completion_queues_count: number of completion queues. * @fw_security_enabled: true if security measures are enabled in firmware,
@@ -570,6 +572,7 @@ struct asic_fixed_properties {u16 first_available_user_msix_interrupt;u16 first_available_cq[HL_MAX_DCORES ];u16 user_interrupt_count; +u16 server_type;u8 tpc_enabled_mask;u8 completion_queues_count;u8 fw_security_enabled;
drivers/misc/habanalabs/common/habanalabs_ioctl.c +2 -0
@@ -94,6 +94,8 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args) hw_ip.first_available_interrupt_id = prop->first_available_user_msix_interrupt; + hw_ip.server_type = prop->server_type; +return copy_to_user (out, &hw_ip,min ((size_t ) size,sizeof (hw_ip))) ? -EFAULT :0 ; }
drivers/misc/habanalabs/gaudi/gaudi.c +2 -0
@@ -645,6 +645,8 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev) prop->hard_reset_done_by_fw = false; prop->gic_interrupts_enable = true; + prop->server_type =HL_SERVER_TYPE_UNKNOWN ; +return 0 ; }
drivers/misc/habanalabs/goya/goya.c +2 -0
@@ -469,6 +469,8 @@ int goya_set_fixed_properties(struct hl_device *hdev) prop->hard_reset_done_by_fw = false; prop->gic_interrupts_enable = true; + prop->server_type =HL_SERVER_TYPE_UNKNOWN ; +return 0 ; }
drivers/misc/habanalabs/include/common/cpucp_if.h +11 -0
@@ -700,6 +700,15 @@ struct cpucp_mac_addr {__u8 mac_addr[ETH_ALEN ]; }; +enum cpucp_serdes_type { +TYPE_1_SERDES_TYPE , +TYPE_2_SERDES_TYPE , +HLS1_SERDES_TYPE , +HLS1H_SERDES_TYPE , +UNKNOWN_SERDES_TYPE , +MAX_NUM_SERDES_TYPE =UNKNOWN_SERDES_TYPE +}; +struct cpucp_nic_info {struct cpucp_mac_addr mac_addrs[CPUCP_MAX_NICS ];__le64 link_mask[CPUCP_NIC_MASK_ARR_LEN ];
@@ -708,6 +717,8 @@ struct cpucp_nic_info {__le64 link_ext_mask[CPUCP_NIC_MASK_ARR_LEN ];__u8 qsfp_eeprom[CPUCP_NIC_QSFP_EEPROM_MAX_LEN ];__le64 auto_neg_mask[CPUCP_NIC_MASK_ARR_LEN ]; +__le16 serdes_type;/* enum cpucp_serdes_type */ + __u8 reserved[6]; };#endif /* CPUCP_IF_H */
include/uapi/misc/habanalabs.h +45 -4
75 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 4/4 habanalabs: convert PCI BAR offset to u64
In reply to Oded GabbayFrom: Ohad Sharabi <[email protected]>
Done as the bar size can exceed 4GB.
--- drivers/misc/habanalabs/common/habanalabs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/habanalabs.h +1 -1
@@ -931,7 +931,7 @@ struct pci_mem_region {u64 region_base;u64 region_size;u64 bar_size; -u32 offset_in_bar; +u64 offset_in_bar;u8 bar_id;u8 used; };
Signature · 1 line
2.25.1