@@ -257,67 +257,55 @@ static void hdac_update_stream(struct hdac_bus *bus, struct hdac_stream *stream)
257257 }
258258}
259259
260- static irqreturn_t hdac_bus_irq_handler ( int irq , void * context )
260+ static irqreturn_t avs_hda_interrupt ( struct hdac_bus * bus )
261261{
262- struct hdac_bus * bus = context ;
263- u32 mask , int_enable ;
262+ irqreturn_t ret = IRQ_NONE ;
264263 u32 status ;
265- int ret = IRQ_NONE ;
266-
267- if (!pm_runtime_active (bus -> dev ))
268- return ret ;
269-
270- spin_lock (& bus -> reg_lock );
271264
272265 status = snd_hdac_chip_readl (bus , INTSTS );
273- if (status == 0 || status == UINT_MAX ) {
274- spin_unlock (& bus -> reg_lock );
275- return ret ;
276- }
266+ if (snd_hdac_bus_handle_stream_irq (bus , status , hdac_update_stream ))
267+ ret = IRQ_HANDLED ;
277268
278- /* clear rirb int */
269+ spin_lock_irq (& bus -> reg_lock );
270+ /* Clear RIRB interrupt. */
279271 status = snd_hdac_chip_readb (bus , RIRBSTS );
280272 if (status & RIRB_INT_MASK ) {
281273 if (status & RIRB_INT_RESPONSE )
282274 snd_hdac_bus_update_rirb (bus );
283275 snd_hdac_chip_writeb (bus , RIRBSTS , RIRB_INT_MASK );
284- }
285-
286- mask = (0x1 << bus -> num_streams ) - 1 ;
287-
288- status = snd_hdac_chip_readl (bus , INTSTS );
289- status &= mask ;
290- if (status ) {
291- /* Disable stream interrupts; Re-enable in bottom half */
292- int_enable = snd_hdac_chip_readl (bus , INTCTL );
293- snd_hdac_chip_writel (bus , INTCTL , (int_enable & (~mask )));
294- ret = IRQ_WAKE_THREAD ;
295- } else {
296276 ret = IRQ_HANDLED ;
297277 }
298278
299- spin_unlock (& bus -> reg_lock );
279+ spin_unlock_irq (& bus -> reg_lock );
300280 return ret ;
301281}
302282
303- static irqreturn_t hdac_bus_irq_thread (int irq , void * context )
283+ static irqreturn_t avs_hda_irq_handler (int irq , void * dev_id )
284+ {
285+ struct hdac_bus * bus = dev_id ;
286+ u32 intsts ;
287+
288+ intsts = snd_hdac_chip_readl (bus , INTSTS );
289+ if (intsts == UINT_MAX || !(intsts & AZX_INT_GLOBAL_EN ))
290+ return IRQ_NONE ;
291+
292+ /* Mask GIE, unmasked in irq_thread(). */
293+ snd_hdac_chip_updatel (bus , INTCTL , AZX_INT_GLOBAL_EN , 0 );
294+
295+ return IRQ_WAKE_THREAD ;
296+ }
297+
298+ static irqreturn_t avs_hda_irq_thread (int irq , void * dev_id )
304299{
305- struct hdac_bus * bus = context ;
300+ struct hdac_bus * bus = dev_id ;
306301 u32 status ;
307- u32 int_enable ;
308- u32 mask ;
309- unsigned long flags ;
310302
311303 status = snd_hdac_chip_readl (bus , INTSTS );
304+ if (status & ~AZX_INT_GLOBAL_EN )
305+ avs_hda_interrupt (bus );
312306
313- snd_hdac_bus_handle_stream_irq (bus , status , hdac_update_stream );
314-
315- /* Re-enable stream interrupts */
316- mask = (0x1 << bus -> num_streams ) - 1 ;
317- spin_lock_irqsave (& bus -> reg_lock , flags );
318- int_enable = snd_hdac_chip_readl (bus , INTCTL );
319- snd_hdac_chip_writel (bus , INTCTL , (int_enable | mask ));
320- spin_unlock_irqrestore (& bus -> reg_lock , flags );
307+ /* Unmask GIE, masked in irq_handler(). */
308+ snd_hdac_chip_updatel (bus , INTCTL , AZX_INT_GLOBAL_EN , AZX_INT_GLOBAL_EN );
321309
322310 return IRQ_HANDLED ;
323311}
@@ -326,14 +314,23 @@ static irqreturn_t avs_dsp_irq_handler(int irq, void *dev_id)
326314{
327315 struct avs_dev * adev = dev_id ;
328316
329- return avs_dsp_op ( adev , irq_handler );
317+ return avs_hda_irq_handler ( irq , & adev -> base . core );
330318}
331319
332320static irqreturn_t avs_dsp_irq_thread (int irq , void * dev_id )
333321{
334322 struct avs_dev * adev = dev_id ;
323+ struct hdac_bus * bus = & adev -> base .core ;
324+ u32 status ;
325+
326+ status = readl (bus -> ppcap + AZX_REG_PP_PPSTS );
327+ if (status & AZX_PPCTL_PIE )
328+ avs_dsp_op (adev , dsp_interrupt );
335329
336- return avs_dsp_op (adev , irq_thread );
330+ /* Unmask GIE, masked in irq_handler(). */
331+ snd_hdac_chip_updatel (bus , INTCTL , AZX_INT_GLOBAL_EN , AZX_INT_GLOBAL_EN );
332+
333+ return IRQ_HANDLED ;
337334}
338335
339336static int avs_hdac_acquire_irq (struct avs_dev * adev )
@@ -349,7 +346,7 @@ static int avs_hdac_acquire_irq(struct avs_dev *adev)
349346 return ret ;
350347 }
351348
352- ret = pci_request_irq (pci , 0 , hdac_bus_irq_handler , hdac_bus_irq_thread , bus ,
349+ ret = pci_request_irq (pci , 0 , avs_hda_irq_handler , avs_hda_irq_thread , bus ,
353350 KBUILD_MODNAME );
354351 if (ret < 0 ) {
355352 dev_err (adev -> dev , "Failed to request stream IRQ handler: %d\n" , ret );
@@ -530,8 +527,6 @@ static void avs_pci_shutdown(struct pci_dev *pci)
530527 snd_hdac_bus_stop_chip (bus );
531528 snd_hdac_display_power (bus , HDA_CODEC_IDX_CONTROLLER , false);
532529
533- if (avs_platattr_test (adev , CLDMA ))
534- pci_free_irq (pci , 0 , & code_loader );
535530 pci_free_irq (pci , 0 , adev );
536531 pci_free_irq (pci , 0 , bus );
537532 pci_free_irq_vectors (pci );
0 commit comments