All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 04/12] ASoC: Intel: avs: Copy only as many RX bytes as necessary
Date: Thu,  7 Jul 2022 14:41:45 +0200	[thread overview]
Message-ID: <20220707124153.1858249-5-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20220707124153.1858249-1-cezary.rojewski@intel.com>

There is no need to copy number of bytes specified by IPC message caller
if DSP firmware returned lower number. In consequence, LARGE_CONFIG_GET
handler is simplified.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/ipc.c      | 1 +
 sound/soc/intel/avs/messages.c | 6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/avs/ipc.c b/sound/soc/intel/avs/ipc.c
index d755ba8b8518..020d85c7520d 100644
--- a/sound/soc/intel/avs/ipc.c
+++ b/sound/soc/intel/avs/ipc.c
@@ -480,6 +480,7 @@ static int avs_dsp_do_send_msg(struct avs_dev *adev, struct avs_ipc_msg *request
 	ret = ipc->rx.rsp.status;
 	if (reply) {
 		reply->header = ipc->rx.header;
+		reply->size = ipc->rx.size;
 		if (reply->data && ipc->rx.size)
 			memcpy(reply->data, ipc->rx.data, reply->size);
 	}
diff --git a/sound/soc/intel/avs/messages.c b/sound/soc/intel/avs/messages.c
index 6404fce8cde4..3559fb496e0b 100644
--- a/sound/soc/intel/avs/messages.c
+++ b/sound/soc/intel/avs/messages.c
@@ -378,7 +378,6 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id
 	union avs_module_msg msg = AVS_MODULE_REQUEST(LARGE_CONFIG_GET);
 	struct avs_ipc_msg request;
 	struct avs_ipc_msg reply = {{0}};
-	size_t size;
 	void *buf;
 	int ret;
 
@@ -406,15 +405,14 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id
 		return ret;
 	}
 
-	size = reply.rsp.ext.large_config.data_off_size;
-	buf = krealloc(reply.data, size, GFP_KERNEL);
+	buf = krealloc(reply.data, reply.size, GFP_KERNEL);
 	if (!buf) {
 		kfree(reply.data);
 		return -ENOMEM;
 	}
 
 	*reply_data = buf;
-	*reply_size = size;
+	*reply_size = reply.size;
 
 	return 0;
 }
-- 
2.25.1


  parent reply	other threads:[~2022-07-07 12:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 12:41 [PATCH 00/12] ASoC: Intel: avs: Updates and cleanups Cezary Rojewski
2022-07-07 12:41 ` [PATCH 01/12] ASoC: Intel: avs: Register HDAudio ext-bus operations Cezary Rojewski
2022-07-07 12:41 ` [PATCH 02/12] ASoC: Intel: avs: Assign I2S gateway when parsing topology Cezary Rojewski
2022-07-07 12:41 ` [PATCH 03/12] ASoC: Intel: avs: Relax DSP core transition timings Cezary Rojewski
2022-07-07 12:41 ` Cezary Rojewski [this message]
2022-07-07 12:41 ` [PATCH 05/12] ASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size Cezary Rojewski
2022-07-07 12:41 ` [PATCH 06/12] ASoC: Intel: avs: Block IPC channel on suspend Cezary Rojewski
2022-07-08 17:28   ` Mark Brown
2022-07-09  8:29     ` Cezary Rojewski
2022-07-07 12:41 ` [PATCH 07/12] ASoC: Intel: avs: Set max DMA segment size Cezary Rojewski
2022-07-07 12:41 ` [PATCH 08/12] ASoC: Intel: avs: Use helper function to set up DMA Cezary Rojewski
2022-07-07 12:41 ` [PATCH 09/12] ASoC: Intel: avs: Recognize FW_CFG_RESERVED Cezary Rojewski
2022-07-07 12:41 ` [PATCH 10/12] ASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET Cezary Rojewski
2022-07-07 12:41 ` [PATCH 11/12] ASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout Cezary Rojewski
2022-07-07 12:41 ` [PATCH 12/12] ASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration Cezary Rojewski
2022-07-11 21:14 ` [PATCH 00/12] ASoC: Intel: avs: Updates and cleanups Mark Brown

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=20220707124153.1858249-5-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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.