Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3691211pxb; Mon, 24 Jan 2022 15:29:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbR2k1UnGHGcveBEEtgkcJh07XMPwrxZSFq2wM/ucCrGHi7Iyy6gwg3/Nw9/dE2A5FhpA+ X-Received: by 2002:a17:90b:3ec4:: with SMTP id rm4mr662752pjb.120.1643066971961; Mon, 24 Jan 2022 15:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066971; cv=none; d=google.com; s=arc-20160816; b=ECIUhR2WUo+XtS6e/R5/60vTUiR2yrUBLxLlcZc45tQ1QlufzzA88WH5DwX0k26uMw Mn1BRjbZLB92QteG/et2LR4kf2ksoLVndbYq5P0dciApTDZr6dUMTUw91o5cGEJioe+C 5FjPhHVAAoJkOPcCc12xEtFiRB7EF+iLT3NnW8knyyOcsun0xmbsWjHlX3WjAC1G9bKg 56uK1kHE/lLnm0TqI551i95HQhrUS0mWpCtzl+JDqXJfiVHEvP3xn9ymsQMif8CMrpTL /zenAfu6Lr9zX00W8LdbnExiSP857COS9Ps3PYLPJ0JAIn2TJq08s8ANjrAGPnpkdLSC L+1g== 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=KUi2os/5RMgc2FgeKYVXC+N0fzw7Z5Bm8u8Yqd/BlOc=; b=E2JScq5NOyLJrDZW6/FKiu9fYcqzon2cNaUHLNWBs3uqbH2yv2hieMTK0vYnfrwDPu hAyKEi+bs2A4FTE0ekI9dkjBbTSKoLbtku/J7Zd9B0F2o8gwRVBTot2uRfrkG/wQObnw ChB70MY9xnnpHY5PLtBT+ev8hinbNe9jFADrbMLs1/WB8D3JxDlhTxwHK6xCCLZfAsa3 DskqKlYmPn6igZ8aHVyYzRWK9NeLClo4ox2PfN7WsBk0kYl0jElBp/V8nIdB4RJY09hm ydclaZ4sIMR6DUU21BZ1o9oj/zftVDnpahYauIuxsnsOYGHiZ4Fx7W+9YZg7Mp7GF28v XHxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mnl6gY1H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si14232023plz.170.2022.01.24.15.29.20; Mon, 24 Jan 2022 15:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mnl6gY1H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1849634AbiAXX0T (ORCPT + 99 others); Mon, 24 Jan 2022 18:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1835941AbiAXWhu (ORCPT ); Mon, 24 Jan 2022 17:37:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805E1C0E9BB2; Mon, 24 Jan 2022 13:00:00 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 22488611DA; Mon, 24 Jan 2022 21:00:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03C52C340E5; Mon, 24 Jan 2022 20:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057999; bh=bLax4OLcXZabgWm10AYP5WuGHuGUFlNoXdOHjo1yZi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mnl6gY1HB/WV1k7Hq198i1TEB5/TxIE3t8KMT4OIdWEUpb+TEJetk+gpjQ7P6upNK rCH7d8IcdI1yyoyp2oUb6Ix7eSf/ufk9hlJmtsdfUwr+TKIW/gDRUhsfwirOa/1Y23 5qXPNQMyzqY7XR1sx62/nbDSmeh/cM5ArYvKlRFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lyude Paul , Douglas Anderson , Sasha Levin Subject: [PATCH 5.16 0148/1039] drm/dp: Dont read back backlight mode in drm_edp_backlight_enable() Date: Mon, 24 Jan 2022 19:32:17 +0100 Message-Id: <20220124184130.141392342@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lyude Paul [ Upstream commit 646596485e1ed2182adf293dfd5aec4a96c46330 ] As it turns out, apparently some machines will actually leave additional backlight functionality like dynamic backlight control on before the OS loads. Currently we don't take care to disable unsupported features when writing back the backlight mode, which can lead to some rather strange looking behavior when adjusting the backlight. So, let's fix this by just not reading back the current backlight mode on initial enable. I don't think there should really be any downsides to this, and this will ensure we don't leave any unsupported functionality enabled. This should fix at least one (but not all) of the issues seen with DPCD backlight support on fi-bdw-samus v5: * Just avoid reading back DPCD register - Doug Anderson Signed-off-by: Lyude Paul Fixes: 867cf9cd73c3 ("drm/dp: Extract i915's eDP backlight code into DRM helpers") Reviewed-by: Douglas Anderson Link: https://patchwork.freedesktop.org/patch/msgid/20211105183342.130810-4-lyude@redhat.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_dp_helper.c | 40 ++++++++++----------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 4d0d1e8e51fa7..db7db839e42d1 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -3246,27 +3246,13 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli const u16 level) { int ret; - u8 dpcd_buf, new_dpcd_buf; + u8 dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD; - ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf); - if (ret != 1) { - drm_dbg_kms(aux->drm_dev, - "%s: Failed to read backlight mode: %d\n", aux->name, ret); - return ret < 0 ? ret : -EIO; - } - - new_dpcd_buf = dpcd_buf; - - if ((dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) != DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) { - new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK; - new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD; - - if (bl->pwmgen_bit_count) { - ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count); - if (ret != 1) - drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", - aux->name, ret); - } + if (bl->pwmgen_bit_count) { + ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count); + if (ret != 1) + drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", + aux->name, ret); } if (bl->pwm_freq_pre_divider) { @@ -3276,16 +3262,14 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli "%s: Failed to write aux backlight frequency: %d\n", aux->name, ret); else - new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE; + dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE; } - if (new_dpcd_buf != dpcd_buf) { - ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf); - if (ret != 1) { - drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n", - aux->name, ret); - return ret < 0 ? ret : -EIO; - } + ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf); + if (ret != 1) { + drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n", + aux->name, ret); + return ret < 0 ? ret : -EIO; } ret = drm_edp_backlight_set_level(aux, bl, level); -- 2.34.1