Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp588130pxb; Tue, 15 Feb 2022 23:01:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJympRqW27VjDz7m1rFeDicjTrm3fpOlcABTP1Jt1zDltl41RcuJ/YYxQIEVC1suMRMO0zvm X-Received: by 2002:a17:90b:4a48:b0:1b9:11a8:1cb9 with SMTP id lb8-20020a17090b4a4800b001b911a81cb9mr199340pjb.7.1644994877224; Tue, 15 Feb 2022 23:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994877; cv=none; d=google.com; s=arc-20160816; b=sVoib8Ac/QBYmRjSRceptQpVPEGzMtE/LjazUkHEOmHHrUE0vn44pW5FqOm6hGsvO9 4b5odwQ3pgoOSPErn2we1uWgph3ZJ/u8YM8a5VDNtqcYDllqxGZVXxWNzKGVQEUFjC9E ajf7HCbtAUXLlhSEvxhoE8QRHZwJaRpELP5BcscOiF2lezKi1uk/FkLXi1qEvET8A0o3 p7xcrJPoFIVQWAVBVwZWtqssDVsdz6L5f+XBxmAdEMIMzbP0hdIwiqVdlttts0+y0VRZ TPRBszFonIKtqN6HUtB1dd8B3rNCPmocyZDafO2QC9ZWA4TC/GPO0Gk+g8NOy0x+fOHp IoZA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XCMuYxh+2di03JYmyV8dujrYzv3SXhYvMBvZiel5/fo=; b=BJXHJ2buvPgfPbLYX5jU4WTVmYI7+wmbWz4St7oSDXq+w1MveNsFad03JDm2XJZQLU Y1paroqdNGLDnWCU8gNJuH9/+JSKV7KqLHcAwxPGuKdRtUgt1IJfLKJB9N6lWx8GF+m7 eb12BpTpWAK8OigTlC3R3bRSgXqx9Ft8Jysxf+cIcS0Uhf4TV9kKQM0yvji1K3J3sfqK MoyVKqov9Dzrt7kN+QwWWEwbbRm8QLnAaDX8CS5xf/oiCIlzEJs3XWjnT89pm95CTKkp 936ZAk7hOu9eticKVHOtYj7qy6KQ8fHSlHxBUcI0lsM4puDG0NK3A5IBjS3kWszGx0x0 n85g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ccxhsBMF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e13si7205066plo.543.2022.02.15.23.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:01:17 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ccxhsBMF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 307C9DEE8; Tue, 15 Feb 2022 22:41:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244909AbiBOXzJ (ORCPT + 99 others); Tue, 15 Feb 2022 18:55:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244902AbiBOXzG (ORCPT ); Tue, 15 Feb 2022 18:55:06 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 235AEF65FE for ; Tue, 15 Feb 2022 15:54:56 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id v8-20020a17090a634800b001bb78857ccdso2550056pjs.1 for ; Tue, 15 Feb 2022 15:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XCMuYxh+2di03JYmyV8dujrYzv3SXhYvMBvZiel5/fo=; b=ccxhsBMFOCVfhgnoeerlnPe9CGG4uxGXLAYEhClhIyCP3tNpTcHx/x+JN4ucRCwQL2 WqY6MYRiz8wL1xuFwwtTVnDt4SsyShQuW1OnmDwEiIOaAiSnJKUYtZyf5HqPE0WTprMn +7Llc0763f37U4Tbbu48tie2OA6UAMwycMI/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XCMuYxh+2di03JYmyV8dujrYzv3SXhYvMBvZiel5/fo=; b=kS/dOkSMPXJvnYrtaU3kkYBxuuEyE7wPSyGHnt7IL/yITxwOkA4ISScWkJGLrYC/uu BYPfii2jFI9Cl1UtMqqIv2aSzoMgy/uKmb5Hd+e+ppDO0TX0Ov0kZjO3LkqNqt12lYIi 3RreBdYo1A2wjql4ZVpajRZkk83ISLHBPCp2wZjqrgJRJmyu3XKfsAv6swQ0LA9OPAdS 1gfKUSP8pZvzUsBaz46qTI3R1vs8avO3Cjwl7V+bdBIfqzGGz5E4NDjG0UEap8LVUGOJ AiEpmg5Ma1Tund1jg1VRIBpk8gxw2l0ArJVjg4LFy+V5pVUKHL0KJz8OgXpxtrJYXWpM 9Hyg== X-Gm-Message-State: AOAM533EipWg0yBetcO9o+sEijKHWnKZFeEd/FtpCHmci+mkFIxpnaYq +9dG7Ri/9NkGZRY9E9izOpbBLg== X-Received: by 2002:a17:90b:4a02:b0:1b8:d3c7:7a2b with SMTP id kk2-20020a17090b4a0200b001b8d3c77a2bmr7163388pjb.194.1644969295688; Tue, 15 Feb 2022 15:54:55 -0800 (PST) Received: from localhost ([2620:15c:202:201:97ca:4b5:7d22:b276]) by smtp.gmail.com with UTF8SMTPSA id a12sm38166601pfv.18.2022.02.15.15.54.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Feb 2022 15:54:55 -0800 (PST) From: Brian Norris To: Andrzej Hajda , Neil Armstrong , Robert Foss , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: Heiko Stuebner , Jernej Skrabec , dri-devel@lists.freedesktop.org, Laurent Pinchart , Jonas Karlman , Sean Paul , linux-kernel@vger.kernel.org, Sean Paul , Brian Norris , stable@vger.kernel.org Subject: [PATCH 2/2] drm/atomic: Force bridge self-refresh-exit on CRTC switch Date: Tue, 15 Feb 2022 15:54:20 -0800 Message-Id: <20220215155417.2.Ic15a2ef69c540aee8732703103e2cff51fb9c399@changeid> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220215235420.1284208-1-briannorris@chromium.org> References: <20220215235420.1284208-1-briannorris@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 It's possible to change which CRTC is in use for a given connector/encoder/bridge while we're in self-refresh without fully disabling the connector/encoder/bridge along the way. This can confuse the bridge encoder/bridge, because (a) it needs to track the SR state (trying to perform "active" operations while the panel is still in SR can be Bad(TM)); and (b) it tracks the SR state via the CRTC state (and after the switch, the previous SR state is lost). Thus, we need to either somehow carry the self-refresh state over to the new CRTC, or else force an encoder/bridge self-refresh transition during such a switch. I choose the latter, so we disable the encoder (and exit PSR) before attaching it to the new CRTC (where we can continue to assume a clean (non-self-refresh) state). This fixes PSR issues seen on Rockchip RK3399 systems with drivers/gpu/drm/bridge/analogix/analogix_dp_core.c. Cc: Fixes: 1452c25b0e60 ("drm: Add helpers to kick off self refresh mode in drivers") Signed-off-by: Brian Norris --- drivers/gpu/drm/drm_atomic_helper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 9603193d2fa1..74161d007894 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1011,9 +1011,19 @@ crtc_needs_disable(struct drm_crtc_state *old_state, return drm_atomic_crtc_effectively_active(old_state); /* - * We need to run through the crtc_funcs->disable() function if the CRTC - * is currently on, if it's transitioning to self refresh mode, or if - * it's in self refresh mode and needs to be fully disabled. + * We need to disable bridge(s) and CRTC if we're transitioning out of + * self-refresh and changing CRTCs at the same time, because the + * bridge tracks self-refresh status via CRTC state. + */ + if (old_state->self_refresh_active && new_state->enable && + old_state->crtc != new_state->crtc) + return true; + + /* + * We also need to run through the crtc_funcs->disable() function if + * the CRTC is currently on, if it's transitioning to self refresh + * mode, or if it's in self refresh mode and needs to be fully + * disabled. */ return old_state->active || (old_state->self_refresh_active && !new_state->active) || -- 2.35.1.265.g69c8d7142f-goog