Skip to content

Commit b421d83

Browse files
bpsegalogabbay
authored andcommitted
habanalabs: fix device IRQ unmasking for BE host
When unmasking IRQs inside the ASIC, the driver passes an array of all the IRQ to unmask. The ASIC's CPU is working in LE so when running in a BE host, the driver needs to do the proper endianness swapping when preparing this array. In addition, this patch also fixes the endianness of a couple of kernel log debug messages that print values of packets Signed-off-by: Ben Segal <bpsegal20@gmail.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
1 parent b9040c9 commit b421d83

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

  • drivers/misc/habanalabs/goya

‎drivers/misc/habanalabs/goya/goya.c‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,9 +3314,11 @@ static int goya_validate_dma_pkt_no_mmu(struct hl_device *hdev,
33143314
int rc;
33153315

33163316
dev_dbg(hdev->dev, "DMA packet details:\n");
3317-
dev_dbg(hdev->dev, "source == 0x%llx\n", user_dma_pkt->src_addr);
3318-
dev_dbg(hdev->dev, "destination == 0x%llx\n", user_dma_pkt->dst_addr);
3319-
dev_dbg(hdev->dev, "size == %u\n", user_dma_pkt->tsize);
3317+
dev_dbg(hdev->dev, "source == 0x%llx\n",
3318+
le64_to_cpu(user_dma_pkt->src_addr));
3319+
dev_dbg(hdev->dev, "destination == 0x%llx\n",
3320+
le64_to_cpu(user_dma_pkt->dst_addr));
3321+
dev_dbg(hdev->dev, "size == %u\n", le32_to_cpu(user_dma_pkt->tsize));
33203322

33213323
ctl = le32_to_cpu(user_dma_pkt->ctl);
33223324
user_dir = (ctl & GOYA_PKT_LIN_DMA_CTL_DMA_DIR_MASK) >>
@@ -3345,9 +3347,11 @@ static int goya_validate_dma_pkt_mmu(struct hl_device *hdev,
33453347
struct packet_lin_dma *user_dma_pkt)
33463348
{
33473349
dev_dbg(hdev->dev, "DMA packet details:\n");
3348-
dev_dbg(hdev->dev, "source == 0x%llx\n", user_dma_pkt->src_addr);
3349-
dev_dbg(hdev->dev, "destination == 0x%llx\n", user_dma_pkt->dst_addr);
3350-
dev_dbg(hdev->dev, "size == %u\n", user_dma_pkt->tsize);
3350+
dev_dbg(hdev->dev, "source == 0x%llx\n",
3351+
le64_to_cpu(user_dma_pkt->src_addr));
3352+
dev_dbg(hdev->dev, "destination == 0x%llx\n",
3353+
le64_to_cpu(user_dma_pkt->dst_addr));
3354+
dev_dbg(hdev->dev, "size == %u\n", le32_to_cpu(user_dma_pkt->tsize));
33513355

33523356
/*
33533357
* WA for HW-23.
@@ -3387,7 +3391,8 @@ static int goya_validate_wreg32(struct hl_device *hdev,
33873391

33883392
dev_dbg(hdev->dev, "WREG32 packet details:\n");
33893393
dev_dbg(hdev->dev, "reg_offset == 0x%x\n", reg_offset);
3390-
dev_dbg(hdev->dev, "value == 0x%x\n", wreg_pkt->value);
3394+
dev_dbg(hdev->dev, "value == 0x%x\n",
3395+
le32_to_cpu(wreg_pkt->value));
33913396

33923397
if (reg_offset != (mmDMA_CH_0_WR_COMP_ADDR_LO & 0x1FFF)) {
33933398
dev_err(hdev->dev, "WREG32 packet with illegal address 0x%x\n",
@@ -4359,6 +4364,8 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr,
43594364
size_t total_pkt_size;
43604365
long result;
43614366
int rc;
4367+
int irq_num_entries, irq_arr_index;
4368+
__le32 *goya_irq_arr;
43624369

43634370
total_pkt_size = sizeof(struct armcp_unmask_irq_arr_packet) +
43644371
irq_arr_size;
@@ -4376,8 +4383,16 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr,
43764383
if (!pkt)
43774384
return -ENOMEM;
43784385

4379-
pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0]));
4380-
memcpy(&pkt->irqs, irq_arr, irq_arr_size);
4386+
irq_num_entries = irq_arr_size / sizeof(irq_arr[0]);
4387+
pkt->length = cpu_to_le32(irq_num_entries);
4388+
4389+
/* We must perform any necessary endianness conversation on the irq
4390+
* array being passed to the goya hardware
4391+
*/
4392+
for (irq_arr_index = 0, goya_irq_arr = (__le32 *) &pkt->irqs;
4393+
irq_arr_index < irq_num_entries ; irq_arr_index++)
4394+
goya_irq_arr[irq_arr_index] =
4395+
cpu_to_le32(irq_arr[irq_arr_index]);
43814396

43824397
pkt->armcp_pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY <<
43834398
ARMCP_PKT_CTL_OPCODE_SHIFT);

0 commit comments

Comments
 (0)