Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp180117pxb; Thu, 12 Aug 2021 13:46:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFXIDPQDoS3bsAIULGAP/ilNF1bc/Pbm9soNns2UCSMTjVN2moY71Co1cipAtX1myF54Cf X-Received: by 2002:a17:906:aada:: with SMTP id kt26mr5550566ejb.199.1628801161790; Thu, 12 Aug 2021 13:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628801161; cv=none; d=google.com; s=arc-20160816; b=XiTv/tWKQ9/dR+os0GxyDJY8sAmgy9C2QhQReIQas/+IQ5+72YFiC3ZE63YKR7rLFp ak8JUwF4kscK17R1ymJGIOi9YamvCRHIHhTou5tJOQVt5/uFLZcKjsaSzSI1UlLhO6k4 mRnSj5eEten0ORYJ212VQC2O+uKuCjeol617b458wC3CQLBqnsKNNtjW4PAkR1g4iVAm 5e7VrBUwQgTZ29e80zBj/277N4XFHKTXvL3Z47SsuvC9NhfJY4zEsrJl1a8l5xGjHhsl O92MohjE32SBVi6bH2tRtslKfhRuEsNzET+GvvLNe6TwSjrcesy0tgGbbcC4adxvOPPJ N0cQ== 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=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=yJHDeXGaV/2XMhJbxFOV9e5R+NmXpcwnuutX35J18SYz8uRyc4wsRz06E/pzfnKTUo 4jVNyDgxYTt7gj8AXvk4zJ/OhSHiiTYFKvxcx3mtvl9k+ayTez8GqzhQNgdJGTxeXmwI Nk81dn2hWjWq6h0kwc12ALmCw1tBjo0I+3kQ0ZVV9y/W3PW9YBpV9cQoPOrmiSBDabZf 6c8QdTsF3p1nGrpvihoxZ9i75ZJkr8ciGTd1Mhrb8WzcDNiuPY6IDEGlCjkp8MwU73op hmYGwmqL/QNS3GNHTUZTQSUNRsAz4L8qe0Mi9C87Yx7jSQazdNO6Vfyop/hTVKjwkRxo et0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WS24WPgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 i7si3436430ejg.459.2021.08.12.13.45.30; Thu, 12 Aug 2021 13:46:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=WS24WPgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S234879AbhHLTvN (ORCPT + 99 others); Thu, 12 Aug 2021 15:51:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbhHLTvG (ORCPT ); Thu, 12 Aug 2021 15:51:06 -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 CE138C0613D9 for ; Thu, 12 Aug 2021 12:50:40 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id s184so10076657ios.2 for ; Thu, 12 Aug 2021 12:50:40 -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=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=WS24WPgGay3hQgbUIR436kNFc73DRxNzR3maz8Q/Ph21IP6Fpg407QTGxKiL8dFeMN 9gzxpBAYI2oznD4Gi6IjhQocSIqiv9IDTeseCP8xuHAPb8QPartndvy9p8FL3ZTIUl3m y/RHgUXbnXSJOUL5xnqwdCdSEkqStWw0S81nQFgMTMdHFIlMEZo6i8JxEYwqvtyGFkTm HKuWXWyc5cdyNHt4utgsJsESyOMojkUTno/4kbpnj+DUS2PinE2PYailtvZbQ/yx+m3q a0+JaCudbp46HQPAij2MjeA48cm5zdmnECy9KG6c0Wls7XjOcR9SP2MRen6e2kRZ9Cvm 1SqA== 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=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=Dvqg2a8YC+Rp5SowEWuKhrsZdAJWrWLfumWJDCzNzeC8xIvbxScLof060SIlXTohgv 1eTlkQXo9QcoqpotE9cFIgs30pZGFVNs8DbEb95WJCvR8pF4RbrOhM7o7w0+azbyoei/ VazXBXzHv7KGomcZeTSEAxZnlYTRfKCp9nHX4Ve8UhRFZwJDPA+v1dvoPVNKEFM5aPKg aVqJIdU/YU4Y1pY4tSVStxOAcZ6DB/qF6M3XmHP57bqGvNah5XisDT4oEIXl+2X568si NN+bVE3XJZJS8sYcvANZM1TWngD4kiJPs6VO9/JWlA8lfK+u8r2O7skX1B1+ZFWGQm2z YlcQ== X-Gm-Message-State: AOAM531VHZCaRIbLqXpwRWWH3Eke8YeF07FTABx+UCJ7cgm+SFrAHcZf Hy3lqk4xBoAXjwNpmF/LM0mlTw== X-Received: by 2002:a05:6602:220e:: with SMTP id n14mr4261919ion.150.1628797840279; Thu, 12 Aug 2021 12:50:40 -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 s16sm2058821iln.5.2021.08.12.12.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:39 -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/6] net: ipa: distinguish system from runtime suspend Date: Thu, 12 Aug 2021 14:50:31 -0500 Message-Id: <20210812195035.2816276-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new flag that is set when the hardware is suspended due to a system suspend operation, distingishing it from runtime suspend. Use it in the SUSPEND IPA interrupt handler to determine whether to trigger a system resume because of the event. Define new suspend and resume power management callback functions to set and clear the new flag, respectively. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index cdbaba6618e9e..8f25107c1f1e7 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -47,10 +47,12 @@ struct ipa_interconnect { /** * enum ipa_power_flag - IPA power flags * @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled + * @IPA_POWER_FLAG_SYSTEM: Hardware is system (not runtime) suspended * @IPA_POWER_FLAG_COUNT: Number of defined power flags */ enum ipa_power_flag { IPA_POWER_FLAG_RESUMED, + IPA_POWER_FLAG_SYSTEM, IPA_POWER_FLAG_COUNT, /* Last; not a flag */ }; @@ -281,6 +283,27 @@ int ipa_clock_put(struct ipa *ipa) return pm_runtime_put(&ipa->pdev->dev); } +static int ipa_suspend(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + __set_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags); + + return pm_runtime_force_suspend(dev); +} + +static int ipa_resume(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + + __clear_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags); + + return ret; +} + /* Return the current IPA core clock rate */ u32 ipa_clock_rate(struct ipa *ipa) { @@ -299,12 +322,13 @@ u32 ipa_clock_rate(struct ipa *ipa) */ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { - /* Just report the event, and let system resume handle the rest. - * More than one endpoint could signal this; if so, ignore - * all but the first. + /* To handle an IPA interrupt we will have resumed the hardware + * just to handle the interrupt, so we're done. If we are in a + * system suspend, trigger a system resume. */ - if (!test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags)) - pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); + if (!__test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags)) + if (test_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags)) + pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); /* Acknowledge/clear the suspend interrupt on all endpoints */ ipa_interrupt_suspend_clear_all(ipa->interrupt); @@ -390,8 +414,8 @@ void ipa_clock_exit(struct ipa_clock *clock) } const struct dev_pm_ops ipa_pm_ops = { - .suspend = pm_runtime_force_suspend, - .resume = pm_runtime_force_resume, + .suspend = ipa_suspend, + .resume = ipa_resume, .runtime_suspend = ipa_runtime_suspend, .runtime_resume = ipa_runtime_resume, .runtime_idle = ipa_runtime_idle, -- 2.27.0