Re: [PATCH v2 27/32] scsi: hisi_sas: add smp protocol support

From: Arnd Bergmann
Date: Fri Oct 30 2015 - 09:54:22 EST


On Monday 26 October 2015 22:14:58 John Garry wrote:

> + /*
> + * DMA-map SMP request, response buffers
> + */
> + /* req */
> + sg_req = &task->smp_task.smp_req;
> + elem = dma_map_sg(dev, sg_req, 1, DMA_TO_DEVICE);
> + if (!elem)
> + return -ENOMEM;
> + req_len = sg_dma_len(sg_req);
> + req_dma_addr = sg_dma_address(sg_req);

If you only use the first element, could you just use dma_map_single()?

> + hdr->cmd_table_addr_lo = cpu_to_le32(lower_32_bits(req_dma_addr));
> + hdr->cmd_table_addr_hi = cpu_to_le32(upper_32_bits(req_dma_addr));
> +
> + hdr->sts_buffer_addr_lo =
> + cpu_to_le32(lower_32_bits(slot->status_buffer_dma));
> + hdr->sts_buffer_addr_hi =
> + cpu_to_le32(upper_32_bits(slot->status_buffer_dma));
> +
>

I see these a lot in your code. Could you replace this wit

hdr->cmd_table_addr = cpu_to_le64(req_dma_addr);

and so on? That would be much more readable. Or are the two __le32 variables
swapped? If so, you could add a small helper function like

static inline __le64 cpu_to_le64_wordswapped(u64 val)
{
return cpu_to_le64(val >> 32 | val << 32);
}

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/