From patchwork Tue Aug 10 19:26:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494378 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264446jap; Tue, 10 Aug 2021 12:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDpOtUntqxRKphIR5Kmf9K7k9v4NNK/SrwQjE4UX//F2qTTyczJDQvC3h+GHZLuSYI8Y4g X-Received: by 2002:a02:5107:: with SMTP id s7mr28883221jaa.65.1628623634994; Tue, 10 Aug 2021 12:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623634; cv=none; d=google.com; s=arc-20160816; b=MYU/9Ytxl3y9quQfpT5lKWnaWjGknLtH4aV7pNkYRSGJfg5Q13hNNGiRJkHi1id+SO WIFU52OLNmudTpS6CTo2TSWY72ZVn7UUEjZ4dmBjFBEZ0Y+GWp8beJGR197enYTMWxVI S3j/C8LMGe11aiW4WySqUOhPno3rNzm+RNCHSI8XuUQbx4F58I1+2ahns1SRl/OrCESQ NoveZcu0jBZTIEP6IlPJJbPCUfQOrR2/787icIwTiKhxqNwaxwhNOoQxDeiWsUYAyEAm pqcobfdgcyIEwVBLNZa+JYP/KugD5g6yg0I5RWipqB2AVP2GWgMUApOywFSSepaUnPDY NqLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tejswFKJ+fSM+4wn7Zu/HrCpQ8GGzNEx5c69sEqueIA=; b=qAPLAvDROayU34oy849Pnx58WWVFKi9UEfyR8PkKqVxOPDlStm27fQAyzzyZOu6R/p VQzfcXxSH/fxFHUNI8M3E/KHqQh96OcWtf2FZBtNnMQThzbe8a64i/TDM2KdMXekizr8 9s17wDm0JgL0LWa297u7sARSPanXdnafFMVyIXiEDaUIMttLx3wSkjmDeE+hAT2cmmMo vaYLck6Xe2PsL6FDtt8NtqRKOVf1wJURgM7cDKwL2COMf1gBomYjUS+dMmMJTBA+mOVg oTgDxJDgBpV/CBT2Dv4+vH5aVP2nhjl9Wiq4ucxbSNVdwwaqtKrclOQfOCBAXX92bq8B r0/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RYlzrTPq; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.14; Tue, 10 Aug 2021 12:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RYlzrTPq; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232717AbhHJT1f (ORCPT + 8 others); Tue, 10 Aug 2021 15:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232473AbhHJT1a (ORCPT ); Tue, 10 Aug 2021 15:27:30 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84755C0613D3 for ; Tue, 10 Aug 2021 12:27:08 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id a4so145510ilj.12 for ; Tue, 10 Aug 2021 12:27:08 -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=tejswFKJ+fSM+4wn7Zu/HrCpQ8GGzNEx5c69sEqueIA=; b=RYlzrTPqEkv+pZFjFuRcC5IbA0FsSkgAiIwEmZcRpadMl3/rwsvy35AiWE/SZ4Yk5z 0myIEAoT77moh28NtF/9TlSbDo0oaQYI6+av3TCkoOintlhyafsmJ3I4XtNK+v3OlT70 VGOAvxLZQsAv2f4DV/jeHYnMZHZ/HkbTs9Rw5paWuBjXYDZy5OWYDld+aNb5UznM79+4 b3zqgNSIuQfTqZfJTTsvHhwlekcj8dqCBT0qpC/bZavw9scncb9gtv0DNV5nxv7CoHNG 7wNYT1o2lBRRFXblhHh4AY4OkZvoAzBu3mKk1FribUTCzaXpjkAhXsXUHQiadDvpBC0x GZSQ== 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=tejswFKJ+fSM+4wn7Zu/HrCpQ8GGzNEx5c69sEqueIA=; b=cHZDTxceeR+GtPKVqf8fuLeJ6prLLNizzhhvUPm5JiKqpHtrvWtj906zr3h27p3Hyo 1V9XknbHw3B3x2Nn9W3L+OnfBIDzxtD4lNibuz0rHrAudtkh2vOXLWlGCRltmsa5VLfG yt0T7atmqb24BHVz8pJ7Y6JCgZ8II5R7kNTIIR1QgyLykM/seJQXY+4UAdJ2JiE5rt/T f8Tz92psBuZQ36McSFRWEtksQId9WQt+wZSXcJONkb2W/v6tPvVoP1UhfxwgAHuFLSkn x8g+GwvOASMpkf52Spot/mn3aVf0D0iVBj1dMjcYTzYvXufl2UzL+0tgb9t63ng1l/zG HWdg== X-Gm-Message-State: AOAM531BA8VyQBXsa4CgtqXWR4SED/L+nOVPCwnosz0kGJupmjbEQ7Z9 yEYexbQ2hqKbHoe5+/jXrQG9Qw== X-Received: by 2002:a05:6e02:1047:: with SMTP id p7mr179109ilj.125.1628623627817; Tue, 10 Aug 2021 12:27:07 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:07 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/7] net: ipa: have ipa_clock_get() return a value Date: Tue, 10 Aug 2021 14:26:58 -0500 Message-Id: <20210810192704.2476461-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We currently assume no errors occur when enabling or disabling the IPA core clock and interconnects. And although this commit exposes errors that could occur, we generally assume this won't happen in practice. This commit changes ipa_clock_get() and ipa_clock_put() so each returns a value. The values returned are meant to mimic what the runtime power management functions return, so we can set up error handling here before we make the switch. Have ipa_clock_get() increment the reference count even if it returns an error, to match the behavior of pm_runtime_get(). More details follow. When taking a reference in ipa_clock_get(), return 0 for the first reference, 1 for subsequent references, or a negative error code if an error occurs. Note that if ipa_clock_get() returns an error, we must not touch hardware; in some cases such errors now cause entire blocks of code to be skipped. When dropping a reference in ipa_clock_put(), we return 0 or an error code. The error would come from ipa_clock_disable(), which now returns what ipa_interconnect_disable() returns (either 0 or a negative error code). For now, callers ignore the return value; if an error occurs, a message will have already been logged, and little more can actually be done to improve the situation. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 44 +++++++++++++++++++++------------ drivers/net/ipa/ipa_clock.h | 14 ++++++++--- drivers/net/ipa/ipa_interrupt.c | 9 ++++--- drivers/net/ipa/ipa_main.c | 36 ++++++++++++++++----------- drivers/net/ipa/ipa_modem.c | 15 +++++++---- drivers/net/ipa/ipa_smp2p.c | 28 +++++++++++---------- drivers/net/ipa/ipa_uc.c | 12 ++++++--- 7 files changed, 99 insertions(+), 59 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index a67b6136e3c01..d5a8b45ee59d1 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -223,10 +223,11 @@ static int ipa_clock_enable(struct ipa *ipa) } /* Inverse of ipa_clock_enable() */ -static void ipa_clock_disable(struct ipa *ipa) +static int ipa_clock_disable(struct ipa *ipa) { clk_disable_unprepare(ipa->clock->core); - (void)ipa_interconnect_disable(ipa); + + return ipa_interconnect_disable(ipa); } /* Get an IPA clock reference, but only if the reference count is @@ -246,43 +247,51 @@ bool ipa_clock_get_additional(struct ipa *ipa) * Incrementing the reference count is intentionally deferred until * after the clock is running and endpoints are resumed. */ -void ipa_clock_get(struct ipa *ipa) +int ipa_clock_get(struct ipa *ipa) { struct ipa_clock *clock = ipa->clock; int ret; /* If the clock is running, just bump the reference count */ if (ipa_clock_get_additional(ipa)) - return; + return 1; /* Otherwise get the mutex and check again */ mutex_lock(&clock->mutex); /* A reference might have been added before we got the mutex. */ - if (ipa_clock_get_additional(ipa)) + if (ipa_clock_get_additional(ipa)) { + ret = 1; goto out_mutex_unlock; + } ret = ipa_clock_enable(ipa); - if (!ret) - refcount_set(&clock->count, 1); + + refcount_set(&clock->count, 1); + out_mutex_unlock: mutex_unlock(&clock->mutex); + + return ret; } /* Attempt to remove an IPA clock reference. If this represents the * last reference, disable the IPA clock under protection of the mutex. */ -void ipa_clock_put(struct ipa *ipa) +int ipa_clock_put(struct ipa *ipa) { struct ipa_clock *clock = ipa->clock; + int ret; /* If this is not the last reference there's nothing more to do */ if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex)) - return; + return 0; - ipa_clock_disable(ipa); + ret = ipa_clock_disable(ipa); mutex_unlock(&clock->mutex); + + return ret; } /* Return the current IPA core clock rate */ @@ -388,7 +397,7 @@ void ipa_clock_exit(struct ipa_clock *clock) * ipa_suspend() - Power management system suspend callback * @dev: IPA device structure * - * Return: Always returns zero + * Return: 0 on success, or a negative error code * * Called by the PM framework when a system suspend operation is invoked. * Suspends endpoints and releases the clock reference held to keep @@ -405,16 +414,14 @@ static int ipa_suspend(struct device *dev) gsi_suspend(&ipa->gsi); } - ipa_clock_put(ipa); - - return 0; + return ipa_clock_put(ipa); } /** * ipa_resume() - Power management system resume callback * @dev: IPA device structure * - * Return: Always returns 0 + * Return: 0 on success, or a negative error code * * Called by the PM framework when a system resume operation is invoked. * Takes an IPA clock reference to keep the clock running until suspend, @@ -423,11 +430,16 @@ static int ipa_suspend(struct device *dev) static int ipa_resume(struct device *dev) { struct ipa *ipa = dev_get_drvdata(dev); + int ret; /* This clock reference will keep the IPA out of suspend * until we get a power management suspend request. */ - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) { + (void)ipa_clock_put(ipa); + return ret; + } /* Endpoints aren't usable until setup is complete */ if (ipa->setup_complete) { diff --git a/drivers/net/ipa/ipa_clock.h b/drivers/net/ipa/ipa_clock.h index 2a0f7ff3c9e64..8692c0d98bd1c 100644 --- a/drivers/net/ipa/ipa_clock.h +++ b/drivers/net/ipa/ipa_clock.h @@ -54,14 +54,20 @@ void ipa_clock_exit(struct ipa_clock *clock); * ipa_clock_get() - Get an IPA clock reference * @ipa: IPA pointer * - * This call blocks if this is the first reference. + * Return: 0 if clock started, 1 if clock already running, or a negative + * error code + * + * This call blocks if this is the first reference. A reference is + * taken even if an error occurs starting the IPA clock. */ -void ipa_clock_get(struct ipa *ipa); +int ipa_clock_get(struct ipa *ipa); /** * ipa_clock_get_additional() - Get an IPA clock reference if not first * @ipa: IPA pointer * + * Return: true if reference taken, false otherwise + * * This returns immediately, and only takes a reference if not the first */ bool ipa_clock_get_additional(struct ipa *ipa); @@ -70,10 +76,12 @@ bool ipa_clock_get_additional(struct ipa *ipa); * ipa_clock_put() - Drop an IPA clock reference * @ipa: IPA pointer * + * Return: 0 if successful, or a negative error code + * * This drops a clock reference. If the last reference is being dropped, * the clock is stopped and RX endpoints are suspended. This call will * not block unless the last reference is dropped. */ -void ipa_clock_put(struct ipa *ipa); +int ipa_clock_put(struct ipa *ipa); #endif /* _IPA_CLOCK_H_ */ diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index aa37f03f4557f..934c14e066a0a 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -83,8 +83,11 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id) u32 pending; u32 offset; u32 mask; + int ret; - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto out_clock_put; /* The status register indicates which conditions are present, * including conditions whose interrupt is not enabled. Handle @@ -112,8 +115,8 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id) offset = ipa_reg_irq_clr_offset(ipa->version); iowrite32(pending, ipa->reg_virt + offset); } - - ipa_clock_put(ipa); +out_clock_put: + (void)ipa_clock_put(ipa); return IRQ_HANDLED; } diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 25bbb456e0078..64112a6767743 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -431,7 +431,9 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) * is held after initialization completes, and won't get dropped * unless/until a system suspend request arrives. */ - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto err_clock_put; ipa_hardware_config(ipa, data); @@ -475,7 +477,8 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) ipa_mem_deconfig(ipa); err_hardware_deconfig: ipa_hardware_deconfig(ipa); - ipa_clock_put(ipa); +err_clock_put: + (void)ipa_clock_put(ipa); return ret; } @@ -493,7 +496,7 @@ static void ipa_deconfig(struct ipa *ipa) ipa->interrupt = NULL; ipa_mem_deconfig(ipa); ipa_hardware_deconfig(ipa); - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); } static int ipa_firmware_load(struct device *dev) @@ -750,20 +753,22 @@ static int ipa_probe(struct platform_device *pdev) goto err_table_exit; /* The clock needs to be active for config and setup */ - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto err_clock_put; ret = ipa_config(ipa, data); if (ret) - goto err_clock_put; /* Error */ + goto err_clock_put; dev_info(dev, "IPA driver initialized"); /* If the modem is doing early initialization, it will trigger a - * call to ipa_setup() call when it has finished. In that case - * we're done here. + * call to ipa_setup() when it has finished. In that case we're + * done here. */ if (modem_init) - goto out_clock_put; /* Done; no error */ + goto done; /* Otherwise we need to load the firmware and have Trust Zone validate * and install it. If that succeeds we can proceed with setup. @@ -775,16 +780,15 @@ static int ipa_probe(struct platform_device *pdev) ret = ipa_setup(ipa); if (ret) goto err_deconfig; - -out_clock_put: - ipa_clock_put(ipa); +done: + (void)ipa_clock_put(ipa); return 0; err_deconfig: ipa_deconfig(ipa); err_clock_put: - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); ipa_modem_exit(ipa); err_table_exit: ipa_table_exit(ipa); @@ -810,7 +814,9 @@ static int ipa_remove(struct platform_device *pdev) struct ipa_clock *clock = ipa->clock; int ret; - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto out_clock_put; if (ipa->setup_complete) { ret = ipa_modem_stop(ipa); @@ -826,8 +832,8 @@ static int ipa_remove(struct platform_device *pdev) } ipa_deconfig(ipa); - - ipa_clock_put(ipa); +out_clock_put: + (void)ipa_clock_put(ipa); ipa_modem_exit(ipa); ipa_table_exit(ipa); diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index ad4019e8016ec..06e44afd2cf66 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -45,7 +45,9 @@ static int ipa_open(struct net_device *netdev) struct ipa *ipa = priv->ipa; int ret; - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto err_clock_put; ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); if (ret) @@ -62,7 +64,7 @@ static int ipa_open(struct net_device *netdev) err_disable_tx: ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); err_clock_put: - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); return ret; } @@ -78,7 +80,7 @@ static int ipa_stop(struct net_device *netdev) ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); return 0; } @@ -297,7 +299,9 @@ static void ipa_modem_crashed(struct ipa *ipa) struct device *dev = &ipa->pdev->dev; int ret; - ipa_clock_get(ipa); + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto out_clock_put; ipa_endpoint_modem_pause_all(ipa, true); @@ -324,7 +328,8 @@ static void ipa_modem_crashed(struct ipa *ipa) if (ret) dev_err(dev, "error %d zeroing modem memory regions\n", ret); - ipa_clock_put(ipa); +out_clock_put: + (void)ipa_clock_put(ipa); } static int ipa_modem_notify(struct notifier_block *nb, unsigned long action, diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c index 0d15438a79e2d..f84d6523636e3 100644 --- a/drivers/net/ipa/ipa_smp2p.c +++ b/drivers/net/ipa/ipa_smp2p.c @@ -150,24 +150,26 @@ static void ipa_smp2p_panic_notifier_unregister(struct ipa_smp2p *smp2p) static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id) { struct ipa_smp2p *smp2p = dev_id; + int ret; mutex_lock(&smp2p->mutex); - if (!smp2p->disabled) { - int ret; + if (smp2p->disabled) + goto out_mutex_unlock; + smp2p->disabled = true; /* If any others arrive, ignore them */ - /* The clock needs to be active for setup */ - ipa_clock_get(smp2p->ipa); + /* The clock needs to be active for setup */ + ret = ipa_clock_get(smp2p->ipa); + if (WARN_ON(ret < 0)) + goto out_clock_put; - ret = ipa_setup(smp2p->ipa); - if (ret) - dev_err(&smp2p->ipa->pdev->dev, - "error %d from ipa_setup()\n", ret); - smp2p->disabled = true; - - ipa_clock_put(smp2p->ipa); - } + /* An error here won't cause driver shutdown, so warn if one occurs */ + ret = ipa_setup(smp2p->ipa); + WARN(ret != 0, "error %d from ipa_setup()\n", ret); +out_clock_put: + (void)ipa_clock_put(smp2p->ipa); +out_mutex_unlock: mutex_unlock(&smp2p->mutex); return IRQ_HANDLED; @@ -206,7 +208,7 @@ static void ipa_smp2p_clock_release(struct ipa *ipa) if (!ipa->smp2p->clock_on) return; - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); ipa->smp2p->clock_on = false; } diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index f88ee02457d49..9c8818c390731 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -154,7 +154,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_clocked) { ipa->uc_loaded = true; - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); ipa->uc_clocked = false; } else { dev_warn(dev, "unexpected init_completed response\n"); @@ -182,21 +182,25 @@ 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_clocked) - ipa_clock_put(ipa); + (void)ipa_clock_put(ipa); } /* Take a proxy clock reference for the microcontroller */ void ipa_uc_clock(struct ipa *ipa) { static bool already; + int ret; if (already) return; already = true; /* Only do this on first boot */ /* This clock reference dropped in ipa_uc_response_hdlr() above */ - ipa_clock_get(ipa); - ipa->uc_clocked = true; + ret = ipa_clock_get(ipa); + if (WARN(ret < 0, "error %d getting proxy clock\n", ret)) + (void)ipa_clock_put(ipa); + + ipa->uc_clocked = ret >= 0; } /* Send a command to the microcontroller */ From patchwork Tue Aug 10 19:26:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494377 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264418jap; Tue, 10 Aug 2021 12:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsys+DfgCpZyaNyaB77tX3YL4ZDpchKuTw3yU4Xt5CQGe5MOADee9LlUHxbSw3z94qbgui X-Received: by 2002:a05:6638:3468:: with SMTP id q40mr28923123jav.117.1628623633202; Tue, 10 Aug 2021 12:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623633; cv=none; d=google.com; s=arc-20160816; b=q3nHmtDA0shKFGJFN6HejY27RmUJQxjRgsWdRV69oIoUB/LzUmGbiKQSZ9P+F4neon A4PftMKLdL8QSN9QCvbGLYt06oBurMSF+3Tie1/LerxagoCg9nSoZilOg8PfTMH+GykL yt3Za/ZZbIcqPgGcxPtXlrVJzm20+zVdQ2hOOKw3aOjwvRyUeUZ/DgCGTNkKzFki3RRu +Q/JLc2FNCEdEFkcCB4a/d4UjwsUnJSsdNfuKnCptBfCzSbA8M+pImkzA3ejiI4pS0Z6 PFP1nrh93/1pdO5dvznleHoDQ3kaarIkAsghejfMp2uV5fEhAojGDVUf8IJ1zg94JISa y9yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m7UrH6Lu6RFgMKSZzNICn6qFCfAM54XgBDQbFAy1V9I=; b=jkSuaeuL+Gh8uy6geqLi6Yq2tPrxqD4hqW5d/WC/zGmJoW8wqs0DK/w9im8iKUJuBn XwtloCVIK/A1/YOtZtxquNvq1YyqRiI0FLYQweRcll+w/W+nDmIIbxmlrlPQvuZVNRN+ GmiChrrty8lqBPzMkANifA8d66Md6yKK7ubc4SPcXgxEMg2E4MOu/j19HjzNj8h+/aDp Dp543VdkUjB4gj9KPfHJIAyQmbuGS80BH+B5FDLk1a7EItTwVygwPEGBGYF0g639knT7 Nxp4QPEqW/w55rmrukHbtsP3uc+C3Xim1mofvcSTYIZNrGJPmT4wptUkXh2CJXYFzMuq kueQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JcWF5d4X; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.13; Tue, 10 Aug 2021 12:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JcWF5d4X; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232664AbhHJT1d (ORCPT + 8 others); Tue, 10 Aug 2021 15:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232552AbhHJT1b (ORCPT ); Tue, 10 Aug 2021 15:27:31 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527DDC0613C1 for ; Tue, 10 Aug 2021 12:27:09 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id a4so145540ilj.12 for ; Tue, 10 Aug 2021 12:27:09 -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=m7UrH6Lu6RFgMKSZzNICn6qFCfAM54XgBDQbFAy1V9I=; b=JcWF5d4X2TO9r2glvm1MaRyb5qrHOgteLdlcnODRFO7ny4Csz4byiwmj31ZxdP5yjR OaGCxcbDskh/2mzO9XgYFJ8KolBgMN7OEteMG3BtLd5oRYBvKnvyjGDoI65jrHmAyjWF 6cGzp5YHYhyAH/aSe0+dN9R9NgtFMKsDUltsbFKLHh+utYivxfiG/WwRTGSiVxPrRqky Td2w18FXE9o6i8DiPVw4N5LYBQp9wbzt1LnybCAXXA5peeptF3MQk5LZFqPTed/Bg7ru POEZ0pHiZMARWAza/YAf471xlONGyxzQDjoW6H15FhubVhd7OYBhsHpBDbGXI3AGInmm Uu8g== 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=m7UrH6Lu6RFgMKSZzNICn6qFCfAM54XgBDQbFAy1V9I=; b=jGjaeqJ23ZEMU4Fr4mYGMi0ICYuBEcP1D2FmzuQ1bZfGtyRrhxqo43SEsRrH1eua7L uGnK9o4J1QR2AeZiTbIbNnIv1NA/9EomgItpQPjnEguONnibW53R2fiKLdNNP+s+2A7g 698bAtFpuxnlddhEW+DUe1NhtlgUpzJJNwJiQ5xNTjyT8hIb5htCAQMTqi3Zw3r2qUVL xh6Q7J8vTTUKdl542GWfK94Z7B5lpAsh9+GDyn6uCi0g6hfjHTEZ6ZUx68Hv+wgRt/rb GtIWT3+MPRTm60xffq7MZOWtTnedOyDDWM0Wj1wYHgrr7txOAbF5ACOj7RlfiiEmXZUO NXwA== X-Gm-Message-State: AOAM532vXljI0N0/bFgMFyCbTWZga+2x6uJrm7IEBx7Hc/8darm/AJ6F KerjiWwaqynFfHvMauHKwnaEOg== X-Received: by 2002:a92:c912:: with SMTP id t18mr360333ilp.152.1628623628748; Tue, 10 Aug 2021 12:27:08 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:08 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/7] net: ipa: disable clock in suspend Date: Tue, 10 Aug 2021 14:26:59 -0500 Message-Id: <20210810192704.2476461-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Disable the IPA clock rather than dropping a reference to it in the system suspend callback. This forces the suspend to occur without affecting existing references. Similarly, enable the clock rather than taking a reference in ipa_resume(), forcing a resume without changing the reference count. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index d5a8b45ee59d1..864991f7ba4b5 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -414,7 +414,7 @@ static int ipa_suspend(struct device *dev) gsi_suspend(&ipa->gsi); } - return ipa_clock_put(ipa); + return ipa_clock_disable(ipa); } /** @@ -432,14 +432,9 @@ static int ipa_resume(struct device *dev) struct ipa *ipa = dev_get_drvdata(dev); int ret; - /* This clock reference will keep the IPA out of suspend - * until we get a power management suspend request. - */ - ret = ipa_clock_get(ipa); - if (WARN_ON(ret < 0)) { - (void)ipa_clock_put(ipa); + ret = ipa_clock_enable(ipa); + if (WARN_ON(ret < 0)) return ret; - } /* Endpoints aren't usable until setup is complete */ if (ipa->setup_complete) { From patchwork Tue Aug 10 19:27:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494379 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264626jap; Tue, 10 Aug 2021 12:27:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRWzRK85K9VkQghzf8xJTfoDiuc0dg/w20fLN1hlAoSZX05loj8O5jQCvx34FR8gMooOQx X-Received: by 2002:a92:cf4a:: with SMTP id c10mr96235ilr.269.1628623650217; Tue, 10 Aug 2021 12:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623650; cv=none; d=google.com; s=arc-20160816; b=CO/4dptbvrE1KMA18SdjwzTHzgEvIQ7pqAAgyXHyUfhMoa+j2Q45cEItHjs55dkxlg flna9YYRc4IjBfZ9ipFAkm8vKoLMMj6pyaceEziYGPkPcpWyu/AAXz4SU8dLzFIwUMtH bllsUUGAiKdQCUyIwEMo4ySlbWxhxIrxU0obvQ7oVJ8moxw8hh4BJVcukCGJ7s5BlzD8 1RAE47mUR3BPVUeGQJ1gKvFQF2X6ymPmMqWUFFy+Njps5MJMaRxJsmK3exRUlbw0kjhg rE7h7QvXod2b7/CTzetGcLLTN2MxZ/CoLEYa2eEwrHP6IBs9Vic7j4hjweGIR/EQxFsT U2Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3RvnSI6p4fqV0uNcU76eKlSqoZMzH9RvMg7i8uWOHwQ=; b=zKIIBtTE/Fo95u/17ki3KUGRx+6R8IxdXv7X707JHDn2Swk5wFtyas4DTUx291ejoe laA8JCoL9shfIRWBoOFX/EVltYWxmxug/bXqf+C5LzUEvSbQ0RPV2MOrmM4JSVQx2e0/ aYlId8Kbr6zi1QJGrdIQ7wE1a5KfmYaH023icbA3z65QJpqsQRiS44SQq/H3By+O7f0H IuSJByddyFJweX1kxJxiEnEznfW54DrnWIvD9aHLWUCHXBSwnQMtSlifbInD8nXzbf37 c9LLBY5uBLWY1b/1XKl4yXZazlcmNLrc7hGydpBtowVWRbRoklvSHTTa5soLqTfamC/F 2XNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OHumJWb4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.30; Tue, 10 Aug 2021 12:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OHumJWb4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233077AbhHJT1v (ORCPT + 8 others); Tue, 10 Aug 2021 15:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232572AbhHJT1c (ORCPT ); Tue, 10 Aug 2021 15:27:32 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29FFBC0613D3 for ; Tue, 10 Aug 2021 12:27:10 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id i13so152547ilm.11 for ; Tue, 10 Aug 2021 12:27:10 -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=3RvnSI6p4fqV0uNcU76eKlSqoZMzH9RvMg7i8uWOHwQ=; b=OHumJWb4OpI6AuHu6FIXwC/YBm/ASJZ0cq2NnUihC0w98GhSEvXddr1zrsbYO+bf26 51tkuH4xzgOrerfYqHAgs4N7S95ZRHe72bfG3sJcUqAdo/27j2ioSwneMywYZpQw4oId UqJ6s1LwItJXSaq3+QXbht524Z7zV+i7YbGecHAaWs1ee2u+ZxgQrS9mnuGJhCGuTWHD xjQSnHeoZ4wcmvPrToSck26n5j4u0zdw4ofstqPXuffj51jKeJXnMOPcKQzk5u+2I7Fa 00z03HdGC3YrRVVHo+9KfRYpJmvSAw3VB/Pdew8YXrhmzXyTaInaAF34k+gyZ2vOZRQp rY6w== 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=3RvnSI6p4fqV0uNcU76eKlSqoZMzH9RvMg7i8uWOHwQ=; b=Xvwv8iii+UE1JFjiDzLpzC3izBhYzUrNZ13ZCiz8MSfBi+67ldYrYFAzA00esnJx0j xBnTpdiNznAR2oTuhdh+jXPXuIzxEzftlnEgReLjpf4fmDavtK0EHHGCoj78AQWV7Qp8 QEVzaFD+os9GcYpjjRYW6Aj2lb5Ol9FQAzD3tzllnJgXT/bP+ljGfgvSXPoWX6a1Is+b DZXvVWa0GQwSULQxrRlktciY/HwZBmW5/VZQ+hqAnndh+mwKKwHBbR7ekyOtsCrFqcvR dIU8KjZyuwCkN65/adgz4LjDiw3J8WF38BtWH30uonyfJRZjXJ2kb58GSTnMWzfGCI+/ D7TA== X-Gm-Message-State: AOAM532tiwO9RJhk6hn1a/hyvjcndMjvEOza8OnSu3oLK2Dy8vfQScZN yqenTtgjXY0Axk19dfUUcEsg7sWzlcQAiA== X-Received: by 2002:a92:b112:: with SMTP id t18mr324207ilh.36.1628623629517; Tue, 10 Aug 2021 12:27:09 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:09 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/7] net: ipa: resume in ipa_clock_get() Date: Tue, 10 Aug 2021 14:27:00 -0500 Message-Id: <20210810192704.2476461-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce ipa_runtime_suspend() and ipa_runtime_resume(), which encapsulate the activities necessary for suspending and resuming the IPA hardware. Call these functions from ipa_clock_get() and ipa_clock_put() when the first reference is taken or last one is dropped. When the very first clock reference is taken (for ipa_config()), setup isn't complete yet, so (as before) only the core clock gets enabled. When the last clock reference is dropped (after ipa_deconfig()), ipa_teardown() will have made the setup_complete flag false, so there too, the core clock will be stopped without affecting GSI or the endpoints. Otherwise these new functions will perform the desired suspend and resume actions once setup is complete. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 63 ++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 26 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 864991f7ba4b5..c0a8fdf0777f4 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "ipa.h" @@ -230,6 +231,38 @@ static int ipa_clock_disable(struct ipa *ipa) return ipa_interconnect_disable(ipa); } +static int ipa_runtime_suspend(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + /* Endpoints aren't usable until setup is complete */ + if (ipa->setup_complete) { + __clear_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags); + ipa_endpoint_suspend(ipa); + gsi_suspend(&ipa->gsi); + } + + return ipa_clock_disable(ipa); +} + +static int ipa_runtime_resume(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + int ret; + + ret = ipa_clock_enable(ipa); + if (WARN_ON(ret < 0)) + return ret; + + /* Endpoints aren't usable until setup is complete */ + if (ipa->setup_complete) { + gsi_resume(&ipa->gsi); + ipa_endpoint_resume(ipa); + } + + return 0; +} + /* Get an IPA clock reference, but only if the reference count is * already non-zero. Returns true if the additional reference was * added successfully, or false otherwise. @@ -265,7 +298,7 @@ int ipa_clock_get(struct ipa *ipa) goto out_mutex_unlock; } - ret = ipa_clock_enable(ipa); + ret = ipa_runtime_resume(&ipa->pdev->dev); refcount_set(&clock->count, 1); @@ -287,7 +320,7 @@ int ipa_clock_put(struct ipa *ipa) if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex)) return 0; - ret = ipa_clock_disable(ipa); + ret = ipa_runtime_suspend(&ipa->pdev->dev); mutex_unlock(&clock->mutex); @@ -405,16 +438,7 @@ void ipa_clock_exit(struct ipa_clock *clock) */ static int ipa_suspend(struct device *dev) { - struct ipa *ipa = dev_get_drvdata(dev); - - /* Endpoints aren't usable until setup is complete */ - if (ipa->setup_complete) { - __clear_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags); - ipa_endpoint_suspend(ipa); - gsi_suspend(&ipa->gsi); - } - - return ipa_clock_disable(ipa); + return ipa_runtime_suspend(dev); } /** @@ -429,20 +453,7 @@ static int ipa_suspend(struct device *dev) */ static int ipa_resume(struct device *dev) { - struct ipa *ipa = dev_get_drvdata(dev); - int ret; - - ret = ipa_clock_enable(ipa); - if (WARN_ON(ret < 0)) - return ret; - - /* Endpoints aren't usable until setup is complete */ - if (ipa->setup_complete) { - gsi_resume(&ipa->gsi); - ipa_endpoint_resume(ipa); - } - - return 0; + return ipa_runtime_resume(dev); } const struct dev_pm_ops ipa_pm_ops = { From patchwork Tue Aug 10 19:27:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494380 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264657jap; Tue, 10 Aug 2021 12:27:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdTW9mZXIBMN2Je7stYVSDV+R7ysCZmDHwdNsvjewMXQUrG5ILXuwoTWu4660aWNzaWbAa X-Received: by 2002:a05:6e02:d49:: with SMTP id h9mr135656ilj.229.1628623653273; Tue, 10 Aug 2021 12:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623653; cv=none; d=google.com; s=arc-20160816; b=eq4DTGVJkcMPPEFb5+EEyPs3W8K8/F5oDY6IInkG5HH1djhi6wCIWpVxN9W3WazLA7 MTjMUCu5HhZjaVzSv84uG5Rr5KAQPS7DifAcWPCTSbhbKEvvQv9w8tCqyC5NsLuqFJSC jD/BbPXbKX1yPWFBxow40HuB+bk8QEaiqwiK9ln4uzyo8KavmVJfuvNYhrW7YiV3JeJB Na8ogyZevQq9WD5qhydISh9X5QzXFAtqcoBqtd5NP8qqdI4hfqBH1YEqohQkcGQFmg8x /UY8EORWh/HIGBi3yuhS2tSqYQ+ICBapU01sO6pLBELNrpl6z9/E0iaFMbTBdrEQ8sM9 OS0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pI+8m5HMPaYPQHluRxxBp4zHquq3RrMrrTVfNZPdFIk=; b=bVN+xgPnZ0ZCUxQwbrkfqM8N59rb4jc6Bt30aorVDZ6QUoTGB3r1gn38gIrdliyUV/ w4Z6oiploj3FEdyYguFha0NeIy8aU5nPKZRkJpN4XgfN3f702TtdUzAPDz+isUi33qL/ WLym6UdwiivIdP2WPKnqHD71R3h5L8q88L/5bbo3TsmbggqSgFyi1h85GIdapNABGW36 jwebvqnhS10te/qc7PctAUX/4fgTE1OBPbvsiFS9TCcZjcJzokLfrCUAecAz7zPkkts7 f8BzdABFgJ45zAtQ4O71IG7eeuFUMx0EWaMw258C/LVbQg+DnaBuRXn/hCItGCi0vhea JyHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HSozmonS; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.32; Tue, 10 Aug 2021 12:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HSozmonS; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232627AbhHJT1x (ORCPT + 8 others); Tue, 10 Aug 2021 15:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbhHJT1d (ORCPT ); Tue, 10 Aug 2021 15:27:33 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8FAC06179B for ; Tue, 10 Aug 2021 12:27:10 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id a13so409166iol.5 for ; Tue, 10 Aug 2021 12:27:10 -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=pI+8m5HMPaYPQHluRxxBp4zHquq3RrMrrTVfNZPdFIk=; b=HSozmonS+ci2B96mKybDmnhhsWqEaMw8SELgDST7o5SeBGMIrKVB7lpWZgfpBrbIgh 4gjxQOpdey+k+jQurniDJIiFFSKE1JufWBur4CjAZQ9AWPsdmrToKsBblubnWoiCSPe2 Ewj5XUt8DEPF3aHHveOrW/HTfCAuYrlnkamaXQtxJRmG5n6rh8gzB7TN1I0lISt4u/DP qsIggBlPmdYg5xFwZp8ANIZkez619F0lk/LjXgKbtjnWW59acwHi3041bzyhJNPHWFk5 2CytkSQrGnxLe/oXt0idnBJLHozwUJeckui8truuKgQ5WWIoud1IIVtG6L5pKUUTU/63 W6+Q== 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=pI+8m5HMPaYPQHluRxxBp4zHquq3RrMrrTVfNZPdFIk=; b=keHGpRBVB8TWcgXwcZ/SUk+yeknYQVetWoGkR1hAf49maOZlnSaBVTG3I4pIKsYpuf 10EJbAEVE2E00Q7KrZbUmQnOna4LvoZta+87qsWmbDzxaMIeCypYN1ih4aKsaYjI/hOq 0+IcM2lKQqxiANQOMJ/TfziNWRqtQ+mIZsUfUYZyHkPyKip6e5ms8vQBATavIVo+2d32 lZBLtpryWCugQU/1rjHmiym9tHNgveXX23xLeXjhHI7hlFhyikDGNioYhE4IvoOi+e83 IFsjXEyc8ooO0lbLwTbvk4rLRUNqDd+BbeClug+6EJFOfhiKWQubQJKdkQvLbihNbVSp 9Tdw== X-Gm-Message-State: AOAM531ejsVVymuLa+1iMlMh76O8+O4iuWgxtwpN3wNvy6LPJlp6/L8y pY+Toe7pDh4/8IY/qe08KNAILQ== X-Received: by 2002:a5d:9681:: with SMTP id m1mr256048ion.113.1628623630357; Tue, 10 Aug 2021 12:27:10 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:10 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/7] net: ipa: use runtime PM core Date: Tue, 10 Aug 2021 14:27:01 -0500 Message-Id: <20210810192704.2476461-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the runtime power management core to cause hardware suspend and resume to occur. Enable it in ipa_clock_init() (without autosuspend), and disable it in ipa_clock_exit(). Use ipa_runtime_suspend() as the ->runtime_suspend power operation, and arrange for it to be called by having ipa_clock_get() call pm_runtime_get_sync() when the first clock reference is taken. Similarly, use ipa_runtime_resume() as the ->runtime_resume power operation, and pm_runtime_put() when the last IPA clock reference is dropped. Introduce ipa_runtime_idle() as the ->runtime_idle power operation, and have it return a non-zero value; this way suspend will never occur except when forced. Use pm_runtime_force_suspend() and pm_runtime_force_resume() as the system suspend and resume callbacks, and remove ipa_suspend() and ipa_resume(). Store a pointer to the device structure passed to ipa_clock_init(), so it can be used by ipa_clock_exit() to disable runtime power management. For now we preserve IPA clock reference counting. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 75 +++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 37 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index c0a8fdf0777f4..f1ee0b46da005 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -60,6 +60,7 @@ enum ipa_power_flag { * struct ipa_clock - IPA clocking information * @count: Clocking reference count * @mutex: Protects clock enable/disable + * @dev: IPA device pointer * @core: IPA core clock * @flags: Boolean state flags * @interconnect_count: Number of elements in interconnect[] @@ -68,6 +69,7 @@ enum ipa_power_flag { struct ipa_clock { refcount_t count; struct mutex mutex; /* protects clock enable/disable */ + struct device *dev; struct clk *core; DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; @@ -263,13 +265,29 @@ static int ipa_runtime_resume(struct device *dev) return 0; } +static int ipa_runtime_idle(struct device *dev) +{ + return -EAGAIN; +} + /* Get an IPA clock reference, but only if the reference count is * already non-zero. Returns true if the additional reference was * added successfully, or false otherwise. */ bool ipa_clock_get_additional(struct ipa *ipa) { - return refcount_inc_not_zero(&ipa->clock->count); + struct device *dev; + int ret; + + if (!refcount_inc_not_zero(&ipa->clock->count)) + return false; + + dev = &ipa->pdev->dev; + ret = pm_runtime_get_sync(dev); + if (ret < 0) + dev_err(dev, "error %d enabling power\n", ret); + + return true; } /* Get an IPA clock reference. If the reference count is non-zero, it is @@ -283,6 +301,7 @@ bool ipa_clock_get_additional(struct ipa *ipa) int ipa_clock_get(struct ipa *ipa) { struct ipa_clock *clock = ipa->clock; + struct device *dev; int ret; /* If the clock is running, just bump the reference count */ @@ -298,7 +317,8 @@ int ipa_clock_get(struct ipa *ipa) goto out_mutex_unlock; } - ret = ipa_runtime_resume(&ipa->pdev->dev); + dev = &ipa->pdev->dev; + ret = pm_runtime_get_sync(dev); refcount_set(&clock->count, 1); @@ -313,14 +333,17 @@ int ipa_clock_get(struct ipa *ipa) */ int ipa_clock_put(struct ipa *ipa) { + struct device *dev = &ipa->pdev->dev; struct ipa_clock *clock = ipa->clock; + int last; int ret; /* If this is not the last reference there's nothing more to do */ - if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex)) - return 0; + last = refcount_dec_and_mutex_lock(&clock->count, &clock->mutex); - ret = ipa_runtime_suspend(&ipa->pdev->dev); + ret = pm_runtime_put(dev); + if (!last) + return ret; mutex_unlock(&clock->mutex); @@ -394,6 +417,7 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data) ret = -ENOMEM; goto err_clk_put; } + clock->dev = dev; clock->core = clk; clock->interconnect_count = data->interconnect_count; @@ -404,6 +428,9 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data) mutex_init(&clock->mutex); refcount_set(&clock->count, 0); + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_enable(dev); + return clock; err_kfree: @@ -420,43 +447,17 @@ void ipa_clock_exit(struct ipa_clock *clock) struct clk *clk = clock->core; WARN_ON(refcount_read(&clock->count) != 0); + pm_runtime_disable(clock->dev); mutex_destroy(&clock->mutex); ipa_interconnect_exit(clock); kfree(clock); clk_put(clk); } -/** - * ipa_suspend() - Power management system suspend callback - * @dev: IPA device structure - * - * Return: 0 on success, or a negative error code - * - * Called by the PM framework when a system suspend operation is invoked. - * Suspends endpoints and releases the clock reference held to keep - * the IPA clock running until this point. - */ -static int ipa_suspend(struct device *dev) -{ - return ipa_runtime_suspend(dev); -} - -/** - * ipa_resume() - Power management system resume callback - * @dev: IPA device structure - * - * Return: 0 on success, or a negative error code - * - * Called by the PM framework when a system resume operation is invoked. - * Takes an IPA clock reference to keep the clock running until suspend, - * and resumes endpoints. - */ -static int ipa_resume(struct device *dev) -{ - return ipa_runtime_resume(dev); -} - const struct dev_pm_ops ipa_pm_ops = { - .suspend = ipa_suspend, - .resume = ipa_resume, + .suspend = pm_runtime_force_suspend, + .resume = pm_runtime_force_resume, + .runtime_suspend = ipa_runtime_suspend, + .runtime_resume = ipa_runtime_resume, + .runtime_idle = ipa_runtime_idle, }; From patchwork Tue Aug 10 19:27:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494382 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264762jap; Tue, 10 Aug 2021 12:27:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3OtoXk+dR/DRnZ1JaRzM5r/LOLZANplTuyl0GdVEDJR6Ni0F9v+zApSGXOIf2v1LOo/Pa X-Received: by 2002:a92:cacd:: with SMTP id m13mr190382ilq.256.1628623661196; Tue, 10 Aug 2021 12:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623661; cv=none; d=google.com; s=arc-20160816; b=i2r792TYzEtU9XOB4xsEgr5QBLMZnsDPgHibwBrOQwBs519LuvD7ZntbuUAgx4gIH1 1McmwfdcXVlo0DXzONnwNeKK96g/vrOceMVCQNEjZBq0wgcSyXzKehu9gXdeswLj4c3S yeVvtCE9Ep85mkqLi2GyPYVOO4GZEyCMPkmfM5SAOBC8/KMf2CFS3cknJmX0iTaBvZw8 WnvV5YoO2sta6rvMoIaqbl0NHxyXU1sg49Cg14QxfpQrZVI26bsIsItpXFLL0BWQFji2 RxrjqzqYOUSSjHrAqZB2/md/ng7ruRyV+5e7mv5mVwgBBIQKJfF++fb/pBpGH00Rw8oJ X2Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ux+nWXRpxXp+ZCGVEu2iXcKzONeSoEn/jJZkwn5TrXk=; b=tLVU+BUud0kDfq0aWtQEw7dunWv9tOYmURaIlom3eG7GdpFK7D1IfGWll2qvnyTPrk xJkFpkmJs+t+nmdAkfqoHxCElvW6bFNllS6NrFEojLgFtHVxReeWnhHJpz2/kMqT78/U cCL665+tgyhzp9syZT7nr7jwMRoTFAyeGt+rO0/G3ijmnzXUMYodpm7D5Td1n2BUCq3i fsoTZbd1MS9XDkpy8sr1WKV+kOe1KPKy66lFp9hiDcV0G0C/gz/R0sINxBv5k78uw2PD gqky6P5VJBlb3MQZLElGTPVb3NTTP31XIImGxxwct31dR+BIiRsZmA0gimKE4ddyZwF3 3rEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TElDuM1U; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.40; Tue, 10 Aug 2021 12:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TElDuM1U; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232972AbhHJT2C (ORCPT + 8 others); Tue, 10 Aug 2021 15:28:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232741AbhHJT1f (ORCPT ); Tue, 10 Aug 2021 15:27:35 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7754C0617A0 for ; Tue, 10 Aug 2021 12:27:11 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id l20so417706iom.4 for ; Tue, 10 Aug 2021 12:27:11 -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=ux+nWXRpxXp+ZCGVEu2iXcKzONeSoEn/jJZkwn5TrXk=; b=TElDuM1UeTsRvMrycPcQskB+U9XpBJYPazUYvbmZYLGoAD0F6ANvKkVepnO4I32r+g AIw4kPCx1SNru8H5sjMgQngmx7Qe6S0oRcDNIFtwEvtJScx4QftVslIDq6dG+iUSKRFa pQkfQJjqKhhY9aSp3VlAo1ZeIIO5oVN0xRUVh3WLvCzLUX/PZedMvjuWS3oxTYxOifJb crTOzO33sv2FCk9X3LyGeS2q8EmnzwcXBDjIWodzmOAUs8N1Lhx/IRbk+TiaRMrkJsOT xsjauy/O0cPUS1qZiq/q3hBufkcvsMfyJy5WmRnYxMTtPttSVLmzhYQ2Z15M1iwl5e1U kVvA== 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=ux+nWXRpxXp+ZCGVEu2iXcKzONeSoEn/jJZkwn5TrXk=; b=rjQlKwqNX1daZqsY1xvCVjK+zcIAlquOJp5PDrqF1HT61JMfS/Bcq5JyS5zOTAk2Oi GVpXj30EI1kOrS7kHiiQc2RYwLh7YUz/Ve7IbmSbSLvwxOis8AgN5S535hHFTnf9zBwd AZeryKF75W1HYFtOdi6KyLtkTaRSBm5gCf6NxKIN7XsQDLRa6/p4tRcOogyaVyCmBLFW U/mPZRSKov6CEec4VVRZMUxbCJNt1hPGrZJZPiqVwHT7d8/zm50a0dCgGaCS7q3SoSw8 KMQqZDExCewehBFs54siXNmiQc9tmJBHYNQ2iJRbOgImvWYEqueOmtKLJTBMhRQY4mx4 Walw== X-Gm-Message-State: AOAM5301qh8QqFBV/FC3+mR2UoCebJ+6kuGPC2rvhjhgjwcuc8jHBGJH ZZk9lXQ7p5RlgeR/vJp2M4RIVQ== X-Received: by 2002:a5d:8b51:: with SMTP id c17mr1311236iot.119.1628623631159; Tue, 10 Aug 2021 12:27:11 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:10 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/7] net: ipa: get rid of extra clock reference Date: Tue, 10 Aug 2021 14:27:02 -0500 Message-Id: <20210810192704.2476461-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Suspending the IPA hardware is now managed by the runtime PM core code. The ->runtime_idle callback returns a non-zero value, so it will never suspend except when forced. As a result, there's no need to take an extra "do not suspend" clock reference. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 11 ----------- 1 file changed, 11 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 64112a6767743..f332210ce5354 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -427,14 +427,6 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) { int ret; - /* Get a clock reference to allow initialization. This reference - * is held after initialization completes, and won't get dropped - * unless/until a system suspend request arrives. - */ - ret = ipa_clock_get(ipa); - if (WARN_ON(ret < 0)) - goto err_clock_put; - ipa_hardware_config(ipa, data); ret = ipa_mem_config(ipa); @@ -477,8 +469,6 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) ipa_mem_deconfig(ipa); err_hardware_deconfig: ipa_hardware_deconfig(ipa); -err_clock_put: - (void)ipa_clock_put(ipa); return ret; } @@ -496,7 +486,6 @@ static void ipa_deconfig(struct ipa *ipa) ipa->interrupt = NULL; ipa_mem_deconfig(ipa); ipa_hardware_deconfig(ipa); - (void)ipa_clock_put(ipa); } static int ipa_firmware_load(struct device *dev) From patchwork Tue Aug 10 19:27:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494383 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264794jap; Tue, 10 Aug 2021 12:27:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk3lm5MCrlXUOR+AJvkMwtC5URCQdyvrWr3+ihjHDjuc47pNDT/0kEZ2qZ/ud1Z1WgLIN1 X-Received: by 2002:a05:6e02:d49:: with SMTP id h9mr136185ilj.229.1628623663580; Tue, 10 Aug 2021 12:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623663; cv=none; d=google.com; s=arc-20160816; b=XXdh/V6tP40kINEg+qUOfbsfLmKKYueluhSUw+iLZ5T8w9Gy/hjcv6k/X49yLAdEvu cANpPfLGo2qsKWE/Tz8HSVrs6CeUsWxZClMjjbHEYz/WoKue/orD+ajFcask8yC39j1n CaQISEU5dZuMFxT7+5hbiIhgJMXC4WRlqMPv9AapXij+VsQ9bQvo52zM+X+zAODyt8fL NrlS8PeQbbAxTEJHQPia320d0s+ioTPmhGSb6GpeekF7kPRjXWdmYx2QyBcuOx8Lyg5w DVilaI+jVg9J/8lOSRp2/3F2EeLWoFcCzpC/hwpsJwO2y1luswbJz6EApJ3ikQfYC1Nu jsLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=75vQHBPl1C4p22sDxWz00VL6td9npCwWWXZWEV8i9ac=; b=N4YGhqa+UYYn5G6Sg4FgDluSd8JPoWRi0F2uojMmVwy2c83JtrCsisM4HyEt1wYxCy FzU3QP886bTD4P2W6cdORJ/Q2OA616OrSIVOL/v3c9dI2nBQHwjTYcNXqZRcDlhNIB+T MXYa1iUhBaDS8G9k6ohIgIt3BEx60hxOlchvjWmtOA30tqrUOpynRdq8BzF1NrUdLLdw tr69xXo7LdW/0i8MLJ6SdrKUdnj+37uIQFcR4E/w6V+nyQIldbAHv9pmYksZxXjrz9lh mVmxwLPia4J4n627SguwnlpyavvQx7YX5dIwZZPpjM4hm4rfthBnNOJZR+nCqrw/noI2 9ozQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTCAsnN7; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.43; Tue, 10 Aug 2021 12:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTCAsnN7; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233310AbhHJT2D (ORCPT + 8 others); Tue, 10 Aug 2021 15:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232746AbhHJT1f (ORCPT ); Tue, 10 Aug 2021 15:27:35 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A55F7C0617A3 for ; Tue, 10 Aug 2021 12:27:12 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id u7so176626ilk.7 for ; Tue, 10 Aug 2021 12:27:12 -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=75vQHBPl1C4p22sDxWz00VL6td9npCwWWXZWEV8i9ac=; b=QTCAsnN7e3qyk21xEzWbrDvfBDD/INdBBnRYLZuVdBqkoSLMBVdnxM59k7EOozVH+R e+pMVexfpCJN7iMm7+eey6RN+lNZ0avZqMrUyilG7Yx/vljXx6UcRExkDzYAqe4LYYCE 56on2yxZo61raBUo8dA7p3I+ZV9yiBcg3AimNuNtnSNxBObd+lzxcFw6Kmzjwf17SowJ ZENOZz1Ljm9RZYbjBIgA4M97mX8TudInuHTKVSspB+UZFAfOFxGVA/aZXv3LaNvo4+rP 9f2Wth7tDTimbEJVtuhduTc0spKTjkm1CWfOGM7UfxI/QTa0sOzgA/oCifByjIjkIyjI JCIg== 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=75vQHBPl1C4p22sDxWz00VL6td9npCwWWXZWEV8i9ac=; b=iVjNbZa6652nb9Jnf6r6wmVF7Tq9qIjV4RB5R3gwV/SxGEAd3DpUhYdcp9umXPrbcD 65an4rU9W585EkUyC7vPdU62IBrBsdLxsPzqV0j8+3bE8sElkK+TJPgj5xR6iTJYYGhG Q96F80aaJwEMXMAd3e4TZkE4G+XZDqJ8PqAGKSVKeIqYiRsCSC8E1N/zfwRlbYdDP3XN 5zvF2f4U1asU78BdeQ3j300vicTG8GbSLu66NAhyeMYlW2u0I+33FXVZjKS7jvxMXuSp ZyNMM+eZ96N7gyEuyT9LpGf8dAsqrI7f56HqOQq57c2OQRnx0ULb2OceTYCgqg5yhoaI pPFA== X-Gm-Message-State: AOAM5306VNM4H2pmFdr/pXJsmanW5bPJKI630gt7j8yMPSQ/+/+MOUxk GolCFnLN5gfzqXZcfjkvxpOh2A== X-Received: by 2002:a05:6e02:107:: with SMTP id t7mr192564ilm.77.1628623632041; Tue, 10 Aug 2021 12:27:12 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:11 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/7] net: ipa: kill IPA clock reference count Date: Tue, 10 Aug 2021 14:27:03 -0500 Message-Id: <20210810192704.2476461-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The runtime power management core code maintains a usage count. This count mirrors the IPA clock reference count, and there's no need to maintain both. So get rid of the IPA clock reference count and just rely on the runtime PM usage count to determine when the hardware should be suspended or resumed. Use pm_runtime_get_if_active() in ipa_clock_get_additional(). We care whether power is active, regardless of whether it's in use, so pass true for its ign_usage_count argument. The IPA clock mutex is just used to make enabling/disabling the clock and updating the reference count occur atomically. Without the reference count, there's no need for the mutex, so get rid of that too. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 77 +++---------------------------------- 1 file changed, 6 insertions(+), 71 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index f1ee0b46da005..ab6626c617b91 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -4,8 +4,6 @@ * Copyright (C) 2018-2021 Linaro Ltd. */ -#include -#include #include #include #include @@ -58,8 +56,6 @@ enum ipa_power_flag { /** * struct ipa_clock - IPA clocking information - * @count: Clocking reference count - * @mutex: Protects clock enable/disable * @dev: IPA device pointer * @core: IPA core clock * @flags: Boolean state flags @@ -67,8 +63,6 @@ enum ipa_power_flag { * @interconnect: Interconnect array */ struct ipa_clock { - refcount_t count; - struct mutex mutex; /* protects clock enable/disable */ struct device *dev; struct clk *core; DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); @@ -276,78 +270,24 @@ static int ipa_runtime_idle(struct device *dev) */ bool ipa_clock_get_additional(struct ipa *ipa) { - struct device *dev; - int ret; - - if (!refcount_inc_not_zero(&ipa->clock->count)) - return false; - - dev = &ipa->pdev->dev; - ret = pm_runtime_get_sync(dev); - if (ret < 0) - dev_err(dev, "error %d enabling power\n", ret); - - return true; + return pm_runtime_get_if_active(&ipa->pdev->dev, true) > 0; } /* Get an IPA clock reference. If the reference count is non-zero, it is - * incremented and return is immediate. Otherwise it is checked again - * under protection of the mutex, and if appropriate the IPA clock - * is enabled. - * - * Incrementing the reference count is intentionally deferred until - * after the clock is running and endpoints are resumed. + * incremented and return is immediate. Otherwise the IPA clock is + * enabled. */ int ipa_clock_get(struct ipa *ipa) { - struct ipa_clock *clock = ipa->clock; - struct device *dev; - int ret; - - /* If the clock is running, just bump the reference count */ - if (ipa_clock_get_additional(ipa)) - return 1; - - /* Otherwise get the mutex and check again */ - mutex_lock(&clock->mutex); - - /* A reference might have been added before we got the mutex. */ - if (ipa_clock_get_additional(ipa)) { - ret = 1; - goto out_mutex_unlock; - } - - dev = &ipa->pdev->dev; - ret = pm_runtime_get_sync(dev); - - refcount_set(&clock->count, 1); - -out_mutex_unlock: - mutex_unlock(&clock->mutex); - - return ret; + return pm_runtime_get_sync(&ipa->pdev->dev); } /* Attempt to remove an IPA clock reference. If this represents the - * last reference, disable the IPA clock under protection of the mutex. + * last reference, disable the IPA clock. */ int ipa_clock_put(struct ipa *ipa) { - struct device *dev = &ipa->pdev->dev; - struct ipa_clock *clock = ipa->clock; - int last; - int ret; - - /* If this is not the last reference there's nothing more to do */ - last = refcount_dec_and_mutex_lock(&clock->count, &clock->mutex); - - ret = pm_runtime_put(dev); - if (!last) - return ret; - - mutex_unlock(&clock->mutex); - - return ret; + return pm_runtime_put(&ipa->pdev->dev); } /* Return the current IPA core clock rate */ @@ -425,9 +365,6 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data) if (ret) goto err_kfree; - mutex_init(&clock->mutex); - refcount_set(&clock->count, 0); - pm_runtime_dont_use_autosuspend(dev); pm_runtime_enable(dev); @@ -446,9 +383,7 @@ void ipa_clock_exit(struct ipa_clock *clock) { struct clk *clk = clock->core; - WARN_ON(refcount_read(&clock->count) != 0); pm_runtime_disable(clock->dev); - mutex_destroy(&clock->mutex); ipa_interconnect_exit(clock); kfree(clock); clk_put(clk); From patchwork Tue Aug 10 19:27:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 494381 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4264698jap; Tue, 10 Aug 2021 12:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOeiCkKXHp9HChhjYi0PnnRE538ajvPu3I0vMEtqj3s6aZD3tnfbrwClK8ELhKv+II01WS X-Received: by 2002:a05:6638:2195:: with SMTP id s21mr7584004jaj.115.1628623656281; Tue, 10 Aug 2021 12:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628623656; cv=none; d=google.com; s=arc-20160816; b=shOMWSslJs2PtMuqNUcuPN5bIzQsnXGUquA3puU97fWfobyn9RtusrW2XxFUglsHSB FpUG4sUC7AqCsNnqpf+6k74ej8saAg0BXpcu53cnPfgQlhJOS/S42f9MOZqKJBAUQtIW zwEGWFJfqAPBRnFpwkPapeA00vHPiTPUTwAGJqG7KGBbB6FAH3NstaM/qUTFdbSMQ6QZ gp4LWvqMd79REtQTx8vME2fXIpLVvcFJsARYgP9gql3OAh1MF9C6aUT0LaSgMGD8FOLf K3Mjol5bZquRQchLxbTKOGxUjXiTrEyQbyp1jehIBEFwFWrLoe2iCSH/tVRBtD+e+p3C GQ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MR4KCI2yYpZ9otoweP9rpmQowf+z82KBy/Idz2Qlj/0=; b=z3OexQlNChLuqYDMK6di8jt5BMrv1NaLf1ycrnRBz1SHuB1YLkCZfYIVg1y09ixqBL wrR9FhDLelmtnKO4RfU4G5aYTkjmwP4PLPfOc5kp46AOy0Wl/FpSqKe3gede4aeU3yNe ZUWq5nkQV7jNujqgDMHG5gh/Dy5NorNbJ0gUk3PGd8SBzJJEosjePpBUATReu7FoevjW 0xIFJvXN4qOR7HfxqwokDcPOYDJ0uaQF3PMkvDl7nncbopQ1LFln0vaofMrerRBc6LIO hkMdHaYOxRQdw4qCZimTDtd4dE7mZ6AqeUNlng2T+2ccR+fEb77LbtVYgzGVLfESV5ml j+iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mefo2O63; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si22116369ile.62.2021.08.10.12.27.36; Tue, 10 Aug 2021 12:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mefo2O63; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233191AbhHJT15 (ORCPT + 8 others); Tue, 10 Aug 2021 15:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232757AbhHJT1f (ORCPT ); Tue, 10 Aug 2021 15:27:35 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74879C0613C1 for ; Tue, 10 Aug 2021 12:27:13 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id i7so440086iow.1 for ; Tue, 10 Aug 2021 12:27:13 -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=MR4KCI2yYpZ9otoweP9rpmQowf+z82KBy/Idz2Qlj/0=; b=mefo2O63gy+ObFFjRU56/Lf4YYjX7qPvTBcZFAFkrC0V6Lg2lTrXRZFlioULpqQrhL TRJJ0/ksQUy11b+fvz8hzUmH0viq0CoTjXp/hbLUmvI/Ckf451vL0suUHJLbcA1bEJZC GIz+Er0hnAxKR1+HcBp/Sfm6mn/8RMR7PBanazy52m7yCw2aDW4rnGkMzTm6Da2otcVK oFymNzFpcB/Ty+mdrMOW5YUtGfYSePXXdk5+iwYABV/giHCq4aY9QzEKkV136VBGR0wk tfgAW6fNPtTr1wYFP+B97a+dL3xZ2oncoLXYgBuj9YpjLVvUFPsM9+ZPn+cjGiKFuC1X xzIg== 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=MR4KCI2yYpZ9otoweP9rpmQowf+z82KBy/Idz2Qlj/0=; b=XQpTba4aHS9bge//XZdN99oyeZfhR3G3dT7P6w+SBoQHtJZs5dSk3hrou/22SJ5OAH 4e346shnTmefZDcrq40JwgLKQr/7QudtRCfnDH9J2lSDsmUGaytrJNdQAsrWD5O4iDAD pyop/wrhXQ6LNamS5/b/63LfxGCzFAz4k9syk/iBrnryV0CEqNg3lHRLBK9su5Nw3bTe r2etcrOWBYYVI9okgmeNzXWoKh6n1bpKQp631C4/VrIbdtaQAk84OeoTCKGqNFeN2arl Mx3ALJJzYbx8JA0m/E2gCjVrWFIJGElMKfBk0j+yYunvFoFONlqywXI9bSjhOQnYYvyN ywOQ== X-Gm-Message-State: AOAM531zWWX5ZnjjBg413Cbg/0Ghi3Fkwk+tzpxBqS2cJ+fbOyWxZThM eTuwEZ2WXzdOMyywsf83/rKrKw== X-Received: by 2002:a5d:91c2:: with SMTP id k2mr56591ior.117.1628623632939; Tue, 10 Aug 2021 12:27:12 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c5sm3025356ioz.25.2021.08.10.12.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 12:27:12 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/7] net: ipa: kill ipa_clock_get_additional() Date: Tue, 10 Aug 2021 14:27:04 -0500 Message-Id: <20210810192704.2476461-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210810192704.2476461-1-elder@linaro.org> References: <20210810192704.2476461-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that ipa_clock_get_additional() is a trivial wrapper around pm_runtime_get_if_active(), just open-code it in its only caller and delete the function. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 9 --------- drivers/net/ipa/ipa_clock.h | 10 ---------- drivers/net/ipa/ipa_smp2p.c | 5 ++++- 3 files changed, 4 insertions(+), 20 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index ab6626c617b91..6df66c574d594 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -264,15 +264,6 @@ static int ipa_runtime_idle(struct device *dev) return -EAGAIN; } -/* Get an IPA clock reference, but only if the reference count is - * already non-zero. Returns true if the additional reference was - * added successfully, or false otherwise. - */ -bool ipa_clock_get_additional(struct ipa *ipa) -{ - return pm_runtime_get_if_active(&ipa->pdev->dev, true) > 0; -} - /* Get an IPA clock reference. If the reference count is non-zero, it is * incremented and return is immediate. Otherwise the IPA clock is * enabled. diff --git a/drivers/net/ipa/ipa_clock.h b/drivers/net/ipa/ipa_clock.h index 8692c0d98bd1c..5c118f2c42e7a 100644 --- a/drivers/net/ipa/ipa_clock.h +++ b/drivers/net/ipa/ipa_clock.h @@ -62,16 +62,6 @@ void ipa_clock_exit(struct ipa_clock *clock); */ int ipa_clock_get(struct ipa *ipa); -/** - * ipa_clock_get_additional() - Get an IPA clock reference if not first - * @ipa: IPA pointer - * - * Return: true if reference taken, false otherwise - * - * This returns immediately, and only takes a reference if not the first - */ -bool ipa_clock_get_additional(struct ipa *ipa); - /** * ipa_clock_put() - Drop an IPA clock reference * @ipa: IPA pointer diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c index f84d6523636e3..04b977cf91593 100644 --- a/drivers/net/ipa/ipa_smp2p.c +++ b/drivers/net/ipa/ipa_smp2p.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -84,13 +85,15 @@ struct ipa_smp2p { */ static void ipa_smp2p_notify(struct ipa_smp2p *smp2p) { + struct device *dev; u32 value; u32 mask; if (smp2p->notified) return; - smp2p->clock_on = ipa_clock_get_additional(smp2p->ipa); + dev = &smp2p->ipa->pdev->dev; + smp2p->clock_on = pm_runtime_get_if_active(dev, true) > 0; /* Signal whether the clock is enabled */ mask = BIT(smp2p->enabled_bit);