From patchwork Fri Mar 3 16:48:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13159002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3804BC7EE37 for ; Fri, 3 Mar 2023 16:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbjCCQsw (ORCPT ); Fri, 3 Mar 2023 11:48:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjCCQsu (ORCPT ); Fri, 3 Mar 2023 11:48:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83E318175; Fri, 3 Mar 2023 08:48:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 719E9B8191F; Fri, 3 Mar 2023 16:48:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 355D0C433EF; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677862103; bh=rsIBiufyPVeN/iiBVMiUsYKGl4amMszJEzKK1e3KNPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kv2V7vi8JBid7b+OQvUUH9Dfwk3myyxVMZcV//d7U73cA/DPvuczUjkxjSFE9RzFv ALh37t/8+aekRIr9OYSf9rR/Pwz/JYs2jN8xg8qdKx03dVAZNWDPk5IrT51hJz+eIA vWNg7wqnZu0g7hrliuXz9qoGSSDzkArNsaQNbXjabk9BCTzYS88D0f7I9/7F959xij bjzhS1eyXs3PmiRJmFfSsCwVhP89xYkDYhxlHvqctnTQw/gGBW04u7Xccc0bhCc1iY aX/Db0JBMnNIBi5EKXIs6geGmMD1VfjtDiH+LFpjop3EkaybQyXAZU8kim4CX01OM6 UvhA4ozZ5Cc9g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pY8aV-0003Qc-Dt; Fri, 03 Mar 2023 17:48:55 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , Bjorn Andersson , stable@vger.kernel.org Subject: [PATCH v2 1/4] drm/msm/adreno: fix runtime PM imbalance at unbind Date: Fri, 3 Mar 2023 17:48:04 +0100 Message-Id: <20230303164807.13124-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303164807.13124-1-johan+linaro@kernel.org> References: <20230303164807.13124-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org A recent commit moved enabling of runtime PM from adreno_gpu_init() to adreno_load_gpu() (called on first open()), which means that unbind() may now be called with runtime PM disabled in case the device was never opened in between. Make sure to only forcibly suspend and disable runtime PM at unbind() in case runtime PM has been enabled to prevent a disable count imbalance. This specifically avoids leaving runtime PM disabled when the device is later opened after a successful bind: msm_dpu ae01000.display-controller: [drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13 Fixes: 4b18299b3365 ("drm/msm/adreno: Defer enabling runpm until hw_init()") Reported-by: Bjorn Andersson Link: https://lore.kernel.org/lkml/20230203181245.3523937-1-quic_bjorande@quicinc.com Cc: stable@vger.kernel.org # 6.0 Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/adreno_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 36f062c7582f..c5c4c93b3689 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -558,7 +558,8 @@ static void adreno_unbind(struct device *dev, struct device *master, struct msm_drm_private *priv = dev_get_drvdata(master); struct msm_gpu *gpu = dev_to_gpu(dev); - WARN_ON_ONCE(adreno_system_suspend(dev)); + if (pm_runtime_enabled(dev)) + WARN_ON_ONCE(adreno_system_suspend(dev)); gpu->funcs->destroy(gpu); priv->gpu_pdev = NULL; From patchwork Fri Mar 3 16:48:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13159000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9B14C64EC4 for ; Fri, 3 Mar 2023 16:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbjCCQsv (ORCPT ); Fri, 3 Mar 2023 11:48:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbjCCQsu (ORCPT ); Fri, 3 Mar 2023 11:48:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9883137F3D; Fri, 3 Mar 2023 08:48:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5F6C618A2; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EF4CC4339C; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677862103; bh=H2ufo+jNyr5bRVWLvkxfPbacY4z2Injj/fm+rrg+q14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVy/3GIpBO3Iy36roKAswL82BbJWNaLt1UlD7Yvvie2LBfCPgaaXGuafDVRySiLwj LBVGz3yh3COUi9l4uGh+PZcPszDVN+Fvy/myLohH4ykB/WT59V8qqw2HPhbrpgdvOq VCF5DOeRcvpzlA+NnEqHW+6GTTyEenrfIuc6ZfGZubhYxNydzwWenpKodg/jx/EW1K WGLskVgFYsqSyaiMbDxLH3yQftu6RYDu9+0esyEkGVjTucWB5NzDms00Uucjn37o3W Vgd5jVOSjBRS4G1GPwlQgaOZ+a/ZQuVk6SZAB7M2gzTErBhlT3HVyKFNhifdC15Bfh 3SI7GUkpeFSxQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pY8aV-0003Qe-Gm; Fri, 03 Mar 2023 17:48:55 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 2/4] drm/msm/adreno: fix runtime PM imbalance at gpu load Date: Fri, 3 Mar 2023 17:48:05 +0100 Message-Id: <20230303164807.13124-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303164807.13124-1-johan+linaro@kernel.org> References: <20230303164807.13124-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org A recent commit moved enabling of runtime PM to GPU load time (first open()) but failed to update the error paths so that runtime PM is disabled if initialisation of the GPU fails. This would trigger a warning about the unbalanced disable count on the next open() attempt. Note that pm_runtime_put_noidle() is sufficient to balance the usage count when pm_runtime_put_sync() fails (and is chosen over pm_runtime_resume_and_get() for consistency reasons). Fixes: 4b18299b3365 ("drm/msm/adreno: Defer enabling runpm until hw_init()") Cc: stable@vger.kernel.org # 6.0 Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/adreno_device.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index c5c4c93b3689..f9a0b11c2e43 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -443,20 +443,21 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) { - pm_runtime_put_sync(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); DRM_DEV_ERROR(dev->dev, "Couldn't power up the GPU: %d\n", ret); - return NULL; + goto err_disable_rpm; } mutex_lock(&gpu->lock); ret = msm_gpu_hw_init(gpu); mutex_unlock(&gpu->lock); - pm_runtime_put_autosuspend(&pdev->dev); if (ret) { DRM_DEV_ERROR(dev->dev, "gpu hw init failed: %d\n", ret); - return NULL; + goto err_put_rpm; } + pm_runtime_put_autosuspend(&pdev->dev); + #ifdef CONFIG_DEBUG_FS if (gpu->funcs->debugfs_init) { gpu->funcs->debugfs_init(gpu, dev->primary); @@ -465,6 +466,13 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) #endif return gpu; + +err_put_rpm: + pm_runtime_put_sync(&pdev->dev); +err_disable_rpm: + pm_runtime_disable(&pdev->dev); + + return NULL; } static int find_chipid(struct device *dev, struct adreno_rev *rev) From patchwork Fri Mar 3 16:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13159001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5680FC7EE32 for ; Fri, 3 Mar 2023 16:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbjCCQsz (ORCPT ); Fri, 3 Mar 2023 11:48:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjCCQsv (ORCPT ); Fri, 3 Mar 2023 11:48:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A0D18B28; Fri, 3 Mar 2023 08:48:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 82328B81991; Fri, 3 Mar 2023 16:48:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BFE8C4339B; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677862103; bh=ghKAflDi6cHXV/m9c7aUUTchyJQbN3Zs5gEFagIodNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EjNFRHUrfVzfTQN1hPMNIZMRPuA5MZpFQoOZTBb7kUjzBtw9js5rHCjRDugStH763 F3mFBOBxY28EDv5le2uu9eb5Hidfcm/Fo8VxaHVJwXPckoLbHaBsok93vN7hD8Xx5H +bweBD6ed8q38NO/5VXPYTyIGF3s52CLEuX+2pZ3c1gF8pHz19VR116xsUlS9aYvdT MimxJEfUdJP/WsXE49pULvCVr7c0YSE1CW7Wu6bcsSC7X5pVOsdHYYsow6Rf5MpK+D phApojlZDsoRBV/6dQLYRjWFW+1i/ccGz7Syyxa0iUaTZw1sSlTXMuVadlefjLBsIk 8laaT/inWojBA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pY8aV-0003Qg-Jx; Fri, 03 Mar 2023 17:48:55 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 3/4] drm/msm/adreno: drop bogus pm_runtime_set_active() Date: Fri, 3 Mar 2023 17:48:06 +0100 Message-Id: <20230303164807.13124-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303164807.13124-1-johan+linaro@kernel.org> References: <20230303164807.13124-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The runtime PM status can only be updated while runtime PM is disabled. Drop the bogus pm_runtime_set_active() call that was made after enabling runtime PM and which (incidentally but correctly) left the runtime PM status set to 'suspended'. Fixes: 2c087a336676 ("drm/msm/adreno: Load the firmware before bringing up the hardware") Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/adreno_device.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index f9a0b11c2e43..d9100e3870bc 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -438,9 +438,6 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) */ pm_runtime_enable(&pdev->dev); - /* Make sure pm runtime is active and reset any previous errors */ - pm_runtime_set_active(&pdev->dev); - ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) { pm_runtime_put_noidle(&pdev->dev); From patchwork Fri Mar 3 16:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13158999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBCAC64EC4 for ; Fri, 3 Mar 2023 16:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbjCCQsv (ORCPT ); Fri, 3 Mar 2023 11:48:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbjCCQst (ORCPT ); Fri, 3 Mar 2023 11:48:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C013B64E; Fri, 3 Mar 2023 08:48:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E50366189A; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D00C433A0; Fri, 3 Mar 2023 16:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677862103; bh=vLHp6zfTAtlmPAsNSVAaON653kcH7IWEthUS+f3d9jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPi6ora5KkXwil7JTuFP5WMoI7+GYA51OE6LgUi8oxJmJKwxDEQacbEmofLEZs4bA 4vGdSTrlImplGjX1478iDKA6GEh3AflKGr0Kvw8MO4Ux5zhvz2eiGsZGhP4fRZ30Hs oyQZ7y20+Z42gS9HAfM0O71N0rFOLGEYnwNUFE7kxDUzNFn6Vr1ofQkezosac0rXkI IulhKXidHaoIzsrxVARyef5JI7RA1lI9TEYyyuNnT96XqpM8Rf02Uoipz/9+8c9NOa 22fRh35/cD2z7zIMl1Nw+lVgDnrjfBkEeV39TPEhD7ZW7Mwc9e3zSl/ZFbabxYC4O6 y8UqrN0WK0zRg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pY8aV-0003Qi-Mx; Fri, 03 Mar 2023 17:48:55 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 4/4] drm/msm/adreno: clean up component ops indentation Date: Fri, 3 Mar 2023 17:48:07 +0100 Message-Id: <20230303164807.13124-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303164807.13124-1-johan+linaro@kernel.org> References: <20230303164807.13124-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Clean up the component ops initialisers which were indented one level too far. Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/adreno_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index d9100e3870bc..f2cdc5ad7ce7 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -571,8 +571,8 @@ static void adreno_unbind(struct device *dev, struct device *master, } static const struct component_ops a3xx_ops = { - .bind = adreno_bind, - .unbind = adreno_unbind, + .bind = adreno_bind, + .unbind = adreno_unbind, }; static void adreno_device_register_headless(void)