From: Clemens Ladisch <clemens@ladisch.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Takashi Iwai <tiwai@suse.de>,
Mauro Carvalho Chehab <mchehab@redhat.com>
Subject: Re: Device driver memory 'mmap()' function helper cleanup
Date: Wed, 17 Apr 2013 11:45:50 +0200 [thread overview]
Message-ID: <516E6F4E.9030808@ladisch.de> (raw)
In-Reply-To: <201304171115.51509.arnd@arndb.de>
Arnd Bergmann wrote:
> On Wednesday 17 April 2013, Linus Torvalds wrote:
>> Anyway, I'm attaching the untested patch to several drivers. Guys,
>> mind taking a look?
>
> I took a look at the hpet_mmap function, which still contains this check:
>
> if (((vma->vm_end - vma->vm_start) != PAGE_SIZE) || vma->vm_pgoff)
> return -EINVAL;
>
> As far as I can tell, this check is implied by the new code in
> vm_iomap_memory as the len argument passed here is PAGE_SIZE, so you
> can remove another three lines in hpet_mmap.
Yes indeed.
> > [...] I just have this untested patch-collection for a few random
> > drivers (picked across a few different driver subsystems, just to make
> > it interesting). I did that largely just to check the different use
> > cases, but I don't actually tend to *use* all that many fancy drivers,
> > so I don't have much of a way of testing it.
Any more-or-less recent x86 machine has HPET, so you could enable
CONFIG_HPET(_MMAP) and try the (completely untested) program below.
Regards,
Clemens
--8<---------------------------------------------------------------->8--
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
int main(void)
{
int fd = open("/dev/hpet", O_RDONLY);
if (fd == -1) {
perror("/dev/hpet");
return 1;
}
const volatile unsigned int *ptr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
perror("mmap");
return 1;
}
printf("frequency: %.5f MHz\n", 1e9 / ptr[1]);
for (;;) {
printf("\rcounter: %08x", ptr[60]);
fflush(stdout);
usleep(123456);
}
}
next prev parent reply other threads:[~2013-04-17 9:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-17 3:12 Device driver memory 'mmap()' function helper cleanup Linus Torvalds
2013-04-17 7:20 ` Takashi Iwai
2013-04-17 9:15 ` Arnd Bergmann
2013-04-17 9:45 ` Clemens Ladisch [this message]
2013-04-17 17:58 ` Linus Torvalds
2013-04-17 21:28 ` Arnd Bergmann
2013-04-17 21:31 ` Linus Torvalds
2013-04-17 10:43 ` Mauro Carvalho Chehab
2013-04-17 12:22 ` [PATCH 1/2] [media] videobuf-dma-contig: remove support for cached mem Mauro Carvalho Chehab
2013-04-17 12:22 ` [PATCH 2/2] [media] videobuf-dma-contig: use vm_iomap_memory() Mauro Carvalho Chehab
2013-04-17 12:56 ` Mauro Carvalho Chehab
2013-04-17 12:49 ` [PATCH 1/2] [media] videobuf-dma-contig: remove support for cached mem Hans Verkuil
2013-05-12 21:52 ` Device driver memory 'mmap()' function helper cleanup Sakari Ailus
2013-04-17 11:34 ` Tomi Valkeinen
2013-04-17 14:44 ` Linus Torvalds
2013-04-17 17:11 ` David Miller
2013-04-17 17:20 ` Linus Torvalds
2013-04-17 17:27 ` David Miller
2013-04-17 17:48 ` Linus Torvalds
2013-04-19 15:43 ` Michel Lespinasse
2013-04-19 23:07 ` Linus Torvalds
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=516E6F4E.9030808@ladisch.de \
--to=clemens@ladisch.de \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=tiwai@suse.de \
--cc=torvalds@linux-foundation.org \
/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