kiobuf issue/question - urgent please help!

From: lan mu
Date: Mon Nov 22 2004 - 21:41:25 EST


Hi experts,

I tried to pass 620000 bytes data which collected from
FPGA and store
in Kernal to user application.

I have tried kiobuf as below:

in linux driver:
==========
static unsigned long gPages[152]; /* page size=4096 */

in the mydriver_read()
===================

unsigned char *ptr;


    /* Allocate an I/O vector */
    result = alloc_kiovec(1, &iobuf);
    if (result)
    {
        printk("Error: alloc_kiovec return error
!!!\n");
        return -EFAULT;
    }
    // kiobuf_init(iobuf);

    /* Map the user I/O buffer and read to do the I/O.
*/
     result = map_user_kiobuf(READ, iobuf, (unsigned
long) buf, count);
    if (result) {
        free_kiovec(1, &iobuf);
        printk("Error: map_user_kiobuf return error
!!!\n");
        return -EFAULT;
    }
    printk("nr_pages == %d\noffset == %d\nlength ==
%d\n",
iobuf->nr_pages, iobuf->offset, iobuf->length);

    for(i = 0; i < iobuf->nr_pages; i++)
    {

       gPages[i] = page_address(iobuf->maplist[i]);
       printk("gPages[%d] == 0x%x\n", i,gPages[i]);

       for (j=0; j<4096; j++)
         ptr[j] = i;
    }

/* unmap the user buffer */
    unmap_kiobuf(iobuf);
    free_kiovec(1, &iobuf);

User application will pass buf with 620000 allocated
in user space.

Issue:
Actually I have got 152 pages with valid addresses and
when I ran user
application, I can see the data I have assigned in
driver space and
seems like okay.

But after intensive testing, I found some value that I
read in user app
is not corrrect (system not crash though).

Question:
=======
After I got page addresses, can I just use it as the
start point to
write 4096 bytes data in that page, or I have to do
something extra?
like
check sectors and etc? If so, can anyone give me an
example?

Please help!
Many thanks!

-Lan



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/