On Wed, 2007-05-02 at 01:08 +0200, Oliver Endriss wrote:
> e9hack wrote:
> > Oliver Endriss wrote:
> > > Jon Burgess wrote:
> > >> It appears the problem is that the driver is using streamed PCI and
> > >> needs to explicitly sync the data otherwise it breaks when the SWIOTLB
> > >> is in use. A call to pci_unmap_sg() was missing too.
> > >>
> > >> This patch is against the current v4l-dvb HG tree.
> > >>
> > >> I've only tested the change with a budget-ci card.
> > >
> > > Has anyone a problem with this patch?
> > > If not I'll apply it tomorrow...
> >
> > If saa7146_pgtable_build_single() returns an error in
> > saa7146_vmalloc_build_pgtable(), pci_free_consistent() should be
> > also called.
>
> Correct, and pci_unmap_sg(), kfree() and vfree() must also be called.
>
> What about re-writing saa7146_vmalloc_build_pgtable():
>
> char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct
> saa7146_pgtable *pt)
> {
> int pages = (length+PAGE_SIZE-1)/PAGE_SIZE;
> char *mem = vmalloc_32(length);
> int slen = 0;
>
> if (NULL == mem)
> return NULL;
>
> if (!(pt->slist = vmalloc_to_sg(mem, pages)))
> goto err_1;
>
> if (saa7146_pgtable_alloc(pci, pt))
> goto err_2;
>
> slen = pci_map_sg(pci, pt->slist, pages, PCI_DMA_FROMDEVICE);
> if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen))
> goto err_3;
>
> pt->nents = pages;
> return mem;
>
> err_3:
> pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
> pci_unmap_sg(pci, pt->slist, pages, PCI_DMA_FROMDEVICE);
> pt->cpu = NULL;
> err_2:
> kfree(pt->slist);
> pt->slist = NULL;
> err_1:
> vfree(mem);
> return NULL;
> }
>
> Ok?
>
> CU
>
> Oliver
>
That is pretty similar to the patch I sent under the thread
"Re: [linux-dvb] inconsistent use of
saa7146_pgtable_free?"
The main difference is that I added a check for slen==0.
I also realised that there are other callers to saa7146_pgtable_free()
which did not have any sg DMA mapped so it seems wrong to add the
pci_unmap_sg() into that function. Instead I created
saa7146_vmalloc_destroy_pgtable() to do this.
Jon
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb