From patchwork Mon Feb 1 17:28:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059575 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFA89C433E0 for ; Mon, 1 Feb 2021 17:30:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B42D864EC8 for ; Mon, 1 Feb 2021 17:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231772AbhBAR3r (ORCPT ); Mon, 1 Feb 2021 12:29:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbhBAR3f (ORCPT ); Mon, 1 Feb 2021 12:29:35 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16882C061756 for ; Mon, 1 Feb 2021 09:28:56 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id m20so8841631ilj.13 for ; Mon, 01 Feb 2021 09:28:56 -0800 (PST) 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=Nmi+suSrpZfRwUpuA9SDfz6AzQTTcweGvCEfMikGM/s=; b=SCjwns0xGu4PCRVAJxUo4cKOUR203WZ9Rix9ZEVp+QhKiTx9EOir+C4rbRwdem6Q+W szdAGcuBPF8xNcHUvWeTrt53S6TtRwh086q5BVt7Lwz+n6qfiZkjvaCjBcGoQVip/Tv9 ZeCUTwIbbAqlDUFA35dg9xRJupeMAdjl5qHMpssAtmNMGQkHZ2TSJYBIaPsrRpQs4z10 9AwkcdrDmMHUFN06WBX1Gvn39GbTH0ZcL3T+qwLm3ZnQ3qjqphmvgv+K2g1SYlYYJGYQ M6QlS7HoNWNSTa+sZtjFNjBPXQA+IO5Oi4fPOgZXWUqa9I0w6NVofqT4iao6epSrkbtR M38Q== 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=Nmi+suSrpZfRwUpuA9SDfz6AzQTTcweGvCEfMikGM/s=; b=P6uHEwag5Gb+jzlsvqE3wO0j3DYJ13u2BaHnELirj3Ls9NL6tvLhX1VjWBeKFnMklo Be7ezyaKYqWM+DEonNwzExo9wUknR+Z2cHBVeiXph2UGBU3Wbry2d20dVFs/ogJpA4cz yyelxovytwFLDRUYVWkLRvSA+HFp1b2pRO8Ajxsee4Qa/lsuOa5KlZU5wCNDkSrDoHhV b6b0WZCTnx7Xsb/DdT6BzpwMSIcypbHC+i20g3x/VgNQUUfABZGqf+glBygWhOm5ECB/ GVdrLJE8FF/McBdaZui+cPsJNuNCda4CnCljhlICyv0zJnN0n4v9VBGs76cQKoBFufKp BoYQ== X-Gm-Message-State: AOAM532vLF/Fe6xQcdZSgY/UPa4pH/3ucZ45tmLn0b3HZLgANnwQsi6s eG7NcSAR9hK4rz0LEb7KlerBuA== X-Google-Smtp-Source: ABdhPJwOFE77Qq2RHPXQ2uk/QvWZ6WlhvXTdG9EhrlX/ynsXUW0mTEzCGhIVOSWEjt3mZWdVxeXu7A== X-Received: by 2002:a05:6e02:19cc:: with SMTP id r12mr14043945ill.4.1612200535576; Mon, 01 Feb 2021 09:28:55 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:28:54 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/7] net: ipa: don't thaw channel if error starting Date: Mon, 1 Feb 2021 11:28:44 -0600 Message-Id: <20210201172850.2221624-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If an error occurs starting a channel, don't "thaw" it. We should assume the channel remains in a non-started state. Update the comment in gsi_channel_stop(); calls to this function are no longer retried. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index f79cf3c327c1c..4a3e125e898f6 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -885,7 +885,9 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id) mutex_unlock(&gsi->mutex); - gsi_channel_thaw(channel); + /* Thaw the channel if successful */ + if (!ret) + gsi_channel_thaw(channel); return ret; } @@ -910,7 +912,7 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) mutex_unlock(&gsi->mutex); - /* Thaw the channel if we need to retry (or on error) */ + /* Re-thaw the channel if an error occurred while stopping */ if (ret) gsi_channel_thaw(channel); From patchwork Mon Feb 1 17:28:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059579 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F7B4C433E6 for ; Mon, 1 Feb 2021 17:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D41A964EAA for ; Mon, 1 Feb 2021 17:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbhBAR3u (ORCPT ); Mon, 1 Feb 2021 12:29:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231475AbhBAR3h (ORCPT ); Mon, 1 Feb 2021 12:29:37 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 966C3C0613ED for ; Mon, 1 Feb 2021 09:28:57 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id x21so18206468iog.10 for ; Mon, 01 Feb 2021 09:28:57 -0800 (PST) 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=LCw8t3dNLb85N9LUx0CmQJolraUZfpfFkvo2+8sOa0o=; b=YaC0edC7bZatVna8cq1y+F9Li8RsLiT8fGSwnT3dt2Q7EOGwF6UW+kFHEOf4E/+pZN Q8UcTWlzxyyi+YYpvCbrhV9MdhBK+dWAviD3Ju19eUoe0U5mJoavcL+6cYKatqkPo/dS TB5pDT+qne/Rt6Q7wBYzAcC+H2kRZ//tqPcR2HZLvEOGm3IyL5YXu9IIvymgnn6RGjxF LGE1A+QUOjxY4uOGxFLgvrh0mgHH8HT+oQtL9FuhlHaouRqik0s93nhGgD8AB+r/TrMT osgYCJiQuILQR5NbzXvBfpbTkpA1h98yTl4jmVvwKxfTQK7FWiuBVAQo6I6XW5JklakQ V+pw== 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=LCw8t3dNLb85N9LUx0CmQJolraUZfpfFkvo2+8sOa0o=; b=bLAPfWywyyjc7YYy518poqlPHll6S2bENVeGst+5H22dXOlGvhu529uM5BQBJzaYNi r2RJOIBVms0bqNsFKf8YWUcTWPW0zpK/AN02R48WYX58eA3o1eem6Unpnesn7kva+XRY wfkf5xkVDwcDNZ7X25t6nOw+k1XEBjUNyd1X6vco3g7k+3VC22iSMHkhKiTFlddcRrzu n5yF4pl8sEvhJAu9G8Zt3S22tgU4bEH59e8Pcr63nm150GbwR9PoMck6yyPEH8t86nU0 NcZSKNMOgm1CFW0LNzd3B8gTdwLibhqldx82vabk1Z6wNIeVgQAE7bkxmGBeQC6u0/bP iaIg== X-Gm-Message-State: AOAM532fcDWOrdQ4r5QyWV+2vUToaHkCSmZUU0B3bcQazX6Of/zd7aPe pcvqvfNpoyJsWzHoKwgX62W2hw== X-Google-Smtp-Source: ABdhPJygz6UZ1A1FN0ClrkS1VJJIGTbdX1zRTQgIibUf+X2X3PVVnsB45qK3MwD8YzWnlwqWFzJZVQ== X-Received: by 2002:a5d:9ad4:: with SMTP id x20mr1836777ion.31.1612200537129; Mon, 01 Feb 2021 09:28:57 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:28:56 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/7] net: ipa: introduce gsi_channel_stop_retry() Date: Mon, 1 Feb 2021 11:28:45 -0600 Message-Id: <20210201172850.2221624-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create a new helper function that encapsulates issuing a set of channel stop commands, retrying if appropriate, with a short delay between attempts. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 4a3e125e898f6..bd1bf388d9892 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -892,15 +892,12 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id) return ret; } -/* Stop a started channel */ -int gsi_channel_stop(struct gsi *gsi, u32 channel_id) +static int gsi_channel_stop_retry(struct gsi_channel *channel) { - struct gsi_channel *channel = &gsi->channel[channel_id]; u32 retries = GSI_CHANNEL_STOP_RETRIES; + struct gsi *gsi = channel->gsi; int ret; - gsi_channel_freeze(channel); - mutex_lock(&gsi->mutex); do { @@ -912,6 +909,19 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) mutex_unlock(&gsi->mutex); + return ret; +} + +/* Stop a started channel */ +int gsi_channel_stop(struct gsi *gsi, u32 channel_id) +{ + struct gsi_channel *channel = &gsi->channel[channel_id]; + int ret; + + gsi_channel_freeze(channel); + + ret = gsi_channel_stop_retry(channel); + /* Re-thaw the channel if an error occurred while stopping */ if (ret) gsi_channel_thaw(channel); From patchwork Mon Feb 1 17:28:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059583 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1322C433E6 for ; Mon, 1 Feb 2021 17:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 948D864EAA for ; Mon, 1 Feb 2021 17:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbhBARac (ORCPT ); Mon, 1 Feb 2021 12:30:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbhBARaU (ORCPT ); Mon, 1 Feb 2021 12:30:20 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C6EC061788 for ; Mon, 1 Feb 2021 09:28:58 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id s24so6662098iob.6 for ; Mon, 01 Feb 2021 09:28:58 -0800 (PST) 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=S6UrYR89rofy8hE7qWATkIkJyfK6GF/86I4qksnu9sI=; b=EnDETKm4J5LhZK4ej0H/mtR46vNCiJWFRQs8N3XLOT39eML1sFrccDex46b1mJJkj4 HzFY309+TQpXLC1RDIEVqVW5FxFbNH4C1xC09myhkYfxLa1k/zk3TCobP+qeeoVzbE9l Q4EAGBin9glOoxzh9dAal5ydMXVvgbsVvKP8WXyl2htHxC0bCzQJ97z6JOn+2SkY2N14 XBDX8RYGg29Jzt9zX3hifE9SXTFoPO76ZHD0TeDpl5b7QOvmB3fPbt+P2Q+SVILQkSU/ wK0nE0cC2sgIKYN0HckRq9+sBnTH3ryPFUYU+jc8myLl5ij5TXcq2kZv7ad9z6NEPDQa vD+w== 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=S6UrYR89rofy8hE7qWATkIkJyfK6GF/86I4qksnu9sI=; b=kcCrlAGMuSwUsHYW7u8gV94Vq3A3XRPTiqCj1tqW7P1vSKiI245BxoCg1RuHqH2kmS yMMC1eK+S320t/bhm1EQLQLlmrv5Oa44OEgblT677D2sjqETW3iD1f9vGgA++GljwCJF vqn+fpeSTTHmks65M/uCrkPq314Lkzz/9IaWPY1spI/pFQ1hgfyxlwcATQ/aGpvUBirt DxE11S97DQtK5FVgBvJFpD6n5075Ki+7DYsNWdS5xxJIAGhpNvsdPsk4VfFmSYEbF6Bt Oi+WyDt93mHd/LXbVfNXYPn2piIphj2H/SpLYq71ij6fWUUIlahPcNogCXDG+VSUmyos Is+Q== X-Gm-Message-State: AOAM533ASbIues5W+eOdgBz3I+/gaBnwk2kFSd1bbFoX9Zt18q6RENGt rtS5t4G3pDM5gHNvnk5njlf76w== X-Google-Smtp-Source: ABdhPJzqXikoXli2cdw8YD8g6w4oiEyCrjfHaBTVK8862fhTr4ingSTAVJh2zz4fDmciLhdTvFHXhw== X-Received: by 2002:a5e:840d:: with SMTP id h13mr13798860ioj.23.1612200538427; Mon, 01 Feb 2021 09:28:58 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:28:57 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 3/7] net: ipa: introduce __gsi_channel_start() Date: Mon, 1 Feb 2021 11:28:46 -0600 Message-Id: <20210201172850.2221624-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create a new function that does most of the work of starting a channel. What's different is that it takes a flag indicating whether the channel should really be started or not. Create another new function __gsi_channel_stop() that behaves similarly. IPA v3.5.1 implements suspend using a special SUSPEND endpoint setting. If the endpoint is suspended when an I/O completes on the underlying GSI channel, a SUSPEND interrupt is generated. Newer versions of IPA do not implement the SUSPEND endpoint mode. Instead, endpoint suspend is implemented by simply stopping the underlying GSI channel. In this case, a completing I/O on a *stopped* channel causes the SUSPEND interrupt condition. These new functions put all activity related to starting or stopping a channel (including "thawing/freezing" the channel) in one place, whether or not the channel is actually started or stopped. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 71 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index bd1bf388d9892..bba64887fe969 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -873,23 +873,30 @@ static void gsi_channel_deprogram(struct gsi_channel *channel) /* Nothing to do */ } +static int __gsi_channel_start(struct gsi_channel *channel, bool start) +{ + struct gsi *gsi = channel->gsi; + int ret; + + mutex_lock(&gsi->mutex); + + ret = start ? gsi_channel_start_command(channel) : 0; + + mutex_unlock(&gsi->mutex); + + /* Thaw the channel if successful */ + if (!ret) + gsi_channel_thaw(channel); + + return ret; +} + /* Start an allocated GSI channel */ int gsi_channel_start(struct gsi *gsi, u32 channel_id) { struct gsi_channel *channel = &gsi->channel[channel_id]; - int ret; - mutex_lock(&gsi->mutex); - - ret = gsi_channel_start_command(channel); - - mutex_unlock(&gsi->mutex); - - /* Thaw the channel if successful */ - if (!ret) - gsi_channel_thaw(channel); - - return ret; + return __gsi_channel_start(channel, true); } static int gsi_channel_stop_retry(struct gsi_channel *channel) @@ -912,21 +919,27 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel) return ret; } +static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) +{ + int ret; + + gsi_channel_freeze(channel); + + ret = stop ? gsi_channel_stop_retry(channel) : 0; + + /* Re-thaw the channel if an error occurred while stopping */ + if (ret) + gsi_channel_thaw(channel); + + return ret; +} + /* Stop a started channel */ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) { struct gsi_channel *channel = &gsi->channel[channel_id]; - int ret; - gsi_channel_freeze(channel); - - ret = gsi_channel_stop_retry(channel); - - /* Re-thaw the channel if an error occurred while stopping */ - if (ret) - gsi_channel_thaw(channel); - - return ret; + return __gsi_channel_stop(channel, true); } /* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */ @@ -952,12 +965,7 @@ int gsi_channel_suspend(struct gsi *gsi, u32 channel_id, bool stop) { struct gsi_channel *channel = &gsi->channel[channel_id]; - if (stop) - return gsi_channel_stop(gsi, channel_id); - - gsi_channel_freeze(channel); - - return 0; + return __gsi_channel_stop(channel, stop); } /* Resume a suspended channel (starting will be requested if STOPPED) */ @@ -965,12 +973,7 @@ int gsi_channel_resume(struct gsi *gsi, u32 channel_id, bool start) { struct gsi_channel *channel = &gsi->channel[channel_id]; - if (start) - return gsi_channel_start(gsi, channel_id); - - gsi_channel_thaw(channel); - - return 0; + return __gsi_channel_start(channel, start); } /** From patchwork Mon Feb 1 17:28:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059585 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08033C433E0 for ; Mon, 1 Feb 2021 17:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C367964EB8 for ; Mon, 1 Feb 2021 17:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbhBARds (ORCPT ); Mon, 1 Feb 2021 12:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbhBARaV (ORCPT ); Mon, 1 Feb 2021 12:30:21 -0500 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 43555C06178C for ; Mon, 1 Feb 2021 09:29:00 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id p8so16372472ilg.3 for ; Mon, 01 Feb 2021 09:29:00 -0800 (PST) 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=DlCW8F0szf7ZcEm2ZEhTbHkqGMJz2nWWOYmbZKt8Dqw=; b=ghtetcHIUsxWLmMhZWewAvClfll7oHvu1j/xc8IPS0HcJyNq5OlSTlf67LdNXRauda rNnjFHJcIuCDYtdPZ/gCFKOQHko+47Fkmr6cxdHdlBRzwbIkywsrOR8jFFstxS0EmcQC Q99eaHWvJpIS0ymTMSIolQow6bbw838FLl9poUvhcN6Ot/EKcb0IjT9KenChGx7/T5TJ +RvGoXRc1NDH+xqfvAI6PEgwyG6L3W0uUyOoRSaeI+Ux8VhVqNz55KmzZUh9TEzZo1Hp GAN+UNGYDvWyR5VtEjG7I1CsqpSJpQmXpPvhIC5YfpQUw9+LTbbwrDDwNXf2WwU5WVj9 3IJg== 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=DlCW8F0szf7ZcEm2ZEhTbHkqGMJz2nWWOYmbZKt8Dqw=; b=VPVbx02e5M6Mj01z40hFUMQyM2EDx59WGk5nXA3gAC4qaut4ZKrul+bVsNQjD4Hn46 W+Rh4BdCdkxb2dsV+ti98GuagPk6QoeLaN3LgPUSI5dUtfvM0ozzYN5t9e7+jRr9pviG P9Mur272wdedutfm0TgRuFsjLOxsktmdGkCHxY6okD6sdtZ9oQs8VJGXDxOTtlPgfpIw rRriycSqsODyA6X7sJQISlZNW9wxbHl6cUG17LYO9ulI+RdPoce7BUmXx6YyS+OWtEGy aZKppbbWAou1PyPEmntIz8tOVJPnUMN0Hs2QoOiBQhEs7z1ATZhR+6n0BgiXhS9hiJtf snxQ== X-Gm-Message-State: AOAM530cy88C8SrDAqYCmWDraFGEz40T9jT+77XCb1EbLYUNOv8992LZ mXQnKy5Eeob6oTA5MIWzGJ3Zfw== X-Google-Smtp-Source: ABdhPJw5zLE1a5ZjzQQMkQ5IoE4vmILj7Lp+FIeWPK3swkN2HhP5qvQdAVppV2VtRJzwikgoZa0JeQ== X-Received: by 2002:a92:d0d:: with SMTP id 13mr13492710iln.36.1612200539712; Mon, 01 Feb 2021 09:28:59 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:28:59 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 4/7] net: ipa: kill gsi_channel_freeze() and gsi_channel_thaw() Date: Mon, 1 Feb 2021 11:28:47 -0600 Message-Id: <20210201172850.2221624-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Open-code gsi_channel_freeze() and gsi_channel_thaw() in all callers and get rid of these two functions. This is part of reworking the sequence of things done during channel suspend/resume and start/stop. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index bba64887fe969..565c785e33a25 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -764,24 +764,6 @@ static void gsi_channel_trans_quiesce(struct gsi_channel *channel) } } -/* Stop channel activity. Transactions may not be allocated until thawed. */ -static void gsi_channel_freeze(struct gsi_channel *channel) -{ - gsi_channel_trans_quiesce(channel); - - napi_disable(&channel->napi); - - gsi_irq_ieob_disable_one(channel->gsi, channel->evt_ring_id); -} - -/* Allow transactions to be used on the channel again. */ -static void gsi_channel_thaw(struct gsi_channel *channel) -{ - gsi_irq_ieob_enable_one(channel->gsi, channel->evt_ring_id); - - napi_enable(&channel->napi); -} - /* Program a channel for use */ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell) { @@ -884,9 +866,10 @@ static int __gsi_channel_start(struct gsi_channel *channel, bool start) mutex_unlock(&gsi->mutex); - /* Thaw the channel if successful */ - if (!ret) - gsi_channel_thaw(channel); + if (!ret) { + gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); + napi_enable(&channel->napi); + } return ret; } @@ -921,15 +904,19 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel) static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) { + struct gsi *gsi = channel->gsi; int ret; - gsi_channel_freeze(channel); + gsi_channel_trans_quiesce(channel); + napi_disable(&channel->napi); + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); ret = stop ? gsi_channel_stop_retry(channel) : 0; - /* Re-thaw the channel if an error occurred while stopping */ - if (ret) - gsi_channel_thaw(channel); + if (ret) { + gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); + napi_enable(&channel->napi); + } return ret; } From patchwork Mon Feb 1 17:28:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059587 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22438C433E6 for ; Mon, 1 Feb 2021 17:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D822A64E9C for ; Mon, 1 Feb 2021 17:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231907AbhBARd6 (ORCPT ); Mon, 1 Feb 2021 12:33:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbhBARaV (ORCPT ); Mon, 1 Feb 2021 12:30:21 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC10C061793 for ; Mon, 1 Feb 2021 09:29:01 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id d6so16367633ilo.6 for ; Mon, 01 Feb 2021 09:29:01 -0800 (PST) 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=AD7sJiqeRNIVKYtmxnmsyabUetsvJJmTXIczDFUxnes=; b=j0ZNpjxFBP2YppUXpqlylkEtM0G6AwPuOwVc962pTU0wtZ0pfH+rl/2UiD5RinVsk2 9BKOVNgo3UoAEy2lKvayX3xIsUDH5n2AFvTXoEUd8RhvHK1w2K8mNp0CN1kUFx70feSP 9BTvoZpyU95S99+jEEuOarwPkJGC78QnCaoDFtIXMiRKfdylC9e39ICQBh/yNusj3beq FtnNFtqMnyiquX7EKXfXBDX0rHiwEBynmzuXGTDCeeVC02XCHbsoJGZQujh2wvL9sfOq 3mwRhjrGJCN2uSJ3fvA1peL0QkScFRrBBS8sVEsADr9C2LNkR7TpGpkAK4nA66/dM2xT 89Ig== 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=AD7sJiqeRNIVKYtmxnmsyabUetsvJJmTXIczDFUxnes=; b=OteNUV1J9VHW2wDcKnD21Fbxcb20Kp9EBlM1SCvF/ozJM38ndnOD3I5uxEOkqPvr9I P1k+ltgREPgtwh+v8LDyPTNg9kviQwsPOHxYiATntgt4VIHHmTHZn99TNRvnm4ToBJop bkvltc62I2uWWRRzCNVds4PZwY+d6gdpVwKh5By97xZDw+1z+TmohORx8AELwv72m2+H xxZpwnCCONp8RsLhNwO30PwI3usasm5Ly9iSf3IyXHX9TMqBq1Yc6WBXnh76QlpGf3tH kgWyKVq3zkoTrAGYqt7oEplzqS3zuTSZP35t7PPREdHPxJBpfEauJHv2x2qja2t1Ge84 R/hw== X-Gm-Message-State: AOAM5327GJWDkOzNL+Qz9BNZW+aSSeIRn85Khg13yegW40ygNLfU2mwN nUysdJubOk6/5IKMphD//EM0OHXxRkrksw== X-Google-Smtp-Source: ABdhPJz4NDQOsBIkEDNxq29t5pxY6NvHO74UsGOfqY6G+o86HbVtQQfgm2h2tr+Vo0gGHer3NOsz7w== X-Received: by 2002:a05:6e02:1b84:: with SMTP id h4mr5304965ili.196.1612200541274; Mon, 01 Feb 2021 09:29:01 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:29:00 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 5/7] net: ipa: disable interrupt and NAPI after channel stop Date: Mon, 1 Feb 2021 11:28:48 -0600 Message-Id: <20210201172850.2221624-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Disable both the I/O completion interrupt and NAPI polling on a channel *after* we successfully stop it rather than before. This ensures a completion occurring just before the channel is stopped gets processed. Enable NAPI polling and the interrupt *before* starting a channel rather than after, to be symmetric. A stopped channel won't generate any completion interrupts anyway. Enable NAPI before the interrupt and disable it afterward. Signed-off-by: Alex Elder --- v2: Update code for *both* NAPI and the completion interrupt. drivers/net/ipa/gsi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 565c785e33a25..93e1d29b28385 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -860,15 +860,18 @@ static int __gsi_channel_start(struct gsi_channel *channel, bool start) struct gsi *gsi = channel->gsi; int ret; + napi_enable(&channel->napi); + gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); + mutex_lock(&gsi->mutex); ret = start ? gsi_channel_start_command(channel) : 0; mutex_unlock(&gsi->mutex); - if (!ret) { - gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); - napi_enable(&channel->napi); + if (ret) { + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); + napi_disable(&channel->napi); } return ret; @@ -908,14 +911,11 @@ static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) int ret; gsi_channel_trans_quiesce(channel); - napi_disable(&channel->napi); - gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); ret = stop ? gsi_channel_stop_retry(channel) : 0; - - if (ret) { - gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); - napi_enable(&channel->napi); + if (!ret) { + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); + napi_disable(&channel->napi); } return ret; From patchwork Mon Feb 1 17:28:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059589 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAD71C433E0 for ; Mon, 1 Feb 2021 17:34:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC71E64EBA for ; Mon, 1 Feb 2021 17:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbhBARed (ORCPT ); Mon, 1 Feb 2021 12:34:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbhBARaV (ORCPT ); Mon, 1 Feb 2021 12:30:21 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4939C0617A7 for ; Mon, 1 Feb 2021 09:29:02 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id l4so16356198ilo.11 for ; Mon, 01 Feb 2021 09:29:02 -0800 (PST) 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=Q2ro88NuZQKHdsGWYPfuJW6JFivC14REhwCxv7lSOYY=; b=fs7JGSWDk2DyIez9s7HBm2L8UFGxKDXrmGsbBnIVdKm37iRyP4KN93gtg94OPSLe+N Hysbo3Owd0YEQJJ6o/9qYf95tgzgdqwQgkPUHrVTve+ZUow6oC1EXxtQ1eH9wif6Nepc Z+J/XbVZtwEoyn93fOqGMq9iaG6U00Qok9genuDr34I8+dSZ34ZXOTZ4rptvk4OECSbe kSSlmlXDlxvZsEjMB2uk678TSpE4Fg1zbJm2unuaXChbtULDKtoDo/A0llwvNrtjObpy wPuCybocR5VM2bHTqmuZ9tSJMBFxU1iqRs0WBXfd0HURLfQboerUG7+qZs5VtcuUjyxi HQAw== 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=Q2ro88NuZQKHdsGWYPfuJW6JFivC14REhwCxv7lSOYY=; b=cjYmFjRV5UMM49NGgfXS7Vck/Wg1/nKTibA1y9OrMj9I/llirNnnSWSzTHHHchqd7C 3VKXzSnGuXlsWzcs66EB5lvPRTpIViGBHJhNl/1VeLPaobmIHU0qu2e2Iv7X85IIB4l+ ITKe8/NmY5FvIkuPCyaXhCr1NMDQSN0R17cqo74vcywp6pQWEuapjnEiPpJz9Ur8X0SU tAeLfL1YE2bocK5rbiETzKFm2Q7RvbaYZRIX/HVTgcmCj4qYCDwAcix7x6G2VB+CAEy/ 6iaNgFkq5vil/A73iKog6ssRPkP99bULjM611p2dGL+LEUEU1ThSWoCJ2HZTKVh0F4NL WrPg== X-Gm-Message-State: AOAM531+PmCCw0zE9rMVySDiftUiG0oCdGecjwRj9BNV2Fb+Kw6O9m08 rT1tWBsrFy72nKFOqmN8mgi8jg== X-Google-Smtp-Source: ABdhPJwAI/ASi0UBA93Xj/MIF9FpEct7cfKR4ESj2WDMXtHG+UitLrC/Px98AVQ2NRSKjulzWv41Rw== X-Received: by 2002:a05:6e02:20ee:: with SMTP id q14mr13386584ilv.259.1612200542357; Mon, 01 Feb 2021 09:29:02 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:29:01 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 6/7] net: ipa: don't disable interrupt on suspend Date: Mon, 1 Feb 2021 11:28:49 -0600 Message-Id: <20210201172850.2221624-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org No completion interrupts will occur while an endpoint is suspended, nor when a channel has been stopped for suspend. So there's no need to disable the interrupt during suspend and re-enable it when resuming. Without any interrupts occurring, there is no need to disable/re-enable NAPI for channel suspend/resume either. We'll only enable NAPI and the interrupt when we first start the channel, and disable it again only when it's "really" stopped. To accomplish this, move the enable/disable calls out of __gsi_channel_start() and __gsi_channel_stop(), and into gsi_channel_start() and gsi_channel_stop() instead. Add a call to napi_synchronize() to gsi_channel_suspend(), to ensure NAPI polling is done before moving on. Signed-off-by: Alex Elder --- v2: Consolidate preparatory patch into the "real" one. v2: Update code for *both* NAPI and the completion interrupt. v2: Use common return path in gsi_channel_start(). drivers/net/ipa/gsi.c | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 93e1d29b28385..03498182ad024 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -860,20 +860,15 @@ static int __gsi_channel_start(struct gsi_channel *channel, bool start) struct gsi *gsi = channel->gsi; int ret; - napi_enable(&channel->napi); - gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); + if (!start) + return 0; mutex_lock(&gsi->mutex); - ret = start ? gsi_channel_start_command(channel) : 0; + ret = gsi_channel_start_command(channel); mutex_unlock(&gsi->mutex); - if (ret) { - gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); - napi_disable(&channel->napi); - } - return ret; } @@ -881,8 +876,19 @@ static int __gsi_channel_start(struct gsi_channel *channel, bool start) int gsi_channel_start(struct gsi *gsi, u32 channel_id) { struct gsi_channel *channel = &gsi->channel[channel_id]; + int ret; - return __gsi_channel_start(channel, true); + /* Enable NAPI and the completion interrupt */ + napi_enable(&channel->napi); + gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); + + ret = __gsi_channel_start(channel, true); + if (ret) { + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); + napi_disable(&channel->napi); + } + + return ret; } static int gsi_channel_stop_retry(struct gsi_channel *channel) @@ -907,16 +913,15 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel) static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) { - struct gsi *gsi = channel->gsi; int ret; + /* Wait for any underway transactions to complete before stopping. */ gsi_channel_trans_quiesce(channel); ret = stop ? gsi_channel_stop_retry(channel) : 0; - if (!ret) { - gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); - napi_disable(&channel->napi); - } + /* Finally, ensure NAPI polling has finished. */ + if (!ret) + napi_synchronize(&channel->napi); return ret; } @@ -925,8 +930,17 @@ static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) int gsi_channel_stop(struct gsi *gsi, u32 channel_id) { struct gsi_channel *channel = &gsi->channel[channel_id]; + int ret; - return __gsi_channel_stop(channel, true); + /* Only disable the completion interrupt if stop is successful */ + ret = __gsi_channel_stop(channel, true); + if (ret) + return ret; + + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); + napi_disable(&channel->napi); + + return 0; } /* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */ From patchwork Mon Feb 1 17:28:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12059591 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0774AC433E6 for ; Mon, 1 Feb 2021 17:35:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1A7464EB8 for ; Mon, 1 Feb 2021 17:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbhBAReV (ORCPT ); Mon, 1 Feb 2021 12:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbhBARaV (ORCPT ); Mon, 1 Feb 2021 12:30:21 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F938C0617A9 for ; Mon, 1 Feb 2021 09:29:04 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id e7so16346713ile.7 for ; Mon, 01 Feb 2021 09:29:04 -0800 (PST) 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=j/UQjfNJ3JWNq4bb7HzoAqoUGHmX5hqgPKQzmM+bjDk=; b=VyxQ5araa1L6Gf/nGTnvtNEb6ocPkU/Y50wsclb0mJSkeK1qMaoRhOHqM0A+Nhl+Bl zEmwH1xLfa657LIb5PDviN0SIvKBbiUm7rtUEomovKoXHN4X09i/fEp2YK9a32j7vsnG n2vOZaDlhuc5ewGN9dRXJ2aNR6jcq0dnkGnnVUCdPXlC2bRWy4dUvQBlTOD9XRVHD3zK DUhCrdA3Y+YIkseLTfU8gjBXlINJKmc6PMSSn8zePJTjBpPux7D3L3tZCBVBUpPCGEhR ngmLONTuuo/tcFpa7iOlTWsWmRfGvWvIUsrJ+yZRR+3jOcFmYKfasvu87touskpJC+Jw tMhw== 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=j/UQjfNJ3JWNq4bb7HzoAqoUGHmX5hqgPKQzmM+bjDk=; b=nW3ZVDjANspMuFoIicZsp/Z77ZUCG2Tc5i73k8Jr5Cjav7n9JpwsnCf3V5Ptq5sgHh HrRu0WhGyq/Skp7fSGQiv9PZioHtIooRebqnKSxNF9ovoEAgia8Jj/c0CodMZ0Iytrv5 tHI17IobSxbTXA5bhq8i2akb85gpK2YLTjNtnML74DFBCaUhs2LX8HcenzTVAGVf3p9a yXR55DacTvNWou93UiVdGMxO4/1xSwo6eekHHNg25/0Q8x7mfywfJQuNwOYoG59rGusC r0BAc6KyX6otOdV1m0dUtilTtJnNQy0tYWrVlM3iNqX2gfPtYG9B5VrQ5D9fqcA8gGdb G15A== X-Gm-Message-State: AOAM530acXGWqj19E+5LTbfwG7FE3BApgy5A9Fv6qknF8diXROzx6m4H ODGIR/PiYwyvuLszGC0KeXgDag== X-Google-Smtp-Source: ABdhPJzcfV4LzvkxTVWq5m0CEvBaBwNSEk5coXC14ha+VjgZoJem/21Mcbw/+GCIYOeUZWGVzf+qFQ== X-Received: by 2002:a05:6e02:1d09:: with SMTP id i9mr13862591ila.207.1612200543565; Mon, 01 Feb 2021 09:29:03 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id v2sm9529856ilj.19.2021.02.01.09.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 09:29:02 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 7/7] net: ipa: expand last transaction check Date: Mon, 1 Feb 2021 11:28:50 -0600 Message-Id: <20210201172850.2221624-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210201172850.2221624-1-elder@linaro.org> References: <20210201172850.2221624-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Transactions to send data for a network device can be allocated at any time up until the point the TX queue is stopped. It is possible for ipa_start_xmit() to be called in one context just before a the transmit queue is stopped in another. Update gsi_channel_trans_last() so that for TX channels the allocated and pending transaction lists are checked--in addition to the completed and polled lists--to determine the "last" transaction. This means any transaction that has been allocated before the TX queue is stopped will be allowed to complete before we conclude the channel is quiesced. Rework the function a bit to use a list pointer and gotos. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 03498182ad024..8b64cbe4737a4 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -725,22 +725,38 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id) gsi_evt_ring_doorbell(gsi, evt_ring_id, 0); } -/* Return the last (most recent) transaction completed on a channel. */ +/* Find the transaction whose completion indicates a channel is quiesced */ static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel) { struct gsi_trans_info *trans_info = &channel->trans_info; + const struct list_head *list; struct gsi_trans *trans; spin_lock_bh(&trans_info->spinlock); - if (!list_empty(&trans_info->complete)) - trans = list_last_entry(&trans_info->complete, - struct gsi_trans, links); - else if (!list_empty(&trans_info->polled)) - trans = list_last_entry(&trans_info->polled, - struct gsi_trans, links); - else - trans = NULL; + /* There is a small chance a TX transaction got allocated just + * before we disabled transmits, so check for that. + */ + if (channel->toward_ipa) { + list = &trans_info->alloc; + if (!list_empty(list)) + goto done; + list = &trans_info->pending; + if (!list_empty(list)) + goto done; + } + + /* Otherwise (TX or RX) we want to wait for anything that + * has completed, or has been polled but not released yet. + */ + list = &trans_info->complete; + if (!list_empty(list)) + goto done; + list = &trans_info->polled; + if (list_empty(list)) + list = NULL; +done: + trans = list ? list_last_entry(list, struct gsi_trans, links) : NULL; /* Caller will wait for this, so take a reference */ if (trans)