From patchwork Mon Apr 22 15:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jocelyn Falempe X-Patchwork-Id: 13638656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DC40C4345F for ; Mon, 22 Apr 2024 15:58:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCBA110F6D9; Mon, 22 Apr 2024 15:58:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Xq463cGy"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0953A10FA8A for ; Mon, 22 Apr 2024 15:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713801503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aB/XmHoI8odWQ2eq7oYyGuDTuxgIQFLMrdmcUG/LDJY=; b=Xq463cGyRzrJo8MLI42wf8wcGDlekSd+o9IMN+Acizat9LOsZaFC9TQHed/ann84VBWeLW 9ww8kjDJcak+Oq7utq7rZTwNLtE7hRh3AmBCfhrLWn4SIl/DQLB6Cv7j4Pevuf0b4T3+G9 hd2tCmXxfnXz+P44Zcz1XUlxGO3iuEY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-9cnovqTmP16BgihRTKLeVw-1; Mon, 22 Apr 2024 11:58:17 -0400 X-MC-Unique: 9cnovqTmP16BgihRTKLeVw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFD1D3C0ED43; Mon, 22 Apr 2024 15:58:16 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.193.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4432492BC6; Mon, 22 Apr 2024 15:58:15 +0000 (UTC) From: Jocelyn Falempe To: dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Jocelyn Falempe Subject: [PATCH 1/2] drm/fb-helper: Add drm_fb_helper_emergency_disable Date: Mon, 22 Apr 2024 17:57:32 +0200 Message-ID: <20240422155811.83648-2-jfalempe@redhat.com> In-Reply-To: <20240422155811.83648-1-jfalempe@redhat.com> References: <20240422155811.83648-1-jfalempe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is needed for drm_panic, to disable fbcon output that will otherwise mix with drm_panic output. Signed-off-by: Jocelyn Falempe --- drivers/gpu/drm/drm_fb_helper.c | 17 +++++++++++++++++ include/drm/drm_fb_helper.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d612133e2cf7e..e2e681e252e73 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -798,6 +798,23 @@ void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, } EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked); +/** + * drm_fb_helper_emergency_disable - disable fb output in panic situation + * @fb_helper: driver-allocated fbdev helper, can be NULL + * + * A wrapper around fb_set_suspend, to disable fb emulation when a panic occurs. + */ +void drm_fb_helper_emergency_disable(struct drm_fb_helper *fb_helper) +{ + if (fb_helper && fb_helper->info && fb_helper->info->state == FBINFO_STATE_RUNNING) { + if (console_trylock()) { + fb_set_suspend(fb_helper->info, FBINFO_STATE_SUSPENDED); + console_unlock(); + } + } +} +EXPORT_SYMBOL(drm_fb_helper_emergency_disable); + static int setcmap_pseudo_palette(struct fb_cmap *cmap, struct fb_info *info) { u32 *palette = (u32 *)info->pseudo_palette; diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 375737fd6c36e..8c61c4fe93e3b 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -261,6 +261,7 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend); void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, bool suspend); +void drm_fb_helper_emergency_disable(struct drm_fb_helper *fb_helper); int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); @@ -378,6 +379,10 @@ drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, bool suspend { } +static inline void drm_fb_helper_emergency_disable(struct drm_fb_helper *fb_helper) +{ +} + static inline int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) { return 0; From patchwork Mon Apr 22 15:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jocelyn Falempe X-Patchwork-Id: 13638655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DED3CC4345F for ; Mon, 22 Apr 2024 15:58:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0178C10F6DE; Mon, 22 Apr 2024 15:58:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="agfmB3ew"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE65B10F6DE for ; Mon, 22 Apr 2024 15:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713801503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WeGa2QESaSAKwW885WTwjCXbB74N5sziUqCsVcD6+/Y=; b=agfmB3ewStnbS/UOxCzGfdvRzu5zbMhdigefWEXXMYshLOTbWOKYv06/L+HDT/CXySIkxU nXs8jl4gKRoqMZyYB335dCJZ1GKI8YqwvL25sh4guqYyomxatHpRficsDozrMVmxlZ3+8A yczIZTPu0FCCUUshCki+gXYIWXDFrso= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-GrFx7gGfORu5GwD_XaOnIQ-1; Mon, 22 Apr 2024 11:58:18 -0400 X-MC-Unique: GrFx7gGfORu5GwD_XaOnIQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D6EF81B561; Mon, 22 Apr 2024 15:58:18 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.193.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id 327C2492BC6; Mon, 22 Apr 2024 15:58:17 +0000 (UTC) From: Jocelyn Falempe To: dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Jocelyn Falempe Subject: [PATCH 2/2] drm/panic: Allows to run with fbcon Date: Mon, 22 Apr 2024 17:57:33 +0200 Message-ID: <20240422155811.83648-3-jfalempe@redhat.com> In-Reply-To: <20240422155811.83648-1-jfalempe@redhat.com> References: <20240422155811.83648-1-jfalempe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Disable the framebuffer emulation when a panic occurs, to avoid fbcon to overwrite the panic screen. So it's now safe to enable DRM_PANIC and FRAMEBUFFER_CONSOLE. Signed-off-by: Jocelyn Falempe --- drivers/gpu/drm/Kconfig | 2 +- drivers/gpu/drm/drm_panic.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 959b19a041018..7a8b1ef4c6bcf 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -106,7 +106,7 @@ config DRM_KMS_HELPER config DRM_PANIC bool "Display a user-friendly message when a kernel panic occurs" - depends on DRM && !FRAMEBUFFER_CONSOLE + depends on DRM select DRM_KMS_HELPER select FONT_SUPPORT help diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index 7ece67086cecb..c46a2b878e759 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -470,6 +471,9 @@ static void draw_panic_plane(struct drm_plane *plane) int ret; unsigned long flags; + /* Prevent fbcon from overwriting the panic screen */ + drm_fb_helper_emergency_disable(plane->dev->fb_helper); + if (!drm_panic_trylock(plane->dev, flags)) return;