copy_to_user doesnt seem to work all the time

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

 



Hi,

I?m writing a kernel driver which passes some data to user-space
by means of copy_to_user(). However, it seems that randomly the
data doesn't make it back to user-space.

Basically I have the following scenario:

1. At startup, I allocate some SHM memory blocks. These are
retained for the lifespan of the system.
2. I fill an SHM buffer with data (a counter and some 0xFFs -
for debug only) and pass its address to the kernel driver in a
write operation. 
3. The kernel driver gets some hardware data.
4. I subsequently do a read operation, and use copy_to_user to
fill the SHM buffer with my acquired hardware data.
5. Back in userspace I look to see what's in the SHM buffer.

Randomly, and very infrequently (one in 30000 or more times),
back in userspace I still see my debug data in the buffer. Yet
copy_to_user is not failing - it returns 0 each time.

The fragment of code doing the copy_to_user in my read routine
is below.

    /* Send hardware data to user space */
    if (data->read.data_len > 0)
    {
        len = copy_to_user(data->read.data_ptr,
data->hardware_data_ptr, data->read.data_len);
        if (len != 0)
        {
            printk(KERN_ALERT "Failed to copy %i bytes of %i\n",
len, data->read.data_len);
        }
    }

    /* Send data to user-space */
    memcpy_toiovec((struct iovec *)vec, (unsigned char *)
&data->read, sizeof(struct muxd_read_data) );

Is there possibly some caching issue with the SHM block I'm
copying data to? Or might it be something else? I've been
looking at this for days now, and got nowhere!

Andy


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Personals - Better first dates. More second dates. 
http://personals.yahoo.com


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux