From nobody Mon Apr 27 07:25:33 2026 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 9D2FBCCA480 for ; Wed, 15 Jun 2022 16:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351200AbiFOQ7r (ORCPT ); Wed, 15 Jun 2022 12:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350013AbiFOQ7i (ORCPT ); Wed, 15 Jun 2022 12:59:38 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A742E9E1 for ; Wed, 15 Jun 2022 09:59:34 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id q12-20020a17090a304c00b001e2d4fb0eb4so2685941pjl.4 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=MISzEd39DBvh7VzToOks8qOu3pFErR+8Ny87xV7eYlYHblAXycOI4czTLtv24h8TLh BJYffMlWpP0FGOO1DpRB95iYaYc3PX3I9pxVqWIuyVeMaasO/EL6cvT9Om4+Lbb3yIor 9CQ+Zm31FYgFa+/EDrGhyczs4TSAeTS2MKaTm5fr4XQ99bW79nvVI20tOuNhUAJn5i2G sgbp1LD4kT1ps1aUVIOpk5aZd4L/jJP+NZ4pAYl4AHiKcPBHzJdnURnidDYkhT2VZqrY Fh+8TDbBf5Mgf+GbKVXF8XsoVqnYqOQKlMeWJqfGuqRqEpq9J7hcB0JrDP/fGQ1HsKBs NHkg== X-Gm-Message-State: AJIora9NIl2UmBj8+e5LUZunhohDSvc9VEIk62/PasFa4hHSmeut4289 6kQ+J+xo2C0ooeDFIYGqq9st+Q== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_r= ing *evt_ring, u32 index) { struct gsi_channel *channel =3D evt_ring->channel; struct gsi_ring *ring =3D &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; =20 - trans_info =3D &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_rin= g *evt_ring, u32 index) */ old_index =3D ring->index; event =3D gsi_ring_virt(ring, old_index); - trans =3D gsi_event_trans(channel->gsi, event); - if (!trans) - return; =20 /* 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_ri= ng *evt_ring, u32 index) event_avail =3D ring->count - old_index % ring->count; event_done =3D gsi_ring_virt(ring, index); do { + struct gsi_trans *trans; + + trans =3D gsi_event_trans(channel->gsi, event); + if (!trans) + return; + trans->len =3D __le16_to_cpu(event->len); =20 /* Move on to the next event and transaction */ @@ -1399,7 +1398,6 @@ static void gsi_evt_ring_rx_update(struct gsi_evt_rin= g *evt_ring, u32 index) event++; else event =3D gsi_ring_virt(ring, 0); - trans =3D gsi_trans_pool_next(&trans_info->pool, trans); } while (event !=3D event_done); } =20 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; =20 #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ =20 -/* 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; } =20 -/* 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 =3D pool->base + pool->count * pool->size; - - WARN_ON(element < pool->base); - WARN_ON(element >=3D end); - WARN_ON(pool->max_alloc !=3D 1); - - element +=3D 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) --=20 2.34.1 From nobody Mon Apr 27 07:25:33 2026 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 43F99C43334 for ; Wed, 15 Jun 2022 16:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355365AbiFOQ7u (ORCPT ); Wed, 15 Jun 2022 12:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351361AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE3A340DD for ; Wed, 15 Jun 2022 09:59:35 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id e66so11901536pgc.8 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=0dky8qsRa1qUzNvs0KSG8U31j6sCaE848nmtF7ezDsLNvCfOP//KLHBSbpQkAFh9NZ Znl0CoJ5Z+AcWTn4TIq0i8Uf4I329De/bbgW5bJW7C4gsgjlUTBGXDij4cOatoG4GWif BfdIxioumckMAqN1TKMMnvOLjzHMP5nUoHUJRfHSNB5iVor7HX56LCWrU2z9uyAkW6Ya IP2oV1S+/yzVqCvLmQ7ah9U4yPKaabM6Vk/ml6/i1B+hU08kOJ9ATf0foVAOQgsImStC X+V6uRE/L79Y7QAFKqIFY8n7VZe7NkeCdqnCFalLEkKapf+n3RePR6tpRyel6pVnSokq mL5g== X-Gm-Message-State: AJIora9MyWMndwRIi7OprpibtaEdVU5OlD/8mrhI7EB18fGBwJAWXJr/ xtfAGTBoeYCDhuklv1mpmaC0AQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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; } =20 -/* 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 =3D &trans->gsi->channel[trans->channel_id]; + + /* The completion event will indicate the last TRE used */ + index +=3D trans->used_count - 1; + /* Note: index *must* be used modulo the ring count here */ channel->trans_info.map[index % channel->tre_ring.count] =3D trans; } @@ -568,15 +572,15 @@ static void __gsi_trans_commit(struct gsi_trans *tran= s, 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 +=3D trans->used_count; =20 trans->len =3D byte_count; if (channel->toward_ipa) gsi_trans_tx_committed(trans); =20 - /* Associate the last TRE with the transaction */ - gsi_channel_trans_map(channel, tre_ring->index - 1, trans); - gsi_trans_move_pending(trans); =20 /* Ring doorbell if requested, or if all TREs are allocated */ --=20 2.34.1 From nobody Mon Apr 27 07:25:33 2026 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 5D271C43334 for ; Wed, 15 Jun 2022 16:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355042AbiFOQ7y (ORCPT ); Wed, 15 Jun 2022 12:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352835AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB163818A for ; Wed, 15 Jun 2022 09:59:37 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id q140so11916514pgq.6 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=Fau5lU50D6l+siR8IQYOuD840iYihnbP5U/CFKxag5ZF3OdlSaRgS1zmvlgdTCTSz+ +K/lSTwOpqE0zx0wZwNS7Q1V+rAhkmUjDLUZbmnFTWfKs0VXla5Y1Q+ONIx+Q6yOYysM DB5BGMrrfvOLUFSWDpUkXE7r7BSUuAqns3lOcgqkpB+horFcrGvijfXqj9qVjRpsBd54 9mLH77OD04tI7j8ZyAIGeIiDStQuIH7ivEgLWZ1Pix7VFQlsONrw8xAkzWUzwbR1HL3d hJ2RJU757b+O2FPIWvBP8IriBJBXsx3DhmzoNwPxoVJNsYbaeW8wBYKok3nLK7rKfmQz W8PQ== X-Gm-Message-State: AJIora9WkG9wEtr0B4KcZ2aEW6XCBneSJx7qakVucqcSPsU9LxtXDR9i XTDOd1GV6fi3KWStMy/WSgHMPg== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 *ev= ent) =20 /** * 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 *ev= ent) * * 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 inde= x) +static void gsi_evt_ring_rx_update(struct gsi *gsi, u32 evt_ring_id, u32 i= ndex) { - struct gsi_channel *channel =3D evt_ring->channel; + struct gsi_evt_ring *evt_ring =3D &gsi->evt_ring[evt_ring_id]; struct gsi_ring *ring =3D &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_rin= g *evt_ring, u32 index) do { struct gsi_trans *trans; =20 - trans =3D gsi_event_trans(channel->gsi, event); + trans =3D gsi_event_trans(gsi, event); if (!trans) return; =20 @@ -1500,7 +1501,7 @@ static struct gsi_trans *gsi_channel_update(struct gs= i_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); =20 gsi_trans_move_complete(trans); =20 --=20 2.34.1 From nobody Mon Apr 27 07:25:33 2026 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 0C5FEC433EF for ; Wed, 15 Jun 2022 17:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356594AbiFORAD (ORCPT ); Wed, 15 Jun 2022 13:00:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349972AbiFOQ7j (ORCPT ); Wed, 15 Jun 2022 12:59:39 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443083A5EE for ; Wed, 15 Jun 2022 09:59:38 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id u18so10936829plb.3 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=nKjvJM5X0MqEYn3wD5Gp7cq0W9akgSPdPlgVGCCaCYMitjzDpim7aOoANeR7XGiOtU 6KahVXvLS636Fa8tncjX9c62RBT1eRn04QmsF8q6bHrsBtYnKoJJB2XDR1tGi6ffWB34 UL4pO66JQcrM0hNEz6NqscQBLnOyGfnxxtpoJY6EZ+5eXhCGd8BcXVOc6POWGY5tM92z c7w/pzCB8G8bmykhCKIvBkcNRTfClA5p6lU2w/YAr0zuH6eCIErWDrm4Qf1xSLjBZnx0 lz+jym0X6LS2K1YskPAd4XFje5HTe9nUWqZdmnFl2p/R25L03RA4rI15X3dR9/2Nj20t e2ZA== X-Gm-Message-State: AJIora8p8W9zvw3VzmwdeKWVxWnQ6WJbF+ekqIEEJsJ+DsM8yW9/60mx u7icuk/zHmqVgUF/GH2Lx83U8g== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, u= 32 evt_ring_id, u32 index) if (!trans) return; =20 - trans->len =3D __le16_to_cpu(event->len); + if (trans->direction =3D=3D DMA_FROM_DEVICE) + trans->len =3D __le16_to_cpu(event->len); =20 /* Move on to the next event and transaction */ if (--event_avail) @@ -1500,8 +1501,7 @@ static struct gsi_trans *gsi_channel_update(struct gs= i_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); =20 gsi_trans_move_complete(trans); =20 --=20 2.34.1 From nobody Mon Apr 27 07:25:33 2026 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 F3A3BC43334 for ; Wed, 15 Jun 2022 16:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356219AbiFOQ75 (ORCPT ); Wed, 15 Jun 2022 12:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353898AbiFOQ7k (ORCPT ); Wed, 15 Jun 2022 12:59:40 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B9D2E084 for ; Wed, 15 Jun 2022 09:59:39 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id y196so11978214pfb.6 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=rY5cl20qVzjkRvzFRPakZUiBdGiFrb0SRmn1SWrRnfgfEZ+KLDFIn7hh0HiTC0L06n RHQ8t+YxTHus8LM4WBB+AVHMDW2UjMShOKsA2Z8+4+kkgDhxITvD5r/7pxKhbhNy4DK2 RShWYGeb/Ve4iGVdgE3nWSskOGrttGDgvPMq50nkbF4f3fuopMn9fbIelWzaLj/o9DYL 5IDRoQvw3J1Fpbp6mWZ6TKyBvfp9wBte0rXCYe1WiQWk8j1WfQdrMr4GyFnyUrgJYGuS fKNsRfM5kbGE9Jqo8AQcLDxMhqYJAq4Nm8EnlozPG3OAgcrBSloFpyeXvJbCLa7tR5eH 6M8w== X-Gm-Message-State: AJIora9z8NlAl6iIpe3BVHleGY8mt1pRLXFIHiPkihwWFIhji9VA8Kdx MGQVvZWomN+nV2jR5GjRTT4rdA== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 *ev= ent) } =20 /** - * 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 *e= vent) * 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 fil= led * 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 *ev= ent) * * 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 i= ndex) +static void gsi_evt_ring_update(struct gsi *gsi, u32 evt_ring_id, u32 inde= x) { struct gsi_evt_ring *evt_ring =3D &gsi->evt_ring[evt_ring_id]; struct gsi_ring *ring =3D &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; =20 - /* 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 =3D ring->index; event =3D 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) =20 if (trans->direction =3D=3D DMA_FROM_DEVICE) trans->len =3D __le16_to_cpu(event->len); + else + gsi_trans_tx_completed(trans); + + gsi_trans_move_complete(trans); =20 /* 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, u= 32 evt_ring_id, u32 index) else event =3D gsi_ring_virt(ring, 0); } while (event !=3D event_done); + + /* Tell the hardware we've handled these events */ + gsi_evt_ring_doorbell(gsi, evt_ring_id, index); } =20 /* Initialize a ring, including allocating DMA memory for its entries */ @@ -1499,14 +1512,7 @@ static struct gsi_trans *gsi_channel_update(struct g= si_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); =20 return gsi_channel_trans_complete(channel); } --=20 2.34.1