[PATCH v6 5/6] drm/log: Implement suspend/resume

Jocelyn Falempe posted 6 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v6 5/6] drm/log: Implement suspend/resume
Posted by Jocelyn Falempe 2 weeks, 4 days ago
Normally the console is already suspended when the graphic driver
suspend callback is called, but if the parameter no_console_suspend
is set, it might still be active.
So call console_stop()/console_start() in the suspend/resume
callbacks, to make sure it won't try to write to the framebuffer
while the graphic driver is suspended.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---

v6:
 * Use console_stop() and console_start() in the suspend/resume callback (Petr Mladek).

 drivers/gpu/drm/drm_log.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/drm_log.c b/drivers/gpu/drm/drm_log.c
index 635dff7b37ce5..e6900c6b96436 100644
--- a/drivers/gpu/drm/drm_log.c
+++ b/drivers/gpu/drm/drm_log.c
@@ -310,10 +310,30 @@ 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);
+
+	console_stop(&dlog->con);
+
+	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);
+
+	console_start(&dlog->con);
+
+	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)
-- 
2.47.0
Re: [PATCH v6 5/6] drm/log: Implement suspend/resume
Posted by Petr Mladek 2 weeks, 4 days ago
On Tue 2024-11-05 13:42:25, Jocelyn Falempe wrote:
> Normally the console is already suspended when the graphic driver
> suspend callback is called, but if the parameter no_console_suspend
> is set, it might still be active.
> So call console_stop()/console_start() in the suspend/resume
> callbacks, to make sure it won't try to write to the framebuffer
> while the graphic driver is suspended.
> 
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>

Just to make it clear that I agree with this approach
for this patchset:

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

PS: I am not going to review the rest of the patchset. I believe
    that John did a good job.

    I actually made a quick look at the 2nd patch and the integration
    with the nbcon API looked reasonable. But it was too quick look
    so that my ack would not be much valuable there.
Re: [PATCH v6 5/6] drm/log: Implement suspend/resume
Posted by John Ogness 2 weeks, 4 days ago
On 2024-11-05, Jocelyn Falempe <jfalempe@redhat.com> wrote:
> Normally the console is already suspended when the graphic driver
> suspend callback is called, but if the parameter no_console_suspend
> is set, it might still be active.
> So call console_stop()/console_start() in the suspend/resume
> callbacks, to make sure it won't try to write to the framebuffer
> while the graphic driver is suspended.
>
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>

Reviewed-by: John Ogness <john.ogness@linutronix.de>