Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-07-02 Thread Alan Stern
On Sun, 1 Jul 2007, David Brownell wrote: > As I understand it the actual mechanism is more like: platforms > always set up a chunk of memory as uncached, and always map that > through the IOMMU. Call that the DMA-{coherent,consistent} region. > > Utilities like dma_alloc_coherent() -- and henc

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-07-02 Thread Pete Zaitcev
On Sun, 1 Jul 2007 21:02:11 -0700, David Brownell <[EMAIL PROTECTED]> wrote: > As I understand it the actual mechanism is more like: platforms > always set up a chunk of memory as uncached, and always map that > through the IOMMU. Call that the DMA-{coherent,consistent} region. > > Utilities li

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-07-01 Thread David Brownell
On Wednesday 06 June 2007, Oliver Neukum wrote: > Am Mittwoch, 6. Juni 2007 schrieb Pete Zaitcev: > > The consistent allocation was intended to things like mailboxes, > > where it is more advantageous to load a couple of words from uncached > > memory than to call an API which invalidates or fl

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-08 Thread Greg KH
On Mon, Jun 04, 2007 at 10:38:44AM +0200, Marcel Holtmann wrote: > Hi, > > after the discussion with Oliver at the LinuxTag last week, I started to > re-write the hci_usb driver to remove this ugly cruft around the URB > management in the driver. The basic driver (without ISOC support) is > workin

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-07 Thread Greg KH
On Tue, Jun 05, 2007 at 02:43:55PM +0200, Marcel Holtmann wrote: > Hi Oliver, > > > > > > an alternate way would be to extend the usb_kill_anchored_urbs() with > > > > > its own complete handler that gets called for every anchored URB. This > > > > > would make it possible to cleanup the allocated

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-06 Thread Oliver Neukum
Am Mittwoch, 6. Juni 2007 schrieb Pete Zaitcev: > On Wed, 6 Jun 2007 11:16:51 +0200, Oliver Neukum <[EMAIL PROTECTED]> wrote: > > > So what exactly is the problem? Is the documentation wrong? > > In the vast majority of cases, streaming transfer is more appropriate, In which regard exactly? Coul

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-06 Thread Pete Zaitcev
On Wed, 6 Jun 2007 11:16:51 +0200, Oliver Neukum <[EMAIL PROTECTED]> wrote: > So what exactly is the problem? Is the documentation wrong? In the vast majority of cases, streaming transfer is more appropriate, which is what you receive if you let HCD to establish and tear down mappings. The consis

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-06 Thread Oliver Neukum
Am Dienstag, 5. Juni 2007 schrieb Pete Zaitcev: > On Mon, 04 Jun 2007 10:38:44 +0200, Marcel Holtmann <[EMAIL PROTECTED]> wrote: > > > static void urb_destroy(struct kref *kref) > > { > > struct urb *urb = to_urb(kref); > > + > > + if (urb->transfer_flags & URB_FREE_BUFFER) > > +

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-06 Thread Oliver Neukum
Am Dienstag, 5. Juni 2007 schrieb Pete Zaitcev: > On Tue, 5 Jun 2007 15:29:12 +0200, Oliver Neukum <[EMAIL PROTECTED]> wrote: > > > Perhaps you need to have two flags, for freeing unconditionally > > and on condition of no errors having happened. > > If you free unconditionally handling errors, eg

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Marcel Holtmann
Hi Pete, > > The usb_buffer_alloc() and usb_buffer_free() usage was taken from the > > skeleton example driver. No idea if that is a good idea or not. I was > > under the impression that using the provided helper function that take > > care of DMA is a good thing. > > Just as I suspected. > > Yo

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Pete Zaitcev
On Tue, 05 Jun 2007 17:26:24 +0200, Marcel Holtmann <[EMAIL PROTECTED]> wrote: > The usb_buffer_alloc() and usb_buffer_free() usage was taken from the > skeleton example driver. No idea if that is a good idea or not. I was > under the impression that using the provided helper function that take >

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Marcel Holtmann
Hi Pete, > > Perhaps you need to have two flags, for freeing unconditionally > > and on condition of no errors having happened. > > If you free unconditionally handling errors, eg. clearing a stall becomes > > hard. > > This assertion makes no sense to me. URBs are not "freed" or "put" by > magic

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Marcel Holtmann
Hi Pete, > > static void urb_destroy(struct kref *kref) > > { > > struct urb *urb = to_urb(kref); > > + > > + if (urb->transfer_flags & URB_FREE_BUFFER) > > + usb_buffer_free(urb->dev, urb->transfer_buffer_length, > > + urb->transfer_buffer, urb->transfe

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Pete Zaitcev
On Mon, 04 Jun 2007 10:38:44 +0200, Marcel Holtmann <[EMAIL PROTECTED]> wrote: > static void urb_destroy(struct kref *kref) > { > struct urb *urb = to_urb(kref); > + > + if (urb->transfer_flags & URB_FREE_BUFFER) > + usb_buffer_free(urb->dev, urb->transfer_buffer_length, >

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Pete Zaitcev
On Tue, 5 Jun 2007 15:29:12 +0200, Oliver Neukum <[EMAIL PROTECTED]> wrote: > Perhaps you need to have two flags, for freeing unconditionally > and on condition of no errors having happened. > If you free unconditionally handling errors, eg. clearing a stall becomes > hard. This assertion makes n

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Oliver Neukum
Am Dienstag, 5. Juni 2007 14:43 schrieb Marcel Holtmann: Hello, > > > To avoid confusion we could rename it to usb_release_t or something > > > similar. > > > > One usage is a bit weak to add common code. > > this is why I wanna have a general solution for one-shot buffers. I understand and co

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Marcel Holtmann
Hi Oliver, > > > > an alternate way would be to extend the usb_kill_anchored_urbs() with > > > > its own complete handler that gets called for every anchored URB. This > > > > would make it possible to cleanup the allocated buffers. I attached a > > > > patch for that, too. > > > > > > No, that w

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-05 Thread Oliver Neukum
Am Montag, 4. Juni 2007 16:44 schrieb Marcel Holtmann: > Hi Oliver, Hello, > > > an alternate way would be to extend the usb_kill_anchored_urbs() with > > > its own complete handler that gets called for every anchored URB. This > > > would make it possible to cleanup the allocated buffers. I atta

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-04 Thread Marcel Holtmann
Hi Oliver, > > an alternate way would be to extend the usb_kill_anchored_urbs() with > > its own complete handler that gets called for every anchored URB. This > > would make it possible to cleanup the allocated buffers. I attached a > > patch for that, too. > > No, that would mean an URB could h

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-04 Thread Oliver Neukum
Am Montag, 4. Juni 2007 13:58 schrieb Marcel Holtmann: > an alternate way would be to extend the usb_kill_anchored_urbs() with > its own complete handler that gets called for every anchored URB. This > would make it possible to cleanup the allocated buffers. I attached a > patch for that, too. No

Re: [linux-usb-devel] [RFC] URBs and buffer management

2007-06-04 Thread Marcel Holtmann
Hi, > after the discussion with Oliver at the LinuxTag last week, I started to > re-write the hci_usb driver to remove this ugly cruft around the URB > management in the driver. The basic driver (without ISOC support) is > working perfectly fine and thanks to the reference count of the URB and > t