From patchwork Thu Aug 12 19:50:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496044 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719442jap; Thu, 12 Aug 2021 12:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxZRN1bUYmk+1pqFJdWSmSeuf3/XR68DPaoy40RtsXkR17eU98IiTmYMHlh5eUrI+eaFsr X-Received: by 2002:a6b:ba87:: with SMTP id k129mr4344010iof.101.1628797843024; Thu, 12 Aug 2021 12:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797843; cv=none; d=google.com; s=arc-20160816; b=onENqHnHHEG5EQ9NvnmEOv+7GJ0/nBKRo1fGRKdkhdvcssvBDSLij53nlbVQgBYGTz s66dCiYRyhSk2J1Bh1lwCyLEffhTVNYTPQQVLauWbYVFnW/qqsd+kXGhfdu5kK/1x0Y2 9ZdnpM9mpdg22Pj+BY0iq63UHukSg+ob3cDTzdw5qSn4+QvnjyUNO+nc5oe+CBXGFNUn /FXoXMWWg2MMkJorIxj48djtixLgIPj+oCbnto8oP5BiUiWLTIdA78bMUSMOvT74f0rW jm8KSvqXdIoyDx0L4b8mczI+VHb9JpGTVYAhHc8h6WBLYayAHfW6icnfeMo6W/JedLu0 pVCA== 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=ykKBXMHcKlze21MzZB0cs6PrhHYH3qk79ar7nof85s0=; b=aUwx+ARRS/pWkboskbwJTf0uxBGD4SxtH4OQB8jQ8I9pi0jNT32fe7D6vUnbsC0EIW E8Anix8cHxqmiE/ea/05PQ6bxoHIowYvfA2TtxRPyGIQB5kJAV76wBU0yt/BOPbXy7N2 pYzAGzIDdKjTsbcLra5agd3qR/GwX7mRjvm1tM2NcJ5Tw5NxUW0wLHvFdIqbOXtqZHFd XLb5cH5R+gtBPPm7aHkOMdqziMDAxI554fmvSTY24lgpQR2lOT0y2tIDtHAsALkwEWv6 xXRIB0oYA0rvLXqy6ufzGZokbJf8ZRkrt4Ling9imW1pzrEvlo44csPhKAECrwWpzWxy 0zDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l/aqAk+W"; 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 i20si4258170jaj.74.2021.08.12.12.50.42; Thu, 12 Aug 2021 12:50: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="l/aqAk+W"; 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 S235688AbhHLTvG (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234835AbhHLTvF (ORCPT ); Thu, 12 Aug 2021 15:51:05 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 066BDC061756 for ; Thu, 12 Aug 2021 12:50:40 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id k3so8303555ilu.2 for ; Thu, 12 Aug 2021 12:50: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=ykKBXMHcKlze21MzZB0cs6PrhHYH3qk79ar7nof85s0=; b=l/aqAk+WNRToSdjo2CK40zg+wckqOyG7PwGgkUPgMKFA1FHo2wYIQVDlGX4Y83H4a0 x/OOo7oVfDiYJj690UK3Ysd9QUV2O1GEn+Kamyd7Sr5+ahn5Vq3VVqRJ6l6Cy4FhMeNl vin/3Y8SoX9vUxVJB0DA/3kZfwMfBRDhK5599555gcsaKa+XEqnqmLdAKy1toBNWdU3M QxbKkC2Aklg1M89GfEwV1NBGZEmRVl4nekGL5S+pizYn6Vty0cqJDr0EJgO67NfbFxD6 U7qxc76v2yIBy7cpR5bphvyDZg5q6KKCPAtx+ZCMpARSpUD3i5dKYeMx1R+JcHG9/kG2 FYpA== 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=ykKBXMHcKlze21MzZB0cs6PrhHYH3qk79ar7nof85s0=; b=F4PmOJ6U+kbOJ/1TgLGugtRSQuW8RVh1cwVUYJMJ/w5xMYVpyrkNilub2I8q1INmKf fRJ9bS8Wj95R3w4nXNM8u4VcuJO1ZK6Q3mB0cpD5z/erEIK1951HrLjUT+7cU/SQ6Ntb 2Fx8KlXdQpUz+SNojS/T/oAkDscq2Bw5z6ohx5iUWjVcCo50awi25dD5TZY4d4DJ2LL0 LB+g9lbFKMHXYLAQSQLj7RCFD86pxAx5nFgx+yYs/p0ABv7JUyk5/15vDGS1Qq5KKkly gQsECiP8QLJM11izmtzxkcGL6cErCQk5ificru3Lqub5tCg2f9j98blHbW4O+jBTF84j 9pGA== X-Gm-Message-State: AOAM530qO504JSSOH9bbKXYeR0fbbwI7eKQBQ2DL9M682PkY0lC32Ovo JP4kIhVbc+kxZ1GeHd3r4ZYkIg== X-Received: by 2002:a05:6e02:d09:: with SMTP id g9mr187795ilj.153.1628797839417; Thu, 12 Aug 2021 12:50:39 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:39 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/6] net: ipa: enable wakeup in ipa_power_setup() Date: Thu, 12 Aug 2021 14:50:30 -0500 Message-Id: <20210812195035.2816276-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the call to enable the IPA interrupt as a wakeup interrupt into ipa_power_setup(), disable it in ipa_power_teardown(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 11 ++++++++++- drivers/net/ipa/ipa_clock.h | 4 +++- drivers/net/ipa/ipa_main.c | 6 +----- 3 files changed, 14 insertions(+), 7 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 6df66c574d594..cdbaba6618e9e 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -310,14 +310,23 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) ipa_interrupt_suspend_clear_all(ipa->interrupt); } -void ipa_power_setup(struct ipa *ipa) +int ipa_power_setup(struct ipa *ipa) { + int ret; + ipa_interrupt_add(ipa->interrupt, IPA_IRQ_TX_SUSPEND, ipa_suspend_handler); + + ret = device_init_wakeup(&ipa->pdev->dev, true); + if (ret) + ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); + + return ret; } void ipa_power_teardown(struct ipa *ipa) { + (void)device_init_wakeup(&ipa->pdev->dev, false); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); } diff --git a/drivers/net/ipa/ipa_clock.h b/drivers/net/ipa/ipa_clock.h index 5c118f2c42e7a..5c53241336a1a 100644 --- a/drivers/net/ipa/ipa_clock.h +++ b/drivers/net/ipa/ipa_clock.h @@ -25,8 +25,10 @@ u32 ipa_clock_rate(struct ipa *ipa); /** * ipa_power_setup() - Set up IPA power management * @ipa: IPA pointer + * + * Return: 0 if successful, or a negative error code */ -void ipa_power_setup(struct ipa *ipa); +int ipa_power_setup(struct ipa *ipa); /** * ipa_power_teardown() - Inverse of ipa_power_setup() diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index f332210ce5354..2f8ef831fa213 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -101,9 +101,7 @@ int ipa_setup(struct ipa *ipa) if (ret) return ret; - ipa_power_setup(ipa); - - ret = device_init_wakeup(dev, true); + ret = ipa_power_setup(ipa); if (ret) goto err_gsi_teardown; @@ -154,7 +152,6 @@ int ipa_setup(struct ipa *ipa) err_endpoint_teardown: ipa_endpoint_teardown(ipa); ipa_power_teardown(ipa); - (void)device_init_wakeup(dev, false); err_gsi_teardown: gsi_teardown(&ipa->gsi); @@ -181,7 +178,6 @@ static void ipa_teardown(struct ipa *ipa) ipa_endpoint_disable_one(command_endpoint); ipa_endpoint_teardown(ipa); ipa_power_teardown(ipa); - (void)device_init_wakeup(&ipa->pdev->dev, false); gsi_teardown(&ipa->gsi); } From patchwork Thu Aug 12 19:50:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496046 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719519jap; Thu, 12 Aug 2021 12:50:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZHHkUZWpOtmxQN8ylIRpln4JIYouMn27JoAOGiRmd7/PZgg9C+efQeRFF9Jw5EnPYGxja X-Received: by 2002:a92:dd82:: with SMTP id g2mr176330iln.279.1628797849746; Thu, 12 Aug 2021 12:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797849; cv=none; d=google.com; s=arc-20160816; b=wEBP/F2PUf8sEJ3CugQSUTfD2IpsiXZ9Ddh2kg4K4Fk3jnTkg82kFBmIYFvaGdi8iD rf/CRGtbuNAD55BHmxEBubVaP2dBHvWqEy/AANAUyaV4KcnqEJl+Lhmm+vlwhT6uat0Q 9EOCh7tX9Uuu2ZSzMo4F9XFzfWFC2oC5qtr3hW3ZEAFOguyTBxnZhj6MBmTyH2bBUO8c Of2OgjuY2UtEe5vkh3vgk1DlSWKGEBq1vbDbNi5MLjhn5QRWTcwfScArt0baIipLnvgQ 3zU4dnqLfR3VU46aIp+9YdZbi40Cg04nHGUAR6SaXSIJmLjzGawZBXjP1b1GjMhwUUXd pTMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=imbyA9zS8iOvDuIMfQFmoFVl8yNiRFQ7/n5XbQxPxFZxymnZs1oJ8FbpxuvTrfjjYw 3uSw61uxgrErn53DojU9ZYE/MQVdBlYYxRCS+0ZkennnJGHJWcu61ovt8EM/VZdNGBuR /L8hQusWoNPLiDpErdzH+eL7hD3UcK99U3Tq3GK19693MpIWpWQn2QU8dPzrEd6cTRAO O9aOgPptI5NzKQrvN2mVW/NesZDM4e+FYoYvX50rdCy+mDnQoNDRn0uD6inXJ/Jmkcmi JmJNicA4ZJS5/t0bEP1S0ceEN0VwQ0SRrSIxlQq0VnqXkjkA2zo5TKWkfQT7lyNVNsqI 8cLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WS24WPgG; spf=pass (google.com: domain of 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 i20si4258170jaj.74.2021.08.12.12.50.49; Thu, 12 Aug 2021 12:50:49 -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=WS24WPgG; 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 S236412AbhHLTvN (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234879AbhHLTvG (ORCPT ); Thu, 12 Aug 2021 15:51:06 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA39CC061756 for ; Thu, 12 Aug 2021 12:50:40 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id f11so9999310ioj.3 for ; Thu, 12 Aug 2021 12:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=WS24WPgGay3hQgbUIR436kNFc73DRxNzR3maz8Q/Ph21IP6Fpg407QTGxKiL8dFeMN 9gzxpBAYI2oznD4Gi6IjhQocSIqiv9IDTeseCP8xuHAPb8QPartndvy9p8FL3ZTIUl3m y/RHgUXbnXSJOUL5xnqwdCdSEkqStWw0S81nQFgMTMdHFIlMEZo6i8JxEYwqvtyGFkTm HKuWXWyc5cdyNHt4utgsJsESyOMojkUTno/4kbpnj+DUS2PinE2PYailtvZbQ/yx+m3q a0+JaCudbp46HQPAij2MjeA48cm5zdmnECy9KG6c0Wls7XjOcR9SP2MRen6e2kRZ9Cvm 1SqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GOarOxSvxcoFvnrPmbTCMPoPjyx0rRztFou8dZUd36s=; b=sx3riKQ/ohG2cCKqt5zlXerQT0/DlVO3EiSrV6RaXONetQojGjqkn33KUXOAcSDK+I nfbnjRatY/U+blTTW3JwU2As2JMVjFIQn7PmC+5quKbblZ5ThYcPMigB2F8sDd9aqy87 jXelroHAQRg/50pKMbjaVID8mBq0flNgUD5iJf0FpR6YkySTgF7m8yyLF/DRCCqy4KAv BXppavyCe2J6WCc2AuZdkn1moBoKVJ86qflg0ekjY2B3/QXC0qSYRAAF5uAH5k7A6iS+ aMl7nZDAks0gTjAp37X9WL+boWus9vvr7B1HwNcLuNOr594hGpTHMZbjLTHUqnHV++d0 x1IQ== X-Gm-Message-State: AOAM532W/UTrKRpXQXP7fdgpXpNhgEzTPyexiiMlPMZLc05d48Jvhfbj 6DqUcehsqNpHAjdRxw4RywUJxQ== X-Received: by 2002:a05:6602:220e:: with SMTP id n14mr4261919ion.150.1628797840279; Thu, 12 Aug 2021 12:50:40 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:39 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/6] net: ipa: distinguish system from runtime suspend Date: Thu, 12 Aug 2021 14:50:31 -0500 Message-Id: <20210812195035.2816276-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a new flag that is set when the hardware is suspended due to a system suspend operation, distingishing it from runtime suspend. Use it in the SUSPEND IPA interrupt handler to determine whether to trigger a system resume because of the event. Define new suspend and resume power management callback functions to set and clear the new flag, respectively. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index cdbaba6618e9e..8f25107c1f1e7 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -47,10 +47,12 @@ struct ipa_interconnect { /** * enum ipa_power_flag - IPA power flags * @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled + * @IPA_POWER_FLAG_SYSTEM: Hardware is system (not runtime) suspended * @IPA_POWER_FLAG_COUNT: Number of defined power flags */ enum ipa_power_flag { IPA_POWER_FLAG_RESUMED, + IPA_POWER_FLAG_SYSTEM, IPA_POWER_FLAG_COUNT, /* Last; not a flag */ }; @@ -281,6 +283,27 @@ int ipa_clock_put(struct ipa *ipa) return pm_runtime_put(&ipa->pdev->dev); } +static int ipa_suspend(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + + __set_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags); + + return pm_runtime_force_suspend(dev); +} + +static int ipa_resume(struct device *dev) +{ + struct ipa *ipa = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + + __clear_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags); + + return ret; +} + /* Return the current IPA core clock rate */ u32 ipa_clock_rate(struct ipa *ipa) { @@ -299,12 +322,13 @@ u32 ipa_clock_rate(struct ipa *ipa) */ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { - /* Just report the event, and let system resume handle the rest. - * More than one endpoint could signal this; if so, ignore - * all but the first. + /* To handle an IPA interrupt we will have resumed the hardware + * just to handle the interrupt, so we're done. If we are in a + * system suspend, trigger a system resume. */ - if (!test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags)) - pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); + if (!__test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags)) + if (test_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags)) + pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); /* Acknowledge/clear the suspend interrupt on all endpoints */ ipa_interrupt_suspend_clear_all(ipa->interrupt); @@ -390,8 +414,8 @@ void ipa_clock_exit(struct ipa_clock *clock) } const struct dev_pm_ops ipa_pm_ops = { - .suspend = pm_runtime_force_suspend, - .resume = pm_runtime_force_resume, + .suspend = ipa_suspend, + .resume = ipa_resume, .runtime_suspend = ipa_runtime_suspend, .runtime_resume = ipa_runtime_resume, .runtime_idle = ipa_runtime_idle, From patchwork Thu Aug 12 19:50:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496045 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719481jap; Thu, 12 Aug 2021 12:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvVuZREBErRNfaxhx3R2HFcfbceqq8rk0DU7K50h4NcB0re19AmJXKZXe+ZROB5Nkc6/AB X-Received: by 2002:a02:cca8:: with SMTP id t8mr5280195jap.51.1628797846672; Thu, 12 Aug 2021 12:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797846; cv=none; d=google.com; s=arc-20160816; b=DIAaQbgU7D8CbiO4NhMsBvF2/JrNpUsdlStZAqqWuYlZYmFbu0ddbrCZcfSuA+Xveh Aj6UBxrQ2ak9XHesg9sk9ZU/yVvmraOgP5/67wXt90JMFlEPvOzcH7+jPvtxAHhdsDgg TrBjZI5DZQQl1H5UVB8WUOrgVFIs+6cZbC7bbI4ATBZLSybp5facAJ+aZt+NCyv3Vbs2 ftABOz8g+VXDIifiyEPP64EGYjzsoOBKhk51ma2Ob+sppyGLBjcs24TYlId/5aq3kCcG OAyRkonVxMPmvexg88j7osGgz44FmZBvqO/BnB8Aw31os+lgwoMfiefSKlhvsEA8AwG1 xTNg== 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=RHMfXVA1Klg6sx1DUmOI8CqqOikuok40UfY0H4FVM/4=; b=hXlZHAr3rxDFABZuXT0eSm95YBFcjuD4fAWeWIjLBc17e9Ak9MwPHrQrtWAMecCBYC LkfY6bYMncb72/1nKMh/ivqQubEhbeVAOyl4N1n+gtA9jO5ZqnRIKkPe9g1pKMiQx4rs 7opJIAgSNUnnK/WsmKZ/XEkFeJ3NPWmb39kvrThHKLF5jLx2NiceLS8oc3ct6oWHKNbk wpFKjpPEH8fmXAEeyW/iFSqGXS99itbVmNfnNJ+YdiKkPiZiA1lXNWN4UlzTu5G8ccqC iFPZHupzIpZraYiMfw8pgPGGJGO4fN5MGmJ07KcpnL/b7cKQROrnSqFdhe6tSqzm1ent Ia/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CE3HBi5o; 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 i20si4258170jaj.74.2021.08.12.12.50.45; Thu, 12 Aug 2021 12:50:46 -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=CE3HBi5o; 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 S236291AbhHLTvJ (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235927AbhHLTvH (ORCPT ); Thu, 12 Aug 2021 15:51:07 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD2EC0613D9 for ; Thu, 12 Aug 2021 12:50:41 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id a13so9981208iol.5 for ; Thu, 12 Aug 2021 12:50: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=RHMfXVA1Klg6sx1DUmOI8CqqOikuok40UfY0H4FVM/4=; b=CE3HBi5oEYA49LkpIZBXqvz6sTp4v9D+6JxJkIOv0lOJ2yxDP2DorP/xmRKBJ1U2XH 15javSaI7EpnfD8cnn31fJDjgtXRP7jrSzTKPkGJp9m5BpEnaP2mtvNWHwgibqfG75FR GpC8ene/Y5L9qohcN4xHxSJmRfLktZKLpWjHLlwaxeePZMTRqSBOHZW7Nl0b8euv3v1D N0mOj/gGhH2hjqehN5vL0j0g0bBZBZ/6Yfvc3JdNevA38vBy6nM77spiF1KXvXJl05T3 1St4T618Vj5fBHsKl4RPje4tQs82eiVdBSY4vKzw8l5N8dZyEbYWlg4EQ/a4KvncamVN SAtw== 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=RHMfXVA1Klg6sx1DUmOI8CqqOikuok40UfY0H4FVM/4=; b=RIChTxNwJmpZe2T+sBezQB6BdV7dOzdy+qV4p0CZMT/pBIASZEqYpDxFa3ue0MBOAB PxsUL5hFDE/cddAT3pOnSX0LsW3pBjZrxKpj+wyBUFstdymaFacBF/H3jaq08fTX0Z2t 81th9TksSyPtTOedZoKzUb84TBTWkeZcVyRfJxrrUpDs+3cxaSIh9+YO5mHiWmkeaU25 fV1c8BhDF75I8u4mByvhTuGP6igbTDClfCgs4ZRaLKcGhi+2+hWLW6ble1rrKoYLzsPk +obxPJMCIQsd2riMRRUXB6sy0L1RZq/VMgf1PFwkH9bMXoWpgaJU/hqaIL5jWPrIh3mB G3tA== X-Gm-Message-State: AOAM530qwVSNJkkGvfk9hBdjNNLjM71tgg9p32ZikvlBsf/meoLNVOoF 2Se7/6DEilOe+l6NsNrzPjni+w== X-Received: by 2002:a5d:93d3:: with SMTP id j19mr4242629ioo.184.1628797841156; Thu, 12 Aug 2021 12:50:41 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:40 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/6] net: ipa: re-enable transmit in PM WQ context Date: Thu, 12 Aug 2021 14:50:32 -0500 Message-Id: <20210812195035.2816276-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Create a new work structure in the modem private data, and use it to re-enable the modem network device transmit queue when resuming. This is needed by the next patch, which stops the TX queue if IPA power isn't active when a transmit request arrives. Packets will start arriving the instant the TX queue is enabled, but resuming isn't complete until ipa_modem_resume() returns. This way we're sure to be resumed before transmits are allowed again. Cancel it before calling ipa_stop() in ipa_modem_stop() to ensure the transmit queue restart completes before it gets stopped there. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_modem.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index 06e44afd2cf66..0a3b034614b61 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "ipa.h" @@ -33,9 +34,14 @@ enum ipa_modem_state { IPA_MODEM_STATE_STOPPING, }; -/** struct ipa_priv - IPA network device private data */ +/** + * struct ipa_priv - IPA network device private data + * @ipa: IPA pointer + * @work: Work structure used to wake the modem netdev TX queue + */ struct ipa_priv { struct ipa *ipa; + struct work_struct work; }; /** ipa_open() - Opens the modem network interface */ @@ -189,6 +195,21 @@ void ipa_modem_suspend(struct net_device *netdev) ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); } +/** + * ipa_modem_wake_queue_work() - enable modem netdev queue + * @work: Work structure + * + * Re-enable transmit on the modem network device. This is called + * in (power management) work queue context, scheduled when resuming + * the modem. + */ +static void ipa_modem_wake_queue_work(struct work_struct *work) +{ + struct ipa_priv *priv = container_of(work, struct ipa_priv, work); + + netif_wake_queue(priv->ipa->modem_netdev); +} + /** ipa_modem_resume() - resume callback for runtime_pm * @dev: pointer to device * @@ -205,7 +226,8 @@ void ipa_modem_resume(struct net_device *netdev) ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); - netif_wake_queue(netdev); + /* Arrange for the TX queue to be restarted */ + (void)queue_pm_work(&priv->work); } int ipa_modem_start(struct ipa *ipa) @@ -233,6 +255,7 @@ int ipa_modem_start(struct ipa *ipa) SET_NETDEV_DEV(netdev, &ipa->pdev->dev); priv = netdev_priv(netdev); priv->ipa = ipa; + INIT_WORK(&priv->work, ipa_modem_wake_queue_work); ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev; ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev; ipa->modem_netdev = netdev; @@ -277,6 +300,9 @@ int ipa_modem_stop(struct ipa *ipa) /* Clean up the netdev and endpoints if it was started */ if (netdev) { + struct ipa_priv *priv = netdev_priv(netdev); + + cancel_work_sync(&priv->work); /* If it was opened, stop it first */ if (netdev->flags & IFF_UP) (void)ipa_stop(netdev); From patchwork Thu Aug 12 19:50:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496047 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719547jap; Thu, 12 Aug 2021 12:50:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/YeNTdIY3p/3DAUu3bzAuiIPC1AIiVigZbgTIG+TOMOdBPVLH+fOcuboa2GhlCkLKnpkd X-Received: by 2002:a92:7c03:: with SMTP id x3mr186239ilc.47.1628797851314; Thu, 12 Aug 2021 12:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797851; cv=none; d=google.com; s=arc-20160816; b=kPlZ1/pcbGuJM6ne8YnAJL8l/hkfAmOuAbStSL4UfJ7RI20sigxT69zg4UDNp9d2Az ms0EIag7ZWPDvAXJ+bzFqd0qkGouBOn8DSKANYIrf2wnuoUy7NN0g8EKNVLGwuSV7IxP DZumd8EhMLwpO5DJsxlPdKwCjxUgB2YZEtnUrhyyI0z4w2uqlExAxeoFrBObtJrnk6GQ mqiRA5tacH1yIzummVFfBraK411nIFc3Nr9f+tdOYl8BopTWXYIwk72tD51EGMfo6DhR E9QjFy6EcaKKndM/9Za4S6WVaLg3BmsbL1Qbs56KNLH2o98e5RXKnI4DFU4bxxQ8qv/+ NeWg== 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=64xPgsftRVJbwugHrzB1UvjPqduhCUZZEB/J6cFDx2k=; b=t+qU+3LC8iS7Tu1mMgQ05JTkQv6Q2I/ufz7++6z+eCbkdsHhzUOa2xywL3aUFOMBNK mwPBCkvFwZ3CFmskI+DyGsVD7xaBEu2dL9SXpF3zbRRfUpCPOwROacRAXaimDeZp/dNJ XbxMwYD43fv+1nlkzy7T5t78YZlftaNiO1LKdfsZ+0P8uF+JmTKdWQGB8piFBuUKq9qQ SwGi2Gc4+k3OUuA5OGUjp2bA3NaNfsg1CvaHfI9JVnA5z/W/0SxGwsdYmJe++GKXTDXA ykpmmhtL52zPpaDbo1aUZNAycCUYjyq65z9S86Ssg0qMICHb+GXyhDedk2jaBFtm8T7A B4/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eXzgkABu; 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 i20si4258170jaj.74.2021.08.12.12.50.51; Thu, 12 Aug 2021 12:50:51 -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=eXzgkABu; 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 S236673AbhHLTvP (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236053AbhHLTvI (ORCPT ); Thu, 12 Aug 2021 15:51:08 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D5D1C0617A8 for ; Thu, 12 Aug 2021 12:50:42 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id s184so10076768ios.2 for ; Thu, 12 Aug 2021 12:50: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=64xPgsftRVJbwugHrzB1UvjPqduhCUZZEB/J6cFDx2k=; b=eXzgkABuTmzTk1yRQI2m382W8/rUC3gAINQz39akmYF6UzQyXUOLKk2Ss59hTyEcz0 eO1FGq5+C0LWlgOkXsiyXNfXu2f8Bb9pyUjPEWW/zoQ4MrGR6eDo/hNz254HNh46M6DW 1wM61mU+CDkotkqhXFPYyipwaZ9WrkjQ36pz3JdTHjrwo4LD6QfdMgs3I+TEGi6oHd9h CIEUFguydH1jEMEvVnzd6qbTE23m1X5sg17hYY9Gs4flbBAbNC8jjWxjsTZuewicL7z3 pjj5FPfrPMthcNdpHBcsAjyZq5Q5+WkgaWW8xJ/IMIYhzymPjdCc63XXs3UnWb2crd0E /f2g== 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=64xPgsftRVJbwugHrzB1UvjPqduhCUZZEB/J6cFDx2k=; b=mFhcK8vNw6MpvF14ajruHDY5n7d49sy0U4O6kZ23OvWhpeSLmtxnUJ8C0pb9Y2eCHj 9gWqVmkjxPvcwi2LB/ktRy87EgfRd8HdnO9CG4wDrrWbKsMoaEoR7lUozeeXtHw9WbRD jX+onrDlL8rhUE0os6zozlwcqS1y8aWcRp0chnzuSD4grpF+8jvI255s5/arlQdep3E6 +s6r2YtuCyaxXOjIBeRXw6eQskXtQJErfhTADnc+4d6726rzPxcslkpKFkvLAIPvWUMt bruA3QAyptyGVbiyW/DdX8neR1tUG2ahaCk7FmopP6ZScRM+OQXxEbg5ilO8Xb8yyZz9 VPLw== X-Gm-Message-State: AOAM532xFV3g9N6grC942SLzilItwNCAc4P6h7l2AxuNpgYpI9cqnJMV eoeLWm0StXsyo5Woavaad94+Yg== X-Received: by 2002:a5e:d91a:: with SMTP id n26mr4169992iop.96.1628797841987; Thu, 12 Aug 2021 12:50:41 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:41 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/6] net: ipa: ensure hardware has power in ipa_start_xmit() Date: Thu, 12 Aug 2021 14:50:33 -0500 Message-Id: <20210812195035.2816276-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We need to ensure the hardware is powered when we transmit a packet. But if it's not, we can't block to wait for it. So asynchronously request power in ipa_start_xmit(), and only proceed if the return value indicates the power state is active. If the hardware is not active, a runtime resume request will have been initiated. In that case, stop the network stack from further transmit attempts until the resume completes. Return NETDEV_TX_BUSY, to retry sending the packet once the queue is restarted. If the power request returns an error (other than -EINPROGRESS, which just means a resume requested elsewhere isn't complete), just drop the packet. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_modem.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index 0a3b034614b61..aa1b483d9f7db 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -106,6 +106,7 @@ static int ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev) struct ipa_endpoint *endpoint; struct ipa *ipa = priv->ipa; u32 skb_len = skb->len; + struct device *dev; int ret; if (!skb_len) @@ -115,7 +116,31 @@ static int ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev) if (endpoint->data->qmap && skb->protocol != htons(ETH_P_MAP)) goto err_drop_skb; + /* The hardware must be powered for us to transmit */ + dev = &ipa->pdev->dev; + ret = pm_runtime_get(dev); + if (ret < 1) { + /* If a resume won't happen, just drop the packet */ + if (ret < 0 && ret != -EINPROGRESS) { + pm_runtime_put_noidle(dev); + goto err_drop_skb; + } + + /* No power (yet). Stop the network stack from transmitting + * until we're resumed; ipa_modem_resume() arranges for the + * TX queue to be started again. + */ + netif_stop_queue(netdev); + + (void)pm_runtime_put(dev); + + return NETDEV_TX_BUSY; + } + ret = ipa_endpoint_skb_tx(endpoint, skb); + + (void)pm_runtime_put(dev); + if (ret) { if (ret != -E2BIG) return NETDEV_TX_BUSY; @@ -201,7 +226,10 @@ void ipa_modem_suspend(struct net_device *netdev) * * Re-enable transmit on the modem network device. This is called * in (power management) work queue context, scheduled when resuming - * the modem. + * the modem. We can't enable the queue directly in ipa_modem_resume() + * because transmits restart the instant the queue is awakened; but the + * device power state won't be ACTIVE until *after* ipa_modem_resume() + * returns. */ static void ipa_modem_wake_queue_work(struct work_struct *work) { From patchwork Thu Aug 12 19:50:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496048 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719610jap; Thu, 12 Aug 2021 12:50:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSvoGWdJrYhWH/b7AT0BkzqJhCJfnLNBzNXOTEFqRhXbB1JlDzo1qHRR/Pr3W1FiPT7oyR X-Received: by 2002:a6b:b502:: with SMTP id e2mr4211383iof.152.1628797857470; Thu, 12 Aug 2021 12:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797857; cv=none; d=google.com; s=arc-20160816; b=I+evzkNpHOdl3K+SsTOEWIbQdOWVSXlFDS8olQL+eNLj9xBBi2lsp2arLASAwXAr// I4rx4jzrwiZgTWy6gsMRNWusHrfcNurCX9sHwlLaqVwtpVHDQMpUbZ3xgP5wxlq5CQKW hz5EUBntEYrYoQwicqrNDFTzJii3clsA7o35Xtvqzui8Ko71gBrnDNPpgWwViMn4SsrH R9PQ0xEYnbte0Nywz85M6VdDaglyf/gSTtKNl4KpkTvN/xgosQrNBK6X8VbTURv4A1mi sslH3rmy22hIHAl0M+iOLl2nG63p2B6Omi2eWeW2bvDzznK0aXnSF0vqEvlDt25zB8MH SIsQ== 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=QSpci64/hMqy88Q22faTec2s8wp9JGPuRuA3v3rI9YQ=; b=skxW31tDCfBKdltug4YfhAxRdRZlSWuHnA0VmJuqHGj7Ap4BHo6OhYo4kZPra/uUdk qS7myaHO+kBdsOM+Zrn4nKCAdTijPgy2OZI36Fts5yRBN1OuPFdjCPzFz8J1uYver5sH go5H4XQYqq2La8iJCAmvmjU3UO0mpMxgLR3kGvUgYoE8DWBd2D7X86n1Np99ILe8YulY eOgpUNQKwd48aUI/nsVCPnqfV7jFQtLI/q3qtpokGUDFFFugZfXvBHhRyrZ78Uq/kMyn z+NviqifiZOp+FPeoQa0Lr2+wIsRc7K2wCxDvwB9nnVvUrH/G+JOeR99lkKeexx19UcH eFjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P3PRMZs3; 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 i20si4258170jaj.74.2021.08.12.12.50.57; Thu, 12 Aug 2021 12:50: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=P3PRMZs3; 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 S236856AbhHLTvT (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236112AbhHLTvJ (ORCPT ); Thu, 12 Aug 2021 15:51:09 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6378CC0613A4 for ; Thu, 12 Aug 2021 12:50:43 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id w6so3333921ill.3 for ; Thu, 12 Aug 2021 12:50: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=QSpci64/hMqy88Q22faTec2s8wp9JGPuRuA3v3rI9YQ=; b=P3PRMZs3/UXYGNdQf6SaCtATu/V7phGy1FxQf7KjkvhAxxvjN3hT//M8K4o4ZBQ7Fq 3dHx2dIcLC6jIsftPgWyWs4noXGATMniiRJxxFAbN+j8t+TDnsM0qUHYoiPwh2EVwWo/ ud4rYqKOEe1v1AjP4t4lIJ2aLiAcK90QyRTg5+/+EAwD/DhNv65eQwPX7XPjsJAn3Hnd HPvYsAR4a2STwLpB2581d7NsTAR83QTdTPApN1cOmTWAq78WAkIrlbQytKTiVPEY4q22 QandDbjzdrgMHQyogapKm+tDPg3OG8Ppe80H/y0rLEo/erFfc63hrdVTULUsJnEeMXXF cb+g== 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=QSpci64/hMqy88Q22faTec2s8wp9JGPuRuA3v3rI9YQ=; b=tLzOx5YgGIUexDTNesWNDzeEj0XJp+CN0M2MnLKOt+oqnph1cVBIpSaGcjdPajpHbN fIxk3v3Wh5xuvYEWQUT++UxPbY+uV2kp0WA167tlLo8lxWwwxOnT+OFK7cVpNHbBppdG lpfx/iqqeOIa+qm3j11fGZZhVOv5iMlEvKD/ShtfJa0d0NBCr5h9IXvJ0rj6tAsoggvk psHEs0KFIAlYun2JGC/tkqFP8+uwbJIjIUvOZC2fguO4wbPaOhTe0zjdmtQ2V1YgWgVW qCtPGz1g/ze7I/1OH7Vqoa3zn1o7rTGrUPBg2KEVdc+FZMi+9IeHEB2RGkjPASpbJlJM KqQQ== X-Gm-Message-State: AOAM532b4AV+1EzRXOkm4pFAjumkjwmwVaHpjo3daV3SvlQXu93bysmg gaKG+pt1p3h2sYsKZcX1JsRgKA== X-Received: by 2002:a92:d18c:: with SMTP id z12mr176696ilz.295.1628797842839; Thu, 12 Aug 2021 12:50:42 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:42 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/6] net: ipa: don't stop TX on suspend Date: Thu, 12 Aug 2021 14:50:34 -0500 Message-Id: <20210812195035.2816276-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently we stop the modem netdev transmit queue when suspending the hardware. For system suspend this ensured we'd never attempt to transmit while attempting to suspend the modem endpoints. For runtime suspend, the IPA hardware might get suspended while the system is operating. In that case we want an attempt to transmit a packet to cause the hardware to resume if necessary. But if we disable the queue this cannot happen. So stop disabling the queue on suspend. In case we end up disabling it in ipa_start_xmit() (see the previous commit), we still arrange to start the TX queue on resume. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_modem.c | 2 -- 1 file changed, 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index aa1b483d9f7db..b176910d72868 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -214,8 +214,6 @@ void ipa_modem_suspend(struct net_device *netdev) if (!(netdev->flags & IFF_UP)) return; - netif_stop_queue(netdev); - ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); } From patchwork Thu Aug 12 19:50:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 496049 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp719625jap; Thu, 12 Aug 2021 12:50:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcEg+fp8m8CJ4NOKkL1bCrJRxr5f6bu2qx6pLcMveCcp7kVkg+mxw/7XScopmtF3AoYUWz X-Received: by 2002:a92:1e03:: with SMTP id e3mr193889ile.89.1628797858560; Thu, 12 Aug 2021 12:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628797858; cv=none; d=google.com; s=arc-20160816; b=SQXkBjI8H/UMv3APH1MNQ7HYFwj7sWHdH9j5v2/eHK0BpsYOpE3T3r2bgXiuPpfrMM iFbCBgwvTa2mMW2F5zE2ccb8fstF8MVYLiDlE0AJR5pfG7xn5B4jmFNWpy92Dg2CBDd9 3/5tHb8uYUG9mIW2uAHiQlsc9xbatRL6LJVc8i7Ey/5aHyy6vEpioJJATAnJRzNJVYCT XE1V9jzuoxT5heIUVQkRdHKQEJ/oPAvYFWCO/jSVQHlhSs1XB6sUYKvShIOSrWTK3+ls YScQo3g7uWSlD73ntj7CSB2zsgjKEK4Y94pk+xaaT/dlJj/lDlW6kZqfdyoQ8jaoWTHO cEvQ== 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=pVDXj/c2GhrmP3JpxAGc+59S/Eh6qUoCDMrEnYN38ig=; b=FmyxHBHJDMYR0HU9A5UKsBnIpXryAH5wV4KvFYvJ0Q88Gkd2hvke48ZgKZ/saX6PZO 3g48wcIDCMCgFccYxWGW2vRYDdHrvo6Wz83IHbJ4weoyugxKZ1vYOsJtl0bc+xl+KH+d jtmr3oFPo6Y/rw4hQqZgT3f+ANm+Fj8fjPDV0fLzi6EJ1QkOTmAsFpsQWhZcu+blP5Sa C5JOPP400vt07rRib/12Y8qyiWyyHycZ9PzgGrksY9SK3gocYofKUHdHEh0Nq9cdgosL PpQ7gHPzvPbhD76ccMF0a98pX6nwKFnj+2oYb+XtQh7B9PoGk6GrXwJjV1iu2aDDGfbv N/Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qu6hMONK; 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 i20si4258170jaj.74.2021.08.12.12.50.58; Thu, 12 Aug 2021 12:50:58 -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=Qu6hMONK; 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 S236956AbhHLTvW (ORCPT + 8 others); Thu, 12 Aug 2021 15:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbhHLTvM (ORCPT ); Thu, 12 Aug 2021 15:51:12 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 491E1C0612E7 for ; Thu, 12 Aug 2021 12:50:44 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id q16so7667086ioj.0 for ; Thu, 12 Aug 2021 12:50:44 -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=pVDXj/c2GhrmP3JpxAGc+59S/Eh6qUoCDMrEnYN38ig=; b=Qu6hMONKHaomHVzVDk6h4d9M7HVT/cFdSqp48XMihTQ1wme3tBEzYfaYsLulMcH6L6 EpNwWR5pwiQUTEC8RpgY2saOsqfd9athwfhrY6wJzsU3r/DWoMJX7KfjBq03QwPG7wGl u8yTVqWyj7p0WUvIdIJSQSMQhp/t5QJ/II0KGcTW386p7MNryUBVeXj75FQSxkPF0ViQ p2icnL69wR1soSjAmsdXZcEWsJzRdDCVDTT1N3gcgfRe8FlVGwNPX3MEsXI7YSL68hJO 3c7n6f8b8bTkK8fSDErufEVZTIYpk1yAwIrjKlLPJc2ILQmYyFGhBnxSy/Q7P/fa6oPe dFng== 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=pVDXj/c2GhrmP3JpxAGc+59S/Eh6qUoCDMrEnYN38ig=; b=oonbllrq2yL/PFqG9u67lKWiRHNknRUZJwms+C+m+X16PVF6/D+6b4k9N0NPy94KK0 +lVM/t2nLb5DijQco/pPvw4Ho1CKbG4/H/LNrRlLfewZySIYknDg4pni7TvSVPZID31n rJ6Hq16Ce16dffbxVamGg3654qcgtWgwzGjvn70OaI5ytVPEt6GSVyXJJcUdXIS+1D7e re8A6tyUc0Jy3/lw1sWA/wLQtyuPoIetPwcLxrVYnkezy0eC64m4S8PYeX5dINPnyT3g AwqcTrdNpTURjU0LjOttiF66b6gsiMZxda0rT/LNZ202wT9VkC1z8QZT/gJLYLftvpuC +ClQ== X-Gm-Message-State: AOAM532HuC09046qJufM3FQ9jKUHUNqto5I8MIQKPPkB7WLSLIWnkDT1 LbjrfcRY9aPO11gqb9KPlV/8Gw== X-Received: by 2002:a5e:8f43:: with SMTP id x3mr4318023iop.206.1628797843642; Thu, 12 Aug 2021 12:50:43 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id s16sm2058821iln.5.2021.08.12.12.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 12:50:43 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/6] net: ipa: don't hold clock reference while netdev open Date: Thu, 12 Aug 2021 14:50:35 -0500 Message-Id: <20210812195035.2816276-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210812195035.2816276-1-elder@linaro.org> References: <20210812195035.2816276-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently a clock reference is taken whenever the ->ndo_open callback for the modem netdev is called. That reference is dropped when the device is closed, in ipa_stop(). We no longer need this, because ipa_start_xmit() now handles the situation where the hardware power state is not active. Drop the clock reference in ipa_open() when we're done, and take a new reference in ipa_stop() before we begin closing the interface. Finally (and unrelated, but trivial), change the return type of ipa_start_xmit() to be netdev_tx_t instead of int. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_modem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index b176910d72868..c8724af935b85 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -65,6 +65,8 @@ static int ipa_open(struct net_device *netdev) netif_start_queue(netdev); + (void)ipa_clock_put(ipa); + return 0; err_disable_tx: @@ -80,12 +82,17 @@ static int ipa_stop(struct net_device *netdev) { struct ipa_priv *priv = netdev_priv(netdev); struct ipa *ipa = priv->ipa; + int ret; + + ret = ipa_clock_get(ipa); + if (WARN_ON(ret < 0)) + goto out_clock_put; netif_stop_queue(netdev); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); - +out_clock_put: (void)ipa_clock_put(ipa); return 0; @@ -99,7 +106,8 @@ static int ipa_stop(struct net_device *netdev) * NETDEV_TX_OK: Success * NETDEV_TX_BUSY: Error while transmitting the skb. Try again later */ -static int ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev) +static netdev_tx_t +ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct net_device_stats *stats = &netdev->stats; struct ipa_priv *priv = netdev_priv(netdev);