Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4481246imw; Tue, 19 Jul 2022 07:25:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vyBhNWTtjKbKf//3koCZyhP/L1AvT4t6ZcG3WZYhx7P9/EHZogUfvV41RVkC/FW4iHNQ2x X-Received: by 2002:a05:6402:84d:b0:435:a764:9aad with SMTP id b13-20020a056402084d00b00435a7649aadmr45936667edz.332.1658240703370; Tue, 19 Jul 2022 07:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658240703; cv=none; d=google.com; s=arc-20160816; b=A5XSHGpHXZOlvUCBoERgY6KC9ajfowS3MVVW4yVsVURgv77I70MIrZ+O7iRpb74YFn 5RJ24wH8ubuenHCuXj/bCz89jacxbcNeaIVcdmtpQ2et+BJjz9z9NbiqnPvc5+RjJ2lD 4ebZTFQXZ/NGWjHFtfpwY/CfWY4q/WfgaB7+05adEz7Nzy1LQ7nYuWIISmHOYCt/mkcG dqU4xLUbL8Odl1T1F6j3uEl4OOERSEDb2u/vNVoyDPlkBvbNohruQXiZlxtuYa61fe9k 5aA1LF6bHLFd8tMTLXFlwyRhZ3JsOjg6LQx6B/p686694OlNZCE4vxAx3mAgqD58dYAK FmKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BAqF6jIGU+eseF6nQxTZW6o6NDPi6vEiNIqllSKXerQ=; b=N5wN74FWD9DHS5tv/V8Q0h3EFlfV/IsGnBOGCFt963udh82PNIHOJOGiKA3VPKDyZa 2W2XCcV27hes7gqB391zRyRgO9BbsdJ0Ieg79t9RuTcaECh6aRmf/60HixA6wQn6kg1O 8ee/PErMvU5kZaBhnKFNP0DKKIs4Vx4RGmtKKD2DAumiYX0E1cPVGxopKhCcCaPNWAos adOsGmXIQiHKDRX0GNnL4WJgDZGVs57aA7J2xVlccfmQVDepcCxbVP+7whXFiWSIUzVE sqIcYZ+RufMS9bDQoCQqR7qZdpul7g9dWYSS114KBEFOfifjrYYFyvqPMeRYGt4w1OCB w3XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fn3ByTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs9-20020a1709072d0900b0072f1f41bf94si12366294ejc.244.2022.07.19.07.24.35; Tue, 19 Jul 2022 07:25:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fn3ByTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243272AbiGSNLe (ORCPT + 99 others); Tue, 19 Jul 2022 09:11:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243224AbiGSNK2 (ORCPT ); Tue, 19 Jul 2022 09:10:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB8C65541; Tue, 19 Jul 2022 05:29:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 4F5FBCE1B7D; Tue, 19 Jul 2022 12:28:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F985C341D1; Tue, 19 Jul 2022 12:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233728; bh=6egDnfLx31jfxdqK3K+JaWDNB/se+vJa4Ry3gxod+sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0fn3ByTBxrcyZe3cIXWLpu2riu9pOx3Suh+1EI06WJ5oz6ZHfDNN8xzmxXh9fJfL5 s/zsizzPu2gBGRQsvly4nq2CqwgtuPR4PENklwgQWy7FROV2Odb5yp/T4zZVsFuXqR mCU0tW+1TiCBE8UHevtX0PeqFlgwjUk6oshxztg0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , "Rafael J. Wysocki" , Sasha Levin , Ben Greening Subject: [PATCH 5.18 221/231] ACPI: video: Fix acpi_video_handles_brightness_key_presses() Date: Tue, 19 Jul 2022 13:55:06 +0200 Message-Id: <20220719114732.326909106@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit 5ad26161a371e4aa2d2553286f0cac580987a493 ] Commit 3a0cf7ab8df3 ("ACPI: video: Change how we determine if brightness key-presses are handled") made acpi_video_handles_brightness_key_presses() report false when none of the ACPI Video Devices support backlight control. But it turns out that at least on a Dell Inspiron N4010 there is no ACPI backlight control, yet brightness hotkeys are still reported through the ACPI Video Bus; and since acpi_video_handles_brightness_key_presses() now returns false, brightness keypresses are now reported twice. To fix this rename the has_backlight flag to may_report_brightness_keys and also set it the first time a brightness key press event is received. Depending on the delivery of the other ACPI (WMI) event vs the ACPI Video Bus event this means that the first brightness key press might still get reported twice, but all further keypresses will be filtered as before. Note that this relies on other drivers reporting brightness key events calling acpi_video_handles_brightness_key_presses() when delivering the events (rather then once during driver probe). This is already required and documented in include/acpi/video.h: /* * Note: The value returned by acpi_video_handles_brightness_key_presses() * may change over time and should not be cached. */ Fixes: 3a0cf7ab8df3 ("ACPI: video: Change how we determine if brightness key-presses are handled") Link: https://lore.kernel.org/regressions/CALF=6jEe5G8+r1Wo0vvz4GjNQQhdkLT5p8uCHn6ZXhg4nsOWow@mail.gmail.com/ Reported-and-tested-by: Ben Greening Signed-off-by: Hans de Goede Acked-by: Rafael J. Wysocki Link: https://lore.kernel.org/r/20220713211101.85547-2-hdegoede@redhat.com Signed-off-by: Sasha Levin --- drivers/acpi/acpi_video.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -73,7 +73,7 @@ module_param(device_id_scheme, bool, 044 static int only_lcd = -1; module_param(only_lcd, int, 0444); -static bool has_backlight; +static bool may_report_brightness_keys; static int register_count; static DEFINE_MUTEX(register_count_mutex); static DEFINE_MUTEX(video_list_lock); @@ -1224,7 +1224,7 @@ acpi_video_bus_get_one_device(struct acp acpi_video_device_find_cap(data); if (data->cap._BCM && data->cap._BCL) - has_backlight = true; + may_report_brightness_keys = true; mutex_lock(&video->device_list_lock); list_add_tail(&data->entry, &video->video_device_list); @@ -1693,6 +1693,9 @@ static void acpi_video_device_notify(acp break; } + if (keycode) + may_report_brightness_keys = true; + acpi_notifier_call_chain(device, event, 0); if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) { @@ -2254,7 +2257,7 @@ void acpi_video_unregister(void) if (register_count) { acpi_bus_unregister_driver(&acpi_video_bus); register_count = 0; - has_backlight = false; + may_report_brightness_keys = false; } mutex_unlock(®ister_count_mutex); } @@ -2276,7 +2279,7 @@ void acpi_video_unregister_backlight(voi bool acpi_video_handles_brightness_key_presses(void) { - return has_backlight && + return may_report_brightness_keys && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS); } EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses);