From patchwork Mon Jun 6 14:53:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 9158497 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 94B1060572 for ; Mon, 6 Jun 2016 14:54:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85C14252D5 for ; Mon, 6 Jun 2016 14:54:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A7FC26E5D; Mon, 6 Jun 2016 14:54:01 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECE20252D5 for ; Mon, 6 Jun 2016 14:54:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 306196E1D4; Mon, 6 Jun 2016 14:53:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E37366E1D4 for ; Mon, 6 Jun 2016 14:53:56 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id n184so17135694wmn.1 for ; Mon, 06 Jun 2016 07:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=cjuY6J0r5zHZEuPb7RMVc50SVI+rJI1cT0Zo5cebHPw=; b=HGA9xMwBPgvjZnf77DnNLRlx/prqpj7a5x9vxbApWls+BLAi1IgylGKob/cm52dUHQ PMutEG5l8XVberPMiWNqOB2q5o8SPEdM47YO/VkGNK5NPw2JK5A9CmOiNuUZGD9DJMis i5Xi5c0hTCEJVbToDarWBRK1805xIGUJCVM+v7gBkHXPOq5JiAUH3blN3sqTRWwoN8Tl C9ZlZhMNWYRkw+EjVhLXa+4pKcIfAgFWDhDSS2YrEuYY9Wk55bbmmXxEZA0obpBKuKEs bnpDfcDL1e2/LeiDuWAhup8dBdESe1rJfzMov9NVJLZYY7o90waFBxWOjhtua2iMF53C VO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=cjuY6J0r5zHZEuPb7RMVc50SVI+rJI1cT0Zo5cebHPw=; b=LjuOW45fPbWWmOXteVFmbXWQTpTIQKEWS/L+3teZISxCjUI1loBbhW+qydXoiF4XE8 9crUyjZrpDSDKMO7htUwjtPgRapcXR/uDg8vFZ7gHRIUJWbsUj/JN7/SQHDxo1flgNgV BQ/sh9r7xnfw65a3m3ocqYexA8XBpISaZNWnjeJf96dLrf+/k37EdYa/FJwt/zzgO4Ou 85IeUv9r5mk8TRHftprkG1BW7bz8UECSh2YBTXhwI4uHh17AVH+28JI/4RLeAcgrVKNG rvEIR+jsqvSaxMx0pOnwmOpjM0nkwAzRGvyeCdW1toRea+N8DsHSwV49sE7PX1Q+2xHL nCnw== X-Gm-Message-State: ALyK8tItXo6ixgUwUJQQWUFiVB7/CBe8ntIsMQlEq6MlAI2f2Hkh3EmHhNu1EEjAcdsUQA== X-Received: by 10.28.4.88 with SMTP id 85mr13249383wme.77.1465224835117; Mon, 06 Jun 2016 07:53:55 -0700 (PDT) Received: from cizrna.lan ([109.72.12.27]) by smtp.gmail.com with ESMTPSA id i190sm14511174wmf.10.2016.06.06.07.53.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 07:53:54 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/rockchip: Use atomic PM helpers Date: Mon, 6 Jun 2016 16:53:32 +0200 Message-Id: <1465224813-7359-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.5 Cc: Tomeu Vizoso , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Caesar Wang , linux-arm-kernel@lists.infradead.org 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 This driver was still using the old legacy helpers and that caused a few NULL dereferences when trying to call empty callbacks. Signed-off-by: Tomeu Vizoso Cc: Caesar Wang Cc: Douglas Anderson Cc: Heiko Stuebner Cc: Yakir Yang --- Hi, these two patches apply on top of Daniel Vetter's series that add async support to the atomic commit helpers. Thanks, Tomeu --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 84 +++++++++++------------------ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + 2 files changed, 32 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 2251121343e6..36c8b58ca45f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "rockchip_drm_drv.h" #include "rockchip_drm_fb.h" @@ -308,25 +309,38 @@ static struct drm_driver rockchip_drm_driver = { }; #ifdef CONFIG_PM_SLEEP -static int rockchip_drm_sys_suspend(struct device *dev) +void rockchip_drm_fb_suspend(struct drm_device *drm) { - struct drm_device *drm = dev_get_drvdata(dev); - struct drm_connector *connector; + struct rockchip_drm_private *priv = drm->dev_private; - if (!drm) - return 0; + console_lock(); + drm_fb_helper_set_suspend(&priv->fbdev_helper, 1); + console_unlock(); +} - drm_modeset_lock_all(drm); - list_for_each_entry(connector, &drm->mode_config.connector_list, head) { - int old_dpms = connector->dpms; +void rockchip_drm_fb_resume(struct drm_device *drm) +{ + struct rockchip_drm_private *priv = drm->dev_private; - if (connector->funcs->dpms) - connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF); + console_lock(); + drm_fb_helper_set_suspend(&priv->fbdev_helper, 0); + console_unlock(); +} - /* Set the old mode back to the connector for resume */ - connector->dpms = old_dpms; +static int rockchip_drm_sys_suspend(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + struct rockchip_drm_private *priv = drm->dev_private; + + drm_kms_helper_poll_disable(drm); + rockchip_drm_fb_suspend(drm); + + priv->state = drm_atomic_helper_suspend(drm); + if (IS_ERR(priv->state)) { + rockchip_drm_fb_resume(drm); + drm_kms_helper_poll_enable(drm); + return PTR_ERR(priv->state); } - drm_modeset_unlock_all(drm); return 0; } @@ -334,47 +348,11 @@ static int rockchip_drm_sys_suspend(struct device *dev) static int rockchip_drm_sys_resume(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); - struct drm_connector *connector; - enum drm_connector_status status; - bool changed = false; - - if (!drm) - return 0; - - drm_modeset_lock_all(drm); - list_for_each_entry(connector, &drm->mode_config.connector_list, head) { - int desired_mode = connector->dpms; - - /* - * at suspend time, we save dpms to connector->dpms, - * restore the old_dpms, and at current time, the connector - * dpms status must be DRM_MODE_DPMS_OFF. - */ - connector->dpms = DRM_MODE_DPMS_OFF; - - /* - * If the connector has been disconnected during suspend, - * disconnect it from the encoder and leave it off. We'll notify - * userspace at the end. - */ - if (desired_mode == DRM_MODE_DPMS_ON) { - status = connector->funcs->detect(connector, true); - if (status == connector_status_disconnected) { - connector->encoder = NULL; - connector->status = status; - changed = true; - continue; - } - } - if (connector->funcs->dpms) - connector->funcs->dpms(connector, desired_mode); - } - drm_modeset_unlock_all(drm); - - drm_helper_resume_force_mode(drm); + struct rockchip_drm_private *priv = drm->dev_private; - if (changed) - drm_kms_helper_hotplug_event(drm); + drm_atomic_helper_resume(drm, priv->state); + rockchip_drm_fb_resume(drm); + drm_kms_helper_poll_enable(drm); return 0; } diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 005634484441..ea3932940061 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -60,6 +60,7 @@ struct rockchip_drm_private { struct drm_fb_helper fbdev_helper; struct drm_gem_object *fbdev_bo; const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC]; + struct drm_atomic_state *state; }; int rockchip_register_crtc_funcs(struct drm_crtc *crtc,