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 43011C7EE2D for ; Fri, 3 Mar 2023 16:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231322AbjCCQs7 (ORCPT ); Fri, 3 Mar 2023 11:48:59 -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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.39.2