From patchwork Tue Feb 21 10:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13147608 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 E5077C6379F for ; Tue, 21 Feb 2023 10:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234129AbjBUKQv (ORCPT ); Tue, 21 Feb 2023 05:16:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233015AbjBUKQu (ORCPT ); Tue, 21 Feb 2023 05:16:50 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE43233E3; Tue, 21 Feb 2023 02:16:49 -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 sin.source.kernel.org (Postfix) with ESMTPS id 6C3CACE09B5; Tue, 21 Feb 2023 10:16:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57961C433EF; Tue, 21 Feb 2023 10:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676974605; bh=rsIBiufyPVeN/iiBVMiUsYKGl4amMszJEzKK1e3KNPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UxVTeCgQv7nr7fYeRtAYvutvyfzn2nEPwWXUgm5gZhaSUjA5fv+/yLOaoWghcY3gw Jo0MgAIQgCMPKgLsPh6eCP5d1g8ZZyXEYFZvoPLom5oeoEtXstfg54huEzCDIU2IMK SO8XmIZukdkDZDbt7ZGjA6IfildbkNuJPq9fydFZ3N1YTxYd6F7i8v+0E/xSuEPQl4 7VgVHwizHTh6QBb5IM4bnoM6kKdvXlubmLzUhY+xGJzD6+TqtWDaGOr1+e7tZ2ImzN SmafOtsH99Wa2sH/tDjbJ37zsyJbgJauoNmdk1TIPU6kUc8oegUBXWLvgKYeDDGufB /NkwxzCndLo2Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pUPhX-0003oF-WE; Tue, 21 Feb 2023 11:16:48 +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 1/4] drm/msm/adreno: fix runtime PM imbalance at unbind Date: Tue, 21 Feb 2023 11:14:27 +0100 Message-Id: <20230221101430.14546-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221101430.14546-1-johan+linaro@kernel.org> References: <20230221101430.14546-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 Tue Feb 21 10:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13147609 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 86137C64EC4 for ; Tue, 21 Feb 2023 10:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234138AbjBUKQv (ORCPT ); Tue, 21 Feb 2023 05:16:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233753AbjBUKQu (ORCPT ); Tue, 21 Feb 2023 05:16:50 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E363233F0; Tue, 21 Feb 2023 02:16:49 -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 sin.source.kernel.org (Postfix) with ESMTPS id 6F9F6CE19AD; Tue, 21 Feb 2023 10:16:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D379C433D2; Tue, 21 Feb 2023 10:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676974605; bh=O3ZdmShGWbUJjxtHFjkD8zibeYG5rnq2WGdw9cH2vEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CslmcW/Gqc+so6rQNDhpB3QFJPYSPJ+L9XRpRtiodR+VWvYXjJcZfxsh4rxoxmTlH priGA26mi1SACSFhFvc5qDaf6T5r0+xrfgFFhz7kzWgDENfdI1m4JnXZ6AlMzh5HWz yXHlK0ilaAKac4mn4R/o7/J7bETbRdK3aR9hXJt9Kxt+6chm5nslHqCLGtnT71acj3 gAvEaG8rtyVofpeWVy2MB3htYDVsGsxRksYPCXoyM6pg5EPK56o8CjxtGpt6XM35Ta VkRFmiMIDq4jAdRg/bB8hnYvvYqLu9mMltZjCYL5ygCe7je6E0xhZKcmwkpdDYgrcd bCiaoni1OEikQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pUPhY-0003oH-2p; Tue, 21 Feb 2023 11:16:48 +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 2/4] drm/msm/adreno: drop bogus pm_runtime_set_active() Date: Tue, 21 Feb 2023 11:14:28 +0100 Message-Id: <20230221101430.14546-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221101430.14546-1-johan+linaro@kernel.org> References: <20230221101430.14546-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 c5c4c93b3689..cd009d56d35d 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_sync(&pdev->dev); From patchwork Tue Feb 21 10:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13147606 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 E6812C64EC4 for ; Tue, 21 Feb 2023 10:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232873AbjBUKQt (ORCPT ); Tue, 21 Feb 2023 05:16:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233728AbjBUKQt (ORCPT ); Tue, 21 Feb 2023 05:16:49 -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 4813923665; Tue, 21 Feb 2023 02:16:48 -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 AE4FCB80E96; Tue, 21 Feb 2023 10:16:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B0A2C4339E; Tue, 21 Feb 2023 10:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676974605; bh=CLnGEscqosrMeLtUFrN4NYlf8E7ksq4zdFj/Jlggmh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+V1fdK1GKXHbxmqrbV9e4k/+EMq/lPTAGIm5msOM6r2++cH9mTlLG7UGkLSIKmai 68WtQLbR5MsoTCjy8rG+jOhcTXI3e60RRUZLbISeYQv7/6Z+xZ9G7ywThRzMT0b0q6 +ZE0O17llIV3WzZrlYA4eiwOQg59FYn5Xn6TCuyymUNOTRbA0waFR5ml0kdld0WZJr 6B+2RdncNDKvzgS9a3tS9aEevT9gmg+cWRnJHsz8Bxu/Thbyv1COe9SifpLyizvcfW U710lcZLepraPrQN8tTmx9p2ekPaYqdh5jS9q6MgryyNM9MZLpLB9DYlTF+i7ETzXW M0ebwVGhTpnrw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pUPhY-0003oJ-5w; Tue, 21 Feb 2023 11:16:48 +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 3/4] drm/msm/adreno: drop redundant pm_runtime_disable() Date: Tue, 21 Feb 2023 11:14:29 +0100 Message-Id: <20230221101430.14546-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221101430.14546-1-johan+linaro@kernel.org> References: <20230221101430.14546-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Since commit 4b18299b3365 ("drm/msm/adreno: Defer enabling runpm until hw_init()") runtime PM is no longer enabled at adreno_gpu_init(), which means that there are no longer any bind() error paths for which adreno_gpu_cleanup() is called with runtime PM enabled. As the runtime PM enable on first open() is balanced by the pm_runtime_force_suspend() call at unbind(), adreno_gpu_cleanup() is now always called with runtime PM disabled so that its pm_runtime_disable() call can be removed. Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index ce6b76c45b6f..1101b8234b49 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -1082,15 +1082,10 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu) { - struct msm_gpu *gpu = &adreno_gpu->base; - struct msm_drm_private *priv = gpu->dev ? gpu->dev->dev_private : NULL; unsigned int i; for (i = 0; i < ARRAY_SIZE(adreno_gpu->info->fw); i++) release_firmware(adreno_gpu->fw[i]); - if (priv && pm_runtime_enabled(&priv->gpu_pdev->dev)) - pm_runtime_disable(&priv->gpu_pdev->dev); - msm_gpu_cleanup(&adreno_gpu->base); } From patchwork Tue Feb 21 10:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13147607 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 7FC95C678D5 for ; Tue, 21 Feb 2023 10:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233811AbjBUKQu (ORCPT ); Tue, 21 Feb 2023 05:16:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233863AbjBUKQt (ORCPT ); Tue, 21 Feb 2023 05:16:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C4323306; Tue, 21 Feb 2023 02:16:48 -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 E0465B80E9D; Tue, 21 Feb 2023 10:16:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E5A4C433AF; Tue, 21 Feb 2023 10:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676974605; bh=yMvJYHxVZptlOU5QkNPi2i647YDtCkktqGaRKrHuIIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDMSqzEIjkQp9Nbi1pc/AzuqhupeOI0A3vwNCZ+xQhLmKTVWYn/ECf7VyPVWCwLWD TuG7eYCCOaDEAGahZTISo0O92OQpg0Wy0ZylhuKSY364JZwl0PZN/d5PAJqjWOPTar UDHsyc2meB8Ioe2RWYK1b0W/OLDEvCQR65EUDoWh4OEtr/L4gHuLR+N8PhE/pY0UEw mCeQL/yDX+LVydQWluxQNOhU4w1cVrTfv9oJmTP2bI9Anz9A6jIrNY2IAEjrFEvisW nCnE9kysBsiCWJDtnFCLseC9daRe0P8aJpG2CSbTtOxSlgWMTgG3lH/GnNPtRoBVSL KYE9DoOW4CtlA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pUPhY-0003oL-8z; Tue, 21 Feb 2023 11:16:48 +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 4/4] drm/msm/adreno: clean up component ops indentation Date: Tue, 21 Feb 2023 11:14:30 +0100 Message-Id: <20230221101430.14546-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221101430.14546-1-johan+linaro@kernel.org> References: <20230221101430.14546-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 cd009d56d35d..80947420ac19 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -563,8 +563,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)