[alsa-devel] [PATCH] 6fire: fix URB transfer buffer for midi output

Alan Stern stern at rowland.harvard.edu
Wed Aug 7 19:38:20 CEST 2013


On Wed, 7 Aug 2013, Takashi Iwai wrote:

> [Cc'ed to linux-usb ML]
> 
> At Wed, 7 Aug 2013 16:51:49 +0200,
> Torsten Schenk wrote:
> > 
> > Patch fixes URB transfer buffer allocation for midi output to be DMA-able.
> 
> Is this really needed?
> That is, can't a transfer buffer be at middle of kmalloc'ed space, but
> must be always the head of the kmalloc'ed space?

A buffer _can_ be in the middle of a kmalloc'ed space, but the CPU must
not access any of the fields around it that might occupy the same cache
line while the buffer is being used for DMA.  In general, it's safest
not to put any other data in the same kmalloc'ed region with a DMA
buffer.

> > @@ -32,7 +28,7 @@
> >  	struct snd_rawmidi_substream *out;
> >  	struct urb out_urb;
> >  	u8 out_serial; /* serial number of out packet */
> > -	u8 out_buffer[MIDI_BUFSIZE];
> > +	u8 *out_buffer;
> >  	int buffer_offset;

In this case, the CPU would access out_urb while out_buffer was in use.

Alan Stern



More information about the Alsa-devel mailing list