All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: Refactor Intel NHLT init
@ 2020-04-23 11:21 Cezary Rojewski
  2020-04-23 11:24 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Cezary Rojewski @ 2020-04-23 11:21 UTC (permalink / raw)
  To: alsa-devel; +Cc: Cezary Rojewski, broonie, tiwai, pierre-louis.bossart

NHLT fetch based on _DSM prevents ACPI table override mechanism from
being utilized. Make use of acpi_get_table to enable it and get rid of
redundant code.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/hda/intel-nhlt.c | 49 +++++++-----------------------------------
 1 file changed, 8 insertions(+), 41 deletions(-)

diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c
index 99a23fe7fab9..2f741d2792d8 100644
--- a/sound/hda/intel-nhlt.c
+++ b/sound/hda/intel-nhlt.c
@@ -4,58 +4,25 @@
 #include <linux/acpi.h>
 #include <sound/intel-nhlt.h>
 
-#define NHLT_ACPI_HEADER_SIG	"NHLT"
-
-/* Unique identification for getting NHLT blobs */
-static const guid_t osc_guid =
-	GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
-		  0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
-
 struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
 {
-	acpi_handle handle;
-	union acpi_object *obj;
-	struct nhlt_resource_desc *nhlt_ptr;
-	struct nhlt_acpi_table *nhlt_table = NULL;
-
-	handle = ACPI_HANDLE(dev);
-	if (!handle) {
-		dev_err(dev, "Didn't find ACPI_HANDLE\n");
-		return NULL;
-	}
+	struct nhlt_acpi_table *nhlt;
+	acpi_status status;
 
-	obj = acpi_evaluate_dsm(handle, &osc_guid, 1, 1, NULL);
-
-	if (!obj)
-		return NULL;
-
-	if (obj->type != ACPI_TYPE_BUFFER) {
-		dev_dbg(dev, "No NHLT table found\n");
-		ACPI_FREE(obj);
+	status = acpi_get_table(ACPI_SIG_NHLT, 0,
+				(struct acpi_table_header **)&nhlt);
+	if (ACPI_FAILURE(status)) {
+		dev_warn(dev, "NHLT table not found\n");
 		return NULL;
 	}
 
-	nhlt_ptr = (struct nhlt_resource_desc  *)obj->buffer.pointer;
-	if (nhlt_ptr->length)
-		nhlt_table = (struct nhlt_acpi_table *)
-			memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
-				 MEMREMAP_WB);
-	ACPI_FREE(obj);
-	if (nhlt_table &&
-	    (strncmp(nhlt_table->header.signature,
-		     NHLT_ACPI_HEADER_SIG,
-		     strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
-		memunmap(nhlt_table);
-		dev_err(dev, "NHLT ACPI header signature incorrect\n");
-		return NULL;
-	}
-	return nhlt_table;
+	return nhlt;
 }
 EXPORT_SYMBOL_GPL(intel_nhlt_init);
 
 void intel_nhlt_free(struct nhlt_acpi_table *nhlt)
 {
-	memunmap((void *)nhlt);
+	acpi_put_table((struct acpi_table_header *)nhlt);
 }
 EXPORT_SYMBOL_GPL(intel_nhlt_free);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 11:21 [PATCH] ALSA: hda: Refactor Intel NHLT init Cezary Rojewski
@ 2020-04-23 11:24 ` Takashi Iwai
  2020-04-23 11:40   ` Cezary Rojewski
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2020-04-23 11:24 UTC (permalink / raw)
  To: Cezary Rojewski; +Cc: alsa-devel, broonie, tiwai, pierre-louis.bossart

On Thu, 23 Apr 2020 13:21:36 +0200,
Cezary Rojewski wrote:
> 
> NHLT fetch based on _DSM prevents ACPI table override mechanism from
> being utilized. Make use of acpi_get_table to enable it and get rid of
> redundant code.
> 
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>

This looks like a nice cleanup and I'll happily apply if anyone can
test with the actual hardware -- currently mine has no DSP, so unable
to check.


thanks,

Takashi

> ---
>  sound/hda/intel-nhlt.c | 49 +++++++-----------------------------------
>  1 file changed, 8 insertions(+), 41 deletions(-)
> 
> diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c
> index 99a23fe7fab9..2f741d2792d8 100644
> --- a/sound/hda/intel-nhlt.c
> +++ b/sound/hda/intel-nhlt.c
> @@ -4,58 +4,25 @@
>  #include <linux/acpi.h>
>  #include <sound/intel-nhlt.h>
>  
> -#define NHLT_ACPI_HEADER_SIG	"NHLT"
> -
> -/* Unique identification for getting NHLT blobs */
> -static const guid_t osc_guid =
> -	GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
> -		  0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
> -
>  struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
>  {
> -	acpi_handle handle;
> -	union acpi_object *obj;
> -	struct nhlt_resource_desc *nhlt_ptr;
> -	struct nhlt_acpi_table *nhlt_table = NULL;
> -
> -	handle = ACPI_HANDLE(dev);
> -	if (!handle) {
> -		dev_err(dev, "Didn't find ACPI_HANDLE\n");
> -		return NULL;
> -	}
> +	struct nhlt_acpi_table *nhlt;
> +	acpi_status status;
>  
> -	obj = acpi_evaluate_dsm(handle, &osc_guid, 1, 1, NULL);
> -
> -	if (!obj)
> -		return NULL;
> -
> -	if (obj->type != ACPI_TYPE_BUFFER) {
> -		dev_dbg(dev, "No NHLT table found\n");
> -		ACPI_FREE(obj);
> +	status = acpi_get_table(ACPI_SIG_NHLT, 0,
> +				(struct acpi_table_header **)&nhlt);
> +	if (ACPI_FAILURE(status)) {
> +		dev_warn(dev, "NHLT table not found\n");
>  		return NULL;
>  	}
>  
> -	nhlt_ptr = (struct nhlt_resource_desc  *)obj->buffer.pointer;
> -	if (nhlt_ptr->length)
> -		nhlt_table = (struct nhlt_acpi_table *)
> -			memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
> -				 MEMREMAP_WB);
> -	ACPI_FREE(obj);
> -	if (nhlt_table &&
> -	    (strncmp(nhlt_table->header.signature,
> -		     NHLT_ACPI_HEADER_SIG,
> -		     strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
> -		memunmap(nhlt_table);
> -		dev_err(dev, "NHLT ACPI header signature incorrect\n");
> -		return NULL;
> -	}
> -	return nhlt_table;
> +	return nhlt;
>  }
>  EXPORT_SYMBOL_GPL(intel_nhlt_init);
>  
>  void intel_nhlt_free(struct nhlt_acpi_table *nhlt)
>  {
> -	memunmap((void *)nhlt);
> +	acpi_put_table((struct acpi_table_header *)nhlt);
>  }
>  EXPORT_SYMBOL_GPL(intel_nhlt_free);
>  
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 11:24 ` Takashi Iwai
@ 2020-04-23 11:40   ` Cezary Rojewski
  2020-04-23 12:15     ` Takashi Iwai
  2020-04-23 16:29     ` Pierre-Louis Bossart
  0 siblings, 2 replies; 8+ messages in thread
From: Cezary Rojewski @ 2020-04-23 11:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, broonie, tiwai, pierre-louis.bossart

On 2020-04-23 13:24, Takashi Iwai wrote:
> On Thu, 23 Apr 2020 13:21:36 +0200,
> Cezary Rojewski wrote:
>>
>> NHLT fetch based on _DSM prevents ACPI table override mechanism from
>> being utilized. Make use of acpi_get_table to enable it and get rid of
>> redundant code.
>>
>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
> 
> This looks like a nice cleanup and I'll happily apply if anyone can
> test with the actual hardware -- currently mine has no DSP, so unable
> to check.
> 
> 
> thanks,
> 
> Takashi
> 

NHLT override method has been added for internal use half a year ago and 
is for some time the default method within our CI. This is tested on a 
wide spread of hardware, that is any Intel AVS archtecture, including 
production laptops.

Actual override works like any SSDT/ DSDT, e.g. usage can be found at:
https://github.com/thesofproject/acpi-scripts

and original:
https://wiki.up-community.org/Pinout_UP2#Installing_ACPI_overrides_to_enable_spi_in_userspace

Early this year I've pushed the initiative to finally shatter bounds of 
mystery surrounding NHLT in Linux and make it available to community. 
Erik and Robert helped me in ACPICA part, patch link:
https://patchwork.kernel.org/patch/11463235/

Spec can now be found at:
https://01.org/blogs/intel-smart-sound-technology-audio-dsp

This has been sanctioned by Intel Legal and acked by Marcin Obara, NHLT 
author so no worries about spec disappearing like it did in 2016.

Czarek

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 11:40   ` Cezary Rojewski
@ 2020-04-23 12:15     ` Takashi Iwai
  2020-04-23 12:21       ` Cezary Rojewski
  2020-04-23 16:29     ` Pierre-Louis Bossart
  1 sibling, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2020-04-23 12:15 UTC (permalink / raw)
  To: Cezary Rojewski; +Cc: alsa-devel, broonie, tiwai, pierre-louis.bossart

On Thu, 23 Apr 2020 13:40:10 +0200,
Cezary Rojewski wrote:
> 
> On 2020-04-23 13:24, Takashi Iwai wrote:
> > On Thu, 23 Apr 2020 13:21:36 +0200,
> > Cezary Rojewski wrote:
> >>
> >> NHLT fetch based on _DSM prevents ACPI table override mechanism from
> >> being utilized. Make use of acpi_get_table to enable it and get rid of
> >> redundant code.
> >>
> >> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
> >
> > This looks like a nice cleanup and I'll happily apply if anyone can
> > test with the actual hardware -- currently mine has no DSP, so unable
> > to check.
> >
> >
> > thanks,
> >
> > Takashi
> >
> 
> NHLT override method has been added for internal use half a year ago
> and is for some time the default method within our CI. This is tested
> on a wide spread of hardware, that is any Intel AVS archtecture,
> including production laptops.

This could be mentioned in the changelog, otherwise we have no idea
about the test coverage.

> Actual override works like any SSDT/ DSDT, e.g. usage can be found at:
> https://github.com/thesofproject/acpi-scripts
> 
> and original:
> https://wiki.up-community.org/Pinout_UP2#Installing_ACPI_overrides_to_enable_spi_in_userspace
> 
> Early this year I've pushed the initiative to finally shatter bounds
> of mystery surrounding NHLT in Linux and make it available to
> community. Erik and Robert helped me in ACPICA part, patch link:
> https://patchwork.kernel.org/patch/11463235/
> 
> Spec can now be found at:
> https://01.org/blogs/intel-smart-sound-technology-audio-dsp
> 
> This has been sanctioned by Intel Legal and acked by Marcin Obara,
> NHLT author so no worries about spec disappearing like it did in 2016.

Great, thanks!


Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 12:15     ` Takashi Iwai
@ 2020-04-23 12:21       ` Cezary Rojewski
  2020-04-23 12:24         ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Cezary Rojewski @ 2020-04-23 12:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, broonie, tiwai, pierre-louis.bossart

On 2020-04-23 14:15, Takashi Iwai wrote:
> On Thu, 23 Apr 2020 13:40:10 +0200,
> Cezary Rojewski wrote:
>>
>> On 2020-04-23 13:24, Takashi Iwai wrote:
>>> On Thu, 23 Apr 2020 13:21:36 +0200,
>>> Cezary Rojewski wrote:
>>>>
>>>> NHLT fetch based on _DSM prevents ACPI table override mechanism from
>>>> being utilized. Make use of acpi_get_table to enable it and get rid of
>>>> redundant code.
>>>>
>>>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
>>>
>>> This looks like a nice cleanup and I'll happily apply if anyone can
>>> test with the actual hardware -- currently mine has no DSP, so unable
>>> to check.
>>>
>>>
>>> thanks,
>>>
>>> Takashi
>>>
>>
>> NHLT override method has been added for internal use half a year ago
>> and is for some time the default method within our CI. This is tested
>> on a wide spread of hardware, that is any Intel AVS archtecture,
>> including production laptops.
> 
> This could be mentioned in the changelog, otherwise we have no idea
> about the test coverage.
> 

My apologizes Takashi, indeed I should have mentioned that :(

I've forgotten about one more positive news:
https://bugs.acpica.org/show_bug.cgi?id=1525

Robert is working on official NHLT support for iASL. Currently, only 
header gets decompilled while the rest is dumped as binary array.

Do you want me to resubmit the patch with this entire info appended to 
the commit message?

Czarek

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 12:21       ` Cezary Rojewski
@ 2020-04-23 12:24         ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2020-04-23 12:24 UTC (permalink / raw)
  To: Cezary Rojewski; +Cc: alsa-devel, broonie, tiwai, pierre-louis.bossart

On Thu, 23 Apr 2020 14:21:15 +0200,
Cezary Rojewski wrote:
> 
> On 2020-04-23 14:15, Takashi Iwai wrote:
> > On Thu, 23 Apr 2020 13:40:10 +0200,
> > Cezary Rojewski wrote:
> >>
> >> On 2020-04-23 13:24, Takashi Iwai wrote:
> >>> On Thu, 23 Apr 2020 13:21:36 +0200,
> >>> Cezary Rojewski wrote:
> >>>>
> >>>> NHLT fetch based on _DSM prevents ACPI table override mechanism from
> >>>> being utilized. Make use of acpi_get_table to enable it and get rid of
> >>>> redundant code.
> >>>>
> >>>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
> >>>
> >>> This looks like a nice cleanup and I'll happily apply if anyone can
> >>> test with the actual hardware -- currently mine has no DSP, so unable
> >>> to check.
> >>>
> >>>
> >>> thanks,
> >>>
> >>> Takashi
> >>>
> >>
> >> NHLT override method has been added for internal use half a year ago
> >> and is for some time the default method within our CI. This is tested
> >> on a wide spread of hardware, that is any Intel AVS archtecture,
> >> including production laptops.
> >
> > This could be mentioned in the changelog, otherwise we have no idea
> > about the test coverage.
> >
> 
> My apologizes Takashi, indeed I should have mentioned that :(
> 
> I've forgotten about one more positive news:
> https://bugs.acpica.org/show_bug.cgi?id=1525
> 
> Robert is working on official NHLT support for iASL. Currently, only
> header gets decompilled while the rest is dumped as binary array.
> 
> Do you want me to resubmit the patch with this entire info appended to
> the commit message?

Yes, it would be appreciated.  Especially the additional information
is helpful.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 11:40   ` Cezary Rojewski
  2020-04-23 12:15     ` Takashi Iwai
@ 2020-04-23 16:29     ` Pierre-Louis Bossart
  2020-04-23 17:10       ` Cezary Rojewski
  1 sibling, 1 reply; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-04-23 16:29 UTC (permalink / raw)
  To: Cezary Rojewski, Takashi Iwai; +Cc: alsa-devel, broonie, tiwai



On 4/23/20 6:40 AM, Cezary Rojewski wrote:
> On 2020-04-23 13:24, Takashi Iwai wrote:
>> On Thu, 23 Apr 2020 13:21:36 +0200,
>> Cezary Rojewski wrote:
>>>
>>> NHLT fetch based on _DSM prevents ACPI table override mechanism from
>>> being utilized. Make use of acpi_get_table to enable it and get rid of
>>> redundant code.
>>>
>>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
>>
>> This looks like a nice cleanup and I'll happily apply if anyone can
>> test with the actual hardware -- currently mine has no DSP, so unable
>> to check.
>>
>>
>> thanks,
>>
>> Takashi
>>
> 
> NHLT override method has been added for internal use half a year ago and 
> is for some time the default method within our CI. This is tested on a 
> wide spread of hardware, that is any Intel AVS archtecture, including 
> production laptops.

We are checking independently with SOF CI [1], the NHLT is used to 
detect microphone counts so we'll see if there's a regression.

That said, for my education Cezary an you clarify what you typically 
override? the settings are usually tied to specific hardware configs.
Also the NHLT may point to a topology file name but with your recent 
changes an alternate file can be used, so it's not clear to me how 
non-Intel folks might use the override and for what?

While I am at it, we recently had a bug report where a user provided the 
NHLT, and I had no idea how to go about parsing it to check its 
contents. Are there any tools to dump the contents in human-readable 
representation?

[1] https://github.com/thesofproject/linux/pull/2046

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda: Refactor Intel NHLT init
  2020-04-23 16:29     ` Pierre-Louis Bossart
@ 2020-04-23 17:10       ` Cezary Rojewski
  0 siblings, 0 replies; 8+ messages in thread
From: Cezary Rojewski @ 2020-04-23 17:10 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Takashi Iwai; +Cc: alsa-devel, broonie, tiwai

On 2020-04-23 18:29, Pierre-Louis Bossart wrote:
> On 4/23/20 6:40 AM, Cezary Rojewski wrote:
>> On 2020-04-23 13:24, Takashi Iwai wrote:
>>> On Thu, 23 Apr 2020 13:21:36 +0200,
>>> Cezary Rojewski wrote:
>>>>
>>>> NHLT fetch based on _DSM prevents ACPI table override mechanism from
>>>> being utilized. Make use of acpi_get_table to enable it and get rid of
>>>> redundant code.
>>>>
>>>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
>>>
>>> This looks like a nice cleanup and I'll happily apply if anyone can
>>> test with the actual hardware -- currently mine has no DSP, so unable
>>> to check.
>>>
>>>
>>> thanks,
>>>
>>> Takashi
>>>
>>
>> NHLT override method has been added for internal use half a year ago 
>> and is for some time the default method within our CI. This is tested 
>> on a wide spread of hardware, that is any Intel AVS archtecture, 
>> including production laptops.
> 
> We are checking independently with SOF CI [1], the NHLT is used to 
> detect microphone counts so we'll see if there's a regression.
> 
> That said, for my education Cezary an you clarify what you typically 
> override? the settings are usually tied to specific hardware configs.

When speaking of testing purposes, we actually ignore the go-to one/two 
format limit which is often applied on production stuff. E.g.: you may 
proliferate SSP blobs and make use of up to 256 formats (NHLT enforced 
limit IIRC). That goes for SSP loopback testing.
Same applies to DMIC. While hardware tells you 0, 2 or 4 channels, 
nothing prevents you to play with different bit depths/ sampling rate. 
You could even force 2ch on 4ch setups. Clock changes are also part of 
the game.

> Also the NHLT may point to a topology file name but with your recent 
> changes an alternate file can be used, so it's not clear to me how 
> non-Intel folks might use the override and for what?

NHLT-based topology filename is a long standing issue. When you launch 
/skylake on a non-NHLT setup (e.g. Linus laptop) you end up with a 
perfectly white-spaced filename. Does not look very secure to me. It 
also makes it difficult to share topologies with OEMs - in practice 
production stuff is available in dozens of different OEM-id/revision-id 
combinations, and thus topology naming becomes a nightmare.

Let's get this nightmare over with.

In perfect world all users would have received their stuff with correct 
BIOS settings applied. We, humans, did not reach that point yet though. 
It's handy to have a quick workaround for that. While none of NHLT GUI 
tools are upstreamed yet, spec is already there. So, a clever user (or 
one with Intel's help) can dump his existing NHLT table:
	cat /sys/firmware/acpi/tables/NHLT > nhlt.bin

Decompile it -or- play with binary directly to append a missing format.

> 
> While I am at it, we recently had a bug report where a user provided the 
> NHLT, and I had no idea how to go about parsing it to check its 
> contents. Are there any tools to dump the contents in human-readable 
> representation?
> 

To my knowledge there are none available externally. Maybe soon this 
will change. If I managed to push spec upstream, a 'simple tool' 
shouldn't be a problem. But who knows..

Internally? There are few : )

> [1] https://github.com/thesofproject/linux/pull/2046

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-23 17:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 11:21 [PATCH] ALSA: hda: Refactor Intel NHLT init Cezary Rojewski
2020-04-23 11:24 ` Takashi Iwai
2020-04-23 11:40   ` Cezary Rojewski
2020-04-23 12:15     ` Takashi Iwai
2020-04-23 12:21       ` Cezary Rojewski
2020-04-23 12:24         ` Takashi Iwai
2020-04-23 16:29     ` Pierre-Louis Bossart
2020-04-23 17:10       ` Cezary Rojewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.