Re: [PATCH rdma-next 1/6] RDMA/umem: Combine contiguous PAGE_SIZE regions in SGEs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 04, 2019 at 08:22:13AM +0100, Christoph Hellwig wrote:
> On Fri, Jan 04, 2019 at 08:18:52AM +0100, Christoph Hellwig wrote:
> > > CH: Does sg_page_iter_dma_address() even make any sense??
> > 
> > No, it doesn't and should never have been edited.  It's one of these
> > typical scatterlist abuses in the media code :(
> 
> Actually I take this back.  Due to the sg_page_iter structure iterating
> over segments first and then pages inside the segment it actually
> is ok.  It just looks very awkward.

I'm looking at __sg_page_iter_next which does this:

static int sg_page_count(struct scatterlist *sg)
{
	return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT;
}

bool __sg_page_iter_next(struct sg_page_iter *piter)
{
[..]
	while (piter->sg_pgoffset >= sg_page_count(piter->sg)) {
		piter->sg_pgoffset -= sg_page_count(piter->sg);

Which isn't going to yield the right math if 
  sg->length != sg_dma_len(sg)

Surely we need a version of sg_page_iter_next() that uses sg_dma_len
to compute page_count if the caller intents to call
sg_page_iter_dma_address() ?

I assume it works for media because they have arranged things so that
sg_dma_len == sg->length, but in the general case with dma_map_sg that
can't be assumed.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux