All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Andreas Mohr <andi@lisas.de>
Cc: linux-mips@linux-mips.org, alsa-devel@alsa-project.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Becky Bruce <beckyb@kernel.crashing.org>,
	Wu Zhangjin <wuzhangjin@gmail.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Kumar Gala <galak@gate.crashing.org>
Subject: Re: [PATCH 0/5] PCM mmap (temporary) fixes for non-coherent	architectures
Date: Wed, 13 Jan 2010 10:07:32 +0100	[thread overview]
Message-ID: <s5hljg24bl7.wl%tiwai@suse.de> (raw)
In-Reply-To: <s5haawj7qlv.wl%tiwai@suse.de>

At Tue, 12 Jan 2010 08:02:36 +0100,
I wrote:
> 
> At Fri, 1 Jan 2010 20:31:30 +0100,
> Andreas Mohr wrote:
> > 
> > Hi,
> > 
> > I've tried this patch set (with the typo-corrected part 4) on my ASUS
> > WL-500gP v2 MIPSEL via a backport to 2.6.31.9, but all I get is a
> > small blip of the sound I wanted to play, and then the system is fubar
> > (I believe just the same thing as what happened without having this patch
> > applied).
> 
> As I mentioned in the previous followup, if your device is a
> USB-audio, the patch doesn't help because it's for devices with
> buffers using dma_alloc_coherent().  For USB-audio, it uses vmalloc
> for an intermediate buffer.  Maybe this should be changed to dma_*()
> stuff for such architectures.

A quick patch below (totally untested!) might do that.
It's passing the device struct blindly, so not sure whether this would
actually work for all dma_alloc_coherent().


Takashi

---
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 9edef46..6c82026 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -734,7 +734,7 @@ static void snd_complete_sync_urb(struct urb *urb)
 	}
 }
 
-
+#ifdef USBAUDIO_VMALLOC_BUFFER
 /* get the physical page pointer at the given offset */
 static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
 					     unsigned long offset)
@@ -769,6 +769,24 @@ static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs)
 	return 0;
 }
 
+#define preallocate_buffer(chip, pcm, stream) /* NOP */
+
+#else
+#define snd_pcm_get_vmalloc_page	NULL
+#define snd_pcm_alloc_vmalloc_buffer	snd_pcm_lib_malloc_pages
+#define snd_pcm_free_vmalloc_buffer	snd_pcm_lib_free_pages
+
+static int preallocate_buffer(struct snd_usb_audio *chip, struct snd_pcm *pcm,
+			      int stream)
+{
+	struct snd_pcm_substream *subs = pcm->streams[stream].substream;
+	if (!subs)
+		return 0;
+	return snd_pcm_lib_preallocate_pages(subs, SNDRV_DMA_TYPE_DEV,
+					     chip->card->dev,
+					     1024 * 64, 1024 * 1024);
+}
+#endif
 
 /*
  * unlink active urbs.
@@ -2328,6 +2346,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
 		err = snd_pcm_new_stream(as->pcm, stream, 1);
 		if (err < 0)
 			return err;
+		preallocate_buffer(chip, as->pcm, stream);
 		init_substream(as, stream, fp);
 		return 0;
 	}
@@ -2356,6 +2375,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
 	else
 		strcpy(pcm->name, "USB Audio");
 
+	preallocate_buffer(chip, pcm, stream);
 	init_substream(as, stream, fp);
 
 	list_add(&as->list, &chip->pcm_list);

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Andreas Mohr <andi@lisas.de>
Cc: alsa-devel@alsa-project.org, Ralf Baechle <ralf@linux-mips.org>,
	Wu Zhangjin <wuzhangjin@gmail.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	linux-mips@linux-mips.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Kumar Gala <galak@gate.crashing.org>,
	Becky Bruce <beckyb@kernel.crashing.org>
Subject: Re: [PATCH 0/5] PCM mmap (temporary) fixes for non-coherent    architectures
Date: Wed, 13 Jan 2010 10:07:32 +0100	[thread overview]
Message-ID: <s5hljg24bl7.wl%tiwai@suse.de> (raw)
In-Reply-To: <s5haawj7qlv.wl%tiwai@suse.de>

At Tue, 12 Jan 2010 08:02:36 +0100,
I wrote:
> 
> At Fri, 1 Jan 2010 20:31:30 +0100,
> Andreas Mohr wrote:
> > 
> > Hi,
> > 
> > I've tried this patch set (with the typo-corrected part 4) on my ASUS
> > WL-500gP v2 MIPSEL via a backport to 2.6.31.9, but all I get is a
> > small blip of the sound I wanted to play, and then the system is fubar
> > (I believe just the same thing as what happened without having this patch
> > applied).
> 
> As I mentioned in the previous followup, if your device is a
> USB-audio, the patch doesn't help because it's for devices with
> buffers using dma_alloc_coherent().  For USB-audio, it uses vmalloc
> for an intermediate buffer.  Maybe this should be changed to dma_*()
> stuff for such architectures.

A quick patch below (totally untested!) might do that.
It's passing the device struct blindly, so not sure whether this would
actually work for all dma_alloc_coherent().


Takashi

---
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 9edef46..6c82026 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -734,7 +734,7 @@ static void snd_complete_sync_urb(struct urb *urb)
 	}
 }
 
-
+#ifdef USBAUDIO_VMALLOC_BUFFER
 /* get the physical page pointer at the given offset */
 static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
 					     unsigned long offset)
