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: 9158507 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 354FB60572 for ; Mon, 6 Jun 2016 14:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 262F6252D5 for ; Mon, 6 Jun 2016 14:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AA8C26490; Mon, 6 Jun 2016 14:54:29 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BAB73252D5 for ; Mon, 6 Jun 2016 14:54:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9vv9-0005mY-3o; Mon, 06 Jun 2016 14:54:27 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b9vuz-0005j9-9s; Mon, 06 Jun 2016 14:54:18 +0000 Received: by mail-wm0-x241.google.com with SMTP id m124so16027457wme.3; 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=gciORQrDw7WL6ktpgydQUiSEA57NfdGD6ZMqIeeY49ZBdHUcsLQ8BSZ2DD2lBbqVLe snMvm2POx4eHrZvoUBc/2iAcofQCxj3y8vqVnSdItSWbwIo8fu3B+XLVoR56AdzaHcAa xHN5sYm3UdNXGkHMSjM1QHUXt/LcOoyYJNFLNp4NgJj/Km7hvu3D2jM8ssl9C4pCV3kD of3x99JO2KFEzyc4r66DyuuURx2xhxAP5shOWm5EbAykz8mGTeZM9bp+aWSwYpRC5del DeXVa2dg3eO7ViektPajYCUUXlJeP9AY+h7vib0iqa+g/4kYw0GwqL2cOsX6QzulwszA pnVw== X-Gm-Message-State: ALyK8tLM9DD719oz+7ZubDMcz+TI5On18aHscAL0PBwPHrTGL7AjN2tGcK9Nh0ihigLGTw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160606_075417_643418_9A10A989 X-CRM114-Status: GOOD ( 16.36 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Tomeu Vizoso , David Airlie , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Yakir Yang , Caesar Wang , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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,