From patchwork Sat Sep 12 00:45: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: 249735 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp339424ilk; Fri, 11 Sep 2020 17:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0+XNcLbgVPLxHAZa4s/a6f6zFF9sOpIgkGgc4wfthciJjbG6QYMFfbHxkyMM0Hm3MeOkl X-Received: by 2002:a50:d304:: with SMTP id g4mr5412853edh.248.1599871622342; Fri, 11 Sep 2020 17:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871622; cv=none; d=google.com; s=arc-20160816; b=sL9BBH9siyqN6zRHMdcN6A7dStKMvlJCNHx/Qb6sk0SF6pWe/Ypw8xdrwYXZ53LsRC jQ28HV7HS76zmTtDf7LYjI5hmsFSC/zsJOHbKWMEgJKUpUa9PLJclXcULSZy/1ioVrXj 2FSWeUdlQvg7f/roYuHLsAkQEuBiLJSQIeHNRduIb0LepJUvTeuPQpHQ0r4GqlIxzFv/ RrtSPT2Ffw7U5kSfjCBhPWyWfMl06IBuI4jLn6OJ99cT1TZvqGNflPC5gXauKjOanqRh hxsy1trSifpjeHd49Fx/5xA+iRXnaGbv9D90pfg8n2NZPC5MieEJWNnNMNFya+omhfpX 1q1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YDLLvKUFt4FLtBLmAvx/wOC4eEuYKN2bBtAm+5nRw3k=; b=U4pTUt47GjTliUCNNVFcxTnAOpBtQ8uVG00dP91ZYzckEaDPGUN7XpsfWlBPsHhhOV iKZytS6JWfDRNSv1OFXu2D/U2J9c22grF/pA1Shj5vGEsNd8AlPO5wpfAn+FvTEWIHv/ YTDXM9hGcaQ0auLMlSIGv8H/7qreE4MkZptTpmXDsbuF4hG68B0jP5LrhF3S4y+H1XKr HnLZya1BFfnp4Phf/sX0tCGKl7o9Cl435ixGV6GjRnvv1553hdKry3CWRVb4yoSb0RYf IGQ8C7YzI3FXKE79Rc51MpBVqBHtLnVUVEjO8hcsDxT24eLWBPivBhQiRhjOU02qGnn2 U9kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QArGIRWF; 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 ng5si2322495ejb.532.2020.09.11.17.47.02; Fri, 11 Sep 2020 17:47:02 -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=QArGIRWF; 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 S1725965AbgILAqH (ORCPT + 8 others); Fri, 11 Sep 2020 20:46:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgILAph (ORCPT ); Fri, 11 Sep 2020 20:45:37 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 683BAC061786 for ; Fri, 11 Sep 2020 17:45:37 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id x2so10638383ilm.0 for ; Fri, 11 Sep 2020 17:45: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=YDLLvKUFt4FLtBLmAvx/wOC4eEuYKN2bBtAm+5nRw3k=; b=QArGIRWFO5muS5frroklu4PCaoP1vWYZLqH/HnLWoRyhftvAdaFY0IUJqRf8oyNOER SrkS+8v2KOWZNRPYQ4TlGG1U88/FSRFus4nNqb8TDCC3svoUGGjibooMEsAe17/s0KL9 NK78nMGigKu24eQk+wxBwHh20vhihLhdChQu5jC4WztVOnqMjgEoqC+ESD/lW9tnqSvt bZu4rV9hlEf95DpZ3q4w0SkZJZXdztmR4E+s1BpdtS1U+JRuehB9Uts3C+LozxpTmj3C Z2m2jZ8Z1DO0FOoo8hxo0UXKgJfo2x6P2sZ/zqxkEHeNN8u3tQBYZnzr0BqWIEssrgVc TL/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=YDLLvKUFt4FLtBLmAvx/wOC4eEuYKN2bBtAm+5nRw3k=; b=MJKzMiULJd0OqYUL8c/i87J09cGx36wSs4C8uTtyKOpkLgalCs5evYJG80Xx9ZUjVj JM3AZ+DqpSC0yW0TpBejyq5QPmw7Or/my/Y09uvx9XAmPQxhIGzoT7QxkjhJEMKKId1+ dDFlnJA5KmYW0qwEfZZz2FeVYO3IJMUvH+aggQzp20BTD4FZykO1Y8MjJiMWsw8fQS8r 1GLzIgwBjk9A3B6xS8whl124deevlA05FYMtuJmCCpKYu81Cb4woqln/KqBoWJZwLRjW BjcZ0UtqiXROuk6CykETtazU08h/U1LTVszbyUMXFdT9oeEamXIsQNvrKMnAv9T21lsF YqTA== X-Gm-Message-State: AOAM533xq/eMVApEX8unjmGP0Q2sC0lBvtzOXg3wzfGjiE9NjBBLe/GH i3SF0IyxZm2eGYUJLw+ya9CxGQ== X-Received: by 2002:a05:6e02:df1:: with SMTP id m17mr3039788ilj.276.1599871536735; Fri, 11 Sep 2020 17:45: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 z4sm2107807ilh.45.2020.09.11.17.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45:36 -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 v2 1/7] net: ipa: use refcount_t for IPA clock reference count Date: Fri, 11 Sep 2020 19:45:26 -0500 Message-Id: <20200912004532.1386-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org 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 is new in version 2 of the series. 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 Sat Sep 12 00:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249740 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp340376ilk; Fri, 11 Sep 2020 17:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiTljsYNXXt6iKmgdtW5BzXKULIYK4AaIE+mYqSYWb0+fWGdKYATEJUNrh6vep+A+JnB77 X-Received: by 2002:aa7:d1ce:: with SMTP id g14mr5475031edp.153.1599871734422; Fri, 11 Sep 2020 17:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871734; cv=none; d=google.com; s=arc-20160816; b=Yw12QPCQ+GkvfaU1aA1DWMBPqX+Mn3fCuaZ3bwc/2myVtry7c+cTvRCsGp7AjUgRnb TVDTQYs3CnHpkb9ag1laAExjfLHVhV5L5JDrs1Fn3fGzACT9shwDPeCWRV30YWN17/nG ma/VsfRsLCvgPnT589HRlJfFYXalhuVhR/wiZY7tXxyMxGNAlsWNGm1UXxYIoC0Ehm9e fbixD8udT/szsznsvuv5j8+0sF2STER/7NMa9Yv598MOTmPtN3eg/mmIwgOa0OcDuWFf M/nayCVgqPj88A2/wCRd6p29eOwbrxcbrz1kVXifR0hCrS71wRSwY2zrGcFN2E6GelLi RA7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ulGFoS8Vx9LeLAE5Vy9/f1b+pYTcrEaaGPkRjEnG1KY=; b=byIB51kkdIct11/SKQK7oX0q/Np6cuk8gaLbuXori5SwHvlDltm4O+orryoqZDUN4B tvKcXg7hsK1RzBtSQk2Ag2BcNWT4IQFjxZPyHA30Ef5NLDEL3eZyocntPk7C8N9LD12O IssD/FGxQe4V0qmU2+YSGPLS1t7c8a96FLp73pee+Ol9JKyQQUPoxegjWr0HyAZ2ac9K 34CAZfRJImzS/2z3lWN6meNUGrqp2OMocbu8mPx01gYtyImY1Q3OsU2spjvlUtlSs2Zr nCmLBRxhpdWyLCeoImRXwO4ZPG6015p0fNvmlLx0zHXnHEJvXlQGkwGmrVAUiSXiCgqR d+UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+mVgQu+; 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 z3si2500704ede.201.2020.09.11.17.48.54; Fri, 11 Sep 2020 17:48:54 -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=K+mVgQu+; 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 S1726030AbgILAsn (ORCPT + 8 others); Fri, 11 Sep 2020 20:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbgILApj (ORCPT ); Fri, 11 Sep 2020 20:45: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 63204C061796 for ; Fri, 11 Sep 2020 17:45:38 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id b6so12923611iof.6 for ; Fri, 11 Sep 2020 17:45: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=ulGFoS8Vx9LeLAE5Vy9/f1b+pYTcrEaaGPkRjEnG1KY=; b=K+mVgQu+oSo9vWRD4jJE/SK9uOM+v4E6cWcQn7Aq3pD/f6l056Hn89GU9pYQs3Q2/0 uUrarKtzEYPKkRnlJ9xcvtcM7EPjbsk6YmktikCBg6CUWpU08oavMLvd0kBk2eKIcpF5 LxewxZQ/4qm9keu+acjXY7+VSMDAhLjBs1S0h8QF0n6szP0tXyhf3xZSo46MkA3EeON9 Rk8IAjAJdEZTjvagrLRGOmGgpoRm57x/kqJ+R8tciZHPOqDAQScs6NuZ9Jr+tQOw3qZk csY7Pl3m+7q4dLqLQLN7HJG3/rr+G1pkOo0FgjFcHTD8tEEFMuEyd/f9LTm02g3xelxH A3dw== 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=ulGFoS8Vx9LeLAE5Vy9/f1b+pYTcrEaaGPkRjEnG1KY=; b=mgW/v1wP9biAftuR1DrCWmTC+U7mzNu7fVAFYPNwhatu3uODfqgIxjiUl4NswYe3w+ Khj0tn1aUG/5EqOAikkVz0NaV/GC6H33JWA/+NULKwdazLZvvsbDboBXkrVXIwiA3ajg rzqUCsYZplSytf1sHhNwnKJKI+SLgHgpx09Q1/4yIgMbIDHRPjgQKQhWLX2C+L0ctsNR txZhtTZr99NjjKRNi0yDoHvw0e5LqO5cAoJixJxRuPtoi6aVJVwN2rxm7D231vKo4vuF XvsBaJ6eCawmMjTn3FdJHL8AyMxbbL6IHEJCq1G92TH3ba0bPplm/p4bSSd8W8jrPv0d s45A== X-Gm-Message-State: AOAM531KVJC+PzLKKYZ05OSg8JSaXeMxuCSSTj4z9DMf+fNId6ypfg8q yasUhNg9HKSn1bmt9yaN8cNMtw== X-Received: by 2002:a05:6638:22f:: with SMTP id f15mr4289906jaq.45.1599871537684; Fri, 11 Sep 2020 17:45:37 -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 z4sm2107807ilh.45.2020.09.11.17.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45: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 v2 2/7] net: ipa: replace ipa->suspend_ref with a flag bit Date: Fri, 11 Sep 2020 19:45:27 -0500 Message-Id: <20200912004532.1386-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For suspend/resume, we currently take an extra clock reference to prevent the IPA clock from being shut down until a power management suspend request arrives. An atomic field in the IPA structure is used to indicate whether this reference has been taken. Instead, introduce a new flags bitmap in the IPA structure, and use a single bit in that bitmap rather than the atomic to indicate whether we have taken the special IPA clock reference. Signed-off-by: Alex Elder --- v2: New patch to use a bitmap bit rather than an atomic_t. 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 Sat Sep 12 00:45:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249734 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp339340ilk; Fri, 11 Sep 2020 17:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3sDi4yg4mNay5vOTrm+CPBfuyjGN+wlmKWDFuGLQXTSBYaQpZcyWq1Yni8svs1ow6/b3c X-Received: by 2002:a50:9fe6:: with SMTP id c93mr5448678edf.151.1599871608609; Fri, 11 Sep 2020 17:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871608; cv=none; d=google.com; s=arc-20160816; b=wzntwYWtdFIFaEvIDCJ/trqmW+yZcH5gc8QA6/gVM59ig5DJk8YoKf9SbOOqljBK89 nVjRMMlu9EB0vw4VcEaCh1/JJHv1QVm6Kk908p/TqYbS0diel4Lf4OIgR1DqBcJofp56 CMxHuAcoY5iCQUOTusA09Q8JT9yPhyd1Jtz1z48FKvA646TIwQeR1Qr7fvoj2LWHTZlU A56GLimBV9G9zUnKM+yXgZKDEPDFUY/ciQ1L343Dm9DDXuE13E0PhwGoxumoojYxu+Vc 7/j2dW72ZLOnZwvnp7Q4FGNk91MRP31QeiAh3zDBfVd1Jl0BDN/gOlXNyDinPkI2KHdV ARiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MHChCwSLb5XE4l+5ihl1Zv+E4B2BQ9FCXd7jmzoDVYY=; b=aIAx0FEPllXzGCnBrtRPLGj8UCeIk4rW3wzK8rXeUrcUty6YM6VNecMlqa8ZZlgZAE 4svlSPCH2ag5CW1l6EPpY53d7p2FU4Qw8jBBuNM2PVPa+ifRAuIJ0LuqSaGOkg8Q7Bkj JT020fNEPEYf+EIGB8XFdAbOGCMzFz0HYLsvb2v9TTILoli3uOkqlwz9gMfrIOjFFD+7 +d3gIkLOpvEWzseb2r60dsYZWNytJCMtbh1gSJk5UcvwMSoXsiOQRsqwm1jfBK3RJ++r QfXImLS+2T5DMOo37i2hLThT71LeEHpfx212fAYuZqMfdBqH95cdAJJjap9nlk9A+BtT Bb/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ffSyNW/8"; 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 ng5si2322495ejb.532.2020.09.11.17.46.48; Fri, 11 Sep 2020 17:46:48 -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="ffSyNW/8"; 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 S1725907AbgILAqa (ORCPT + 8 others); Fri, 11 Sep 2020 20:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgILApj (ORCPT ); Fri, 11 Sep 2020 20:45:39 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577D8C061798 for ; Fri, 11 Sep 2020 17:45:39 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id z25so12910564iol.10 for ; Fri, 11 Sep 2020 17:45:39 -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=MHChCwSLb5XE4l+5ihl1Zv+E4B2BQ9FCXd7jmzoDVYY=; b=ffSyNW/8JF/v6l8tc3nI8IoF7xiQnY0HRqTHgNv/SS9PRGEC7eNCKWbaqGss9+qOWx E6U8l2D24xUGpLqYl0msG24mNR2pTe6OpAUPZJ/6agggAUogfIJPKXINiKYG5BrFOVha 4XQa6O5yVTH60RTnb9pghEGTPD4VPJE0IyYBRSSGX896/VHLTKAnVHAjehDWBKCgLg14 mfy4IT9r3xd2WsKo82hiusJIB2yaLAWo4FEZitCueU8DBJWAYOi56HB7E3nhrTdIfnpl O+wd5yC25wuTnOPG3FEApA0zqeJR5RHtwJR9viM0TIaqLzDQnpBD0mo2OQ+Y1NgTYc/m lPrA== 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=MHChCwSLb5XE4l+5ihl1Zv+E4B2BQ9FCXd7jmzoDVYY=; b=sbMI6kCEgown9r7jynVIAJ03IGV99wCA1lYT2TDVgGXMJhJ9FELxUbsd5dQmOoo0wl axyeYUiahxsm1puGymG6TbZjyesoQZAA/U/itZh4jf9FFJzfRvhFecI0wlHdvcXPuSjq QdbL4voCOUQ9JJNrgHAdIs+avkErdJClmn3mM0RcoAqCQ9goo9lBk+rL1OK/2/GNEP89 LeRr+xnbSiD2DaU77DJf0WltDL/1RbbvXJrfiuO/guZdEQcrcY03Kf8icfuLJM67ujD+ IU2zysFAff4fNuGm3WPBNTz1o+VucOFUK08vwZg9Pua4pbOoyzujH0/nXAt1seUau9Cf Qi7A== X-Gm-Message-State: AOAM532tJWCjwD/enGJkiUCgYt47u457dxuC1d74uAnqccsDUEZOqfzo ZJMA5zAr/Ph1cQR6ZG5kMPrQCQ== X-Received: by 2002:a05:6638:248d:: with SMTP id x13mr4436283jat.39.1599871538639; Fri, 11 Sep 2020 17:45: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 z4sm2107807ilh.45.2020.09.11.17.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45: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 v2 3/7] net: ipa: verify reference flag values Date: Fri, 11 Sep 2020 19:45:28 -0500 Message-Id: <20200912004532.1386-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We take a single IPA clock reference to keep the clock running until we get a system suspend operation, and maintain a flag indicating whether that reference has been taken. When a suspend request arrives, we drop that reference and clear the flag. In most places we simply set or clear the extra-reference flag. Instead--primarily to catch coding errors--test the previous value of the flag and report an error in the event the previous value is unexpected. And if the clock reference is already taken, don't take another. In a couple of cases it's pretty clear atomic access is not necessary and an error should never be reported. Report these anyway, conveying our surprise with an added exclamation point. Signed-off-by: Alex Elder --- v2: Updated to operate on a bitmap bit rather than an atomic_t. drivers/net/ipa/ipa_main.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 409375b96eb8f..cfdf60ded86ca 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -83,6 +83,7 @@ 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. + * The first call activates the clock; ignore any others. */ if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) ipa_clock_get(ipa); @@ -502,14 +503,17 @@ static void ipa_resource_deconfig(struct ipa *ipa) */ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) { + struct device *dev = &ipa->pdev->dev; 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. */ - __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); - ipa_clock_get(ipa); + if (!__test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + ipa_clock_get(ipa); + else + dev_err(dev, "suspend clock reference already taken!\n"); ipa_hardware_config(ipa); @@ -544,7 +548,8 @@ 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); + if (!__test_and_clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + dev_err(dev, "suspend clock reference already dropped!\n"); return ret; } @@ -562,7 +567,8 @@ 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); + if (!test_and_clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + dev_err(&ipa->pdev->dev, "no suspend clock reference\n"); } static int ipa_firmware_load(struct device *dev) @@ -913,7 +919,8 @@ static int ipa_suspend(struct device *dev) struct ipa *ipa = dev_get_drvdata(dev); ipa_clock_put(ipa); - __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags); + if (!test_and_clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + dev_err(dev, "suspend: missing suspend clock reference\n"); return 0; } @@ -933,8 +940,10 @@ 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); + if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) + ipa_clock_get(ipa); + else + dev_err(dev, "resume: duplicate suspend clock reference\n"); return 0; } From patchwork Sat Sep 12 00:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249739 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp340132ilk; Fri, 11 Sep 2020 17:48:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3e+7ZP4L3Um361cauaNh+unpYvi3KRDao0264G3Nqj8230fkz/HKlQNDc81KqX+VJPf6Q X-Received: by 2002:a17:906:3913:: with SMTP id f19mr4649914eje.83.1599871707057; Fri, 11 Sep 2020 17:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871707; cv=none; d=google.com; s=arc-20160816; b=Uc7fUuUVf8WAg+p7KTUAYc5s5tkEH3Ox5zRRM/wrih0uYxVNzojrFEirgJjMb3YiNN hGeMWbsiIQ8nk81K13KD4f/iyaioH0IzhIaorIxSRNrDcsPttqai0TlWda+KXblIparO VK1mlNdLVSNem6gkmWuzIbnzkAhz0dH49LLCrmbZKQaYDgLzKeJvbxCr5rwgCAW+L3XL y5xMJhGaPiihSqVpnFMeK8OEwkoKJoi1rRvQ/F74XGYO67g4HuXZ+cpeNuCIropdv8UI OOFNskUkvj1ogDU+ldqMGRqFOMWfBeBo6G+CLn2sn1f64lzf2pdi7s2HYznFJdck9TLn KFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vovszmszeTX3/fYMq/yEC/8V2nM1of8JQPOPUdTofb0=; b=exg6t6/aw+WqqKq2Lmf/LeHkhoEcBJr8ZGjrk5ctP1hohMmCgTbtkqa773oWh8c3d2 Mh5wJmJrQOfZCSV9OY9JqcR0eSpNvbVew4kvSJ2cMzYQcy7bHhk/cHnUviUEPuSv7eCL DW9RWpOOr0tDouLauxopYpR9Pojl0A0deZRfZGdoA8Ilsg18f/F4DcwKiZBlXQLR2/kV gxYkiZ7uhQZGuqJzS2FGUNBYJaytsTwqlSWoB+KLgEQk93BbIaC/73kY+dc7dc42kaO1 /e6itcjTKF7v7fHKRycn+ADzfwGuNLqQJalH3Kkg6v32nQgP5gG8VAnt4FIchfYN1cir r7Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IkL89XVU; 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 z3si2500704ede.201.2020.09.11.17.48.26; Fri, 11 Sep 2020 17:48:27 -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=IkL89XVU; 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 S1726016AbgILAsJ (ORCPT + 8 others); Fri, 11 Sep 2020 20:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbgILApu (ORCPT ); Fri, 11 Sep 2020 20:45:50 -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 6CB79C06179E for ; Fri, 11 Sep 2020 17:45:41 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id t16so10565189ilf.13 for ; Fri, 11 Sep 2020 17:45: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=vovszmszeTX3/fYMq/yEC/8V2nM1of8JQPOPUdTofb0=; b=IkL89XVUEnh3Zuv9T+7VES56Y4g9Nw3dq5ZpAcRuwDOu/KUDNKe4aYXujKA7jTmmAb r1jhSlm96K9YZuUq+LQA44kzLSQl7zf1zCQBeGmJpnOOu9IChQFJhOQ6RBqCJybFidzV IF0RbfQU5oMXmaLeWqNd1PfqOwIvMUDenKgaCewWeYR2moUqv/Yl6rUq3T/0iUtpxTXn rqNeRxgR+B8rZ+tAuxoT+CeWfHqnFi9SEhw/L4aXEMRKFYrweKsYSYfBryWz47M2/8Vj wh0GQ5mF9VsQlGWsbom8BgBSQkC08uOcSMSTPvy+dVzrcfhp1d02wJAM53j+F1YxHbpM JERQ== 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=vovszmszeTX3/fYMq/yEC/8V2nM1of8JQPOPUdTofb0=; b=HfNWcz47CrCj70wyQhmtRyMGtRLfrn4PxRzOiS+/cHqnOuH+clhZFAKocEiJi7eEZn jqha6XYyqqvoRGL/oADX7MYX4VcgTyGpShl28rY7I5tuQPJZ4LXteeLOGtJtnWlrw2k8 OTnK+V/5jfcqKhVPeIInHqZY83Un051y4Flq7gjaEdZiRErHzIpnLJqo2jPYtPHaqqPd Cuz4S9hop16DXi9NYx9qvCdOGfIoTGHEJ3TEcVHawbmzPqGfY5rhUjtiypSHFGbFF5Ub u0jamjaSbmfmsAu4yldCQuTGR/0622AIkQivETfa/CVrDMS6UbOHuxoRCYEPOPJH+Z2i 3/Tw== X-Gm-Message-State: AOAM532T663YBGu+cGmN7w0bPwJnvGuXQy3tTYCXk47hEMyQuTBNIwE0 YOJqD1sowtpU5yrFR30PloPPgg== X-Received: by 2002:a92:ba44:: with SMTP id o65mr4105148ili.255.1599871539593; Fri, 11 Sep 2020 17:45: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 z4sm2107807ilh.45.2020.09.11.17.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45:39 -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 v2 4/7] net: ipa: manage endpoints separate from clock Date: Fri, 11 Sep 2020 19:45:29 -0500 Message-Id: <20200912004532.1386-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org 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 --- drivers/net/ipa/ipa_clock.c | 14 ++++---------- drivers/net/ipa/ipa_main.c | 8 ++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) -- 2.20.1 Reviewed-by: Bjorn Andersson 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 cfdf60ded86ca..3b68b53c99015 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -913,11 +913,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); if (!test_and_clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags)) dev_err(dev, "suspend: missing suspend clock reference\n"); @@ -932,6 +936,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) { @@ -945,6 +951,8 @@ static int ipa_resume(struct device *dev) else dev_err(dev, "resume: duplicate suspend clock reference\n"); + ipa_endpoint_resume(ipa); + return 0; } From patchwork Sat Sep 12 00:45:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249738 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp340008ilk; Fri, 11 Sep 2020 17:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaO2m8V0iPI9NEYgceqkX6XddHLhIKNJEGc+QurXnFmEt2Zm02AzsMFS6QJLDz+fYRSULO X-Received: by 2002:a50:f199:: with SMTP id x25mr5305132edl.347.1599871695065; Fri, 11 Sep 2020 17:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871695; cv=none; d=google.com; s=arc-20160816; b=iIFsBpMkEDelOdb2Ab9r++NHrViapvs7optfNF87KVU7/vausYKw2zJd8P85O9nxsX 5w++D9Rc80yiajo6JZh0mwE5bbcTLcdmNTBmSKRSdIzx2Lgouf33YzQkJ2+7EIkB9tws bVI9Dv/Bl/fvJJsRxBZxD/AfBJOGbIc/xzEng/QhJ2hOS2qTieR+gMw6bnPLLHN/vQeM QBb4+mPKIv8jQENsPmfoFZ3bub7LLfiMeAaWWv8VHEx4wPfKiS33astFBxPu+2J51YZx unRUE/Ki8KZvW+LJ0uMGIAWmulUQ9KSMaal70sEte4hQvI9idlo4652WrupMA5eT1ys0 Ukww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6l4tdMeRmxzggJyDsuQpGPMnQKd0WjklRLIqQAdVFaM=; b=hqACcEP/nJIurINm4wMGkSeZ4oJQXjlSpQCntkDjla/5Bz/hxpj/w49rFws8gzwFx7 BIPgKSGnwT87BE0Mu30DdVEhWVVbzxq9kZHSqwGTLGTWY5CzzQgLM6brO3hIlwuWQtpy mecU8KmgekHZ53xJFpgg+aZKJDztmKYD1X9I+sLUhJc8B+T9lXWz5OvY7doWms/C6TKq di+s914SLn/zqz3vKyIIrezxM6bAsx4SGFjl/UydAC+/Is5dvR6BmtSEB5nrp4ov9/KW wAVN0LmNNvg6eqU3RnznxWoDBoL0AhnxYIPJttb86UL3UeHnQlxwNyBb0G5MH4FF1Eex ehOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IpKhQQQ9; 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 z3si2500704ede.201.2020.09.11.17.48.14; Fri, 11 Sep 2020 17:48:15 -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=IpKhQQQ9; 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 S1726022AbgILAsM (ORCPT + 8 others); Fri, 11 Sep 2020 20:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbgILApt (ORCPT ); Fri, 11 Sep 2020 20:45:49 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4072AC06179A for ; Fri, 11 Sep 2020 17:45:41 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id d190so12959465iof.3 for ; Fri, 11 Sep 2020 17:45: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=6l4tdMeRmxzggJyDsuQpGPMnQKd0WjklRLIqQAdVFaM=; b=IpKhQQQ9M9KfG12g585751mFf8MpJMhEx64T4xDG4EXsl/5rGVWhZ/VMApit3TX+NL sxSq2lipWeVHDEA24HwiBe5z6m/GDJMEkQTiOZiKxZR73Kjh7etN6fZ4L2YCubmm/DIN u+728c2fYQcbyqsuq2hYlQPDd4MV44HNhKkN21rHVON6ECKMIRKcpKtthlVXXE8+rYMe cb4bS6IXcKDSIQpRE8qcXT+UGQegKDITAKpg9f7ckFvmengjz4zsrsN8LT/KyD1Zw9BM OEFWz4k1yxe6ZMLDSquJdVNqVDJtG/KkEGkdqQapxkaDbAmv/Y612d2lu0lct8uwU3Rg Jumw== 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=6l4tdMeRmxzggJyDsuQpGPMnQKd0WjklRLIqQAdVFaM=; b=GcoDM3Re+BfTmxidQ1PhqqdTU1hT4xoNMlAElGfX5buRG/KXZJyIGfpSH1VgtFW8JI YNQ82WguIs5me8CHVF/29zAKjtfXkv295Kkso0uAAYkfn6T5cbaEoKkeGsF0ODKd+xF+ vTTsKDLUd96CbuTvZNWBHGk7oKw/ODul3slnjVoE+dtHtf4/nHjCOr6i2hY/JcDEG43E V+bq1sbA5eVxym4RJnFch+JiqjEysydyVWAP0BTOmfSvIdKl3Fizz0Wvox0s+tpyvnih PpwPsZz8XSMEvu0cFDg2W+Si08+1rS2VNcOd2FpEY+TRnqADoUwqgeogHrZiqkOi/g/V pUaQ== X-Gm-Message-State: AOAM5339c7kQqRVg7u/fzjq04gwomqeon8Fv5OZ5fEuWRTANRigXlIXa yw1i4V4IMLvbXCUJh0K2Add8tCL8/1NILw== X-Received: by 2002:a02:a615:: with SMTP id c21mr3780852jam.106.1599871540562; Fri, 11 Sep 2020 17:45:40 -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 z4sm2107807ilh.45.2020.09.11.17.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45:40 -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 v2 5/7] net: ipa: use device_init_wakeup() Date: Fri, 11 Sep 2020 19:45:30 -0500 Message-Id: <20200912004532.1386-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org 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. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 2 -- drivers/net/ipa/ipa_main.c | 43 ++++++++++++++++---------------------- 2 files changed, 18 insertions(+), 27 deletions(-) -- 2.20.1 Reviewed-by: Bjorn Andersson 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 3b68b53c99015..5e714d9d2e5cb 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -75,18 +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. - * The first call activates the clock; ignore any others. + /* 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); @@ -107,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 */ @@ -124,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 @@ -159,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; @@ -174,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); @@ -201,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); @@ -715,7 +724,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; @@ -764,19 +772,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; @@ -784,7 +784,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); @@ -863,8 +862,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: @@ -878,11 +875,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) @@ -899,7 +893,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 Sat Sep 12 00:45:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249737 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp339938ilk; Fri, 11 Sep 2020 17:48:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwByDY7qwhFErG5jbBq7WdrwHKLJrSbzS1E8dGdEJbE1xENopqHh4nUHLw/R/yGTuh3gCtt X-Received: by 2002:a17:906:1b58:: with SMTP id p24mr4589872ejg.77.1599871687566; Fri, 11 Sep 2020 17:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871687; cv=none; d=google.com; s=arc-20160816; b=CQW07JD5Y9FHQELBuu0WiVHTd+Jg4uxIs+Fgu7CNTYlLN0uY8s1xuJ/SnxMak3s8Lj yzkYX33wJCZWvjlc6kgtlvo1ZZg2pJGlo+5eeKdiKoge3V7JutEfihUAYtVxQbDJszAM QvSnT3B2B9vXcwOMzs83Uq/JXsRImYIHuZJUyE28oswO/36y7YsQrmfxUqq0w4UhPAb7 VVIvCeloloRKR9Z8ix6ammVNQWOVyFzjabRk+/2dKgSuvnwDomLdQj6K9qYjH28EVdTX H2PMXyPJgiW12sRufSigcyN1XIiPuQ/auh3r8u5PceBgQIGVd15TBjx3M70bqfITOUGi OVzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C+4RJZne7XWnSNpMScCQkiPgvon7cqSHe4LlitFTkv0=; b=gHfZaLfI9WwhYxRcBjLx+zrOLalNtylP4LGluv8poPB6tWReUgWq3ZCxKRAyzVB8Bf g6uqpueF9lq+EJGVW2JlI50jIAHjt9F/DZ0eRDhZBf35R/ShZfG71gtzxK8jrGEUZp13 1oDKNuMBmvvQjo8tZjKgmRdBWWf3C7uOUMTZ4Konf2czRiHtEW6ZrBNQVFHdxn6WuQ1M 6+ksLMxLLIlhyEaxQCLCuOSt+x+zO5+zcNaw2oFg1cRNfv4DDK0UIBV5jJRnIyyLH5e7 TR9AaW6YAiVIdYdMToz/tYcM7UzD37KSnpuMMDZKm4j6FrD4l9RFUzKaM/sELfurMe2D w9uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Utdyhr0a; 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 g7si2492598edu.333.2020.09.11.17.48.07; Fri, 11 Sep 2020 17:48:07 -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=Utdyhr0a; 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 S1725921AbgILAsD (ORCPT + 8 others); Fri, 11 Sep 2020 20:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgILApy (ORCPT ); Fri, 11 Sep 2020 20:45:54 -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 5CCA4C06179F for ; Fri, 11 Sep 2020 17:45:42 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id p13so10615348ils.3 for ; Fri, 11 Sep 2020 17:45:42 -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=C+4RJZne7XWnSNpMScCQkiPgvon7cqSHe4LlitFTkv0=; b=Utdyhr0awvpZ4vaNinnSkBVq+NxEV2KtEH8XKorI6SzfWRyFbXDyDDnoOJ0MfOHAC/ GvRo63Wh/VPA6AYsaxhy+JtpeNDOeBESCr7mfAlEs1gr6nbzXIGIJR/r7Ayo32uX4VV/ 1q8xePfX+/LksdK3TxwbgCgzC4KPQTZqLp5JTUWL11RJEUYO+Tx6Rl3XRyFRvjQyrciE ulRBtTTThTvnpmLRGBsnWQbIDEKofGKj6KB4G1sSpK13UiwnT5EtStawGLs4kO1UUe1F xrgiOva3GHk5u/RZ/vHcrJcpl8ePYWP9jPpRJz22RpCNpIMK7XcCaIxl27bCWIYbxp0V IiPg== 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=C+4RJZne7XWnSNpMScCQkiPgvon7cqSHe4LlitFTkv0=; b=SLzGt5lgG1FTLIL95E+xLl9Nc5T8UD/bBgGp7K7jUtkEDs8/UHHwgWvrKF9KmUNOuK VGU8zKvrFIcq+WDCyW1L5EtiU63jkaXgM3ONLBryP+mbPui332pFhGWCTiuMIgLG+Ddv pt04m1yIP1P5az9/te00Q3NABmcK6l8hIzdjgQ08CDJDhdPnUU1Vq15A3xS/RvOLs80U 2Nf8f8ymgSF5EBsQ/ZsqBFdrF0xurBS7IdSHB71184EOtC4KDg2Nmz8RNZHNwXQdu2sl C0HGm8/NoOg1Q8LpRTKJ7Uw9b8OJcqrsHzNN6AByeRWEb94qQZLHpg0pOmbCQHiuCNXB Sldw== X-Gm-Message-State: AOAM533SRROOA3Po5DF7sbvohkeYjkHdeJWOV9hyTkyGfO3mAIKNitiy VeKD63pYNUqdUI2kbWW74/vV8g== X-Received: by 2002:a92:9ac7:: with SMTP id c68mr3815204ill.221.1599871541685; Fri, 11 Sep 2020 17:45:41 -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 z4sm2107807ilh.45.2020.09.11.17.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45:41 -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 v2 6/7] net: ipa: enable wakeup on IPA interrupt Date: Fri, 11 Sep 2020 19:45:31 -0500 Message-Id: <20200912004532.1386-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org 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 --- drivers/net/ipa/ipa_interrupt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.20.1 Reviewed-by: Bjorn Andersson 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 Sat Sep 12 00:45:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 249736 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp339785ilk; Fri, 11 Sep 2020 17:47:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhv7TklsqXSgZPtiBp9oBPQPm+Njc0RlgrW9mFSxRu8RU7/d+Bs0MssqEPsQJW5gBFpOz+ X-Received: by 2002:a05:6402:44e:: with SMTP id p14mr5565036edw.1.1599871673315; Fri, 11 Sep 2020 17:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599871673; cv=none; d=google.com; s=arc-20160816; b=g0Dii7yX6a+s/a06NuTXocLEpegW0TAv7rhJpnIvoAEyeLdKRozs24bc3UGRe7BVkb 9H/jrSdMg0zEe8L+YnXkQxMHxpD01WAmnjtg57iHZ+78Ocp07rvO8N/bBZdMoUaZxb1f xl2Itn/1PpBsjo/yW/Rku/x2dCQlpDnoVUdzTpxMz3EqLNPubEUiPhbqDjNA7msR39yI OrAV37bUlu8RUIV3uH7c6hVsV8zpd0qB8FVTd/Z6dsngFmWz9nsXnhdKjDg462h4Vd65 m7oEJ6PzhUNqptjRhQM7wabwXB+CiO9ONhxmjdzeOakRgB7OcAEjv3KaabtqNAvQGb1g N42w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GXt6HV+Ir2mOjyqv+jsDtLLXzMvpXAXcGItzvsZha8c=; b=WTe9iuBKUzCghtPLueeLoK12pKfs8L+7xYtpz3AUXcPH51dXEqBRy9BL5OH95HxvYU d8KwR+syKnEYvNhbkJMTxmtysGAC635Lxp4jk4dL8X1ecJXRe/CdFcvFLSYnILpqesXi 1mt9iTgRt4DXM4VFCD5qYaFZiqxWjX7O+s5NjknaAWcDB/hzSnPbGiEuVz/WqMJViIQx iI1fRa77siFXnCbdHin2LYWtqpe1pH39Po72t7xNkAOvOSaTjQf+r5yaEpL7/OqwXobX +PM3AlNyw+8A9vc3wcCkU+EnPX0FGoTfLZbeEj9KljznWcPTjSK+XBtSGRrS2bxCNfDF Z7Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=col5BAuW; 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 g7si2492598edu.333.2020.09.11.17.47.52; Fri, 11 Sep 2020 17:47: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=col5BAuW; 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 S1726007AbgILArs (ORCPT + 8 others); Fri, 11 Sep 2020 20:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgILApz (ORCPT ); Fri, 11 Sep 2020 20:45:55 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8BEC0617A0 for ; Fri, 11 Sep 2020 17:45:43 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id j2so12938761ioj.7 for ; Fri, 11 Sep 2020 17:45:43 -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=GXt6HV+Ir2mOjyqv+jsDtLLXzMvpXAXcGItzvsZha8c=; b=col5BAuWHgufoYczLGg0c0uTkur7OT3fhzhEM2E4Yg1F1SZJ7iCmlUUdT/KWCFtdNO VjYKjvkzB8BBop24zMqOLP7RggE8CaaKS4k/0bkg4s63Gqb1D7m7gqfFs7TotA5UOxpZ uk8qO33Rqhx3keJuJ4FMcJ6WPFot+5dWJf//FMkXToqd2ohG8zg0K9ZQc269QDLGSx2X DFNTK1g4A2VWYztqJbFRkK8+IzKQtI5CYWpWvvD9a1fkcFcxmcrMxH5ndGHlQZyXNVmg 0tykMnobVMtlDMuW20WnMc7bnQbuzvtgu2G4Ka3MtAwhfI4U0mLZiHbNUDDtCg25Btz+ FYrw== 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=GXt6HV+Ir2mOjyqv+jsDtLLXzMvpXAXcGItzvsZha8c=; b=J4AnAt6YgXtR3M0IJeBIORK0qIyWqr78f1UkWYM2sMKy7KCbFYWLLs60qUJ64aqivR N90me6jyAmrnCoVylU9YbpoqZ80nJyHw+nHcQ+pSkC7KP3orShNJf2qNUZxK9uOApRvk fZ7nWAjR2WSqzDN1XF7P0GaMDg918fVweKrT81Dz1OKgrbI0wczI/TgcQTLqodcVRuWA 1G4lWsrAj0BoIsWyBCVz6VXB88c5acI3rvEb75ycztFH079fwfzoOaliITrMldrlcN/i zqpB4+VFByYKflB2XsfyuejON8mly5NezJM+uX8U0IbGN1FfdXLvZrDyxoyAoRx1VwIR WmbQ== X-Gm-Message-State: AOAM531kCyUmQ19fwlIM3GNGep7tYocCrdL9V1/VI6qJAxj/cm7ctCyq SXCGJ9aiR2Fjgcn/vbw0/KC/Lg== X-Received: by 2002:a05:6638:220c:: with SMTP id l12mr4269019jas.139.1599871542598; Fri, 11 Sep 2020 17:45:42 -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 z4sm2107807ilh.45.2020.09.11.17.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 17:45:42 -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 v2 7/7] net: ipa: do not enable GSI interrupt for wakeup Date: Fri, 11 Sep 2020 19:45:32 -0500 Message-Id: <20200912004532.1386-8-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200912004532.1386-1-elder@linaro.org> References: <20200912004532.1386-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org 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 --- drivers/net/ipa/gsi.c | 17 ++++------------- drivers/net/ipa/gsi.h | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) -- 2.20.1 Reviewed-by: Bjorn Andersson 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];