From: bill_carson@126.com (bill) Date: Fri, 8 Jul 2011 09:38:16 +0800 (CST) Subject: Query about UIO In-Reply-To: <20110707183745.GA4860@local> References: <20110707183745.GA4860@local> <46e1f1fb.536f.13103837ed0.Coremail.bill_carson@126.com> <20110707141525.GA27984@kroah.com> Message-ID: <2342cc83.816b.13107652dc1.Coremail.bill_carson@126.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org At 2011-07-08 02:37:46?"Hans J. Koch" wrote: >On Thu, Jul 07, 2011 at 07:15:25AM -0700, Greg KH wrote: >> On Thu, Jul 07, 2011 at 03:32:54PM +0800, bill wrote: >> > Hi, Greg >> > >> > I've been reading the UIO code, one place puzzled me a lot. >> > May I ask one question about it? >> > >> > ------------------------------------------------------------------------------- >> > drivers/uio/uio.c >> > static int uio_find_mem_index(struct vm_area_struct *vma) >> > { >> > int mi; >> > struct uio_device *idev = vma->vm_private_data; >> > >> > for (mi = 0; mi < MAX_UIO_MAPS; mi++) { >> > if (idev->info->mem[mi].size == 0) >> > return -1; >> > if (vma->vm_pgoff == mi) >> > return mi; >> > } >> > return -1; >> > } >> > >> > I don't get it why use vma->vm_pgoff as the index for struct uio_mem mem[MAX_UIO_MAPS], >> > Suppose there are twohardware memory space, if user intends to map the 2nd mem, then >> > the last parameter of mmap should be 1, >> > >> > mapaddr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, >> > fd, 1); >> > >> > Is my understanding correct? > >No, it isn't. The last parameter of mmap is divided by PAGE_SIZE before it >reaches the UIO core. Therefore, it has to be set to n * getpagesize(). >This is explained in the docs under Documentation/DocBook/. >Use "make htmldocs" to generate HTML documentation. A faster way is to do > >dblatex Documentation/DocBook/uio-howto.tmpl > >This generates a PDF with the UIO documentation, provided you have a working >LaTeX system, and have dblatex installed. > >Thanks, >Hans > Thanks for your explanation. So vma->vm_pgoff is not used as its original meanings, that's the point puzzled me. Now it's clear:) >> >> I really don't know, sorry. >> >> But Hans should know, Hans? >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110708/d30d1d3a/attachment.html