Message ID | 20230721094722.300586-3-cezary.rojewski@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | ACPI: NHLT: Access and query helpers | expand |
On Fri, Jul 21, 2023 at 11:47:20AM +0200, Cezary Rojewski wrote: > While there is no strict limit to amount of NHLT tables present, usually > just the first one is utilized. To simplify implementation of sound > drivers, provide publicly accessible pointer. Accessing it after calling > acpi_nhlt_get_gbl_table() yields the first NHLT table met during the > scan. ... > @@ -594,6 +594,9 @@ config ACPI_PRMT > +config ACPI_NHLT Wouldn't be better to squeeze it to the most ordered piece of the file, so the list of the table support code files will be kinda ordered? Otherwise looks good to me, FWIW, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
On 2023-07-21 12:48 PM, Andy Shevchenko wrote: > On Fri, Jul 21, 2023 at 11:47:20AM +0200, Cezary Rojewski wrote: >> While there is no strict limit to amount of NHLT tables present, usually >> just the first one is utilized. To simplify implementation of sound >> drivers, provide publicly accessible pointer. Accessing it after calling >> acpi_nhlt_get_gbl_table() yields the first NHLT table met during the >> scan. ... >> @@ -594,6 +594,9 @@ config ACPI_PRMT > >> +config ACPI_NHLT > > Wouldn't be better to squeeze it to the most ordered piece of the file, so > the list of the table support code files will be kinda ordered? I may be wrong about this, but it seems that the driver/acpi/Kconfig file does not list tables supported in any kind of ordered fashion. I'd refrain from reordering the Kconfig in this very patch and rather have such job done in a separate series instead. > Otherwise looks good to me, FWIW, > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
On Fri, Jul 21, 2023 at 02:44:42PM +0200, Cezary Rojewski wrote: > On 2023-07-21 12:48 PM, Andy Shevchenko wrote: > > On Fri, Jul 21, 2023 at 11:47:20AM +0200, Cezary Rojewski wrote: ... > > > @@ -594,6 +594,9 @@ config ACPI_PRMT > > > > > +config ACPI_NHLT > > > > Wouldn't be better to squeeze it to the most ordered piece of the file, so > > the list of the table support code files will be kinda ordered? > > I may be wrong about this, but it seems that the driver/acpi/Kconfig file > does not list tables supported in any kind of ordered fashion. I'd refrain > from reordering the Kconfig in this very patch and rather have such job done > in a separate series instead. Yes, but my point to make this job easier to whoever will do it. > > Otherwise looks good to me, FWIW, > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
On 2023-07-21 2:55 PM, Andy Shevchenko wrote: > On Fri, Jul 21, 2023 at 02:44:42PM +0200, Cezary Rojewski wrote: >> On 2023-07-21 12:48 PM, Andy Shevchenko wrote: >>> On Fri, Jul 21, 2023 at 11:47:20AM +0200, Cezary Rojewski wrote: ... >>>> @@ -594,6 +594,9 @@ config ACPI_PRMT >>> >>>> +config ACPI_NHLT >>> >>> Wouldn't be better to squeeze it to the most ordered piece of the file, so >>> the list of the table support code files will be kinda ordered? >> >> I may be wrong about this, but it seems that the driver/acpi/Kconfig file >> does not list tables supported in any kind of ordered fashion. I'd refrain >> from reordering the Kconfig in this very patch and rather have such job done >> in a separate series instead. > > Yes, but my point to make this job easier to whoever will do it. Hmm.. I see that the most occurrences of word "Table" is around ACPI_SPCR_TABLE/_FPDT/LPIT area. Should I put it after ACPI_LPIT perhaps? >>> Otherwise looks good to me, FWIW, >>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
On Fri, Jul 21, 2023 at 03:18:11PM +0200, Cezary Rojewski wrote: > On 2023-07-21 2:55 PM, Andy Shevchenko wrote: > > On Fri, Jul 21, 2023 at 02:44:42PM +0200, Cezary Rojewski wrote: > > > On 2023-07-21 12:48 PM, Andy Shevchenko wrote: > > > > On Fri, Jul 21, 2023 at 11:47:20AM +0200, Cezary Rojewski wrote: ... > > > > > @@ -594,6 +594,9 @@ config ACPI_PRMT > > > > > > > > > +config ACPI_NHLT > > > > > > > > Wouldn't be better to squeeze it to the most ordered piece of the file, so > > > > the list of the table support code files will be kinda ordered? > > > > > > I may be wrong about this, but it seems that the driver/acpi/Kconfig file > > > does not list tables supported in any kind of ordered fashion. I'd refrain > > > from reordering the Kconfig in this very patch and rather have such job done > > > in a separate series instead. > > > > Yes, but my point to make this job easier to whoever will do it. > > Hmm.. I see that the most occurrences of word "Table" is around > ACPI_SPCR_TABLE/_FPDT/LPIT area. Should I put it after ACPI_LPIT perhaps? Works for me! As I wrote "most ordered place" and "kinda ordered" above. > > > > Otherwise looks good to me, FWIW, > > > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccbeab9500ec..01ce5d3533db 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -594,6 +594,9 @@ config ACPI_PRMT substantially increase computational overhead related to the initialization of some server systems. +config ACPI_NHLT + bool + endif # ACPI config X86_PM_TIMER diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index feb36c0b9446..8de34970e7db 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -93,6 +93,7 @@ obj-$(CONFIG_ACPI) += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_PLATFORM_PROFILE) += platform_profile.o obj-$(CONFIG_ACPI_NFIT) += nfit/ +obj-$(CONFIG_ACPI_NHLT) += nhlt.o obj-$(CONFIG_ACPI_NUMA) += numa/ obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o diff --git a/drivers/acpi/nhlt.c b/drivers/acpi/nhlt.c new file mode 100644 index 000000000000..18b2f3752840 --- /dev/null +++ b/drivers/acpi/nhlt.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2023 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <cezary.rojewski@intel.com> +// Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com> +// + +#include <linux/export.h> +#include <acpi/nhlt.h> + +struct acpi_table_nhlt *acpi_gbl_nhlt; +EXPORT_SYMBOL_GPL(acpi_gbl_nhlt); + +static struct acpi_table_nhlt empty_nhlt = { + .header = { + .signature = ACPI_SIG_NHLT, + }, +}; + +/** + * acpi_nhlt_get_gbl_table - Retrieve a pointer to the first NHLT table. + * + * If there is no NHLT in the system, acpi_gbl_nhlt will instead point to an + * empty table. + * + * Return: ACPI status code of the operation. + */ +acpi_status acpi_nhlt_get_gbl_table(void) +{ + acpi_status status; + + status = acpi_get_table(ACPI_SIG_NHLT, 0, (struct acpi_table_header **)(&acpi_gbl_nhlt)); + if (!acpi_gbl_nhlt) + acpi_gbl_nhlt = &empty_nhlt; + return status; +} +EXPORT_SYMBOL_GPL(acpi_nhlt_get_gbl_table); + +/** + * acpi_nhlt_put_gbl_table - Release the global NHLT table. + */ +void acpi_nhlt_put_gbl_table(void) +{ + acpi_put_table((struct acpi_table_header *)acpi_gbl_nhlt); +} +EXPORT_SYMBOL_GPL(acpi_nhlt_put_gbl_table); diff --git a/include/acpi/nhlt.h b/include/acpi/nhlt.h index af3ec45ba4f9..e68e0534412d 100644 --- a/include/acpi/nhlt.h +++ b/include/acpi/nhlt.h @@ -63,4 +63,34 @@ __cfg->capabilities_size == struct_size(__cfg, mics, __cfg->num_mics) ? \ __cfg : NULL; }) +#if IS_ENABLED(CONFIG_ACPI_NHLT) + +/* + * System-wide pointer to the first NHLT table. + * + * A sound driver may utilize acpi_nhlt_get/put_gbl_table() on its + * initialization and removal respectively to avoid excessive mapping + * and unmapping of the memory occupied by the table between streaming + * operations. + */ +extern struct acpi_table_nhlt *acpi_gbl_nhlt; + +acpi_status acpi_nhlt_get_gbl_table(void); +void acpi_nhlt_put_gbl_table(void); + +#else /* !CONFIG_ACPI_NHLT */ + +#define acpi_gbl_nhlt NULL + +static inline acpi_status acpi_nhlt_get_gbl_table(void) +{ + return AE_NOT_FOUND; +} + +static inline void acpi_nhlt_put_gbl_table(void) +{ +} + +#endif /* CONFIG_ACPI_NHLT */ + #endif /* __ACPI_NHLT_H__ */
While there is no strict limit to amount of NHLT tables present, usually just the first one is utilized. To simplify implementation of sound drivers, provide publicly accessible pointer. Accessing it after calling acpi_nhlt_get_gbl_table() yields the first NHLT table met during the scan. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> --- drivers/acpi/Kconfig | 3 +++ drivers/acpi/Makefile | 1 + drivers/acpi/nhlt.c | 47 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/nhlt.h | 30 +++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 drivers/acpi/nhlt.c