mbox series

[v2,0/4] Add Loongson HD Audio support

Message ID cover.1686057365.git.siyanteng@loongson.cn
Headers show
Series Add Loongson HD Audio support | expand

Message

Yanteng Si June 6, 2023, 1:25 p.m. UTC
v2:
* Handling with two new flags added to struct hdac_bus.

v1:
* The Loongson HDA controller is compatible with High Definition Audio
  Specification Revision 1.0a.
  See <https://loongson.github.io/LoongArch-Documentation/Loongson-
  7A1000-usermanual-EN.html#hda-controller>

Yanteng Si (4):
  ALSA: hda: Add Loongson LS7A HD-Audio support
  ALSA: hda: Using polling mode for loongson controller by default
  ALSA: hda: Workaround for SDnCTL register on loongson controller
  ALSA: hda/intel: Workaround for WALLCLK register for loongson
    controller

 include/linux/pci_ids.h     |  3 +++
 include/sound/hdaudio.h     |  2 ++
 sound/hda/hdac_controller.c |  5 ++++-
 sound/hda/hdac_device.c     |  1 +
 sound/hda/hdac_stream.c     |  6 +++++-
 sound/pci/hda/hda_intel.c   | 15 +++++++++++++++
 sound/pci/hda/patch_hdmi.c  |  1 +
 7 files changed, 31 insertions(+), 2 deletions(-)

Comments

Takashi Iwai June 6, 2023, 1:39 p.m. UTC | #1
On Tue, 06 Jun 2023 15:25:28 +0200,
Yanteng Si wrote:
> 
> On loongson controller, RIRBSTS.RINTFL cannot be cleared,
> azx_interrupt() is called all the time. We disable RIRB
> interrupt, and use polling mode by default.
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Yingkun Meng <mengyingkun@loongson.cn>
> ---
>  include/sound/hdaudio.h     | 1 +
>  sound/hda/hdac_controller.c | 5 ++++-
>  sound/pci/hda/hda_intel.c   | 4 ++++
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index 97f09acae302..a1dcc7f97d08 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -346,6 +346,7 @@ struct hdac_bus {
>  	bool reverse_assign:1;		/* assign devices in reverse order */
>  	bool corbrp_self_clear:1;	/* CORBRP clears itself after reset */
>  	bool polling_mode:1;
> +	bool no_intr_polling_mode:1;

It isn't clear enough what this flag does.  It's basically prohibiting
the RIRB IRQ (hence requiring the polling mode), right?  Write it in
the comment.

> diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c
> index 3c7af6558249..705e09cc50ac 100644
> --- a/sound/hda/hdac_controller.c
> +++ b/sound/hda/hdac_controller.c
> @@ -79,7 +79,10 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
>  	/* set N=1, get RIRB response interrupt for new entry */
>  	snd_hdac_chip_writew(bus, RINTCNT, 1);
>  	/* enable rirb dma and response irq */
> -	snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
> +	if (bus->no_intr_polling_mode)
> +		snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN);
> +	else
> +		snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
>  	/* Accept unsolicited responses */
>  	snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);
>  	spin_unlock_irq(&bus->reg_lock);
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index 9c353dc7740c..1e8993836fc6 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -1875,6 +1875,10 @@ static int azx_first_init(struct azx *chip)
>  	if (chip->driver_type == AZX_DRIVER_GFHDMI)
>  		bus->polling_mode = 1;
>  
> +	if (chip->driver_type == AZX_DRIVER_LOONGSON) {
> +		bus->no_intr_polling_mode = 1;
> +	}

Don't you need to set the bus->polling_mode?


thanks,

Takashi
Yanteng Si June 7, 2023, 4:48 a.m. UTC | #2
在 2023/6/6 21:39, Takashi Iwai 写道:
> On Tue, 06 Jun 2023 15:25:28 +0200,
> Yanteng Si wrote:
>> On loongson controller, RIRBSTS.RINTFL cannot be cleared,
>> azx_interrupt() is called all the time. We disable RIRB
>> interrupt, and use polling mode by default.
>>
>> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
>> Signed-off-by: Yingkun Meng <mengyingkun@loongson.cn>
>> ---
>>   include/sound/hdaudio.h     | 1 +
>>   sound/hda/hdac_controller.c | 5 ++++-
>>   sound/pci/hda/hda_intel.c   | 4 ++++
>>   3 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
>> index 97f09acae302..a1dcc7f97d08 100644
>> --- a/include/sound/hdaudio.h
>> +++ b/include/sound/hdaudio.h
>> @@ -346,6 +346,7 @@ struct hdac_bus {
>>   	bool reverse_assign:1;		/* assign devices in reverse order */
>>   	bool corbrp_self_clear:1;	/* CORBRP clears itself after reset */
>>   	bool polling_mode:1;
>> +	bool no_intr_polling_mode:1;
> It isn't clear enough what this flag does.  It's basically prohibiting
> the RIRB IRQ (hence requiring the polling mode), right?  Write it in
> the comment.
OK!
>
>> diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c
>> index 3c7af6558249..705e09cc50ac 100644
>> --- a/sound/hda/hdac_controller.c
>> +++ b/sound/hda/hdac_controller.c
>> @@ -79,7 +79,10 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
>>   	/* set N=1, get RIRB response interrupt for new entry */
>>   	snd_hdac_chip_writew(bus, RINTCNT, 1);
>>   	/* enable rirb dma and response irq */
>> -	snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
>> +	if (bus->no_intr_polling_mode)
>> +		snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN);
>> +	else
>> +		snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
>>   	/* Accept unsolicited responses */
>>   	snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);
>>   	spin_unlock_irq(&bus->reg_lock);
>> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
>> index 9c353dc7740c..1e8993836fc6 100644
>> --- a/sound/pci/hda/hda_intel.c
>> +++ b/sound/pci/hda/hda_intel.c
>> @@ -1875,6 +1875,10 @@ static int azx_first_init(struct azx *chip)
>>   	if (chip->driver_type == AZX_DRIVER_GFHDMI)
>>   		bus->polling_mode = 1;
>>   
>> +	if (chip->driver_type == AZX_DRIVER_LOONGSON) {
>> +		bus->no_intr_polling_mode = 1;
>> +	}
> Don't you need to set the bus->polling_mode?

Yes, I do.

Although it works now, some messages will print.


Thanks,

Yanteng

>
>
> thanks,
>
> Takashi