Skip to content

Commit 97bd565

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: avs: Abstract IRQ handling
Servicing IPCs on CNL platforms and onward differs from the existing one. To make room for these, relocate SKL-based platforms specific code into the skl.c file leaving only the genering irq_handler in the common code. Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240220115035.770402-6-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7576e2f commit 97bd565

File tree

5 files changed

+48
-37
lines changed

5 files changed

+48
-37
lines changed

sound/soc/intel/avs/apl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ const struct avs_dsp_ops avs_apl_dsp_ops = {
236236
.power = avs_dsp_core_power,
237237
.reset = avs_dsp_core_reset,
238238
.stall = avs_dsp_core_stall,
239-
.irq_handler = avs_dsp_irq_handler,
240-
.irq_thread = avs_dsp_irq_thread,
239+
.irq_handler = avs_irq_handler,
240+
.irq_thread = avs_skl_irq_thread,
241241
.int_control = avs_dsp_interrupt_control,
242242
.load_basefw = avs_hda_load_basefw,
243243
.load_lib = avs_hda_load_library,

sound/soc/intel/avs/avs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct avs_dsp_ops {
4646
int (* const power)(struct avs_dev *, u32, bool);
4747
int (* const reset)(struct avs_dev *, u32, bool);
4848
int (* const stall)(struct avs_dev *, u32, bool);
49-
irqreturn_t (* const irq_handler)(int, void *);
50-
irqreturn_t (* const irq_thread)(int, void *);
49+
irqreturn_t (* const irq_handler)(struct avs_dev *);
50+
irqreturn_t (* const irq_thread)(struct avs_dev *);
5151
void (* const int_control)(struct avs_dev *, bool);
5252
int (* const load_basefw)(struct avs_dev *, struct firmware *);
5353
int (* const load_lib)(struct avs_dev *, struct firmware *, u32);
@@ -242,8 +242,7 @@ struct avs_ipc {
242242
#define AVS_IPC_RET(ret) \
243243
(((ret) <= 0) ? (ret) : -AVS_EIPC)
244244

245-
irqreturn_t avs_dsp_irq_handler(int irq, void *dev_id);
246-
irqreturn_t avs_dsp_irq_thread(int irq, void *dev_id);
245+
irqreturn_t avs_irq_handler(struct avs_dev *adev);
247246
void avs_dsp_process_response(struct avs_dev *adev, u64 header);
248247
int avs_dsp_send_msg_timeout(struct avs_dev *adev, struct avs_ipc_msg *request,
249248
struct avs_ipc_msg *reply, int timeout, const char *name);
@@ -265,6 +264,7 @@ void avs_ipc_block(struct avs_ipc *ipc);
265264
int avs_dsp_disable_d0ix(struct avs_dev *adev);
266265
int avs_dsp_enable_d0ix(struct avs_dev *adev);
267266

267+
irqreturn_t avs_skl_irq_thread(struct avs_dev *adev);
268268
int avs_skl_log_buffer_offset(struct avs_dev *adev, u32 core);
269269

270270
/* Firmware resources management */

sound/soc/intel/avs/core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ static irqreturn_t hdac_bus_irq_thread(int irq, void *context)
321321
return IRQ_HANDLED;
322322
}
323323

324+
static irqreturn_t avs_dsp_irq_handler(int irq, void *dev_id)
325+
{
326+
struct avs_dev *adev = dev_id;
327+
328+
return avs_dsp_op(adev, irq_handler);
329+
}
330+
331+
static irqreturn_t avs_dsp_irq_thread(int irq, void *dev_id)
332+
{
333+
struct avs_dev *adev = dev_id;
334+
335+
return avs_dsp_op(adev, irq_thread);
336+
}
337+
324338
static int avs_hdac_acquire_irq(struct avs_dev *adev)
325339
{
326340
struct hdac_bus *bus = &adev->base.core;

sound/soc/intel/avs/ipc.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,8 @@ void avs_dsp_process_response(struct avs_dev *adev, u64 header)
301301
complete(&ipc->busy_completion);
302302
}
303303

304-
irqreturn_t avs_dsp_irq_handler(int irq, void *dev_id)
304+
irqreturn_t avs_irq_handler(struct avs_dev *adev)
305305
{
306-
struct avs_dev *adev = dev_id;
307306
struct avs_ipc *ipc = adev->ipc;
308307
const struct avs_spec *const spec = adev->spec;
309308
u32 adspis, hipc_rsp, hipc_ack;
@@ -350,33 +349,6 @@ irqreturn_t avs_dsp_irq_handler(int irq, void *dev_id)
350349
return ret;
351350
}
352351

353-
irqreturn_t avs_dsp_irq_thread(int irq, void *dev_id)
354-
{
355-
struct avs_dev *adev = dev_id;
356-
union avs_reply_msg msg;
357-
u32 hipct, hipcte;
358-
359-
hipct = snd_hdac_adsp_readl(adev, SKL_ADSP_REG_HIPCT);
360-
hipcte = snd_hdac_adsp_readl(adev, SKL_ADSP_REG_HIPCTE);
361-
362-
/* ensure DSP sent new response to process */
363-
if (!(hipct & SKL_ADSP_HIPCT_BUSY))
364-
return IRQ_NONE;
365-
366-
msg.primary = hipct;
367-
msg.ext.val = hipcte;
368-
avs_dsp_process_response(adev, msg.val);
369-
370-
/* tell DSP we accepted its message */
371-
snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCT,
372-
SKL_ADSP_HIPCT_BUSY, SKL_ADSP_HIPCT_BUSY);
373-
/* unmask busy interrupt */
374-
snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCCTL,
375-
AVS_ADSP_HIPCCTL_BUSY, AVS_ADSP_HIPCCTL_BUSY);
376-
377-
return IRQ_HANDLED;
378-
}
379-
380352
static bool avs_ipc_is_busy(struct avs_ipc *ipc)
381353
{
382354
struct avs_dev *adev = to_avs_dev(ipc->dev);

sound/soc/intel/avs/skl.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@
1212
#include "avs.h"
1313
#include "messages.h"
1414

15+
irqreturn_t avs_skl_irq_thread(struct avs_dev *adev)
16+
{
17+
union avs_reply_msg msg;
18+
u32 hipct, hipcte;
19+
20+
hipct = snd_hdac_adsp_readl(adev, SKL_ADSP_REG_HIPCT);
21+
hipcte = snd_hdac_adsp_readl(adev, SKL_ADSP_REG_HIPCTE);
22+
23+
/* Ensure DSP sent new response to process. */
24+
if (!(hipct & SKL_ADSP_HIPCT_BUSY))
25+
return IRQ_NONE;
26+
27+
msg.primary = hipct;
28+
msg.ext.val = hipcte;
29+
avs_dsp_process_response(adev, msg.val);
30+
31+
/* Tell DSP we accepted its message. */
32+
snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCT, SKL_ADSP_HIPCT_BUSY, SKL_ADSP_HIPCT_BUSY);
33+
/* Unmask busy interrupt. */
34+
snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCCTL, AVS_ADSP_HIPCCTL_BUSY,
35+
AVS_ADSP_HIPCCTL_BUSY);
36+
37+
return IRQ_HANDLED;
38+
}
39+
1540
static int __maybe_unused
1641
avs_skl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32 aging_period,
1742
u32 fifo_full_period, unsigned long resource_mask, u32 *priorities)
@@ -103,8 +128,8 @@ const struct avs_dsp_ops avs_skl_dsp_ops = {
103128
.power = avs_dsp_core_power,
104129
.reset = avs_dsp_core_reset,
105130
.stall = avs_dsp_core_stall,
106-
.irq_handler = avs_dsp_irq_handler,
107-
.irq_thread = avs_dsp_irq_thread,
131+
.irq_handler = avs_irq_handler,
132+
.irq_thread = avs_skl_irq_thread,
108133
.int_control = avs_dsp_interrupt_control,
109134
.load_basefw = avs_cldma_load_basefw,
110135
.load_lib = avs_cldma_load_library,

0 commit comments

Comments
 (0)