From nobody Fri Jan 19 16:39:33 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TGlh536Gcz56s1P; Fri, 19 Jan 2024 16:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TGlh52Y7vz47lP; Fri, 19 Jan 2024 16:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q9vzaWDQSwVEGg18a9u6hIgRl56W7btFMUP3SfWP5XI=; b=XQwVRFNNTFZ2bU+Rl2fCvmPBsa5c75OXBmwXhxj17VzvKXewdXW5PyxgJP3hV1wxd+FBHH KJ8NM7zbowXzHOOXQT5032v2dIvtsl807ZS2ESTwFTc9nDIARcPfTg91A6Z9CVugYVBW/H wLj36zwPuaaVqnqKp8MZm+P86U9oQY02I2M3XGFRlij/PJjtxSn+UGrM1v4VEOzlBfCWIa VeSih5sMyCAguYbPRope45m3bjmNqZm06Agu2vo4494udnhUdk0EsSip1theEzLhWserbu AUzbbqWQkJ7EyFbgf4cZlxqWJtqK3adDaA9TcUi68iuCjfckJhd2d0rIHJc4xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q9vzaWDQSwVEGg18a9u6hIgRl56W7btFMUP3SfWP5XI=; b=yJ+zo5a+jQwZLMIZnBl7hDJYa1iw5CavogwE3X5PS1+DPMDTh+bPn+ZUD1Iy7cb3fnj0M4 5qh65sSzHHrGKJbf72seWQe6PUkuG4qLceaJ/yZfFuRieirsZhsICtIYj/xCtMZ/OE8/io doZLSPUHb0rA7xj3rYRX3shhZsJJBw2k26i+1xhMIw29TlJOd8j2lJtvGvqjo+pVg1Wo+Z 6lhnS9ALycuSxMMbyQd48vGK9DbgU9MR1yoXD6FdJi3pr7cEA6eo4OQ2Bx0mssXr/rBOIs FYF4YSLiNUYjJowL9AaeYB1Uw3qlRhLSze0sEI3h4UU6Z6QPEmEbUCeyxVst2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705682373; a=rsa-sha256; cv=none; b=D2OdJzVyqSDuzWmaj6UzJStGgFoEfhNOfiUKZnuAObAKawLHPqGqzXkg7ESAsAySh4bpVA LyAoHntLjVMZTvc9e7mFIb70wZOWM94GRgEfl6n1zkm8HvpOR+EfogFebdMhej2NlFhCRt 0nMtF4AIDomO0SkVnSxpBqhdtbumlyJop74V+vg2AU2l0/j+RcQtzKqY6RF6x/4ATKhd4r 1P6jFQ68eu33CSiUiSCmh+AKmNyFdsdUjfJMjE0tWWGz0dZqy6Gw04JWfXEdp0KWjsZ4Va ZoG1HPF/d/oLzLwECpyF36DQijfMSTgu7d9kVTk/L2WAC1r5U3rIXHRG2y8mkQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TGlh51cC7zyb4; Fri, 19 Jan 2024 16:39:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40JGdXHE027422; Fri, 19 Jan 2024 16:39:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JGdXPY027419; Fri, 19 Jan 2024 16:39:33 GMT (envelope-from git) Date: Fri, 19 Jan 2024 16:39:33 GMT Message-Id: <202401191639.40JGdXPY027419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 265a52fe6cd2 - stable/14 - acpi_lid: Remove duplicate events List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 265a52fe6cd27398c115d374bf778c7e0dfd850b Auto-Submitted: auto-generated The branch stable/14 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=265a52fe6cd27398c115d374bf778c7e0dfd850b commit 265a52fe6cd27398c115d374bf778c7e0dfd850b Author: Alexander Motin AuthorDate: 2023-12-24 02:33:51 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 16:39:28 +0000 acpi_lid: Remove duplicate events Remove extra acpi_UserNotify() call per event. Filter duplicate notifications received from ACPI without actual status change. Without this on my Dell XPS 13 9310 I saw 4 devd events for either open or close, now only one. MFC after: 1 month (cherry picked from commit 1a3ee6002f3e008e0bc29d04c976285434503e19) --- sys/dev/acpica/acpi_lid.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c index 44730879c31e..142791f7282a 100644 --- a/sys/dev/acpica/acpi_lid.c +++ b/sys/dev/acpica/acpi_lid.c @@ -91,7 +91,7 @@ static driver_t acpi_lid_driver = { DRIVER_MODULE(acpi_lid, acpi, acpi_lid_driver, 0, 0); MODULE_DEPEND(acpi_lid, acpi, 1, 1, 1); -static void +static int acpi_lid_status_update(struct acpi_lid_softc *sc) { ACPI_STATUS status; @@ -107,9 +107,12 @@ acpi_lid_status_update(struct acpi_lid_softc *sc) status = acpi_GetInteger(sc->lid_handle, "_LID", &lid_status); if (ACPI_FAILURE(status)) lid_status = 1; /* assume lid is opened */ + else + lid_status = (lid_status != 0); /* range check value */ - /* range check value */ - sc->lid_status = lid_status ? 1 : 0; + if (sc->lid_status == lid_status) + return (EALREADY); + sc->lid_status = lid_status; /* Send notification via devd */ acpi_UserNotify("Lid", sc->lid_handle, sc->lid_status); @@ -119,6 +122,7 @@ acpi_lid_status_update(struct acpi_lid_softc *sc) evdev_push_sw(sc->lid_evdev, SW_LID, lid_status ? 0 : 1); evdev_sync(sc->lid_evdev); #endif + return (0); } static int @@ -146,6 +150,7 @@ acpi_lid_attach(device_t dev) sc = device_get_softc(dev); sc->lid_dev = dev; acpi_lid_handle = sc->lid_handle = acpi_get_handle(dev); + sc->lid_status = -1; #ifdef EVDEV_SUPPORT /* Register evdev device before initial status update */ @@ -219,7 +224,8 @@ acpi_lid_notify_status_changed(void *arg) ACPI_SERIAL_BEGIN(lid); /* Update lid status, if any */ - acpi_lid_status_update(sc); + if (acpi_lid_status_update(sc) != 0) + goto out; acpi_sc = acpi_device_get_parent_softc(sc->lid_dev); if (acpi_sc == NULL) @@ -228,8 +234,6 @@ acpi_lid_notify_status_changed(void *arg) ACPI_VPRINT(sc->lid_dev, acpi_sc, "Lid %s\n", sc->lid_status ? "opened" : "closed"); - acpi_UserNotify("Lid", sc->lid_handle, sc->lid_status); - if (sc->lid_status == 0) EVENTHANDLER_INVOKE(acpi_sleep_event, acpi_sc->acpi_lid_switch_sx); else