From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759132AbbJ3QYa (ORCPT ); Fri, 30 Oct 2015 12:24:30 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:35638 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751355AbbJ3QY2 (ORCPT ); Fri, 30 Oct 2015 12:24:28 -0400 Subject: Re: [PATCH v2 27/32] scsi: hisi_sas: add smp protocol support To: Arnd Bergmann References: <1445868903-183817-1-git-send-email-john.garry@huawei.com> <1445868903-183817-28-git-send-email-john.garry@huawei.com> <3976707.At0tktvfqn@wuerfel> CC: , , , , , , , , , , , , , From: John Garry Message-ID: <5633995D.20607@huawei.com> Date: Fri, 30 Oct 2015 16:22:53 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <3976707.At0tktvfqn@wuerfel> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.137.251] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.56339976.00AA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 93440e3b2e313a41da7e17a2daf1ac7a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/10/2015 13:53, Arnd Bergmann wrote: > 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()? > Can do. Actually sg_req seems only ever has one element: expander.c, smp_execute_task() sg_init_one(&task->smp_task.smp_req, req, req_size); >> + 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); > This seems reasonable. They are not swapped. > 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 > > . > cheers