Skip to content

Commit a76e1d9

Browse files
committed
ASoC: Intel: catpt: Round of fixes and PM changes
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: Set of changes addressing gaps in DRAM offset checks, error paths and PM. The first three patches are straight-forward, the last three relate to the power management. The standing out PM change is removal of the catpt-driver as a system-suspend (S3) blocker. This is a suggestion from Andy as indeed, audio is not a critical component that should prevent the system from going into S3. Whatever happens, the driver can recover on a follow up resume (S3 -> S0).
2 parents f2b4592 + 5673654 commit a76e1d9

4 files changed

Lines changed: 37 additions & 25 deletions

File tree

sound/soc/intel/catpt/device.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define CREATE_TRACE_POINTS
2929
#include "trace.h"
3030

31-
static int catpt_suspend(struct device *dev)
31+
static int catpt_do_suspend(struct device *dev)
3232
{
3333
struct catpt_dev *cdev = dev_get_drvdata(dev);
3434
struct dma_chan *chan;
@@ -72,6 +72,13 @@ static int catpt_suspend(struct device *dev)
7272
return catpt_dsp_power_down(cdev);
7373
}
7474

75+
/* Do not block the system from suspending, recover on resume() if needed. */
76+
static int catpt_suspend(struct device *dev)
77+
{
78+
catpt_do_suspend(dev);
79+
return 0;
80+
}
81+
7582
static int catpt_resume(struct device *dev)
7683
{
7784
struct catpt_dev *cdev = dev_get_drvdata(dev);
@@ -114,7 +121,7 @@ static int catpt_runtime_suspend(struct device *dev)
114121
}
115122
module_put(dev->driver->owner);
116123

117-
return catpt_suspend(dev);
124+
return catpt_do_suspend(dev);
118125
}
119126

120127
static int catpt_runtime_resume(struct device *dev)
@@ -184,22 +191,25 @@ static int catpt_probe_components(struct catpt_dev *cdev)
184191
goto err_boot_fw;
185192
}
186193

187-
ret = catpt_register_board(cdev);
188-
if (ret) {
189-
dev_err(cdev->dev, "register board failed: %d\n", ret);
190-
goto err_reg_board;
191-
}
192-
193194
/* reflect actual ADSP state in pm_runtime */
194195
pm_runtime_set_active(cdev->dev);
195196

196197
pm_runtime_set_autosuspend_delay(cdev->dev, 2000);
197198
pm_runtime_use_autosuspend(cdev->dev);
198199
pm_runtime_mark_last_busy(cdev->dev);
200+
/* Enable PM before spawning child device. See catpt_dai_pcm_new(). */
199201
pm_runtime_enable(cdev->dev);
202+
203+
ret = catpt_register_board(cdev);
204+
if (ret) {
205+
dev_err(cdev->dev, "register board failed: %d\n", ret);
206+
goto err_reg_board;
207+
}
208+
200209
return 0;
201210

202211
err_reg_board:
212+
pm_runtime_disable(cdev->dev);
203213
snd_soc_unregister_component(cdev->dev);
204214
err_boot_fw:
205215
catpt_dmac_remove(cdev);

sound/soc/intel/catpt/loader.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
208208

209209
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
210210
struct catpt_save_meminfo *info;
211+
struct resource r = {};
211212
u32 off;
212213
int ret;
213214

@@ -216,7 +217,8 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
216217
continue;
217218

218219
off = catpt_to_host_offset(info->offset);
219-
if (off < cdev->dram.start || off > cdev->dram.end)
220+
resource_set_range(&r, off, info->size);
221+
if (!resource_contains(&cdev->dram, &r))
220222
continue;
221223

