2011-03-17 09:39:25 mmap() / MAP_PRIVATE fails on /dev char device
Martin Strubel (SWITZERLAND)
I've used to mmap a char device driver the following way:
c->buffers[i].start = mmap(NULL, buffer.length,
PROT_READ | PROT_WRITE, /* required */
MAP_PRIVATE, // must be private on uClinux
The char driver implements the .mmap method and used to work fine up to 2009R1 release.
With the 2010R1-RC5, the mapping fails within mm/nommu.c, specifical in validate_mmap_request(), the following sequence applies:
mapping = file->f_mapping;
mapping = file->f_path.dentry->d_inode->i_mapping;
capabilities = 0;
if (mapping && mapping->backing_dev_info)
capabilities = mapping->backing_dev_info->capabilities;
On the last above code line, capabilities is returned as BDI_MAP_CAP_COPY, however, has to be BDI_MAP_CAP_DIRECT in order to call the drivers .mmap method. If there is no backing_dev_info (and capabilities remain 0), the proper caps would be determined later.
Is this a bug or a feature I'm missing?
2011-03-28 01:59:15 Re: mmap() / MAP_PRIVATE fails on /dev char device
Aaron Wu (CHINA)
What's the latest status for this proplem, do you have some sample code and instructions by following which we can reproduce this issue?