From patchwork Tue Aug 30 21:50:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haixia Shi X-Patchwork-Id: 9306123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10A51607F0 for ; Tue, 30 Aug 2016 21:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04893288F6 for ; Tue, 30 Aug 2016 21:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED84528D8D; Tue, 30 Aug 2016 21:50:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A20E6288F6 for ; Tue, 30 Aug 2016 21:50:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A4806E6CE; Tue, 30 Aug 2016 21:50:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x22e.google.com (mail-pf0-x22e.google.com [IPv6:2607:f8b0:400e:c00::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B1606E6CC for ; Tue, 30 Aug 2016 21:50:28 +0000 (UTC) Received: by mail-pf0-x22e.google.com with SMTP id y134so11837763pfg.0 for ; Tue, 30 Aug 2016 14:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5LrUefH5LAIX42a1etK1aqN+PLeeMSBUn+JJ+Q7h638=; b=McZdzezIYW5Mq2jN4iZ4PlSOhxLb/xDV9wLzV3S4FIElcO8611u/c8xY6BXn04+LAn /D3bcqTwh93K/U1pbWPeW1ySZmwZeZ5HMBFzXtAqhCMg47s+OK/GZW8CmvUBswaFzCMI cpUAF/qT0SWoFceAXWw/OdbMcbTuRQs1dKxjQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5LrUefH5LAIX42a1etK1aqN+PLeeMSBUn+JJ+Q7h638=; b=Xn4Ih16ojPGqOxdhQyXJb7M9P5anWBkZ1pvHnjd3bAk3RWl8mBodmIzugHQNZgIiJb aJY7uoHZTQ/qjOPh3RVUSTVfwHyR366xL4YEhX+yUIWWeAQ5NIYGyqsMyxFvTirRMSwJ PW3DvAawzxnvNA65i61cDTqsIGFnwRkEO6cICUeLB4fNeeScOSiz+3C3GJGy/HWnoy5/ 3URbuJUe0zY72Lz8/1+lwx3CSyhGvAj8SGsnaB8wHPbHF0ACh82YrRZIneaJLacT95E6 eJHmKG030hR18rJc0iDRt4oO/Z4StVfE5uXdByNt00Y89YyM19kOW5ttctGSYzJ9CDt5 81EQ== X-Gm-Message-State: AE9vXwO3t05KojgPSUF7B4WdbjFyVAPZAN9UUXFMsF3Ms2JmoxTCZ4gB6cOcGmH16H0Y/GjN X-Received: by 10.98.75.65 with SMTP id y62mr10285097pfa.99.1472593827579; Tue, 30 Aug 2016 14:50:27 -0700 (PDT) Received: from haixia-z620.mtv.corp.google.com ([172.22.117.235]) by smtp.gmail.com with ESMTPSA id c7sm59485064pfj.25.2016.08.30.14.50.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Aug 2016 14:50:27 -0700 (PDT) From: Haixia Shi To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/udl: implement usb_driver suspend/resume. Date: Tue, 30 Aug 2016 14:50:21 -0700 Message-Id: <1472593821-38429-2-git-send-email-hshi@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1472593821-38429-1-git-send-email-hshi@chromium.org> References: <1472593821-38429-1-git-send-email-hshi@chromium.org> Cc: Haixia Shi X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The usb_driver suspend and resume function pointers must be populated to prevent forced unbinding of USB interface driver. See usb/core/driver.c: unbind_no_pm_drivers_interfaces(). Restore mode and damage the entire frame buffer upon resume. TEST=suspend and resume with the same UDL device connected TEST=suspend with UDL, unplug UDL and resume TEST=suspend with UDL, unplug and connect another UDL device then resume Signed-off-by: Haixia Shi Reviewed-by: Stphane Marchesin --- drivers/gpu/drm/udl/udl_drv.c | 17 +++++++++++++++++ drivers/gpu/drm/udl/udl_drv.h | 2 ++ drivers/gpu/drm/udl/udl_modeset.c | 13 +++++++++++++ 3 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c index 17d34e0..e5dc73b 100644 --- a/drivers/gpu/drm/udl/udl_drv.c +++ b/drivers/gpu/drm/udl/udl_drv.c @@ -16,6 +16,21 @@ static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m) return 0; } +static int udl_usb_suspend(struct usb_interface *interface, + pm_message_t message) +{ + return 0; +} + +static int udl_usb_resume(struct usb_interface *interface) +{ + struct drm_device *dev = usb_get_intfdata(interface); + + udl_modeset_restore(dev); + return 0; +} + + static const struct vm_operations_struct udl_gem_vm_ops = { .fault = udl_gem_fault, .open = drm_gem_vm_open, @@ -122,6 +137,8 @@ static struct usb_driver udl_driver = { .name = "udl", .probe = udl_usb_probe, .disconnect = udl_usb_disconnect, + .suspend = udl_usb_suspend, + .resume = udl_usb_resume, .id_table = id_table, }; module_usb_driver(udl_driver); diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 0b03d34..f338a57 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -52,6 +52,7 @@ struct udl_device { struct device *dev; struct drm_device *ddev; struct usb_device *udev; + struct drm_crtc *crtc; int sku_pixel_limit; @@ -87,6 +88,7 @@ struct udl_framebuffer { /* modeset */ int udl_modeset_init(struct drm_device *dev); +void udl_modeset_restore(struct drm_device *dev); void udl_modeset_cleanup(struct drm_device *dev); int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder); diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 7369512..69d6a4f 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -309,6 +309,8 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc, char *wrptr; int color_depth = 0; + udl->crtc = crtc; + buf = (char *)udl->mode_buf; /* for now we just clip 24 -> 16 - if we fix that fix this */ @@ -450,6 +452,17 @@ int udl_modeset_init(struct drm_device *dev) return 0; } +void udl_modeset_restore(struct drm_device *dev) +{ + struct udl_device *udl = dev->dev_private; + struct udl_framebuffer *ufb; + if (!udl->crtc || !udl->crtc->primary->fb) + return; + udl_crtc_commit(udl->crtc); + ufb = to_udl_fb(udl->crtc->primary->fb); + udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height); +} + void udl_modeset_cleanup(struct drm_device *dev) { drm_mode_config_cleanup(dev);