From patchwork Wed Apr 1 16:52:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haixia Shi X-Patchwork-Id: 6141511 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 883A4BF4A6 for ; Wed, 1 Apr 2015 16:53:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4A9120364 for ; Wed, 1 Apr 2015 16:53:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A3FEA2015E for ; Wed, 1 Apr 2015 16:53:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D98A16E1E1; Wed, 1 Apr 2015 09:52:59 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D28E6E1E1 for ; Wed, 1 Apr 2015 09:52:59 -0700 (PDT) Received: by iedfl3 with SMTP id fl3so54139240ied.1 for ; Wed, 01 Apr 2015 09:52:58 -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:mime-version:content-type :content-transfer-encoding; bh=W/i+6hI6pbM1yg1h50wg+1mAXlzTP8EuAgE+DOfiZIo=; b=DgYEQ58774cfZ1Z8RqpUszntBfgd+pyrrvrg9KFTkqHQelZro79no5IOsBM+xaCvdA rwkF0iKnHG9FMJw7IsEtDISSVj/FeGkYvbrJRYp+bJdok5JkYTE/rnYATHGwSM+9FTmV eQOMzsGkGCq7umlZhsVYHXKKcLp3dcbY9M5gg= 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:mime-version :content-type:content-transfer-encoding; bh=W/i+6hI6pbM1yg1h50wg+1mAXlzTP8EuAgE+DOfiZIo=; b=K/hBbS8sRNVWKRJr092h1y7mp5KNITlOjYcnZoY+SIaK32wXVB/kM/3zprW4DokuIu CA0rAUjNsM/yeUxB+PiVXX5Cgofm23ZOk01peYzNf4glOIhX2K4z/tbsZ2ybfTKmlLEw xmIXs1xwlLQZMpA7LlHGB2T52jRsA4g39U5hERMXPeyU3ZHZmBgnqxsYnS8idzq4o13m UERXO49TZw+8shwkxvz0fMhBrqgtFuxVaNRJRRb3maEi85u8HNNozJxfxI+7YP6qsz11 0Yt4Jr3um1BPQlHIiQnqAPloW8lDdMWEpKn0szy5sA1AGgWcB94d+Bjs/7Noq9wj6ZGg h4KA== X-Gm-Message-State: ALoCoQnA29tu0cK53cc4hukEcjwtIxX7h+2yOCyygEPxbrekWoIVJgfvKiNRU1sXcq+GmxkAOSEx X-Received: by 10.42.171.193 with SMTP id k1mr75832671icz.67.1427907178506; Wed, 01 Apr 2015 09:52:58 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:e14d:6be8:ad41:2fd0]) by mx.google.com with ESMTPSA id i1sm12483656igh.5.2015.04.01.09.52.56 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 01 Apr 2015 09:52:57 -0700 (PDT) From: Haixia Shi To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/udl: implement usb_driver suspend/resume. Date: Wed, 1 Apr 2015 09:52:51 -0700 Message-Id: <1427907171-9639-1-git-send-email-hshi@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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. Signed-off-by: Haixia Shi Reviewed-by: Stéphane 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 d5728ec..5b37aad 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, @@ -123,6 +138,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, }; diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 80adbac..19cb75d 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; @@ -89,6 +90,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 677190a6..e4a986c 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -317,6 +317,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 */ @@ -461,6 +463,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);