From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sagi Grimberg Subject: Re: [PATCH 6/6] IB/srp: Fix srp_map_sg_fr() Date: Wed, 2 Dec 2015 13:59:38 +0200 Message-ID: <565EDD2A.6050407@dev.mellanox.co.il> References: <565DE3EC.2070002@sandisk.com> <565DE4BA.1040703@sandisk.com> <565DE864.5050407@dev.mellanox.co.il> <565DE977.2070606@sandisk.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <565DE977.2070606-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Bart Van Assche , Doug Ledford Cc: Christoph Hellwig , Sebastian Parschauer , "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" List-Id: linux-rdma@vger.kernel.org On 01/12/2015 20:39, Bart Van Assche wrote: > On 12/01/2015 10:35 AM, Sagi Grimberg wrote: >>> After dma_map_sg() has been called the return value of that function >>> must be used as the number of elements in the scatterlist instead of >>> scsi_sg_count(). >> >> Umm, but ib_map_mr_sg iterates on the sg list. Say you have sg_nents=3 >> and after mapping you got dma_nents=2 (2 entries are contig) and you >> pass that, ib_sg_to_pages will only iterate on 2 elements won't it? am >> I missing something? > > Hello Sagi, > > From https://www.kernel.org/doc/Documentation/DMA-API-HOWTO.txt: > > > With scatterlists, you map a region gathered from several regions by: > > int i, count = dma_map_sg(dev, sglist, nents, direction); > struct scatterlist *sg; > > for_each_sg(sglist, sg, count, i) { > hw_address[i] = sg_dma_address(sg); > hw_len[i] = sg_dma_len(sg); > } > > where nents is the number of entries in the sglist. > From Documentation/DMA_API.txt int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) Returns: the number of DMA address segments mapped (this may be shorter than passed in if some elements of the scatter/gather list are physically or virtually adjacent and an IOMMU maps them with a single entry). -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html