ASoC: Intel: catpt: IPC log improvements and code simplification
Subsystems (3)
Cezary Rojewski
maintainercover ASoC: Intel: catpt: IPC log improvements and code simplification
Entire patchset provides no new features and does not alter the code from functional (user) perspective.
The first two improve IPC-error logging 'mechanism' and align the catpt-driver with what's done in another Intel's driver: the avs-driver. In essence, no need to log the error in every function, let the common handler do so instead.
The last three simplify the code, and fix some spacing issues. All in all, we get better readability with lower LOC.
Cezary Rojewski (5):
ASoC: Intel: catpt: Move IPC error messages one level down
ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
ASoC: Intel: catpt: Simplify catpt_stream_read_position()
ASoC: Intel: catpt: Specify image names in the device descriptor
ASoC: Intel: catpt: Drop superfluous space in PCM code
sound/soc/intel/catpt/core.h | 7 +-- sound/soc/intel/catpt/device.c | 6 ++- sound/soc/intel/catpt/ipc.c | 12 +++-- sound/soc/intel/catpt/loader.c | 8 +-- sound/soc/intel/catpt/messages.c | 89 +++++--------------------------- sound/soc/intel/catpt/pcm.c | 46 +++++++---------- sound/soc/intel/catpt/sysfs.c | 2 +- 7 files changed, 49 insertions(+), 121 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/5 ASoC: Intel: catpt: Move IPC error messages one level down
Code size can be reduced if catpt_dsp_do_send_msg() takes responsibility for dumping logs in case of an IPC message failure.
--- sound/soc/intel/catpt/core.h | 4 +- sound/soc/intel/catpt/ipc.c | 12 +++-- sound/soc/intel/catpt/messages.c | 89 +++++--------------------------- 3 files changed, 21 insertions(+), 84 deletions(-)
sound/soc/intel/catpt/core.h +2 -2
@@ -133,9 +133,9 @@ irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);int catpt_dsp_send_msg_timeout (struct catpt_dev *cdev,struct catpt_ipc_msg request, -struct catpt_ipc_msg *reply,int timeout); +struct catpt_ipc_msg *reply,int timeout,const char *name);int catpt_dsp_send_msg (struct catpt_dev *cdev,struct catpt_ipc_msg request, -struct catpt_ipc_msg *reply); +struct catpt_ipc_msg *reply,const char *name);int catpt_first_boot_firmware (struct catpt_dev *cdev);int catpt_boot_firmware (struct catpt_dev *cdev,bool restore);
sound/soc/intel/catpt/ipc.c +7 -5
@@ -84,7 +84,7 @@ static int catpt_wait_msg_completion(struct catpt_dev *cdev, int timeout)static int catpt_dsp_do_send_msg (struct catpt_dev *cdev,struct catpt_ipc_msg request, -struct catpt_ipc_msg *reply,int timeout) +struct catpt_ipc_msg *reply,int timeout,const char *name) {struct catpt_ipc *ipc = &cdev->ipc;unsigned long flags;
@@ -111,6 +111,8 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev, } ret = ipc->rx.rsp.status; +if (ret) +dev_err (cdev->dev,"%s (0x%08x) failed: %d\n" , name, request.header, ret);if (reply) { reply->header = ipc->rx.header;
@@ -123,23 +125,23 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev,int catpt_dsp_send_msg_timeout (struct catpt_dev *cdev,struct catpt_ipc_msg request, -struct catpt_ipc_msg *reply,int timeout) +struct catpt_ipc_msg *reply,int timeout,const char *name) {struct catpt_ipc *ipc = &cdev->ipc;int ret;mutex_lock (&ipc->mutex); - ret =catpt_dsp_do_send_msg (cdev, request, reply, timeout); + ret =catpt_dsp_do_send_msg (cdev, request, reply, timeout, name);mutex_unlock (&ipc->mutex);return ret; }int catpt_dsp_send_msg (struct catpt_dev *cdev,struct catpt_ipc_msg request, -struct catpt_ipc_msg *reply) +struct catpt_ipc_msg *reply,const char *name) {return catpt_dsp_send_msg_timeout (cdev, request, reply, - cdev->ipc.default_timeout); + cdev->ipc.default_timeout, name); } static void
sound/soc/intel/catpt/messages.c +12 -77
215 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 2/5 ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
In reply to Cezary RojewskiMake it easier for functions that call IPC handlers to deal with their results by accounting for '0' (success) code. Rename the macro to reflect this behaviour change.
--- sound/soc/intel/catpt/core.h | 2 +- sound/soc/intel/catpt/device.c | 4 ++-- sound/soc/intel/catpt/loader.c | 2 +- sound/soc/intel/catpt/pcm.c | 24 ++++++++++-------------- sound/soc/intel/catpt/sysfs.c | 2 +- 5 files changed, 15 insertions(+), 19 deletions(-)
sound/soc/intel/catpt/core.h +1 -1
@@ -129,7 +129,7 @@ irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);* HOST <-> DSP communication yet failure to process specific request. * Use below macro to convert returned non-zero values appropriately */ -#define CATPT_IPC_ERROR (err) (((err) < 0) ? (err) : -EREMOTEIO) +#define CATPT_IPC_RET (ret) (((ret) <= 0) ? (ret) : -EREMOTEIO) int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev, struct catpt_ipc_msg request,
sound/soc/intel/catpt/device.c +2 -2
@@ -41,7 +41,7 @@ static int catpt_do_suspend(struct device *dev)memset (&cdev->dx_ctx,0 ,sizeof (cdev->dx_ctx)); ret =catpt_ipc_enter_dxstate (cdev,CATPT_DX_STATE_D3 , &cdev->dx_ctx);if (ret) { - ret =CATPT_IPC_ERROR (ret); + ret =CATPT_IPC_RET (ret); goto release_dma_chan; }
@@ -107,7 +107,7 @@ static int catpt_resume(struct device *dev) ret =catpt_ipc_set_device_format (cdev, &cdev->devfmt[i]);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); }return 0 ;
sound/soc/intel/catpt/loader.c +1 -1
@@ -657,7 +657,7 @@ int catpt_first_boot_firmware(struct catpt_dev *cdev) ret =catpt_ipc_get_mixer_stream_info (cdev, &cdev->mixer);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); ret =catpt_arm_stream_templates (cdev);if (ret) {
sound/soc/intel/catpt/pcm.c +10 -14
@@ -365,9 +365,7 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,if (stream->template->type !=CATPT_STRM_TYPE_LOOPBACK )return catpt_set_dspvol (cdev, id, (long *)pos->private_value); ret =catpt_ipc_mute_loopback (cdev, id, *(bool *)pos->private_value); -if (ret) -return CATPT_IPC_ERROR (ret); -return 0 ; +return CATPT_IPC_RET (ret); } static int catpt_dai_hw_params(struct snd_pcm_substream *substream,
@@ -414,7 +412,7 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream, cdev->scratch, &stream->info);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); ret =catpt_dai_apply_usettings (dai, stream);if (ret) {
@@ -456,11 +454,11 @@ static int catpt_dai_prepare(struct snd_pcm_substream *substream, ret =catpt_ipc_reset_stream (cdev, stream->info.stream_hw_id);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); ret =catpt_ipc_pause_stream (cdev, stream->info.stream_hw_id);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); stream->prepared = true;return 0 ;
@@ -491,7 +489,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd, ret =catpt_ipc_set_write_pos (cdev, stream->info.stream_hw_id, pos, false, false);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); fallthrough;case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
@@ -499,7 +497,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd,catpt_dsp_update_lpclock (cdev); ret =catpt_ipc_resume_stream (cdev, stream->info.stream_hw_id);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret);break ;case SNDRV_PCM_TRIGGER_STOP :
@@ -510,7 +508,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd, ret =catpt_ipc_pause_stream (cdev, stream->info.stream_hw_id);catpt_dsp_update_lpclock (cdev);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret);break ;default :
@@ -679,7 +677,7 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm,pm_runtime_put_autosuspend (cdev->dev);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret);/* store device format set for given SSP */ memcpy (&cdev->devfmt[devfmt.iface], &devfmt,sizeof (devfmt));
@@ -849,9 +847,7 @@ static int catpt_set_dspvol(struct catpt_dev *cdev, u8 stream_id, long *ctlvol) } } -if (ret) -return CATPT_IPC_ERROR (ret); -return 0 ; +return CATPT_IPC_RET (ret); } static int catpt_volume_info(struct snd_kcontrol *kcontrol,
@@ -1041,7 +1037,7 @@ static int catpt_loopback_switch_put(struct snd_kcontrol *kcontrol,pm_runtime_put_autosuspend (cdev->dev);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret); *(bool *)kcontrol->private_value = mute;return 0 ;
sound/soc/intel/catpt/sysfs.c +1 -1
@@ -24,7 +24,7 @@ static ssize_t fw_version_show(struct device *dev,pm_runtime_put_autosuspend (cdev->dev);if (ret) -return CATPT_IPC_ERROR (ret); +return CATPT_IPC_RET (ret);return sysfs_emit (buf,"%d.%d.%d.%d\n" , version.type, version.major, version.minor, version.build);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 3/5 ASoC: Intel: catpt: Simplify catpt_stream_read_position()
In reply to Cezary RojewskiAdd position to the argument list to simplify the wrapper.
--- sound/soc/intel/catpt/pcm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
sound/soc/intel/catpt/pcm.c +4 -8
@@ -114,14 +114,10 @@ catpt_stream_find(struct catpt_dev *cdev, u8 stream_hw_id)return result; } -static u32 catpt_stream_read_position (struct catpt_dev *cdev, -struct catpt_stream_runtime *stream) +static void catpt_stream_read_position (struct catpt_dev *cdev, +struct catpt_stream_runtime *stream,u32 *pos) { -u32 pos; - -memcpy_fromio (&pos, cdev->lpe_ba + stream->info.read_pos_regaddr, -sizeof (pos)); -return pos; +memcpy_fromio (pos, cdev->lpe_ba + stream->info.read_pos_regaddr,sizeof (*pos)); } static u32 catpt_stream_volume(struct catpt_dev *cdev,
@@ -615,7 +611,7 @@ catpt_component_pointer(struct snd_soc_component *component,return 0 ; stream =snd_soc_dai_get_dma_data (cpu_dai, substream); - pos =catpt_stream_read_position (cdev, stream); +catpt_stream_read_position (cdev, stream, &pos);return bytes_to_frames (substream->runtime, pos); }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/5 ASoC: Intel: catpt: Specify image names in the device descriptor
In reply to Cezary RojewskiState files to load explicitly in the device descriptor instead of hiding the details within a loading function. Apart from readability, this also reduces the catpt module size slightly.
--- sound/soc/intel/catpt/core.h | 1 + sound/soc/intel/catpt/device.c | 2 ++ sound/soc/intel/catpt/loader.c | 6 +----- 3 files changed, 4 insertions(+), 5 deletions(-)
sound/soc/intel/catpt/core.h +1 -0
@@ -62,6 +62,7 @@ struct catpt_module_type {struct catpt_spec {struct snd_soc_acpi_mach *machines;u8 core_id; +const char *fw_name;u32 host_dram_offset;u32 host_iram_offset;u32 host_shim_offset;
sound/soc/intel/catpt/device.c +2 -0
@@ -348,6 +348,7 @@ static struct snd_soc_acpi_mach wpt_machines[] = {static struct catpt_spec lpt_desc = { .machines = lpt_machines, .core_id =0x01 , + .fw_name ="intel/IntcSST1.bin" , .host_dram_offset =0x000000 , .host_iram_offset =0x080000 , .host_shim_offset =0x0E7000 ,
@@ -363,6 +364,7 @@ static struct catpt_spec lpt_desc = {static struct catpt_spec wpt_desc = { .machines = wpt_machines, .core_id =0x02 , + .fw_name ="intel/IntcSST2.bin" , .host_dram_offset =0x000000 , .host_iram_offset =0x0A0000 , .host_shim_offset =0x0FB000 ,
sound/soc/intel/catpt/loader.c +1 -5
@@ -581,10 +581,6 @@ static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan,static int catpt_load_images (struct catpt_dev *cdev,bool restore) { -static const char *const names[] = { -"intel/IntcSST1.bin" , -"intel/IntcSST2.bin" , - };struct dma_chan *chan;int ret;
@@ -592,7 +588,7 @@ static int catpt_load_images(struct catpt_dev *cdev, bool restore)if (IS_ERR (chan))return PTR_ERR (chan); - ret =catpt_load_image (cdev, chan, names[cdev->spec->core_id -1 ], + ret =catpt_load_image (cdev, chan, cdev->spec->fw_name,FW_SIGNATURE , restore);if (ret) goto release_dma_chan;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 5/5 ASoC: Intel: catpt: Drop superfluous space in PCM code
In reply to Cezary RojewskiThose spaces are redundant.
--- sound/soc/intel/catpt/pcm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/intel/catpt/pcm.c +5 -5
@@ -687,7 +687,7 @@ static const struct snd_soc_dai_ops catpt_dai_ops = {static struct snd_soc_dai_driver dai_drivers[] = {/* FE DAIs */ { - .name ="System Pin" , + .name ="System Pin" , .id =CATPT_STRM_TYPE_SYSTEM , .ops = &catpt_fe_dai_ops, .playback = {
@@ -710,7 +710,7 @@ static struct snd_soc_dai_driver dai_drivers[] = { }, }, { - .name = "Offload0 Pin", + .name = "Offload0 Pin", .id = CATPT_STRM_TYPE_RENDER, .ops = &catpt_fe_dai_ops, .playback = {
@@ -724,7 +724,7 @@ static struct snd_soc_dai_driver dai_drivers[] = { }, }, { - .name = "Offload1 Pin", + .name = "Offload1 Pin", .id = CATPT_STRM_TYPE_RENDER, .ops = &catpt_fe_dai_ops, .playback = {
@@ -738,7 +738,7 @@ static struct snd_soc_dai_driver dai_drivers[] = { }, }, { - .name = "Loopback Pin", + .name = "Loopback Pin", .id = CATPT_STRM_TYPE_LOOPBACK, .ops = &catpt_fe_dai_ops, .capture = {
@@ -752,7 +752,7 @@ static struct snd_soc_dai_driver dai_drivers[] = { }, }, { - .name = "Bluetooth Pin", + .name = "Bluetooth Pin", .id = CATPT_STRM_TYPE_BLUETOOTH_RENDER, .ops = &catpt_fe_dai_ops, .playback = {
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Cezary Rojewski
Entire patchset provides no new features and does not alter the code from functional (user) perspective.
The first two improve IPC-error logging 'mechanism' and align the catpt-driver with what's done in another Intel's driver: the avs-driver. In essence, no need to log the error in every function, let the common handler do so instead.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: Intel: catpt: Move IPC error messages one level down
commit: 384b13038715f16713d1b2bfe5fb927c8437e48b
[2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
commit: eded4483b8a21eaeb0886ef6f961ccf4e0d9c976
[3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position()
commit: d44f62b09b1e97baee3b10484a1c3c203bb83caf
[4/5] ASoC: Intel: catpt: Specify image names in the device descriptor
commit: e97e07138f956a551895a9556d1a929978a5346d
[5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code
commit: aa30193af8873b3ccfd70a4275336ab6cbd4e5e6All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark