Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp801379lqt; Fri, 19 Apr 2024 10:45:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVjruxVL4/D/ghpd1bcBjOQ0rlbDUlYRz0DtWHqG+7lwvD0FEfGl5jLMFqJ3FFConVpaY/w6YARJouYYq4rPLzfLnnD6tIYvcaDw/njw== X-Google-Smtp-Source: AGHT+IHXuP7WKA2+9dC0cAhBaSl4LM8S5XtU/n9Q7Lx47loIaaHo0ZJkU/n/f+KdRaaIXyI3oBKW X-Received: by 2002:a17:90a:ac0d:b0:2aa:90f3:a4b8 with SMTP id o13-20020a17090aac0d00b002aa90f3a4b8mr3768962pjq.24.1713548756574; Fri, 19 Apr 2024 10:45:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713548756; cv=pass; d=google.com; s=arc-20160816; b=OGulqzmpPRjNE/hjDuO4MKLM7wWFyphTXCRhwlRL/+qr2jh9SKHuXnovh8suyKEiux 8mpf3aETVOZykgQZfy9Rj72hbNl0OtqUrGfqUdwX4aPGFpxXD2a2RHAg4exomVuPSuPq ewcZ7inBIgk29aIf51p9WksM9kbaagMZLdinEm8qB6JITtOAboqiOw6R1FIy+j6vxmP5 6OluCO6XuIdwfYagbK85zOYfzTpHB8Z54U42SLDdcv/127FUje7WKgfnfE1kwXPle+1e PfHv73Qhi1UrQKSPeXr1Fd+Pf/BLvuV2whLA5NPNFBAZh36SxwZRXnzcZy/GXImO+Fh2 uT8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=zVcF4tkhiJ1R4pD5M5QXfTeW4YDPYDWBSaaJ4kcEO2U=; fh=2lsK6tbH0IscUsnITJh5ZaGh4cIWGnVOMf9hmY2DGE0=; b=aJm+p3N9M8Y3CIycei6jIrHqdqq+G2AeaItM3dlXX7m6+xwcC0NgRxYUNemS00V+7j n4pteMFiFZy3/bDpya6fWQcOIS/gYJDVLvTSh6vcWC99UtnwNzaUbgb35O4HHROU9v+0 Z+XJq3En0NgdczT4Wws/9viafkFMbo/aZLwCWNQxmqx/ID/0YfYebFV4H+wGS62ETMAe i8i+9kORXXgBlAsD/rnO2YXcB5fUrqBbycRjmZgBZTJbVDwsrSo+kySQUIM2Pbmx8tRV swCUwXe8fO9HQjMqx2LY2VoxqV5HG/QzMgRU6dSzFT/N1mIgcVu5LF16FejzHuKScboI tXCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aCRdVpda; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-151831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q3-20020a17090a2e0300b002a2bab50de7si5331588pjd.121.2024.04.19.10.45.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:45:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aCRdVpda; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-151831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3765228187E for ; Fri, 19 Apr 2024 17:45:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F16A013AD30; Fri, 19 Apr 2024 17:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="aCRdVpda" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9215D13A86B for ; Fri, 19 Apr 2024 17:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713548750; cv=none; b=mEd2xWRbrKPngO47vgkXncL67g1T1etfWESbxFmn7WEir5uvfFC3Z2biXp1i/WMJymO0twnqy9qPtqWc56iYeqUdXtavXBmo86O2DR3sDo2Eo9Wi5cR6xBxCctT0P6OboulCCesF3OXS4u3waVFxDfhbjOvbmB4UcjhqtUQALjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713548750; c=relaxed/simple; bh=tg8CNjSpWN2BcBDo2ESp9bjBzlZSzMIk0QNMl4nZYbA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=boS9sBNvMx6cQeEMirIiwpZyUFS0+goeyVPCS1EvKweulKC5s73Lp9HSG1a2cr8Q7Zg+lwyS8iS8AVr41QIadlTVGCNDpS15w5tIhvI53zPgJ96PzXaLrU94Em9U4bLbKjmOeyNd6JmiFEOpIVq+BoZVz0s/WbCocxRwYCbVuQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=aCRdVpda; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713548746; bh=tg8CNjSpWN2BcBDo2ESp9bjBzlZSzMIk0QNMl4nZYbA=; h=From:To:Cc:Subject:Date:From; b=aCRdVpdahXIbXIWgMggkkeyMfyj00RFePkKCUXa9vvmPOryTab8WeJK1xioUerVe3 3j9qCE22dAYsDJfJO8IarsnMX9631nkI/BkTBHo7Me9zzVE4WjxJX3AiAP3pJm49A3 YyTsRgMbvJzIbR76votXMr/ObHPp0UHTz16W1xGXS1QPXXz8BH/8JMRsGQ6pSpO5+g S+Bl8WxsE1pcL1869tsyNzY3JN97U3G23JLPyJd5zJ5Yh57tvkvv6PZCe+FLkRyYUt aBV6PSfWhGetcgqmwBh5gVx+IGooPEDOWMzvdfaxrJ45jAZFnl5EJE80zwNqeOOxZJ rWkisKZhhNqiA== Received: from hermes-devbox.lan (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madrid.collaboradmins.com (Postfix) with ESMTPSA id D62E83782154; Fri, 19 Apr 2024 17:45:45 +0000 (UTC) From: Bob Beckett To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: kernel@collabora.com, Robert Beckett , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm: fix drm lastclose ignoring closed active fbs Date: Fri, 19 Apr 2024 18:45:30 +0100 Message-ID: <20240419174531.1696581-1-bob.beckett@collabora.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Robert Beckett when fb's have been marked as closed, if there is still something active then don't restore fbdev during lastclose Signed-off-by: Robert Beckett --- drivers/gpu/drm/drm_fb_helper.c | 3 +++ drivers/gpu/drm/drm_plane.c | 21 +++++++++++++++++++++ include/drm/drm_plane.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d612133e2cf7e..b7509b0cd926a 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -2002,6 +2002,9 @@ EXPORT_SYMBOL(drm_fb_helper_hotplug_event); */ void drm_fb_helper_lastclose(struct drm_device *dev) { + if (drm_has_active_plane(dev)) + return; + drm_fb_helper_restore_fbdev_mode_unlocked(dev->fb_helper); } EXPORT_SYMBOL(drm_fb_helper_lastclose); diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 672c655c7a8e7..7eb3d06696ca7 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -930,6 +930,27 @@ static int __setplane_check(struct drm_plane *plane, return 0; } +/** + * drm_has_active_plane - check whether any planes are currently active + * @dev: the DRM device + * + * Return true if any planes are currently active + */ +bool drm_has_active_plane(struct drm_device *dev) +{ + struct drm_plane *plane; + + drm_for_each_plane(plane, dev) { + if (plane->state && plane->state->crtc && plane->state->fb) + return true; + if (plane->crtc && plane->fb) + return true; + } + + return false; +} +EXPORT_SYMBOL(drm_has_active_plane); + /** * drm_any_plane_has_format - Check whether any plane supports this format and modifier combination * @dev: DRM device diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 641fe298052dc..74fec8cbee8c6 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -965,6 +965,8 @@ static inline struct drm_plane *drm_plane_find(struct drm_device *dev, #define drm_for_each_plane(plane, dev) \ list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) +bool drm_has_active_plane(struct drm_device *dev); + bool drm_any_plane_has_format(struct drm_device *dev, u32 format, u64 modifier); -- 2.44.0