From patchwork Tue Jan 10 01:18: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: 41242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2481482wrt; Mon, 9 Jan 2023 17:22:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbOY4slrzcz7ia0rLz3wU5C+QbmgQYbHC8XKGRQHDM2f+jUMVVGjWbpl1+etlXYnSz8mRf X-Received: by 2002:a17:906:9141:b0:7b2:757a:1411 with SMTP id y1-20020a170906914100b007b2757a1411mr64847908ejw.9.1673313730870; Mon, 09 Jan 2023 17:22:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673313730; cv=none; d=google.com; s=arc-20160816; b=b/uEodWfEPzXzCLCoMWAZc6aTu1R7GWQc+MD56aeBfRv86bSh47dInyG0CF7s9PxVm SMd9v5c9sPr2Mt+8ZA0KobxrVSPSrBvu7FP8JjBOetu7dENzTSQx1P+KRl+h6NB2AP3O KUraGstuBVZ2hz25ex9WCR6zUfis84vTwl9LS8dwFcdH3AAv0M4RfFBPj72doLYdt+4/ OZJ0nLahe8vkySFsBPosWT+H2yf3qdZGM7qrMpOweaa2HK3gz7twUGp8wNpKOjjyh2C0 8HdSmZZWSnIUSSn/6QUlwtSq/rQy94COc3X+JAU0WovP6Jq8Rp5/8d6rvOdx7uWdtFON 7puQ== 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=XYUtIGSdiXv+1u4fwXxMmXFQoGZCC8A3hPLYtYLpNZQ=; b=hO8pz9hTIEfeEXyw1I9+E24VJeJwntKvicfh3V7JizEAs/2wuV9BKViCsUfIGkpNd2 Ql10u+8TUdw1YCauf58QIhcQq0sy5ZYe1fsOxAQU74AMNtCCC48T3Zd+gqCy3dqmFBWf bQmvNw2z0o+8uqy/nevakxivqJn3JkbWolad4jYA30nfyI2sFHOGGpXymwwZrJdaZ+u0 cdv16o6tYt7ZJ122xd5lPOEkrPcTYkbp1WP6APvCM7UPb/D6nGSZL1l3qGf/XSaICLD2 OKTzozEc4Fcykvle6Sy4BOdXxdA//KJMIBo9lYW9oi93apN1ClWlpQR48ZrxsY2qWKpH RLrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Bmk2SAk4; 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 ce11-20020a170906b24b00b007882936242fsi7919444ejb.769.2023.01.09.17.21.46; Mon, 09 Jan 2023 17:22:10 -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=Bmk2SAk4; 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 S229463AbjAJBTX (ORCPT + 99 others); Mon, 9 Jan 2023 20:19:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbjAJBTQ (ORCPT ); Mon, 9 Jan 2023 20:19:16 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D392962EE for ; Mon, 9 Jan 2023 17:19:15 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id bj3so7450473pjb.0 for ; Mon, 09 Jan 2023 17:19:15 -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=XYUtIGSdiXv+1u4fwXxMmXFQoGZCC8A3hPLYtYLpNZQ=; b=Bmk2SAk4VLW306BHVtiboysQjz5H/DFJf0Tjh0hvrntMIxLtck9ATcuiUFhmj7LHNL B2lYETyD1f5zrcSLwCFTSAlf7/2XYNt9xuJqUxURQT7gjmsPAV0cEbg1BsWx9KUl86lc IzdBVOADWqnelw8o3fWnEGPECU4Vf3WBPVXls= 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=XYUtIGSdiXv+1u4fwXxMmXFQoGZCC8A3hPLYtYLpNZQ=; b=pFqd454EQbz0OD5ua/1+I9/iPDgS38oGLzAemykklNQm6D6mpuDZVO753DS0VXPGqB EwabiINns0i6OYPFFccRa0l5Tvl5taKtm7fy9r/HjtyBQUReW/+Vqin+n1H1cr9VwpRS IYV7JhGiNOmITdTqg5teZ7neyir1af1XTdKtpr/k9GJTx2Xj4zMFUOniVRK+htSd/tHO xU6YxD3iVUZvU/SLvrXtpQxOwtyNBuBPBg45l/b+EIvfsS8FPE2zkNhZvZVMrWjY/fvk 8p6q3BbbdGBFUcZw92qb4jjy8+tkLjLr8t5LDG8m+0Kswa45gHcv3wgND1p7W+5HHpyk 1unA== X-Gm-Message-State: AFqh2kr0hwhDXHOrs3epW3715Gb9Pfhp6Q0UjXy3BjvHcmhFOqYcoiF2 fNvJSmGhu1Hw2wl9GPczzifbqw== X-Received: by 2002:a05:6a21:999d:b0:9e:9685:f15e with SMTP id ve29-20020a056a21999d00b0009e9685f15emr100766242pzb.0.1673313555362; Mon, 09 Jan 2023 17:19:15 -0800 (PST) Received: from localhost ([2620:15c:9d:2:99d8:feca:9efd:a216]) by smtp.gmail.com with UTF8SMTPSA id j1-20020a170902c3c100b0018853416bbcsm6827097plj.7.2023.01.09.17.19.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Jan 2023 17:19:14 -0800 (PST) From: Brian Norris To: =?utf-8?q?Heiko_St=C3=BCbner?= , Daniel Vetter , Sean Paul Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sandy Huang , =?utf-8?q?Michel_D=C3=A4nzer?= , Brian Norris , stable@vger.kernel.org, "kernelci.org bot" Subject: [PATCH v3 2/2] drm/rockchip: vop: Leave vblank enabled in self-refresh Date: Mon, 9 Jan 2023 17:18:17 -0800 Message-Id: <20230109171809.v3.2.Ic07cba4ab9a7bd3618a9e4258b8f92ea7d10ae5a@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230109171809.v3.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid> References: <20230109171809.v3.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=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?1754596618679210132?= X-GMAIL-MSGID: =?utf-8?q?1754596618679210132?= 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). This issue was exposed by IGT's kms_vblank tests, and reported by KernelCI. The bug has been around a while (longer than KernelCI noticed), but was only exposed once self-refresh was bugfixed more recently, and so KernelCI could properly test it. Some other notes in: https://lore.kernel.org/dri-devel/Y6OCg9BPnJvimQLT@google.com/ Re: renesas/master bisection: igt-kms-rockchip.kms_vblank.pipe-A-wait-forked on rk3399-gru-kevin == 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. v3: * no update v2: * skip unnecessary lock/unlock 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index fa1f4ee6d195..9fea03121247 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -717,13 +717,13 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, if (crtc->state->self_refresh_active) rockchip_drm_set_win_enabled(crtc, false); + if (crtc->state->self_refresh_active) + goto out; + mutex_lock(&vop->vop_lock); drm_crtc_vblank_off(crtc); - if (crtc->state->self_refresh_active) - goto out; - /* * Vop standby will take effect at end of current frame, * if dsp hold valid irq happen, it means standby complete. @@ -757,9 +757,9 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, vop_core_clks_disable(vop); pm_runtime_put(vop->dev); -out: mutex_unlock(&vop->vop_lock); +out: if (crtc->state->event && !crtc->state->active) { spin_lock_irq(&crtc->dev->event_lock); drm_crtc_send_vblank_event(crtc, crtc->state->event);