Commit 439bc47b authored by Alon Mizrahi's avatar Alon Mizrahi Committed by Oded Gabbay

habanalabs: firmware returns 64bit argument

F/W message returns 64bit value but up until now we casted it to
a 32bit variable, instead of receiving 64bit in the first place.
Signed-off-by: default avatarAlon Mizrahi <amizrahi@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 00e1b59c
...@@ -22,6 +22,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr, ...@@ -22,6 +22,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
u8 i2c_reg, long *val) u8 i2c_reg, long *val)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
if (!hl_device_operational(hdev, NULL)) if (!hl_device_operational(hdev, NULL))
...@@ -36,7 +37,9 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr, ...@@ -36,7 +37,9 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
pkt.i2c_reg = i2c_reg; pkt.i2c_reg = i2c_reg;
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, val); 0, &result);
*val = (long) result;
if (rc) if (rc)
dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc); dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
......
...@@ -88,7 +88,7 @@ int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode) ...@@ -88,7 +88,7 @@ int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode)
} }
int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
u16 len, u32 timeout, long *result) u16 len, u32 timeout, u64 *result)
{ {
struct cpucp_packet *pkt; struct cpucp_packet *pkt;
dma_addr_t pkt_dma_addr; dma_addr_t pkt_dma_addr;
...@@ -143,7 +143,7 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, ...@@ -143,7 +143,7 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
>> CPUCP_PKT_CTL_OPCODE_SHIFT); >> CPUCP_PKT_CTL_OPCODE_SHIFT);
rc = -EIO; rc = -EIO;
} else if (result) { } else if (result) {
*result = (long) le64_to_cpu(pkt->result); *result = le64_to_cpu(pkt->result);
} }
out: out:
...@@ -157,7 +157,7 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, ...@@ -157,7 +157,7 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type) int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
long result; u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -180,7 +180,7 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr, ...@@ -180,7 +180,7 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
{ {
struct cpucp_unmask_irq_arr_packet *pkt; struct cpucp_unmask_irq_arr_packet *pkt;
size_t total_pkt_size; size_t total_pkt_size;
long result; u64 result;
int rc; int rc;
total_pkt_size = sizeof(struct cpucp_unmask_irq_arr_packet) + total_pkt_size = sizeof(struct cpucp_unmask_irq_arr_packet) +
...@@ -219,7 +219,7 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr, ...@@ -219,7 +219,7 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
int hl_fw_test_cpu_queue(struct hl_device *hdev) int hl_fw_test_cpu_queue(struct hl_device *hdev)
{ {
struct cpucp_packet test_pkt = {}; struct cpucp_packet test_pkt = {};
long result; u64 result;
int rc; int rc;
test_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST << test_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST <<
...@@ -232,7 +232,7 @@ int hl_fw_test_cpu_queue(struct hl_device *hdev) ...@@ -232,7 +232,7 @@ int hl_fw_test_cpu_queue(struct hl_device *hdev)
if (!rc) { if (!rc) {
if (result != CPUCP_PACKET_FENCE_VAL) if (result != CPUCP_PACKET_FENCE_VAL)
dev_err(hdev->dev, dev_err(hdev->dev,
"CPU queue test failed (0x%08lX)\n", result); "CPU queue test failed (%#08llx)\n", result);
} else { } else {
dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc); dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc);
} }
...@@ -263,7 +263,7 @@ void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size, ...@@ -263,7 +263,7 @@ void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,
int hl_fw_send_heartbeat(struct hl_device *hdev) int hl_fw_send_heartbeat(struct hl_device *hdev)
{ {
struct cpucp_packet hb_pkt = {}; struct cpucp_packet hb_pkt = {};
long result; u64 result;
int rc; int rc;
hb_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST << hb_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST <<
...@@ -285,7 +285,7 @@ int hl_fw_cpucp_info_get(struct hl_device *hdev) ...@@ -285,7 +285,7 @@ int hl_fw_cpucp_info_get(struct hl_device *hdev)
struct cpucp_packet pkt = {}; struct cpucp_packet pkt = {};
void *cpucp_info_cpu_addr; void *cpucp_info_cpu_addr;
dma_addr_t cpucp_info_dma_addr; dma_addr_t cpucp_info_dma_addr;
long result; u64 result;
int rc; int rc;
cpucp_info_cpu_addr = cpucp_info_cpu_addr =
...@@ -336,7 +336,7 @@ int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size) ...@@ -336,7 +336,7 @@ int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size)
struct cpucp_packet pkt = {}; struct cpucp_packet pkt = {};
void *eeprom_info_cpu_addr; void *eeprom_info_cpu_addr;
dma_addr_t eeprom_info_dma_addr; dma_addr_t eeprom_info_dma_addr;
long result; u64 result;
int rc; int rc;
eeprom_info_cpu_addr = eeprom_info_cpu_addr =
...@@ -379,7 +379,7 @@ int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev, ...@@ -379,7 +379,7 @@ int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev,
struct hl_info_pci_counters *counters) struct hl_info_pci_counters *counters)
{ {
struct cpucp_packet pkt = {}; struct cpucp_packet pkt = {};
long result; u64 result;
int rc; int rc;
pkt.ctl = cpu_to_le32(CPUCP_PACKET_PCIE_THROUGHPUT_GET << pkt.ctl = cpu_to_le32(CPUCP_PACKET_PCIE_THROUGHPUT_GET <<
...@@ -426,7 +426,7 @@ int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev, ...@@ -426,7 +426,7 @@ int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev,
int hl_fw_cpucp_total_energy_get(struct hl_device *hdev, u64 *total_energy) int hl_fw_cpucp_total_energy_get(struct hl_device *hdev, u64 *total_energy)
{ {
struct cpucp_packet pkt = {}; struct cpucp_packet pkt = {};
long result; u64 result;
int rc; int rc;
pkt.ctl = cpu_to_le32(CPUCP_PACKET_TOTAL_ENERGY_GET << pkt.ctl = cpu_to_le32(CPUCP_PACKET_TOTAL_ENERGY_GET <<
...@@ -452,7 +452,7 @@ int hl_fw_cpucp_pll_info_get(struct hl_device *hdev, ...@@ -452,7 +452,7 @@ int hl_fw_cpucp_pll_info_get(struct hl_device *hdev,
u32 *pll_info) u32 *pll_info)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
long result; u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -467,7 +467,7 @@ int hl_fw_cpucp_pll_info_get(struct hl_device *hdev, ...@@ -467,7 +467,7 @@ int hl_fw_cpucp_pll_info_get(struct hl_device *hdev,
if (rc) if (rc)
dev_err(hdev->dev, "Failed to read PLL info, error %d\n", rc); dev_err(hdev->dev, "Failed to read PLL info, error %d\n", rc);
*pll_info = result; *pll_info = (u32) result;
return rc; return rc;
} }
......
...@@ -925,7 +925,7 @@ struct hl_asic_funcs { ...@@ -925,7 +925,7 @@ struct hl_asic_funcs {
int (*get_eeprom_data)(struct hl_device *hdev, void *data, int (*get_eeprom_data)(struct hl_device *hdev, void *data,
size_t max_size); size_t max_size);
int (*send_cpu_message)(struct hl_device *hdev, u32 *msg, int (*send_cpu_message)(struct hl_device *hdev, u32 *msg,
u16 len, u32 timeout, long *result); u16 len, u32 timeout, u64 *result);
int (*pci_bars_map)(struct hl_device *hdev); int (*pci_bars_map)(struct hl_device *hdev);
int (*init_iatu)(struct hl_device *hdev); int (*init_iatu)(struct hl_device *hdev);
u32 (*rreg)(struct hl_device *hdev, u32 reg); u32 (*rreg)(struct hl_device *hdev, u32 reg);
...@@ -2178,7 +2178,7 @@ int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name, ...@@ -2178,7 +2178,7 @@ int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name,
void __iomem *dst, u32 src_offset, u32 size); void __iomem *dst, u32 src_offset, u32 size);
int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode); int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode);
int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
u16 len, u32 timeout, long *result); u16 len, u32 timeout, u64 *result);
int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type); int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type);
int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr, int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
size_t irq_arr_size); size_t irq_arr_size);
......
...@@ -312,6 +312,7 @@ int hl_get_temperature(struct hl_device *hdev, ...@@ -312,6 +312,7 @@ int hl_get_temperature(struct hl_device *hdev,
int sensor_index, u32 attr, long *value) int sensor_index, u32 attr, long *value)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -322,7 +323,9 @@ int hl_get_temperature(struct hl_device *hdev, ...@@ -322,7 +323,9 @@ int hl_get_temperature(struct hl_device *hdev,
pkt.type = __cpu_to_le16(attr); pkt.type = __cpu_to_le16(attr);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, value); 0, &result);
*value = (long) result;
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
...@@ -363,6 +366,7 @@ int hl_get_voltage(struct hl_device *hdev, ...@@ -363,6 +366,7 @@ int hl_get_voltage(struct hl_device *hdev,
int sensor_index, u32 attr, long *value) int sensor_index, u32 attr, long *value)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -373,7 +377,9 @@ int hl_get_voltage(struct hl_device *hdev, ...@@ -373,7 +377,9 @@ int hl_get_voltage(struct hl_device *hdev,
pkt.type = __cpu_to_le16(attr); pkt.type = __cpu_to_le16(attr);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, value); 0, &result);
*value = (long) result;
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
...@@ -389,6 +395,7 @@ int hl_get_current(struct hl_device *hdev, ...@@ -389,6 +395,7 @@ int hl_get_current(struct hl_device *hdev,
int sensor_index, u32 attr, long *value) int sensor_index, u32 attr, long *value)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -399,7 +406,9 @@ int hl_get_current(struct hl_device *hdev, ...@@ -399,7 +406,9 @@ int hl_get_current(struct hl_device *hdev,
pkt.type = __cpu_to_le16(attr); pkt.type = __cpu_to_le16(attr);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, value); 0, &result);
*value = (long) result;
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
...@@ -415,6 +424,7 @@ int hl_get_fan_speed(struct hl_device *hdev, ...@@ -415,6 +424,7 @@ int hl_get_fan_speed(struct hl_device *hdev,
int sensor_index, u32 attr, long *value) int sensor_index, u32 attr, long *value)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -425,7 +435,9 @@ int hl_get_fan_speed(struct hl_device *hdev, ...@@ -425,7 +435,9 @@ int hl_get_fan_speed(struct hl_device *hdev,
pkt.type = __cpu_to_le16(attr); pkt.type = __cpu_to_le16(attr);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, value); 0, &result);
*value = (long) result;
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
...@@ -441,6 +453,7 @@ int hl_get_pwm_info(struct hl_device *hdev, ...@@ -441,6 +453,7 @@ int hl_get_pwm_info(struct hl_device *hdev,
int sensor_index, u32 attr, long *value) int sensor_index, u32 attr, long *value)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -451,7 +464,9 @@ int hl_get_pwm_info(struct hl_device *hdev, ...@@ -451,7 +464,9 @@ int hl_get_pwm_info(struct hl_device *hdev,
pkt.type = __cpu_to_le16(attr); pkt.type = __cpu_to_le16(attr);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
0, value); 0, &result);
*value = (long) result;
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr) long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
long result; u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -32,10 +32,10 @@ long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr) ...@@ -32,10 +32,10 @@ long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
dev_err(hdev->dev, dev_err(hdev->dev,
"Failed to get frequency of PLL %d, error %d\n", "Failed to get frequency of PLL %d, error %d\n",
pll_index, rc); pll_index, rc);
result = rc; return rc;
} }
return result; return (long) result;
} }
void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq) void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
...@@ -62,7 +62,7 @@ void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq) ...@@ -62,7 +62,7 @@ void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
u64 hl_get_max_power(struct hl_device *hdev) u64 hl_get_max_power(struct hl_device *hdev)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
long result; u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
...@@ -75,7 +75,7 @@ u64 hl_get_max_power(struct hl_device *hdev) ...@@ -75,7 +75,7 @@ u64 hl_get_max_power(struct hl_device *hdev)
if (rc) { if (rc) {
dev_err(hdev->dev, "Failed to get max power, error %d\n", rc); dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
result = rc; return (u64) rc;
} }
return result; return result;
......
...@@ -4561,7 +4561,7 @@ static void *gaudi_get_int_queue_base(struct hl_device *hdev, ...@@ -4561,7 +4561,7 @@ static void *gaudi_get_int_queue_base(struct hl_device *hdev,
} }
static int gaudi_send_cpu_message(struct hl_device *hdev, u32 *msg, static int gaudi_send_cpu_message(struct hl_device *hdev, u32 *msg,
u16 len, u32 timeout, long *result) u16 len, u32 timeout, u64 *result)
{ {
struct gaudi_device *gaudi = hdev->asic_specific; struct gaudi_device *gaudi = hdev->asic_specific;
......
...@@ -2954,7 +2954,7 @@ static int goya_send_job_on_qman0(struct hl_device *hdev, struct hl_cs_job *job) ...@@ -2954,7 +2954,7 @@ static int goya_send_job_on_qman0(struct hl_device *hdev, struct hl_cs_job *job)
} }
int goya_send_cpu_message(struct hl_device *hdev, u32 *msg, u16 len, int goya_send_cpu_message(struct hl_device *hdev, u32 *msg, u16 len,
u32 timeout, long *result) u32 timeout, u64 *result)
{ {
struct goya_device *goya = hdev->asic_specific; struct goya_device *goya = hdev->asic_specific;
...@@ -4540,7 +4540,7 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr, ...@@ -4540,7 +4540,7 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr,
{ {
struct cpucp_unmask_irq_arr_packet *pkt; struct cpucp_unmask_irq_arr_packet *pkt;
size_t total_pkt_size; size_t total_pkt_size;
long result; u64 result;
int rc; int rc;
int irq_num_entries, irq_arr_index; int irq_num_entries, irq_arr_index;
__le32 *goya_irq_arr; __le32 *goya_irq_arr;
...@@ -4599,7 +4599,7 @@ static int goya_soft_reset_late_init(struct hl_device *hdev) ...@@ -4599,7 +4599,7 @@ static int goya_soft_reset_late_init(struct hl_device *hdev)
static int goya_unmask_irq(struct hl_device *hdev, u16 event_type) static int goya_unmask_irq(struct hl_device *hdev, u16 event_type)
{ {
struct cpucp_packet pkt; struct cpucp_packet pkt;
long result; u64 result;
int rc; int rc;
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
......
...@@ -192,7 +192,7 @@ int goya_test_queue(struct hl_device *hdev, u32 hw_queue_id); ...@@ -192,7 +192,7 @@ int goya_test_queue(struct hl_device *hdev, u32 hw_queue_id);
int goya_test_queues(struct hl_device *hdev); int goya_test_queues(struct hl_device *hdev);
int goya_test_cpu_queue(struct hl_device *hdev); int goya_test_cpu_queue(struct hl_device *hdev);
int goya_send_cpu_message(struct hl_device *hdev, u32 *msg, u16 len, int goya_send_cpu_message(struct hl_device *hdev, u32 *msg, u16 len,
u32 timeout, long *result); u32 timeout, u64 *result);
long goya_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr); long goya_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr);
long goya_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr); long goya_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment