Re: [PATCH] Add support for usbfs zerocopy.

2016-02-24 Thread Steinar H. Gunderson
On Wed, Feb 24, 2016 at 02:30:08PM -0500, Sasha Levin wrote: > I'm seeing the following warning while fuzzing: > [ 1595.188189] WARNING: CPU: 3 PID: 26063 at mm/page_alloc.c:3207 > __alloc_pages_nodemask+0x960/0x29e0() > [ 1595.188287] Modules linked in: > [ 1595.188316] CPU: 3 PID: 26063 Comm:

Re: [PATCH] Add support for usbfs zerocopy.

2016-02-24 Thread Sasha Levin
On 11/25/2015 07:19 PM, Steinar H. Gunderson wrote: > Add a new interface for userspace to preallocate memory that can be > used with usbfs. This gives two primary benefits: > > - Zerocopy; data no longer needs to be copied between the userspace >and the kernel, but can instead be read

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-06 Thread Steinar H. Gunderson
On Wed, Jan 06, 2016 at 04:22:12PM +0100, Peter Stuge wrote: >>> Our interface for zero copy reads/writes is O_DIRECT, and that requires >>> not special memory allocation, just proper alignment. >> But that assumes you are using I/O using read()/write(). There's no way you >> can shoehorn USB

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-06 Thread Alan Stern
On Wed, 6 Jan 2016, Peter Stuge wrote: > Steinar H. Gunderson wrote: > > > Our interface for zero copy reads/writes is O_DIRECT, and that requires > > > not special memory allocation, just proper alignment. > > > > But that assumes you are using I/O using read()/write(). There's no way you > >

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-06 Thread Peter Stuge
Steinar H. Gunderson wrote: > > Our interface for zero copy reads/writes is O_DIRECT, and that requires > > not special memory allocation, just proper alignment. > > But that assumes you are using I/O using read()/write(). There's no way you > can shoehorn USB isochronous reads into the read()

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-06 Thread Steinar H. Gunderson
On Tue, Jan 05, 2016 at 10:49:49PM -0800, Christoph Hellwig wrote: > This is a completely broken usage of the mmap interface. if you use > mmap on a device file you must use the actual mmap for the data > transfer. Really? V4L does exactly the same thing, from what I can see. It's just a way of

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-06 Thread Alan Stern
On Wed, 6 Jan 2016, Steinar H. Gunderson wrote: > On Tue, Jan 05, 2016 at 10:49:49PM -0800, Christoph Hellwig wrote: > > This is a completely broken usage of the mmap interface. if you use > > mmap on a device file you must use the actual mmap for the data > > transfer. > > Really? V4L does

RE: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread David Laight
From: Steinar H. Gunderson [mailto:se...@google.com] > Sent: 26 November 2015 00:19 There is still a problem with this code, not sure how to fix it. ... > +static void dec_usb_memory_use_count(struct usb_memory *usbm, int *count) > +{ > + struct usb_dev_state *ps = usbm->ps; > + unsigned

RE: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Alan Stern
On Tue, 5 Jan 2016, David Laight wrote: > From: Steinar H. Gunderson [mailto:se...@google.com] > > Sent: 26 November 2015 00:19 > > There is still a problem with this code, not sure how to fix it. > > ... > > +static void dec_usb_memory_use_count(struct usb_memory *usbm, int *count) > > +{ > >

RE: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread David Laight
From: Alan Stern [mailto:st...@rowland.harvard.edu] > Sent: 05 January 2016 15:58 > On Tue, 5 Jan 2016, David Laight wrote: > > > From: Steinar H. Gunderson [mailto:se...@google.com] > > > Sent: 26 November 2015 00:19 > > > > There is still a problem with this code, not sure how to fix it. > > >

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Markus Rechberger
On Tue, Jan 5, 2016 at 4:57 PM, Alan Stern wrote: > On Tue, 5 Jan 2016, David Laight wrote: > >> From: Steinar H. Gunderson [mailto:se...@google.com] >> > Sent: 26 November 2015 00:19 >> >> There is still a problem with this code, not sure how to fix it. >> >> ... >> >

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Christoph Hellwig
This is a completely broken usage of the mmap interface. if you use mmap on a device file you must use the actual mmap for the data transfer. Our interface for zero copy reads/writes is O_DIRECT, and that requires not special memory allocation, just proper alignment. -- To unsubscribe from this

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Greg Kroah-Hartman
On Thu, Nov 26, 2015 at 01:19:13AM +0100, Steinar H. Gunderson wrote: > Add a new interface for userspace to preallocate memory that can be > used with usbfs. This gives two primary benefits: Please 'version' your patches, so that I have a chance to figure out what patch is what, and what changed

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Steinar H. Gunderson
On Tue, Jan 05, 2016 at 04:11:43PM -0800, Greg Kroah-Hartman wrote: >> Add a new interface for userspace to preallocate memory that can be >> used with usbfs. This gives two primary benefits: > Please 'version' your patches, so that I have a chance to figure out > what patch is what, and what

[PATCH] Add support for usbfs zerocopy.

2016-01-05 Thread Steinar H. Gunderson
Add a new interface for userspace to preallocate memory that can be used with usbfs. This gives two primary benefits: - Zerocopy; data no longer needs to be copied between the userspace and the kernel, but can instead be read directly by the driver from userspace's buffers. This works for

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-03 Thread Steinar H. Gunderson
On Mon, Jan 04, 2016 at 01:42:06AM +0100, Markus Rechberger wrote: > Don't expect anyone else seriously testing this interface aside of me > and Steinar. FWIW, I got an email from the OpenKinect people, who are (as far as I know) currently testing the patch together with my libusb-1.0 patch. It

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-03 Thread Markus Rechberger
On Mon, Jan 4, 2016 at 1:06 AM, Greg Kroah-Hartman wrote: > On Mon, Jan 04, 2016 at 12:54:57AM +0100, Markus Rechberger wrote: >> I would appreciate if this thing could speed up a little bit. We have >> implemented our previous mmap support into some embedded systems

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-03 Thread Markus Rechberger
I would appreciate if this thing could speed up a little bit. We have implemented our previous mmap support into some embedded systems however we need to update quite a few systems if we are going to support the current mmap version. It's taking 2 months already for this small change. When I did

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-03 Thread Greg Kroah-Hartman
On Mon, Jan 04, 2016 at 12:54:57AM +0100, Markus Rechberger wrote: > I would appreciate if this thing could speed up a little bit. We have > implemented our previous mmap support into some embedded systems > however we need to update quite a few systems if we are going to > support the current

Re: [PATCH] Add support for usbfs zerocopy.

2016-01-03 Thread Peter Stuge
Markus Rechberger wrote: > just improve that sloppy situation Dude I don't care who you are, your attitude sucks, and flushes any merit you have down the drain. It makes you look super bad. :) > we're at 3 months now Right, so chill out, watch a movie, go to a party, go to several, have some

[PATCH] Add support for usbfs zerocopy.

2015-12-28 Thread Steinar H. Gunderson
Add a new interface for userspace to preallocate memory that can be used with usbfs. This gives two primary benefits: - Zerocopy; data no longer needs to be copied between the userspace and the kernel, but can instead be read directly by the driver from userspace's buffers. This works for

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-28 Thread Steinar H. Gunderson
On Fri, Dec 25, 2015 at 01:36:44PM -0500, Alan Stern wrote: > That's okay; lots of drivers do this and people expect it. It also > reduces the total amount of code. Okay, fixed. > > > > + mem = usb_alloc_coherent(ps->dev, size, GFP_KERNEL, > > > > _handle); > > > Shouldn't this be

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-25 Thread Steinar H. Gunderson
On Fri, Dec 25, 2015 at 09:50:50AM +0100, Oliver Neukum wrote: > > + ret = usbfs_increase_memory_usage(size + sizeof(struct usb_memory)); > > + if (ret) { > > + module_put(THIS_MODULE); > > + return ret; > > + } > > Could you do the error handling in

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-25 Thread Oliver Neukum
On Thu, 2015-11-26 at 01:19 +0100, Steinar H. Gunderson wrote: Hi, just two small nits to pick: > +static int usbdev_mmap(struct file *file, struct vm_area_struct *vma) > +{ > + struct usb_memory *usbm = NULL; > + struct usb_dev_state *ps = file->private_data; > + size_t size

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-25 Thread Alan Stern
On Fri, 25 Dec 2015, Steinar H. Gunderson wrote: > On Fri, Dec 25, 2015 at 09:50:50AM +0100, Oliver Neukum wrote: > > > + ret = usbfs_increase_memory_usage(size + sizeof(struct > > > usb_memory)); > > > + if (ret) { > > > + module_put(THIS_MODULE); > > > +

[PATCH] Add support for usbfs zerocopy.

2015-12-24 Thread Steinar H. Gunderson
Add a new interface for userspace to preallocate memory that can be used with usbfs. This gives two primary benefits: - Zerocopy; data no longer needs to be copied between the userspace and the kernel, but can instead be read directly by the driver from userspace's buffers. This works for

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-24 Thread Steinar H. Gunderson
On Tue, Dec 22, 2015 at 10:38:57AM -0500, Alan Stern wrote: > Steinar, you can look at those if you want to. But I really don't > think anything more is needed other than the try_module_get and > module_put calls. At least, the Linux Device Drivers book doesn't > mention anything else. OK.

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-22 Thread Alan Stern
On Tue, 22 Dec 2015, Oliver Neukum wrote: > On Tue, 2015-12-22 at 01:12 +0100, Steinar H. Gunderson wrote: > > On Tue, Dec 15, 2015 at 03:32:45PM +, David Laight wrote: > > > That still isn't entirely correct. > > > > > > Someone with more knowledge than either of us has needs to sort out >

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-21 Thread Steinar H. Gunderson
On Tue, Dec 15, 2015 at 03:32:45PM +, David Laight wrote: > That still isn't entirely correct. > > Someone with more knowledge than either of us has needs to sort out > how to handle this properly. This discussion sort of stalled. Short of actually becoming a kernel VM expert (not very

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-21 Thread Oliver Neukum
On Tue, 2015-12-22 at 01:12 +0100, Steinar H. Gunderson wrote: > On Tue, Dec 15, 2015 at 03:32:45PM +, David Laight wrote: > > That still isn't entirely correct. > > > > Someone with more knowledge than either of us has needs to sort out > > how to handle this properly. > > This discussion

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-15 Thread Alan Stern
On Tue, 15 Dec 2015, David Laight wrote: > > Good point. So it seems that the try_module_get() / module_put() > > solution is the only one. > > That still isn't entirely correct. > > Someone with more knowledge than either of us has needs to sort out > how to handle this properly. > > Before

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-15 Thread David Laight
From: Alan Stern [mailto:st...@rowland.harvard.edu] > Sent: 14 December 2015 17:59 > On Mon, 14 Dec 2015, David Laight wrote: > > > From: Alan Stern > > > Sent: 14 December 2015 15:28 > > ... > > > I thought of something else, a more serious problem. According to the > > > man page for

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-15 Thread David Laight
From: Alan Stern > Sent: 15 December 2015 15:13 ... > > I was thinking that some side effect of dma_free_coherent() would > > find the user mapping for the pages, force unmap them and invalidate > > the user PTE (although the address range would have to remain reserved). > > Maybe that is wishful

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-15 Thread Alan Stern
On Tue, 15 Dec 2015, David Laight wrote: > From: Alan Stern [mailto:st...@rowland.harvard.edu] > > Sent: 14 December 2015 17:59 > > On Mon, 14 Dec 2015, David Laight wrote: > > > > > From: Alan Stern > > > > Sent: 14 December 2015 15:28 > > > ... > > > > I thought of something else, a more

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-14 Thread Steinar H. Gunderson
Software Engineer, Google Switzerland >From 659c4025a0e182a1a205fc4d945a68b8cb3602f0 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" <se...@google.com> Date: Thu, 26 Nov 2015 01:19:13 +0100 Subject: [PATCH] Add support for usbfs zerocopy. To: Greg Kroah-Hartman <gre...@linuxfound

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-14 Thread Alan Stern
On Mon, 14 Dec 2015, Steinar H. Gunderson wrote: > On Mon, Dec 14, 2015 at 04:41:24PM +0800, Peter Chen wrote: > >> + ret = usbfs_increase_memory_usage(size + sizeof(struct usb_memory)); > >> + if (ret) { > >> + return ret; > >> + } > > The braces are not needed. > > New patch

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-14 Thread David Laight
From: Alan Stern > Sent: 14 December 2015 15:28 ... > I thought of something else, a more serious problem. According to the > man page for munmap(2), closing the file descriptor does not unmap the > region. Therefore we need to explicitly make sure that the usbcore > module cannot be unloaded

RE: [PATCH] Add support for usbfs zerocopy.

2015-12-14 Thread Alan Stern
On Mon, 14 Dec 2015, David Laight wrote: > From: Alan Stern > > Sent: 14 December 2015 15:28 > ... > > I thought of something else, a more serious problem. According to the > > man page for munmap(2), closing the file descriptor does not unmap the > > region. Therefore we need to explicitly

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-14 Thread Peter Chen
On Thu, Nov 26, 2015 at 01:19:13AM +0100, Steinar H. Gunderson wrote: > +static int usbdev_mmap(struct file *file, struct vm_area_struct *vma) > +{ > + struct usb_memory *usbm = NULL; > + struct usb_dev_state *ps = file->private_data; > + size_t size = vma->vm_end - vma->vm_start; > +

[PATCH] Add support for usbfs zerocopy.

2015-12-09 Thread Steinar H. Gunderson
Add a new interface for userspace to preallocate memory that can be used with usbfs. This gives two primary benefits: - Zerocopy; data no longer needs to be copied between the userspace and the kernel, but can instead be read directly by the driver from userspace's buffers. This works for

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-09 Thread Greg Kroah-Hartman
On Thu, Nov 26, 2015 at 01:19:13AM +0100, Steinar H. Gunderson wrote: > Add a new interface for userspace to preallocate memory that can be > used with usbfs. This gives two primary benefits: > > - Zerocopy; data no longer needs to be copied between the userspace >and the kernel, but can

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-09 Thread Steinar H. Gunderson
On Wed, Dec 09, 2015 at 09:29:20AM -0500, Greg Kroah-Hartman wrote: > Shouldn't there also be some sort of documentation update with this > patch as well, so that people know of the new functionality we are > adding? I can write documentation if you can point me to a reasonable place. /* Steinar

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-09 Thread Alan Stern
On Wed, 9 Dec 2015, Steinar H. Gunderson wrote: > On Wed, Dec 09, 2015 at 09:29:20AM -0500, Greg Kroah-Hartman wrote: > > Shouldn't there also be some sort of documentation update with this > > patch as well, so that people know of the new functionality we are > > adding? > > I can write

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-09 Thread Steinar H. Gunderson
On Wed, Dec 09, 2015 at 10:39:35AM -0500, Alan Stern wrote: >> I can write documentation if you can point me to a reasonable place. > The only documentation I know of for usbfs is a dreadfully out-of-date > section in Documentation/DocBook/usb.tmpl. I don't volunteer to get your documentation in

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-05 Thread kbuild test robot
Hi Steinar, [auto build test WARNING on usb/usb-testing] [also build test WARNING on v4.4-rc3 next-20151203] url: https://github.com/0day-ci/linux/commits/Steinar-H-Gunderson/Add-support-for-usbfs-zerocopy/20151206-034258 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-05 Thread kbuild test robot
Hi Steinar, [auto build test WARNING on usb/usb-testing] [also build test WARNING on v4.4-rc3 next-20151203] url: https://github.com/0day-ci/linux/commits/Steinar-H-Gunderson/Add-support-for-usbfs-zerocopy/20151206-034258 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-05 Thread kbuild test robot
Hi Steinar, [auto build test WARNING on usb/usb-testing] [also build test WARNING on v4.4-rc3 next-20151203] url: https://github.com/0day-ci/linux/commits/Steinar-H-Gunderson/Add-support-for-usbfs-zerocopy/20151206-034258 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Re: [PATCH] Add support for usbfs zerocopy.

2015-12-05 Thread kbuild test robot
Hi Steinar, [auto build test WARNING on usb/usb-testing] [also build test WARNING on v4.4-rc3 next-20151203] url: https://github.com/0day-ci/linux/commits/Steinar-H-Gunderson/Add-support-for-usbfs-zerocopy/20151206-034258 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git