All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks
@ 2014-03-05 14:28 Charles Keepax
  2014-03-06  4:35 ` Mark Brown
  2014-03-12  0:29 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Charles Keepax @ 2014-03-05 14:28 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, patches, lgirdwood

The firmware files can be quite large and allocating the whole firmware
a single DMA safe buffer can be problematic if the system is under a
high memory load. Ease the requirements slightly by writing the firmware
out in page sized chunks.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/wm_adsp.c |   50 ++++++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f9fd564..937af6f 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -684,24 +684,38 @@ static int wm_adsp_load(struct wm_adsp *dsp)
 		}
 
 		if (reg) {
-			buf = wm_adsp_buf_alloc(region->data,
-						le32_to_cpu(region->len),
-						&buf_list);
-			if (!buf) {
-				adsp_err(dsp, "Out of memory\n");
-				ret = -ENOMEM;
-				goto out_fw;
-			}
+			size_t to_write = PAGE_SIZE;
+			size_t remain = le32_to_cpu(region->len);
+			const u8 *data = region->data;
+
+			while (remain > 0) {
+				if (remain < PAGE_SIZE)
+					to_write = remain;
+
+				buf = wm_adsp_buf_alloc(data,
+							to_write,
+							&buf_list);
+				if (!buf) {
+					adsp_err(dsp, "Out of memory\n");
+					ret = -ENOMEM;
+					goto out_fw;
+				}
 
-			ret = regmap_raw_write_async(regmap, reg, buf->buf,
-						     le32_to_cpu(region->len));
-			if (ret != 0) {
-				adsp_err(dsp,
-					"%s.%d: Failed to write %d bytes at %d in %s: %d\n",
-					file, regions,
-					le32_to_cpu(region->len), offset,
-					region_name, ret);
-				goto out_fw;
+				ret = regmap_raw_write_async(regmap, reg,
+							     buf->buf,
+							     to_write);
+				if (ret != 0) {
+					adsp_err(dsp,
+						"%s.%d: Failed to write %d bytes at %d in %s: %d\n",
+						file, regions,
+						to_write, offset,
+						region_name, ret);
+					goto out_fw;
+				}
+
+				data += to_write;
+				reg += to_write / 2;
+				remain -= to_write;
 			}
 		}
 
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks
  2014-03-05 14:28 [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks Charles Keepax
@ 2014-03-06  4:35 ` Mark Brown
  2014-03-12  0:29 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-03-06  4:35 UTC (permalink / raw)
  To: Charles Keepax; +Cc: alsa-devel, patches, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 330 bytes --]

On Wed, Mar 05, 2014 at 02:28:16PM +0000, Charles Keepax wrote:
> The firmware files can be quite large and allocating the whole firmware
> a single DMA safe buffer can be problematic if the system is under a
> high memory load. Ease the requirements slightly by writing the firmware
> out in page sized chunks.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks
  2014-03-05 14:28 [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks Charles Keepax
  2014-03-06  4:35 ` Mark Brown
@ 2014-03-12  0:29 ` Mark Brown
  2014-03-12 15:31   ` Charles Keepax
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2014-03-12  0:29 UTC (permalink / raw)
  To: Charles Keepax; +Cc: alsa-devel, patches, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 725 bytes --]

On Wed, Mar 05, 2014 at 02:28:16PM +0000, Charles Keepax wrote:
> The firmware files can be quite large and allocating the whole firmware
> a single DMA safe buffer can be problematic if the system is under a
> high memory load. Ease the requirements slightly by writing the firmware
> out in page sized chunks.

While looking at some other related stuff it occurred to me that while
this is probably what you want for your backported code for upstream you
probably want to just convert to vmalloc() - SPI will do DMA mappings in
page sized chunks in order to support this so you get a similar effect
but without needing to split into multiple physical writes so it can all
be pushed down into hardware for best performance.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks
  2014-03-12  0:29 ` Mark Brown
@ 2014-03-12 15:31   ` Charles Keepax
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2014-03-12 15:31 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, lgirdwood

On Wed, Mar 12, 2014 at 12:29:06AM +0000, Mark Brown wrote:
> On Wed, Mar 05, 2014 at 02:28:16PM +0000, Charles Keepax wrote:
> > The firmware files can be quite large and allocating the whole firmware
> > a single DMA safe buffer can be problematic if the system is under a
> > high memory load. Ease the requirements slightly by writing the firmware
> > out in page sized chunks.
> 
> While looking at some other related stuff it occurred to me that while
> this is probably what you want for your backported code for upstream you
> probably want to just convert to vmalloc() - SPI will do DMA mappings in
> page sized chunks in order to support this so you get a similar effect
> but without needing to split into multiple physical writes so it can all
> be pushed down into hardware for best performance.

Sounds sensible I will look at testing this and doing a patch for
it.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-12 15:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-05 14:28 [PATCH] ASoC: wm_adsp: Split firmware load into smaller chunks Charles Keepax
2014-03-06  4:35 ` Mark Brown
2014-03-12  0:29 ` Mark Brown
2014-03-12 15:31   ` Charles Keepax

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.