From patchwork Wed Jun 15 16:59:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 582318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B6DC433EF for ; Wed, 15 Jun 2022 16:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349993AbiFOQ7k (ORCPT ); Wed, 15 Jun 2022 12:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350002AbiFOQ7i (ORCPT ); Wed, 15 Jun 2022 12:59:38 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 927C92E9DF for ; Wed, 15 Jun 2022 09:59:34 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id v11-20020a17090a4ecb00b001e2c5b837ccso2687688pjl.3 for ; Wed, 15 Jun 2022 09:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rpIVO5Kfmx2LoU227Q0lbW/FLezMOp+ICqcp8J2B6FI=; b=MZpYEqAM/KX+Nu/O0mwQPCl2GJDQG3BQQBIWo9GaDMMfvVfCJGL0yTeCPiq6izrFor CLalTVjKv5Om+Cux+Qz7lkVbo11fce/QEbQgl6yrV3kM9xpUTvIC97MEWVhPJNmkx4ek kYzMko73AHKQlsafOON8jgXe47eiuTBrgT2N+lLMWYzOg6QvB/nJeo/zuZNlti9vCp8O TasXSMtCNQppiXD8b+sRBIKGg5m8MhLLlDxeN113kjn8sb4bcyfWdYmIG4Yh5wzG+3mZ vqrsHrJNvdQSYy/7vLm+m89jH3MfBWZKrbtU0WA3P4YNxenrKmwd4KLX6X/unKSD4LQr VTeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rpIVO5Kfmx2LoU227Q0lbW/FLezMOp+ICqcp8J2B6FI=; b=6FCYd93X039YFdPrm5WtLm7HI2eVKgMxSxsna/tKdzgJyegvw9Q00z9u+sYGm4YdKB xgRA0BLAJkTADa1lneKWR/nskrLFi3l98eSqQm5AGVmhO9yJOUuq9gMJB1i/X3rsU8oa FhZoaEBqR8kGr+5KpxLvhNrTaA8Fs0WO8ysJAIIJ/1NaFKJWuDF55hTJ9eA2g7WDEAxl ru9c/M20TqljhREoMkPVokz4uWVW8pMRkjZqMuAV19HWhCZ7WENVA2M6dYm3d26lwYLR uigBOtU88eyT79LgpY4vFyg9yt7OFFgWjTAsKgDFpxl1hzruFLoy6M4tdVK4Z3nu7aUl xOvg== X-Gm-Message-State: AJIora/LaLtYK8fCvD9F+t2mmSZLVejZwVd/y/lSFJnt++rmbIJh8opz h+7t3qDZofjK8CQBzTuijW9gqw== X-Google-Smtp-Source: AGRyM1ufbWyrUR7cMW1ED5blXTBvzX2GdcvoY3l2cczUqBWYxE8jz8arVAs7v/PQtOd+NX0fEFbhxQ== X-Received: by 2002:a17:902:f541:b0:163:f64a:6127 with SMTP id h1-20020a170902f54100b00163f64a6127mr596561plf.134.1655312374000; Wed, 15 Jun 2022 09:59:34 -0700 (PDT) Received: from localhost.localdomain ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id s194-20020a6377cb000000b003fd1111d73csm10618513pgc.4.2022.06.15.09.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:59:33 -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 1/5] net: ipa: don't assume one channel per event ring Date: Wed, 15 Jun 2022 11:59:25 -0500 Message-Id: <20220615165929.5924-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615165929.5924-1-elder@linaro.org> References: <20220615165929.5924-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In gsi_evt_ring_rx_update(), use gsi_event_trans() repeatedly to find the transaction associated with an event, rather than assuming consecutive events are associated with the same channel. This removes the only caller of gsi_trans_pool_next(), so get rid of it. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 14 ++++++-------- drivers/net/ipa/gsi_private.h | 3 --- drivers/net/ipa/gsi_trans.c | 16 ---------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index df8af1f00fc8b..0e9064c043adf 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1366,15 +1366,11 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) { struct gsi_channel *channel = evt_ring->channel; struct gsi_ring *ring = &evt_ring->ring; - struct gsi_trans_info *trans_info; struct gsi_event *event_done; struct gsi_event *event; - struct gsi_trans *trans; u32 event_avail; u32 old_index; - trans_info = &channel->trans_info; - /* We'll start with the oldest un-processed event. RX channels * replenish receive buffers in single-TRE transactions, so we * can just map that event to its transaction. Transactions @@ -1382,9 +1378,6 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) */ old_index = ring->index; event = gsi_ring_virt(ring, old_index); - trans = gsi_event_trans(channel->gsi, event); - if (!trans) - return; /* Compute the number of events to process before we wrap, * and determine when we'll be done processing events. @@ -1392,6 +1385,12 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) event_avail = ring->count - old_index % ring->count; event_done = gsi_ring_virt(ring, index); do { + struct gsi_trans *trans; + + trans = gsi_event_trans(channel->gsi, event); + if (!trans) + return; + trans->len = __le16_to_cpu(event->len); /* Move on to the next event and transaction */ @@ -1399,7 +1398,6 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) event++; else event = gsi_ring_virt(ring, 0); - trans = gsi_trans_pool_next(&trans_info->pool, trans); } while (event != event_done); } diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index 74cbc287fc715..0b2516fa21b5d 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -16,9 +16,6 @@ struct gsi_channel; #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ -/* Return the entry that follows one provided in a transaction pool */ -void *gsi_trans_pool_next(struct gsi_trans_pool *pool, void *element); - /** * gsi_trans_move_complete() - Mark a GSI transaction completed * @trans: Transaction to commit diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index a110be72f70b6..54a2400cb560e 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -214,22 +214,6 @@ void *gsi_trans_pool_alloc_dma(struct gsi_trans_pool *pool, dma_addr_t *addr) return pool->base + offset; } -/* Return the pool element that immediately follows the one given. - * This only works done if elements are allocated one at a time. - */ -void *gsi_trans_pool_next(struct gsi_trans_pool *pool, void *element) -{ - void *end = pool->base + pool->count * pool->size; - - WARN_ON(element < pool->base); - WARN_ON(element >= end); - WARN_ON(pool->max_alloc != 1); - - element += pool->size; - - return element < end ? element : pool->base; -} - /* Map a given ring entry index to the transaction associated with it */ static void gsi_channel_trans_map(struct gsi_channel *channel, u32 index, struct gsi_trans *trans) From patchwork Wed Jun 15 16:59:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 582316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B647ACCA47F for ; Wed, 15 Jun 2022 16:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350965AbiFOQ7s (ORCPT ); Wed, 15 Jun 2022 12:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351500AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E4333EA6 for ; Wed, 15 Jun 2022 09:59:35 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id s37so9297017pfg.11 for ; Wed, 15 Jun 2022 09:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v6dWtN6JS61iJPZCoy25a1Ek81mQCcvRmSG+rHnd6IM=; b=Jq50bywAEAIc9z9c0NiXsJMlHs054omA+BzgwjRtP7uWKt5yDKdix5WgOkrjfxBzco i7D7SvwPnwuXZwooDA0MobkQ22sh60FKpnhOq+iJETcWOv6EmoT2fN2alyh0Nk2ECE73 9ZCWJV+H7XVtHBNdd0UHAzF0Wj/pz1wBmJpfYJOXf3VlfTJvKobzlLvSCXllsdDdC4VJ G0HomL9ahay9JRaVZfTuqnQXsclwWcktSjCgIlIGZSIv88mZhz2tCmLmYdAjmciMLRo5 SkenroUSWzV3NS+Qg9WCdKsIRlTjoP7YUFxLXSHXpN+Yi67vBFl6ijmvANN9sWRqyjTd 2L0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v6dWtN6JS61iJPZCoy25a1Ek81mQCcvRmSG+rHnd6IM=; b=nMzHo2Q76tZePZDnIgisgxzaLhzTnaEwIa7x/nURDRnSLXO2XJTwaFXcU19XHa7ECG XgDsxlbfz6Hjl+/fW8NMmc2/7Mm+xs29WIcZxGB/5GlqJuz08yIYUzzlPuKyGPdrrqQ9 /Dk7HWiOrptTO5zQiXA+MUuwclnu7yVaQGFO14HhacqvGuw1ACcTJkbrEGfmqMcM0pci gp1X1W0WgrEJPqOYkP5Y3FG19qTVNhxhS9T1iopiz3ahEM/Ff6EhQEXNPV/TD6wUYvz8 s4b7ovF/a91+nlUIw2llg4dWVKhzCERYdEl0ZrqoD7DrVYGeEg2XsjZqxpT6Vxz3XNFS QpaA== X-Gm-Message-State: AJIora8TyBLy/s/eGbh7ajsk6CS9cRveWRrX0Jz3gKQCg83cqG4LOOxT QFFbGIgoRyYJhBk/1TfagT3gRQ== X-Google-Smtp-Source: AGRyM1sOuPiCrNsH9UB2zWAkGK6dCRv6+fmJT7YepeQkAYQHA+7UBn+6UMUP45kiSulxxF7jRNAV7g== X-Received: by 2002:a05:6a00:170b:b0:51b:cf4b:9187 with SMTP id h11-20020a056a00170b00b0051bcf4b9187mr539797pfc.15.1655312375308; Wed, 15 Jun 2022 09:59:35 -0700 (PDT) Received: from localhost.localdomain ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id s194-20020a6377cb000000b003fd1111d73csm10618513pgc.4.2022.06.15.09.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:59:35 -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 2/5] net: ipa: don't pass channel when mapping transaction Date: Wed, 15 Jun 2022 11:59:26 -0500 Message-Id: <20220615165929.5924-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615165929.5924-1-elder@linaro.org> References: <20220615165929.5924-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Change gsi_channel_trans_map() so it derives the channel used from the transaction. Pass the index of the *first* TRE used by the transaction, and have the called function account for the fact that the last one used is what's important. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi_trans.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 54a2400cb560e..cf646dc8e36a3 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -214,10 +214,14 @@ void *gsi_trans_pool_alloc_dma(struct gsi_trans_pool *pool, dma_addr_t *addr) return pool->base + offset; } -/* Map a given ring entry index to the transaction associated with it */ -static void gsi_channel_trans_map(struct gsi_channel *channel, u32 index, - struct gsi_trans *trans) +/* Map a TRE ring entry index to the transaction it is associated with */ +static void gsi_trans_map(struct gsi_trans *trans, u32 index) { + struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id]; + + /* The completion event will indicate the last TRE used */ + index += trans->used_count - 1; + /* Note: index *must* be used modulo the ring count here */ channel->trans_info.map[index % channel->tre_ring.count] = trans; } @@ -568,15 +572,15 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db) gsi_trans_tre_fill(dest_tre, addr, len, last_tre, bei, opcode); dest_tre++; } + /* Associate the TRE with the transaction */ + gsi_trans_map(trans, tre_ring->index); + tre_ring->index += trans->used_count; trans->len = byte_count; if (channel->toward_ipa) gsi_trans_tx_committed(trans); - /* Associate the last TRE with the transaction */ - gsi_channel_trans_map(channel, tre_ring->index - 1, trans); - gsi_trans_move_pending(trans); /* Ring doorbell if requested, or if all TREs are allocated */ From patchwork Wed Jun 15 16:59:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 581991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F98C43334 for ; Wed, 15 Jun 2022 16:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349940AbiFOQ7q (ORCPT ); Wed, 15 Jun 2022 12:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352214AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A4F377EE for ; Wed, 15 Jun 2022 09:59:37 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id s135so11895959pgs.10 for ; Wed, 15 Jun 2022 09:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lZ2eXkpiTB+9jl0HokhuJqpkh8lZk8zY1cp/z4xtYvI=; b=l9Mpq1W0KjZEmbKPUv1rBTxHL0HBBVf0Ns4SFqtn+/mkDhfYR3K6V/purrC8pPC9CS mpnA06nBuCh6seBBgPNsh+Qvuqk9NLynCVDJtgyvqsr6sBOR9viD0SiIloyJa/teuDGm ruZ25bQoLZLuy0apE5H9S3KQ+mZQGzUsZ5BM5aDj1u7yC88Uw1BAApBnq7ww8MNuB1Pv PM/n8C4aiZqgKW1Vhlq52Xtpee2XT3iP3GkQWaMmwN7sdNXWChlfTCBmYTIHTNGEECYP Rbe/8p5s2h6K3AtVYTbVYTeNp8nfXX8nksU9uz9A5ZkRPd7dMV4C7yuPpl9Jp+jQJBTL j6Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lZ2eXkpiTB+9jl0HokhuJqpkh8lZk8zY1cp/z4xtYvI=; b=EedtRJMMM/WqeyyJ8HflgQ9NomSKlgnKtVeW+x9gXuuGcYISCTxvkvhySeywKNK757 tLBTcErU7k6zy2NCbnNyy0BeuXm2uoDhq856umm8OFgDkzPOHZ3ke++yzb2bISxm9PrY D+6XtPTq1MiKv4LURQlAniWO5u40yvkDdHfOTMog+ivMwnBy8TkiV1TwbcGCFg/AEVoS lyVP6eZN7Ct/ckuD90bAtsLmYaZLApvJzewo319mdXvofGMxJ3WPF5S/iFYM1lHf6QBV eMEJCCYF0dp1yOqZMy5dTNC1aFt9h62c0NPauiYJLkzeGwVv3PU0g22dRdqXL7Xttipg ZgmQ== X-Gm-Message-State: AJIora+pdgIRxMdiWJnqpeCiNvvcBi2wfDxaCc5eKoiOFAOqqXCpX8Wo sIZoaNpRLnyQr/3LcKQ4j1AsJw== X-Google-Smtp-Source: AGRyM1scPWmtV+ed1tWRQRcdPCDvfos5dt6Mby8svxYYWHAdYffmpN6MfVa9W5JNzydMdtkhEbHFUg== X-Received: by 2002:aa7:85d1:0:b0:51b:f4b5:db7b with SMTP id z17-20020aa785d1000000b0051bf4b5db7bmr512545pfn.41.1655312376492; Wed, 15 Jun 2022 09:59:36 -0700 (PDT) Received: from localhost.localdomain ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id s194-20020a6377cb000000b003fd1111d73csm10618513pgc.4.2022.06.15.09.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:59:36 -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 3/5] net: ipa: pass GSI pointer to gsi_evt_ring_rx_update() Date: Wed, 15 Jun 2022 11:59:27 -0500 Message-Id: <20220615165929.5924-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615165929.5924-1-elder@linaro.org> References: <20220615165929.5924-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The only reason the event ring's channel pointer is needed in gsi_evt_ring_rx_update() is so we can get at its GSI pointer. We can pass the GSI pointer as an argument, along with the event ring ID, and thereby avoid using the event ring channel pointer. This is another step toward no longer assuming an event ring services a single channel. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 0e9064c043adf..2c531ba1af2eb 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1345,8 +1345,9 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event) /** * gsi_evt_ring_rx_update() - Record lengths of received data - * @evt_ring: Event ring associated with channel that received packets - * @index: Event index in ring reported by hardware + * @gsi: GSI pointer + * @evt_ring_id: Event ring ID + * @index: Event index in ring reported by hardware * * Events for RX channels contain the actual number of bytes received into * the buffer. Every event has a transaction associated with it, and here @@ -1362,9 +1363,9 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event) * * Note that @index always refers to an element *within* the event ring. */ -static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) +static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) { - struct gsi_channel *channel = evt_ring->channel; + struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; struct gsi_ring *ring = &evt_ring->ring; struct gsi_event *event_done; struct gsi_event *event; @@ -1387,7 +1388,7 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_ring *evt_ring, u32 index) do { struct gsi_trans *trans; - trans = gsi_event_trans(channel->gsi, event); + trans = gsi_event_trans(gsi, event); if (!trans) return; @@ -1500,7 +1501,7 @@ static struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) if (channel->toward_ipa) gsi_trans_tx_completed(trans); else - gsi_evt_ring_rx_update(evt_ring, index); + gsi_evt_ring_rx_update(gsi, evt_ring_id, index); gsi_trans_move_complete(trans); From patchwork Wed Jun 15 16:59:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 582317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2EE9CCA47B for ; Wed, 15 Jun 2022 16:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354617AbiFOQ7p (ORCPT ); Wed, 15 Jun 2022 12:59:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349940AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD223A18E for ; Wed, 15 Jun 2022 09:59:38 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id k7so1563841plg.7 for ; Wed, 15 Jun 2022 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lXZFWdvOk+2G/828a0TSiVe4aud+DVakeFtxO/uHdck=; b=iv9xOEKfWjO+xONkID0kePbuHV8InQ7gwM9b2L6wEsEAJDtAltt/yo5Ws+yfSnBH4a Tx5BI4uXgSoikFpYmd+/rlOKS+6d5OSaXbMs2rhkPyPuta1xuakCFAU7IMqqeCfawnxY IibDIacKW9lS21Z5j/smVrdGzO4zKnKEWL8iNODcFpt6YYdf+u6iGwL0n5kOKWgGt7jJ CVDQItfDAdPeuI6dEiYk9LgyIg6MA687AvuXPvMRxaP+ACf5fSA0bZY0cQBXVJikwdZb d60hetq7XnXu3DV088QniY/W8QC6tfG7rlLR2M3WklRjSXdT1trRLqx/UK9eFIMld2u3 qilQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lXZFWdvOk+2G/828a0TSiVe4aud+DVakeFtxO/uHdck=; b=HLxqftamw7SE+DV85QqAPdcHLrHFcI0BzMmlr33q26jUiJNuCVKjdw1wibCM1ahFjQ k9yq2AxTtlleh6bICys1ATlNir4e2EDDjote1R+rdqKzzo5900Y9NQ3mMRBSaf72PCP7 PQQ7UCczKKqKMGF7TsS2yrpWXJ3goQg+w6TXA0slyNG7/CK1JsLe8xXVjuLTToOJ7JgU 4GoMz5O+xl9Ndt8165dEe7SJYtdipDD2jKT+KbLmm8CZ74QziNS9x8wBWQ8Zeh9Mlt+t 4Jpf1JgtoMBS3cmtRq2Wzcc/sS4vmIEu/epI1QnTrukuCxh/hI8gIgB1krzNIbX79IX3 +AuQ== X-Gm-Message-State: AJIora8PCbE94hCJPrp+VAyDF40bDELSSKHBdq8tMbFeMbXus7zDpVz8 ImBznjp1BU1uFqrOfim/VDdWRQ== X-Google-Smtp-Source: AGRyM1sI7sKoQ1ZvnChZzUwkd27mhnK2tSWLsUJUYldrc8MkKz37gZmFvHKbc4iJQj/6nrYl9a3AjA== X-Received: by 2002:a17:90b:3a87:b0:1e8:789d:c60 with SMTP id om7-20020a17090b3a8700b001e8789d0c60mr388274pjb.77.1655312377639; Wed, 15 Jun 2022 09:59:37 -0700 (PDT) Received: from localhost.localdomain ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id s194-20020a6377cb000000b003fd1111d73csm10618513pgc.4.2022.06.15.09.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:59:37 -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/5] net: ipa: call gsi_evt_ring_rx_update() unconditionally Date: Wed, 15 Jun 2022 11:59:28 -0500 Message-Id: <20220615165929.5924-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615165929.5924-1-elder@linaro.org> References: <20220615165929.5924-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org When an RX transaction completes, we update the trans->len field to contain the actual number of bytes received. This is done in a loop in gsi_evt_ring_rx_update(). Change that function so it checks the data transfer direction recorded in the transaction, and only updates trans->len for RX transfers. Then call it unconditionally. This means events for TX endpoints will run through the loop without otherwise doing anything, but this will change shortly. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 2c531ba1af2eb..d08f3e73d51fc 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1392,7 +1392,8 @@ static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) if (!trans) return; - trans->len = __le16_to_cpu(event->len); + if (trans->direction == DMA_FROM_DEVICE) + trans->len = __le16_to_cpu(event->len); /* Move on to the next event and transaction */ if (--event_avail) @@ -1500,8 +1501,7 @@ static struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) */ if (channel->toward_ipa) gsi_trans_tx_completed(trans); - else - gsi_evt_ring_rx_update(gsi, evt_ring_id, index); + gsi_evt_ring_rx_update(gsi, evt_ring_id, index); gsi_trans_move_complete(trans); From patchwork Wed Jun 15 16:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 581992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83670C433EF for ; Wed, 15 Jun 2022 16:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349990AbiFOQ7n (ORCPT ); Wed, 15 Jun 2022 12:59:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350033AbiFOQ7k (ORCPT ); Wed, 15 Jun 2022 12:59:40 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 983962E0A9 for ; Wed, 15 Jun 2022 09:59:39 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id 187so11966279pfu.9 for ; Wed, 15 Jun 2022 09:59: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=yR38ccdgKnrRjCuDMGRCE5StIBkp839XVZD0RSnVzf0=; b=mZ1yiu1IsEYQaQrG5j1bdIMF5bbDREHPevOeyc9afs1CwmgonhuFmXsEpg4vOeAoSq CrNh0td8hESqycp8HYBKyyngs6nnWGF0S+idzEirlllrqh2xXLt4DQ7femi9mtzOrPjo 0nr65KZRfv3gnnycRkG7whM7CXy940pf6ziwUOqCvhUcycJfXl7e5iMzPpycMXE2E4ch 7aQibgDpWn0faHZXH8AZ8S/bbqHhI+KQB1PoNwGuZfgVhwRRkaSGiCG4jyDwzFJtcIbL ZnbWlg2aszRV9Fdmj6kerAK78BxXbl/wFX1x8Hprd86ihXM9Lhmyv9a9DFC89fLoqxMb lT1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yR38ccdgKnrRjCuDMGRCE5StIBkp839XVZD0RSnVzf0=; b=sVAARZDiONikI0rbiMbXh1ycmE02Qmm0C2MBVRAPLhXL6hDoo4hC5TekTRIox39Cdn jWAc57K08QoM1EjZvSEpNVl0sHFuCYEuJ0yElLJXwzzhau2xy4+DGuwgVQMnAL9ut1mU E2yzDO33oWZRrwPd9ZgB52I7JoBgjqEGMp5/CWDR+5jPhvEKZnpe90zXOZQdHULCIG6l qqqr1SmaHCevpKwv39kqmPNVURRFdFxh5PfS+334LZ1drYBB75FitQ4oXAAICLTd2yWW BQBnoYb80Tr7dx1Uio9/muT0ET2jkmmYqXxOU3Ngs1FnnLFbi5msL+TvYQHhb1jek0Eq SsbA== X-Gm-Message-State: AJIora/7ceRK3SAaqMjJe1S1Oi06QAE8L/Cp9+4vznKOr7IgvmvR4HNB b77Ve2wrsjpo8/5KzUQVu8TjnQ== X-Google-Smtp-Source: AGRyM1tieMSlqX6r3NjvN0HfQkohWMO5hBXzzB79TBsSneWc0a35yqQgGYx+GpFcZK/sqhz8LqrfcQ== X-Received: by 2002:aa7:98cd:0:b0:520:5200:1c07 with SMTP id e13-20020aa798cd000000b0052052001c07mr518649pfm.13.1655312378945; Wed, 15 Jun 2022 09:59:38 -0700 (PDT) Received: from localhost.localdomain ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id s194-20020a6377cb000000b003fd1111d73csm10618513pgc.4.2022.06.15.09.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:59:38 -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 5/5] net: ipa: move more code out of gsi_channel_update() Date: Wed, 15 Jun 2022 11:59:29 -0500 Message-Id: <20220615165929.5924-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615165929.5924-1-elder@linaro.org> References: <20220615165929.5924-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move the processing done for TX channels in gsi_channel_update() into gsi_evt_ring_rx_update(). The called function is called for both RX and TX channels, so rename it to be gsi_evt_ring_update(). As a result, this code no longer assumes events in an event ring are associated with just one channel. Because all events in a ring are handled in that function, we can move the call to gsi_trans_move_complete() there, and can ring the event ring doorbell there as well after all new events in the ring have been processed. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index d08f3e73d51fc..4e46974a69ecd 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1344,7 +1344,7 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event) } /** - * gsi_evt_ring_rx_update() - Record lengths of received data + * gsi_evt_ring_update() - Update transaction state from hardware * @gsi: GSI pointer * @evt_ring_id: Event ring ID * @index: Event index in ring reported by hardware @@ -1353,6 +1353,10 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event) * the buffer. Every event has a transaction associated with it, and here * we update transactions to record their actual received lengths. * + * When an event for a TX channel arrives we use information in the + * transaction to report the number of requests and bytes have been + * transferred. + * * This function is called whenever we learn that the GSI hardware has filled * new events since the last time we checked. The ring's index field tells * the first entry in need of processing. The index provided is the @@ -1363,7 +1367,7 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event) * * Note that @index always refers to an element *within* the event ring. */ -static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) +static void gsi_evt_ring_update(struct gsi *gsi, u32 evt_ring_id, u32 index) { struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; struct gsi_ring *ring = &evt_ring->ring; @@ -1372,10 +1376,12 @@ static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) u32 event_avail; u32 old_index; - /* We'll start with the oldest un-processed event. RX channels - * replenish receive buffers in single-TRE transactions, so we - * can just map that event to its transaction. Transactions - * associated with completion events are consecutive. + /* Starting with the oldest un-processed event, determine which + * transaction (and which channel) is associated with the event. + * For RX channels, update each completed transaction with the + * number of bytes that were actually received. For TX channels + * associated with a network device, report to the network stack + * the number of transfers and bytes this completion represents. */ old_index = ring->index; event = gsi_ring_virt(ring, old_index); @@ -1394,6 +1400,10 @@ static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) if (trans->direction == DMA_FROM_DEVICE) trans->len = __le16_to_cpu(event->len); + else + gsi_trans_tx_completed(trans); + + gsi_trans_move_complete(trans); /* Move on to the next event and transaction */ if (--event_avail) @@ -1401,6 +1411,9 @@ static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 index) else event = gsi_ring_virt(ring, 0); } while (event != event_done); + + /* Tell the hardware we've handled these events */ + gsi_evt_ring_doorbell(gsi, evt_ring_id, index); } /* Initialize a ring, including allocating DMA memory for its entries */ @@ -1499,14 +1512,7 @@ static struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) * the number of transactions and bytes this completion represents * up the network stack. */ - if (channel->toward_ipa) - gsi_trans_tx_completed(trans); - gsi_evt_ring_rx_update(gsi, evt_ring_id, index); - - gsi_trans_move_complete(trans); - - /* Tell the hardware we've handled these events */ - gsi_evt_ring_doorbell(gsi, evt_ring_id, index); + gsi_evt_ring_update(gsi, evt_ring_id, index); return gsi_channel_trans_complete(channel); }