222224
dev_dbg(cdev->dev, "restoring memdump: off 0x%08x size %d\n",
@@ -239,34 +241,32 @@ static int catpt_restore_fwimage(struct catpt_dev *cdev,
239241
struct dma_chan *chan, dma_addr_t paddr,
240242
struct catpt_fw_block_hdr *blk)
241243
{
242-
struct resource r1, r2, common;
244+
struct resource r1 = {};
243245
int i;
244246

245247
print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4,
246248
blk, sizeof(*blk), false);
247249

248-
r1.start = cdev->dram.start + blk->ram_offset;
249-
r1.end = r1.start + blk->size - 1;
250+
resource_set_range(&r1, cdev->dram.start + blk->ram_offset, blk->size);
250251
/* advance to data area */
251252
paddr += sizeof(*blk);
252253

253254
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
254255
struct catpt_save_meminfo *info;
256+
struct resource common = {};
257+
struct resource r2 = {};
255258
u32 off;
256259
int ret;
257260

258261
info = &cdev->dx_ctx.meminfo[i];
259-
260262
if (info->source != CATPT_DX_TYPE_FW_IMAGE)
261263
continue;
262264

263265
off = catpt_to_host_offset(info->offset);
264-
if (off < cdev->dram.start || off > cdev->dram.end)
266+
resource_set_range(&r2, off, info->size);
267+
if (!resource_contains(&cdev->dram, &r2))
265268
continue;
266269

267-
r2.start = off;
268-
r2.end = r2.start + info->size - 1;
269-
270270
if (!resource_intersection(&r2, &r1, &common))
271271
continue;
272272
/* calculate start offset of common data area */

sound/soc/intel/catpt/pcm.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,10 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream,
417417
return CATPT_IPC_ERROR(ret);
418418

419419
ret = catpt_dai_apply_usettings(dai, stream);
420-
if (ret)
420+
if (ret) {
421+
catpt_ipc_free_stream(cdev, stream->info.stream_hw_id);
421422
return ret;
423+
}
422424

423425
stream->allocated = true;
424426
return 0;
@@ -669,7 +671,7 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm,
669671
return 0;
670672

671673
ret = pm_runtime_resume_and_get(cdev->dev);
672-
if (ret < 0 && ret != -EACCES)
674+
if (ret)
673675
return ret;
674676

675677
ret = catpt_ipc_set_device_format(cdev, &devfmt);
@@ -872,7 +874,7 @@ static int catpt_mixer_volume_get(struct snd_kcontrol *kcontrol,
872874
int i;
873875

874876
ret = pm_runtime_resume_and_get(cdev->dev);
875-
if (ret < 0 && ret != -EACCES)
877+
if (ret)
876878
return ret;
877879

878880
for (i = 0; i < CATPT_CHANNELS_MAX; i++) {
@@ -893,7 +895,7 @@ static int catpt_mixer_volume_put(struct snd_kcontrol *kcontrol,
893895
int ret;
894896

895897
ret = pm_runtime_resume_and_get(cdev->dev);
896-
if (ret < 0 && ret != -EACCES)
898+
if (ret)
897899
return ret;
898900

899901
ret = catpt_set_dspvol(cdev, cdev->mixer.mixer_hw_id,
@@ -924,7 +926,7 @@ static int catpt_stream_volume_get(struct snd_kcontrol *kcontrol,
924926
}
925927

926928
ret = pm_runtime_resume_and_get(cdev->dev);
927-
if (ret < 0 && ret != -EACCES)
929+
if (ret)
928930
return ret;
929931

930932
for (i = 0; i < CATPT_CHANNELS_MAX; i++) {
@@ -955,7 +957,7 @@ static int catpt_stream_volume_put(struct snd_kcontrol *kcontrol,
955957
}
956958

957959
ret = pm_runtime_resume_and_get(cdev->dev);
958-
if (ret < 0 && ret != -EACCES)
960+
if (ret)
959961
return ret;
960962

961963
ret = catpt_set_dspvol(cdev, stream->info.stream_hw_id,
@@ -1031,7 +1033,7 @@ static int catpt_loopback_switch_put(struct snd_kcontrol *kcontrol,
10311033
}
10321034

10331035
ret = pm_runtime_resume_and_get(cdev->dev);
1034-
if (ret < 0 && ret != -EACCES)
1036+
if (ret)
10351037
return ret;
10361038

10371039
ret = catpt_ipc_mute_loopback(cdev, stream->info.stream_hw_id, mute);

sound/soc/intel/catpt/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static ssize_t fw_version_show(struct device *dev,
1616
int ret;
1717

1818
ret = pm_runtime_resume_and_get(cdev->dev);
19-
if (ret < 0 && ret != -EACCES)
19+
if (ret)
2020
return ret;
2121

2222
ret = catpt_ipc_get_fw_version(cdev, &version);

0 commit comments

Comments
 (0)