From patchwork Tue Feb 1 14:04:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12731766 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 54A68C433F5 for ; Tue, 1 Feb 2022 14:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239031AbiBAOET (ORCPT ); Tue, 1 Feb 2022 09:04:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237314AbiBAOES (ORCPT ); Tue, 1 Feb 2022 09:04:18 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188D4C06173B for ; Tue, 1 Feb 2022 06:04:18 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id q204so21271623iod.8 for ; Tue, 01 Feb 2022 06:04:18 -0800 (PST) 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=MLEfOvs0XYTBMi37IYE0nxh2vKRdvGYr4hL4oQxHa8M=; b=Xj2bWEPqf/2o6pjwC5MIf9Pl3NxXOWzz7BeXYgtgm6Hus2Yg3a3j6lvS6Mh3MLMWjl XZmowq6m0Cg4I3jz80YK4GAhyGfB0jX6GvuIgpX7SSW8WYS67i51CLR1n6D3j6I8GJqS V7c8maJhi0BoIbeuo0Hfequvnf3k/jSCe2xoP6YmCFlXoNIHYA7XIj5jopwozViiO6eA /53is8M4gdf+L0/2kcthNDduO/rRUO9wW0b6zMjoi6J6UWvxb675WqEg2VTrCz5HAr2H gIlzofTgo1XmStIAR0OHYFAeYFl/+B5WySuRTnNkh3X2g2zLOfEE6ZAJH0P+h0dvYd1m 2L1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MLEfOvs0XYTBMi37IYE0nxh2vKRdvGYr4hL4oQxHa8M=; b=CVolSaUiGrIRnOfzjwYXF04pjInzSsGJEs2oT5rOgHsKTyd+A2/rLPBbzxmGENSba+ wwuqC7rMXS+sPdKyzJ3CjlN/JTUcNBh1bPTJNAleiUas6YPiLxyctIAdRwP32OrEKsMk ZjvJfdsgqMcdUYEC9BL76zZEpTNplIfjozDLmu7UcNZtyOG0bwQV/CTy7KoammZPCoS+ UR+CQVaozIOzy6YednznZWyDOf6nssdi/Z9pK7jTMwm97DDAhOXrPx8Loh5qQdV1cypz cgCUgxVkPZVaZ1GviyS1k92wlWIQkHOiWTnj0WqSg3skBhKUWdW62arXcECZ8Ze3lNzr JSmA== X-Gm-Message-State: AOAM531fRaHqdB9dLyQ2qNW3gMcs/WgcLhiIJwoI6kgnY6rri0xiEvWW owU2AJE6/LdmVd9MinocCDYZJWGaXlUwM5V2 X-Google-Smtp-Source: ABdhPJzhJCQkilBeE2UUjay3h4zAOk49+hyIXb1Kon58qZEntbRNmrkJBEYbHMuFuxnSqthW9Q+BeA== X-Received: by 2002:a05:6602:2207:: with SMTP id n7mr13354260ion.89.1643724257507; Tue, 01 Feb 2022 06:04:17 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id o7sm189267ilo.17.2022.02.01.06.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 06:04:16 -0800 (PST) From: Alex Elder To: robh+dt@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/2] dt-bindings: net: qcom,ipa: add optional qcom,qmp property Date: Tue, 1 Feb 2022 08:04:11 -0600 Message-Id: <20220201140412.467233-2-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220201140412.467233-1-elder@linaro.org> References: <20220201140412.467233-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org For some systems, the IPA driver must make a request to ensure that its registers are retained across power collapse of the IPA hardware. On such systems, we'll use the existence of the "qcom,qmp" property as a signal that this request is required. Signed-off-by: Alex Elder --- Documentation/devicetree/bindings/net/qcom,ipa.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/net/qcom,ipa.yaml b/Documentation/devicetree/bindings/net/qcom,ipa.yaml index b86edf67ce626..58ecc62adfaae 100644 --- a/Documentation/devicetree/bindings/net/qcom,ipa.yaml +++ b/Documentation/devicetree/bindings/net/qcom,ipa.yaml @@ -107,6 +107,10 @@ properties: - const: imem - const: config + qcom,qmp: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle to the AOSS side-channel message RAM + qcom,smem-states: $ref: /schemas/types.yaml#/definitions/phandle-array description: State bits used in by the AP to signal the modem. @@ -222,6 +226,8 @@ examples: "imem", "config"; + qcom,qmp = <&aoss_qmp>; + qcom,smem-states = <&ipa_smp2p_out 0>, <&ipa_smp2p_out 1>; qcom,smem-state-names = "ipa-clock-enabled-valid", From patchwork Tue Feb 1 14:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12731767 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 D309BC433FE for ; Tue, 1 Feb 2022 14:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239023AbiBAOEV (ORCPT ); Tue, 1 Feb 2022 09:04:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239019AbiBAOET (ORCPT ); Tue, 1 Feb 2022 09:04:19 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A23C061714 for ; Tue, 1 Feb 2022 06:04:19 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id e8so14330065ilm.13 for ; Tue, 01 Feb 2022 06:04:19 -0800 (PST) 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=Psa2zXq9CIoesnxGhdNYAKpIpdpvJqYiAj5N20pw5fs=; b=R8Gd32zO+ggkJZzrzU+J+0CiBHwvzbqTSr+wXkInM/YxdBHTEEtuuaftMihGG2cS/B 5Z2/ylVm32KvgG3Ayj1VO/ih6Fd3/7DrV5/VgjMNj11lcmLroHbCHszyTCzqCr6X7pba i/3lWrNpFGokrgzcrdoefzMJyyFkJqHZZ3XP/mmlyPUw/fBnoxw0oc/5i+WrCnok41gc svcZeW0kF9pxzX2z9AIDSEbFPzXOHndV0cO3jE9fIuupukohnp/paCsgTMgQMpcUu3yy 2DOecvZXoN2lXTh1FUVAFTIiYQdxMVMOCi1PBmsAb/jdtoDJ3+HSXG2Nr5p4KheXFY1/ UJZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Psa2zXq9CIoesnxGhdNYAKpIpdpvJqYiAj5N20pw5fs=; b=N1y9fgIA1e+xqdYtHwbPMpLCZVmk1ClaTlm7R1JrabEktCaJHDA6VbR1yzVeBEEMrw xYJlEH3pX6A53WLg6qQxz9wvajuvvIKIAY4b4yk+cve11ml+/cT3rSnaoYFD8gpMznPf TMc5IlpNFFqyVkUcpglf9oC0kBoEdDSEbQx2OXw3nV7axfCOuGRhAV6QnbslTaYekytr zkZepamJxOiOe13YspsIZsKLVHEXorj5xFw4jbFxoCMTvXnOk587IehwjS+330MH7aHC b4SSQxKgfeqmRtIDf1SKtu/+1QOWhPPFSlZuzBoiEeu5OjhEJNzMyFTFsBRzFGRLK62O rNcg== X-Gm-Message-State: AOAM533Cbx0Us+Jc/OqcrjhfDleds8y7tJ9+lbXiIPdYgIdXQxIj1jVB iFav6oNYvh9yZDMOzHW8XyROaQ== X-Google-Smtp-Source: ABdhPJzMLsyTQsL9D/NRUWKyaKgw+jTPGTo79naKeZcc8sPfZKroTxE949/sAwmyRdHA3jFNDov/7Q== X-Received: by 2002:a05:6e02:1c42:: with SMTP id d2mr2369514ilg.97.1643724258819; Tue, 01 Feb 2022 06:04:18 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id o7sm189267ilo.17.2022.02.01.06.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 06:04:18 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: robh+dt@kernel.org, bjorn.andersson@linaro.org, agross@kernel.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 2/2] net: ipa: request IPA register values be retained Date: Tue, 1 Feb 2022 08:04:12 -0600 Message-Id: <20220201140412.467233-3-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220201140412.467233-1-elder@linaro.org> References: <20220201140412.467233-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In some cases, the IPA hardware needs to request the always-on subsystem (AOSS) to coordinate with the IPA microcontroller to retain IPA register values at power collapse. This is done by issuing a QMP request to the AOSS microcontroller. A similar request ondoes that request. We must get and hold the "QMP" handle early, because we might get back EPROBE_DEFER for that. But the actual request should be sent while we know the IPA clock is active, and when we know the microcontroller is operational. Fixes: 2775cbc5afeb6 ("net: ipa: rename "ipa_clock.c"") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 52 +++++++++++++++++++++++++++++++++++++ drivers/net/ipa/ipa_power.h | 7 +++++ drivers/net/ipa/ipa_uc.c | 5 ++++ 3 files changed, 64 insertions(+) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index b1c6c0fcb654f..f2989aac47a62 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -11,6 +11,8 @@ #include #include +#include "linux/soc/qcom/qcom_aoss.h" + #include "ipa.h" #include "ipa_power.h" #include "ipa_endpoint.h" @@ -64,6 +66,7 @@ enum ipa_power_flag { * struct ipa_power - IPA power management information * @dev: IPA device pointer * @core: IPA core clock + * @qmp: QMP handle for AOSS communication * @spinlock: Protects modem TX queue enable/disable * @flags: Boolean state flags * @interconnect_count: Number of elements in interconnect[] @@ -72,6 +75,7 @@ enum ipa_power_flag { struct ipa_power { struct device *dev; struct clk *core; + struct qmp *qmp; spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; @@ -382,6 +386,47 @@ void ipa_power_modem_queue_active(struct ipa *ipa) clear_bit(IPA_POWER_FLAG_STARTED, ipa->power->flags); } +static int ipa_power_retention_init(struct ipa_power *power) +{ + struct qmp *qmp = qmp_get(power->dev); + + if (IS_ERR(qmp)) { + if (PTR_ERR(qmp) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + /* We assume any other error means it's not defined/needed */ + qmp = NULL; + } + power->qmp = qmp; + + return 0; +} + +static void ipa_power_retention_exit(struct ipa_power *power) +{ + qmp_put(power->qmp); + power->qmp = NULL; +} + +/* Control register retention on power collapse */ +void ipa_power_retention(struct ipa *ipa, bool enable) +{ + static const char fmt[] = "{ class: bcm, res: ipa_pc, val: %c }"; + struct ipa_power *power = ipa->power; + char buf[36]; /* Exactly enough for fmt[]; size a multiple of 4 */ + int ret; + + if (!power->qmp) + return; /* Not needed on this platform */ + + (void)snprintf(buf, sizeof(buf), fmt, enable ? '1' : '0'); + + ret = qmp_send(power->qmp, buf, sizeof(buf)); + if (ret) + dev_err(power->dev, "error %d sending QMP %sable request\n", + ret, enable ? "en" : "dis"); +} + int ipa_power_setup(struct ipa *ipa) { int ret; @@ -438,12 +483,18 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) if (ret) goto err_kfree; + ret = ipa_power_retention_init(power); + if (ret) + goto err_interconnect_exit; + pm_runtime_set_autosuspend_delay(dev, IPA_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); return power; +err_interconnect_exit: + ipa_interconnect_exit(power); err_kfree: kfree(power); err_clk_put: @@ -460,6 +511,7 @@ void ipa_power_exit(struct ipa_power *power) pm_runtime_disable(dev); pm_runtime_dont_use_autosuspend(dev); + ipa_power_retention_exit(power); ipa_interconnect_exit(power); kfree(power); clk_put(clk); diff --git a/drivers/net/ipa/ipa_power.h b/drivers/net/ipa/ipa_power.h index 2151805d7fbb0..6f84f057a2095 100644 --- a/drivers/net/ipa/ipa_power.h +++ b/drivers/net/ipa/ipa_power.h @@ -40,6 +40,13 @@ void ipa_power_modem_queue_wake(struct ipa *ipa); */ void ipa_power_modem_queue_active(struct ipa *ipa); +/** + * ipa_power_retention() - Control register retention on power collapse + * @ipa: IPA pointer + * @enable: Whether retention should be enabled or disabled + */ +void ipa_power_retention(struct ipa *ipa, bool enable); + /** * ipa_power_setup() - Set up IPA power management * @ipa: IPA pointer diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 856e55a080a7f..fe11910518d95 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -11,6 +11,7 @@ #include "ipa.h" #include "ipa_uc.h" +#include "ipa_power.h" /** * DOC: The IPA embedded microcontroller @@ -154,6 +155,7 @@ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) case IPA_UC_RESPONSE_INIT_COMPLETED: if (ipa->uc_powered) { ipa->uc_loaded = true; + ipa_power_retention(ipa, true); pm_runtime_mark_last_busy(dev); (void)pm_runtime_put_autosuspend(dev); ipa->uc_powered = false; @@ -184,6 +186,9 @@ void ipa_uc_deconfig(struct ipa *ipa) ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); + if (ipa->uc_loaded) + ipa_power_retention(ipa, false); + if (!ipa->uc_powered) return;