From nobody Fri Dec 19 17:43:31 2025 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 B0024FA3740 for ; Thu, 27 Oct 2022 12:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235602AbiJ0M0r (ORCPT ); Thu, 27 Oct 2022 08:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235480AbiJ0M0j (ORCPT ); Thu, 27 Oct 2022 08:26:39 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D58DE132EBD for ; Thu, 27 Oct 2022 05:26:38 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id 11so1305212iou.0 for ; Thu, 27 Oct 2022 05:26:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MjjSjVxz43dPoj+rB5pDgaOIlILrA2m91ybZAXvDhDE=; b=LFbhw/vDugO3V+guejpZp9r55Py7iMGG6jyjnu9kESgzHZbFfP+VFBMim552nitqST Q8p7/ZL3JQTGEFe2PDO7eWH8E69a6ayRvfK2N4xY2CIm6EToqdRKuRV0kQPX1UC9A9XK L2+6sNH0CvZ0+rFiZRuJ4E69Vbbz/17nG8QEkMBlqUpTiACt75Wgnjl4SS6+XAL0S8Yj JI8xZl+RxmcjpHDJk8uIOrrZ0DLKxNAhs4yxWScvT20VSb3SkOoJWBvU9Q+77eo4u1dd tvQ8m+AaFCszslPrcET1X+Lkclnc+l2rhhll3YGJc2dTtjrnWBrqEi9Tg2+f3qXdFMT2 r6DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MjjSjVxz43dPoj+rB5pDgaOIlILrA2m91ybZAXvDhDE=; b=QJerwaM00wk/fUq18YZp6TLj1dYUhhUAL6RPWTAcniGF3jBw9NFWJLIvaH+3UQwHZb IZPd76mmEDIldeg8wrJV909pS7TBIPrZzYcPpJVjLKETHV9Frax1186GqGjYg6lw6q0/ Ic+p6WMPnc/McvuonmfsjQoxqDNHgpfo9m62V34dg5ITXjvTHEIcwUFwIJ8y8OvHd3SF ckRznMfwiYDLq0/W2pXMlchqfJk9THG9skIf/VC8crTFN4M1CeMxZQA8rdou5l5bJQtI asH5F943RgM66q0jYK2B08iEf7J++y9rjEfuMnPowOH0l2ctYqgsXNZR5A6YT4bhqsSc A7wQ== X-Gm-Message-State: ACrzQf0M9m3XBbs0w7HJ7f8FRG60t/R5dUxJ3kx3afIl2K+anbfdWA1K NSbhp7SWejNQrLPR0FmHL0LZUA== X-Google-Smtp-Source: AMsMyM5PqnJLBdgCpX7QF9OkT4hEG1qV5vjb5X57TKMbdWNxjkzbv1GT9SwXPTNQqrN0pn3aoVAy2g== X-Received: by 2002:a5d:9ac1:0:b0:6a3:1938:e6b0 with SMTP id x1-20020a5d9ac1000000b006a31938e6b0mr28385734ion.186.1666873598126; Thu, 27 Oct 2022 05:26:38 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26: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, andersson@kernel.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/7] net: ipa: define IPA v5.0 Date: Thu, 27 Oct 2022 07:26:26 -0500 Message-Id: <20221027122632.488694-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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 preparation for adding support for IPA v5.0, define it as an understood version. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_version.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ipa/ipa_version.h b/drivers/net/ipa/ipa_version.h index 7870e0cc3d7c9..7889c310e943d 100644 --- a/drivers/net/ipa/ipa_version.h +++ b/drivers/net/ipa/ipa_version.h @@ -19,6 +19,7 @@ * @IPA_VERSION_4_7: IPA version 4.7/GSI version 2.7 * @IPA_VERSION_4_9: IPA version 4.9/GSI version 2.9 * @IPA_VERSION_4_11: IPA version 4.11/GSI version 2.11 (2.1.1) + * @IPA_VERSION_5_0: IPA version 5.0/GSI version 3.0 * @IPA_VERSION_COUNT: Number of defined IPA versions * * Defines the version of IPA (and GSI) hardware present on the platform. @@ -36,6 +37,7 @@ enum ipa_version { IPA_VERSION_4_7, IPA_VERSION_4_9, IPA_VERSION_4_11, + IPA_VERSION_5_0, IPA_VERSION_COUNT, /* Last; not a version */ }; =20 @@ -48,6 +50,7 @@ static inline bool ipa_version_supported(enum ipa_version= version) case IPA_VERSION_4_5: case IPA_VERSION_4_9: case IPA_VERSION_4_11: + case IPA_VERSION_5_0: return true; default: return false; --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 BD643FA3744 for ; Thu, 27 Oct 2022 12:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234330AbiJ0M0x (ORCPT ); Thu, 27 Oct 2022 08:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235562AbiJ0M0l (ORCPT ); Thu, 27 Oct 2022 08:26:41 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3802C132240 for ; Thu, 27 Oct 2022 05:26:40 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id y143so460949iof.9 for ; Thu, 27 Oct 2022 05:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mZhPH98EZI2dEoFXGWQtmjLxJRjCACN6xFS+27Ga9q8=; b=CGOB+dy4GUYVpZbN/DWiHffXQGLBKtcmB1o3l8pIV6Su1Tk7/cZYKQBTlO6wnaarmQ 7VxFaYWL5uwsE9aAL2ZwDSgT0VNkNynJspstC4HVS2vS4YWvbNdYKdx3gIuoHuMhusDL GSh6+4QsnoL1WXG8yGkpQ5nU05969EC4nc/mQP+BH5cxcDqHiNJYDLqYY8vgDs9uz5wN uNGMVLymJbJfomK+gHqG4Q0Rr+NB8gWE7k3ZXOg7Pdj6k42BfgnCpf8kbAA4gapcXSUd E1q6/w1VhnDAepMXHViahUPSJdEs/+tVmTv8jnyFpPIYcPMgHjzFKTKFkZeziQ0YwKat DX6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mZhPH98EZI2dEoFXGWQtmjLxJRjCACN6xFS+27Ga9q8=; b=lIHlvATdeaAkuxCYBnwcYbIImkMsc5ZBNbBlIPdkHdNas03OWWd5ZnaqoMba+5raTL ztt2RqcuxHWQEjGEGZGPpPxkz4zV5uAErpCXyip01JEKUHTJ/rTWcaJ/2Err4YUQgeVj 7Nq7GopfRV9vKyrv64BmbFc1/7m8710oRyp8ZluH3TznF+235caOmvk6MxzxpNMc/SgJ C6Ylc/KEGGCnWzwL8y5UqZi9cltOqdY0h6ZhZyX0G6PxYIhQWIiawfj6WQrDKwN9KnmA Sa0sVm0ANgZcIHLMKW7LtgRnwBDlj03AVcUzswcpBTMBu0K+dhMmgeojsv/NeLnQH3i7 3cXw== X-Gm-Message-State: ACrzQf3OZtpy7DUa15/8g4JtS55Yc7MD0PDE7/lFdMAQfsPzew3fkDSW CX7glRmySjuVkkr00VNPRFJB0Q== X-Google-Smtp-Source: AMsMyM4g+r8w9GFfz7c0hkxjUrZJwSTc6gyWD9hZwwkTwdOZ6LpuMCgR3yYayx37JARnCXXFoBgCOQ== X-Received: by 2002:a6b:5f1d:0:b0:6c5:247c:6763 with SMTP id t29-20020a6b5f1d000000b006c5247c6763mr1803360iob.65.1666873599556; Thu, 27 Oct 2022 05:26:39 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:39 -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, andersson@kernel.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/7] net: ipa: change an IPA v5.0 memory requirement Date: Thu, 27 Oct 2022 07:26:27 -0500 Message-Id: <20221027122632.488694-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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" Don't require IPA v5.0 to have a STATS_TETHERING memory region. Downstream defines its size to 0, so it apparently is unused. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index cb95402018394..9ec5af323f731 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -198,9 +198,12 @@ static bool ipa_mem_id_required(struct ipa *ipa, enum = ipa_mem_id mem_id) =20 case IPA_MEM_PDN_CONFIG: case IPA_MEM_STATS_QUOTA_MODEM: - case IPA_MEM_STATS_TETHERING: return ipa->version >=3D IPA_VERSION_4_0; =20 + case IPA_MEM_STATS_TETHERING: + return ipa->version >=3D IPA_VERSION_4_0 && + ipa->version !=3D IPA_VERSION_5_0; + default: return false; /* Anything else is optional */ } --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 305CDECAAA1 for ; Thu, 27 Oct 2022 12:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235622AbiJ0M04 (ORCPT ); Thu, 27 Oct 2022 08:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235587AbiJ0M0m (ORCPT ); Thu, 27 Oct 2022 08:26:42 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11BC13C1CA for ; Thu, 27 Oct 2022 05:26:41 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id q18so836677ils.12 for ; Thu, 27 Oct 2022 05:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lniLLq0wWXt/bwGWmVmVl0IrNVPhksr2CD/LLDMRS+A=; b=iT1BRxpiJ1FEPFYwmqxHLZwKGyvfuqDSSjPdNyeSC8hI3C5hVMsF6/UOjXFUyYS9nq XVwlez9HeD1TD792m2ZwoXP22fBXJbo7scUTO+g5diRZNPog3/CpkeLQBkKYxBpndyW/ DL/zpb9ZpRHOgKgspyfFhQzeyrudcvHvLY0hArRYzIvsiMOb7xTdDzzBce4TsvknUHTo a6cT7gI+rsDazezSiL/tRGHZCyN1OCR11LCZnk81tUWhTl0gJRdAkdsW2z7QrNhgOFck /90Im8QD7CwhSDeNlYksE88k+wsCyXbka0PMvRJ+ciSeRWDnfuCQWZj/smEjLoVvjGRr LRNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lniLLq0wWXt/bwGWmVmVl0IrNVPhksr2CD/LLDMRS+A=; b=snZgjCU9lhYMfU3TqB+sJetjF3Gc/GWSbwHGNjKEBt74cWRTGiFymZpsbfw73/PMMA ikKgmnOW69CEZ9HVvVv+nkcD3cDdBJWwvxWZvsr4I4dM30oNRlqUV8j4dp3mTFFOe3M5 je7Ochljolyknl/ehjV+Q60Wg5vord0lx+2Qx5GtXFWTETcqPe70nRCBbmqrJTNtHiH9 UkdOn7/wpMXaaQHVgeYv8nie8VtgehBEEjRp9tBO5gDtTxKp2+MKl+TxLaQF6N69xZt2 UEq/HsYQEShYJrRZgfasD5zdGaVhnvao3K9iHcRhKaaWRY3rIwkiENNpwc5inbplEKW/ vX8w== X-Gm-Message-State: ACrzQf1KtHeKvot5r8nwMthBsrY4FAN339HOrVpw81Z26zfmmyFCMdRw t8E5lAKDb8YYxbLrttWFK6Jbmg== X-Google-Smtp-Source: AMsMyM5p5OoGa5JWm9afYrjlUvN/zVxlsYvYweWofRMNvAoRuj9t9V8CIEvHDh1wuGMYIkg7eyzjMQ== X-Received: by 2002:a92:d0a:0:b0:300:3d26:b1fa with SMTP id 10-20020a920d0a000000b003003d26b1famr9158422iln.272.1666873601045; Thu, 27 Oct 2022 05:26:41 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:40 -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, andersson@kernel.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/7] net: ipa: no more global filtering starting with IPA v5.0 Date: Thu, 27 Oct 2022 07:26:28 -0500 Message-Id: <20221027122632.488694-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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" IPA v5.0 eliminates the global filter table entry. As a result, there is no need to shift the filtered endpoint bitmap when it is written to IPA local memory. Update comments to explain this. Also delete a redundant block of comments above the function. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 59 ++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index db1992eaafaa9..cf3a3de239dc3 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -32,8 +32,8 @@ * endian 64-bit "slot" that holds the address of a rule definition. (The * size of these slots is 64 bits regardless of the host DMA address size.) * - * Separate tables (both filter and route) used for IPv4 and IPv6. There - * are normally another set of "hashed" filter and route tables, which are + * Separate tables (both filter and route) are used for IPv4 and IPv6. Th= ere + * is normally another set of "hashed" filter and route tables, which are * used with a hash of message metadata. Hashed operation is not supported * by all IPA hardware (IPA v4.2 doesn't support hashed tables). * @@ -51,19 +51,32 @@ * Each filter rule is associated with an AP or modem TX endpoint, though * not all TX endpoints support filtering. The first 64-bit slot in a * filter table is a bitmap indicating which endpoints have entries in - * the table. The low-order bit (bit 0) in this bitmap represents a - * special global filter, which applies to all traffic. This is not - * used in the current code. Bit 1, if set, indicates that there is an - * entry (i.e. slot containing a system address referring to a rule) for - * endpoint 0 in the table. Bit 3, if set, indicates there is an entry - * for endpoint 2, and so on. Space is set aside in IPA local memory to - * hold as many filter table entries as might be required, but typically - * they are not all used. + * the table. Each set bit in this bitmap indicates the presence of the + * address of a filter rule in the memory following the bitmap. Until IPA + * v5.0, the low-order bit (bit 0) in this bitmap represents a special + * global filter, which applies to all traffic. Otherwise the position of + * each set bit represents an endpoint for which a filter rule is defined. + * + * The global rule is not used in current code, and support for it is + * removed starting at IPA v5.0. For IPA v5.0+, the endpoint bitmap + * position defines the endpoint ID--i.e. if bit 1 is set in the endpoint + * bitmap, endpoint 1 has a filter rule. Older versions of IPA represent + * the presence of a filter rule for endpoint X by bit (X + 1) being set. + * I.e., bit 1 set indicates the presence of a filter rule for endpoint 0, + * and bit 3 set means there is a filter rule present for endpoint 2. + * + * Each filter table entry has the address of a set of equations that + * implement a filter rule. So following the endpoint bitmap there + * will be such an address/entry for each endpoint with a set bit in + * the bitmap. * * The AP initializes all entries in a filter table to refer to a "zero" - * entry. Once initialized the modem and AP update the entries for - * endpoints they "own" directly. Currently the AP does not use the - * IPA filtering functionality. + * rule. Once initialized, the modem and AP update the entries for + * endpoints they "own" directly. Currently the AP does not use the IPA + * filtering functionality. + * + * This diagram shows an example of a filter table with an endpoint + * bitmap as defined prior to IPA v5.0. * * IPA Filter Table * ---------------------- @@ -658,12 +671,6 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool filter) * when a route table is initialized or reset, its entries are made to ref= er * to the zero rule. The zero rule is shared for route and filter tables. * - * Note that the IPA hardware requires a filter or route rule address to be - * aligned on a 128 byte boundary. The coherent DMA buffer we allocate he= re - * has a minimum alignment, and we place the zero rule at the base of that - * allocated space. In ipa_table_init() we verify the minimum DMA allocat= ion - * meets our requirement. - * * +-------------------+ * --> | zero rule | * / |-------------------| @@ -708,12 +715,16 @@ int ipa_table_init(struct ipa *ipa) /* First slot is the zero rule */ *virt++ =3D 0; =20 - /* Next is the filter table bitmap. The "soft" bitmap value - * must be converted to the hardware representation by shifting - * it left one position. (Bit 0 repesents global filtering, - * which is possible but not used.) + /* Next is the filter table bitmap. The "soft" bitmap value might + * need to be converted to the hardware representation by shifting + * it left one position. Prior to IPA v5.0, bit 0 repesents global + * filtering, which is possible but not used. IPA v5.0+ eliminated + * that option, so there's no shifting required. */ - *virt++ =3D cpu_to_le64((u64)ipa->filter_map << 1); + if (ipa->version < IPA_VERSION_5_0) + *virt++ =3D cpu_to_le64((u64)ipa->filter_map << 1); + else + *virt++ =3D cpu_to_le64((u64)ipa->filter_map); =20 /* All the rest contain the DMA address of the zero rule */ le_addr =3D cpu_to_le64(addr); --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 7A7D0ECAAA1 for ; Thu, 27 Oct 2022 12:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235067AbiJ0M1B (ORCPT ); Thu, 27 Oct 2022 08:27:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235557AbiJ0M0n (ORCPT ); Thu, 27 Oct 2022 08:26:43 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43D9134AB3 for ; Thu, 27 Oct 2022 05:26:42 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id y143so461056iof.9 for ; Thu, 27 Oct 2022 05:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PANmuigY2dyK4ROc5rs4Gly3suQYhUI4Jvo2R9OvA2c=; b=CNIPTfja4d7m0UUvAc898mJLSi8nuvTEtwk390CUT8LLOZ1Yvw6rMwssAbUQFEmB83 AAw/OYfkSg+b5It3jiavbaVjKPJ0VxHdydf4Hhueu2M7P+4oLvjAhR4ulNs4E5JQZNmO uTAtYpTZPKgwt4wJDjtzIAWZSaBYSTmslPpv47BzwfOekUMR5BhdZUj6C4sTCqkv/c1v gN6Qc9qFT0qpNKM5yEgRvsZrTXd729hp6tYoReRAuibU+gujlXUbdWW9IKJpvzvoYb+L fQy1m6utqPHp+d/BceLWEMvQzR6AphefF06vF4AoXgzIpg4+mckq3xlpgN7de5E8680J FGlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PANmuigY2dyK4ROc5rs4Gly3suQYhUI4Jvo2R9OvA2c=; b=q8hwSKSVjNdPhDZY/6rm4U7HnySzYo1JAzBXJ3u/TKvOTyMVGJ62LyRkNVL+kU4n+P bVsHhT/Qpm2SS5jAwx1gqZ65BJmgYEadcF75yk2612TAw1OZhzFPaBdPrzhSMe2NMvmx b/oukfD9whSUtj3FBvnEEen6azI8YJGBmWF5jXqRRPCU3U8GGWWxipiGkhEz3AbYhd8M 6uVSJI72101qaAN4Y2AnqNt33IIBtG1TxAElKAO++BZJeFfmF3qrxMrvmN9CazT/J1Zs ByAHXc5Po9/sFyj/WKWA/bQ64IjqpmNZNgQDKgTK4ddjrYNvLjXpX+8lm9YUw7tOgRFc PpSA== X-Gm-Message-State: ACrzQf0QV2/ISNSPl4JCxC/4koRMKrWQhnoQrE629mdH2XQWZLrz5xYU PZxYM9KYp4nCC/iuriMsZDyePg== X-Google-Smtp-Source: AMsMyM7948ncau+MksGbU5iwfardCsWRE6DiqjByPQPSPYOlju6O4NNT+XrwmwJHOTge3Q4AeyB9bg== X-Received: by 2002:a02:c90a:0:b0:363:2b87:887c with SMTP id t10-20020a02c90a000000b003632b87887cmr31914891jao.72.1666873602491; Thu, 27 Oct 2022 05:26:42 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:41 -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, andersson@kernel.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/7] net: ipa: more completely check endpoint validity Date: Thu, 27 Oct 2022 07:26:29 -0500 Message-Id: <20221027122632.488694-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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" Ensure all defined TX endpoints are in the range [0, CONS_PIPES) and defined RX endpoints are within [PROD_LOWEST, PROD_LOWEST+PROD_PIPES). Modify the way local variables are used to make the checks easier to understand. Check for each endpoint being in valid range in the loop, and drop the logical-AND check of initialized against unavailable IDs. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 67 +++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 093e11ec7c2d1..6fc3cc6379fb0 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1843,14 +1843,13 @@ int ipa_endpoint_config(struct ipa *ipa) struct device *dev =3D &ipa->pdev->dev; const struct ipa_reg *reg; u32 initialized; + u32 tx_count; + u32 rx_count; u32 rx_base; - u32 rx_mask; - u32 tx_mask; - int ret =3D 0; - u32 max; + u32 limit; u32 val; =20 - /* Prior to IPAv3.5, the FLAVOR_0 register was not supported. + /* Prior to IPA v3.5, the FLAVOR_0 register was not supported. * Furthermore, the endpoints were not grouped such that TX * endpoint numbers started with 0 and RX endpoints had numbers * higher than all TX endpoints, so we can't do the simple @@ -1866,33 +1865,25 @@ int ipa_endpoint_config(struct ipa *ipa) } =20 /* Find out about the endpoints supplied by the hardware, and ensure - * the highest one doesn't exceed the number we support. + * the highest one doesn't exceed the number supported by software. */ reg =3D ipa_reg(ipa, FLAVOR_0); val =3D ioread32(ipa->reg_virt + ipa_reg_offset(reg)); =20 - /* Our RX is an IPA producer */ + /* Our RX is an IPA producer; our TX is an IPA consumer. */ + tx_count =3D ipa_reg_decode(reg, MAX_CONS_PIPES, val); + rx_count =3D ipa_reg_decode(reg, MAX_PROD_PIPES, val); rx_base =3D ipa_reg_decode(reg, PROD_LOWEST, val); - max =3D rx_base + ipa_reg_decode(reg, MAX_PROD_PIPES, val); - if (max > IPA_ENDPOINT_MAX) { - dev_err(dev, "too many endpoints (%u > %u)\n", - max, IPA_ENDPOINT_MAX); + + limit =3D rx_base + rx_count; + if (limit > IPA_ENDPOINT_MAX) { + dev_err(dev, "too many endpoints, %u > %u\n", + limit, IPA_ENDPOINT_MAX); return -EINVAL; } - rx_mask =3D GENMASK(max - 1, rx_base); =20 - /* Our TX is an IPA consumer */ - max =3D ipa_reg_decode(reg, MAX_CONS_PIPES, val); - tx_mask =3D GENMASK(max - 1, 0); - - ipa->available =3D rx_mask | tx_mask; - - /* Check for initialized endpoints not supported by the hardware */ - if (ipa->initialized & ~ipa->available) { - dev_err(dev, "unavailable endpoint id(s) 0x%08x\n", - ipa->initialized & ~ipa->available); - ret =3D -EINVAL; /* Report other errors too */ - } + /* Mark all supported RX and TX endpoints as available */ + ipa->available =3D GENMASK(limit - 1, rx_base) | GENMASK(tx_count - 1, 0); =20 initialized =3D ipa->initialized; while (initialized) { @@ -1901,16 +1892,32 @@ int ipa_endpoint_config(struct ipa *ipa) =20 initialized ^=3D BIT(endpoint_id); =20 - /* Make sure it's pointing in the right direction */ - endpoint =3D &ipa->endpoint[endpoint_id]; - if ((endpoint_id < rx_base) !=3D endpoint->toward_ipa) { - dev_err(dev, "endpoint id %u wrong direction\n", + if (endpoint_id >=3D limit) { + dev_err(dev, "invalid endpoint id, %u > %u\n", + endpoint_id, limit - 1); + return -EINVAL; + } + + if (!(BIT(endpoint_id) & ipa->available)) { + dev_err(dev, "unavailable endpoint id %u\n", endpoint_id); - ret =3D -EINVAL; + return -EINVAL; } + + /* Make sure it's pointing in the right direction */ + endpoint =3D &ipa->endpoint[endpoint_id]; + if (endpoint->toward_ipa) { + if (endpoint_id < tx_count) + continue; + } else if (endpoint_id >=3D rx_base) { + continue; + } + + dev_err(dev, "endpoint id %u wrong direction\n", endpoint_id); + return -EINVAL; } =20 - return ret; + return 0; } =20 void ipa_endpoint_deconfig(struct ipa *ipa) --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 C165BECAAA1 for ; Thu, 27 Oct 2022 12:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235655AbiJ0M1H (ORCPT ); Thu, 27 Oct 2022 08:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235599AbiJ0M0p (ORCPT ); Thu, 27 Oct 2022 08:26:45 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 770C0144E18 for ; Thu, 27 Oct 2022 05:26:44 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id y143so461115iof.9 for ; Thu, 27 Oct 2022 05:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lh1EaQjT2Reomce8kVVBzGzrDBNIcwVObojZzaiEYwI=; b=Aoj+E+2QqQ3GfZknmX8bjYVVjTqTknVXBgtukTrN+IiQ4/sLUoSqr3DsM1gal3O6XR T6eGVNVcmHM0fV8NukcOgwGlPAyFjHwg3rKS7u+oR+8W5ouHPrWhVuzBeYc0iZrFrkH7 +JYmZ27IfImAqHzt9l/Z1YdogztdX0IwCtYmf70OfcXy4DrvnC4ExQwaSDdr4XOqOdCc 2uaUcxDg0OL7MSfaVGw7hOXCj/7KnPeVs0i16HOhpubwiJfSgGoF57+OZsmjKIuDZ+rU G+chfM0GPoN4ff1z1ufcy60NQNv2BGgNoKS3KQZMvyjwk7SUH3qKX3/qsrQLiM4NJYxS C+AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lh1EaQjT2Reomce8kVVBzGzrDBNIcwVObojZzaiEYwI=; b=i34CdbNvTEfUsEtlqtgQpAV6uRD+NDYEFzjsAiCYeKiNY5REoObgVlqIL+EItWZsDE y0G0s6C/2txUi2x/cyQ1ghSGAze18bkYb+fOatD466TAT1TzW4zIdhOd+/JbsjoukpmE 8w96ylYQ8W8afEpp8OrRXqVjFJEA85VbAQp3LCp4cGl8SAj5Rnx5lKmVnI4Rf2muMTq7 JhDugEhZqDyhKlqYBvuw4BAxiCuKjBm/uzuFruemrpsvLFI7lKhWfcgbybpgfU26TbC5 z61KfO+uViaevnf/9Dl3qI5j5Kfd0FoAX/tag0kTjuwLr7nDUTPezYdTTpTN2M5h/Wz6 NxVg== X-Gm-Message-State: ACrzQf0HPmo5HM1fyGbJgFgJ9e7q6Om7tcFbAcwtuwWCrLrh2kqnDq0g hd7SuQ4ca2oRpTIpJMAbbEs+OQ== X-Google-Smtp-Source: AMsMyM4fqCIVwfpp8JR3l3QjHc6SdWOigd6nFRNkyDpODhBKAwdNTUDyeG0MwO/3SIaj4r7JmL+ILw== X-Received: by 2002:a05:6638:14cf:b0:365:c889:4285 with SMTP id l15-20020a05663814cf00b00365c8894285mr29372852jak.312.1666873604012; Thu, 27 Oct 2022 05:26:44 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:43 -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, andersson@kernel.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/7] net: ipa: refactor endpoint loops Date: Thu, 27 Oct 2022 07:26:30 -0500 Message-Id: <20221027122632.488694-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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 two functions that iterate over all endpoints to use while loops, using "endpoint_id" as the index variables in both spots. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 6fc3cc6379fb0..740b2e4e0c50a 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -426,10 +426,10 @@ ipa_endpoint_program_suspend(struct ipa_endpoint *end= point, bool enable) */ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable) { - u32 endpoint_id; + u32 endpoint_id =3D 0; =20 - for (endpoint_id =3D 0; endpoint_id < IPA_ENDPOINT_MAX; endpoint_id++) { - struct ipa_endpoint *endpoint =3D &ipa->endpoint[endpoint_id]; + while (endpoint_id < IPA_ENDPOINT_MAX) { + struct ipa_endpoint *endpoint =3D &ipa->endpoint[endpoint_id++]; =20 if (endpoint->ee_id !=3D GSI_EE_MODEM) continue; @@ -1008,10 +1008,10 @@ static void ipa_endpoint_init_hol_block_disable(str= uct ipa_endpoint *endpoint) =20 void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa) { - u32 i; + u32 endpoint_id =3D 0; =20 - for (i =3D 0; i < IPA_ENDPOINT_MAX; i++) { - struct ipa_endpoint *endpoint =3D &ipa->endpoint[i]; + while (endpoint_id < IPA_ENDPOINT_MAX) { + struct ipa_endpoint *endpoint =3D &ipa->endpoint[endpoint_id++]; =20 if (endpoint->toward_ipa || endpoint->ee_id !=3D GSI_EE_MODEM) continue; --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 8E244FA3740 for ; Thu, 27 Oct 2022 12:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235649AbiJ0M1O (ORCPT ); Thu, 27 Oct 2022 08:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235604AbiJ0M0s (ORCPT ); Thu, 27 Oct 2022 08:26:48 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DA4147053 for ; Thu, 27 Oct 2022 05:26:46 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id y143so461176iof.9 for ; Thu, 27 Oct 2022 05:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=epeLvt8lBCaZ5l7avoF50kT1TtYCZEpBvcBKlNT2iwg=; b=ASZTBTVg0XueoY1mvGbHkTi9Ugs5LisP/oDcEfaQOmPS1HYaqq9S6/676ekGpiR3vC UGmIy2WKb2YUQPBdPfh4H/TZsoRvP8FO3XsAIPgrc3wzmtxeKeIXKrSfzN/I4HztApCU pGuLaS4tJlPkem/X7itLVokqzg+g9nvzSj5yFXYu6Sf1r1j45Eepd+hfbhyFxPAYt+YP WuhnKJ/6SvlDpfivLdVOzukQ294KArdt7oeMW7jQCG9Qmuz/SiUhdODIUm8it+oDHlmg DeW59JdtbrEHqowOpFKFDfgXZzRi29ncMWVW7Q9L6XJQvSGUhLxkjTZf1krqzaDKOvJw Yl9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=epeLvt8lBCaZ5l7avoF50kT1TtYCZEpBvcBKlNT2iwg=; b=F0h1mwhnXuQYcpNAvFMsZxW9OLI6tsWPg7pCekaiSPOq25nOiORlOaY0ZEPe34xKEa c7hKDmHkv1pw8qzWZ2E/ev0k3J6qcchMaMF8u9haAFT//XKVpu3TlKA+ZGjs0FMOhxKE jbB7M7aF86FkC0SZpAfHE7/zJnGJgFQYWimGl21uVZkgvrpKkf7tjoFgVL/U0W8lHWSZ BHkHMfD6+8FaNNg18L/gKDvZ5DrzzxN9KclAT0mX+9vlHIL68hge5k2E+VTJ/5sPTl4b LbNiYK8pBAW8lt9x9ESNMOH3JU5vbi5A9jbrsiHALUVfKN3FCsE57fIhRl9jmwt9tuTQ y4Dw== X-Gm-Message-State: ACrzQf2hCJlYLB7zS7qa+ZAlcpEUPtNa5MjoCNpCd2rQP55YsX0jSrw/ EbBjtk18tDqpDxOzymup2rrylA== X-Google-Smtp-Source: AMsMyM6ni5QhUhys+hLhqfkIp7C+QW9+qOAkWkXOowfVcKCznQjFWQgqgckN5rrzBZOwgl6zplX0ww== X-Received: by 2002:a02:2242:0:b0:375:29b5:b885 with SMTP id o63-20020a022242000000b0037529b5b885mr935862jao.162.1666873605571; Thu, 27 Oct 2022 05:26:45 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:44 -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, andersson@kernel.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/7] net: ipa: determine the maximum endpoint ID Date: Thu, 27 Oct 2022 07:26:31 -0500 Message-Id: <20221027122632.488694-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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 endpoint ID has an entry in the IPA endpoint array. But the size of that array is defined at compile time. Instead, rename ipa_endpoint_data_valid() to be ipa_endpoint_max() and have it return the maximum endpoint ID defined in configuration data. That function will still validate configuration data. Zero is returned on error; it's a valid endpoint ID, but we need more than one, so it can't be the maximum. The next patch makes use of the returned maximum value. Finally, rename the "initialized" mask of endpoints defined by configuration data to be "defined". Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 6 +-- drivers/net/ipa/ipa_endpoint.c | 67 ++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 82225316a2e25..e975f63271c96 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -61,9 +61,9 @@ struct ipa_interrupt; * @zero_addr: DMA address of preallocated zero-filled memory * @zero_virt: Virtual address of preallocated zero-filled memory * @zero_size: Size (bytes) of preallocated zero-filled memory + * @defined: Bit mask indicating endpoints defined in config data * @available: Bit mask indicating endpoints hardware supports * @filter_map: Bit mask indicating endpoints that support filtering - * @initialized: Bit mask indicating endpoints initialized * @set_up: Bit mask indicating endpoints set up * @enabled: Bit mask indicating endpoints enabled * @modem_tx_count: Number of defined modem TX endoints @@ -117,9 +117,9 @@ struct ipa { size_t zero_size; =20 /* Bit masks indicating endpoint state */ - u32 available; /* supported by hardware */ + u32 defined; /* Defined in configuration data */ + u32 available; /* Supported by hardware */ u32 filter_map; - u32 initialized; u32 set_up; u32 enabled; =20 diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 740b2e4e0c50a..9fd72ba149afa 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -243,42 +243,47 @@ static bool ipa_endpoint_data_valid_one(struct ipa *i= pa, u32 count, return true; } =20 -static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count, - const struct ipa_gsi_endpoint_data *data) +/* Validate endpoint configuration data. Return max defined endpoint ID */ +static u32 ipa_endpoint_max(struct ipa *ipa, u32 count, + const struct ipa_gsi_endpoint_data *data) { const struct ipa_gsi_endpoint_data *dp =3D data; struct device *dev =3D &ipa->pdev->dev; enum ipa_endpoint_name name; + u32 max; =20 if (count > IPA_ENDPOINT_COUNT) { dev_err(dev, "too many endpoints specified (%u > %u)\n", count, IPA_ENDPOINT_COUNT); - return false; + return 0; } =20 /* Make sure needed endpoints have defined data */ if (ipa_gsi_endpoint_data_empty(&data[IPA_ENDPOINT_AP_COMMAND_TX])) { dev_err(dev, "command TX endpoint not defined\n"); - return false; + return 0; } if (ipa_gsi_endpoint_data_empty(&data[IPA_ENDPOINT_AP_LAN_RX])) { dev_err(dev, "LAN RX endpoint not defined\n"); - return false; + return 0; } if (ipa_gsi_endpoint_data_empty(&data[IPA_ENDPOINT_AP_MODEM_TX])) { dev_err(dev, "AP->modem TX endpoint not defined\n"); - return false; + return 0; } if (ipa_gsi_endpoint_data_empty(&data[IPA_ENDPOINT_AP_MODEM_RX])) { dev_err(dev, "AP<-modem RX endpoint not defined\n"); - return false; + return 0; } =20 - for (name =3D 0; name < count; name++, dp++) + max =3D 0; + for (name =3D 0; name < count; name++, dp++) { if (!ipa_endpoint_data_valid_one(ipa, count, data, dp)) - return false; + return 0; + max =3D max_t(u32, max, dp->endpoint_id); + } =20 - return true; + return max; } =20 /* Allocate a transaction to use on a non-command endpoint */ @@ -448,7 +453,7 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool= enable) /* Reset all modem endpoints to use the default exception endpoint */ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) { - u32 initialized =3D ipa->initialized; + u32 defined =3D ipa->defined; struct gsi_trans *trans; u32 count; =20 @@ -463,13 +468,13 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa= *ipa) return -EBUSY; } =20 - while (initialized) { - u32 endpoint_id =3D __ffs(initialized); + while (defined) { + u32 endpoint_id =3D __ffs(defined); struct ipa_endpoint *endpoint; const struct ipa_reg *reg; u32 offset; =20 - initialized ^=3D BIT(endpoint_id); + defined ^=3D BIT(endpoint_id); =20 /* We only reset modem TX endpoints */ endpoint =3D &ipa->endpoint[endpoint_id]; @@ -1812,13 +1817,13 @@ static void ipa_endpoint_teardown_one(struct ipa_en= dpoint *endpoint) =20 void ipa_endpoint_setup(struct ipa *ipa) { - u32 initialized =3D ipa->initialized; + u32 defined =3D ipa->defined; =20 ipa->set_up =3D 0; - while (initialized) { - u32 endpoint_id =3D __ffs(initialized); + while (defined) { + u32 endpoint_id =3D __ffs(defined); =20 - initialized ^=3D BIT(endpoint_id); + defined ^=3D BIT(endpoint_id); =20 ipa_endpoint_setup_one(&ipa->endpoint[endpoint_id]); } @@ -1842,10 +1847,10 @@ int ipa_endpoint_config(struct ipa *ipa) { struct device *dev =3D &ipa->pdev->dev; const struct ipa_reg *reg; - u32 initialized; u32 tx_count; u32 rx_count; u32 rx_base; + u32 defined; u32 limit; u32 val; =20 @@ -1885,12 +1890,12 @@ int ipa_endpoint_config(struct ipa *ipa) /* Mark all supported RX and TX endpoints as available */ ipa->available =3D GENMASK(limit - 1, rx_base) | GENMASK(tx_count - 1, 0); =20 - initialized =3D ipa->initialized; - while (initialized) { - u32 endpoint_id =3D __ffs(initialized); + defined =3D ipa->defined; + while (defined) { + u32 endpoint_id =3D __ffs(defined); struct ipa_endpoint *endpoint; =20 - initialized ^=3D BIT(endpoint_id); + defined ^=3D BIT(endpoint_id); =20 if (endpoint_id >=3D limit) { dev_err(dev, "invalid endpoint id, %u > %u\n", @@ -1943,24 +1948,24 @@ static void ipa_endpoint_init_one(struct ipa *ipa, = enum ipa_endpoint_name name, endpoint->toward_ipa =3D data->toward_ipa; endpoint->config =3D data->endpoint.config; =20 - ipa->initialized |=3D BIT(endpoint->endpoint_id); + ipa->defined |=3D BIT(endpoint->endpoint_id); } =20 static void ipa_endpoint_exit_one(struct ipa_endpoint *endpoint) { - endpoint->ipa->initialized &=3D ~BIT(endpoint->endpoint_id); + endpoint->ipa->defined &=3D ~BIT(endpoint->endpoint_id); =20 memset(endpoint, 0, sizeof(*endpoint)); } =20 void ipa_endpoint_exit(struct ipa *ipa) { - u32 initialized =3D ipa->initialized; + u32 defined =3D ipa->defined; =20 - while (initialized) { - u32 endpoint_id =3D __fls(initialized); + while (defined) { + u32 endpoint_id =3D __fls(defined); =20 - initialized ^=3D BIT(endpoint_id); + defined ^=3D BIT(endpoint_id); =20 ipa_endpoint_exit_one(&ipa->endpoint[endpoint_id]); } @@ -1977,10 +1982,10 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, =20 BUILD_BUG_ON(!IPA_REPLENISH_BATCH); =20 - if (!ipa_endpoint_data_valid(ipa, count, data)) + if (!ipa_endpoint_max(ipa, count, data)) return 0; /* Error */ =20 - ipa->initialized =3D 0; + ipa->defined =3D 0; =20 filter_map =3D 0; for (name =3D 0; name < count; name++, data++) { --=20 2.34.1 From nobody Fri Dec 19 17:43:31 2025 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 82942FA3740 for ; Thu, 27 Oct 2022 12:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235662AbiJ0M1Q (ORCPT ); Thu, 27 Oct 2022 08:27:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235616AbiJ0M0u (ORCPT ); Thu, 27 Oct 2022 08:26:50 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10960148FE4 for ; Thu, 27 Oct 2022 05:26:47 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id r73so988047iod.10 for ; Thu, 27 Oct 2022 05:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s//CwYJkDKmQmM0SN+cOE1kh8GQDyqEkHeEiZBjgvdk=; b=eHDHrj6rkYZwRXHJl18s80X76ciclOcO7haBrN4mR7H7ksv9knqE44zAEEDoWwvb3J Yiy0SYRuE/xQY7sMwFGvrfKegl6t9wX7NaT8ZuwRRHVJxae75Lazwdn61uKXOQRa/jgm CdoWjIHJw4EZMnIwtu9e47+VFZyrNXmK9LtECrFIWtDan6D7v5X4/2MoMygc4e9pcMh1 66FfStTzqJlx6u1Cs1a29z+X4N9sN0n4E6vzIj1+sVKnUYZUyPxNTQKKHa0jJcZfv/vb x0g/GqMNsShZGx640igZMY5hvVAEBblAuD9c98ZnlcrczUiqDwmodGXUdsMmXRrH1mfm +URA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s//CwYJkDKmQmM0SN+cOE1kh8GQDyqEkHeEiZBjgvdk=; b=PTDMpvsW8dLVsamA1uU85UhTiy5Y0r1zM3+HQTMQcEEdmAK9/PIAs7wGgMliIHHZy1 llEm4sNDxxmvPxTheIKCkSpzZ0hQNamTddpy2lBYWzGDLQn13N0hgT7SGqIOhGwh7928 A77QAfxAdnjBU3PnsALoWWVqEdLayWTymijz3mjxivtgQo+5Yk9FTPeWAodRr/6UjdxW jJH7TyqpKrWLN8yBeWFcEru90yGvrqPfAp7+xC+RSH4lQfjMbYKSzjrvM/SAZJ5BYunM qeHPeAn8IQRVmw9dtKeaHaMgDu69s/oRBWyXpn9Iaqd+W7ZrvpEwan/p3LbmS6uIjo1d Byfg== X-Gm-Message-State: ACrzQf2nMgSCkYXRFJ3l3OQ+qD0+BxySdftXnElUQGGuEWVAy1c7PFWb lwpARf/V7H/RMsStmFaAv/a2Rg== X-Google-Smtp-Source: AMsMyM7zyLreCWigjz7BlESkxMCNzJ30WUCWZB4iTQ65X/QUaRYil72JOYdB5LABJDY0+5acBg1pxw== X-Received: by 2002:a05:6638:300e:b0:35a:ab7a:4509 with SMTP id r14-20020a056638300e00b0035aab7a4509mr32112847jak.82.1666873607157; Thu, 27 Oct 2022 05:26:47 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003566ff0eb13sm526528jao.34.2022.10.27.05.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:26:46 -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, andersson@kernel.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 7/7] net: ipa: record and use the number of defined endpoint IDs Date: Thu, 27 Oct 2022 07:26:32 -0500 Message-Id: <20221027122632.488694-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027122632.488694-1-elder@linaro.org> References: <20221027122632.488694-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" Define a new field in the IPA structure that records the maximum number of entries that will be used in the IPA endpoint array. Use that value rather than IPA_ENDPOINT_MAX to determine the end condition for two loops that iterate over all endpoints. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 2 ++ drivers/net/ipa/ipa_endpoint.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index e975f63271c96..a44595575d066 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -61,6 +61,7 @@ struct ipa_interrupt; * @zero_addr: DMA address of preallocated zero-filled memory * @zero_virt: Virtual address of preallocated zero-filled memory * @zero_size: Size (bytes) of preallocated zero-filled memory + * @endpoint_count: Number of endpoints represented by bit masks below * @defined: Bit mask indicating endpoints defined in config data * @available: Bit mask indicating endpoints hardware supports * @filter_map: Bit mask indicating endpoints that support filtering @@ -117,6 +118,7 @@ struct ipa { size_t zero_size; =20 /* Bit masks indicating endpoint state */ + u32 endpoint_count; u32 defined; /* Defined in configuration data */ u32 available; /* Supported by hardware */ u32 filter_map; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 9fd72ba149afa..2a6184ea8f5ca 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -433,7 +433,7 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool= enable) { u32 endpoint_id =3D 0; =20 - while (endpoint_id < IPA_ENDPOINT_MAX) { + while (endpoint_id < ipa->endpoint_count) { struct ipa_endpoint *endpoint =3D &ipa->endpoint[endpoint_id++]; =20 if (endpoint->ee_id !=3D GSI_EE_MODEM) @@ -1015,7 +1015,7 @@ void ipa_endpoint_modem_hol_block_clear_all(struct ip= a *ipa) { u32 endpoint_id =3D 0; =20 - while (endpoint_id < IPA_ENDPOINT_MAX) { + while (endpoint_id < ipa->endpoint_count) { struct ipa_endpoint *endpoint =3D &ipa->endpoint[endpoint_id++]; =20 if (endpoint->toward_ipa || endpoint->ee_id !=3D GSI_EE_MODEM) @@ -1982,7 +1982,9 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, =20 BUILD_BUG_ON(!IPA_REPLENISH_BATCH); =20 - if (!ipa_endpoint_max(ipa, count, data)) + /* Number of endpoints is one more than the maximum ID */ + ipa->endpoint_count =3D ipa_endpoint_max(ipa, count, data) + 1; + if (!ipa->endpoint_count) return 0; /* Error */ =20 ipa->defined =3D 0; --=20 2.34.1