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

Takashi Iwai tiwai at suse.de
Thu Aug 8 08:03:39 CEST 2013


At Wed, 7 Aug 2013 13:38:20 -0400 (EDT),
Alan Stern wrote:
> 
> 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.

Hrm, but does the kmalloc buffer always guarantee such cache line
exclusiveness...?  I thought a simple one like SLOB doesn't care.


> > > @@ -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.

OK, then we need to fix sound/usb/6fire/pcm.c, too.
Torsten, care to respin the patch?


thanks,

Takashi


More information about the Alsa-devel mailing list