Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2026 13:41:34 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: cc2715cf1f86 - main - acpi_apm: Narrow scope of ACPI_LOCK
Message-ID:  <69ca7d8e.245f6.17fbbc14@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=cc2715cf1f864345ab175db691d4e152d5fb84af

commit cc2715cf1f864345ab175db691d4e152d5fb84af
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-03-30 13:38:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-03-30 13:41:06 +0000

    acpi_apm: Narrow scope of ACPI_LOCK
    
    This lock doesn't need to be held across seldrain/knlist_destroy.  It
    is also redundant (and a bug) to hold it across knlist_add and
    knlist_remove since it is the mutex for the knlist.
    
    PR:             293901
    Reported by:    Jiaming Zhang <r772577952@gmail.com>
    Reviewed by:    markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D55994
---
 sys/x86/acpica/acpi_apm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/x86/acpica/acpi_apm.c b/sys/x86/acpica/acpi_apm.c
index 919f76949dd4..71e2573d5fde 100644
--- a/sys/x86/acpica/acpi_apm.c
+++ b/sys/x86/acpica/acpi_apm.c
@@ -243,9 +243,9 @@ apmdtor(void *data)
 	/* Remove this clone's data from the list and free it. */
 	ACPI_LOCK(acpi);
 	STAILQ_REMOVE(&acpi_sc->apm_cdevs, clone, apm_clone_data, entries);
+	ACPI_UNLOCK(acpi);
 	seldrain(&clone->sel_read);
 	knlist_destroy(&clone->sel_read.si_note);
-	ACPI_UNLOCK(acpi);
 	free(clone, M_APMDEV);
 }
 
@@ -408,11 +408,9 @@ apmkqfilter(struct cdev *dev, struct knote *kn)
 	struct	apm_clone_data *clone;
 
 	devfs_get_cdevpriv((void **)&clone);
-	ACPI_LOCK(acpi);
 	kn->kn_hook = clone;
 	kn->kn_fop = &apm_readfiltops;
 	knlist_add(&clone->sel_read.si_note, kn, 0);
-	ACPI_UNLOCK(acpi);
 	return (0);
 }
 
@@ -421,10 +419,8 @@ apmreadfiltdetach(struct knote *kn)
 {
 	struct	apm_clone_data *clone;
 
-	ACPI_LOCK(acpi);
 	clone = kn->kn_hook;
 	knlist_remove(&clone->sel_read.si_note, kn, 0);
-	ACPI_UNLOCK(acpi);
 }
 
 static int
@@ -433,8 +429,8 @@ apmreadfilt(struct knote *kn, long hint)
 	struct	apm_clone_data *clone;
 	int	sleeping;
 
-	ACPI_LOCK(acpi);
 	clone = kn->kn_hook;
+	ACPI_LOCK(acpi);
 	sleeping = clone->acpi_sc->acpi_next_stype != POWER_STYPE_AWAKE;
 	ACPI_UNLOCK(acpi);
 	return (sleeping);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ca7d8e.245f6.17fbbc14>