From: Andrew Grover <andy.grover@gmail.com>
To: Peter Chubb <peterc@gelato.unsw.edu.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: User mode drivers: part 2: PCI device handling (patch 1/2 for 2.6.11)
Date: Sat, 12 Mar 2005 02:49:10 -0800 [thread overview]
Message-ID: <c0a09e5c0503120249598c57a0@mail.gmail.com> (raw)
In-Reply-To: <16945.4717.402555.893411@berry.gelato.unsw.EDU.AU>
On Fri, 11 Mar 2005 14:37:17 +1100, Peter Chubb
<peterc@gelato.unsw.edu.au> wrote:
> + npages = get_user_pages(current,
> + current->mm,
> + (unsigned long)m.virtaddr,
> + maxpages,
> + write,
> + 0,
> + imp->pages,
> + NULL);
Can't comment on usermode drivers overall, so just some code comments.
do you need a down_read(current->mm->mmap_sem) here? I'm not sure but
that seems to be what most other users of this function are doing.
> + /*
> + * Build scatterlist, one entry per page.
> + * Allow for partial pages at start and end.
> + */
> + i = 1;
> + imp->sg[0].page = imp->pages[0];
> + imp->sg[0].offset = ((unsigned long)m.virtaddr) & (PAGE_SIZE - 1);
> + imp->sg[0].length = PAGE_SIZE - imp->sg[0].offset;
> + if (imp->sg[0].length >= m.size) {
> + imp->sg[0].length = m.size;
> + } else {
> + unsigned long len = m.size - imp->sg[0].length;
> + for (;len >= PAGE_SIZE && i < npages ; i++) {
> + imp->sg[i].page = imp->pages[i];
> + imp->sg[i].offset = 0;
> + imp->sg[i].length = PAGE_SIZE;
> + len -= PAGE_SIZE;
> + }
> + if (len) {
> + BUG_ON(i >= npages);
> + BUG_ON(len >= PAGE_SIZE);
> + imp->sg[i].page = imp->pages[i];
> + imp->sg[i].offset = 0;
> + imp->sg[i].length = len;
> + i++;
> + }
> + }
size_t len = m.size;
int offset = (unsigned long) m.virtaddr & ~PAGE_MASK;
for (i = 0; i < npages; i++)
{
imp->sg[i].page = imp->pages[i];
imp->sg[i].offset = offset;
imp->sg[i].length = min(len, PAGE_SIZE - offset);
offset = 0;
len -= imp->sg[i].length;
}
instead possibly?
Regards -- Andy
next prev parent reply other threads:[~2005-03-12 10:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-11 3:37 User mode drivers: part 2: PCI device handling (patch 1/2 for 2.6.11) Peter Chubb
2005-03-11 7:18 ` Greg KH
2005-03-11 8:34 ` Peter Chubb
2005-03-11 10:31 ` Pavel Machek
2005-03-11 15:21 ` Greg KH
2005-03-11 16:45 ` Jesse Barnes
2005-03-12 22:43 ` Jon Smirl
2005-03-14 0:13 ` Peter Chubb
2005-03-14 17:46 ` Alan Cox
2005-03-11 19:16 ` Alan Cox
2005-03-12 10:49 ` Andrew Grover [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-03-11 5:18 Albert Cahalan
2005-03-11 19:15 ` Alan Cox
2005-03-11 21:04 ` Albert Cahalan
2005-03-14 13:34 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c0a09e5c0503120249598c57a0@mail.gmail.com \
--to=andy.grover@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterc@gelato.unsw.edu.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox