Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp301769rwb; Fri, 2 Sep 2022 14:33:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7jM0muvcsGwX8FnNU2Wh4Hhxv+11dxeYex+1AAgn8m2oS2CpQ6SWFwvgUw6LZphSx3Psp8 X-Received: by 2002:a17:906:58c8:b0:6fe:91d5:18d2 with SMTP id e8-20020a17090658c800b006fe91d518d2mr29054011ejs.190.1662154392123; Fri, 02 Sep 2022 14:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662154392; cv=none; d=google.com; s=arc-20160816; b=k0aXjfsed5v7DgRuMcJ5IAufHcA8mkuQoDUf3qHjncLqpUIwzMRFOcBS0JaqQAXMpN Ab7v3ru4KQ/LzPz20lQoHVj4xbheKAM79Z5OBx+kcp4OeECJjWh7HhNPth+i+PNNkdde PYQB1G6srYW9SlCT4MhdzJaVJDAn/KrGYAw7lZqOi8yWI6H9z8NN9i88NTS4EkMT2mF5 IFuF1ldZgVnTSKp5kjPPiFLhDa4lg1JnmdcEm6rJnTHECrDNLmvid3o0w3BlbYLvMaC4 QvdjIFhaBCgc+8vN4pdvTUFadaEycLnCG5nGuzPaxs3k3C76SNgsX4vtM/aUqgeDzVj+ OujA== 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=wXtVbgfVAjAnFG+gl8zfcyZNigB/A7fWYjmIjrEWnFw=; b=mQDjnibKaAkEEN9vmHGshKrAVVNUG1K1zFecvQwVVBSujZB10vV0EMnJ75JEqw+aiA Hc/xHyw3dzfr2PHM7shtotBIPE9jqwFT1PhJkoScO8QyE2WdPtdPQG7GYgoXEvs0bx0D M9IpYJtlZFLz/jtWca+pgzBx4wWRbYp3dkWG9ojDeiSBxL3MqXiwWybEmX77t+f6TzVg 8yyE0bpUanB9dVAIvqqwB9JMLOPDGqvyzVS/+8Y1f+sbUPSFYGU7Siw617TD2OVG5HAK EQZGIMO/jJYY7DY+3xTxvuco4Fi7vBA+i2nGxB7V4ALQ01MNdwwMWKXT19xHvuDHylID CqKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tJ5pt1iO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg31-20020a170907a41f00b0072af8809a85si2620736ejc.332.2022.09.02.14.32.46; Fri, 02 Sep 2022 14:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tJ5pt1iO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbiIBVCp (ORCPT + 99 others); Fri, 2 Sep 2022 17:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbiIBVC1 (ORCPT ); Fri, 2 Sep 2022 17:02:27 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51EAB2CFF for ; Fri, 2 Sep 2022 14:02:26 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id r141so2660118iod.4 for ; Fri, 02 Sep 2022 14:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wXtVbgfVAjAnFG+gl8zfcyZNigB/A7fWYjmIjrEWnFw=; b=tJ5pt1iOrDE9HnmuU2z91c5o+GjTXTa8xAjYRYQKVx3qijRfKzjWWMIWGcjqfDgZ2v 0Sodk0RcMNFYfD6MJeZaUzOWwef4lr3T+anFkraj3Y8tKWIH4oMz3f+yMOX+mayO2b6+ owNRcbl8hwj2AQ/8o/gLPXdfcO5rdQbdnMcnF0YnsleKf3S+b6wqixm3f7hIe8OyD+6U xNZgPwXc66i3qahVCbNpAnQezUB0RnSaTm3BrdiP/RNh/9Bkwxk/mzBXefzHNXn4vWDo /aBIzL4jCT0IRBLTv9Qh4PCqdXatpTX+cF6TeJIh67N6OspPedGn34FuS9Qyk/nfOwrS Uw1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wXtVbgfVAjAnFG+gl8zfcyZNigB/A7fWYjmIjrEWnFw=; b=tZCXO+oAyXahfl+QA+p/0/OPjDUeRcu5SDcj0AxWnK0aM96gQAYaiV33XHa4EeyCKW KSpkkpokaytw+JUxqAAKu55LtkBMvU2oNBWRFRZTS4XMJATHRVLfqFkdUewpfZ41+4wW SRVaSzrdPO0ujoGxRtl167ffVO99d6iQpMXNcKVZz2JxLNaPF7VokqO3YtmwF1ibyonI 2sOtGvcJ69ZORUUNNe1rA1310/NdY6x69WKafOiWo7AUydhng7RW+nLCw9U6fNErANuC 8EXdzdpZwmqDmuazHlgV/XFbLxoakRQOGYvVQBD0O1Mu26SmNRgQ7kZAaskSa9df1qmY uBBQ== X-Gm-Message-State: ACgBeo0yxXjD3jmhunoFB3VY1f8QVzsv3PP0RUoPJNdD7NuR1i2AxczW OTWevpwdD0qQOeQbxqKEd0EQQA== X-Received: by 2002:a02:b60d:0:b0:343:5ddd:66b3 with SMTP id h13-20020a02b60d000000b003435ddd66b3mr20698508jam.8.1662152546588; Fri, 02 Sep 2022 14:02:26 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id i7-20020a0566022c8700b00689e718d971sm1259208iow.51.2022.09.02.14.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 14:02:26 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, bjorn.andersson@linaro.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/6] net: ipa: simplify gsi_channel_trans_last() Date: Fri, 2 Sep 2022 16:02:16 -0500 Message-Id: <20220902210218.745873-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902210218.745873-1-elder@linaro.org> References: <20220902210218.745873-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using a little logic we can simplify gsi_channel_trans_last(). The first condition in that function looks like this: if (trans_info->allocated_id != trans_info->free_id) And if that's false, we proceed to the next one: if (trans_info->committed_id != trans_info->allocated_id) Failure of the first test implies: trans_info->allocated_id == trans_info->free_id And therefore, the second one can be rewritten this way: if (trans_info->committed_id != trans_info->free_id) Substituting free_id for allocated_id and committed_id can also be done in the code blocks executed when these conditions yield true. The net result is that all three blocks for TX endpoints can be consolidated into just one. The two blocks of code at the end of that function (used for both TX and RX channels) can be similarly consolidated into a single block. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 0983a11409f2d..841a946bc286a 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -718,46 +718,27 @@ static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel) * before we disabled transmits, so check for that. */ if (channel->toward_ipa) { - /* The last allocated transaction precedes the first free */ - if (trans_info->allocated_id != trans_info->free_id) { + /* The last allocated, committed, or pending transaction + * precedes the first free transaction. + */ + if (trans_info->pending_id != trans_info->free_id) { trans_id = trans_info->free_id - 1; trans_index = trans_id % channel->tre_count; trans = &trans_info->trans[trans_index]; goto done; } - - /* Last committed transaction precedes the first allocated */ - if (trans_info->committed_id != trans_info->allocated_id) { - trans_id = trans_info->allocated_id - 1; - trans_index = trans_id % channel->tre_count; - trans = &trans_info->trans[trans_index]; - goto done; - } - - /* Last pending transaction precedes the first committed */ - if (trans_info->pending_id != trans_info->committed_id) { - trans_id = trans_info->committed_id - 1; - trans_index = trans_id % channel->tre_count; - trans = &trans_info->trans[trans_index]; - goto done; - } } /* Otherwise (TX or RX) we want to wait for anything that * has completed, or has been polled but not released yet. * - * The last pending transaction precedes the first committed. + * The last completed or polled transaction precedes the + * first pending transaction. */ - if (trans_info->completed_id != trans_info->pending_id) { + if (trans_info->polled_id != trans_info->pending_id) { trans_id = trans_info->pending_id - 1; trans_index = trans_id % channel->tre_count; trans = &trans_info->trans[trans_index]; - goto done; - } - if (trans_info->polled_id != trans_info->completed_id) { - trans_id = trans_info->completed_id - 1; - trans_index = trans_id % channel->tre_count; - trans = &trans_info->trans[trans_index]; } else { trans = NULL; } -- 2.34.1