[pxc] Re: PXC strangeness on Mandriva 2006.0

M Bianchi mbianchi@Foveal.com
Mon Jul 10 20:14:37 CEST 2006


On Sun, Jul 09, 2006 at 05:32:19PM -0400, M Bianchi wrote:
> I've been having trouble bringing up 2  PXC200AL  framegrabbers up on an
>  Intel D949GNT  mother board with Celeron 2.53GHz processor under
>  Mandriva 2006.0 (kernel 2.6.12-12mdk)  and  pxc-snapshot-051124 .
> 	:
> 	:

I have found half the problem.

By putting  printk()  calls at all the
	return -ENOMEM;

lines I found that the one that was returning was in  dma.c .

/* this function allocates all stuff for DMA */
int px_allocate_dma_and_program(Px_Dev *dev, int size, int nbufs, int prio)
{
    unsigned long flags;
    unsigned long dmabuffer;
    void *dmaremap;
    Px_Buffer *b;
    int i, errors = 0;

    px_free_dma_and_program(dev);

    /* Our status should be "all or nothing". Therefore, allocate stuff
       first, and only if successful place stuff in dev */

    b = __vmalloc(nbufs * sizeof(Px_Buffer), prio,
        __pgprot (PROT_READ | PROT_WRITE));
    if (!b) return -ENOMEM;
    memset(b, 0, nbufs * sizeof(Px_Buffer));

    size = PAGE_ALIGN(size);
    dmabuffer = allocator_allocate_dma(size * nbufs, prio);
    PDEBUG("allocating: %i bufs, %i bytes each, got 0x%08lx\n", nbufs,
           size, dmabuffer);
    if (!dmabuffer) {
        vfree(b);
        return -ENOMEM;		//<<<<<<<<<<<<<<<<<
    }

The problem turns out that the first call to  px_allocate_dma_and_program()
for starting the first  pxc_live /dev/pxc0pgm  calls  allocator_allocate_dma()
with
	size	77824
	nbufs	215
	prio	208

Apparently that works the first time, but when running  pxc_live /dev/pxc1pgm
the call is made again, and that time  allocator_allocate_dma()  returns NULL
and  -ENOMEM  is returned.

Issuing   pxc_load buffers=6  prevents the problem.  ((Why 6?  I could not
quickly determine of the buffers were shared among all the framegrabber cards
or were allocated per card.  I was tired.))


The root cause is in  hardware.c .

/* This is called at the end of set_dma_parameters, and from ioctl() */
int px_prepare_device(Px_Dev *dev, int nbuf, int prio)
{
    int retval = 0;
    int size;

    /* no lock is held, as each called function locks by itself */
    px_acq_off(dev, 1);

    size = dev->xsize * dev->ysize * PX_PIXEL_SIZE(dev);
    /* If nbuf < 0, use size to get all available memory */
    if (nbuf < 0) {
        nbuf = allocator_get_size() / PAGE_ALIGN(size);		//<<<<<<<<<<<<
        printk(KERN_INFO PX_MSG "allocating %i buffers\n", nbuf);
    }

The assumption here is that if nbuf is < 0 (i.e. uninitialized) why not get as
many buffers as we can and use them all.  That works, but only for the first
device.  The second framegrabber card finds itself starved out of memory.

The older code (pxc-0.81), did not do this.



I still have the problem that the pxc_live and pxc_show applications do not
show any image when started after a reboot, BUT do work after
		modprobe bttv
		modprobe -r bttv tvaudio

Any insights or suggestions are welcome.

-- 
 Mike Bianchi
 Foveal Systems

 973 822-2085	call to arrange Fax

 MBianchi@Foveal.com
 http://www.AutoAuditorium.com
 http://www.FovealMounts.com


More information about the pxc mailing list