From patchwork Tue Jun 30 16:31:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11634379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBD76739 for ; Tue, 30 Jun 2020 16:31:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEFD220723 for ; Tue, 30 Jun 2020 16:31:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SU2fRu4g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388228AbgF3QbY (ORCPT ); Tue, 30 Jun 2020 12:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728931AbgF3QbW (ORCPT ); Tue, 30 Jun 2020 12:31:22 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E1AC061755 for ; Tue, 30 Jun 2020 09:31:21 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id b92so9699299pjc.4 for ; Tue, 30 Jun 2020 09:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zvy3pnrdBE7rKtZhGMaIJc9nAztjPriT4eb+3HACwU8=; b=SU2fRu4gMarPK9IcwuRoQjy9vH+xKChjZnAVHGvLqscgK/haRnvHWvQ8aS+RuCr3eB NJmXjFhm+ZfC6AkcE7rkJpKHC64ZrF3Gq8FLRTvKBseE3sUylVhXBfFW9EMDpRfjy+z+ P3dI41B1u1dG5bls5jbgbjVX2uZsyr5e+c16Oqz9iQXhC+mOwc9sdFZ7FZPW7XNl4M+1 07/QUlZ8CqN0aSqz8eKCa9JNAFydmaWMmgfxZyQjyg0emrjIybWq0uYz9qHXME3MBFCz /qbRYGf31hCqxCmcu83oNFUasajy0gM42eVWVCQsVYtvsoDT0Pui0eXWAK9CsYE+QVQd ctGw== 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=Zvy3pnrdBE7rKtZhGMaIJc9nAztjPriT4eb+3HACwU8=; b=kfQZ3uhyJK47gFwHLYKVUkbRmDbHt0CHKLQvzYZmo7CFH7aDmhqZI7CWnioTb5iPLF hJVj5mlfoXB95heNKsILuj7Zz2OOgq07AzRlkbLm0861htIKE8Fsrr/MRMMdNatAICGO XZUu5+q48dtxmJL118XQ1gavAa7Ssvw8EGDVlEWveB6ZgZY9stfZtrFjM1ry1dprJIBj qQI5GJb+KVz597nqwAn9YGwLHLsWgsoYngSkBAV7arKFQBERHSgHJvzOI3kAAC6Zgezj u75rEU8TRW5BkjzvzU4WvkFq+oXXk8xxJ/mleXu9IgWCXECyU7twxml4fwDw/D6og5nk /nBQ== X-Gm-Message-State: AOAM533O+I734k8ouHwIAnnjUj8hK9seQgAgA+6aimnMl7H6156MXvzC WeTnMaaNXB1S7N/NVMTRqRUOUw== X-Google-Smtp-Source: ABdhPJxVhBXvLkZLUZNrDUcMWD7chck0CLy8ssAC74MPRXCiRAAolcbzvIswyBdRxgXLXR6QAAhHTA== X-Received: by 2002:a17:902:9a94:: with SMTP id w20mr18084177plp.177.1593534681521; Tue, 30 Jun 2020 09:31:21 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id n4sm3184606pfq.9.2020.06.30.09.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 09:31:21 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, paul@crapouillou.net, s-anna@ti.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] remoteproc: ingenic: Move clock handling to prepare/unprepare callbacks Date: Tue, 30 Jun 2020 10:31:17 -0600 Message-Id: <20200630163118.3830422-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200630163118.3830422-1-mathieu.poirier@linaro.org> References: <20200630163118.3830422-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This patch moves clock related operations to the remoteproc prepare() and unprepare() callbacks so that the PM runtime framework doesn't have to be involved needlessly. This provides a simpler approach and requires less code. Based on the work from Paul Cercueil published here: https://lore.kernel.org/linux-remoteproc/20191116170846.67220-4-paul@crapouillou.net/ Signed-off-by: Mathieu Poirier Reviewed-by: Suman Anna --- drivers/remoteproc/ingenic_rproc.c | 84 +++++++++--------------------- 1 file changed, 26 insertions(+), 58 deletions(-) diff --git a/drivers/remoteproc/ingenic_rproc.c b/drivers/remoteproc/ingenic_rproc.c index 189020d77b25..b0fc8eace6ec 100644 --- a/drivers/remoteproc/ingenic_rproc.c +++ b/drivers/remoteproc/ingenic_rproc.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "remoteproc_internal.h" @@ -62,6 +61,28 @@ struct vpu { struct device *dev; }; +static int ingenic_rproc_prepare(struct rproc *rproc) +{ + struct vpu *vpu = rproc->priv; + int ret; + + /* The clocks must be enabled for the firmware to be loaded in TCSM */ + ret = clk_bulk_prepare_enable(ARRAY_SIZE(vpu->clks), vpu->clks); + if (ret) + dev_err(vpu->dev, "Unable to start clocks: %d", ret); + + return ret; +} + +static int ingenic_rproc_unprepare(struct rproc *rproc) +{ + struct vpu *vpu = rproc->priv; + + clk_bulk_disable_unprepare(ARRAY_SIZE(vpu->clks), vpu->clks); + + return 0; +} + static int ingenic_rproc_start(struct rproc *rproc) { struct vpu *vpu = rproc->priv; @@ -115,6 +136,8 @@ static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len) } static struct rproc_ops ingenic_rproc_ops = { + .prepare = ingenic_rproc_prepare, + .unprepare = ingenic_rproc_unprepare, .start = ingenic_rproc_start, .stop = ingenic_rproc_stop, .kick = ingenic_rproc_kick, @@ -135,16 +158,6 @@ static irqreturn_t vpu_interrupt(int irq, void *data) return rproc_vq_interrupt(rproc, vring); } -static void ingenic_rproc_disable_clks(void *data) -{ - struct vpu *vpu = data; - - pm_runtime_resume(vpu->dev); - pm_runtime_disable(vpu->dev); - - clk_bulk_disable_unprepare(ARRAY_SIZE(vpu->clks), vpu->clks); -} - static int ingenic_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -206,35 +219,13 @@ static int ingenic_rproc_probe(struct platform_device *pdev) disable_irq(vpu->irq); - /* The clocks must be enabled for the firmware to be loaded in TCSM */ - ret = clk_bulk_prepare_enable(ARRAY_SIZE(vpu->clks), vpu->clks); - if (ret) { - dev_err(dev, "Unable to start clocks\n"); - return ret; - } - - pm_runtime_irq_safe(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - pm_runtime_get_sync(dev); - pm_runtime_use_autosuspend(dev); - - ret = devm_add_action_or_reset(dev, ingenic_rproc_disable_clks, vpu); - if (ret) { - dev_err(dev, "Unable to register action\n"); - goto out_pm_put; - } - ret = devm_rproc_add(dev, rproc); if (ret) { dev_err(dev, "Failed to register remote processor\n"); - goto out_pm_put; + return ret; } -out_pm_put: - pm_runtime_put_autosuspend(dev); - - return ret; + return 0; } static const struct of_device_id ingenic_rproc_of_matches[] = { @@ -243,33 +234,10 @@ static const struct of_device_id ingenic_rproc_of_matches[] = { }; MODULE_DEVICE_TABLE(of, ingenic_rproc_of_matches); -static int __maybe_unused ingenic_rproc_suspend(struct device *dev) -{ - struct vpu *vpu = dev_get_drvdata(dev); - - clk_bulk_disable(ARRAY_SIZE(vpu->clks), vpu->clks); - - return 0; -} - -static int __maybe_unused ingenic_rproc_resume(struct device *dev) -{ - struct vpu *vpu = dev_get_drvdata(dev); - - return clk_bulk_enable(ARRAY_SIZE(vpu->clks), vpu->clks); -} - -static const struct dev_pm_ops __maybe_unused ingenic_rproc_pm = { - SET_RUNTIME_PM_OPS(ingenic_rproc_suspend, ingenic_rproc_resume, NULL) -}; - static struct platform_driver ingenic_rproc_driver = { .probe = ingenic_rproc_probe, .driver = { .name = "ingenic-vpu", -#ifdef CONFIG_PM - .pm = &ingenic_rproc_pm, -#endif .of_match_table = ingenic_rproc_of_matches, }, }; From patchwork Tue Jun 30 16:31:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11634381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4351C739 for ; Tue, 30 Jun 2020 16:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C21C2074F for ; Tue, 30 Jun 2020 16:31:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qkso+Mi+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388286AbgF3Qb2 (ORCPT ); Tue, 30 Jun 2020 12:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388193AbgF3QbX (ORCPT ); Tue, 30 Jun 2020 12:31:23 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 025D2C03E97A for ; Tue, 30 Jun 2020 09:31:23 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h22so9705188pjf.1 for ; Tue, 30 Jun 2020 09:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kSFl/PPm+laMZYzO9Qtv6/OB8Vc89JQ/oHAdPk57qm8=; b=qkso+Mi+qizQchWvUN3dG7Wi4ZOVa62pZ2tRLklIqmByJxOpPpQDM3TxIA3P9NZjNy 4ukXOfnIU20yYItRqCnRqwyqH0B5KMEO13xuF3HOLgDL63XwbVtaV8qfHf8UdizPZ2uk XodigXIm9T/CTu5zSaMBmAIFoSpViGDEeviLsLv7R0KP3s0q6ztcltNXz4kiQWMWRtyH MQdZcevN15+Di7TJ7MwTz0AtL/ZAhH3FwZssIj8vpy8rCZAwczKwTTQGvYRD7JA/SFif gnG9Do1eevxfhk5LMrFl6PEguRBnypXAouv2MEzGDZFfv4lgi95JfxuzNGoyb0QiqZ04 PKXQ== 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=kSFl/PPm+laMZYzO9Qtv6/OB8Vc89JQ/oHAdPk57qm8=; b=GGxBVpFdCUvBLg8T/7wXBW/55gVCM0tTY7M1CbVtaHRLJ3JlVWdf/LkuRVtmYajkrM 5uNkTfFzXy254l3vz8sRADOtim9d1+1y8qylKoI6qMTyLwAJepWGGKHykTN7EWuGcCH3 o9C6YLgSp4zHvrdQOV3VYkp73pA96u3kmCoL5uOwb/2p/imMXhDZG4Z9QFXRug2W2zM8 N+H0iVpMvzucOdL97iwqaLP6CbtRyLc2uhU005PmlxxdgSsOLA6bU+rSU5xrmnwSYLMh di7YtkkPZZf94UrlIuNsEZnoVZ+UEU8WqSxqQfQayViRPolAuTUrpoOfqjvytNBf09i+ l9vA== X-Gm-Message-State: AOAM530y8/lzqIUAvlk5+Gu+cMq/m37sRZCor3L/RQPKQtmYk7QjyLgw R3NRWdUG6K2FQmftPqs/yQauSw== X-Google-Smtp-Source: ABdhPJyaJKMQeRKv2cqPQNBgC/3/uMn/MxqcTdfzfmnQ4Lz4DpxXj9L22s5atSLvhitAiasA5H0RtA== X-Received: by 2002:a17:902:b095:: with SMTP id p21mr17521475plr.4.1593534682551; Tue, 30 Jun 2020 09:31:22 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id n4sm3184606pfq.9.2020.06.30.09.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 09:31:22 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, paul@crapouillou.net, s-anna@ti.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Revert "remoteproc: Add support for runtime PM" Date: Tue, 30 Jun 2020 10:31:18 -0600 Message-Id: <20200630163118.3830422-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200630163118.3830422-1-mathieu.poirier@linaro.org> References: <20200630163118.3830422-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This reverts commit a99a37f6cd5a74d5b22c08544aa6c5890813c8ba. Removing PM runtime operations from the remoteproc core in order to: 1) Keep all power management operations in platform drivers. That way we do not loose flexibility in an area that is very HW specific. 2) Avoid making the support for remote processor managed by external entities more complex that it already is. 3) Fix regression introduced for the Omap remoteproc driver. Signed-off-by: Mathieu Poirier Tested-by: Suman Anna Acked-by: Suman Anna --- drivers/remoteproc/remoteproc_core.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9f04c30c4aaf..0f95e025ba03 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -1383,12 +1382,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) if (ret) return ret; - ret = pm_runtime_get_sync(dev); - if (ret < 0) { - dev_err(dev, "pm_runtime_get_sync failed: %d\n", ret); - return ret; - } - dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size); /* @@ -1398,7 +1391,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ret = rproc_enable_iommu(rproc); if (ret) { dev_err(dev, "can't enable iommu: %d\n", ret); - goto put_pm_runtime; + return ret; } /* Prepare rproc for firmware loading if needed */ @@ -1452,8 +1445,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) rproc_unprepare_device(rproc); disable_iommu: rproc_disable_iommu(rproc); -put_pm_runtime: - pm_runtime_put(dev); return ret; } @@ -1891,8 +1882,6 @@ void rproc_shutdown(struct rproc *rproc) rproc_disable_iommu(rproc); - pm_runtime_put(dev); - /* Free the copy of the resource table */ kfree(rproc->cached_table); rproc->cached_table = NULL; @@ -2183,9 +2172,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->state = RPROC_OFFLINE; - pm_runtime_no_callbacks(&rproc->dev); - pm_runtime_enable(&rproc->dev); - return rproc; put_device: @@ -2205,7 +2191,6 @@ EXPORT_SYMBOL(rproc_alloc); */ void rproc_free(struct rproc *rproc) { - pm_runtime_disable(&rproc->dev); put_device(&rproc->dev); } EXPORT_SYMBOL(rproc_free);