Re: Port "RDMA/hns: Get rid of page operation after dma_alloc_coherent" to mlx4

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

 



On Mon, Dec 17, 2018 at 10:45:44AM -0700, Stephen Warren wrote:
> On 12/14/18 7:51 PM, Wei Hu (Xavier) wrote:
> > 
> > 
> > On 2018/12/15 3:01, Stephen Warren wrote:
> > > Wei,
> > > 
> > > I'm attempting to port 378efe798ecf "RDMA/hns: Get rid of page
> > > operation after dma_alloc_coherent" to the mlx4 driver.
> > > 
> > > One gotcha is that mlx4 has two alternative allocation/free paths; one
> > > using dma_alloc/free_coherent, and the other using
> > > alloc/__free_pages. I attempted to edit the pages path for mlx4 in a
> > > similar way to your edit to the dma coherent path:
> > > 
> > > > @@ -61,7 +61,7 @@ static void mlx4_free_icm_pages(struct mlx4_dev *dev, struct mlx4_icm_chunk *chu
> > > >          for (i = 0; i < chunk->npages; ++i)
> > > >                  __free_pages(sg_page(&chunk->mem[i]),
> > > > -                            get_order(chunk->mem[i].length));
> > > > +                            get_order(sg_dma_len(&chunk->mem[i])));
> > > >   }
> > > 
> > > > -static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order,
> > > > +static int mlx4_alloc_icm_pages(struct mlx4_icm_chunk *chunk, int order,
> > > >                                  gfp_t gfp_mask, int node)
> > > >   {
> > > > +       struct scatterlist *mem = &chunk->mem[chunk->npages];
> > > > +       void **buf = &chunk->buf[chunk->npages];
> > > >          struct page *page;
> > > >          page = alloc_pages_node(node, gfp_mask, order);
> > > > @@ -107,24 +109,29 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order,
> > > >          }
> > > >          sg_set_page(mem, page, PAGE_SIZE << order, 0);
> > > > +       sg_dma_len(mem) = PAGE_SIZE << order;
> > > > +       *buf = page_address(page);
> > > >          return 0;

why? These hunks all look wrong to me.

What are you trying to do?

The HNS driver had some bugs in how it uses the DMA API, I don't know
that the Mellanox driver has the same bugs?

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