On Fri, Mar 19, 2021 at 9:01 PM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > > On Sat, Mar 13, 2021 at 11:02:41AM +0800, Zhu Yanjun wrote: > > On Fri, Mar 12, 2021 at 10:01 PM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > > > > > > On Fri, Mar 12, 2021 at 09:49:52PM +0800, Zhu Yanjun wrote: > > > > In short, the sg list from __sg_alloc_table_from_pages is different > > > > from the sg list from ib_umem_add_sg_table. > > > > > > I don't care about different. Tell me what is wrong with what we have > > > today. > > > > > > I thought your first message said the sgl's were too small, but now > > > you seem to say they are too big? > > > > Sure. > > > > The sg list from __sg_alloc_table_from_pages, length of sg is too big. > > And the dma address is like the followings: > > > > " > > sg_dma_address(sg):0x4b3c1ce000 > > sg_dma_address(sg):0x4c3c1cd000 > > sg_dma_address(sg):0x4d3c1cc000 > > sg_dma_address(sg):0x4e3c1cb000 > > " > > Ok, so how does too big a dma segment side cause > __sg_alloc_table_from_pages() to return sg elements that are too > small? > > I assume there is some kind of maths overflow here? Please check this function __sg_alloc_table_from_pages " ... 457 /* Merge contiguous pages into the last SG */ 458 prv_len = prv->length; 459 while (n_pages && page_to_pfn(pages[0]) == paddr) { 460 if (prv->length + PAGE_SIZE > max_segment) <--max_segment is too big. So n_pages will be 0. Then the function will goto out to exit. 461 break; 462 prv->length += PAGE_SIZE; 463 paddr++; 464 pages++; 465 n_pages--; 466 } 467 if (!n_pages) 468 goto out; ... " > > Jason