From patchwork Thu Sep 17 17:39:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 313140 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp652803ilg; Thu, 17 Sep 2020 11:05:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4GAE0IXm737pBR8mUslnCCnlaat6zasoCMlqJ3X31lG1Jjn1JBqxOlPhI8j89NjrlM6Po X-Received: by 2002:a17:906:2681:: with SMTP id t1mr14881084ejc.474.1600365935361; Thu, 17 Sep 2020 11:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600365935; cv=none; d=google.com; s=arc-20160816; b=MdCp3iSL3aEvGM2aykBNk1FS3ITpU0wLeHPhD3/pgmNRl0s8BYB78tomZwsBCvYGm2 nHD9rZajAWBzd4gZPIFgfqVAUhGQxvi9i0ohoO1tzQCr93+xKLsVf+vgUC4hz5wTBlJH 69CMEM1R5k0vfXN4nu6UCDnClDQ50nyMt+m7O7GkNrp/m104+dogJGWXUEhGVhoeOTuW vPwlvIoTO1bz8xjNCPkhytCR8Xx7RuNpDVeeBiWmA3GrZsdIjVmDsUUsx+aNl3urdUbh cSjICP3vXqPjr7h0M/aSjC7XUIf7cC1dRf7NOglIiYIcDoDiZT+Sdy2WCPoGNfWlWa+r U4gA== 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=bXindhdvkQaAk3Cd415sil6PrEN75fleSugapgasIK0=; b=ajd1wsGMhVlu2lyy7dP6gziOWYyQG6QnxGgLUzMBVVIrf6oQFX7knbjsICdLHDAqDs +8bqayU0yBFaLf4MbrAtx1FK4g/JgcFbHojOgu1uZxLKyfB91FvbgGz1ZWwOxztMc3ov 5bOGavnQJrGQScrZR1gvGFm/KWg0kdW31WfWz2RrT3VbtuVbUIzPSNcrmyA9QrvMeH1o OfQfFKYZbluMqgNlXSDLm/WTfpasNFIzwq0t2MLX/QzmOIMGVkvkX3TZ8Z7+i1drrPPt 3iDGBH6LQamnB9ddLPwrAN+nKfnvWoJZ0/XIctcR7OUoC1gUZZ06Cbob+2Po5fzb8AI7 nCbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T69eAZTJ; 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 o90si315123edd.165.2020.09.17.11.05.35; Thu, 17 Sep 2020 11:05:35 -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=T69eAZTJ; 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 S1726511AbgIQSBe (ORCPT + 8 others); Thu, 17 Sep 2020 14:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbgIQRjd (ORCPT ); Thu, 17 Sep 2020 13:39:33 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC70FC061351 for ; Thu, 17 Sep 2020 10:39:32 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id r9so3160094ioa.2 for ; Thu, 17 Sep 2020 10:39:32 -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=bXindhdvkQaAk3Cd415sil6PrEN75fleSugapgasIK0=; b=T69eAZTJvv3a87sZwq7xkk9cDvGBj8Y6Xb5Uul5fYOfMkEZXE1jZ+tMwuw8Iun1mmC sJUsk+62obo/B2prpFs2GbZ2+bGUY3JWqCeN4g5ezw8MCa50n9KOgZGM1QLR7XjE5g2I YqussllL33xvrzXLdCuQ4BPi1gz1mX8Uoa3L3p+myjxRVSp38QxcRurWQ/OFEfBvTSt/ 5JHyT+L2vvBSo760UJ1hPmkAE0TjN3b1S4yhVeW2plxvgpaUBvys0xLe4sIhMD0LUysN 91w91O224zoLMxmtdvh+J+lZ2AhiW878pigJg685HWp48gwzIYKWzCuUPZ4sEp5AAik3 CJTQ== 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=bXindhdvkQaAk3Cd415sil6PrEN75fleSugapgasIK0=; b=jQuVgd9NTLt4ZYmO+OwFjnDJiaVTPJgv6cUtnr56W48/Vc8uhdI6/AjW2PmrRdrl7t ApruN8wWD0cCrsHxJ+VXslJuyrJHJuzm939fKP0riO7hV+jHXTBXUyvt3+607NWuZH9V 1Bb72eEGicL9nid667z5/+8N2oumbsPi/v6l+xCzez8o/XxP9j94QMZiPVbiZ2uqrgHa qG+PIqPCybV5HVDI4MbjtVK4NHKf8Ua5RNZksiJjJFq6FSPTjZWcJ0Xx4E7oZWXN/6Rb r1UrZiiXSLxcmHtJm8//aT9gVPXuvQao6sz77JO8RFAxtmaJZYFELO9Cm2AEgd9C4EUs ecgw== X-Gm-Message-State: AOAM5310YUIVJDkDl0mjM1c1dpV4PAahQ4wpzG3k3XhoRPscoIJoatWE WIaqSUOoYFAT4fjgRWW9dTdmQQ== X-Received: by 2002:a05:6602:2d55:: with SMTP id d21mr23642445iow.134.1600364371878; Thu, 17 Sep 2020 10:39:31 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:31 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/7] net: ipa: use refcount_t for IPA clock reference count Date: Thu, 17 Sep 2020 12:39:20 -0500 Message-Id: <20200917173926.24266-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Take advantage of the checking provided by refcount_t, rather than using a plain atomic to represent the IPA clock reference count. Note that we need to *set* the value to 1 in ipa_clock_get() rather than incrementing it from 0 (because doing that is considered an error for a refcount_t). Signed-off-by: Alex Elder --- v2: This patch was added in version 2 of the series. v3: No change. drivers/net/ipa/ipa_clock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 398f2e47043d8..b703866f2e20b 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -4,7 +4,7 @@ * Copyright (C) 2018-2020 Linaro Ltd. */ -#include +#include #include #include #include @@ -51,7 +51,7 @@ * @config_path: Configuration space interconnect */ struct ipa_clock { - atomic_t count; + refcount_t count; struct mutex mutex; /* protects clock enable/disable */ struct clk *core; struct icc_path *memory_path; @@ -195,7 +195,7 @@ static void ipa_clock_disable(struct ipa *ipa) */ bool ipa_clock_get_additional(struct ipa *ipa) { - return !!atomic_inc_not_zero(&ipa->clock->count); + return refcount_inc_not_zero(&ipa->clock->count); } /* Get an IPA clock reference. If the reference count is non-zero, it is @@ -231,7 +231,7 @@ void ipa_clock_get(struct ipa *ipa) ipa_endpoint_resume(ipa); - atomic_inc(&clock->count); + refcount_set(&clock->count, 1); out_mutex_unlock: mutex_unlock(&clock->mutex); @@ -246,7 +246,7 @@ void ipa_clock_put(struct ipa *ipa) struct ipa_clock *clock = ipa->clock; /* If this is not the last reference there's nothing more to do */ - if (!atomic_dec_and_mutex_lock(&clock->count, &clock->mutex)) + if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex)) return; ipa_endpoint_suspend(ipa); @@ -294,7 +294,7 @@ struct ipa_clock *ipa_clock_init(struct device *dev) goto err_kfree; mutex_init(&clock->mutex); - atomic_set(&clock->count, 0); + refcount_set(&clock->count, 0); return clock; @@ -311,7 +311,7 @@ void ipa_clock_exit(struct ipa_clock *clock) { struct clk *clk = clock->core; - WARN_ON(atomic_read(&clock->count) != 0); + WARN_ON(refcount_read(&clock->count) != 0); mutex_destroy(&clock->mutex); ipa_interconnect_exit(clock); kfree(clock); From patchwork Thu Sep 17 17:39:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 313138 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp649627ilg; Thu, 17 Sep 2020 11:01:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx712WEAe/uBYk4C+u8S0s6TQSTqY/VgrbHe/8qWhsMo3bStiLzhmc6WncBOZfJbXyyUbrL X-Received: by 2002:a17:907:2078:: with SMTP id qp24mr34305212ejb.500.1600365713792; Thu, 17 Sep 2020 11:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600365713; cv=none; d=google.com; s=arc-20160816; b=Op0podKjP0xPwrrpUCHVOWyuJ0GPdk2BduXaLA72NQ9p9ljoewYvKuZg8bcf2pHeQ8 WUrxiZEy31XuBgIapFX7Y9Pfa6xNEJxK7jQEIzdQ65giwV7PdHr8aMqMYtCUHFXi8bsG oM4lCBSm3rnFvCPSGs0QIRzSyy+QWNxOi5q99T9v1R0sSSJuUJGpagYOa+uVAiizdFhY GHPFFej0uU9H0UzjkonkkTcXIKoUURmb7wkHn5NA7RP1Y5JXRCU/7ynmkTldqrxg07Bz M8Q5ZNhkfwACBmMgVOz1fmVztsSFpIDzllmgPGJfS4olVwLkrrjM+7Vb6fd4BoDPUAoe uR4Q== 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=6NeP1uYfvZjGbv5rdqBsPlN4zX/YVHDBY5G7Hrtv3Dw=; b=La/8U0kObrgYznHAN+IbuFT9S/BUY+0l+7jNwItDdwe2ktjGPzwSl/nW9V2eChwK2B a81/5fECNmea+PtRN+eLmHde4oLHjALI4XAdzfscpvZVReoIwMujlfLEtwj6eIJjPsgA B1EcYPX9XqQRidPzNWruxymZ+JNeY8SQUjR7ZHTtE+t+yCmS/sxmUvm16M2zQ6m+AcMd 8qym5eySeRSfW+3iN1EC2ifxJlYaxFwmy4Bxw/+3yn/PWPS5/Mw0ghk1N99ICL7plLCF qQnDosActD3QFoBLfLmo98tjevQqEsu8/PVRHRhyBadWY+3J2msOjXxZuVgU2xERhtOm mS3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ijnENzee; 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 qx23si443432ejb.355.2020.09.17.11.01.53; Thu, 17 Sep 2020 11:01:53 -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=ijnENzee; 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 S1726576AbgIQSBg (ORCPT + 8 others); Thu, 17 Sep 2020 14:01:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbgIQRjj (ORCPT ); Thu, 17 Sep 2020 13:39:39 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4559C061352 for ; Thu, 17 Sep 2020 10:39:33 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id u6so3118238iow.9 for ; Thu, 17 Sep 2020 10:39:33 -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=6NeP1uYfvZjGbv5rdqBsPlN4zX/YVHDBY5G7Hrtv3Dw=; b=ijnENzeeMfTLahfsLi5q0tEX3kQ7Lap1kUdtclu/SG+CxdoqD+j3runx39IWzp95tc eJYGKaDCQHWvzVi6MPZzje1uigbERnhu+W+Mr87RxUP5q3nDZ2JLBVcdT/D1J+3wAnRd DJQIoszoyycEjxstpylzxmvaHnAda147k7uKVYgxcWdB7HbVF5H+HJ/8zvTaatQknCJI peN3MR6Z/OGm76MA2UD80lOQ7IHypIvRK0xR/LuTv6C8AzwFHH4T7j35rwyETnfh0SbS JYtn17tL1pfl8i7xvPRiJ9EivLKBah9d2BY6X0zG+vKoMe6iVoELaD6lSqkE91SbodSm dnOw== 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=6NeP1uYfvZjGbv5rdqBsPlN4zX/YVHDBY5G7Hrtv3Dw=; b=MufeRrp0gRiam6iaX3aPMpYqC6yOaO8e0HGG9gX/oKOl3U2zN3GAkb+JnNxbUM7tfu mWLqOdY1zvkJLHhaxicTgyxsxomnL9jVUKkk9gHLJwB/1FA1ajg1AykTv+AZ/PdH0T5O U0nKfK7J+O7Ry8GjBQt1QKHmXapRqcND2oSuHYrGceBUWJtlFifIsI7HMVuOylnkzc80 PNO4doGPIudETkRXPcwCtDOu4Xa/tUgmvWTE3M2eXx09zbBgNbzzBTYSry0yN2TeVqQI /UG+SWFj15k+yWym6HPoDLhsOcnI9rSdlesXSzu1yN11TsUUIcJwS8mppmbwD+OnkJfZ x0Ig== X-Gm-Message-State: AOAM531btx7zoGgtvoYWdNc3Kt30qM/OZmyNby1HYM1JeYIICGNKg9gz fXDC3wS0xkG9eg3kFhVXshvRVw== X-Received: by 2002:a5e:9911:: with SMTP id t17mr24297534ioj.58.1600364373031; Thu, 17 Sep 2020 10:39:33 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:32 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 2/7] net: ipa: replace ipa->suspend_ref with a flag bit Date: Thu, 17 Sep 2020 12:39:21 -0500 Message-Id: <20200917173926.24266-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We take a clock reference in ipa_config() in order to prevent the the IPA clock from being shutdown until a power management suspend request arrives. An atomic field in the IPA structure records whether that extra reference had been taken. Rather than using an atomic to represent a Boolean value, define a new flags bitmap, and define a "clock held" flag to represent whether the extra clock reference has been taken. Signed-off-by: Alex Elder --- v2: New patch to use a bitmap bit rather than an atomic_t. v3: No change since v2. drivers/net/ipa/ipa.h | 14 ++++++++++++-- drivers/net/ipa/ipa_main.c | 14 +++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 407fee841a9a8..e02fe979b645b 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -27,15 +27,25 @@ struct ipa_clock; struct ipa_smp2p; struct ipa_interrupt; +/** + * enum ipa_flag - IPA state flags + * @IPA_FLAG_CLOCK_HELD: Whether IPA clock is held to prevent suspend + * @IPA_FLAG_COUNT: Number of defined IPA flags + */ +enum ipa_flag { + IPA_FLAG_CLOCK_HELD, + IPA_FLAG_COUNT, /* Last; not a flag */ +}; + /** * struct ipa - IPA information * @gsi: Embedded GSI structure + * @flags: Boolean state flags * @version: IPA hardware version * @pdev: Platform device * @modem_rproc: Remoteproc handle for modem subsystem * @smp2p: SMP2P information * @clock: IPA clocking information - * @suspend_ref: Whether clock reference preventing suspend taken * @table_addr: DMA address of filter/route table content * @table_virt: Virtual address of filter/route table content * @interrupt: IPA Interrupt information @@ -70,6 +80,7 @@ struct ipa_interrupt; */ struct ipa { struct gsi gsi; + DECLARE_BITMAP(flags, IPA_FLAG_COUNT); enum ipa_version version; struct platform_device *pdev; struct rproc *modem_rproc; @@ -77,7 +88,6 @@ struct ipa { void *notifier; struct ipa_smp2p *smp2p; struct ipa_clock *clock; - atomic_t suspend_ref; dma_addr_t table_addr; __le64 *table_virt; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 1fdfec41e4421..409375b96eb8f 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -84,7 +84,7 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) * endpoints will be resumed as a result. This reference will * be dropped when we get a power management suspend request. */ - if (!atomic_xchg(&ipa->suspend_ref, 1)) + if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) ipa_clock_get(ipa); /* Acknowledge/clear the suspend interrupt on all endpoints */ @@ -508,7 +508,7 @@ 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. */ - atomic_set(&ipa->suspend_ref, 1); + __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa_clock_get(ipa); ipa_hardware_config(ipa); @@ -544,7 +544,7 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) err_hardware_deconfig: ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); return ret; } @@ -562,7 +562,7 @@ static void ipa_deconfig(struct ipa *ipa) ipa_endpoint_deconfig(ipa); ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); } static int ipa_firmware_load(struct device *dev) @@ -777,7 +777,7 @@ static int ipa_probe(struct platform_device *pdev) dev_set_drvdata(dev, ipa); ipa->modem_rproc = rproc; ipa->clock = clock; - atomic_set(&ipa->suspend_ref, 0); + __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa->wakeup_source = wakeup_source; ipa->version = data->version; @@ -913,7 +913,7 @@ static int ipa_suspend(struct device *dev) struct ipa *ipa = dev_get_drvdata(dev); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); return 0; } @@ -933,7 +933,7 @@ static int ipa_resume(struct device *dev) /* This clock reference will keep the IPA out of suspend * until we get a power management suspend request. */ - atomic_set(&ipa->suspend_ref, 1); + __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa_clock_get(ipa); return 0; From patchwork Thu Sep 17 17:39:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 260702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABEDC2BBD1 for ; Thu, 17 Sep 2020 17:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45694208E4 for ; Thu, 17 Sep 2020 17:59:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="U405yXMX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbgIQR6v (ORCPT ); Thu, 17 Sep 2020 13:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbgIQRjl (ORCPT ); Thu, 17 Sep 2020 13:39:41 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0236EC061356 for ; Thu, 17 Sep 2020 10:39:35 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id g128so3103809iof.11 for ; Thu, 17 Sep 2020 10:39:34 -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=1JC8Jq8l5d3FMIOqG3s3tOJTv29rQ/B9PWS+aSrpLGw=; b=U405yXMXivO9GetXit4zYyFid6bzqqIA4UwrlGS5LHR/5sRVogi2Yb/2UL2pKQhQ6I h2y8mLHqugpSytlwllaXNvD6yLD2LkMx6JYV9OkEP9tOlOXqlqXR51d7I0PXmXIgGSsN Z56BE5EQTRP3G5Ug/DWidnc4tOtRGffpZTTssuJqbgiX/9ELY7wXCL/+ZS3FxPlQWGF6 macQV8BiucaZiMVMEUIulgydWrNK1duaqGU3OOj+9FOBLjc3olAiIFCgp8R3MkMyWWgA 5qS+MG6/cUb69sajAlTpfCU8wIwH/K+AT3KB9jsPOHI/1Cg3LPckfVKgyvafgZhfiaOt 2cXA== 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=1JC8Jq8l5d3FMIOqG3s3tOJTv29rQ/B9PWS+aSrpLGw=; b=gIvXgGADX6Q6NC6JD0j1fdi796g+OL8PJfKCaj/sXkT98y1Zt97guBY7UDuGYUYd0B Tw9co5uTq+i509C/WO+0ttSCsjHuQb0ZPCYpyavjd7m7VTcaunTRSCn1H2UygrpSJfqN Uz+6Qt1PSHz8zf608FtSK5D/f9bDNqhSEupLLJm4Q50SJaDbYUq72cmIbRWy1Nf8sZoY 7POenYdsag0ytwgf1UvYtU2sPicJMZSSU0x8Y6u4AKa2jSsM/fk/o02BIchqdJSwkSCL 4hr+s3/hwTwKzKk8Az2Wa/U1OtYqb/sGkfC7Ji6Vy6wSYFavr2fCDQxO/VPebwr+C/Bt OUyA== X-Gm-Message-State: AOAM532Q7nV6HzA8dlV17iqXCNRQelK8BGbxqT+uyj/QmCK7hvHjTWjw ELpETEKsGsnFxhHzp+pTmZHezgHV1C3SAg== X-Google-Smtp-Source: ABdhPJybbRBFZ3GvAgFEYWFu2IpIWGxn/o7bQ4EoBVHUsEH7hygQHQnFqx2LFmtttDZyH5am5EUs7Q== X-Received: by 2002:a05:6638:144:: with SMTP id y4mr27177041jao.61.1600364374081; Thu, 17 Sep 2020 10:39:34 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:33 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 3/7] net: ipa: manage endpoints separate from clock Date: Thu, 17 Sep 2020 12:39:22 -0500 Message-Id: <20200917173926.24266-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, when (before) the last IPA clock reference is dropped, all endpoints are suspended. And whenever the first IPA clock reference is taken, all endpoints are resumed (or started). In most cases there's no need to start endpoints when the clock starts. So move the calls to ipa_endpoint_suspend() and ipa_endpoint_resume() out of ipa_clock_put() and ipa_clock_get(), respectiely. Instead, only suspend endpoints when handling a system suspend, and only resume endpoints when handling a system resume. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson --- v3: Added Bjorn's reviewed-by tag. drivers/net/ipa/ipa_clock.c | 14 ++++---------- drivers/net/ipa/ipa_main.c | 8 ++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index b703866f2e20b..a2c0fde058199 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -200,9 +200,8 @@ bool ipa_clock_get_additional(struct ipa *ipa) /* 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 clock (and - * interconnects) are enabled suspended endpoints (if any) are resumed - * before returning. + * 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. @@ -229,17 +228,14 @@ void ipa_clock_get(struct ipa *ipa) goto out_mutex_unlock; } - ipa_endpoint_resume(ipa); - refcount_set(&clock->count, 1); out_mutex_unlock: mutex_unlock(&clock->mutex); } -/* Attempt to remove an IPA clock reference. If this represents the last - * reference, suspend endpoints and disable the clock (and interconnects) - * under protection of a mutex. +/* 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) { @@ -249,8 +245,6 @@ void ipa_clock_put(struct ipa *ipa) if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex)) return; - ipa_endpoint_suspend(ipa); - ipa_clock_disable(ipa); mutex_unlock(&clock->mutex); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 409375b96eb8f..4d5394bcfe47e 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -907,11 +907,15 @@ static int ipa_remove(struct platform_device *pdev) * Return: Always returns zero * * 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) { struct ipa *ipa = dev_get_drvdata(dev); + ipa_endpoint_suspend(ipa); + ipa_clock_put(ipa); __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); @@ -925,6 +929,8 @@ static int ipa_suspend(struct device *dev) * Return: Always returns 0 * * 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) { @@ -936,6 +942,8 @@ static int ipa_resume(struct device *dev) __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa_clock_get(ipa); + ipa_endpoint_resume(ipa); + return 0; } From patchwork Thu Sep 17 17:39:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 313136 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp647197ilg; Thu, 17 Sep 2020 10:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcuUfnRKn3+q862JL3ZrEc2WWSQHsHXmwZSJkQ1nHTfrzTyHE3snOhEdL5PFplRQY7FPLD X-Received: by 2002:a17:906:275b:: with SMTP id a27mr33386552ejd.190.1600365523060; Thu, 17 Sep 2020 10:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600365523; cv=none; d=google.com; s=arc-20160816; b=v66WKYYLa50BqfIIrRYDD4zCE9qhT5hwQ/N1JvwjmJT/JRTsRds2BLGYYJz2Qrc4SX KAyUdqKel4UfcKKgCrz87BayFLcF0KTfo6lxFyQ3+ii38lfT9WvepdaqdLMhaK9huhDW 6Ue8uduI+0wSjoqt9eODfJ72zNOYaZiO1KalQarKfldaPkgThTrI4bZWffzV+leGtVqX TwDMDGynRpTrGD4bANLNzxVxai4FmyxYIM732J0TP4XAYtM6AqJYmK4K0ssIEaxkv37b TuCP6XG1e0ao6g6ZsWrBRucqUXKxHAkey4l8BAuxcOmAyWF9E1Us7MmskaUHyuRagagQ jZaw== 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=rTpW3FNcBGaT4VwfmVMgzfLSYM7ObfFzlWr4lD0H81Y=; b=D4guV0BPePYLN4Fbs0uIZK4sZ8yE2e3ititTJYwoQBFI2uMNaC6M7TBiPeVHTTMb8+ HkimJfYub4jmev9/rU/Gs2wcNfCW+Vm6P3jHnSlAp5y3uhJ6ifHafC+pSNtdbGQydFbD eV6V8BSNTSpP6jHFefvP5qcEuilC9PHC+oVqKEVMkgjNpKIL4Ftpx5R+a1gwtD0iK8l1 6/sPa7H+3Gc1mMlhF8kIPHIZ9ky7PTK6h/RwuqWarMOR0eCZKMu+LvB3saAHlxsRjC2+ +DDSR89Pe95StGtYEWutO7CLudWBS0vTt6JarG2Q59nzWvhxcSxdBBfexOpVL3sBC4e8 JcTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QlhMnJ4R; 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 da18si276826edb.466.2020.09.17.10.58.42; Thu, 17 Sep 2020 10:58: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=QlhMnJ4R; 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 S1726634AbgIQR6j (ORCPT + 8 others); Thu, 17 Sep 2020 13:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbgIQRjl (ORCPT ); Thu, 17 Sep 2020 13:39:41 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6DC1C0612F2 for ; Thu, 17 Sep 2020 10:39:35 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id b6so3128438iof.6 for ; Thu, 17 Sep 2020 10:39:35 -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=rTpW3FNcBGaT4VwfmVMgzfLSYM7ObfFzlWr4lD0H81Y=; b=QlhMnJ4RWiyKxprNM4XBp9qS7dGEy7oolZwAPHOSewO4Rq9qLs8XsRARWl1gqte78Y LzV0pDl/qub20uTH0brcbvS2e36lStDuYI5IvZmc5uIKMMOLCX1UXhNh/HrWvQAv7Xgc rY+X4dB493DYPdFpY0u6WMPeogFqMUDbVOxuKXs6jEosh7MH+qTVwoeBV3AIOhxisJyX OvwBko98YQRgrAK0OZWhSO0jE8yaZ4QsiH0UR/1qtuBIngVQixXhIiOM+8wgacPOLtt5 hgavctH+HrKhakOrcfbaIW7pn8BaXHyujRsUJvxX99hFHCI5WBfXleQE052CYmc4bz9F 2XTg== 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=rTpW3FNcBGaT4VwfmVMgzfLSYM7ObfFzlWr4lD0H81Y=; b=nTqxzKWxaBaIKLD2tiKscNWGSWUmafTVqm3EpGjKumyqL79pIJeGsL1oBxvREVzLAv MQt/dHD/DHF/E0/RR/kq/dkMyJQAbToIL5Pbl3P/UuCoH8/i7teDghK+v4QrHiN9UgAt ka1dIcswfzVEI3BQo8vhpP8TAcRM+SPUeXvw8GrGZlTgrZlKalTNW0F6in5/P6/EPaIg YOzyfujWbsSr7GnpbXcxqjrjemm3ltW5n+bbb30QGKoIHiGCYwlI96QJipX3DJzALWY5 U/o/pHVLJZCIi0u+r3V2SF7inAhHl39NRpjUvxRLFzhhokC1cO2JwSkgqkvOoywUA5aM T/FA== X-Gm-Message-State: AOAM532PVXAK0/IkvF+0qYmSYpPkb3aJHs7ikf1fLiJBv4meZw+cj3Iz gUX19i5UX3CWei2N5JG5eti/BQ== X-Received: by 2002:a6b:b846:: with SMTP id i67mr24671016iof.103.1600364375115; Thu, 17 Sep 2020 10:39:35 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:34 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 4/7] net: ipa: use device_init_wakeup() Date: Thu, 17 Sep 2020 12:39:23 -0500 Message-Id: <20200917173926.24266-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The call to wakeup_source_register() in ipa_probe() does not do what it was intended to do. Call device_init_wakeup() in ipa_setup() instead, to set the IPA device as wakeup-capable and to initially enable wakeup capability. When we receive a SUSPEND interrupt, call pm_wakeup_dev_event() with a zero processing time, to simply call for a resume without any other processing. The ipa_resume() call will take care of waking things up again, and will handle receiving the packet. Note that this gets rid of a clock reference counting bug that occurred when handling an IPA SUSPEND interrupt. Specifically, ipa_suspend_handler() took an IPA clock reference *in addition* to the one taken by ipa_resume(). There is no need to back-port this fix however, because it only affects code that was not previously working (this patch is part of fixing that). Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson --- v3: Added Bjorn's reviewed-by tag. drivers/net/ipa/ipa.h | 2 -- drivers/net/ipa/ipa_main.c | 42 ++++++++++++++++---------------------- 2 files changed, 18 insertions(+), 26 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index e02fe979b645b..c688155ccf375 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -114,8 +114,6 @@ struct ipa { void *zero_virt; size_t zero_size; - struct wakeup_source *wakeup_source; - /* Bit masks indicating endpoint state */ u32 available; /* supported by hardware */ u32 filter_map; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 4d5394bcfe47e..4e2508bb1bf80 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -75,17 +75,19 @@ * @ipa: IPA pointer * @irq_id: IPA interrupt type (unused) * - * When in suspended state, the IPA can trigger a resume by sending a SUSPEND - * IPA interrupt. + * If an RX endpoint is in suspend state, and the IPA has a packet + * destined for that endpoint, the IPA generates a SUSPEND interrupt + * to inform the AP that it should resume the endpoint. If we get + * one of these interrupts we just resume everything. */ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { - /* Take a a single clock reference to prevent suspend. All - * endpoints will be resumed as a result. This reference will - * be dropped when we get a power management suspend request. + /* 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. */ if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) - ipa_clock_get(ipa); + pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); /* Acknowledge/clear the suspend interrupt on all endpoints */ ipa_interrupt_suspend_clear_all(ipa->interrupt); @@ -106,6 +108,7 @@ int ipa_setup(struct ipa *ipa) { struct ipa_endpoint *exception_endpoint; struct ipa_endpoint *command_endpoint; + struct device *dev = &ipa->pdev->dev; int ret; /* Setup for IPA v3.5.1 has some slight differences */ @@ -123,6 +126,10 @@ int ipa_setup(struct ipa *ipa) ipa_uc_setup(ipa); + ret = device_init_wakeup(dev, true); + if (ret) + goto err_uc_teardown; + ipa_endpoint_setup(ipa); /* We need to use the AP command TX endpoint to perform other @@ -158,7 +165,7 @@ int ipa_setup(struct ipa *ipa) ipa->setup_complete = true; - dev_info(&ipa->pdev->dev, "IPA driver setup completed successfully\n"); + dev_info(dev, "IPA driver setup completed successfully\n"); return 0; @@ -173,6 +180,8 @@ int ipa_setup(struct ipa *ipa) ipa_endpoint_disable_one(command_endpoint); err_endpoint_teardown: ipa_endpoint_teardown(ipa); + (void)device_init_wakeup(dev, false); +err_uc_teardown: ipa_uc_teardown(ipa); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); ipa_interrupt_teardown(ipa->interrupt); @@ -200,6 +209,7 @@ static void ipa_teardown(struct ipa *ipa) command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; ipa_endpoint_disable_one(command_endpoint); ipa_endpoint_teardown(ipa); + (void)device_init_wakeup(&ipa->pdev->dev, false); ipa_uc_teardown(ipa); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); ipa_interrupt_teardown(ipa->interrupt); @@ -709,7 +719,6 @@ static void ipa_validate_build(void) */ static int ipa_probe(struct platform_device *pdev) { - struct wakeup_source *wakeup_source; struct device *dev = &pdev->dev; const struct ipa_data *data; struct ipa_clock *clock; @@ -758,19 +767,11 @@ static int ipa_probe(struct platform_device *pdev) goto err_clock_exit; } - /* Create a wakeup source. */ - wakeup_source = wakeup_source_register(dev, "ipa"); - if (!wakeup_source) { - /* The most likely reason for failure is memory exhaustion */ - ret = -ENOMEM; - goto err_clock_exit; - } - /* Allocate and initialize the IPA structure */ ipa = kzalloc(sizeof(*ipa), GFP_KERNEL); if (!ipa) { ret = -ENOMEM; - goto err_wakeup_source_unregister; + goto err_clock_exit; } ipa->pdev = pdev; @@ -778,7 +779,6 @@ static int ipa_probe(struct platform_device *pdev) ipa->modem_rproc = rproc; ipa->clock = clock; __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); - ipa->wakeup_source = wakeup_source; ipa->version = data->version; ret = ipa_reg_init(ipa); @@ -857,8 +857,6 @@ static int ipa_probe(struct platform_device *pdev) ipa_reg_exit(ipa); err_kfree_ipa: kfree(ipa); -err_wakeup_source_unregister: - wakeup_source_unregister(wakeup_source); err_clock_exit: ipa_clock_exit(clock); err_rproc_put: @@ -872,11 +870,8 @@ static int ipa_remove(struct platform_device *pdev) struct ipa *ipa = dev_get_drvdata(&pdev->dev); struct rproc *rproc = ipa->modem_rproc; struct ipa_clock *clock = ipa->clock; - struct wakeup_source *wakeup_source; int ret; - wakeup_source = ipa->wakeup_source; - if (ipa->setup_complete) { ret = ipa_modem_stop(ipa); if (ret) @@ -893,7 +888,6 @@ static int ipa_remove(struct platform_device *pdev) ipa_mem_exit(ipa); ipa_reg_exit(ipa); kfree(ipa); - wakeup_source_unregister(wakeup_source); ipa_clock_exit(clock); rproc_put(rproc); From patchwork Thu Sep 17 17:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 260703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0430C433E2 for ; Thu, 17 Sep 2020 17:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B874208E4 for ; Thu, 17 Sep 2020 17:56:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xcjO2apo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgIQR4G (ORCPT ); Thu, 17 Sep 2020 13:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbgIQRjm (ORCPT ); Thu, 17 Sep 2020 13:39:42 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6ADDC06121D for ; Thu, 17 Sep 2020 10:39:37 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id x2so3142052ilm.0 for ; Thu, 17 Sep 2020 10:39:37 -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=c6CNu1LYWNz4YTYxiYPRvkqPWBqpDM+ovhrPcXJRY08=; b=xcjO2apobyoynwr8mlo+BSGWBbL2VnaNrO/p5X+YCAfoQW0L3BTq5m4l9/P5y82U1b 31XYlB/+9ASi1ngE2ipcUdePPYfd3yRJrFhgHXqqU1y6x4ymTawjEeEyat16xG3dy3JI dUQ+qPqLg/kCTQPGyc/nWbHkBo1CJFnyQzLvnIhoGjtUbjGVK3gQQL+UfJFTv1JSMMVb 4trRT8nGQQxMY4b9jpbIHpHzq6QLy6KhCUOO066hxad3KHSQtV0btNKx2hRwsbOA/2RS /22uXRYgObFyCedDtzl17so7ac6enMRyDVgttaNomlW33nsHMxuUCP3B/RlQjVJJYY1t Z+cA== 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=c6CNu1LYWNz4YTYxiYPRvkqPWBqpDM+ovhrPcXJRY08=; b=mgqvmMJ6bIwuUW83lPMS8Z90rZdsanQ4Zebd21TkyyX2chKXyT046dFPZBxbkF19H3 CJ9Zoh1+TJs16qkp2RSFfZvMrpvmNNiU9i7Hpyuf6E/3qMqNwAVpQEy6hQJaAiSBR7vz v/QIVklaUYmy42OgBkUccrVyM8Qfpa/mhffFb4DXUgEovg5tbN7bh6rOnketlWp1r98d 9x8ppP8O3DKO5HSCzM01zCHDqkHyyXDYrh/GNy2//vWu/HHjTc3LpS+Xg9owK7qVenE4 xcGeZudA/+fjYbEaR4gIYKnAOb1FJffvFZOnNWLimVCIZHMTcPMBBUULIwizYzAc5mc8 pY4g== X-Gm-Message-State: AOAM533R0qPsHostz/fStvuO7XKcEX1bRvxYzE7GjgOD8P3PNyvFvz2y AJ3O6YKRjFOi+9Igt6OYq0Kygg== X-Google-Smtp-Source: ABdhPJwaFsCSU3TPi/ucp9NUFbo+IVA1+K0seDDcl5QN5d1HKoNl+4jATzsWhbdJY0CYLF0bWqLxcw== X-Received: by 2002:a92:8b0e:: with SMTP id i14mr485068ild.28.1600364376991; Thu, 17 Sep 2020 10:39:36 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:35 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 5/7] net: ipa: repurpose CLOCK_HELD flag Date: Thu, 17 Sep 2020 12:39:24 -0500 Message-Id: <20200917173926.24266-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The previous patch causes a system resume to be triggered when a packet is available for receipt on a suspended RX endpoint. The CLOCK_HELD flag was previously used to indicate that an extra clock reference was held, preventing suspend. But we no longer need such a flag: - We take an initial reference in ipa_config(). - That reference is held until ipa_suspend() releases it. - A subsequent system resume leads to a reference getting re-acquired in ipa_resume(). - This can repeat until ultimately the module is removed, where ipa_remove() releases the reference. We no longer need a special flag to determine whether this extra reference is held--it is, provided probe has completed successfully and the driver is not suspended (or removed). On the other hand, once suspended, it's possible for more than one endpoint to trip the IPA SUSPEND interrupt, and we only want to trigger the system resume once. So repurpose the Boolean CLOCK_HELD flag to record whether the IPA SUSPEND handler should initiate a system resume. The flag will be be cleared each time ipa_suspend() is called, *before* any endpoints are suspended. And it will be set inside the IPA SUSPEND interrupt handler exactly once per suspend. Rename the flag IPA_FLAG_RESUMED to reflect its new purpose. Signed-off-by: Alex Elder --- v3: New; eliminated need for "clock held" flag, as Bjorn suggested. drivers/net/ipa/ipa.h | 6 +++--- drivers/net/ipa/ipa_main.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index c688155ccf375..6c2371084c55a 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -29,11 +29,11 @@ struct ipa_interrupt; /** * enum ipa_flag - IPA state flags - * @IPA_FLAG_CLOCK_HELD: Whether IPA clock is held to prevent suspend - * @IPA_FLAG_COUNT: Number of defined IPA flags + * @IPA_FLAG_RESUMED: Whether resume from suspend has been signaled + * @IPA_FLAG_COUNT: Number of defined IPA flags */ enum ipa_flag { - IPA_FLAG_CLOCK_HELD, + IPA_FLAG_RESUMED, IPA_FLAG_COUNT, /* Last; not a flag */ }; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 4e2508bb1bf80..1044758b501d2 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -86,7 +86,7 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) * More than one endpoint could signal this; if so, ignore * all but the first. */ - if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + if (!test_and_set_bit(IPA_FLAG_RESUMED, ipa->flags)) pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); /* Acknowledge/clear the suspend interrupt on all endpoints */ @@ -518,7 +518,6 @@ 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. */ - __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa_clock_get(ipa); ipa_hardware_config(ipa); @@ -554,7 +553,6 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) err_hardware_deconfig: ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); return ret; } @@ -572,7 +570,6 @@ static void ipa_deconfig(struct ipa *ipa) ipa_endpoint_deconfig(ipa); ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); } static int ipa_firmware_load(struct device *dev) @@ -778,7 +775,6 @@ static int ipa_probe(struct platform_device *pdev) dev_set_drvdata(dev, ipa); ipa->modem_rproc = rproc; ipa->clock = clock; - __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa->version = data->version; ret = ipa_reg_init(ipa); @@ -908,10 +904,15 @@ static int ipa_suspend(struct device *dev) { struct ipa *ipa = dev_get_drvdata(dev); + /* When a suspended RX endpoint has a packet ready to receive, we + * get an IPA SUSPEND interrupt. We trigger a system resume in + * that case, but only on the first such interrupt since suspend. + */ + __clear_bit(IPA_FLAG_RESUMED, ipa->flags); + ipa_endpoint_suspend(ipa); ipa_clock_put(ipa); - __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); return 0; } @@ -933,7 +934,6 @@ static int ipa_resume(struct device *dev) /* This clock reference will keep the IPA out of suspend * until we get a power management suspend request. */ - __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); ipa_clock_get(ipa); ipa_endpoint_resume(ipa); From patchwork Thu Sep 17 17:39:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 260704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1D6EC43461 for ; Thu, 17 Sep 2020 17:55:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5491020707 for ; Thu, 17 Sep 2020 17:55:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="K3Ac1DXp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgIQRzV (ORCPT ); Thu, 17 Sep 2020 13:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbgIQRjm (ORCPT ); Thu, 17 Sep 2020 13:39:42 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D68D0C061220 for ; Thu, 17 Sep 2020 10:39:38 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id j2so3128210ioj.7 for ; Thu, 17 Sep 2020 10:39:38 -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=HrZCFxVFcYmGpM7JLW5ZudWd5nkjs2XIh9Pd/OiKsY0=; b=K3Ac1DXpCUDFckXVqfzLOHAWwGMN6dq3ot6IW6bcmrnjNhVJyoUuGUkN8jQkaAuLfP 8M+jfohg5uj6njFc14tkJPL4rmiXsOdeXXT5q/pUVKBYSlDur1WwBf575bfX3PkkEKUr AeJVa+zjaJWj/R/zNHs0Q1LHsn514TU0WhQEHEdvYvWzSRnyPG+GB5O894O4cnR3RVu8 q+zeXa4zSuLLDW/3/Ko3B80JQFlb7jSb7GP/5+gUwajDg0JfDrRwG3JtTPhJa2Xij5pA /DNzmd43ZwZ/x5Bq5QZdLixq9XORb5pBNWozbasYrdW1qUP5Kj03mbmS4ERHiuzhwnaN ZkJA== 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=HrZCFxVFcYmGpM7JLW5ZudWd5nkjs2XIh9Pd/OiKsY0=; b=Wpup2OR32gpxA6wYtn6xUfozUsfE0tXqJJkx6KWTZzzJ9qVKAIsEaSbjlY6AyZ3bSD kU+hprIPxW4LUoGuihbMWcL4rJJwdky5aWC7iwcUWICRIwfXRcAXsr5R6Dj+qk2MQAeq DKW8IIlw0EGHQHJ86bGqbx2XWefz797y5KbIlSGSjVGb/UX3H97yxKNabAZhKMLxKuvX 34ImmYTxdA3BWKdl5rSIkuPBF0qNjq/bDBWe9TmCD5OPHxtoWTF6kHJtalC2QhKtA4il Yick+ho3wW7dSNHt9ES4YKLKsMATBUGJSGprJozwJONIAA2QqBMJOuzBMU8X0/jX/Lb+ y8og== X-Gm-Message-State: AOAM530Xu1ajE7A+WZjb9aKBWvN8qQmGLfByYmEggegBmXSyGGOleW32 NIXpZAKS9hh3LfHiHimubYW8+g== X-Google-Smtp-Source: ABdhPJz+iPi9RVcnb1dl99VPd/ct60p0U2gUgsb/VWfvS5Z46FlYjdvhnktkK4WE62uiKjzi0CNqzg== X-Received: by 2002:a05:6602:2201:: with SMTP id n1mr23796879ion.35.1600364378167; Thu, 17 Sep 2020 10:39:38 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:37 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 6/7] net: ipa: enable wakeup on IPA interrupt Date: Thu, 17 Sep 2020 12:39:25 -0500 Message-Id: <20200917173926.24266-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that we handle wakeup interrupts properly, arrange for the IPA interrupt to be treated as a wakeup interrupt. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson --- v3: Added Bjorn's reviewed-by tag. drivers/net/ipa/ipa_interrupt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 90353987c45fc..cc1ea28f7bc2e 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -237,8 +237,16 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa) goto err_kfree; } + ret = enable_irq_wake(irq); + if (ret) { + dev_err(dev, "error %d enabling wakeup for \"ipa\" IRQ\n", ret); + goto err_free_irq; + } + return interrupt; +err_free_irq: + free_irq(interrupt->irq, interrupt); err_kfree: kfree(interrupt); @@ -248,6 +256,12 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa) /* Tear down the IPA interrupt framework */ void ipa_interrupt_teardown(struct ipa_interrupt *interrupt) { + struct device *dev = &interrupt->ipa->pdev->dev; + int ret; + + ret = disable_irq_wake(interrupt->irq); + if (ret) + dev_err(dev, "error %d disabling \"ipa\" IRQ wakeup\n", ret); free_irq(interrupt->irq, interrupt); kfree(interrupt); } From patchwork Thu Sep 17 17:39:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 313134 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp645459ilg; Thu, 17 Sep 2020 10:55:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaEZ1HkttixDGO0XN8aee/+zsamX2KTaeRWC9eRO62s6DNjiqujh0oPxXEJY2KoNM+wFHf X-Received: by 2002:a17:906:2552:: with SMTP id j18mr31302942ejb.476.1600365357969; Thu, 17 Sep 2020 10:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600365357; cv=none; d=google.com; s=arc-20160816; b=xeed6OKjIavialWoWKLa1KXe69JeoKIeYmcfZccvMhHtIzpd8mqbRuWHdVFcrgrbEO 6a+FZBHftviuIBkx8QY+9lUuyMJsdHFr2tuhLWH92IEdRoS0qe7ZjDRpPB95sdClcsyY t1UyVqz4tTkZQ/Gz+nwsiKLPaWA4Yb2Wh9LbnJz0c0Clmfup+UAGVNN4AQ+8yEu43cI3 RgRKoIRHLiUBPesgfN8nVE8fbHCkeGPkkh8kDMQk9YWcvnHRmAhXmmVv5yoGYWuhtbsE eAcXpvEsWFCfiU2h7wDQHSZF6Lr9QmpOFbVdUHfuzlhqrrhJjCb+ZtFppwOf0IuDlPuf DQMQ== 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=QtUWdu0boBZfHKiwa2SwHiBOCnpmKxcR3V7b9dhKC/U=; b=bArVlwSVVnd+ulPprmaUHNpLemKyPkL3NomutylNvDw6zKyk6ljyMlYcIs+WjxP6Sq O3/6oF4Tc2L2nbteJnZMQu8iQTacn+D9deuPGapJN1OTrSFUQOPB3KHCtTFIXKJtkXNo PBghTUghJ8VtHqPBXsqbDtoabMRY9Rb+3n+cycbHkRCsDDb6l8ejxRUhzXtzTI811eEv FMnfO5H3hS3q1s9/NJvGOT5fSDYXGEq3VRjR4+v466Eo5vV51J4/Kc/9ffLZEsBsnNC7 BdKPt+BgZgT5ZV8ZrpmmVwx/0N0ppniroff1UGXXh5az27b465KTBBwxCQ5jRuznvIz9 qR/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZcH1VLRn; 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 t17si408023eje.331.2020.09.17.10.55.57; Thu, 17 Sep 2020 10:55:57 -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=ZcH1VLRn; 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 S1726531AbgIQRzv (ORCPT + 8 others); Thu, 17 Sep 2020 13:55:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbgIQRjm (ORCPT ); Thu, 17 Sep 2020 13:39:42 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACBBC061221 for ; Thu, 17 Sep 2020 10:39:41 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id t18so3105936ilp.5 for ; Thu, 17 Sep 2020 10:39:41 -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=QtUWdu0boBZfHKiwa2SwHiBOCnpmKxcR3V7b9dhKC/U=; b=ZcH1VLRn9FP/6UN0owL7QxSHThCvJQxUHQ/eE5TwtAGhO+hOJlndEktTeRQunrxBqF XujShKHmGZZW9ptlkrTXO6Hy9Gv0zfnSAi7qLkXCBO3KEBsjAeF7VqMWzktTKAtyZPAH vclwSl1YMLKxdCW1prHwcBIvTDNclJjMLzAJbd8LS0N6kN1gcTM9plyaz19eD1ELf/oT OqrKX1cJE7YhmrtO/tsbOzWswzUWWlGItPyfINy8DeM5pvT4Z+RA+DVZKiq/RyNelDzY OuesX2lAGm0GbkgVP3hGoWdtAK6gZzIdUg1nb3H/HYF1lF1j5qKXrkdWwkAObTkkjSqy O2QA== 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=QtUWdu0boBZfHKiwa2SwHiBOCnpmKxcR3V7b9dhKC/U=; b=fYZ1GcaAT+VfvK/o2LyLF/+tzLwiizFnUJRrXr3EpOpbOVxRp+ncqSOmxgSttcNqfO DtHTbz01SvRj5UL6bSMFTKiLVi4J6rigf2JBat67AB07zoxhTVtRyYaChPIRh7Uw1uaQ n0Y/LwvxiFEhA7Tc4oTSkr8H/nydRHnFPXe/XJ/WfQpcuGUOlmZz6Vmb2DqeU/KYkW/s pjzLgKCnAGQDKgFVqhWbWwa1vMHKueB0U5yGDM8pyfi0F9sy8suAOTt83e+DimXcv2EM wFkP6PpGogGlmucloMO0LcmpFDSsVa79Y6uHz1ytuXn4iPNAon9AcjQBfCsPE0vx8sEU h8Ng== X-Gm-Message-State: AOAM530tLeg3ImAwceaI2WjfQ1dAl2GglwVNwNNbfuhw5R7MrnY1Fvgj bIX0I0aICZ9gaaD+iXMsV3GH3oajLBuEfw== X-Received: by 2002:a92:ca85:: with SMTP id t5mr9989407ilo.254.1600364379249; Thu, 17 Sep 2020 10:39:39 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l6sm192725ilt.34.2020.09.17.10.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 10:39:38 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 7/7] net: ipa: do not enable GSI interrupt for wakeup Date: Thu, 17 Sep 2020 12:39:26 -0500 Message-Id: <20200917173926.24266-8-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200917173926.24266-1-elder@linaro.org> References: <20200917173926.24266-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We now trigger a system resume when we receive an IPA SUSPEND interrupt. We should *not* wake up on GSI interrupts. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson --- v3: Added Bjorn's reviewed-by tag. drivers/net/ipa/gsi.c | 17 ++++------------- drivers/net/ipa/gsi.h | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 0e63d35320aaf..cb75f7d540571 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1987,31 +1987,26 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch, } gsi->irq = irq; - ret = enable_irq_wake(gsi->irq); - if (ret) - dev_warn(dev, "error %d enabling gsi wake irq\n", ret); - gsi->irq_wake_enabled = !ret; - /* Get GSI memory range and map it */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi"); if (!res) { dev_err(dev, "DT error getting \"gsi\" memory property\n"); ret = -ENODEV; - goto err_disable_irq_wake; + goto err_free_irq; } size = resource_size(res); if (res->start > U32_MAX || size > U32_MAX - res->start) { dev_err(dev, "DT memory resource \"gsi\" out of range\n"); ret = -EINVAL; - goto err_disable_irq_wake; + goto err_free_irq; } gsi->virt = ioremap(res->start, size); if (!gsi->virt) { dev_err(dev, "unable to remap \"gsi\" memory\n"); ret = -ENOMEM; - goto err_disable_irq_wake; + goto err_free_irq; } ret = gsi_channel_init(gsi, prefetch, count, data, modem_alloc); @@ -2025,9 +2020,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch, err_iounmap: iounmap(gsi->virt); -err_disable_irq_wake: - if (gsi->irq_wake_enabled) - (void)disable_irq_wake(gsi->irq); +err_free_irq: free_irq(gsi->irq, gsi); return ret; @@ -2038,8 +2031,6 @@ void gsi_exit(struct gsi *gsi) { mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); - if (gsi->irq_wake_enabled) - (void)disable_irq_wake(gsi->irq); free_irq(gsi->irq, gsi); iounmap(gsi->virt); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 061312773df09..3f9f29d531c43 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -150,7 +150,6 @@ struct gsi { struct net_device dummy_dev; /* needed for NAPI */ void __iomem *virt; u32 irq; - bool irq_wake_enabled; u32 channel_count; u32 evt_ring_count; struct gsi_channel channel[GSI_CHANNEL_COUNT_MAX];