From patchwork Fri Jan 6 01:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 39899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp585776wrt; Thu, 5 Jan 2023 17:44:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqTahQLCdWSviAA1sYFJOLRzlWoo026oCI8cIkgbhvPbeSTgpNm5bWt1RPVyc+CyYQOC5B X-Received: by 2002:a62:1d0e:0:b0:57f:ef11:acf8 with SMTP id d14-20020a621d0e000000b0057fef11acf8mr52809588pfd.2.1672969489683; Thu, 05 Jan 2023 17:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672969489; cv=none; d=google.com; s=arc-20160816; b=TjxWQ4/hNieR3EBN2xaktorm+TZH3qkw8B2SeHTrBfxGozPt8XxfexyPZiYai3TYau QGVoo5A66bUs/vqduptr71DN03WDjQzaiZR8sRWlF4rgUuxEgBTtMs+VuFbEoAaOErRE A0nPMTNQOjhnT9TN+IRWzO9ZModRm7Fm+E92YzJvG9PKEA/cIJqhtJIGD/tGVf9JTvVi Y323rWLquYfmAVmkUXpMD0uxOWxPASHOmwfPDxQerciOCZSrozYMQIhrY1LqRvVG0Q7M LEBDGlOXF7sED3yLHP+N3xKZBmDCx9PKh7J24Bl6Uo/McyA+gJzQCawnswiiYHraFJcg v2Ng== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Vd1mAgVVTT449fHfx2SSArigVZjhQAUUxQLxBkWmUZY=; b=B0MkNcd1LwSyBOaARIZ1SAXyCYI9PbO6ELEGqo9BFJ/gl8SNH6xfSpENBbwiP+KJTR HQ4KOt78lrJdZhGgupFZItSwl0DIWbcCg4bCHpK1QYrUMOy08VR+p1ATmTRfKbt8Lj8S DFkxMaoeoqoLIlb66eyRnptXOAxi+yWK/W6JGcznexY2BCywNY7lBmyQQBrHLKyUAQIJ ZU/9Epf2FV1z5UtbEt9MkQM9La2gJer4W5cU2WHkXPbK6+Chh4JQv5PWkph9y+xGN7ad ipyN39C99hINwWBJxQVIlL9N0+loEjF0vqWWYaOURxlsdXgTMEh0Z64zZuF8So3tgq3O W6xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DPHGui8Q; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s29-20020a056a00179d00b00565a581ecc0si9986389pfg.11.2023.01.05.17.44.37; Thu, 05 Jan 2023 17:44:49 -0800 (PST) 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=@chromium.org header.s=google header.b=DPHGui8Q; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbjAFBkc (ORCPT + 99 others); Thu, 5 Jan 2023 20:40:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbjAFBk2 (ORCPT ); Thu, 5 Jan 2023 20:40:28 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4CFB3227F for ; Thu, 5 Jan 2023 17:40:27 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id cl14so119010pjb.2 for ; Thu, 05 Jan 2023 17:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Vd1mAgVVTT449fHfx2SSArigVZjhQAUUxQLxBkWmUZY=; b=DPHGui8QRmvaHU3DjCknrlpCldx/5v2OWyAyXICYBob9XLXk8DRWNug04ad+L+D6QF yQtKJe2REavJ/0MCusreMlT5MSx/4G0eq24SxO0ufeBTun+1XdP7BTN6KqtS2fV34YPD cvqScEg2/NatNc3sAr34tTgsDmpFnKUJ2dcqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Vd1mAgVVTT449fHfx2SSArigVZjhQAUUxQLxBkWmUZY=; b=muC7MHnrlj62OtnGQSwg7xVlYjUyWfXH1WaCoVp6nB/hYC3UKdiwm6faK7es/Mr43u B+9FKVsMri9iaLftCDaRovYw7qJxeeAD34P8i1YCAd5GBhwpORBcaSGPtBJvp0b0giA/ waWnATcdoCvUTB0wW2h+wTAPf9hXT5NrDgfD6563olIGvNd3LVJMif8P/1QNGVOq0k1m rvxmyg/P44379q+SA/vduQmMN0N747FC+YkizRlp+0CAJp4yQHa9NFNYvMwKI0SI+Y7t i3FuPtLRfBdMYFiCeJLodAqMx9IbSN55f0n+U3mFuSza7T4+ExPEoHBLmvT9hYjfmhgi v3Jw== X-Gm-Message-State: AFqh2kpNOx0/0RURJqO/x8TmloRfNjaUToMLMHjxoTHPOuSIGzyNdFHf yMs4fl0eJHHmE4tGHUawVS3umQ== X-Received: by 2002:a05:6a20:429f:b0:ad:bd55:6dcf with SMTP id o31-20020a056a20429f00b000adbd556dcfmr79280084pzj.28.1672969227205; Thu, 05 Jan 2023 17:40:27 -0800 (PST) Received: from localhost ([2620:15c:9d:2:5567:fb20:aa4f:352]) by smtp.gmail.com with UTF8SMTPSA id i1-20020a6551c1000000b00478f87eaa44sm22461638pgq.35.2023.01.05.17.40.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Jan 2023 17:40:26 -0800 (PST) From: Brian Norris To: =?utf-8?q?Heiko_St=C3=BCbner?= , Sean Paul Cc: Sandy Huang , =?utf-8?q?Michel_D=C3=A4nzer?= , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org, Brian Norris , stable@vger.kernel.org Subject: [PATCH 1/2] drm/atomic: Allow vblank-enabled + self-refresh "disable" Date: Thu, 5 Jan 2023 17:40:17 -0800 Message-Id: <20230105174001.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754235655698650529?= X-GMAIL-MSGID: =?utf-8?q?1754235655698650529?= The self-refresh helper framework overloads "disable" to sometimes mean "go into self-refresh mode," and this mode activates automatically (e.g., after some period of unchanging display output). In such cases, the display pipe is still considered "on", and user-space is not aware that we went into self-refresh mode. Thus, users may expect that vblank-related features (such as DRM_IOCTL_WAIT_VBLANK) still work properly. However, we trigger the WARN_ONCE() here if a CRTC driver tries to leave vblank enabled here. Add a new exception, such that we allow CRTCs to be "disabled" (with self-refresh active) with vblank interrupts still enabled. Cc: # dependency for subsequent patch Signed-off-by: Brian Norris --- drivers/gpu/drm/drm_atomic_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index d579fd8f7cb8..7b5eddadebd5 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1207,6 +1207,12 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) if (!drm_dev_has_vblank(dev)) continue; + /* + * Self-refresh is not a true "disable"; let vblank remain + * enabled. + */ + if (new_crtc_state->self_refresh_active) + continue; ret = drm_crtc_vblank_get(crtc); WARN_ONCE(ret != -EINVAL, "driver forgot to call drm_crtc_vblank_off()\n"); From patchwork Fri Jan 6 01:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 39900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp585794wrt; Thu, 5 Jan 2023 17:44:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbqONrEC3Yl6rsGHbmkAxTHWOyLj6JacaBgeLuLdqHky7Z6Cjzh6aVh+2EVundp+bx99v5 X-Received: by 2002:a05:6a20:158b:b0:af:7b32:4deb with SMTP id h11-20020a056a20158b00b000af7b324debmr78841762pzj.4.1672969493300; Thu, 05 Jan 2023 17:44:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672969493; cv=none; d=google.com; s=arc-20160816; b=ulZWUtvqtIbr9ybmO567nWdaeKpmAq3FgKV8L8uRcsWWQ/pZENToNOpLmGJdxrX3m+ i1lImTlpYLLt82/6yHdKDUcDaHE8vl6BIIelJ5bvQT88ZBIS7UOS60Lfv5D5UfeER4HR n6yAk9HU7VMqjmA6kFeAFGbDDeZHRWNMccfPqCDga1fa5ID49yu1ijgL92NxyUvt9kDN aniFPgzlX5NnwjpVgENa/sfLwWCj9tf7BB1ZFSz/Y5V1Nit3RCYOiXzL3+p+ASONiTNG Px++RYPSqfWxqxHqFLL4rbeQYyBl8Zt3FffuttXjN4i+q0RXQK3TXDkgSZq9wvrcV3Rg jqkg== 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=c8gCbSML/p6Kr09DdbXaCD2bHHww6ZP3H/AZnf3Fw7g=; b=Ubs9yJTxUc4T1G8EOG2Ob3j7Y4kz/1AY9OfdLNDFSa2t7Sp8IbKf9GvKL22Z0TUA5w Glk4qjgw9Xv/T6Pne3lynhIfTk2NfLFHJHg23krx6FB0LNwL20wkNBW3mQBTC1np2t/n 6+iqUM2g4HKfP028achqJtbzd3J/5Ws+Z7pYAg+pokZghRZQ8rWixebF6FMQ1s8eXDam SMYP0XMmZFgIAinfKEe8h5mf7gDf6APx0eFVlwJIIlewT90hFnrOhwIyDMVbT5mV7bkr V4lLlAvOHrK8CO7lJ/vt6O/+8+X3DhdNq3yySabi35Q/TLA8lyTeoph2qXeznN3Z9ooc 3/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=glG7tzqp; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a654c4f000000b00477fbd59895si41759802pgr.852.2023.01.05.17.44.39; Thu, 05 Jan 2023 17:44:53 -0800 (PST) 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=@chromium.org header.s=google header.b=glG7tzqp; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbjAFBkh (ORCPT + 99 others); Thu, 5 Jan 2023 20:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbjAFBka (ORCPT ); Thu, 5 Jan 2023 20:40:30 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8C23224A for ; Thu, 5 Jan 2023 17:40:29 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id 18so94611pfx.7 for ; Thu, 05 Jan 2023 17:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c8gCbSML/p6Kr09DdbXaCD2bHHww6ZP3H/AZnf3Fw7g=; b=glG7tzqprNLpK21tSwouvhh29Ru3oQMMT++WF/8EdyAe9E16EXDVV2gQ7MgD/YLbfD 7i5ORFsmWI/15TfC6bE9Zh+BDD8BK7F3Cr25qWSmjIrnEIqHKvXKZPM93FIz7er9IXb9 P09kmLdjasAmuSD6VJ5W6wIZSgZ1vfi8G3Cak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c8gCbSML/p6Kr09DdbXaCD2bHHww6ZP3H/AZnf3Fw7g=; b=uY3AgYzRpeUUsgUzXpNLKG2woRw/0IAVbTBwzLnluSc6+E84RK0264MSTucU0AlTAK woZbzNJrUOTWGLK5nU46exT0TjC+daZBuRMlT0CMI7PCqAMy6bGSKnsOB6/w5xDWe0kE ejXXUFjSZ1eM5RwcbzV7o/fuOcE2Py1oE541MQXVb8KYf+6qTPKJ4Nsx3ec7Ytz4C5Lz +6O/yDlNSGKGkv2AA97+dL8AXFJpddC6I293q3CcNZyHeMZQaMQqlMfRErf7YKJiYsow snrlbUBrt0oS9Z3CRNI0GKXuvsXBEbNSK5iH2v3m7UFlUzFhx8dl2las24nTq6B95F5u UaZA== X-Gm-Message-State: AFqh2krvnYTU5RWzhQrXELTm9c4ltkjQok/FLW8GUCTRe8XYLgpSbcCt fYbUQ4BybexfljuK4cLK696sRg== X-Received: by 2002:a62:e510:0:b0:582:5b8d:52be with SMTP id n16-20020a62e510000000b005825b8d52bemr19080880pff.8.1672969229354; Thu, 05 Jan 2023 17:40:29 -0800 (PST) Received: from localhost ([2620:15c:9d:2:5567:fb20:aa4f:352]) by smtp.gmail.com with UTF8SMTPSA id 142-20020a621994000000b00575caf80d08sm17868008pfz.31.2023.01.05.17.40.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Jan 2023 17:40:28 -0800 (PST) From: Brian Norris To: =?utf-8?q?Heiko_St=C3=BCbner?= , Sean Paul Cc: Sandy Huang , =?utf-8?q?Michel_D=C3=A4nzer?= , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org, Brian Norris , stable@vger.kernel.org, "kernelci.org bot" Subject: [PATCH 2/2] drm/rockchip: vop: Leave vblank enabled in self-refresh Date: Thu, 5 Jan 2023 17:40:18 -0800 Message-Id: <20230105174001.2.Ic07cba4ab9a7bd3618a9e4258b8f92ea7d10ae5a@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105174001.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid> References: <20230105174001.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754235659108805290?= X-GMAIL-MSGID: =?utf-8?q?1754235659108805290?= If we disable vblank when entering self-refresh, vblank APIs (like DRM_IOCTL_WAIT_VBLANK) no longer work. But user space is not aware when we enter self-refresh, so this appears to be an API violation -- that DRM_IOCTL_WAIT_VBLANK fails with EINVAL whenever the display is idle and enters self-refresh. The downstream driver used by many of these systems never used to disable vblank for PSR, and in fact, even upstream, we didn't do that until radically redesigning the state machine in commit 6c836d965bad ("drm/rockchip: Use the helpers for PSR"). Thus, it seems like a reasonable API fix to simply restore that behavior, and leave vblank enabled. Note that this appears to potentially unbalance the drm_crtc_vblank_{off,on}() calls in some cases, but: (a) drm_crtc_vblank_on() documents this as OK and (b) if I do the naive balancing, I find state machine issues such that we're not in sync properly; so it's easier to take advantage of (a). Backporting notes: Marking as 'Fixes' commit 6c836d965bad ("drm/rockchip: Use the helpers for PSR"), but it probably depends on commit bed030a49f3e ("drm/rockchip: Don't fully disable vop on self refresh") as well. We also need the previous patch ("drm/atomic: Allow vblank-enabled + self-refresh "disable""), of course. Fixes: 6c836d965bad ("drm/rockchip: Use the helpers for PSR") Cc: Link: https://lore.kernel.org/dri-devel/Y5itf0+yNIQa6fU4@sirena.org.uk/ Reported-by: "kernelci.org bot" Signed-off-by: Brian Norris --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index fa1f4ee6d195..c541967114b4 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -719,11 +719,11 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, mutex_lock(&vop->vop_lock); - drm_crtc_vblank_off(crtc); - if (crtc->state->self_refresh_active) goto out; + drm_crtc_vblank_off(crtc); + /* * Vop standby will take effect at end of current frame, * if dsp hold valid irq happen, it means standby complete.