From nobody Tue Nov 26 01:40:38 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4F9E61AE01F for ; Wed, 23 Oct 2024 12:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729685546; cv=none; b=B0SO/Pcf0bCraHYaVfRIXx8GA3MwIpRnxKJuCn0tC1Cu5vsibZF5qbbqO0U//N526cgR8MgLNOnHiT57ljIf2oHqKu3e4UOCdZekeuXRUR2DO9tSkgwlXGMECSvwdtewwbnEzn3sbvwxsGPoxjQjLGoU/so3xqMjj7A/ZGSIFiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729685546; c=relaxed/simple; bh=LiSN6tooqIkaAAgNCmt29B1J+fv6j9/I+h0oGZp0w8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dt9v0IvIfzwly+XXykToZ1yvkQ5bzkslo4xP9X6arjtimIQxoTvbh7kDv1/khG6U1HmCTra3rzmS25+OdZxXX1BOz1GpfHCfgPVjxL2EkNeXjYrtKwT1o6qijjDT7PNXRcOqXWgxfedjepsX1e9z+Gw2+Tc2U4/Hy6ySw81sF6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dCzqNZII; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dCzqNZII" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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_d= ev *client) return 0; } =20 +static int drm_log_client_suspend(struct drm_client_dev *client, bool _con= sole_lock) +{ + struct drm_log *dlog =3D client_to_drm_log(client); + + mutex_lock(&dlog->lock); + dlog->suspended =3D true; + mutex_unlock(&dlog->lock); + return 0; +} + +static int drm_log_client_resume(struct drm_client_dev *client, bool _cons= ole_lock) +{ + struct drm_log *dlog =3D client_to_drm_log(client); + + mutex_lock(&dlog->lock); + dlog->suspended =3D false; + mutex_unlock(&dlog->lock); + return 0; +} + static const struct drm_client_funcs drm_log_client_funcs =3D { .owner =3D THIS_MODULE, .unregister =3D drm_log_client_unregister, .hotplug =3D drm_log_client_hotplug, + .suspend =3D drm_log_client_suspend, + .resume =3D drm_log_client_resume, }; =20 static void drm_log_write_thread(struct console *con, struct nbcon_write_c= ontext *wctxt) @@ -321,6 +344,9 @@ static void drm_log_write_thread(struct console *con, s= truct nbcon_write_context struct drm_log *dlog =3D console_to_drm_log(con); int i; =20 + if (dlog->suspended) + return; + if (!dlog->probed) drm_log_init_client(dlog); =20 --=20 2.47.0