From patchwork Mon Mar 23 14:49:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11453295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1746E174A for ; Mon, 23 Mar 2020 14:52:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E9FB720753 for ; Mon, 23 Mar 2020 14:52:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="chccHnon" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9FB720753 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3981E6E266; Mon, 23 Mar 2020 14:51:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EE226E22A for ; Mon, 23 Mar 2020 14:51:00 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id w10so17459236wrm.4 for ; Mon, 23 Mar 2020 07:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xn0XXOeheSX/LDac3pG8Cvhtu2NIuIWTYQkrsycx4bU=; b=chccHnonJxHv0Lqj5UuYLXi9jULvSru1KpcqEIgsZp5fOgQdrYw7RK/RIs7zgdrkBM +GlJ+YM2kx+8vrwaxMKBK9WpKG7EzfpFRAh5QdcmatmUGI5xz7lDZ2TtcO3CsfGYv4mF utglDC+RV/vTLudztFe8aHw6FeorgH4MgYrW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xn0XXOeheSX/LDac3pG8Cvhtu2NIuIWTYQkrsycx4bU=; b=F+Ue4lkwHNWqzH5sAhLN8DxX5/GRGIEi0CPEGyc+0W34yE8CuFecpgT+QkebMHWSEN ngWFK2EZNKGySiozaPQAaYTOSCugeTN1DQN11T13u3ojSkHjYxGRWmtWMjbZ07zBAJXt +b5WDacZPG8cX31cC60zUUaDlAxWRaMThL3/p1R8bAbWY33Q0VyeYNN/P0RYUtKnLJrE ffxaD8sdOzvokVp+5Vc3f7T04BxuQ3FKddApoW1rzOvRA5BH2JT4noOxvuX3LLbaFyIm ykNIAMFRNwshMgDka6zUK3at3BxAsPEjUqAKQi/rC/0CcYME89bq1YBApDTHauDlD4NK u5Qg== X-Gm-Message-State: ANhLgQ3V8tnchvkcpDQk7hqkRU9ZtHKv6YFVIdB/nzB/54ccONDcgtnD my6intM0RcTpNcNoSIzsaCnS4n9+Vsq8qA== X-Google-Smtp-Source: ADFU+vvNTuyYcyc0RNLIAiJ3rxRyI0Htp7aw/++NvQEvoF0kIDBEN5aWcXdJguxBmK+NGG90+pWP+g== X-Received: by 2002:adf:dc92:: with SMTP id r18mr24388809wrj.76.1584975058647; Mon, 23 Mar 2020 07:50:58 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id s22sm20376522wmc.16.2020.03.23.07.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 07:50:57 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 44/51] drm/gm12u320: Use helpers for shutdown/suspend/resume Date: Mon, 23 Mar 2020 15:49:43 +0100 Message-Id: <20200323144950.3018436-45-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200323144950.3018436-1-daniel.vetter@ffwll.ch> References: <20200323144950.3018436-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 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: , Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development , Hans de Goede Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Also there's a race in the disconnect implemenation. First shut down, then unplug, leaves a window where userspace could sneak in and restart the entire machinery. With this we can also delete the very un-atomic global pipe_enabled tracking. Reviewed-by: Hans de Goede Signed-off-by: Daniel Vetter Cc: Hans de Goede Cc: "Noralf Trønnes" --- drivers/gpu/drm/tiny/gm12u320.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c index 9fb579fc3412..9627cbc3ec64 100644 --- a/drivers/gpu/drm/tiny/gm12u320.c +++ b/drivers/gpu/drm/tiny/gm12u320.c @@ -88,7 +88,6 @@ struct gm12u320_device { struct usb_device *udev; unsigned char *cmd_buf; unsigned char *data_buf[GM12U320_BLOCK_COUNT]; - bool pipe_enabled; struct { bool run; struct workqueue_struct *workq; @@ -589,7 +588,6 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe, gm12u320_fb_mark_dirty(plane_state->fb, &rect); gm12u320_start_fb_update(gm12u320); - gm12u320->pipe_enabled = true; } static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe) @@ -597,7 +595,6 @@ static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe) struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private; gm12u320_stop_fb_update(gm12u320); - gm12u320->pipe_enabled = false; } static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe, @@ -733,22 +730,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface, static void gm12u320_usb_disconnect(struct usb_interface *interface) { struct drm_device *dev = usb_get_intfdata(interface); - struct gm12u320_device *gm12u320 = dev->dev_private; - gm12u320_stop_fb_update(gm12u320); drm_dev_unplug(dev); + drm_atomic_helper_shutdown(dev); } static __maybe_unused int gm12u320_suspend(struct usb_interface *interface, pm_message_t message) { struct drm_device *dev = usb_get_intfdata(interface); - struct gm12u320_device *gm12u320 = dev->dev_private; - if (gm12u320->pipe_enabled) - gm12u320_stop_fb_update(gm12u320); - - return 0; + return drm_mode_config_helper_suspend(dev); } static __maybe_unused int gm12u320_resume(struct usb_interface *interface) @@ -757,10 +749,8 @@ static __maybe_unused int gm12u320_resume(struct usb_interface *interface) struct gm12u320_device *gm12u320 = dev->dev_private; gm12u320_set_ecomode(gm12u320); - if (gm12u320->pipe_enabled) - gm12u320_start_fb_update(gm12u320); - return 0; + return drm_mode_config_helper_resume(dev); } static const struct usb_device_id id_table[] = {