From patchwork Mon Mar 2 22:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11416677 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 26A1D14B4 for ; Mon, 2 Mar 2020 22:28:40 +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 050CC2465D for ; Mon, 2 Mar 2020 22:28:40 +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="Y6T+CoVf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 050CC2465D 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 CEAC46E8DE; Mon, 2 Mar 2020 22:27:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA1536E8DE for ; Mon, 2 Mar 2020 22:27:36 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id r7so1903223wro.2 for ; Mon, 02 Mar 2020 14:27:36 -0800 (PST) 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=KWgXr/WkInjaQ8cVX1YfsEAGUgyxCqxAciePN/v2iAY=; b=Y6T+CoVfKDl5dtt9zPUYQb3hnYFhKXK5+XivPZ+0sFz/CIwOT+uHPSjrXGiqWaec9h MVyY9qoxK0Dc1hx3HLSVE49vwuS5w7Apx3URhaQwPSRmkKbesgjfdewkJ8/v4ruONyYB lZAHHLpJDHi3ZyORVI5T3Cv/1C+s7PHUvccTk= 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=KWgXr/WkInjaQ8cVX1YfsEAGUgyxCqxAciePN/v2iAY=; b=TEVy2lKVvm+OE+9fsjVkHAh2/EmOJd7n/OtH1MaIBGsnWy3TGCX9OPAECzEP1+94b2 XKrsHl9lgN9KOGTC4VKkBawzz8Jj7VWH3qfjePdu+E5BVJy1+2mZyoroMy2EbKivp4b2 7T7srknfBdUYSLbzDmIgrLPAaeVXILm1FWxJ99eiJY9krR+mBxQ3B3v1XP7rfiuqfJ6g hWluvpdSYyOwAijPxvxtsiViDLqNpLs6CV1XE7RXCfjuc8YMHHb/vtA2LED31+AsSmeu lLQKNYSFiyosWiVZkFIsBVckFgmdDAGh9vuv9/XC7bsz9lioS4j2hyDJF2TEijlKs92T 0+FA== X-Gm-Message-State: ANhLgQ35V2xdC1b8TzaukUEFtxmdTgYC1AXnN+d8bZ1Eaq8tC7Y86wGB AQj4qScHVSk7njQ17q0PDxw1Z7CgW24= X-Google-Smtp-Source: ADFU+vuiUxXldeDRNS1BpAbBgMbgvA0pw63RQDAWoUUin3anEVllq8xWgUD/ImXJ/PUDB5ZLuqmj1A== X-Received: by 2002:adf:fc10:: with SMTP id i16mr1584149wrr.331.1583188055187; Mon, 02 Mar 2020 14:27:35 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id o18sm26114589wrv.60.2020.03.02.14.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 14:27:34 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 44/51] drm/gm12u320: Use helpers for shutdown/suspend/resume Date: Mon, 2 Mar 2020 23:26:24 +0100 Message-Id: <20200302222631.3861340-45-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302222631.3861340-1-daniel.vetter@ffwll.ch> References: <20200302222631.3861340-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[] = {