From patchwork Tue Oct 2 15:05:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Wang X-Patchwork-Id: 10623829 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B60EE15A7 for ; Tue, 2 Oct 2018 15:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A902F2000A for ; Tue, 2 Oct 2018 15:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BA1420453; Tue, 2 Oct 2018 15:05:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0BDB20415 for ; Tue, 2 Oct 2018 15:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbeJBVtZ (ORCPT ); Tue, 2 Oct 2018 17:49:25 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:37056 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbeJBVtY (ORCPT ); Tue, 2 Oct 2018 17:49:24 -0400 Received: by mail-yb1-f196.google.com with SMTP id h1-v6so907693ybm.4 for ; Tue, 02 Oct 2018 08:05:33 -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-transfer-encoding; bh=qX5CovQgpARUnX8jYxuzmOumd9Fv26/ku3zbrxJ6qpw=; b=HrOga0pw3UPnKZh1L4wxp5TW9ZJwBxG4RqVjjL6UlRxC34Siuexb0UPEe7b8wn7RsK K3m+7gCe/BP+SLW8OBTbtPLGFxtg7tvHhpPDWz3D5Dd4LYB4WPyYxeGcnPgwwJo1TJ38 66zB38ZBS5uCs1pPLVtCrrQcl6sZp/Z4mXVKo= 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:mime-version :content-transfer-encoding; bh=qX5CovQgpARUnX8jYxuzmOumd9Fv26/ku3zbrxJ6qpw=; b=e2+BM1uAfi2jVSBLdniz5ruyvpKR8pR/dJYzyFTnsaPZLvUrw/XfJtwyNry8SsL3B3 Bhdpg8pqbrK/9rOaqiSP3po6tcAiCTTwNYPep2lRzVXaL1ZeTJ3Tdd/D1/syACBfx22+ p7M2cJMSW89aPXJOBC0WKjc1YGKV/sqJvetf7guZ8i3wjAEsi5zji8C2pc67S9U7SUvE UkFWGBmbR3hq1YTONkwSvQuIMka5//hHa65UDXJxdtz/iK5ai4Huu0Ew2dnj9rH5rA8+ 0Tf0wOTdMo4o+7K8jHsK5dhtEhoTtZlQJ8hrLZND7idhfJ7YUhlxw4xlsJNmmGXHNdgi ntxw== X-Gm-Message-State: ABuFfohTnzw5dBLMDVmBQ3GuqOJSWoJVf3c5vEjZ4y03y7UahKM2tYtb Flrc/Tj0srsoRQ8iI7A0aAVGNw== X-Google-Smtp-Source: ACcGV63wQduG395ftXHTKLsCyxF0Luj5x6QhG5TokdUqV5QoatLcB5nQcts1RqRv+iMzgeq8k0V1Rg== X-Received: by 2002:a5b:18a:: with SMTP id r10-v6mr996621ybl.361.1538492733498; Tue, 02 Oct 2018 08:05:33 -0700 (PDT) Received: from bzwang.cnc.corp.google.com ([2620:0:1013:11:6f9e:dcbe:41ef:a61]) by smtp.gmail.com with ESMTPSA id o202-v6sm37961956ywo.38.2018.10.02.08.05.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 08:05:32 -0700 (PDT) From: Bruce Wang To: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: seanpaul@chromium.org, jsanka@codeaurora.org, robdclark@gmail.com, abhinavk@codeaurora.org, jcrouse@codeaurora.org Subject: [PATCH 1/2] drm/msm: Use atomic helpers for pm_suspend/resume Date: Tue, 2 Oct 2018 11:05:29 -0400 Message-Id: <20181002150530.6407-1-bzwang@chromium.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The dpu implementation of pm_resume were causing a crash. This patch changes msm_pm_suspend and msm_pm_resume to use the atomic helpers drm_atomic_helper_suspend and drm_atomic_helper_resume. Removes the hooks needed for calling the dpu_kms implementations of suspend/resume. Note that the poll_disable call is likely not needed as of right now as the DRM_CONNECTOR_POLL_CONNECT flag is never set. Signed-off-by: Bruce Wang --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 -- drivers/gpu/drm/msm/msm_drv.c | 28 +++++++++---------------- drivers/gpu/drm/msm/msm_kms.h | 3 --- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 0a683e65a9f3..e0142912d676 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -873,8 +873,6 @@ static const struct msm_kms_funcs kms_funcs = { .check_modified_format = dpu_format_check_modified_format, .get_format = dpu_get_msm_format, .round_pixclk = dpu_kms_round_pixclk, - .pm_suspend = dpu_kms_pm_suspend, - .pm_resume = dpu_kms_pm_resume, .destroy = dpu_kms_destroy, .set_encoder_mode = _dpu_kms_set_encoder_mode, #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index c1abad8a8612..b8dc854c99f2 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1069,37 +1069,29 @@ static int msm_pm_suspend(struct device *dev) { struct drm_device *ddev = dev_get_drvdata(dev); struct msm_drm_private *priv = ddev->dev_private; - struct msm_kms *kms = priv->kms; - - /* TODO: Use atomic helper suspend/resume */ - if (kms && kms->funcs && kms->funcs->pm_suspend) - return kms->funcs->pm_suspend(dev); - drm_kms_helper_poll_disable(ddev); + if (!IS_ERR_OR_NULL(priv->pm_state)) + return 0; priv->pm_state = drm_atomic_helper_suspend(ddev); - if (IS_ERR(priv->pm_state)) { - drm_kms_helper_poll_enable(ddev); - return PTR_ERR(priv->pm_state); - } - return 0; + return IS_ERR(priv->pm_state) ? PTR_ERR(priv->pm_state) : 0; } static int msm_pm_resume(struct device *dev) { struct drm_device *ddev = dev_get_drvdata(dev); struct msm_drm_private *priv = ddev->dev_private; - struct msm_kms *kms = priv->kms; + int ret; - /* TODO: Use atomic helper suspend/resume */ - if (kms && kms->funcs && kms->funcs->pm_resume) - return kms->funcs->pm_resume(dev); + if (IS_ERR_OR_NULL(priv->pm_state)) + return 0; - drm_atomic_helper_resume(ddev, priv->pm_state); - drm_kms_helper_poll_enable(ddev); + ret = drm_atomic_helper_resume(ddev, priv->pm_state); + if (ret == 0) + priv->pm_state = NULL; - return 0; + return ret; } #endif diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h index fd88cebb6adb..2b81b43a4bab 100644 --- a/drivers/gpu/drm/msm/msm_kms.h +++ b/drivers/gpu/drm/msm/msm_kms.h @@ -67,9 +67,6 @@ struct msm_kms_funcs { void (*set_encoder_mode)(struct msm_kms *kms, struct drm_encoder *encoder, bool cmd_mode); - /* pm suspend/resume hooks */ - int (*pm_suspend)(struct device *dev); - int (*pm_resume)(struct device *dev); /* cleanup: */ void (*destroy)(struct msm_kms *kms); #ifdef CONFIG_DEBUG_FS From patchwork Tue Oct 2 15:05:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Wang X-Patchwork-Id: 10623831 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBE8715A7 for ; Tue, 2 Oct 2018 15:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF1362000A for ; Tue, 2 Oct 2018 15:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A357520453; Tue, 2 Oct 2018 15:05:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255E82000A for ; Tue, 2 Oct 2018 15:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbeJBVt0 (ORCPT ); Tue, 2 Oct 2018 17:49:26 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:40598 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbeJBVt0 (ORCPT ); Tue, 2 Oct 2018 17:49:26 -0400 Received: by mail-yb1-f196.google.com with SMTP id w7-v6so903339ybm.7 for ; Tue, 02 Oct 2018 08:05:35 -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 :mime-version:content-transfer-encoding; bh=kRaSv9qC1i7OBB1FjcCB8sM/e8ZPf3Os0hctkKmq+mk=; b=M93PTNIKY5SJOWthUcY1vZcoUMQC4yBKHQNU37hDKvq7Sbt+nwjAVkBzY7C+YTGhwK GKi4LP8Yu7J5N1JIFKDiHSgF2V9LNkSR2CiAyEpXrqmIYwxcII6gCcN4IP7DdbeFBpAg oNSFDrQHEqRVJjsWTonvVWB7m4Cg+Fpjux1fU= 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=kRaSv9qC1i7OBB1FjcCB8sM/e8ZPf3Os0hctkKmq+mk=; b=EWamRQ2PkMG6c3o+9DFz4dXJI17MOx3XGa9FDFxfxIwO6DGhZBhTpyJTCcW/CEM820 oZmHZZ0Le0ShSDi2DyUG3mto/vimvMsw/EhAa17xDkENJ9vPyP/stnOFbvvNRGQmrStT ZdJuafU3k2IMRMFeZbFSAczdxc39w3CaLVX0SPC156s1/BxBJkGkIMKxvy6TkXnPS2Fi pY99WUNdCTgEex28mcupFUIimxQZSEQgnUkkifdcXhxBGlC7MQiQSCFTVWAlbcGTt8vn 8l3X3OOa8l/4jbS8HumaE8ZbMs8XD+bEsvRDltW40ZK6rh7LlxY6wTfAH9L4/LZv4Dq0 7eWw== X-Gm-Message-State: ABuFfojpFOrih9z83Kq97WD2C9AJRs/5qHOxblW801qyeg8FkUgsxcO2 QSHyAGDK0KJl0gw14WJHrYpDiA== X-Google-Smtp-Source: ACcGV62blO3XKpoaEbe7UsiRv5giXMEy7IXnjVv1ni5qAkqeM3aorAwnHRU39iE07YVAbQbRPRH1YQ== X-Received: by 2002:a25:3186:: with SMTP id x128-v6mr9024864ybx.227.1538492735285; Tue, 02 Oct 2018 08:05:35 -0700 (PDT) Received: from bzwang.cnc.corp.google.com ([2620:0:1013:11:6f9e:dcbe:41ef:a61]) by smtp.gmail.com with ESMTPSA id o202-v6sm37961956ywo.38.2018.10.02.08.05.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 08:05:33 -0700 (PDT) From: Bruce Wang To: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: seanpaul@chromium.org, jsanka@codeaurora.org, robdclark@gmail.com, abhinavk@codeaurora.org, jcrouse@codeaurora.org Subject: [PATCH 2/2] drm/msm/dpu: Remove all dpu pm_suspend/resume code Date: Tue, 2 Oct 2018 11:05:30 -0400 Message-Id: <20181002150530.6407-2-bzwang@chromium.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181002150530.6407-1-bzwang@chromium.org> References: <20181002150530.6407-1-bzwang@chromium.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Removes the now uncalled pm_suspend/resume code. Also removes dpu_kms_is_suspend_blocked which is never called, and changes dpu_kms_is_suspend_state to work with the new msm_pm_suspend/resume implementations. Signed-off-by: Bruce Wang --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 121 ------------------------ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 23 +---- 2 files changed, 2 insertions(+), 142 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index e0142912d676..ff06b50dfc87 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -709,127 +709,6 @@ static void dpu_kms_destroy(struct msm_kms *kms) _dpu_kms_hw_destroy(dpu_kms); } -static int dpu_kms_pm_suspend(struct device *dev) -{ - struct drm_device *ddev; - struct drm_modeset_acquire_ctx ctx; - struct drm_atomic_state *state; - struct dpu_kms *dpu_kms; - int ret = 0, num_crtcs = 0; - - if (!dev) - return -EINVAL; - - ddev = dev_get_drvdata(dev); - if (!ddev || !ddev_to_msm_kms(ddev)) - return -EINVAL; - - dpu_kms = to_dpu_kms(ddev_to_msm_kms(ddev)); - - /* disable hot-plug polling */ - drm_kms_helper_poll_disable(ddev); - - /* acquire modeset lock(s) */ - drm_modeset_acquire_init(&ctx, 0); - -retry: - DPU_ATRACE_BEGIN("kms_pm_suspend"); - - ret = drm_modeset_lock_all_ctx(ddev, &ctx); - if (ret) - goto unlock; - - /* save current state for resume */ - if (dpu_kms->suspend_state) - drm_atomic_state_put(dpu_kms->suspend_state); - dpu_kms->suspend_state = drm_atomic_helper_duplicate_state(ddev, &ctx); - if (IS_ERR_OR_NULL(dpu_kms->suspend_state)) { - DRM_ERROR("failed to back up suspend state\n"); - dpu_kms->suspend_state = NULL; - goto unlock; - } - - /* create atomic state to disable all CRTCs */ - state = drm_atomic_state_alloc(ddev); - if (IS_ERR_OR_NULL(state)) { - DRM_ERROR("failed to allocate crtc disable state\n"); - goto unlock; - } - - state->acquire_ctx = &ctx; - - /* check for nothing to do */ - if (num_crtcs == 0) { - DRM_DEBUG("all crtcs are already in the off state\n"); - drm_atomic_state_put(state); - goto suspended; - } - - /* commit the "disable all" state */ - ret = drm_atomic_commit(state); - if (ret < 0) { - DRM_ERROR("failed to disable crtcs, %d\n", ret); - drm_atomic_state_put(state); - goto unlock; - } - -suspended: - dpu_kms->suspend_block = true; - -unlock: - if (ret == -EDEADLK) { - drm_modeset_backoff(&ctx); - goto retry; - } - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); - - DPU_ATRACE_END("kms_pm_suspend"); - return 0; -} - -static int dpu_kms_pm_resume(struct device *dev) -{ - struct drm_device *ddev; - struct dpu_kms *dpu_kms; - int ret; - - if (!dev) - return -EINVAL; - - ddev = dev_get_drvdata(dev); - if (!ddev || !ddev_to_msm_kms(ddev)) - return -EINVAL; - - dpu_kms = to_dpu_kms(ddev_to_msm_kms(ddev)); - - DPU_ATRACE_BEGIN("kms_pm_resume"); - - drm_mode_config_reset(ddev); - - drm_modeset_lock_all(ddev); - - dpu_kms->suspend_block = false; - - if (dpu_kms->suspend_state) { - dpu_kms->suspend_state->acquire_ctx = - ddev->mode_config.acquire_ctx; - ret = drm_atomic_commit(dpu_kms->suspend_state); - if (ret < 0) { - DRM_ERROR("failed to restore state, %d\n", ret); - drm_atomic_state_put(dpu_kms->suspend_state); - } - dpu_kms->suspend_state = NULL; - } - drm_modeset_unlock_all(ddev); - - /* enable hot-plug polling */ - drm_kms_helper_poll_enable(ddev); - - DPU_ATRACE_END("kms_pm_resume"); - return 0; -} - static void _dpu_kms_set_encoder_mode(struct msm_kms *kms, struct drm_encoder *encoder, bool cmd_mode) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h index 66d466628e2b..b04aa222e150 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -135,10 +135,6 @@ struct dpu_kms { struct dpu_core_perf perf; - /* saved atomic state during system suspend */ - struct drm_atomic_state *suspend_state; - bool suspend_block; - struct dpu_rm rm; bool rm_init; @@ -170,24 +166,9 @@ struct vsync_info { */ static inline bool dpu_kms_is_suspend_state(struct drm_device *dev) { - if (!ddev_to_msm_kms(dev)) - return false; - - return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_state != NULL; -} - -/** - * dpu_kms_is_suspend_blocked - whether or not commits are blocked due to pm - * suspend status - * @dev: Pointer to drm device - * Return: True if commits should be rejected due to pm suspend - */ -static inline bool dpu_kms_is_suspend_blocked(struct drm_device *dev) -{ - if (!dpu_kms_is_suspend_state(dev)) - return false; + struct msm_drm_private *priv = dev->dev_private; - return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_block; + return !IS_ERR_OR_NULL(priv->pm_state); } /**