git: ba4f05b55fb4 - main - acpi_spmc(4): Factor out testing for present DSMs/functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 May 2026 12:40:02 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=ba4f05b55fb4b006f1bbe26d3ad3527f48e85939
commit ba4f05b55fb4b006f1bbe26d3ad3527f48e85939
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-05-06 09:31:19 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-05-13 12:38:25 +0000
acpi_spmc(4): Factor out testing for present DSMs/functions
Since we are now keeping in the softc the information about which DSM
functions are available (in supported_functions[]), the 'dsms' field
there is somewhat redundant.
Make it completely redundant by keeping the bit representing the
enumeration function itself in each element of supported_functions[],
and then remove the field.
As a result, convert has_dsm() to rely on supports_function().
Adapt acpi_spmc_dsm_check_functions() so that it does not take into
account the enumeration function bit.
While here, use the self-explanatory stance
IDX_TO_BIT(DSM_ENUM_FUNCTIONS) instead of a hardcoded 1.
Reviewed by: obiwac
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56878
---
sys/dev/acpica/acpi_spmc.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c
index b2da99864581..da9c80266952 100644
--- a/sys/dev/acpica/acpi_spmc.c
+++ b/sys/dev/acpica/acpi_spmc.c
@@ -223,7 +223,6 @@ struct acpi_spmc_constraint {
struct acpi_spmc_softc {
device_t dev;
ACPI_HANDLE handle;
- int dsms;
uint64_t supported_functions[nitems(dsms)];
struct eventhandler_entry *eh_suspend;
@@ -257,7 +256,7 @@ supports_function(const struct acpi_spmc_softc *const sc, const int dsm_index,
static bool
has_dsm(const struct acpi_spmc_softc *const sc, const int dsm_index)
{
- return ((sc->dsms & IDX_TO_BIT(dsm_index)) != 0);
+ return (supports_function(sc, dsm_index, DSM_ENUM_FUNCTIONS));
}
typedef const char *pbf_get_name_t(const int, const void *const);
@@ -371,6 +370,7 @@ acpi_spmc_attach(device_t dev)
{
struct acpi_spmc_softc *const sc = device_get_softc(dev);
const ACPI_HANDLE handle = acpi_get_handle(dev);
+ int supported_dsms;
char buf[32];
int error;
@@ -382,6 +382,7 @@ acpi_spmc_attach(device_t dev)
sc->dev = dev;
sc->handle = handle;
+ supported_dsms = 0;
for (int i = 0; i < nitems(dsms); ++i) {
KASSERT(dsms[i] != NULL, ("%s: Sparse dsms[]!", __func__));
KASSERT(dsms[i]->index == i,
@@ -389,14 +390,17 @@ acpi_spmc_attach(device_t dev)
dsms[i]->name));
acpi_spmc_probe_dsm(sc, dsms[i]);
+ if (has_dsm(sc, i))
+ supported_dsms |= IDX_TO_BIT(i);
}
- if (sc->dsms == 0) {
+ if (supported_dsms == 0) {
device_printf(dev, "No DSM supported!");
return (ENXIO);
}
- print_bit_field(buf, sizeof(buf), sc->dsms, "DSM", pbf_dsm_name, NULL);
+ print_bit_field(buf, sizeof(buf), supported_dsms, "DSM",
+ pbf_dsm_name, NULL);
device_printf(dev, "DSMs supported: %s\n", buf);
/* Print supported functions of usable DSMs. */
@@ -436,7 +440,12 @@ static void
acpi_spmc_dsm_print_functions(const struct acpi_spmc_softc *const sc,
const struct dsm_desc *const dsm)
{
- const uint64_t supported_functions =
+ /*
+ * Remove the enumeration function bit, which we do not care about when
+ * printing which functions are supported and which we do not want to
+ * report as unknown.
+ */
+ const uint64_t supported_functions = ~IDX_TO_BIT(DSM_ENUM_FUNCTIONS) &
sc->supported_functions[dsm->index];
const uint64_t missing = dsm->expected_functions & ~supported_functions;
const uint64_t unknown = supported_functions &
@@ -475,10 +484,9 @@ acpi_spmc_probe_dsm(struct acpi_spmc_softc *const sc,
/*
* DSM is supported if bit 0 is set.
*/
- if ((supported_functions & 1) == 0)
+ if ((supported_functions & IDX_TO_BIT(DSM_ENUM_FUNCTIONS)) == 0)
return;
- sc->supported_functions[dsm->index] = supported_functions & ~1;
- sc->dsms |= IDX_TO_BIT(dsm->index);
+ sc->supported_functions[dsm->index] = supported_functions;
}
static void