From patchwork Wed Oct 23 12:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jocelyn Falempe X-Patchwork-Id: 13847003 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 A822ECDDE79 for ; Wed, 23 Oct 2024 12:12:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27E7210E7B2; Wed, 23 Oct 2024 12:12:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="dCzqNZII"; 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 5C77610E7B2 for ; Wed, 23 Oct 2024 12:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729685544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vLQ4EQ67+8gevIx/PP1n5uexwWyC+rShOaFtXswP62Q=; b=dCzqNZIILnFigylX1CecfcwYVa97h6OyoemDf/4pcH+j67qf7EUROryq3NzKBuqsVex9Ta oJNMNV/fBpMBJs8St1nLgjVH4HbbDMnxze3yR1EvU/CJh3+QVdFMheyB3x8CtY/TXWwTzf SL3Vj4UMGOQQk9NFrySKq01ZrGVPAWk= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-572-jZ4_tS8rNvWMvwHPJDBRbw-1; Wed, 23 Oct 2024 08:12:21 -0400 X-MC-Unique: jZ4_tS8rNvWMvwHPJDBRbw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E3791956089; Wed, 23 Oct 2024 12:12:19 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.193.145]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 90F343000198; Wed, 23 Oct 2024 12:12:15 +0000 (UTC) From: Jocelyn Falempe To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , John Ogness , Javier Martinez Canillas , "Guilherme G . Piccoli" , bluescreen_avenger@verizon.net, Caleb Connolly , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Jocelyn Falempe Subject: [PATCH v5 5/6] drm/log: Implement suspend/resume Date: Wed, 23 Oct 2024 14:00:13 +0200 Message-ID: <20241023121145.1321921-6-jfalempe@redhat.com> In-Reply-To: <20241023121145.1321921-1-jfalempe@redhat.com> References: <20241023121145.1321921-1-jfalempe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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" The console is already suspended in printk.c. Just make sure we don't write to the framebuffer while the graphic driver is suspended. It may lose a few messages between graphic suspend and console suspend. Signed-off-by: Jocelyn Falempe --- drivers/gpu/drm/drm_log.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/gpu/drm/drm_log.c b/drivers/gpu/drm/drm_log.c index 635dff7b37ce5..07d1513001468 100644 --- a/drivers/gpu/drm/drm_log.c +++ b/drivers/gpu/drm/drm_log.c @@ -50,6 +50,7 @@ struct drm_log { struct drm_client_dev client; struct console con; bool probed; + bool suspended; u32 n_scanout; struct drm_log_scanout *scanout; }; @@ -310,10 +311,32 @@ static int drm_log_client_hotplug(struct drm_client_dev *client) return 0; } +static int drm_log_client_suspend(struct drm_client_dev *client, bool _console_lock) +{ + struct drm_log *dlog = client_to_drm_log(client); + + mutex_lock(&dlog->lock); + dlog->suspended = true; + mutex_unlock(&dlog->lock); + return 0; +} + +static int drm_log_client_resume(struct drm_client_dev *client, bool _console_lock) +{ + struct drm_log *dlog = client_to_drm_log(client); + + mutex_lock(&dlog->lock); + dlog->suspended = false; + mutex_unlock(&dlog->lock); + return 0; +} + static const struct drm_client_funcs drm_log_client_funcs = { .owner = THIS_MODULE, .unregister = drm_log_client_unregister, .hotplug = drm_log_client_hotplug, + .suspend = drm_log_client_suspend, + .resume = drm_log_client_resume, }; static void drm_log_write_thread(struct console *con, struct nbcon_write_context *wctxt) @@ -321,6 +344,9 @@ static void drm_log_write_thread(struct console *con, struct nbcon_write_context struct drm_log *dlog = console_to_drm_log(con); int i; + if (dlog->suspended) + return; + if (!dlog->probed) drm_log_init_client(dlog);