@@ -769,6 +769,24 @@ static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs)
 	return 0;
 }
 
+#define preallocate_buffer(chip, pcm, stream) /* NOP */
+
+#else
+#define snd_pcm_get_vmalloc_page	NULL
+#define snd_pcm_alloc_vmalloc_buffer	snd_pcm_lib_malloc_pages
+#define snd_pcm_free_vmalloc_buffer	snd_pcm_lib_free_pages
+
+static int preallocate_buffer(struct snd_usb_audio *chip, struct snd_pcm *pcm,
+			      int stream)
+{
+	struct snd_pcm_substream *subs = pcm->streams[stream].substream;
+	if (!subs)
+		return 0;
+	return snd_pcm_lib_preallocate_pages(subs, SNDRV_DMA_TYPE_DEV,
+					     chip->card->dev,
+					     1024 * 64, 1024 * 1024);
+}
+#endif
 
 /*
  * unlink active urbs.
@@ -2328,6 +2346,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
 		err = snd_pcm_new_stream(as->pcm, stream, 1);
 		if (err < 0)
 			return err;
+		preallocate_buffer(chip, as->pcm, stream);
 		init_substream(as, stream, fp);
 		return 0;
 	}
@@ -2356,6 +2375,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
 	else
 		strcpy(pcm->name, "USB Audio");
 
+	preallocate_buffer(chip, pcm, stream);
 	init_substream(as, stream, fp);
 
 	list_add(&as->list, &chip->pcm_list);

  reply	other threads:[~2010-01-13  9:07 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-26 15:13 [PATCH 0/5] PCM mmap (temporary) fixes for non-coherent architectures Takashi Iwai
2009-11-26 15:13 ` Takashi Iwai
2009-11-26 15:13 ` [PATCH 1/5] ALSA: pcm - Use dma_mmap_coherent() if available Takashi Iwai
2009-11-26 15:13   ` Takashi Iwai
2009-11-26 15:13   ` [PATCH 2/5] ALSA: pcm - define snd_pcm_default_page_ops() Takashi Iwai
2009-11-26 15:13     ` Takashi Iwai
2009-11-26 15:13     ` [PATCH 3/5] ALSA: pcm - fix page conversion on non-coherent MIPS arch Takashi Iwai
2009-11-26 15:13       ` Takashi Iwai
2009-11-26 15:13       ` [PATCH 4/5] ALSA: pcm - fix page conversion on non-coherent PPC arch Takashi Iwai
2009-11-26 15:13         ` Takashi Iwai
2009-11-26 15:13         ` [PATCH 5/5] ALSA: Remove old DMA-mmap code from arm/devdma.c Takashi Iwai
2009-11-26 15:13           ` Takashi Iwai
2009-11-26 16:56         ` [PATCH 4/5] ALSA: pcm - fix page conversion on non-coherent PPC arch Takashi Iwai
2009-11-26 16:56           ` Takashi Iwai
2009-11-26 21:14           ` Benjamin Herrenschmidt
2009-11-26 21:14             ` Benjamin Herrenschmidt
2009-11-26 20:51         ` Benjamin Herrenschmidt
2009-11-26 20:51           ` Benjamin Herrenschmidt
2009-11-27  9:18           ` Takashi Iwai
2009-11-27  9:18             ` Takashi Iwai
2009-11-27  3:52       ` [PATCH 3/5] ALSA: pcm - fix page conversion on non-coherent MIPS arch Wu Zhangjin
2009-11-27  9:26         ` Takashi Iwai
2009-11-27  9:26           ` Takashi Iwai
2009-11-27  8:46       ` Ralf Baechle
2009-11-27  8:46         ` Ralf Baechle
2009-11-27  9:20         ` Takashi Iwai
2009-11-27  9:20           ` Takashi Iwai
2010-01-01 19:31 ` [PATCH 0/5] PCM mmap (temporary) fixes for non-coherent architectures Andreas Mohr
2010-01-12  7:02   ` Takashi Iwai
2010-01-12  7:02     ` Takashi Iwai
2010-01-13  9:07     ` Takashi Iwai [this message]
2010-01-13  9:07       ` Takashi Iwai
2010-01-14  7:46       ` Andreas Mohr
2010-01-14  7:46         ` Andreas Mohr
2010-01-14  7:54         ` Takashi Iwai
2010-01-14  7:54           ` Takashi Iwai
2010-01-15  3:28       ` Benjamin Herrenschmidt
2010-01-15  3:28         ` Benjamin Herrenschmidt
2010-01-15  6:43         ` Takashi Iwai
2010-01-15  6:43           ` Takashi Iwai
2010-01-15  6:50           ` Benjamin Herrenschmidt
2010-01-15  6:50             ` Benjamin Herrenschmidt
2010-01-15  7:32             ` Takashi Iwai
2010-01-15  7:32               ` Takashi Iwai
2010-01-13  9:28     ` Andreas Mohr
2010-01-13  9:28       ` Andreas Mohr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hljg24bl7.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=andi@lisas.de \
    --cc=beckyb@kernel.crashing.org \
    --cc=benh@kernel.crashing.org \
    --cc=galak@gate.crashing.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=wuzhangjin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.