Commit 8c844879 authored by Oded Gabbay's avatar Oded Gabbay Committed by Greg Kroah-Hartman

habanalabs: fix little-endian<->cpu conversion warnings

Add __cpu_to_le16/32/64 and __le16/32/64_to_cpu where needed according to
sparse.
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 70496af9
...@@ -29,7 +29,8 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr, ...@@ -29,7 +29,8 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_I2C_RD << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_I2C_RD <<
ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.i2c_bus = i2c_bus; pkt.i2c_bus = i2c_bus;
pkt.i2c_addr = i2c_addr; pkt.i2c_addr = i2c_addr;
pkt.i2c_reg = i2c_reg; pkt.i2c_reg = i2c_reg;
...@@ -54,11 +55,12 @@ static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr, ...@@ -54,11 +55,12 @@ static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_I2C_WR << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_I2C_WR <<
ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.i2c_bus = i2c_bus; pkt.i2c_bus = i2c_bus;
pkt.i2c_addr = i2c_addr; pkt.i2c_addr = i2c_addr;
pkt.i2c_reg = i2c_reg; pkt.i2c_reg = i2c_reg;
pkt.value = val; pkt.value = __cpu_to_le64(val);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
HL_DEVICE_TIMEOUT_USEC, NULL); HL_DEVICE_TIMEOUT_USEC, NULL);
...@@ -79,9 +81,10 @@ static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state) ...@@ -79,9 +81,10 @@ static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_LED_SET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_LED_SET <<
pkt.led_index = led; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.value = state; pkt.led_index = __cpu_to_le32(led);
pkt.value = __cpu_to_le64(state);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
HL_DEVICE_TIMEOUT_USEC, NULL); HL_DEVICE_TIMEOUT_USEC, NULL);
......
...@@ -39,7 +39,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args) ...@@ -39,7 +39,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
hw_ip.num_of_events = prop->num_of_events; hw_ip.num_of_events = prop->num_of_events;
memcpy(hw_ip.armcp_version, memcpy(hw_ip.armcp_version,
prop->armcp_info.armcp_version, VERSION_MAX_LEN); prop->armcp_info.armcp_version, VERSION_MAX_LEN);
hw_ip.armcp_cpld_version = prop->armcp_info.cpld_version; hw_ip.armcp_cpld_version = __le32_to_cpu(prop->armcp_info.cpld_version);
hw_ip.psoc_pci_pll_nr = prop->psoc_pci_pll_nr; hw_ip.psoc_pci_pll_nr = prop->psoc_pci_pll_nr;
hw_ip.psoc_pci_pll_nf = prop->psoc_pci_pll_nf; hw_ip.psoc_pci_pll_nf = prop->psoc_pci_pll_nf;
hw_ip.psoc_pci_pll_od = prop->psoc_pci_pll_od; hw_ip.psoc_pci_pll_od = prop->psoc_pci_pll_od;
......
...@@ -80,9 +80,9 @@ static void ext_queue_submit_bd(struct hl_device *hdev, struct hl_hw_queue *q, ...@@ -80,9 +80,9 @@ static void ext_queue_submit_bd(struct hl_device *hdev, struct hl_hw_queue *q,
bd = (struct hl_bd *) (uintptr_t) q->kernel_address; bd = (struct hl_bd *) (uintptr_t) q->kernel_address;
bd += hl_pi_2_offset(q->pi); bd += hl_pi_2_offset(q->pi);
bd->ctl = ctl; bd->ctl = __cpu_to_le32(ctl);
bd->len = len; bd->len = __cpu_to_le32(len);
bd->ptr = ptr + hdev->asic_prop.host_phys_base_address; bd->ptr = __cpu_to_le64(ptr + hdev->asic_prop.host_phys_base_address);
q->pi = hl_queue_inc_ptr(q->pi); q->pi = hl_queue_inc_ptr(q->pi);
hdev->asic_funcs->ring_doorbell(hdev, q->hw_queue_id, q->pi); hdev->asic_funcs->ring_doorbell(hdev, q->hw_queue_id, q->pi);
...@@ -249,10 +249,11 @@ static void ext_hw_queue_schedule_job(struct hl_cs_job *job) ...@@ -249,10 +249,11 @@ static void ext_hw_queue_schedule_job(struct hl_cs_job *job)
len = job->job_cb_size; len = job->job_cb_size;
ptr = cb->bus_address; ptr = cb->bus_address;
cq_pkt.data = (q->pi << CQ_ENTRY_SHADOW_INDEX_SHIFT) cq_pkt.data = __cpu_to_le32(
& CQ_ENTRY_SHADOW_INDEX_MASK; ((q->pi << CQ_ENTRY_SHADOW_INDEX_SHIFT)
cq_pkt.data |= 1 << CQ_ENTRY_SHADOW_INDEX_VALID_SHIFT; & CQ_ENTRY_SHADOW_INDEX_MASK) |
cq_pkt.data |= 1 << CQ_ENTRY_READY_SHIFT; (1 << CQ_ENTRY_SHADOW_INDEX_VALID_SHIFT) |
(1 << CQ_ENTRY_READY_SHIFT));
/* /*
* No need to protect pi_offset because scheduling to the * No need to protect pi_offset because scheduling to the
...@@ -267,7 +268,9 @@ static void ext_hw_queue_schedule_job(struct hl_cs_job *job) ...@@ -267,7 +268,9 @@ static void ext_hw_queue_schedule_job(struct hl_cs_job *job)
cq_addr += cq->pi * sizeof(struct hl_cq_entry); cq_addr += cq->pi * sizeof(struct hl_cq_entry);
hdev->asic_funcs->add_end_of_cb_packets(cb->kernel_address, len, hdev->asic_funcs->add_end_of_cb_packets(cb->kernel_address, len,
cq_addr, cq_pkt.data, q->hw_queue_id); cq_addr,
__le32_to_cpu(cq_pkt.data),
q->hw_queue_id);
q->shadow_queue[hl_pi_2_offset(q->pi)] = job; q->shadow_queue[hl_pi_2_offset(q->pi)] = job;
...@@ -292,8 +295,8 @@ static void int_hw_queue_schedule_job(struct hl_cs_job *job) ...@@ -292,8 +295,8 @@ static void int_hw_queue_schedule_job(struct hl_cs_job *job)
u64 *pi, *pbd = (u64 *) &bd; u64 *pi, *pbd = (u64 *) &bd;
bd.ctl = 0; bd.ctl = 0;
bd.len = job->job_cb_size; bd.len = __cpu_to_le32(job->job_cb_size);
bd.ptr = (u64) (uintptr_t) job->user_cb; bd.ptr = __cpu_to_le64((u64) (uintptr_t) job->user_cb);
pi = (u64 *) (uintptr_t) (q->kernel_address + pi = (u64 *) (uintptr_t) (q->kernel_address +
((q->pi & (q->int_queue_len - 1)) * sizeof(bd))); ((q->pi & (q->int_queue_len - 1)) * sizeof(bd)));
......
...@@ -26,7 +26,7 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev, ...@@ -26,7 +26,7 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev,
int rc, i, j; int rc, i, j;
for (i = 0 ; i < ARMCP_MAX_SENSORS ; i++) { for (i = 0 ; i < ARMCP_MAX_SENSORS ; i++) {
type = sensors_arr[i].type; type = __le32_to_cpu(sensors_arr[i].type);
if ((type == 0) && (sensors_arr[i].flags == 0)) if ((type == 0) && (sensors_arr[i].flags == 0))
break; break;
...@@ -58,10 +58,10 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev, ...@@ -58,10 +58,10 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev,
} }
for (i = 0 ; i < arr_size ; i++) { for (i = 0 ; i < arr_size ; i++) {
type = sensors_arr[i].type; type = __le32_to_cpu(sensors_arr[i].type);
curr_arr = sensors_by_type[type]; curr_arr = sensors_by_type[type];
curr_arr[sensors_by_type_next_index[type]++] = curr_arr[sensors_by_type_next_index[type]++] =
sensors_arr[i].flags; __le32_to_cpu(sensors_arr[i].flags);
} }
channels_info = kcalloc(num_active_sensor_types + 1, channels_info = kcalloc(num_active_sensor_types + 1,
...@@ -273,9 +273,10 @@ long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr) ...@@ -273,9 +273,10 @@ long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_TEMPERATURE_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_TEMPERATURE_GET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
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),
SENSORS_PKT_TIMEOUT, &result); SENSORS_PKT_TIMEOUT, &result);
...@@ -298,9 +299,10 @@ long hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr) ...@@ -298,9 +299,10 @@ long hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_VOLTAGE_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_VOLTAGE_GET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
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),
SENSORS_PKT_TIMEOUT, &result); SENSORS_PKT_TIMEOUT, &result);
...@@ -323,9 +325,10 @@ long hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr) ...@@ -323,9 +325,10 @@ long hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_CURRENT_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_CURRENT_GET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
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),
SENSORS_PKT_TIMEOUT, &result); SENSORS_PKT_TIMEOUT, &result);
...@@ -348,9 +351,10 @@ long hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr) ...@@ -348,9 +351,10 @@ long hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_FAN_SPEED_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_FAN_SPEED_GET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
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),
SENSORS_PKT_TIMEOUT, &result); SENSORS_PKT_TIMEOUT, &result);
...@@ -373,9 +377,10 @@ long hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr) ...@@ -373,9 +377,10 @@ long hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_PWM_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_PWM_GET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
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),
SENSORS_PKT_TIMEOUT, &result); SENSORS_PKT_TIMEOUT, &result);
...@@ -398,10 +403,11 @@ void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, ...@@ -398,10 +403,11 @@ void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_PWM_SET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_PWM_SET <<
pkt.sensor_index = sensor_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.type = attr; pkt.sensor_index = __cpu_to_le16(sensor_index);
pkt.value = value; pkt.type = __cpu_to_le16(attr);
pkt.value = __cpu_to_le64(value);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
SENSORS_PKT_TIMEOUT, NULL); SENSORS_PKT_TIMEOUT, NULL);
......
...@@ -161,8 +161,8 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg) ...@@ -161,8 +161,8 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg)
while (1) { while (1) {
bool entry_ready = bool entry_ready =
((eq_base[eq->ci].hdr.ctl & EQ_CTL_READY_MASK) ((__le32_to_cpu(eq_base[eq->ci].hdr.ctl) &
>> EQ_CTL_READY_SHIFT); EQ_CTL_READY_MASK) >> EQ_CTL_READY_SHIFT);
if (!entry_ready) if (!entry_ready)
break; break;
...@@ -194,7 +194,9 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg) ...@@ -194,7 +194,9 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg)
} }
skip_irq: skip_irq:
/* Clear EQ entry ready bit */ /* Clear EQ entry ready bit */
eq_entry->hdr.ctl &= ~EQ_CTL_READY_MASK; eq_entry->hdr.ctl =
__cpu_to_le32(__le32_to_cpu(eq_entry->hdr.ctl) &
~EQ_CTL_READY_MASK);
eq->ci = hl_eq_inc_ptr(eq->ci); eq->ci = hl_eq_inc_ptr(eq->ci);
......
...@@ -21,12 +21,12 @@ long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr) ...@@ -21,12 +21,12 @@ long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
if (curr) if (curr)
pkt.ctl = ARMCP_PACKET_FREQUENCY_CURR_GET << pkt.ctl = __cpu_to_le32(ARMCP_PACKET_FREQUENCY_CURR_GET <<
ARMCP_PKT_CTL_OPCODE_SHIFT; ARMCP_PKT_CTL_OPCODE_SHIFT);
else else
pkt.ctl = ARMCP_PACKET_FREQUENCY_GET << pkt.ctl = __cpu_to_le32(ARMCP_PACKET_FREQUENCY_GET <<
ARMCP_PKT_CTL_OPCODE_SHIFT; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.pll_index = pll_index; pkt.pll_index = __cpu_to_le32(pll_index);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
SET_CLK_PKT_TIMEOUT, &result); SET_CLK_PKT_TIMEOUT, &result);
...@@ -48,9 +48,10 @@ void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq) ...@@ -48,9 +48,10 @@ void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_FREQUENCY_SET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_FREQUENCY_SET <<
pkt.pll_index = pll_index; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.value = freq; pkt.pll_index = __cpu_to_le32(pll_index);
pkt.value = __cpu_to_le64(freq);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
SET_CLK_PKT_TIMEOUT, NULL); SET_CLK_PKT_TIMEOUT, NULL);
...@@ -69,7 +70,8 @@ u64 hl_get_max_power(struct hl_device *hdev) ...@@ -69,7 +70,8 @@ u64 hl_get_max_power(struct hl_device *hdev)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_MAX_POWER_GET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_MAX_POWER_GET <<
ARMCP_PKT_CTL_OPCODE_SHIFT);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
SET_PWR_PKT_TIMEOUT, &result); SET_PWR_PKT_TIMEOUT, &result);
...@@ -89,8 +91,9 @@ void hl_set_max_power(struct hl_device *hdev, u64 value) ...@@ -89,8 +91,9 @@ void hl_set_max_power(struct hl_device *hdev, u64 value)
memset(&pkt, 0, sizeof(pkt)); memset(&pkt, 0, sizeof(pkt));
pkt.ctl = ARMCP_PACKET_MAX_POWER_SET << ARMCP_PKT_CTL_OPCODE_SHIFT; pkt.ctl = __cpu_to_le32(ARMCP_PACKET_MAX_POWER_SET <<
pkt.value = value; ARMCP_PKT_CTL_OPCODE_SHIFT);
pkt.value = __cpu_to_le64(value);
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
SET_PWR_PKT_TIMEOUT, NULL); SET_PWR_PKT_TIMEOUT, NULL);
......
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