From patchwork Mon Apr 3 16:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 670086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A2DAC76188 for ; Mon, 3 Apr 2023 16:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232395AbjDCQEi (ORCPT ); Mon, 3 Apr 2023 12:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbjDCQEh (ORCPT ); Mon, 3 Apr 2023 12:04:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 944572136 for ; Mon, 3 Apr 2023 09:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZFVVTffN7T4iHRpTNuctasc2/r1P7S64tl62ohoRynw=; b=PRsu7hb6BQYq3qljcU35vZXhRj1Gj6vrhMupeYpm5o9PJemba3UcfgFPsx/CQYHvPSmHY3 8Xfby3DWFFz74k52H6unspKOnJVNJ2he5iaY8piBFdsl08hhrsAXuO0JKXGgGd1VtZb9cq INj3ydECITN/nco7qwHz9gm3BSkf5MM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-3sXnh4DKO4uOygpOMo5y2Q-1; Mon, 03 Apr 2023 12:03:40 -0400 X-MC-Unique: 3sXnh4DKO4uOygpOMo5y2Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD67C3C17F42; Mon, 3 Apr 2023 16:03:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id E794C2166B26; Mon, 3 Apr 2023 16:03:38 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/6] ACPI: video: Add auto_detect arg to __acpi_video_get_backlight_type() Date: Mon, 3 Apr 2023 18:03:24 +0200 Message-Id: <20230403160329.707176-2-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Allow callers of __acpi_video_get_backlight_type() to pass a pointer to a bool which will get set to false if the backlight-type comes from the cmdline or a DMI quirk and set to true if auto-detection was used. And make __acpi_video_get_backlight_type() non static so that it can be called directly outside of video_detect.c . While at it turn the acpi_video_get_backlight_type() and acpi_video_backlight_use_native() wrappers into static inline functions in include/acpi/video.h, so that we need to export one less symbol. Fixes: 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/acpi/video_detect.c | 21 ++++++++------------- include/acpi/video.h | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index fd7cbce8076e..f7c218dd8742 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -782,7 +782,7 @@ static bool prefer_native_over_acpi_video(void) * Determine which type of backlight interface to use on this system, * First check cmdline, then dmi quirks, then do autodetect. */ -static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native) +enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect) { static DEFINE_MUTEX(init_mutex); static bool nvidia_wmi_ec_present; @@ -807,6 +807,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native) native_available = true; mutex_unlock(&init_mutex); + if (auto_detect) + *auto_detect = false; + /* * The below heuristics / detection steps are in order of descending * presedence. The commandline takes presedence over anything else. @@ -818,6 +821,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native) if (acpi_backlight_dmi != acpi_backlight_undef) return acpi_backlight_dmi; + if (auto_detect) + *auto_detect = true; + /* Special cases such as nvidia_wmi_ec and apple gmux. */ if (nvidia_wmi_ec_present) return acpi_backlight_nvidia_wmi_ec; @@ -837,15 +843,4 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native) /* No ACPI video/native (old hw), use vendor specific fw methods. */ return acpi_backlight_vendor; } - -enum acpi_backlight_type acpi_video_get_backlight_type(void) -{ - return __acpi_video_get_backlight_type(false); -} -EXPORT_SYMBOL(acpi_video_get_backlight_type); - -bool acpi_video_backlight_use_native(void) -{ - return __acpi_video_get_backlight_type(true) == acpi_backlight_native; -} -EXPORT_SYMBOL(acpi_video_backlight_use_native); +EXPORT_SYMBOL(__acpi_video_get_backlight_type); diff --git a/include/acpi/video.h b/include/acpi/video.h index 8ed9bec03e53..ff5a8da5d883 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -59,8 +59,6 @@ extern void acpi_video_unregister(void); extern void acpi_video_register_backlight(void); extern int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, void **edid); -extern enum acpi_backlight_type acpi_video_get_backlight_type(void); -extern bool acpi_video_backlight_use_native(void); /* * Note: The value returned by acpi_video_handles_brightness_key_presses() * may change over time and should not be cached. @@ -69,6 +67,19 @@ extern bool acpi_video_handles_brightness_key_presses(void); extern int acpi_video_get_levels(struct acpi_device *device, struct acpi_video_device_brightness **dev_br, int *pmax_level); + +extern enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, + bool *auto_detect); + +static inline enum acpi_backlight_type acpi_video_get_backlight_type(void) +{ + return __acpi_video_get_backlight_type(false, NULL); +} + +static inline bool acpi_video_backlight_use_native(void) +{ + return __acpi_video_get_backlight_type(true, NULL) == acpi_backlight_native; +} #else static inline void acpi_video_report_nolcd(void) { return; }; static inline int acpi_video_register(void) { return -ENODEV; } From patchwork Mon Apr 3 16:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 669821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF07AC76196 for ; Mon, 3 Apr 2023 16:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbjDCQEi (ORCPT ); Mon, 3 Apr 2023 12:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbjDCQEh (ORCPT ); Mon, 3 Apr 2023 12:04:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2601BF4 for ; Mon, 3 Apr 2023 09:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QFnDNILODHR5me6InULDE/PUm3Vc5LEdBrYsm2u34sI=; b=KX8PLVKlo0wdJ4cKAmR+47GQsEjvGKNvq0wsWTEkfdhw8bU/ESN61rxCzOj3mqjQ5jEJ0F n6dbek6VMN2jndTIlGZI6YOP+CkH+zjelw/EJbVeAaLTcyzY7VwKP6aSgfRNMh7n/qmXB7 GwLhoPHNkHH8C7iWgCaS3k7BAuo6T7k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-PbXa3y9eOjGTBdraZkoPNQ-1; Mon, 03 Apr 2023 12:03:41 -0400 X-MC-Unique: PbXa3y9eOjGTBdraZkoPNQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 105E5101A553; Mon, 3 Apr 2023 16:03:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BF992166B26; Mon, 3 Apr 2023 16:03:40 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/6] ACPI: video: Make acpi_backlight=video work independent from GPU driver Date: Mon, 3 Apr 2023 18:03:25 +0200 Message-Id: <20230403160329.707176-3-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Commit 3dbc80a3e4c5 ("ACPI: video: Make backlight class device registration a separate step (v2)") combined with commit 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Means that the video.ko code now fully depends on the GPU driver calling acpi_video_register_backlight() for the acpi_video# backlight class devices to get registered. This means that if the GPU driver does not do this, acpi_backlight=video on the cmdline, or DMI quirks for selecting acpi_video# will not work. This is a problem on for example Apple iMac14,1 all-in-ones where the monitor's LCD panel shows up as a regular DP connection instead of eDP so the GPU driver will not call acpi_video_register_backlight() [1]. Fix this by making video.ko directly register the acpi_video# devices when these have been explicitly requested either on the cmdline or through DMI quirks (rather then auto-detection being used). [1] GPU drivers only call acpi_video_register_backlight() when an internal panel is detected, to avoid non working acpi_video# devices getting registered on desktops which unfortunately is a real issue. Fixes: 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/acpi/acpi_video.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 97b711e57bff..c7a6d0b69dab 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1984,6 +1984,7 @@ static int instance; static int acpi_video_bus_add(struct acpi_device *device) { struct acpi_video_bus *video; + bool auto_detect; int error; acpi_status status; @@ -2045,10 +2046,20 @@ static int acpi_video_bus_add(struct acpi_device *device) mutex_unlock(&video_list_lock); /* - * The userspace visible backlight_device gets registered separately - * from acpi_video_register_backlight(). + * If backlight-type auto-detection is used then a native backlight may + * show up later and this may change the result from video to native. + * Therefor normally the userspace visible /sys/class/backlight device + * gets registered separately by the GPU driver calling + * acpi_video_register_backlight() when an internal panel is detected. + * Register the backlight now when not using auto-detection, so that + * when the kernel cmdline or DMI-quirks are used the backlight will + * get registered even if acpi_video_register_backlight() is not called. */ acpi_video_run_bcl_for_osi(video); + if (__acpi_video_get_backlight_type(false, &auto_detect) == acpi_backlight_video && + !auto_detect) + acpi_video_bus_register_backlight(video); + acpi_video_bus_add_notify_handler(video); return 0; From patchwork Mon Apr 3 16:03:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 670085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0688C761A6 for ; Mon, 3 Apr 2023 16:04:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233143AbjDCQEw (ORCPT ); Mon, 3 Apr 2023 12:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbjDCQEn (ORCPT ); Mon, 3 Apr 2023 12:04:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCE5212F for ; Mon, 3 Apr 2023 09:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/pk84Fr/RFxb7TE42E27TH2BnZCwPX5iqADsugRvnw=; b=HS+2S6WXixXVybcemaqK9MCBaMpYHdlg0IEU7xXyw4R8GvGMfEcQPOhBfBzo6V5iZwS0gF wdHodXyvE+tLOPt8DaJxOuLbpfP/x5ztAtdmGKVKB0gJQDSN089OzJotTtx2tTG19Lp8Ro ct1hjPrEawBbUr9bSLcHS3iCbbGOEPE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-tYVI3L_9PwSXGEXQkFAfVA-1; Mon, 03 Apr 2023 12:03:42 -0400 X-MC-Unique: tYVI3L_9PwSXGEXQkFAfVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 385288030D1; Mon, 3 Apr 2023 16:03:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41B152166B26; Mon, 3 Apr 2023 16:03:41 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/6] ACPI: video: Add acpi_backlight=video quirk for Apple iMac14,1 and iMac14,2 Date: Mon, 3 Apr 2023 18:03:26 +0200 Message-Id: <20230403160329.707176-4-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On the Apple iMac14,1 and iMac14,2 all-in-ones (monitors with builtin "PC") the connection between the GPU and the panel is seen by the GPU driver as regular DP instead of eDP, causing the GPU driver to never call acpi_video_register_backlight(). (GPU drivers only call acpi_video_register_backlight() when an internal panel is detected, to avoid non working acpi_video# devices getting registered on desktops which unfortunately is a real issue.) Fix the missing acpi_video# backlight device on these all-in-ones by adding a acpi_backlight=video DMI quirk, so that video.ko will immediately register the backlight device instead of waiting for an acpi_video_register_backlight() call. Fixes: 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/acpi/video_detect.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index f7c218dd8742..295744fe7c92 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -276,6 +276,29 @@ static const struct dmi_system_id video_detect_dmi_table[] = { }, }, + /* + * Models which need acpi_video backlight control where the GPU drivers + * do not call acpi_video_register_backlight() because no internal panel + * is detected. Typically these are all-in-ones (monitors with builtin + * PC) where the panel connection shows up as regular DP instead of eDP. + */ + { + .callback = video_detect_force_video, + /* Apple iMac14,1 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,1"), + }, + }, + { + .callback = video_detect_force_video, + /* Apple iMac14,2 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,2"), + }, + }, + /* * These models have a working acpi_video backlight control, and using * native backlight causes a regression where backlight does not work From patchwork Mon Apr 3 16:03:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 670083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD97EC761A6 for ; Mon, 3 Apr 2023 16:04:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229498AbjDCQEz (ORCPT ); Mon, 3 Apr 2023 12:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233155AbjDCQEl (ORCPT ); Mon, 3 Apr 2023 12:04:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DDB2D44 for ; Mon, 3 Apr 2023 09:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qz47ygUTtJFsbQSSqll5q7aL5tEKMt97oq3yTwrvfdU=; b=YTphF4iRFyj3UWiAJ0QxTpIkBVYTdAUWk5GKEdcGHZnHlKJvWd2vPeGghjgcUp5o81yGEP kUlcwl7ikZN9ESRIxoZjfi153J4QPMKYAqjYG0n4F36XFjDinGSku85q5EMqAhryPN48tF 6urjq3Ib0PlxOi/B1p5TL/Q4F75bLfs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-UlKovdj-NbaUXgmqCwIgog-1; Mon, 03 Apr 2023 12:03:43 -0400 X-MC-Unique: UlKovdj-NbaUXgmqCwIgog-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C67E101A531; Mon, 3 Apr 2023 16:03:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68D2A2166B26; Mon, 3 Apr 2023 16:03:42 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 4/6] ACPI: video: Add acpi_backlight=video quirk for Lenovo ThinkPad W530 Date: Mon, 3 Apr 2023 18:03:27 +0200 Message-Id: <20230403160329.707176-5-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The Lenovo ThinkPad W530 uses a nvidia k1000m GPU. When this gets used together with one of the older nvidia binary driver series (the latest series does not support it), then backlight control does not work. This is caused by commit 3dbc80a3e4c5 ("ACPI: video: Make backlight class device registration a separate step (v2)") combined with commit 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default"). After these changes the acpi_video# backlight device is only registered when requested by a GPU driver calling acpi_video_register_backlight() which the nvidia binary driver does not do. I realize that using the nvidia binary driver is not a supported use-case and users can workaround this by adding acpi_backlight=video on the kernel commandline, but the ThinkPad W530 is a popular model under Linux users, so it seems worthwhile to add a quirk for this. I will also email Nvidia asking them to make the driver call acpi_video_register_backlight() when an internal LCD panel is detected. So maybe the next maintenance release of the drivers will fix this... Fixes: 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/acpi/video_detect.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 295744fe7c92..e85729fc481f 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -299,6 +299,20 @@ static const struct dmi_system_id video_detect_dmi_table[] = { }, }, + /* + * Older models with nvidia GPU which need acpi_video backlight + * control and where the old nvidia binary driver series does not + * call acpi_video_register_backlight(). + */ + { + .callback = video_detect_force_video, + /* ThinkPad W530 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"), + }, + }, + /* * These models have a working acpi_video backlight control, and using * native backlight causes a regression where backlight does not work From patchwork Mon Apr 3 16:03:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 669819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB93CC77B70 for ; Mon, 3 Apr 2023 16:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232650AbjDCQEy (ORCPT ); Mon, 3 Apr 2023 12:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233156AbjDCQEl (ORCPT ); Mon, 3 Apr 2023 12:04:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783B62103 for ; Mon, 3 Apr 2023 09:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WwKNpHdk6yYFfjh5jC43+CS29ijftEYs1VExDljmGBc=; b=ADlBm8TrAQ9EVcHY0v9zYLMj/DnM62F8fkOZrb7IncF7tfFztgjOX31wqCoqyPSAmQZXxk 2HjKtquXK0y0QCo81a/0qZ7z2CkKSe9AS0pLPPlmP92niDLb+QmJjusIXVh4mNNovlitu8 EnhnR7L8+5yDE4oglMdbWcxD06WxFUk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-p9nM_DhdPV6fqruUum4p9A-1; Mon, 03 Apr 2023 12:03:45 -0400 X-MC-Unique: p9nM_DhdPV6fqruUum4p9A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 998C9811E7C; Mon, 3 Apr 2023 16:03:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90A952166B29; Mon, 3 Apr 2023 16:03:43 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH 5/6] ACPI: video: Remove register_backlight_delay module option and code Date: Mon, 3 Apr 2023 18:03:28 +0200 Message-Id: <20230403160329.707176-6-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Since commit 5aa9d943e9b6 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default"), the delayed registerering of acpi_video# backlight devices has been disabled by default. The few bugreports where this option was used as a workaround were all cases where the GPU driver did not call acpi_video_register_backlight() and the workaround was to pass video.register_backlight_delay=1. With the recent "ACPI: video: Make acpi_backlight=video work independent from GPU driver" changes acpi_backlight=video can be used to achieve the same result. So there is no need for the register_backlight_delay option + code anymore. Signed-off-by: Hans de Goede --- drivers/acpi/acpi_video.c | 38 ------------------- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 -- include/acpi/video.h | 2 - 3 files changed, 44 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index c7a6d0b69dab..62f4364e4460 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -70,12 +70,6 @@ module_param(device_id_scheme, bool, 0444); static int only_lcd = -1; module_param(only_lcd, int, 0444); -static int register_backlight_delay; -module_param(register_backlight_delay, int, 0444); -MODULE_PARM_DESC(register_backlight_delay, - "Delay in seconds before doing fallback (non GPU driver triggered) " - "backlight registration, set to 0 to disable."); - static bool may_report_brightness_keys; static int register_count; static DEFINE_MUTEX(register_count_mutex); @@ -84,9 +78,6 @@ static LIST_HEAD(video_bus_head); static int acpi_video_bus_add(struct acpi_device *device); static void acpi_video_bus_remove(struct acpi_device *device); static void acpi_video_bus_notify(struct acpi_device *device, u32 event); -static void acpi_video_bus_register_backlight_work(struct work_struct *ignored); -static DECLARE_DELAYED_WORK(video_bus_register_backlight_work, - acpi_video_bus_register_backlight_work); /* * Indices in the _BCL method response: the first two items are special, @@ -2096,11 +2087,6 @@ static void acpi_video_bus_remove(struct acpi_device *device) kfree(video); } -static void acpi_video_bus_register_backlight_work(struct work_struct *ignored) -{ - acpi_video_register_backlight(); -} - static int __init is_i740(struct pci_dev *dev) { if (dev->device == 0x00D1) @@ -2183,17 +2169,6 @@ static bool should_check_lcd_flag(void) return false; } -/* - * At least one graphics driver has reported that no LCD is connected - * via the native interface. cancel the registration for fallback acpi_video0. - * If another driver still deems this necessary, it can explicitly register it. - */ -void acpi_video_report_nolcd(void) -{ - cancel_delayed_work(&video_bus_register_backlight_work); -} -EXPORT_SYMBOL(acpi_video_report_nolcd); - int acpi_video_register(void) { int ret = 0; @@ -2222,18 +2197,6 @@ int acpi_video_register(void) */ register_count = 1; - /* - * acpi_video_bus_add() skips registering the userspace visible - * backlight_device. The intend is for this to be registered by the - * drm/kms driver calling acpi_video_register_backlight() *after* it is - * done setting up its own native backlight device. The delayed work - * ensures that acpi_video_register_backlight() always gets called - * eventually, in case there is no drm/kms driver or it is disabled. - */ - if (register_backlight_delay) - schedule_delayed_work(&video_bus_register_backlight_work, - register_backlight_delay * HZ); - leave: mutex_unlock(®ister_count_mutex); return ret; @@ -2244,7 +2207,6 @@ void acpi_video_unregister(void) { mutex_lock(®ister_count_mutex); if (register_count) { - cancel_delayed_work_sync(&video_bus_register_backlight_work); acpi_bus_unregister_driver(&acpi_video_bus); register_count = 0; may_report_brightness_keys = false; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 7c96faa73426..d832f9ac43d4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4436,10 +4436,6 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) amdgpu_set_panel_orientation(&aconnector->base); } - /* If we didn't find a panel, notify the acpi video detection */ - if (dm->adev->flags & AMD_IS_APU && dm->num_of_edps == 0) - acpi_video_report_nolcd(); - /* Software is initialized. Now we can register interrupt handlers. */ switch (adev->asic_type) { #if defined(CONFIG_DRM_AMD_DC_SI) diff --git a/include/acpi/video.h b/include/acpi/video.h index ff5a8da5d883..4230392b5b0b 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -53,7 +53,6 @@ enum acpi_backlight_type { }; #if IS_ENABLED(CONFIG_ACPI_VIDEO) -extern void acpi_video_report_nolcd(void); extern int acpi_video_register(void); extern void acpi_video_unregister(void); extern void acpi_video_register_backlight(void); @@ -81,7 +80,6 @@ static inline bool acpi_video_backlight_use_native(void) return __acpi_video_get_backlight_type(true, NULL) == acpi_backlight_native; } #else -static inline void acpi_video_report_nolcd(void) { return; }; static inline int acpi_video_register(void) { return -ENODEV; } static inline void acpi_video_unregister(void) { return; } static inline void acpi_video_register_backlight(void) { return; } From patchwork Mon Apr 3 16:03:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 670084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 706A2C77B6E for ; Mon, 3 Apr 2023 16:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233158AbjDCQEy (ORCPT ); Mon, 3 Apr 2023 12:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbjDCQEs (ORCPT ); Mon, 3 Apr 2023 12:04:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E729268E for ; Mon, 3 Apr 2023 09:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680537831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8+jnkE8wO/e6osNTrn9Sp9wxcXrWZyhEgmpwfrnqth8=; b=E3XjVUKQ9ISB73NXo+gJBxQ8aNEaGb0Ww71yeDR3U/a0J0JUpxqvGWvGa+LS0x5g9CLOxR R7Dgg0W/YWl5xKFGNp41WOCMYUwlAuQlFAygMyfq/G45fnV6eIFNmwI2z49ydgviQdoR5M lbuCxwFiwsL7tlrEBU5JT2cGGIeNb7E= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-38Qjn3I6M7ejK3NT-rb4Vg-1; Mon, 03 Apr 2023 12:03:46 -0400 X-MC-Unique: 38Qjn3I6M7ejK3NT-rb4Vg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B634B3C17F6D; Mon, 3 Apr 2023 16:03:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id D25D22166B26; Mon, 3 Apr 2023 16:03:44 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" Cc: Hans de Goede , Mario Limonciello , Daniel Dadap , Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH 6/6] ACPI: video: Remove desktops without backlight DMI quirks Date: Mon, 3 Apr 2023 18:03:29 +0200 Message-Id: <20230403160329.707176-7-hdegoede@redhat.com> In-Reply-To: <20230403160329.707176-1-hdegoede@redhat.com> References: <20230403160329.707176-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org After the recent backlight changes acpi_video# backlight devices are only registered when explicitly requested from the cmdline, by DMI quirk or by the GPU driver. This means that we no longer get false-positive backlight control support advertised on desktop boards. Remove the 3 DMI quirks for desktop boards where the false-positive issue was fixed through quirks before. Note many more desktop boards were affected but we never build a full quirk list for this. Signed-off-by: Hans de Goede --- drivers/acpi/video_detect.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index e85729fc481f..07fa1bc843f2 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -768,35 +768,6 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 15 3535"), }, }, - - /* - * Desktops which falsely report a backlight and which our heuristics - * for this do not catch. - */ - { - .callback = video_detect_force_none, - /* Dell OptiPlex 9020M */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), - }, - }, - { - .callback = video_detect_force_none, - /* GIGABYTE GB-BXBT-2807 */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), - DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"), - }, - }, - { - .callback = video_detect_force_none, - /* MSI MS-7721 */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "MSI"), - DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"), - }, - }, { }, };