From nobody Mon Apr 27 16:13:01 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 AAEEFC433EF for ; Fri, 10 Jun 2022 15:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347504AbiFJPqi (ORCPT ); Fri, 10 Jun 2022 11:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344073AbiFJPqW (ORCPT ); Fri, 10 Jun 2022 11:46:22 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E636C3B3F5 for ; Fri, 10 Jun 2022 08:46:20 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id z11so2395978ilq.6 for ; Fri, 10 Jun 2022 08:46:20 -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=43meA/r92kh0CxM1YdpORf+ubVh2S9/XYnxfpi31kfI=; b=Y7aJA8Yu5+r6p/HHzNqOJL2V6fzXWk433pPrrfOP6oOLjCkTIMnXJ5AChT/9UT1HOB hkVgzRT3Fe8YfVrBEVygkxI7UDvNGymbaEtTR7/V3y5rczFrZQmiT4K4mJ5/RDW3m8uI Q5pQvJewBcYF88lskqYgToICp+wx+BbyEi0T7Tyrk+5SAi0HsmEQLm/qZh0b3EfB/mha MXaL5WhWWEYe/FQkeVQ+kCR2LJ0abETtBTyN6yrImyztuGRev2bYgRmYounZKVteEV8P EZDPjL2xpLyrIwY8o9FcwKy4giVzyyaeRQIkrG0gZyBgJN7OERBdpFGpOLOAmXDCBJGw SNzQ== 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=43meA/r92kh0CxM1YdpORf+ubVh2S9/XYnxfpi31kfI=; b=aP+oxGOG8fHDIu6aP2mwfRTrB5DsO8lMEXopTMNcY2VB+RuUDfEJWD+LRXQLw1aMFq 4PqseMwc0O/K2drZ0r7OTjonkioTiKbZxh3uTNlQ9SfzEC7R/sVhsBsgIPmMsgA9/baT j/tadCnjvJFtpXHmsHU+xhYOmlFAtyvADWIy9X4igr2rpwaTPLGJH0sn4qmZbq/6iGZQ +rdeJaR7mZVEYAoOyyu5ejkXEaB6GFG9nH6Z9PXCOEU65jdMeO6VpyYSVcBzW1DEDesN /WM6Y9TqrCIB+TQjprh7NXy4PHqRuehpe5p+YVw3fdfS0S7Rulu1E3incs1oVJhj0RWk yCdw== X-Gm-Message-State: AOAM530Ru89QHLJZDaFc7dD3v7LH+V1rJcZw4GpL6CB1/caBm+aWTHTr PwvxE/5hIxsud9urq91i5IEzVA== X-Google-Smtp-Source: ABdhPJyUiFBDSpYCVKl4wSv/JVH8/xbQ3jlNF7UStRDaNP9jdb4e5HDh7YD8c0psdHzLtRWGzelQyg== X-Received: by 2002:a05:6e02:f44:b0:2d3:b54f:d83e with SMTP id y4-20020a056e020f4400b002d3b54fd83emr24924981ilj.9.1654875980181; Fri, 10 Jun 2022 08:46:20 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:19 -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/6] net: ipa: verify command channel TLV count Date: Fri, 10 Jun 2022 10:46:10 -0500 Message-Id: <20220610154616.249304-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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 commit 8797972afff3d ("net: ipa: remove command info pool"), the maximum number of IPA commands that would be sent in a single transaction was defined. That number can't exceed the size of the TLV FIFO on the command channel, and we can check that at runtime. To add this check, pass a new flag to gsi_channel_data_valid() to indicate the channel being checked is being used for IPA commands. Knowing that we can also verify the channel direction is correct. Use a new local variable that refers to the command-specific portion of the data being checked. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 9cfe84319ee4d..65ed5a697577e 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -2001,9 +2001,10 @@ static void gsi_channel_evt_ring_exit(struct gsi_cha= nnel *channel) gsi_evt_ring_id_free(gsi, evt_ring_id); } =20 -static bool gsi_channel_data_valid(struct gsi *gsi, +static bool gsi_channel_data_valid(struct gsi *gsi, bool command, const struct ipa_gsi_endpoint_data *data) { + const struct gsi_channel_data *channel_data; u32 channel_id =3D data->channel_id; struct device *dev =3D gsi->dev; =20 @@ -2019,10 +2020,24 @@ static bool gsi_channel_data_valid(struct gsi *gsi, return false; } =20 - if (!data->channel.tlv_count || - data->channel.tlv_count > GSI_TLV_MAX) { + if (command && !data->toward_ipa) { + dev_err(dev, "command channel %u is not TX\n", channel_id); + return false; + } + + channel_data =3D &data->channel; + + if (!channel_data->tlv_count || + channel_data->tlv_count > GSI_TLV_MAX) { dev_err(dev, "channel %u bad tlv_count %u; must be 1..%u\n", - channel_id, data->channel.tlv_count, GSI_TLV_MAX); + channel_id, channel_data->tlv_count, GSI_TLV_MAX); + return false; + } + + if (command && IPA_COMMAND_TRANS_TRE_MAX > channel_data->tlv_count) { + dev_err(dev, "command TRE max too big for channel %u (%u > %u)\n", + channel_id, IPA_COMMAND_TRANS_TRE_MAX, + channel_data->tlv_count); return false; } =20 @@ -2031,22 +2046,22 @@ static bool gsi_channel_data_valid(struct gsi *gsi, * gsi_channel_tre_max() is computed, tre_count has to be almost * twice the TLV FIFO size to satisfy this requirement. */ - if (data->channel.tre_count < 2 * data->channel.tlv_count - 1) { + if (channel_data->tre_count < 2 * channel_data->tlv_count - 1) { dev_err(dev, "channel %u TLV count %u exceeds TRE count %u\n", - channel_id, data->channel.tlv_count, - data->channel.tre_count); + channel_id, channel_data->tlv_count, + channel_data->tre_count); return false; } =20 - if (!is_power_of_2(data->channel.tre_count)) { + if (!is_power_of_2(channel_data->tre_count)) { dev_err(dev, "channel %u bad tre_count %u; not power of 2\n", - channel_id, data->channel.tre_count); + channel_id, channel_data->tre_count); return false; } =20 - if (!is_power_of_2(data->channel.event_count)) { + if (!is_power_of_2(channel_data->event_count)) { dev_err(dev, "channel %u bad event_count %u; not power of 2\n", - channel_id, data->channel.event_count); + channel_id, channel_data->event_count); return false; } =20 @@ -2062,7 +2077,7 @@ static int gsi_channel_init_one(struct gsi *gsi, u32 tre_count; int ret; =20 - if (!gsi_channel_data_valid(gsi, data)) + if (!gsi_channel_data_valid(gsi, command, data)) return -EINVAL; =20 /* Worst case we need an event for every outstanding TRE */ --=20 2.34.1 From nobody Mon Apr 27 16:13:01 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 48904C433EF for ; Fri, 10 Jun 2022 15:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348728AbiFJPqn (ORCPT ); Fri, 10 Jun 2022 11:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345270AbiFJPqX (ORCPT ); Fri, 10 Jun 2022 11:46:23 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6572C110 for ; Fri, 10 Jun 2022 08:46:21 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id u2so20281470iln.2 for ; Fri, 10 Jun 2022 08:46:21 -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=S7La6nBk9Cx4BOrsERhSKtFTTEJXNgqXNboxuglpfJg=; b=PxMvN8seSWWhuH2UJ7lvFUjHsGE+jwR1lX4BUn8STq/hm4XqYNvgH+lIOdhUYxFbXI qUd8Gum0pEV1mw7hUSYPH8UVW9RpfhvX86svQXwrhh9ml6TropR9pqxjyr5yP+t08dDu /HM8wf60+VxPH6BH/4cSDRABqcCjyiTkimptZTniLCAo2c2Z6ITZOLBmGzwnBepwVfs0 A0RVsaDxumAuZnA/qXhrvfry1P5SuPj4G/hkEYeIPsnt/bxwhQljPwJnI0b7iEaYYFo7 lDb0RQ8t5vVcakzuH0IF/DSVF1bxB1XQLy6hQAZpnRnf0+cGMBb0COGym5SEdIJPZejp /8eQ== 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=S7La6nBk9Cx4BOrsERhSKtFTTEJXNgqXNboxuglpfJg=; b=av5QzVBxKEzBnNDUxJxBoTTgTrkSnUvRS+X/NVxJL+lBKLQKkmh4qHzHdOSHL1ZHbz Ol19VlI4OTZHPPoJ8gRlj1T6j3CZAIKpUow77YDp8aRx1nYhlIJym85zqHxoPQN+ZnxL xr3JFl3riw/K6pMCkFC8eDtda0J/qXQt0N0bpKiKlrAbKxV5C2ZfHXKy+YnbUxh2ZVTD LrRy6sxSUlzAOcE9Q5Nk7tO9V2KKOlPaMP5Kzw9TR1oG+ypouCKyA7Iwduo3IGPtMdMd hzFKQ7oNRIC7TisDd1hS20llhlOYBSx+ilaxwzUvhGKqywFGBOFJlxjrDTaQ0lDKKDBZ /TOw== X-Gm-Message-State: AOAM532fPVMyJdFSv/jrQ/xIv9b7POwbrQU8+6+AxiWbdwKjTcLgYKqZ C1pSPXOFDLX/l4HZiks003L/+Q== X-Google-Smtp-Source: ABdhPJzlXpTG8DdFUCx6d2OvAlPVIBA+7masa5y5JPqmXL69816WafFNg8YVYSOB9yz0mdBxHOn7lA== X-Received: by 2002:a05:6e02:552:b0:2d1:db28:5434 with SMTP id i18-20020a056e02055200b002d1db285434mr25898979ils.115.1654875981312; Fri, 10 Jun 2022 08:46:21 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:21 -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/6] net: ipa: rename channel->tlv_count Date: Fri, 10 Jun 2022 10:46:11 -0500 Message-Id: <20220610154616.249304-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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" Each GSI channel has a TLV FIFO of a certain size, specified in the configuration data for an AP channel. That size dictates the maximum number of TREs that are allowed in a single transaction. The only way that value is used after initialization is as a limit on the number of TREs in a transaction; calling it "tlv_count" isn't helpful, and in fact gsi_channel_trans_tre_max() exists to sort of abstract it. Instead, rename the channel->tlv_count field trans_tre_max, and get rid of the helper function. Update a couple of comments as well. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 14 +++----------- drivers/net/ipa/gsi.h | 11 +---------- drivers/net/ipa/gsi_trans.c | 8 ++------ drivers/net/ipa/ipa_cmd.c | 8 ++++---- drivers/net/ipa/ipa_endpoint.c | 2 +- 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 65ed5a697577e..b1acc7d36b23b 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -823,7 +823,7 @@ static void gsi_channel_program(struct gsi_channel *cha= nnel, bool doorbell) =20 /* Now update the scratch registers for GPI protocol */ gpi =3D &scr.gpi; - gpi->max_outstanding_tre =3D gsi_channel_trans_tre_max(gsi, channel_id) * + gpi->max_outstanding_tre =3D channel->trans_tre_max * GSI_RING_ELEMENT_SIZE; gpi->outstanding_threshold =3D 2 * GSI_RING_ELEMENT_SIZE; =20 @@ -2095,7 +2095,7 @@ static int gsi_channel_init_one(struct gsi *gsi, channel->gsi =3D gsi; channel->toward_ipa =3D data->toward_ipa; channel->command =3D command; - channel->tlv_count =3D data->channel.tlv_count; + channel->trans_tre_max =3D data->channel.tlv_count; channel->tre_count =3D tre_count; channel->event_count =3D data->channel.event_count; =20 @@ -2310,13 +2310,5 @@ u32 gsi_channel_tre_max(struct gsi *gsi, u32 channel= _id) struct gsi_channel *channel =3D &gsi->channel[channel_id]; =20 /* Hardware limit is channel->tre_count - 1 */ - return channel->tre_count - (channel->tlv_count - 1); -} - -/* Returns the maximum number of TREs in a single transaction for a channe= l */ -u32 gsi_channel_trans_tre_max(struct gsi *gsi, u32 channel_id) -{ - struct gsi_channel *channel =3D &gsi->channel[channel_id]; - - return channel->tlv_count; + return channel->tre_count - (channel->trans_tre_max - 1); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 5d66116b46b03..89dac7fc8c4cb 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -110,7 +110,7 @@ struct gsi_channel { bool toward_ipa; bool command; /* AP command TX channel or not */ =20 - u8 tlv_count; /* # entries in TLV FIFO */ + u8 trans_tre_max; /* max TREs in a transaction */ u16 tre_count; u16 event_count; =20 @@ -188,15 +188,6 @@ void gsi_teardown(struct gsi *gsi); */ u32 gsi_channel_tre_max(struct gsi *gsi, u32 channel_id); =20 -/** - * gsi_channel_trans_tre_max() - Maximum TREs in a single transaction - * @gsi: GSI pointer - * @channel_id: Channel whose limit is to be returned - * - * Return: The maximum TRE count per transaction on the channel - */ -u32 gsi_channel_trans_tre_max(struct gsi *gsi, u32 channel_id); - /** * gsi_channel_start() - Start an allocated GSI channel * @gsi: GSI pointer diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 55f8fe7d2668e..870a4c1752838 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -340,7 +340,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *g= si, u32 channel_id, struct gsi_trans_info *trans_info; struct gsi_trans *trans; =20 - if (WARN_ON(tre_count > gsi_channel_trans_tre_max(gsi, channel_id))) + if (WARN_ON(tre_count > channel->trans_tre_max)) return NULL; =20 trans_info =3D &channel->trans_info; @@ -745,14 +745,10 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 chann= el_id) * element is used to fill a single TRE when the transaction is * committed. So we need as many scatterlist elements as the * maximum number of TREs that can be outstanding. - * - * All TREs in a transaction must fit within the channel's TLV FIFO. - * A transaction on a channel can allocate as many TREs as that but - * no more. */ ret =3D gsi_trans_pool_init(&trans_info->sg_pool, sizeof(struct scatterlist), - tre_max, channel->tlv_count); + tre_max, channel->trans_tre_max); if (ret) goto err_trans_pool_exit; =20 diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index e58cd4478fd3d..6dea40259b604 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -353,13 +353,13 @@ int ipa_cmd_pool_init(struct gsi_channel *channel, u3= 2 tre_max) /* This is as good a place as any to validate build constants */ ipa_cmd_validate_build(); =20 - /* Even though command payloads are allocated one at a time, - * a single transaction can require up to tlv_count of them, - * so we treat them as if that many can be allocated at once. + /* Command payloads are allocated one at a time, but a single + * transaction can require up to the maximum supported by the + * channel; treat them as if they were allocated all at once. */ return gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool, sizeof(union ipa_cmd_payload), - tre_max, channel->tlv_count); + tre_max, channel->trans_tre_max); } =20 void ipa_cmd_pool_exit(struct gsi_channel *channel) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index d3b3255ac3d12..57507a109269b 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1721,7 +1721,7 @@ static void ipa_endpoint_setup_one(struct ipa_endpoin= t *endpoint) if (endpoint->ee_id !=3D GSI_EE_AP) return; =20 - endpoint->trans_tre_max =3D gsi_channel_trans_tre_max(gsi, channel_id); + endpoint->trans_tre_max =3D gsi->channel[channel_id].trans_tre_max; if (!endpoint->toward_ipa) { /* RX transactions require a single TRE, so the maximum * backlog is the same as the maximum outstanding TREs. --=20 2.34.1 From nobody Mon Apr 27 16:13:01 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 63D59C43334 for ; Fri, 10 Jun 2022 15:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348923AbiFJPqr (ORCPT ); Fri, 10 Jun 2022 11:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345594AbiFJPq1 (ORCPT ); Fri, 10 Jun 2022 11:46:27 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080DB40E5D for ; Fri, 10 Jun 2022 08:46:23 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id a15so21181012ilq.12 for ; Fri, 10 Jun 2022 08:46:23 -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=0BQDmv34wyVMx4obn1fqFEZa9pyMw3o6hJ+fsh6NgSM=; b=ga0Eg6Tt0RYWMUIgu1mvu7J/5FJ6m0+zf/4G9GxASMNYSXwLJOLWCJU+YBYGQi3HH7 O9Smz2tRhWSRSpgY6ToXMhnTfqczzenh7EWkthxJFr7gBWIp6+qI1y1O9xPkD5enXdl2 gOEqi5hQJFHIHjnRtK6+sBfbAxTepolG6edtZ2ZU/1KMoQCHsMUlenmPd1aXiBqT6N8w p60CMhIbKsCrtDaDsEJAGqyKKGBV1spMJo/zEm9974xKinQaYxTf/Za0dqo+UIZzHWSs p8SK4dUKqzy8TJXhtwqLFRvkAknuzJ9oLsiKGc2r5Kju0Q+AlaLq0z1ixmhn0Xi+Z1s8 olTw== 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=0BQDmv34wyVMx4obn1fqFEZa9pyMw3o6hJ+fsh6NgSM=; b=tBlAG+QHs5thhKZ+Xh1o7xR9cUIAeu7pw0uNf6XY3QhJVqAcvkzWrmaqs8vDhEBc8a PgCSu+1KwGCQv4SlVXC7fbSX/yeQfZHLFt6xFftI7aoyaOQG6K/+p5oAgMCUnMB2dYLX lnGybSC/E8pOpbxXKw04mINax0A1Tf8Ohi3DzVGRjcS5K7T775vQhcbOATASsqt1j+Mz VYVljGOM1YYgICGjfcqFlHEQapS9ROdbOKAU2lrcR2gJA75c8ZqemvrN42GWPz6aL5t6 qYvNzd8WpPsWhHSzI5XAndobZq4mz2zHnaxRzy4y+vK4NjU07DZmkqSyY33VxISsllms 8ZkA== X-Gm-Message-State: AOAM533U5ExKnJ6aTfiFbgYb1h0y2EGyrIL+aDo4jq98mx6anYy3EBsv Yk7AQnGCWwU4KVaUq8AlOJDToQ== X-Google-Smtp-Source: ABdhPJxGCzAWxekqR/1CB6I34OLmakcTvMrRIr9MdyRPb8GCN98mBQJtFdvPK8caFVS3lBNXTECOBA== X-Received: by 2002:a05:6e02:1b87:b0:2d6:5e74:217a with SMTP id h7-20020a056e021b8700b002d65e74217amr7584781ili.74.1654875982391; Fri, 10 Jun 2022 08:46:22 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:22 -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/6] net: ipa: rename endpoint->trans_tre_max Date: Fri, 10 Jun 2022 10:46:12 -0500 Message-Id: <20220610154616.249304-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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 trans_tre_max field of the IPA endpoint structure is only used to limit the number of fragments allowed for an SKB being prepared for transmission. Recognizing that, rename the field skb_frag_max, and reduce its value by 1. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 4 ++-- drivers/net/ipa/ipa_endpoint.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 57507a109269b..86ef91f83eb68 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1020,7 +1020,7 @@ int ipa_endpoint_skb_tx(struct ipa_endpoint *endpoint= , struct sk_buff *skb) * If not, see if we can linearize it before giving up. */ nr_frags =3D skb_shinfo(skb)->nr_frags; - if (1 + nr_frags > endpoint->trans_tre_max) { + if (nr_frags > endpoint->skb_frag_max) { if (skb_linearize(skb)) return -E2BIG; nr_frags =3D 0; @@ -1721,7 +1721,7 @@ static void ipa_endpoint_setup_one(struct ipa_endpoin= t *endpoint) if (endpoint->ee_id !=3D GSI_EE_AP) return; =20 - endpoint->trans_tre_max =3D gsi->channel[channel_id].trans_tre_max; + endpoint->skb_frag_max =3D gsi->channel[channel_id].trans_tre_max - 1; if (!endpoint->toward_ipa) { /* RX transactions require a single TRE, so the maximum * backlog is the same as the maximum outstanding TREs. diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h index 01790c60bee8d..28e0a7386fd72 100644 --- a/drivers/net/ipa/ipa_endpoint.h +++ b/drivers/net/ipa/ipa_endpoint.h @@ -142,7 +142,7 @@ enum ipa_replenish_flag { * @endpoint_id: IPA endpoint number * @toward_ipa: Endpoint direction (true =3D TX, false =3D RX) * @config: Default endpoint configuration - * @trans_tre_max: Maximum number of TRE descriptors per transaction + * @skb_frag_max: Maximum allowed number of TX SKB fragments * @evt_ring_id: GSI event ring used by the endpoint * @netdev: Network device pointer, if endpoint uses one * @replenish_flags: Replenishing state flags @@ -157,7 +157,7 @@ struct ipa_endpoint { bool toward_ipa; struct ipa_endpoint_config config; =20 - u32 trans_tre_max; + u32 skb_frag_max; /* Used for netdev TX only */ u32 evt_ring_id; =20 /* Net device this endpoint is associated with, if any */ --=20 2.34.1 From nobody Mon Apr 27 16:13:01 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 1C4F8C433EF for ; Fri, 10 Jun 2022 15:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349051AbiFJPqv (ORCPT ); Fri, 10 Jun 2022 11:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345630AbiFJPq2 (ORCPT ); Fri, 10 Jun 2022 11:46:28 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5FF22D for ; Fri, 10 Jun 2022 08:46:24 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p128so6212268iof.1 for ; Fri, 10 Jun 2022 08:46:24 -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=yzpg6uSX6tMLeSyY3HSLNWDLn7gtZwirUKg77xaYBSY=; b=NgvGg1sb/EMOxOd0Hk4IC0/bLMvgrcj1VRmfcbBh+wwoCZAw81jAjGyJ18FjHTna2x bdp9AKZ06s4jsbYtlf8XJAGKM1NF3tD3DtFX4+IfZg5gZIDyw0TpKrcB8vfpKQ3wJBgy 9CvUD52CRzeRKBwE1pZ0E+AmX2gNfZYJQztMaBXTl+iKSYgh7f/8x37q795ziU4kmAy6 TcDxp2zmDOst1QrGrkRcP/r8O3gwh3uIdrlYTqtyCRQUEk1KY2vAApZNZeloNtxuKT8H yY+7GUuKHvxzyNMyQojL5RWz2/UZ9ZEMAl9oeoqUhhEgOmXPXP6xoFUoEMqr3wZz+Y1U rqvA== 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=yzpg6uSX6tMLeSyY3HSLNWDLn7gtZwirUKg77xaYBSY=; b=FkeAvxgihyo2tkee6dqK9Wuw/HOt//GN43e7KgFryOVlzvPkziXeYHzbXYj6n7+c65 6/hzteh6EmtUrLTdbQO70mVk5an7uqyBCFdd9YatQWVR9e0XWIGYcQHn4l2jt2X7pL3K ZCXEdcsoGY+2q7+y79G9cp8ws09MDw+Uriyn+CTiP3+Gr5sVAWUyqKwZ9T/+Cvpc89xP L2en6zCKJfYfxuAChu4UMuy+Q4wxVVQb27GQu+3yT28CwXfXbcNNVsQ5YP53XYyzDbAl uikBghR1b0zkK1G0YKGtQI+C9401E74qGGDvKN+Lnn0hbF+3DSI/WZA7T8pAlbVg88tO M07g== X-Gm-Message-State: AOAM530qYikzPQ/GyKlEbKKQMH5IiHf+Z+weibfp0qWYflJeNXAJse0N 5Zxo/EbESzNmt+glovB0F7Xw1w== X-Google-Smtp-Source: ABdhPJxT6mIepia5PxJjdru8UpkhyTrUg4l/P9fcEkomP2u+44qHE3xpLXAGA/tvIhTqpz6z+sKdbQ== X-Received: by 2002:a6b:108:0:b0:669:a9e4:24a0 with SMTP id 8-20020a6b0108000000b00669a9e424a0mr5226313iob.165.1654875983381; Fri, 10 Jun 2022 08:46:23 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:23 -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 endpoint transaction completion Date: Fri, 10 Jun 2022 10:46:13 -0500 Message-Id: <20220610154616.249304-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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 a GSI transaction completes, ipa_endpoint_trans_complete() is eventually called. That handles TX and RX completions separately, but ipa_endpoint_tx_complete() is a no-op. Instead, have ipa_endpoint_trans_complete() return immediately for a TX transaction, and incorporate code from ipa_endpoint_rx_complete() to handle RX transactions. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 86ef91f83eb68..66d2bfdf9e423 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1368,18 +1368,14 @@ static void ipa_endpoint_status_parse(struct ipa_en= dpoint *endpoint, } } =20 -/* Complete a TX transaction, command or from ipa_endpoint_skb_tx() */ -static void ipa_endpoint_tx_complete(struct ipa_endpoint *endpoint, - struct gsi_trans *trans) -{ -} - -/* Complete transaction initiated in ipa_endpoint_replenish_one() */ -static void ipa_endpoint_rx_complete(struct ipa_endpoint *endpoint, - struct gsi_trans *trans) +void ipa_endpoint_trans_complete(struct ipa_endpoint *endpoint, + struct gsi_trans *trans) { struct page *page; =20 + if (endpoint->toward_ipa) + return; + if (trans->cancelled) goto done; =20 @@ -1393,15 +1389,6 @@ static void ipa_endpoint_rx_complete(struct ipa_endp= oint *endpoint, ipa_endpoint_replenish(endpoint); } =20 -void ipa_endpoint_trans_complete(struct ipa_endpoint *endpoint, - struct gsi_trans *trans) -{ - if (endpoint->toward_ipa) - ipa_endpoint_tx_complete(endpoint, trans); - else - ipa_endpoint_rx_complete(endpoint, trans); -} - void ipa_endpoint_trans_release(struct ipa_endpoint *endpoint, struct gsi_trans *trans) { --=20 2.34.1 From nobody Mon Apr 27 16:13:01 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 1A6E6C43334 for ; Fri, 10 Jun 2022 15:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345910AbiFJPqz (ORCPT ); Fri, 10 Jun 2022 11:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345672AbiFJPq3 (ORCPT ); Fri, 10 Jun 2022 11:46:29 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2171149F3E for ; Fri, 10 Jun 2022 08:46:25 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id y12so25678696ior.7 for ; Fri, 10 Jun 2022 08:46:25 -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=H+HiH5kTQtRHo/h67V+G+1rByOl+HT84huwB93SdFF4=; b=MH0/ex7pQYFU3FynRa4guAtnpYUYFfOE1ZX5ue+Gmxj4XgtT4ogdKvu1cIv8iLBXoO TyfqAjFjPhG5x+RFtPCRjvzVB1NiW34107TsVJIW/T1AiEqnEcd3YQK5+kBprjipX47Q kqtU8OBDeroN5akL+XEiqGJB3FEARjkGJ+CB2rtipWBjleiR4z9zc/RGRmX1bSRFU/bY S8KVMJj9n7uiQ6hVyMe4yi35qNUuffb+7HnVReGwIOVro/pdbi8LhIHBxAzjoX3I9pxg ldZXwYdfYfDtvXoTo8kHTWBIFGpo/ixLk04+xqrZPKjUyJZMRBzHxv4DG8uBjlPOppJm 8zXg== 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=H+HiH5kTQtRHo/h67V+G+1rByOl+HT84huwB93SdFF4=; b=ai9pnA9hTjfXvHn2AK1MKezxsZ4MehpWwXUaqmrzmd+9Pt0KHGLjJ5P1TwkDWB6oxz CkNJIzKrOfrdsKn7hyDKPmerU2eLSu/ybuMbYFiA53r5HuZV3d+Zvnujy+yX80S21utG IKmKmZ3+y+FBNxL5UnpHkIcbTrcMKq8PxMPZbq0a1MGV8nlY3xVUnsbGbYPmMv83ber3 wOzGKqm+94XhUW9+QSNozdLzMCUIwaevRW2puqfoJkJuhTU/lLmy3pKRF+PliSqWw+kj dtbRSGm0+Yr/R3kTntR7QGr778I8S+o9Ue6UiXe/v1hV6u/1uXrOI2o9RnriSFEHvp7n iETA== X-Gm-Message-State: AOAM533e/Wp0YaeyOvq6kaPkN9iWFQhUykRykm+K4CooqWL4zagZNqs/ teLt5Y90B7ckx6H8Gcmmk+qDYA== X-Google-Smtp-Source: ABdhPJwEUXLBB1sJj2ow0lN3MVJyaVknIOgVftb4vBlLCWs24AAQCOfuiBkb89Ee/8sfXH3FFDrd9A== X-Received: by 2002:a05:6602:72f:b0:669:488c:ff79 with SMTP id g15-20020a056602072f00b00669488cff79mr15187211iox.27.1654875984459; Fri, 10 Jun 2022 08:46:24 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:24 -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/6] net: ipa: determine channel from event Date: Fri, 10 Jun 2022 10:46:14 -0500 Message-Id: <20220610154616.249304-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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" Each event in an event ring describes the TRE whose completion caused the event. Currently, every event ring is dedicated to a single channel, so the channel is easily derived from the event ring. An event ring can actually be shared by more than one channel though, and to distinguish events for one channel from another, the event structure contains a field indicating which channel the event is associated with. In gsi_event_trans(), use the channel ID in an event to determine which channel the event is for. This makes the channel pointer now passed to that function irrelevant; pass the GSI pointer to that function instead. And although it shouldn't happen, warn if an event arrives that records a channel ID that's not in use, or if the event does not have a transaction associated with it. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index b1acc7d36b23b..64417668b8a9a 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1327,17 +1327,29 @@ static int gsi_irq_init(struct gsi *gsi, struct pla= tform_device *pdev) } =20 /* Return the transaction associated with a transfer completion event */ -static struct gsi_trans *gsi_event_trans(struct gsi_channel *channel, - struct gsi_event *event) +static struct gsi_trans * +gsi_event_trans(struct gsi *gsi, struct gsi_event *event) { + u32 channel_id =3D event->chid; + struct gsi_channel *channel; + struct gsi_trans *trans; u32 tre_offset; u32 tre_index; =20 + channel =3D &gsi->channel[channel_id]; + if (WARN(!channel->gsi, "event has bad channel %u\n", channel_id)) + return NULL; + /* Event xfer_ptr records the TRE it's associated with */ tre_offset =3D lower_32_bits(le64_to_cpu(event->xfer_ptr)); tre_index =3D gsi_ring_index(&channel->tre_ring, tre_offset); =20 - return gsi_channel_trans_mapped(channel, tre_index); + trans =3D gsi_channel_trans_mapped(channel, tre_index); + + if (WARN(!trans, "channel %u event with no transaction\n", channel_id)) + return NULL; + + return trans; } =20 /** @@ -1381,7 +1393,9 @@ 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, event); + 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. @@ -1493,7 +1507,9 @@ static struct gsi_trans *gsi_channel_update(struct gs= i_channel *channel) return NULL; =20 /* Get the transaction for the latest completed event. */ - trans =3D gsi_event_trans(channel, gsi_ring_virt(ring, index - 1)); + trans =3D gsi_event_trans(gsi, gsi_ring_virt(ring, index - 1)); + if (!trans) + return NULL; =20 /* For RX channels, update each completed transaction with the number * of bytes that were actually received. For TX channels, report --=20 2.34.1 From nobody Mon Apr 27 16:13:01 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 DECA1C43334 for ; Fri, 10 Jun 2022 15:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349300AbiFJPrW (ORCPT ); Fri, 10 Jun 2022 11:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346087AbiFJPq3 (ORCPT ); Fri, 10 Jun 2022 11:46:29 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C8858E53 for ; Fri, 10 Jun 2022 08:46:26 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id d123so6695007iof.10 for ; Fri, 10 Jun 2022 08:46:26 -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=rzg7Iow9fAmaKgsdU7mGzgw2dtvwGPhEQmm7lb2v2dI=; b=Go3UU13RUL7Su3WFcFQZEQWn19aFNSiLMT4iZEqcX5aXxDh7U8Gg9rTXlMFcHMpOZ+ 0gHSPaiNYkNQujued/pPga7cYZNSq0DXDatYShLZXacJ7r/609m2c1xqjf513rhDAHi3 nf0WsnhopAGSDvCjKYrP/8t7+uhMOi9FVn9PYZ8soB5Os10HWdYQdYp6Atym4N5SdRPR 3/i8pF++h1oaRthygyMqzgxNRr6PsE3TH2F8Ik2VLWJjl9yua8b9Kfs0J+ZIz6tu0dUU jEFWqR9X96G/JWqNo3HyZmfYGWOrTKyNUfY3gBENo3tEuMWkQ3iQU2R/8/sWTuyKlijP iEoA== 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=rzg7Iow9fAmaKgsdU7mGzgw2dtvwGPhEQmm7lb2v2dI=; b=igl+uT5/1gx5lNGD+Df4zQ/MtdzDfolgQcjdE2mmJllG4983SOgYt3jvU2fyMNx8L9 RhKId//jdzGEuaP6PXkSfJPHuoAkbfUjQrIEbVyZPK5u2jFiMPN1sjQnmA3nD4JXMrTH 1NkAz7Cre3geAacMopTDo1eKpEfLdYIo73zUodZEyHww3yhVsEivAQvn5JFcJ/HFb6h4 W1Wi/kFqE5txLa8eIb+Q0GiMhFw/XdAQt0T1pxY7UFTcT1W1lA+GdM4BT4ZkzkmypKs9 jazrUAY1Q1DRSwY8iXlqjaTOerReHD5gh0jjfxf1Uc5rXdjE+pt7jFjPdL/wIZlVsdGs M6Kg== X-Gm-Message-State: AOAM533cHbORGuoIS7NJ/ES/vDhO1vkEvRCDP0QIhD4d+wg+EJn+BqM0 /MlfrNPpLnRKtKMZ5V/gVHM0+g== X-Google-Smtp-Source: ABdhPJwwDcev7BFxOZ5NvJzSfIKGesXaHnnwWB1/bTwAMkR3fPANEeZunQbbYB4U6VSI1GWR+bqhhw== X-Received: by 2002:a05:6638:1346:b0:331:b571:9fd6 with SMTP id u6-20020a056638134600b00331b5719fd6mr14413045jad.266.1654875985510; Fri, 10 Jun 2022 08:46:25 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y15-20020a92950f000000b002d3adf71893sm12100488ilh.20.2022.06.10.08.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:46:25 -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 6/6] net: ipa: derive channel from transaction Date: Fri, 10 Jun 2022 10:46:15 -0500 Message-Id: <20220610154616.249304-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610154616.249304-1-elder@linaro.org> References: <20220610154616.249304-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_channel_tx_queued(), we report when a transaction gets passed to hardware. Change that function so it takes transaction rather than a channel as its argument, and derive the channel from the transaction. Rename the function accordingly. Delete the header comments above the function definition; the ones above the declaration in "gsi_private.h" should suffice. In addition, the comments above gsi_channel_tx_update() do a fine job of explaining what's going on. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 28 +++++++--------------------- drivers/net/ipa/gsi_private.h | 12 +++++------- drivers/net/ipa/gsi_trans.c | 2 +- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 64417668b8a9a..5b446d2a07c8a 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -991,36 +991,22 @@ void gsi_resume(struct gsi *gsi) enable_irq(gsi->irq); } =20 -/** - * gsi_channel_tx_queued() - Report queued TX transfers for a channel - * @channel: Channel for which to report - * - * Report to the network stack the number of bytes and transactions that - * have been queued to hardware since last call. This and the next functi= on - * supply information used by the network stack for throttling. - * - * For each channel we track the number of transactions used and bytes of - * data those transactions represent. We also track what those values are - * each time this function is called. Subtracting the two tells us - * the number of bytes and transactions that have been added between - * successive calls. - * - * Calling this each time we ring the channel doorbell allows us to - * provide accurate information to the network stack about how much - * work we've given the hardware at any point in time. - */ -void gsi_channel_tx_queued(struct gsi_channel *channel) +void gsi_trans_tx_queued(struct gsi_trans *trans) { + u32 channel_id =3D trans->channel_id; + struct gsi *gsi =3D trans->gsi; + struct gsi_channel *channel; u32 trans_count; u32 byte_count; =20 + channel =3D &gsi->channel[channel_id]; + byte_count =3D channel->byte_count - channel->queued_byte_count; trans_count =3D channel->trans_count - channel->queued_trans_count; channel->queued_byte_count =3D channel->byte_count; channel->queued_trans_count =3D channel->trans_count; =20 - ipa_gsi_channel_tx_queued(channel->gsi, gsi_channel_id(channel), - trans_count, byte_count); + ipa_gsi_channel_tx_queued(gsi, channel_id, trans_count, byte_count); } =20 /** diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index ea333a244cf5e..56450a1899074 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -105,14 +105,12 @@ void gsi_channel_doorbell(struct gsi_channel *channel= ); void *gsi_ring_virt(struct gsi_ring *ring, u32 index); =20 /** - * gsi_channel_tx_queued() - Report the number of bytes queued to hardware - * @channel: Channel whose bytes have been queued + * gsi_trans_tx_queued() - Report a queued TX channel transaction + * @trans: Transaction being passed to hardware * - * This arranges for the the number of transactions and bytes for - * transfer that have been queued to hardware to be reported. It - * passes this information up the network stack so it can be used to - * throttle transmissions. + * Report to the network stack that a TX transaction is being supplied + * to the hardware. */ -void gsi_channel_tx_queued(struct gsi_channel *channel); +void gsi_trans_tx_queued(struct gsi_trans *trans); =20 #endif /* _GSI_PRIVATE_H_ */ diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 870a4c1752838..278e467c5430b 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -603,7 +603,7 @@ static void __gsi_trans_commit(struct gsi_trans *trans,= bool ring_db) if (ring_db || !atomic_read(&channel->trans_info.tre_avail)) { /* Report what we're handing off to hardware for TX channels */ if (channel->toward_ipa) - gsi_channel_tx_queued(channel); + gsi_trans_tx_queued(trans); gsi_channel_doorbell(channel); } } --=20 2.34.1