[PATCH] staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap
Dan Carpenter
dan.carpenter at oracle.com
Tue Jun 25 13:25:47 UTC 2019
On Tue, Jun 25, 2019 at 02:21:41PM +0100, Ian Abbott wrote:
> On 25/06/2019 12:47, Dan Carpenter wrote:
> > On Tue, Jun 25, 2019 at 12:26:59PM +0100, Ian Abbott wrote:
> > > + } else {
> > > + for (i = 0; i < bm->n_pages; i++) {
> > > + buf = &bm->page_list[i];
> > > + ClearPageReserved(virt_to_page(buf->virt_addr));
> >
> > I think we need a NULL check here:
> >
> > if (!buf->virt_addr)
> > continue;
> >
> > > free_page((unsigned long)buf->virt_addr);
> > > }
> > > }
>
> Hi Dan, I don't think that is strictly required because bm->n_pages gets set
> to the number of successfully allocated pages (not the number of required
> pages) by comedi_buf_map_alloc():
>
> > + for (i = 0; i < n_pages; i++) {
> > + buf = &bm->page_list[i];
> > + buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL);
> > + if (!buf->virt_addr)
> > + break;
> > +
> > + SetPageReserved(virt_to_page(buf->virt_addr));
> > + }
> > +
> > + bm->n_pages = i;
>
> Here! ^
>
Oh, yeah. I misread. Sorry for the noise.
regards,
dan carpenter
More information about the devel
mailing list