Re: Device driver memory 'mmap()' function helper cleanup

2013-05-13 Thread Sakari Ailus
Hi Mauro, On Wed, Apr 17, 2013 at 07:43:00AM -0300, Mauro Carvalho Chehab wrote: > and a camera anymore. The OMAP2 were used on some Nokia phones. > They used to maintain that code, but now that they moved to the dark > side of the moon, they lost their interests on it. So, it may not > be easily

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-19 Thread Linus Torvalds
On Fri, Apr 19, 2013 at 8:43 AM, Michel Lespinasse wrote: > > Just a suggestion: when file->f_op->mmap returns an error code, > mmap_region() currently has to call unmap_region() to undo any partial > mappings that might have been created by the device driver. Would it > make more sense to ask tha

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-19 Thread Michel Lespinasse
On Tue, Apr 16, 2013 at 8:12 PM, Linus Torvalds wrote: > Guys, I just pushed out a new helper function intended for cleaning up > various device driver mmap functions, because they are rather messy, > and at least part of the problem was the bad impedance between what a > driver author would want

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Linus Torvalds
On Wed, Apr 17, 2013 at 2:28 PM, Arnd Bergmann wrote: > > There is a separate check for the physical address that gets > mapped in hpet_mmap: Ahh, right you are. The earlier check for PAGE_SIZE's mapping and zero offset is indeed superfluous. Linus -- To unsubscribe from this list: send

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Linus Torvalds wrote: > Not the way things are now. > > vm_iomap_memory() actually allows non-page-aligned things to be > mapped, with the assumption that the user will then know about the > internal offsets. > > The reason for that is questionable, but that's how prett

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Linus Torvalds
On Wed, Apr 17, 2013 at 2:15 AM, Arnd Bergmann wrote: > > 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 th

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Linus Torvalds
On Wed, Apr 17, 2013 at 10:27 AM, David Miller wrote: > > Passing PCI BARs into these routines is illegal, we have proper > abstractions for mmap()'ing PCI resources via pci_mmap_page_range() > et al. > > So, any code doing that needs to be fixed. Hmm. I've definitely seen code that does that (we

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread David Miller
From: Linus Torvalds Date: Wed, 17 Apr 2013 10:20:43 -0700 > On Wed, Apr 17, 2013 at 10:11 AM, David Miller wrote: >> >> Yeah, the only thing special we do on sparc is interpret the PFN >> specially. We munge it into the real physical address and then >> pass it all down to remap_pfn_range() to

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Linus Torvalds
On Wed, Apr 17, 2013 at 10:11 AM, David Miller wrote: > > Yeah, the only thing special we do on sparc is interpret the PFN > specially. We munge it into the real physical address and then > pass it all down to remap_pfn_range() to do the real work. So the main thing I want to check is that *if*

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread David Miller
From: Linus Torvalds Date: Wed, 17 Apr 2013 07:44:33 -0700 > (*) io_remap_pfn_page() is the "extended" version that takes care of > some special magical details on a couple of odd architectures, notably > sparc (but also one special case of MIPS PAE that have some magic bit > tricks). But even fo

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Linus Torvalds
On Wed, Apr 17, 2013 at 4:34 AM, Tomi Valkeinen wrote: > > Should there be a similar helper that uses remap_pfn_range() instead of > io_remap_pfn_range()? The two are practically identical (*). I went back-and-forth over which one to use, and ended up using io_remap_pfn_range() because that ends

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Tomi Valkeinen
On 2013-04-17 06:12, Linus Torvalds wrote: > Guys, I just pushed out a new helper function intended for cleaning up > various device driver mmap functions, because they are rather messy, > and at least part of the problem was the bad impedance between what a > driver author would want to have, and

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Mauro Carvalho Chehab
Em Tue, 16 Apr 2013 20:12:32 -0700 Linus Torvalds escreveu: > Guys, I just pushed out a new helper function intended for cleaning up > various device driver mmap functions, because they are rather messy, > and at least part of the problem was the bad impedance between what a > driver author would

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Clemens Ladisch
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_

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Linus Torvalds wrote: > Anyway, I'm attaching the untested patch to several drivers. Guys, > mind taking a look? The point here is to simplify the interface, > avoiding bugs, but also: > > 5 files changed, 21 insertions(+), 87 deletions(-) > > it needs current -git fo

Re: Device driver memory 'mmap()' function helper cleanup

2013-04-17 Thread Takashi Iwai
At Tue, 16 Apr 2013 20:12:32 -0700, Linus Torvalds wrote: > > Guys, I just pushed out a new helper function intended for cleaning up > various device driver mmap functions, because they are rather messy, > and at least part of the problem was the bad impedance between what a > driver author would

Device driver memory 'mmap()' function helper cleanup

2013-04-16 Thread Linus Torvalds
Guys, I just pushed out a new helper function intended for cleaning up various device driver mmap functions, because they are rather messy, and at least part of the problem was the bad impedance between what a driver author would want to have, and the VM interfaces to map a memory range into user s