From patchwork Sun Oct 30 00:18:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1566981wru; Sat, 29 Oct 2022 17:19:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40i7cMcelGZOzHK8324h6kkg/Iupw9zkIHAwoeOi6cVOxHKs+f5uXI+oBFN/GSCbz8lgQr X-Received: by 2002:a05:6a00:189f:b0:56b:b192:cda with SMTP id x31-20020a056a00189f00b0056bb1920cdamr6713359pfh.2.1667089173518; Sat, 29 Oct 2022 17:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089173; cv=none; d=google.com; s=arc-20160816; b=a3XkOke+1ciAEnn+9ilf5nnPYxsTvJbt+illDmymy2grZPXy98absIIUzqznEMUh87 nXL6IEb87vBwX9rvn2NFYoAWx2Aknq6hJd9yaLoOuyKl7X4xtPC6rqEKFw6gBlsU1VDe ctogfXgwY7FvRvG/WPtsZhYC/eGROsgYSH2RP47Nk2YYvL1V2lo5iaFiwhCSTo17r3qX CBVuhTeKFXMt1u3cHHWsA56OR0PZomkaMRgpUelbCjZQJSktzEyx76NTpS37XysygWj0 bhPcT2ZkiWpuhZv12gvTzEUK+zSxsuwhpEXUUedLlmhkHYXhaMTDaKpAIrZ+OIfWn2aw tpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=Uqe94PHTpVW+vRMvVc4xWrol6W9nU0dyAP4+XvVD/IZu2PnX2bF0RdaSCrQQ8DngWe Bh5TjEuUq/AmUS1hg/0AryhZQiOQfWGh/7p4B7nnlxeCZyvgHijBYry59jCCoiBtpERy V3x3aqWKhz8D1cCJnYCIP99eCCnO10EU/d5tU7qR+DFjEAOkqvziq0rX3IABu+c8juU8 +UVK83KGAOiwMssIP2iUoYJ2UX1bOci5rLWSkYPmk/amFvc5m56J+TTjl6i9ge7Uv/W1 XgQJm1KVyGEpOnx026hhHdTQB6MdBZUGUV4bBY9mDDo0IJ3zhlKb1CKpM5RV2Ir3sS7x q4nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mFRjU8Vy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a056a0023c800b0056b345b7f5dsi4058587pfc.26.2022.10.29.17.19.21; Sat, 29 Oct 2022 17:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mFRjU8Vy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiJ3ASn (ORCPT + 99 others); Sat, 29 Oct 2022 20:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiJ3ASj (ORCPT ); Sat, 29 Oct 2022 20:18:39 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82C3F24F0E for ; Sat, 29 Oct 2022 17:18:37 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id c65so4043704iof.1 for ; Sat, 29 Oct 2022 17:18:37 -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=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=mFRjU8VyCMQFZRCnmc4mwYxK+EmqfjHKvJdfbxtCfqCmyc+cIS3KWFHcrPH9Gr4zK0 DQDAVd2KM4lAPKzPybAPi5GZSKCtvMUo6o58yZNMtZG4puUEOEH+JgBPlkmXk4F9jDCE EMt1/tsIpvz8pma7RpR3XB3zCKSFUxSO5lAaFaFmpk7WvjBzzfr1TfXflvLlX7UZ5Uv6 /IMjXQyjDlVFjJaagS28/wvIbhFgYjEvaMDKqGJqCWolf8oNCR+WeLPRHPwgIZvnjKNj ++L4cmYnzIJpm1i7Tf2P0a7QqO7ErkomGkoBqCRjTt9dZn4R+nYFMzE0/sMBwQ+HVedp PSGg== 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=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=4wXIlpOOJGMZAKZAMvkXg1j7HsHiq7382j//gp6Ol0YUmvtuJct7V3A3C3cyO1F/xk 7HqSX1Ss1GGydQhQujP+6kSrNXhy3SRZTbfmS7+t6UHqwG8c3Vl13SOYAtJfcOLYqPp2 h29oaZnmVOj6ad7u0EU3Xe6JW2Dn+lBF0wdnUtHvSDmvAF+It2brYLfbL71MVT99Rqc6 5PvK+DzkyDb22eILR6VUYzgcK/w5PynIEnxTKV7aLPtP0jneOaOJ+ZO2hCGTYkn0qoTH 2LIBbBHAd0ddW+ieu/nZzDy7Nv7Jl1mZYTBJkgBjhoq0MSoNOedPNYZPLwGJ+5YLozOp sFIg== X-Gm-Message-State: ACrzQf2g5uER5Wl3iM/yea9M+jFDdm1vGMhYoO0y32/MPp9L0n5F5oBJ /S7IhwOv6ek7zVPSLNfNxRfkUw== X-Received: by 2002:a6b:3ec5:0:b0:6ce:16bf:2e8e with SMTP id l188-20020a6b3ec5000000b006ce16bf2e8emr777958ioa.160.1667089116799; Sat, 29 Oct 2022 17:18:36 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18: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, 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/9] net: ipa: reduce arguments to ipa_table_init_add() Date: Sat, 29 Oct 2022 19:18:20 -0500 Message-Id: <20221030001828.754010-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069697523846869?= X-GMAIL-MSGID: =?utf-8?q?1748069697523846869?= Recently ipa_table_mem() was added as a way to look up one of 8 possible memory regions by indicating whether it was a filter or route table, hashed or not, and IPv6 or not. We can simplify the interface to ipa_table_init_add() by passing two flags to it instead of the opcode and both hashed and non-hashed memory region IDs. The "filter" and "ipv6" flags are sufficient to determine the opcode to use, and with ipa_table_mem() can look up the correct memory region as well. It's possible to not have hashed tables, but we already verify the number of entries in a filter or routing table is nonzero. Stop assuming a hashed table entry exists in ipa_table_init_add(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index cf3a3de239dc3..94bb7611e574b 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -376,14 +376,12 @@ int ipa_table_hash_flush(struct ipa *ipa) return 0; } -static void ipa_table_init_add(struct gsi_trans *trans, bool filter, - enum ipa_cmd_opcode opcode, - enum ipa_mem_id mem_id, - enum ipa_mem_id hash_mem_id) +static void ipa_table_init_add(struct gsi_trans *trans, bool filter, bool ipv6) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *hash_mem = ipa_mem_find(ipa, hash_mem_id); - const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); + const struct ipa_mem *hash_mem; + enum ipa_cmd_opcode opcode; + const struct ipa_mem *mem; dma_addr_t hash_addr; dma_addr_t addr; u32 zero_offset; @@ -393,6 +391,14 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, u16 count; u16 size; + opcode = filter ? ipv6 ? IPA_CMD_IP_V6_FILTER_INIT + : IPA_CMD_IP_V4_FILTER_INIT + : ipv6 ? IPA_CMD_IP_V6_ROUTING_INIT + : IPA_CMD_IP_V4_ROUTING_INIT; + + mem = ipa_table_mem(ipa, filter, false, ipv6); + hash_mem = ipa_table_mem(ipa, filter, true, ipv6); + /* Compute the number of table entries to initialize */ if (filter) { /* The number of filtering endpoints determines number of @@ -401,13 +407,13 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, * table is either the same as the non-hashed one, or zero. */ count = 1 + hweight32(ipa->filter_map); - hash_count = hash_mem->size ? count : 0; + hash_count = hash_mem && hash_mem->size ? count : 0; } else { /* The size of a route table region determines the number * of entries it has. */ count = mem->size / sizeof(__le64); - hash_count = hash_mem->size / sizeof(__le64); + hash_count = hash_mem && hash_mem->size / sizeof(__le64); } size = count * sizeof(__le64); hash_size = hash_count * sizeof(__le64); @@ -458,17 +464,10 @@ int ipa_table_setup(struct ipa *ipa) return -EBUSY; } - ipa_table_init_add(trans, false, IPA_CMD_IP_V4_ROUTING_INIT, - IPA_MEM_V4_ROUTE, IPA_MEM_V4_ROUTE_HASHED); - - ipa_table_init_add(trans, false, IPA_CMD_IP_V6_ROUTING_INIT, - IPA_MEM_V6_ROUTE, IPA_MEM_V6_ROUTE_HASHED); - - ipa_table_init_add(trans, true, IPA_CMD_IP_V4_FILTER_INIT, - IPA_MEM_V4_FILTER, IPA_MEM_V4_FILTER_HASHED); - - ipa_table_init_add(trans, true, IPA_CMD_IP_V6_FILTER_INIT, - IPA_MEM_V6_FILTER, IPA_MEM_V6_FILTER_HASHED); + ipa_table_init_add(trans, false, false); + ipa_table_init_add(trans, false, true); + ipa_table_init_add(trans, true, false); + ipa_table_init_add(trans, true, true); gsi_trans_commit_wait(trans); From patchwork Sun Oct 30 00:18:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567454wru; Sat, 29 Oct 2022 17:20:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7q3+HK2wifwuhFRRU14Il39Igfymm/3EnboxQMKYCfq2Zl6pd2m4aXR71xUKJNBuJzUW0H X-Received: by 2002:a17:90b:3504:b0:213:5b03:639 with SMTP id ls4-20020a17090b350400b002135b030639mr22340543pjb.16.1667089254667; Sat, 29 Oct 2022 17:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089254; cv=none; d=google.com; s=arc-20160816; b=Dhhd9Ox6BfKqa0lXB0EgEMnPW6Hi2F1+TJSRZU9f/Gk/q3I6rNS+5z3JxeGRDtoBns E1Y1N2G00OtVOKzXiubB4/8/gDU36zAAB54kQBx/pmmeIz7vYg0/G8JH1GLbYh5dZc23 Rf7AqA8QV9U8QvHXg1LTYy9neJ4zcRN7tT8NcrKTc5Hfkj3F3OolYxYhmkXspbltHGCG wBNgUeRDAi37IebAjlcP6r0wxBeVxy7oKVaU7QRlKH0GM7Lh6hOvyj2yp3wW1k3dH/HS FIBJOaXk/WVj8r3uBk5gVO3kOam249IKEpAMFgmODq6Nkbey+NUgxfHOqQC/BKiC/PsZ fCiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lCQLB8py1X/NJwP3+BLi4r+G0VNoFsbUa3BWr+xCFoQ=; b=QigVw1oDf54zf4SR5SOB7U14xUop7xBFtnbh8Joqg3NVcwAHJHz5K6xMcC796B6WvI O69OpWlVeekHan/TvwDRywvvKx+MvJDGk0VEQHcWFu5fzk1gzMxC4D3+J4taI2QzUNfX gPA5gVKcea1Brgiupo9p746gi07D+A36hQrfCIa0WfOK18uRdEmaKOyyxABSeEU51P+D +kEpz0tXCqQ43eSgBBoo2KnUJqaOiqYtuwA+YIxmv0WYuQ359nTaldoHTG69oLHecL5P e73qpWpq63Fen/aU1zooUJVMAH5KNhBXQgSyZktscSKelFrEcCunw4CgGyBKEyBslAR7 OttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jmHp3teu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z21-20020a63e115000000b00439c1e186c8si3547271pgh.281.2022.10.29.17.20.41; Sat, 29 Oct 2022 17:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jmHp3teu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbiJ3ASz (ORCPT + 99 others); Sat, 29 Oct 2022 20:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbiJ3ASk (ORCPT ); Sat, 29 Oct 2022 20:18:40 -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 7CDB724BE7 for ; Sat, 29 Oct 2022 17:18:39 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id m15so2556715ilq.2 for ; Sat, 29 Oct 2022 17:18:39 -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=lCQLB8py1X/NJwP3+BLi4r+G0VNoFsbUa3BWr+xCFoQ=; b=jmHp3teuCYigeQt5u903OOVQ/7tU565Ceuoo6r+WKRicQaxX9/qE2YA1qGRDG+YMdE 7uRTAfkhzLe8y/gNNUeTDclMFbUWslOXbXddHaCasYQ0H4j9PvoHdq3yniv5koNpfQ/N lv08Elpb6jFc+MoRgQTFGSqSIfuG6nthwoytr5v06vdcDbTVmVQUXyoYs9qXpBDti4UD UdbVs62YN6Hm1wMry6Y5rNB8hI4RlnZwWHai+gBN3z31leL9xLKRXQO27zoOimEE59zJ lmEqqJn74/bGFEluyielEKYZ2Zt4G+npO5j081lqW4VCdDXX714kv2qMWva0t15zlE8p OhcQ== 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=lCQLB8py1X/NJwP3+BLi4r+G0VNoFsbUa3BWr+xCFoQ=; b=ymoEdhHp2kRLdGavP2k5efh/DKGaC/88a2fs3QhoVLXFNj+4YpUU+NuX88WfEJ/3Pm xll6djC5tCIOf6DJVEq3y7yp2dM83AavBaE4O0tpa8a5OuWEsJUBqDxRqqiYzxABz+/2 NyL0hyrbHTKPEMxz1e6QrRO+r2lw8R93jeDVhhSYbpLq66X6oSjMlnCrXzr/HjoiWyoO 7NaehYkNoy8HRjp6mjd0oqR74McJ8H3xzREuZ3L6/7H4XcPPlob4+MBNkSqetQCYWkdR 5zuyFbCJ5NK5jCH4tN5HJHBOx2MYAi9Q4Imtmtci9TRsi/7RfEraDhtCsAmdrUE2Jung DGxQ== X-Gm-Message-State: ACrzQf1oa3/d86cwFZ6QpZgf3SyFrENrUKasu+kut/Mfrv2+duJ9ohkN 4W+dCvZdqrPuRz7MvjPn0/GarQ== X-Received: by 2002:a05:6e02:152e:b0:2f9:e082:7fc7 with SMTP id i14-20020a056e02152e00b002f9e0827fc7mr3011352ilu.167.1667089118791; Sat, 29 Oct 2022 17:18:38 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18: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, 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/9] net: ipa: use ipa_table_mem() in ipa_table_reset_add() Date: Sat, 29 Oct 2022 19:18:21 -0500 Message-Id: <20221030001828.754010-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069782435536079?= X-GMAIL-MSGID: =?utf-8?q?1748069782435536079?= Similar to the previous commit, pass flags rather than a memory region ID to ipa_table_reset_add(), and there use ipa_table_mem() to look up the memory region affected based on those flags. Currently all eight of these table memory regions are assumed to exist, because they all have canaries within them. Stop assuming that will always be the case, and in ipa_table_reset_add() allow these memory regions to be non-existent. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 94bb7611e574b..3a14465bf8a64 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -200,16 +200,17 @@ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) } static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, - u16 first, u16 count, enum ipa_mem_id mem_id) + bool hashed, bool ipv6, u16 first, u16 count) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); + const struct ipa_mem *mem; dma_addr_t addr; u32 offset; u16 size; - /* Nothing to do if the table memory region is empty */ - if (!mem->size) + /* Nothing to do if the memory region is doesn't exist or is empty */ + mem = ipa_table_mem(ipa, filter, hashed, ipv6); + if (!mem || !mem->size) return; if (filter) @@ -227,7 +228,7 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, * for the IPv4 and IPv6 non-hashed and hashed filter tables. */ static int -ipa_filter_reset_table(struct ipa *ipa, enum ipa_mem_id mem_id, bool modem) +ipa_filter_reset_table(struct ipa *ipa, bool hashed, bool ipv6, bool modem) { u32 ep_mask = ipa->filter_map; u32 count = hweight32(ep_mask); @@ -253,7 +254,7 @@ ipa_filter_reset_table(struct ipa *ipa, enum ipa_mem_id mem_id, bool modem) if (endpoint->ee_id != ee_id) continue; - ipa_table_reset_add(trans, true, endpoint_id, 1, mem_id); + ipa_table_reset_add(trans, true, hashed, ipv6, endpoint_id, 1); } gsi_trans_commit_wait(trans); @@ -269,18 +270,18 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem) { int ret; - ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER, modem); + ret = ipa_filter_reset_table(ipa, false, false, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER_HASHED, modem); + ret = ipa_filter_reset_table(ipa, true, false, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER, modem); + ret = ipa_filter_reset_table(ipa, false, true, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER_HASHED, modem); + ret = ipa_filter_reset_table(ipa, true, true, modem); return ret; } @@ -312,13 +313,11 @@ static int ipa_route_reset(struct ipa *ipa, bool modem) count = ipa->route_count - modem_route_count; } - ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE); - ipa_table_reset_add(trans, false, first, count, - IPA_MEM_V4_ROUTE_HASHED); + ipa_table_reset_add(trans, false, false, false, first, count); + ipa_table_reset_add(trans, false, true, false, first, count); - ipa_table_reset_add(trans, false, first, count, IPA_MEM_V6_ROUTE); - ipa_table_reset_add(trans, false, first, count, - IPA_MEM_V6_ROUTE_HASHED); + ipa_table_reset_add(trans, false, false, true, first, count); + ipa_table_reset_add(trans, false, true, true, first, count); gsi_trans_commit_wait(trans); From patchwork Sun Oct 30 00:18:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567142wru; Sat, 29 Oct 2022 17:20:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6J+AvMe17UiYKhV8so5YpHG5Qq/PvSAyzUTkjStETrQD28jpsCZn0GqArpS+XRyV5scQtk X-Received: by 2002:a17:90b:1d09:b0:213:773a:b4b2 with SMTP id on9-20020a17090b1d0900b00213773ab4b2mr16509759pjb.40.1667089202382; Sat, 29 Oct 2022 17:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089202; cv=none; d=google.com; s=arc-20160816; b=rIEaoUj0NkxRikAbSxnrjkNcd3lcWc+XAbelSVrVlU660KTOT54aMQCdNhV7KfKGQk LrUgqH/GgOl18E2lKwBSsKguhCJui/Bjk8FGk7HmJBNQiNs8s+KQfbfFqyezzJBvZKSu LbEhJzOcOI+Lc288CWzp7na+CwWOHWQJfIEgdEPUBsVfdYJeB5XiOpyW7wqanP+YNU/m sYTOf/BkvIf0hHe5huI/81wLxAE/5g051YKwKlXNTW3qjQd3Zv7y+nKQQ34kieV+GXCQ GALjyx8a161ziSc8c6mjifPQzV6+IK0+W8Psv8Yh1C6xDQBwV7cAzCTTf6oc1Z9FlSMV uyxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=44inpgxMtLGpYTBDTKxPiEfpRDa0k0SEfGcjuP68SFA=; b=qia8IaxStHUeX0cByYi0kXIp3Il3hFm4K7jPLoDLdeKjgj7AzMm9jwa1mkkco9N+hD 0Eul8pMPkFJlPGS0Nzp8vLVOmlhsH4OiLKG0bICzI5X//dvVZY2eXgv9kNalXWVabGGH 0S7+G/nLTYOjUBq0XYwJf+/Z1+WEFnesyVSkf5Zx7IwRTlv0bweIE/dRZ350+un3Ss6m 0EfijpUWRdeRr1G/PS0T9GVrl3rdxXuMMr8HSp5uAX4jQ9m3cZXiHZydSrIXPEfV4PfN iSVXPqs4FNKsqHLRobcUlYE5bZxbpnhJ9WcJLd4bnXFFNOpOFblHesuH2iyCQX/RHu+k 2E/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOU9ISnR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a056a000b4500b0056368cb7d1asi4107352pfo.104.2022.10.29.17.19.49; Sat, 29 Oct 2022 17:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOU9ISnR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiJ3ATA (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJ3ASn (ORCPT ); Sat, 29 Oct 2022 20:18:43 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F59624BE6 for ; Sat, 29 Oct 2022 17:18:41 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id e15so7394602iof.2 for ; Sat, 29 Oct 2022 17:18: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=44inpgxMtLGpYTBDTKxPiEfpRDa0k0SEfGcjuP68SFA=; b=jOU9ISnRJykZ1m9fmF9YXcWG7FDrGdkvHGKbqbLOR3jGAOKl33y1/Vm37lFB3V2Lns SUyfsK3SH8yElF90bnz0+hUW5IZlGTy8UYt3LlY91ESUpWH1B5KncHCyO5BkwRuI1IuD kpgc1XkFXgCX3eomgp0dL9lwl3Dpyyl/gs3h2v+4BUWJDa8JWqYXGqC65FgVjwy2ypf7 M7PyLGXNJt7PpY33LqMwALZMWR8suGTEJnl/RKwks47O/aJ0LgCgBMv4hEkPZEyM7Q80 doBVRPqJ4U1ecgFtJVYRdHRcnkxV5KRrncvo7IBDYdmq8E4Cg4RcbgPMyhR/IP8mUwz4 pX8A== 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=44inpgxMtLGpYTBDTKxPiEfpRDa0k0SEfGcjuP68SFA=; b=BYyJ1vGYWFF2T4AkG2f5RcVfSegqr2x6FhOR+nAfViRN2cmQCnHYBvOjR/UlEqwbid D78C+135O7aByobye2PTPKTaw5WCsxtl3GFheu6eZHXyL0gpSjUXJew6RY0bCOgDbAFy jMur85nLo1EC6Eo5YrkUeSAZQzfSV4AVJ3LA/V2VrYPWvPVbByzwojCR37xam/CyrFS3 M0CNz5yqSw2aooH06NhKV/Sr0+nILqi3WHkWKmji3wMZ6r+ZAATooNXPLe1yDWAy1WmM Uz6MhwkPxl8wC8ZRGpuN9tQJKTVLjIl+bOs6YKyr+jWSYO3OP8/6DfXgYSTUzkOsulqz UXwA== X-Gm-Message-State: ACrzQf12k+scrGOzwdFPr9dSvEAWKk1mRit409QcC5Gm1IdHny7VCETk mYvWtMvHjbg7J0+zg+yzeqZl6g== X-Received: by 2002:a05:6638:1688:b0:364:134b:92cc with SMTP id f8-20020a056638168800b00364134b92ccmr3350849jat.104.1667089120963; Sat, 29 Oct 2022 17:18:40 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18: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/9] net: ipa: add a parameter to aggregation registers Date: Sat, 29 Oct 2022 19:18:22 -0500 Message-Id: <20221030001828.754010-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069727634698275?= X-GMAIL-MSGID: =?utf-8?q?1748069727634698275?= Starting with IPA v5.0, a single IPA instance can have more than 32 endpoints defined. To handle this, each register that holds a bitmap of IPA endpoints is replicated as needed to represent the available endpoints. To prepare for this, registers that represent endpoint IDs in a bit mask will be defined to have a parameter, with a stride value of 4 bytes. The first 32 endpoints are represented in the first 32-bit register, then the next (up to) 32 endpoints at an offset 4 bytes higher. When accessing such a register, the endpoint ID divided by 32 determines the offset, and the endpoint ID modulo 32 defines the endpoint's bit position within the register. The first two registers we'll update for this are STATE_AGGR_ACTIVE and AGGR_FORCE_CLOSE. Until more than 32 endpoints are supported, this change has no practical effect. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 14 ++++++++++---- drivers/net/ipa/reg/ipa_reg-v3.1.c | 4 ++-- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 4 ++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 4 ++-- drivers/net/ipa/reg/ipa_reg-v4.2.c | 4 ++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 4 ++-- drivers/net/ipa/reg/ipa_reg-v4.9.c | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 2a6184ea8f5ca..32559ed498c19 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -350,29 +350,35 @@ ipa_endpoint_program_delay(struct ipa_endpoint *endpoint, bool enable) static bool ipa_endpoint_aggr_active(struct ipa_endpoint *endpoint) { - u32 mask = BIT(endpoint->endpoint_id); + u32 endpoint_id = endpoint->endpoint_id; + u32 mask = BIT(endpoint_id % 32); struct ipa *ipa = endpoint->ipa; + u32 unit = endpoint_id / 32; const struct ipa_reg *reg; u32 val; + /* This works until we actually have more than 32 endpoints */ WARN_ON(!(mask & ipa->available)); reg = ipa_reg(ipa, STATE_AGGR_ACTIVE); - val = ioread32(ipa->reg_virt + ipa_reg_offset(reg)); + val = ioread32(ipa->reg_virt + ipa_reg_n_offset(reg, unit)); return !!(val & mask); } static void ipa_endpoint_force_close(struct ipa_endpoint *endpoint) { - u32 mask = BIT(endpoint->endpoint_id); + u32 endpoint_id = endpoint->endpoint_id; + u32 mask = BIT(endpoint_id % 32); struct ipa *ipa = endpoint->ipa; + u32 unit = endpoint_id / 32; const struct ipa_reg *reg; + /* This works until we actually have more than 32 endpoints */ WARN_ON(!(mask & ipa->available)); reg = ipa_reg(ipa, AGGR_FORCE_CLOSE); - iowrite32(mask, ipa->reg_virt + ipa_reg_offset(reg)); + iowrite32(mask, ipa->reg_virt + ipa_reg_n_offset(reg, unit)); } /** diff --git a/drivers/net/ipa/reg/ipa_reg-v3.1.c b/drivers/net/ipa/reg/ipa_reg-v3.1.c index 0d002c3c38a26..0b6edc2912bd3 100644 --- a/drivers/net/ipa/reg/ipa_reg-v3.1.c +++ b/drivers/net/ipa/reg/ipa_reg-v3.1.c @@ -103,7 +103,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x0000090); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c, 0x0004); IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); @@ -116,7 +116,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_counter_cfg_fmask[] = { [EOT_COAL_GRANULARITY] = GENMASK(3, 0), diff --git a/drivers/net/ipa/reg/ipa_reg-v3.5.1.c b/drivers/net/ipa/reg/ipa_reg-v3.5.1.c index 6e2f939b18f19..10f62f6aaf7a4 100644 --- a/drivers/net/ipa/reg/ipa_reg-v3.5.1.c +++ b/drivers/net/ipa/reg/ipa_reg-v3.5.1.c @@ -108,7 +108,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x0000090); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c, 0x0004); IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); @@ -121,7 +121,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_counter_cfg_fmask[] = { /* Bits 0-3 reserved */ diff --git a/drivers/net/ipa/reg/ipa_reg-v4.11.c b/drivers/net/ipa/reg/ipa_reg-v4.11.c index 8fd36569bb9f8..113a25c006da1 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.11.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.11.c @@ -140,7 +140,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { [IPA_BASE_ADDR] = GENMASK(17, 0), @@ -151,7 +151,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { /* Bits 0-1 reserved */ diff --git a/drivers/net/ipa/reg/ipa_reg-v4.2.c b/drivers/net/ipa/reg/ipa_reg-v4.2.c index f8e78e1907c83..c93f2da9290fc 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.2.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.2.c @@ -132,7 +132,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); @@ -145,7 +145,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_counter_cfg_fmask[] = { /* Bits 0-3 reserved */ diff --git a/drivers/net/ipa/reg/ipa_reg-v4.5.c b/drivers/net/ipa/reg/ipa_reg-v4.5.c index d32b805abb11a..1615c5ead8cc1 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.5.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.5.c @@ -134,7 +134,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { [IPA_BASE_ADDR] = GENMASK(17, 0), @@ -145,7 +145,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { /* Bits 0-1 reserved */ diff --git a/drivers/net/ipa/reg/ipa_reg-v4.9.c b/drivers/net/ipa/reg/ipa_reg-v4.9.c index eabbc5451937b..4efc890d31589 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.9.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.9.c @@ -139,7 +139,7 @@ static const u32 ipa_reg_filt_rout_hash_flush_fmask[] = { IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); /* Valid bits defined by ipa->available */ -IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); +IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { [IPA_BASE_ADDR] = GENMASK(17, 0), @@ -150,7 +150,7 @@ static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); /* Valid bits defined by ipa->available */ -IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); +IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { /* Bits 0-1 reserved */ From patchwork Sun Oct 30 00:18:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567145wru; Sat, 29 Oct 2022 17:20:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ykuq9Sy7gfPxzGnncS+jR0iZh7oldDJdYh9E0/j+jm/96oL7IKkKw2vmyb8De0skG9R5v X-Received: by 2002:a17:902:7c12:b0:186:8111:ade2 with SMTP id x18-20020a1709027c1200b001868111ade2mr6748160pll.111.1667089203103; Sat, 29 Oct 2022 17:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089203; cv=none; d=google.com; s=arc-20160816; b=BN2amCgoMicBzDQBg61qIH6hrbddCu3aEw7Vxm4CftYNpiSdfu84MYbVGIqLdNEpst QjVf3tupehWvpJuqaJnMYZBVfltFplDdP8noP6yLgW0dRR9WIJPzDNlMnEd5rUU309MT 7+7m+cvtzt4bQY9SVDZpdXrRPFw3vT70NxYPmTGkos00lTIWqlh/DizRpOm3g0+mrXfD GbjfgXJkJ1yt7Z/j0E6gul/2nB7XjqWjuGVtlquz6TDxmU/pcmzfIWylLpmIj/sr2PBY FNQFGQspHoMG4w4a65ynawvj6aIITx30k2TUR+kYrYpYTldeL4QUfnBeEOpT+aQB2CWl F3EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZcCihh0f7Qr/rXNZsx/9L0DCMnXVjeXTxfp8VH2CZiE=; b=0YdQ6ZXKvTtK9JJGAjNMKQXKFWGD3OdaWt+oxvvJ2HkdgQlusBk4an5uRh+J+0p5ek hQ/97qEqKijfHxQVtVi8lwLkZ0/L91xTePw6qYnEi9tFZcAuoiLw5zm4Ank/ZC9oC3ar PpHthkNiD1HHrqwstj/WFOGsxuf7q7sceHpPag3z+xpb8/ZSWbXc8CTiE72xbPyBfzbp rV7ohUpcqIW61LdjUQeYk2jTjt4u32lYjcivqCx7P7qQIO8rLKawqZJMASr43qII4VZQ /RP/TjkIRn7yWEtMIGp9bAW7Mn9ML7n23lWqKLKEG3JF8qwWnf/UbdMgAceMAgyEVcs0 POVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LJ2tPsV9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a635b04000000b0046af0960898si3165917pgb.625.2022.10.29.17.19.50; Sat, 29 Oct 2022 17:20:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LJ2tPsV9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiJ3ATC (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbiJ3ASp (ORCPT ); Sat, 29 Oct 2022 20:18:45 -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 8A31A24F27 for ; Sat, 29 Oct 2022 17:18:43 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id l127so7378752iof.12 for ; Sat, 29 Oct 2022 17:18:43 -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=ZcCihh0f7Qr/rXNZsx/9L0DCMnXVjeXTxfp8VH2CZiE=; b=LJ2tPsV9r1KXTlBIXYpW1XKmjCTrupbkXfgVj9o4EUIi20+QTbQ1/Kujr4S8iPxh08 bgw69SDHHrkGXezV/clsAfYHTrbzYxVh3m5wRCVyp5g2yzqV0f5YxQ6YAWzo5xzxDyNV 8VGheGUNkK7N77kfm2HbfQQ/IITpxcD77SSuHBy7gtUe0XqX2smlRokRKcSZWnfmqlqr pWRK2eEA8EXbFPUKGNISZNtzQKNVJjPXLNsYGYxFRFZOaWW2tHfp+MKiZVLNIKGdICXN DLVi4pBzB10LNnt6J3p0q0Frzmk5FmW5rf8Y81dEyw5+7W37fNMntBy+XC/YC4R7bjYB Og+Q== 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=ZcCihh0f7Qr/rXNZsx/9L0DCMnXVjeXTxfp8VH2CZiE=; b=qT/130I154I/c6s3HYmhSJ11weqxW0a9Tfo5PzUI5d1Debfl5gdCt7yhuSKf5rwEdB W7iXYS9Qvp770EzHVJcI94GHpMNljC9KZB2y54wGE2AG+N+YK7eTzCWqtuRlsA5XowqY NYoxFMnXOn2HaIHrD1G2Nt4Iz0yjXDbmQjG+eijGzxzCEN9cAomcDl0TNfSbI3piYFYI 59cHEqfjZFiy2RCi76TqVVh8zmi8TyMrunF5sld1JDc8xxpTRSz+fjU/kJFoOwcQsLKS bK1KMmWPqUXXJMpRIGvILykBeIvoIGf4VNnHNaEuyRALxQCph5KaSqPHH3jGIcx84Hsp i4IA== X-Gm-Message-State: ACrzQf2YHrzUU1OGERq3i7j5w99/Fi7VAgoaKagdNYnM5Orrg3Zap93I xD9DUc3Y82Ah/ne8Mzy4/JmlSg== X-Received: by 2002:a05:6602:2a48:b0:6bc:e1c7:797b with SMTP id k8-20020a0566022a4800b006bce1c7797bmr3103929iov.131.1667089122908; Sat, 29 Oct 2022 17:18:42 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18:42 -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/9] net: ipa: add a parameter to suspend registers Date: Sat, 29 Oct 2022 19:18:23 -0500 Message-Id: <20221030001828.754010-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069727807843548?= X-GMAIL-MSGID: =?utf-8?q?1748069727807843548?= The SUSPEND_INFO, SUSPEND_EN, SUSPEND_CLR registers represent endpoint IDs in a bit mask. When more than 32 endpoints are supported, these registers will be replicated as needed to represent the number of supported endpoints. Update the definitions of these registers to have a stride of 4 bytes, and update the code that operates them to select the proper offset and bit. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 30 ++++++++++++++++++---------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 9 ++++++--- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 9 ++++++--- drivers/net/ipa/reg/ipa_reg-v4.11.c | 9 ++++++--- drivers/net/ipa/reg/ipa_reg-v4.2.c | 9 ++++++--- drivers/net/ipa/reg/ipa_reg-v4.5.c | 9 ++++++--- drivers/net/ipa/reg/ipa_reg-v4.9.c | 9 ++++++--- 7 files changed, 55 insertions(+), 29 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index c269432f9c2ee..a62bc667bda0e 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -132,11 +132,13 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, u32 endpoint_id, bool enable) { struct ipa *ipa = interrupt->ipa; - u32 mask = BIT(endpoint_id); + u32 mask = BIT(endpoint_id % 32); + u32 unit = endpoint_id / 32; const struct ipa_reg *reg; u32 offset; u32 val; + /* This works until we actually have more than 32 endpoints */ WARN_ON(!(mask & ipa->available)); /* IPA version 3.0 does not support TX_SUSPEND interrupt control */ @@ -144,7 +146,7 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, return; reg = ipa_reg(ipa, IRQ_SUSPEND_EN); - offset = ipa_reg_offset(reg); + offset = ipa_reg_n_offset(reg, unit); val = ioread32(ipa->reg_virt + offset); if (enable) val |= mask; @@ -171,18 +173,24 @@ ipa_interrupt_suspend_disable(struct ipa_interrupt *interrupt, u32 endpoint_id) void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt) { struct ipa *ipa = interrupt->ipa; - const struct ipa_reg *reg; - u32 val; + u32 unit_count; + u32 unit; - reg = ipa_reg(ipa, IRQ_SUSPEND_INFO); - val = ioread32(ipa->reg_virt + ipa_reg_offset(reg)); + unit_count = roundup(ipa->endpoint_count, 32); + for (unit = 0; unit < unit_count; unit++) { + const struct ipa_reg *reg; + u32 val; - /* SUSPEND interrupt status isn't cleared on IPA version 3.0 */ - if (ipa->version == IPA_VERSION_3_0) - return; + reg = ipa_reg(ipa, IRQ_SUSPEND_INFO); + val = ioread32(ipa->reg_virt + ipa_reg_n_offset(reg, unit)); - reg = ipa_reg(ipa, IRQ_SUSPEND_CLR); - iowrite32(val, ipa->reg_virt + ipa_reg_offset(reg)); + /* SUSPEND interrupt status isn't cleared on IPA version 3.0 */ + if (ipa->version == IPA_VERSION_3_0) + continue; + + reg = ipa_reg(ipa, IRQ_SUSPEND_CLR); + iowrite32(val, ipa->reg_virt + ipa_reg_n_offset(reg, unit)); + } } /* Simulate arrival of an IPA TX_SUSPEND interrupt */ diff --git a/drivers/net/ipa/reg/ipa_reg-v3.1.c b/drivers/net/ipa/reg/ipa_reg-v3.1.c index 0b6edc2912bd3..677ece3bce9e5 100644 --- a/drivers/net/ipa/reg/ipa_reg-v3.1.c +++ b/drivers/net/ipa/reg/ipa_reg-v3.1.c @@ -386,13 +386,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000301c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00003030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00003030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00003034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00003034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00003038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00003038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, diff --git a/drivers/net/ipa/reg/ipa_reg-v3.5.1.c b/drivers/net/ipa/reg/ipa_reg-v3.5.1.c index 10f62f6aaf7a4..b9c6a50de2436 100644 --- a/drivers/net/ipa/reg/ipa_reg-v3.5.1.c +++ b/drivers/net/ipa/reg/ipa_reg-v3.5.1.c @@ -397,13 +397,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000301c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00003030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00003030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00003034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00003034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00003038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00003038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, diff --git a/drivers/net/ipa/reg/ipa_reg-v4.11.c b/drivers/net/ipa/reg/ipa_reg-v4.11.c index 113a25c006da1..9a315130530dd 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.11.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.11.c @@ -453,13 +453,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000401c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00004030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00004030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00004034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00004034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00004038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00004038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, diff --git a/drivers/net/ipa/reg/ipa_reg-v4.2.c b/drivers/net/ipa/reg/ipa_reg-v4.2.c index c93f2da9290fc..7a95149f8ec7a 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.2.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.2.c @@ -399,13 +399,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000301c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00003030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00003030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00003034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00003034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00003038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00003038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, diff --git a/drivers/net/ipa/reg/ipa_reg-v4.5.c b/drivers/net/ipa/reg/ipa_reg-v4.5.c index 1615c5ead8cc1..587eb8d4e00f7 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.5.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.5.c @@ -472,13 +472,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000301c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00003030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00003030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00003034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00003034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00003038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00003038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, diff --git a/drivers/net/ipa/reg/ipa_reg-v4.9.c b/drivers/net/ipa/reg/ipa_reg-v4.9.c index 4efc890d31589..1f67a03fe5992 100644 --- a/drivers/net/ipa/reg/ipa_reg-v4.9.c +++ b/drivers/net/ipa/reg/ipa_reg-v4.9.c @@ -450,13 +450,16 @@ static const u32 ipa_reg_ipa_irq_uc_fmask[] = { IPA_REG_FIELDS(IPA_IRQ_UC, ipa_irq_uc, 0x0000401c + 0x1000 * GSI_EE_AP); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_INFO, irq_suspend_info, 0x00004030 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_INFO, irq_suspend_info, + 0x00004030 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_EN, irq_suspend_en, 0x00004034 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_EN, irq_suspend_en, + 0x00004034 + 0x1000 * GSI_EE_AP, 0x0004); /* Valid bits defined by ipa->available */ -IPA_REG(IRQ_SUSPEND_CLR, irq_suspend_clr, 0x00004038 + 0x1000 * GSI_EE_AP); +IPA_REG_STRIDE(IRQ_SUSPEND_CLR, irq_suspend_clr, + 0x00004038 + 0x1000 * GSI_EE_AP, 0x0004); static const struct ipa_reg *ipa_reg_array[] = { [COMP_CFG] = &ipa_reg_comp_cfg, From patchwork Sun Oct 30 00:18:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567189wru; Sat, 29 Oct 2022 17:20:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gd6nLWYXPLYkbgmIQ+BI+DHslHi8J+jVnbq0eGVNUX2xtASwWjy7rhnjsbFlmrabqngZg X-Received: by 2002:a17:903:41cc:b0:186:b756:a5f0 with SMTP id u12-20020a17090341cc00b00186b756a5f0mr6797208ple.132.1667089210977; Sat, 29 Oct 2022 17:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089210; cv=none; d=google.com; s=arc-20160816; b=l+TX6I5gX9yGBUPxs94VeVsdiz8/OSvkEnauWYO664B3eYtB0l5n8AmRagZTWpMMj3 zwp367an63yb2iVWh4D7YQlbJ2q4mEcJAm5ETZ1dwAJ9UkjGJCyuVh9XjPyyrCkte2rt dZRfvPuinosSsoPV/tNAJ/ESPS09fAeapfycyXeRWtQO1B0+trR2Dz2wuwdExEKXVMvh EXC4rTPGop2xJbpF5QvycSs0LQQ9yE6UhYLfgLcIWAzigjaCl5lpbt0/9ZeMswJoSgwn +3l41aZiCVAEecQSf/kgU3Z87rm3T5eLnHxJg8hAnpDCrcssftjBPQC6fIN2oMIutsXN 8uvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R88kCoeCwDv+6qx8H8D1eKrnunl5yRlCsLCL15HFklE=; b=KmFDFjCI6ec8SZ6d3NNHtUnSwfWD9MPm4YXhHK8kX9oXS++j5g/XBv17sGsN0C10S8 3/VqhpFBAYwSYzjbT4zl9A/o5qWQXce52Z1es/v25xb+LkZJQ1gWtHj3W75z3yRF3DBa yMsRhrlffQTl3y6+M9OmHSN0rVsJGVQEhTQ/H4wHpoataXCVCDJH+8QxAanfFjw+UeMN xY/1CfwfWWV3KuL4HY4m1+f71oX34Q9LKc4s5pY83tTB4UkZ3bihIbhvGfGCaHn2FFMP YRtdB5S3t/4qc89gSX0sf4bG3hzxZMtW7wLLY2xLUfgCMQRlaWPqqkY2Taijm3ja2aDY QeiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F1+aFWl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020a631b57000000b00455bdca34dcsi3750147pgm.88.2022.10.29.17.19.58; Sat, 29 Oct 2022 17:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F1+aFWl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiJ3ATJ (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiJ3ASr (ORCPT ); Sat, 29 Oct 2022 20:18:47 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757FB24F0E for ; Sat, 29 Oct 2022 17:18:45 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id x16so4722744ilm.5 for ; Sat, 29 Oct 2022 17:18:45 -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=R88kCoeCwDv+6qx8H8D1eKrnunl5yRlCsLCL15HFklE=; b=F1+aFWl9mh16nV+3OhidAUkfR8KopPxpN92zsTwEGVEphUWqJtVtDlSMjRjOpGxUmG XMy8lwKkGE6/E+YVPj3ZDdAfaUwmGqDWbgmu/4YtRWvg37LLXBK7uXdbioJX7PNlwt1k 3uLIEXp2cgBNoVpCWmmqSmmsfrhloczhjmsqFt7MbVy9W1zYyjYi/wvQDRiwJshL9Q4o JFcVsjhnAfuTeixlcaASHodHRvZbmLzbK31vH1B2qqe08f2z5w7JKSCZ/NGx1/O4hUop /TKpWLB+1Dg1hY1a4ZR/Nxdq3ZUsolUL9IxMovRHXE+P4b2Db0kaPXFNOcw7gv6qo0h0 gPqQ== 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=R88kCoeCwDv+6qx8H8D1eKrnunl5yRlCsLCL15HFklE=; b=0qHbQDYHjV6yfLVVeMjmR9Hdhts60hY+yYRNUmmXHeVBvyB+kDC6qIOzUYN6IZLaLm 2hoy3XP6uLI2n6KHNChFTw4GXYbXONogXZ3YFOdhFPKaiHIzIOnaIWnPhrmPKvwAjR7Q V+pR00vKJbqK9VJ2gJufWMoZfmoth5JFrDVSP24YTZDd2xLjuwImU8IXGSk/AqObBET3 wb++YUf+k8AfVNi26Te13YvhEYh4Jggm7IAoAmkaO1x2OVe874eLw4QBNMnr1hHNd8IJ UarY43dSRB0ER9Y/seu5RjaY1eDtNVi8v86pxq7y+zB642+qyi6A7ctTXmcTWNm2fIGd cmHQ== X-Gm-Message-State: ACrzQf07idI1hsTqfuM0HqXBM/MAGKQ2QBpN/TTJfgP4b3DSOfSDvWO3 y7K8S9UpNDYt2n8aJSzsUVFfXA== X-Received: by 2002:a92:502:0:b0:2fc:5e54:b4a6 with SMTP id q2-20020a920502000000b002fc5e54b4a6mr2946656ile.41.1667089124808; Sat, 29 Oct 2022 17:18:44 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18: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 5/9] net: ipa: use a bitmap for defined endpoints Date: Sat, 29 Oct 2022 19:18:24 -0500 Message-Id: <20221030001828.754010-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069736811217078?= X-GMAIL-MSGID: =?utf-8?q?1748069736811217078?= IPA v5.0 supports more than 32 endpoints, so we will be unable to represent endpoints defined in the configuration data with a 32-bit value. To prepare for that, convert the field in the IPA structure representing defined endpoints to be a Linux bitmap. Convert loops based on that field into for_each_set_bit() calls over the new bitmap. Note that the loop in ipa_endpoint_config() still assumes there are 32 or fewer endpoints (when comparing against the available endpoint bit mask); that assumption goes away in the next patch. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 6 ++--- drivers/net/ipa/ipa_endpoint.c | 49 +++++++++++++++------------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index a44595575d066..261c7263f9e31 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -62,7 +62,7 @@ struct ipa_interrupt; * @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 + * @defined: Bitmap of endpoints defined in config data * @available: Bit mask indicating endpoints hardware supports * @filter_map: Bit mask indicating endpoints that support filtering * @set_up: Bit mask indicating endpoints set up @@ -117,9 +117,9 @@ struct ipa { void *zero_virt; size_t zero_size; - /* Bit masks indicating endpoint state */ + /* Bitmaps indicating endpoint state */ u32 endpoint_count; - u32 defined; /* Defined in configuration data */ + unsigned long *defined; /* Defined in configuration data */ u32 available; /* Supported by hardware */ u32 filter_map; u32 set_up; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 32559ed498c19..56908ee097cf6 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -459,8 +459,8 @@ 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 defined = ipa->defined; struct gsi_trans *trans; + u32 endpoint_id; u32 count; /* We need one command per modem TX endpoint, plus the commands @@ -474,14 +474,11 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa) return -EBUSY; } - while (defined) { - u32 endpoint_id = __ffs(defined); + for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) { struct ipa_endpoint *endpoint; const struct ipa_reg *reg; u32 offset; - defined ^= BIT(endpoint_id); - /* We only reset modem TX endpoints */ endpoint = &ipa->endpoint[endpoint_id]; if (!(endpoint->ee_id == GSI_EE_MODEM && endpoint->toward_ipa)) @@ -1823,16 +1820,11 @@ static void ipa_endpoint_teardown_one(struct ipa_endpoint *endpoint) void ipa_endpoint_setup(struct ipa *ipa) { - u32 defined = ipa->defined; + u32 endpoint_id; ipa->set_up = 0; - while (defined) { - u32 endpoint_id = __ffs(defined); - - defined ^= BIT(endpoint_id); - + for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_setup_one(&ipa->endpoint[endpoint_id]); - } } void ipa_endpoint_teardown(struct ipa *ipa) @@ -1853,10 +1845,10 @@ int ipa_endpoint_config(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; const struct ipa_reg *reg; + u32 endpoint_id; u32 tx_count; u32 rx_count; u32 rx_base; - u32 defined; u32 limit; u32 val; @@ -1896,13 +1888,9 @@ int ipa_endpoint_config(struct ipa *ipa) /* Mark all supported RX and TX endpoints as available */ ipa->available = GENMASK(limit - 1, rx_base) | GENMASK(tx_count - 1, 0); - defined = ipa->defined; - while (defined) { - u32 endpoint_id = __ffs(defined); + for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) { struct ipa_endpoint *endpoint; - defined ^= BIT(endpoint_id); - if (endpoint_id >= limit) { dev_err(dev, "invalid endpoint id, %u > %u\n", endpoint_id, limit - 1); @@ -1954,27 +1942,26 @@ static void ipa_endpoint_init_one(struct ipa *ipa, enum ipa_endpoint_name name, endpoint->toward_ipa = data->toward_ipa; endpoint->config = data->endpoint.config; - ipa->defined |= BIT(endpoint->endpoint_id); + __set_bit(endpoint->endpoint_id, ipa->defined); } static void ipa_endpoint_exit_one(struct ipa_endpoint *endpoint) { - endpoint->ipa->defined &= ~BIT(endpoint->endpoint_id); + __clear_bit(endpoint->endpoint_id, endpoint->ipa->defined); memset(endpoint, 0, sizeof(*endpoint)); } void ipa_endpoint_exit(struct ipa *ipa) { - u32 defined = ipa->defined; - - while (defined) { - u32 endpoint_id = __fls(defined); - - defined ^= BIT(endpoint_id); + u32 endpoint_id; + for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_exit_one(&ipa->endpoint[endpoint_id]); - } + + bitmap_free(ipa->defined); + ipa->defined = NULL; + memset(ipa->name_map, 0, sizeof(ipa->name_map)); memset(ipa->channel_map, 0, sizeof(ipa->channel_map)); } @@ -1983,6 +1970,7 @@ void ipa_endpoint_exit(struct ipa *ipa) u32 ipa_endpoint_init(struct ipa *ipa, u32 count, const struct ipa_gsi_endpoint_data *data) { + struct device *dev = &ipa->pdev->dev; enum ipa_endpoint_name name; u32 filter_map; @@ -1993,7 +1981,12 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, if (!ipa->endpoint_count) return 0; /* Error */ - ipa->defined = 0; + /* Set up the defined endpoint bitmap */ + ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + if (!ipa->defined) { + dev_err(dev, "unable to allocate defined endpoint bitmap\n"); + return 0; + } filter_map = 0; for (name = 0; name < count; name++, data++) { From patchwork Sun Oct 30 00:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567168wru; Sat, 29 Oct 2022 17:20:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46wi90gXYkcl52lB5/Mq4yLq9cf29QaSu3Hs3Ab7e+E9qYEAFVk7cL4NUdGPlnEK+e7LFc X-Received: by 2002:a05:6a00:1823:b0:56b:f348:998f with SMTP id y35-20020a056a00182300b0056bf348998fmr6665115pfa.28.1667089207658; Sat, 29 Oct 2022 17:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089207; cv=none; d=google.com; s=arc-20160816; b=Hp5U3P5xHvRaIeRfSdXhyD2CY/uVpvYT8oTuqwR1J0zMuWdGKQIcXpyXL4fUwf22mo bZLwieQRPyPUSAL4DZXfLwx7DpPRaB8Dt+i5lFFh5UGrMGXS7/UFjTKQbjrMMy4w+AGK aayavbvmktoYfe8h7UdNO+EZLxO1BEmR2N6fZcS1PKcz89LbtWom/lZ7/qduVVuFqMn1 W16fOq0pJiG1PbBbzk2zD4HjRiQtdkbDRZMljHotjGMxo9NXnIX+qpaWGNTEk/dwTyWQ Pm/M6jGVP+xJXXp8lRTuiOyer3VCkBIgzO3TrSaP3oj4n/DKM1xc85Ak1Jb7dHP8O0aK nYJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Lk3pnPj9yt9t91KAvzsXB5y55ZuWPJLZLwDcUNTFozw=; b=hpQ0W+mVqO/xWAWjQa3gSOmklJgYAe0tmJHVTQjkjboq2LzqG0YLiu4kXChiKfYORX sQvnlz9m6DLuHwDLekFft4/eLikCyorph3cVrD/zMYgxZg/6fvfYwkl9lRBM7Q9e78BT TJz4DKWIgfzyG9EEymxUHeg4ZpF/yeK29NMggRF4HkXXN4m8v/7TdlB6JBd/bp+uYTOV 1QHwIrd+iQNWsqomwMlgXJhLp692pCnxR5TrR7LmzcqUG+kX+7G4Y4gNaDY3gGjhDV6R NsCvnMZDa5DRlGpabvlcU2Cp36oRJ1DKaL4DwXqmxgeZ6sbnNivoML4DabNEhxXsKbcT ijNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dfJAjEjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170902f31100b0018685c559a1si2939819ple.383.2022.10.29.17.19.54; Sat, 29 Oct 2022 17:20:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dfJAjEjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbiJ3ATF (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiJ3ASs (ORCPT ); Sat, 29 Oct 2022 20:18:48 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D98D3B70B for ; Sat, 29 Oct 2022 17:18:47 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id h206so3909565iof.10 for ; Sat, 29 Oct 2022 17:18: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=Lk3pnPj9yt9t91KAvzsXB5y55ZuWPJLZLwDcUNTFozw=; b=dfJAjEjOKaMWvJQAhG9FkquaM+/gFfJ8lFxaU5DP/wGG8THdDVUZDLBDCpHS0/eOuP nvmVVwABhf9vIWdiiF0tM8KcJQUlTV/np8Yn1lT2CICzOCfvowO4xkBBIWmqdJ+lSd3m 6/ruvJahVNZvwp0FfHUtHHjRCjPu2IluiebekKaSy+WNUbZ9xhoMGxMEzci6gI6b7BHE Ldbmrkk1kVuWQEkv91HsMChlRqfIDUyChimWcWrZK2nsWsXdstWxoVofxc0CNhmBpyTv oAuPi0jUUeAezOsSLtp84umLwHx3EgcuZ0cSjpB8SFy7SlWBzJUBvNvOSPsvWsKva5ZF 1RjQ== 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=Lk3pnPj9yt9t91KAvzsXB5y55ZuWPJLZLwDcUNTFozw=; b=MuIgpjq0nx/GQnazLewOTNvUcOyeSaNnNg9kq0Pr7bbX5ZOkrUOp8vZWjOanlNpSPX NJOdJ2IrWVZuR6ngJXFVDNYJVYrswDwjtKFpKuHkAZYIFyc4XF2sznN8xjoSNuJKdjmh KPe9f2mDJJra4Mr19VHtXB7XQXB8rqmtvxWRh8LsH3LKBDqaKFklz3RtgXZciXchn4pu 77t1dTIArSdQFWCfyN3/woVPQyZCxwI9J8hHLTHq8Fp5l04GXupL1m5WGO3HfY96kZ/U i31KNCww91auXBzkBSflo4Q0MP86vQpTfWSKgWbG24DMoIGKObJ6yT4ZlK3yKlb59+kh cpQw== X-Gm-Message-State: ACrzQf3kOaXh/vbKNpiBqsTRmPDDcXWJuH92z49WHKlvtZm4yXc4k3Xy CF1QtDoBJjd6OqFbfzh+DwL9+A== X-Received: by 2002:a05:6638:2605:b0:363:a059:36bd with SMTP id m5-20020a056638260500b00363a05936bdmr3535592jat.267.1667089126738; Sat, 29 Oct 2022 17:18:46 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18: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 6/9] net: ipa: use a bitmap for available endpoints Date: Sat, 29 Oct 2022 19:18:25 -0500 Message-Id: <20221030001828.754010-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069732698797276?= X-GMAIL-MSGID: =?utf-8?q?1748069732698797276?= Similar to the previous patch, replace the 32-bit unsigned used to track endpoints supported by hardware with a Linux bitmap, to allow an arbitrary number of endpoints to be represented. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 8 +++--- drivers/net/ipa/ipa_endpoint.c | 44 +++++++++++++++++++++++---------- drivers/net/ipa/ipa_interrupt.c | 8 +++--- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 261c7263f9e31..c603575e2a58b 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -61,9 +61,10 @@ 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 + * @endpoint_count: Number of defined bits in most bitmaps below + * @available_count: Number of defined bits in the available bitmap * @defined: Bitmap of endpoints defined in config data - * @available: Bit mask indicating endpoints hardware supports + * @available: Bitmap of endpoints supported by hardware * @filter_map: Bit mask indicating endpoints that support filtering * @set_up: Bit mask indicating endpoints set up * @enabled: Bit mask indicating endpoints enabled @@ -119,8 +120,9 @@ struct ipa { /* Bitmaps indicating endpoint state */ u32 endpoint_count; + u32 available_count; unsigned long *defined; /* Defined in configuration data */ - u32 available; /* Supported by hardware */ + unsigned long *available; /* Supported by hardware */ u32 filter_map; u32 set_up; u32 enabled; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 56908ee097cf6..8d4cb2c30ec90 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -351,19 +351,17 @@ ipa_endpoint_program_delay(struct ipa_endpoint *endpoint, bool enable) static bool ipa_endpoint_aggr_active(struct ipa_endpoint *endpoint) { u32 endpoint_id = endpoint->endpoint_id; - u32 mask = BIT(endpoint_id % 32); struct ipa *ipa = endpoint->ipa; u32 unit = endpoint_id / 32; const struct ipa_reg *reg; u32 val; - /* This works until we actually have more than 32 endpoints */ - WARN_ON(!(mask & ipa->available)); + WARN_ON(!test_bit(endpoint_id, ipa->available)); reg = ipa_reg(ipa, STATE_AGGR_ACTIVE); val = ioread32(ipa->reg_virt + ipa_reg_n_offset(reg, unit)); - return !!(val & mask); + return !!(val & BIT(endpoint_id % 32)); } static void ipa_endpoint_force_close(struct ipa_endpoint *endpoint) @@ -374,8 +372,7 @@ static void ipa_endpoint_force_close(struct ipa_endpoint *endpoint) u32 unit = endpoint_id / 32; const struct ipa_reg *reg; - /* This works until we actually have more than 32 endpoints */ - WARN_ON(!(mask & ipa->available)); + WARN_ON(!test_bit(endpoint_id, ipa->available)); reg = ipa_reg(ipa, AGGR_FORCE_CLOSE); iowrite32(mask, ipa->reg_virt + ipa_reg_n_offset(reg, unit)); @@ -1863,7 +1860,13 @@ int ipa_endpoint_config(struct ipa *ipa) * assume the configuration is valid. */ if (ipa->version < IPA_VERSION_3_5) { - ipa->available = ~0; + ipa->available = bitmap_zalloc(IPA_ENDPOINT_MAX, GFP_KERNEL); + if (!ipa->available) + return -ENOMEM; + ipa->available_count = IPA_ENDPOINT_MAX; + + bitmap_set(ipa->available, 0, IPA_ENDPOINT_MAX); + return 0; } @@ -1885,8 +1888,15 @@ int ipa_endpoint_config(struct ipa *ipa) return -EINVAL; } + /* Allocate and initialize the available endpoint bitmap */ + ipa->available = bitmap_zalloc(limit, GFP_KERNEL); + if (!ipa->available) + return -ENOMEM; + ipa->available_count = limit; + /* Mark all supported RX and TX endpoints as available */ - ipa->available = GENMASK(limit - 1, rx_base) | GENMASK(tx_count - 1, 0); + bitmap_set(ipa->available, 0, tx_count); + bitmap_set(ipa->available, rx_base, rx_count); for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) { struct ipa_endpoint *endpoint; @@ -1894,13 +1904,13 @@ int ipa_endpoint_config(struct ipa *ipa) if (endpoint_id >= limit) { dev_err(dev, "invalid endpoint id, %u > %u\n", endpoint_id, limit - 1); - return -EINVAL; + goto err_free_bitmap; } - if (!(BIT(endpoint_id) & ipa->available)) { + if (!test_bit(endpoint_id, ipa->available)) { dev_err(dev, "unavailable endpoint id %u\n", endpoint_id); - return -EINVAL; + goto err_free_bitmap; } /* Make sure it's pointing in the right direction */ @@ -1913,15 +1923,23 @@ int ipa_endpoint_config(struct ipa *ipa) } dev_err(dev, "endpoint id %u wrong direction\n", endpoint_id); - return -EINVAL; + goto err_free_bitmap; } return 0; + +err_free_bitmap: + bitmap_free(ipa->available); + ipa->available = NULL; + + return -EINVAL; } void ipa_endpoint_deconfig(struct ipa *ipa) { - ipa->available = 0; /* Nothing more to do */ + ipa->available_count = 0; + bitmap_free(ipa->available); + ipa->available = NULL; } static void ipa_endpoint_init_one(struct ipa *ipa, enum ipa_endpoint_name name, diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index a62bc667bda0e..a49f66efacb87 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -132,14 +132,13 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, u32 endpoint_id, bool enable) { struct ipa *ipa = interrupt->ipa; - u32 mask = BIT(endpoint_id % 32); u32 unit = endpoint_id / 32; const struct ipa_reg *reg; u32 offset; + u32 mask; u32 val; - /* This works until we actually have more than 32 endpoints */ - WARN_ON(!(mask & ipa->available)); + WARN_ON(!test_bit(endpoint_id, ipa->available)); /* IPA version 3.0 does not support TX_SUSPEND interrupt control */ if (ipa->version == IPA_VERSION_3_0) @@ -148,10 +147,13 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, reg = ipa_reg(ipa, IRQ_SUSPEND_EN); offset = ipa_reg_n_offset(reg, unit); val = ioread32(ipa->reg_virt + offset); + + mask = BIT(endpoint_id); if (enable) val |= mask; else val &= ~mask; + iowrite32(val, ipa->reg_virt + offset); } From patchwork Sun Oct 30 00:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567448wru; Sat, 29 Oct 2022 17:20:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yr5NUpZ/ohmJxAfQqxYRchRgEGZkwuLEG/82m81UT7kTTJcvrlrmHC3Uz6PzdvwRe1k2T X-Received: by 2002:a17:90a:71ca:b0:213:c03a:1b07 with SMTP id m10-20020a17090a71ca00b00213c03a1b07mr2828221pjs.67.1667089252849; Sat, 29 Oct 2022 17:20:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089252; cv=none; d=google.com; s=arc-20160816; b=X9ZfIT/Icv8b562EiZuuycdlxE0/jumxnmyi0HPpCTXscIo8FwzC+p6kyOrzFzKwBR qvbBCWgmHSJGuXGZO1+k32ijDnbOKcoeimy6rukfzBwCSdYcR5lOhnKT7Aj1Hj8yb46R nXFNOzhWmW7Lc2LmocMV6EtwTG2GQHA7ZoCyZ0NoTfqvJ7qAnPSxpo+EmKCHZwNXZ+aa pEY6nOc9mVnvOs8agl2eu4zLKM3o+4cHoFdLJcr/RI7N7A2PJ7asn5nQV/VzabUIuKkv wEnNopDI4bcaYPzx5C1SMXr853fEaVlGKqM4sMQ7x7rBom/OJ7redHxtko9PRCAt2i4n 9lZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b+B/7+vxq/3O8eHqvvwYVc/AJMZK0GiWxC3wTnrGp9I=; b=PM0G3iP9D1kPFgxInnB8xBgSox42+7dkTlaoNkMYVgOhtMfnjV6RNAyLkFdg4Q+v3I mirtgLj/JCnYbxZNTik8eos/BOViqUETmyRsHe6aHCCt7Btli9yJxnkhc3fp4b9Jccae n7SN959gvoBwPQAA+Lh5IdyhqFKofau8pQpvBr39uJxBSc/ZlhIg3i0zBYj+MpiHT3zG SuM4uhAuU4UOhY4hxK2DP8HN8bg6hBRZIWRanl6zyqhU8src76d00HogqTR3osCyUUoV yGOkNO91IAt4lTk6Al+OW6qhg/hLLfxk3YaJYgYV+AIdLvM3FD+dzcBwFJHlEWchSSVR vvVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DhWUxWBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020a63e958000000b00439ae52c996si3959909pgj.71.2022.10.29.17.20.40; Sat, 29 Oct 2022 17:20:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DhWUxWBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbiJ3ATM (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbiJ3ASx (ORCPT ); Sat, 29 Oct 2022 20:18:53 -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 2864E3C8C3 for ; Sat, 29 Oct 2022 17:18:49 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id 63so7367503iov.8 for ; Sat, 29 Oct 2022 17:18:49 -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=b+B/7+vxq/3O8eHqvvwYVc/AJMZK0GiWxC3wTnrGp9I=; b=DhWUxWBhTCG5yXmaIEiO0wHnWESH7Gv7FRtu6HxINJuMw049G+YgGqg8ETIky4mg3s P34Iq01Vs0y5lMRJCk04FOX903W9KiDQZRYtUt90DGeBJ8T0hfTQ2syfwJ6Se8Boar7h zmKX7Qea1iW+WmdatZTeA6p+kL9J36UPBDPBtT1qs2TmCPzA9VzPNKfzH2v5orrkrxX0 usKvqTGI2Gz7G1IVJSrPhVnK5wqsJ5Rhvjv7mOZnT8WOdGIxqvB4wDauO4zEAMreYkwB /9o7XE6DKGMReppUtPvAfSuq5Fn1LsqlN6h7FYvXRkaX+Jh7TnKW2hlGyUJqp5ULBqKp PctQ== 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=b+B/7+vxq/3O8eHqvvwYVc/AJMZK0GiWxC3wTnrGp9I=; b=OFtQZWY5NRirBs008e71faNwB7czA1prNImV5G7vF/QJypB6lhaV2j/PlNNNlLMKj0 Hhm9uJDHh2vD1rWtj9et18KoK/kx8VHZKNJy15IDniIF05R37kK/ERRd62z3ftDeGKaR j5F2NdQHK0Oc9tPPspykJ+YWFivjoZ6zEXpnWXp3YIDXAyqnnX6hKoqxW+oigeLe48Z0 r2srTFGfuxlJFtnyeflFTsCj3pDVDQBEv0ke6el7+thWixqgmz6+lm7IHiQTflHIhX2M JgWOlAUEcoQn6L8zirDiotuGbLkFyg85BF66arWlYL88sn9UZHsyE/s4qVV0tdUlqbp6 yeuw== X-Gm-Message-State: ACrzQf1Ek+E1OPVEwPxLHgxzMxyHCM2veDhJFJBM68DjSJDKIHK6RSOK uy+mDnoOalPuGmZRl7D9BYj4Bg== X-Received: by 2002:a05:6638:1644:b0:363:eeaf:cc66 with SMTP id a4-20020a056638164400b00363eeafcc66mr3354728jat.68.1667089128743; Sat, 29 Oct 2022 17:18:48 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18:48 -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/9] net: ipa: support more filtering endpoints Date: Sat, 29 Oct 2022 19:18:26 -0500 Message-Id: <20221030001828.754010-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069779998705879?= X-GMAIL-MSGID: =?utf-8?q?1748069779998705879?= Prior to IPA v5.0, there could be no more than 32 endpoints. A filter table begins with a bitmap indicating which endpoints have a filter defined. That bitmap is currently assumed to fit in a 32-bit value. Starting with IPA v5.0, more than 32 endpoints are supported, so it's conceivable that a TX endpoint has an ID that exceeds 32. Increase the size of the field representing endpoints that support filtering to 64 bits. Rename the bitmap field "filtered". Unlike other similar fields, we do not use an (arbitrarily long) Linux bitmap for this purpose. The reason is that if a filter table ever *did* need to support more than 64 TX endpoints, its format would change in ways we can't anticipate. Have ipa_endpoint_init() return a negative errno rather than a mask that indicates which endpoints support filtering, and have that function assign the "filtered" field directly. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 4 ++-- drivers/net/ipa/ipa_endpoint.c | 20 +++++++++++--------- drivers/net/ipa/ipa_endpoint.h | 2 +- drivers/net/ipa/ipa_main.c | 7 ++----- drivers/net/ipa/ipa_table.c | 20 ++++++++++---------- drivers/net/ipa/ipa_table.h | 6 +++--- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index c603575e2a58b..557101c2d5838 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -65,7 +65,7 @@ struct ipa_interrupt; * @available_count: Number of defined bits in the available bitmap * @defined: Bitmap of endpoints defined in config data * @available: Bitmap of endpoints supported by hardware - * @filter_map: Bit mask indicating endpoints that support filtering + * @filtered: Bitmap of endpoints that support filtering * @set_up: Bit mask indicating endpoints set up * @enabled: Bit mask indicating endpoints enabled * @modem_tx_count: Number of defined modem TX endoints @@ -123,7 +123,7 @@ struct ipa { u32 available_count; unsigned long *defined; /* Defined in configuration data */ unsigned long *available; /* Supported by hardware */ - u32 filter_map; + u64 filtered; /* Support filtering (AP and modem) */ u32 set_up; u32 enabled; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 8d4cb2c30ec90..923299cc46fe5 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1985,28 +1985,28 @@ void ipa_endpoint_exit(struct ipa *ipa) } /* Returns a bitmask of endpoints that support filtering, or 0 on error */ -u32 ipa_endpoint_init(struct ipa *ipa, u32 count, +int ipa_endpoint_init(struct ipa *ipa, u32 count, const struct ipa_gsi_endpoint_data *data) { struct device *dev = &ipa->pdev->dev; enum ipa_endpoint_name name; - u32 filter_map; + u32 filtered; BUILD_BUG_ON(!IPA_REPLENISH_BATCH); /* Number of endpoints is one more than the maximum ID */ ipa->endpoint_count = ipa_endpoint_max(ipa, count, data) + 1; if (!ipa->endpoint_count) - return 0; /* Error */ + return -EINVAL; /* Set up the defined endpoint bitmap */ ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); if (!ipa->defined) { dev_err(dev, "unable to allocate defined endpoint bitmap\n"); - return 0; + return -ENOMEM; } - filter_map = 0; + filtered = 0; for (name = 0; name < count; name++, data++) { if (ipa_gsi_endpoint_data_empty(data)) continue; /* Skip over empty slots */ @@ -2014,18 +2014,20 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, ipa_endpoint_init_one(ipa, name, data); if (data->endpoint.filter_support) - filter_map |= BIT(data->endpoint_id); + filtered |= BIT(data->endpoint_id); if (data->ee_id == GSI_EE_MODEM && data->toward_ipa) ipa->modem_tx_count++; } - if (!ipa_filter_map_valid(ipa, filter_map)) + if (!ipa_filtered_valid(ipa, filtered)) goto err_endpoint_exit; - return filter_map; /* Non-zero bitmask */ + ipa->filtered = filtered; + + return 0; err_endpoint_exit: ipa_endpoint_exit(ipa); - return 0; /* Error */ + return -EINVAL; } diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h index d8dfa24f52140..4a5c3bc549df5 100644 --- a/drivers/net/ipa/ipa_endpoint.h +++ b/drivers/net/ipa/ipa_endpoint.h @@ -195,7 +195,7 @@ void ipa_endpoint_deconfig(struct ipa *ipa); void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id); void ipa_endpoint_default_route_clear(struct ipa *ipa); -u32 ipa_endpoint_init(struct ipa *ipa, u32 count, +int ipa_endpoint_init(struct ipa *ipa, u32 count, const struct ipa_gsi_endpoint_data *data); void ipa_endpoint_exit(struct ipa *ipa); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 8f6a6890697e8..ebb6c9b311eb9 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -788,12 +788,9 @@ static int ipa_probe(struct platform_device *pdev) goto err_mem_exit; /* Result is a non-zero mask of endpoints that support filtering */ - ipa->filter_map = ipa_endpoint_init(ipa, data->endpoint_count, - data->endpoint_data); - if (!ipa->filter_map) { - ret = -EINVAL; + ret = ipa_endpoint_init(ipa, data->endpoint_count, data->endpoint_data); + if (ret) goto err_gsi_exit; - } ret = ipa_table_init(ipa); if (ret) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 3a14465bf8a64..e657540dc7dfb 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -161,18 +161,18 @@ ipa_table_mem(struct ipa *ipa, bool filter, bool hashed, bool ipv6) return ipa_mem_find(ipa, mem_id); } -bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) +bool ipa_filtered_valid(struct ipa *ipa, u64 filtered) { struct device *dev = &ipa->pdev->dev; u32 count; - if (!filter_map) { + if (!filtered) { dev_err(dev, "at least one filtering endpoint is required\n"); return false; } - count = hweight32(filter_map); + count = hweight64(filtered); if (count > ipa->filter_count) { dev_err(dev, "too many filtering endpoints (%u, max %u)\n", count, ipa->filter_count); @@ -230,8 +230,8 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, static int ipa_filter_reset_table(struct ipa *ipa, bool hashed, bool ipv6, bool modem) { - u32 ep_mask = ipa->filter_map; - u32 count = hweight32(ep_mask); + u64 ep_mask = ipa->filtered; + u32 count = hweight64(ep_mask); struct gsi_trans *trans; enum gsi_ee_id ee_id; @@ -405,7 +405,7 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, bool ipv6) * to hold the bitmap itself. The size of the hashed filter * table is either the same as the non-hashed one, or zero. */ - count = 1 + hweight32(ipa->filter_map); + count = 1 + hweight64(ipa->filtered); hash_count = hash_mem && hash_mem->size ? count : 0; } else { /* The size of a route table region determines the number @@ -503,7 +503,7 @@ static void ipa_filter_tuple_zero(struct ipa_endpoint *endpoint) static void ipa_filter_config(struct ipa *ipa, bool modem) { enum gsi_ee_id ee_id = modem ? GSI_EE_MODEM : GSI_EE_AP; - u32 ep_mask = ipa->filter_map; + u64 ep_mask = ipa->filtered; if (!ipa_table_hash_support(ipa)) return; @@ -615,7 +615,7 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool filter) /* Filter tables must able to hold the endpoint bitmap plus * an entry for each endpoint that supports filtering */ - if (count < 1 + hweight32(ipa->filter_map)) + if (count < 1 + hweight64(ipa->filtered)) return false; } else { /* Routing tables must be able to hold all modem entries, @@ -720,9 +720,9 @@ int ipa_table_init(struct ipa *ipa) * that option, so there's no shifting required. */ if (ipa->version < IPA_VERSION_5_0) - *virt++ = cpu_to_le64((u64)ipa->filter_map << 1); + *virt++ = cpu_to_le64(ipa->filtered << 1); else - *virt++ = cpu_to_le64((u64)ipa->filter_map); + *virt++ = cpu_to_le64(ipa->filtered); /* All the rest contain the DMA address of the zero rule */ le_addr = cpu_to_le64(addr); diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 8a4dcd7df4c0f..7cc951904bb48 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -11,13 +11,13 @@ struct ipa; /** - * ipa_filter_map_valid() - Validate a filter table endpoint bitmap + * ipa_filtered_valid() - Validate a filter table endpoint bitmap * @ipa: IPA pointer - * @filter_mask: Filter table endpoint bitmap to check + * @filtered: Filter table endpoint bitmap to check * * Return: true if all regions are valid, false otherwise */ -bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); +bool ipa_filtered_valid(struct ipa *ipa, u64 filtered); /** * ipa_table_hash_support() - Return true if hashed tables are supported From patchwork Sun Oct 30 00:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567544wru; Sat, 29 Oct 2022 17:21:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM616oCwxNcK5i4xm53Qs37QMVN2Ykj3fdW4a61x5htLXkC4dVjtla3cbA0yxVYvkH/iO4qi X-Received: by 2002:a62:a503:0:b0:56b:cb10:2d87 with SMTP id v3-20020a62a503000000b0056bcb102d87mr6690122pfm.79.1667089269445; Sat, 29 Oct 2022 17:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089269; cv=none; d=google.com; s=arc-20160816; b=M5PnMHXaVCmFzzghb9BCArIdN5qiFRdEp94Hq0qJkKYiE9IhCktFA6IkP3ZHqRGAVl gBV6tMIgso/7gu4wrDpBGpTmjTDC30R9Kb7uwaMZW+bmcvTgvCt01yIIEbVKxRyCGQFy Uo6zPNHO6tDgJBbI841WL5SZJ9pl4cj3Nl+O5Gl6ic5crhhFzJd4nY8WYMO4qsEunUIT XhqqCOPdD+foGziXIS4RL0y4kuzAAYf91F2w8uhHbczTcLCLf7ov34trti6cC8BLup3r WT9dJ0Ib6+U77bGoy8zAk3QvvsSl3TD/T/B2o8pgrLKMkXFyYbkmxHQ+uYV5Q614ewcu Le6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XGjf4m+z8VLv96itNVJOvkxO2bjdazwhjFdsDMTWA4k=; b=qGtPXUuYWxHZnHELvXYuwf8MoyUeDeOmd/TIPAcLIkPl8ylFmfHA/lFLFlG/+WEQEi 4wnINJo0y5vob6obF/Wm3946drQAMstB1FPg5Cr8UvIZMPVE6SO78iPD6nF+zw1iT6E8 trBsIqNOspLEn1zwKgJQ88PvV1N1+HZCKekmEnBwKUytHru2PZa1jRdbqF+YiYUFOhJ8 ns6EH/d/CTYkMfUsJiE+GjmsJHp3knv4DgFIRA6B99oQ9M/YySb+3EZCDblmChr0RylH aFK3LRcAzZ3f4IzVkvCty/3TKNh4YLTsA6a9iBJbVcTRXWaRysIwcJlKw6mjTxaaAoys Tqew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b7X1PDwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170902d50900b0018683763131si3912341plg.501.2022.10.29.17.20.56; Sat, 29 Oct 2022 17:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b7X1PDwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiJ3AT1 (ORCPT + 99 others); Sat, 29 Oct 2022 20:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbiJ3ATB (ORCPT ); Sat, 29 Oct 2022 20:19:01 -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 216364F64D for ; Sat, 29 Oct 2022 17:18:51 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id z3so7385622iof.3 for ; Sat, 29 Oct 2022 17:18:51 -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=XGjf4m+z8VLv96itNVJOvkxO2bjdazwhjFdsDMTWA4k=; b=b7X1PDwIHi4vLETogYLVomhE5cORrmJwMBi0/Vo0RRDUfBQPcTKE98mLeyF77BtQQe iO6W+BtVVprtLo2jQ8IxgWYkyGPwkfSiM1tpnriJZB9WLPw0SedYvEIHnQrnjNojEImV 4lKvcE97hdpg+ukZBF0w9voOv/GL5iygsF9iI5gyMPYcfgdneR+ho1f0/tZcC2P3orr0 KUwg9Y4DG5qE0WXMUV8MxCG8vj9b+Nyny3wFNP11GjcT20DqrhOrwVL0CTZW1+TVm/EA XVFrxSucJIyyt8V673dFnd6RgihT970DxPOXOjA+LOQz6WpB8/te/xdEQTMFzWQTH46U CzFA== 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=XGjf4m+z8VLv96itNVJOvkxO2bjdazwhjFdsDMTWA4k=; b=oATkpp2ZYCtXWs7fUeBnXx0c5nQ8oDhTErCjM1kB9hYoKkWvxa+H3BmezEuUEGt3Lz iYf9GGKMT7FYr6A2Ta/P6sEfHy22Ue/7awv3Dmi/D+oj8fgc3O9QkyN4MHCkrVRqG6Z6 W9GfjF2G+jK0+kUH/iJtjDmyzHgpTO52AeeccZ8hnKCUXfxc0C2PQg66dQg/b0Bn1ZGk BYLEWzhRZ2ewSGzaK5Qy9KusPxYODu0F7nuR1PCqqblDEKRTX5UDj3CyhauyQu2Kx5+H G/j5Ke2v2oXbBghKUHpyWcm3xcu4PfS3t9q83WqJNJRfWcsLSjYOP0FOn24QqhwyaH5g 3Nvg== X-Gm-Message-State: ACrzQf2Fpyb/s0tSdWtq5LhkOxVGQt8znhBfc/Anvyrpz6I0DSiO9rqa fegX0rmJneFEXOHzgBpQoFpkzw== X-Received: by 2002:a05:6638:35a2:b0:375:21c3:f5cf with SMTP id v34-20020a05663835a200b0037521c3f5cfmr3380037jal.229.1667089130772; Sat, 29 Oct 2022 17:18:50 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18:50 -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 8/9] net: ipa: use a bitmap for set-up endpoints Date: Sat, 29 Oct 2022 19:18:27 -0500 Message-Id: <20221030001828.754010-9-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069797682343408?= X-GMAIL-MSGID: =?utf-8?q?1748069797682343408?= Replace the 32-bit unsigned used to track endpoints that have completed setup with a Linux bitmap, to allow an arbitrary number of endpoints to be represented. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 4 ++-- drivers/net/ipa/ipa_endpoint.c | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 557101c2d5838..f14d1bd34e7e5 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -66,7 +66,7 @@ struct ipa_interrupt; * @defined: Bitmap of endpoints defined in config data * @available: Bitmap of endpoints supported by hardware * @filtered: Bitmap of endpoints that support filtering - * @set_up: Bit mask indicating endpoints set up + * @set_up: Bitmap of endpoints that are set up for use * @enabled: Bit mask indicating endpoints enabled * @modem_tx_count: Number of defined modem TX endoints * @endpoint: Array of endpoint information @@ -124,7 +124,7 @@ struct ipa { unsigned long *defined; /* Defined in configuration data */ unsigned long *available; /* Supported by hardware */ u64 filtered; /* Support filtering (AP and modem) */ - u32 set_up; + unsigned long *set_up; u32 enabled; u32 modem_tx_count; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 923299cc46fe5..564a209f75a0f 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1802,12 +1802,12 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *endpoint) ipa_endpoint_program(endpoint); - endpoint->ipa->set_up |= BIT(endpoint->endpoint_id); + __set_bit(endpoint->endpoint_id, endpoint->ipa->set_up); } static void ipa_endpoint_teardown_one(struct ipa_endpoint *endpoint) { - endpoint->ipa->set_up &= ~BIT(endpoint->endpoint_id); + __clear_bit(endpoint->endpoint_id, endpoint->ipa->set_up); if (!endpoint->toward_ipa) cancel_delayed_work_sync(&endpoint->replenish_work); @@ -1819,23 +1819,16 @@ void ipa_endpoint_setup(struct ipa *ipa) { u32 endpoint_id; - ipa->set_up = 0; for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_setup_one(&ipa->endpoint[endpoint_id]); } void ipa_endpoint_teardown(struct ipa *ipa) { - u32 set_up = ipa->set_up; - - while (set_up) { - u32 endpoint_id = __fls(set_up); - - set_up ^= BIT(endpoint_id); + u32 endpoint_id; + for_each_set_bit(endpoint_id, ipa->set_up, ipa->endpoint_count) ipa_endpoint_teardown_one(&ipa->endpoint[endpoint_id]); - } - ipa->set_up = 0; } int ipa_endpoint_config(struct ipa *ipa) @@ -1977,7 +1970,9 @@ void ipa_endpoint_exit(struct ipa *ipa) for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_exit_one(&ipa->endpoint[endpoint_id]); + bitmap_free(ipa->set_up); bitmap_free(ipa->defined); + ipa->set_up = NULL; ipa->defined = NULL; memset(ipa->name_map, 0, sizeof(ipa->name_map)); @@ -2001,8 +1996,11 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, /* Set up the defined endpoint bitmap */ ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); - if (!ipa->defined) { - dev_err(dev, "unable to allocate defined endpoint bitmap\n"); + ipa->set_up = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + if (!ipa->defined || !ipa->set_up) { + dev_err(dev, "unable to allocate endpoint bitmaps\n"); + bitmap_free(ipa->defined); + ipa->defined = NULL; return -ENOMEM; } From patchwork Sun Oct 30 00:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1567897wru; Sat, 29 Oct 2022 17:22:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FJMuZxb22taMlYhGvlNtmuYinofUpbPNryYWGfaGeI0kGZCI9xLICvomEeSGJRbtBkiV/ X-Received: by 2002:a63:e00a:0:b0:43c:7f5c:822b with SMTP id e10-20020a63e00a000000b0043c7f5c822bmr5913159pgh.307.1667089345469; Sat, 29 Oct 2022 17:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667089345; cv=none; d=google.com; s=arc-20160816; b=Kl8+I/VgTd8HlQGFQSkasRemaIl//uywGPezKPrj+beMvLyUleNMBUVvrhPN8xs5+q 0/u7qpOHcpXHq2vpx38ArnqIhzr76AwGARIRQnJzaX7ntn2+HX4j3DCnyLkZSBYSFw1o ulQWfn6Rpfkmq0eBrV3O3KE/ZhtkNy1dH/OgnMAHBQW1I97SlGOzT14+xLOViFh7Gp9g irWRnRXGDvCRJuGEx6iLDzqMpJVnQULB0kd+FL6AqtHMJgQKQl/X79BQxC2ReEd8OSFV fz+FLM40wUeigG08lupZ7UXlfzp3JwSBFKeU5hIQm03msmWOfd9J5Em0sY+GXHPX7k7d qktw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cEUlpLn6RuLc4Fo/uPSYCehvdn31euMXFsdMmyCklyk=; b=W/P0Szo8MJCJws2EbFNSibFzPQcs24nNku1x4gyVPeMmhKd9YCttqVmf9e2IYMvqfF Q3reDuY9gUj65yE/GLb6uQftf0yspZ0eDGUQLnCbTNiVRXo9lL/DAoc12M97IQGXiv+/ 94fzvWQw4vgpWVQYL/OSUZO0pycoMhgk3tH9zngm97uDQmHfzpqEUlSlnM/FMhSHLpk2 xbkqzyCp4axply7OHtscD/XoSD9ZRkj6hp34vNu4jGF4Lnp+jixAj5o6+t1zpVDwHdQ1 BTmNXsr4KrzRjqPFMM1J+RLZ3fqW/f5LMOLycTlHobybmtnFcd/fJjJb8F19+kaY0ECM CGww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SgQo6EF4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170902e94800b00180d51f70cfsi3710457pll.107.2022.10.29.17.22.12; Sat, 29 Oct 2022 17:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SgQo6EF4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbiJ3AUR (ORCPT + 99 others); Sat, 29 Oct 2022 20:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiJ3ATI (ORCPT ); Sat, 29 Oct 2022 20:19:08 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2653D4F6B4 for ; Sat, 29 Oct 2022 17:18:53 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id h206so3909649iof.10 for ; Sat, 29 Oct 2022 17:18:53 -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=cEUlpLn6RuLc4Fo/uPSYCehvdn31euMXFsdMmyCklyk=; b=SgQo6EF4wTm/UBaevZtlQYHMSlg7mAp5S8g0l0XvdCufc9TjYfk8eg50qb7ggL3r0+ musLPB0I22VqJZrSvjCgVwVYGvZNf5prBF0zZ+fBVXIMt+a7KjCieF8pGqSQ0qIjzkD1 9uoK2iP8Hz4rwvZqYh91jq2MsQrZgCDV9QSIY86oo2k7s0tn2epfkA0nEUHGdYfu/zfl BduYuQWAYUGnfgfS8/cVLUhnmDAONGv97oB772BePT7HsJCs3+D/533siTlS9fhYbDyx 7MVOrpcGYlJlDtLeEtoqD6cRmVZ7dEcTAfYSRdiKjgJ2RPFKbAxYhljzKXkSJqIpUI7G zXSA== 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=cEUlpLn6RuLc4Fo/uPSYCehvdn31euMXFsdMmyCklyk=; b=DCOEopY55tizAuQg6wWkjA+qioNClTpH6wL5qOmyr2Hzlw0RRVg+sv5zWOO6LNXTi9 ptVg6h7HlPbqi0PQw8VvV7pnjC9BUDAKko3/dGFf8rvU1RpozvCa+kD1CT6S8ksk/Z4b b0EpYS1VO8XaYKM0fj9N5XyObp2iOkbtUGz+AWzd2WClByQTRGfFPbfEXsl5Inko+4ri WxKVluyuJTeWyZefFTuIQXFBBcIQLQ6ih7+xhVGbacyFn0lMrjSvVSijD+dqt+Hq8ixk egZ1H0s43zZXsGG5EXG28sTyGhmfvwdCtCKfjDRh6YwlFuUlMcM4PkVj1mMpoYH2Kguc XKFQ== X-Gm-Message-State: ACrzQf14EFpG/iN5IflIAamJXmHb16r1aqG3NvePAj7tWZr59pKfHhNR qgbnEmlXZO3K1IOXIbduPxjAxg== X-Received: by 2002:a02:6d15:0:b0:375:3523:b643 with SMTP id m21-20020a026d15000000b003753523b643mr3579915jac.144.1667089132781; Sat, 29 Oct 2022 17:18:52 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co20-20020a0566383e1400b00375126ae55fsm1087519jab.58.2022.10.29.17.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 17:18:52 -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 9/9] net: ipa: use a bitmap for enabled endpoints Date: Sat, 29 Oct 2022 19:18:28 -0500 Message-Id: <20221030001828.754010-10-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221030001828.754010-1-elder@linaro.org> References: <20221030001828.754010-1-elder@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748069877163617477?= X-GMAIL-MSGID: =?utf-8?q?1748069877163617477?= Replace the 32-bit unsigned used to track enabled endpoints with a Linux bitmap, to allow an arbitrary number of endpoints to be represented. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 4 ++-- drivers/net/ipa/ipa_endpoint.c | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index f14d1bd34e7e5..5372db58b5bdc 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -67,7 +67,7 @@ struct ipa_interrupt; * @available: Bitmap of endpoints supported by hardware * @filtered: Bitmap of endpoints that support filtering * @set_up: Bitmap of endpoints that are set up for use - * @enabled: Bit mask indicating endpoints enabled + * @enabled: Bitmap of currently enabled endpoints * @modem_tx_count: Number of defined modem TX endoints * @endpoint: Array of endpoint information * @channel_map: Mapping of GSI channel to IPA endpoint @@ -125,7 +125,7 @@ struct ipa { unsigned long *available; /* Supported by hardware */ u64 filtered; /* Support filtering (AP and modem) */ unsigned long *set_up; - u32 enabled; + unsigned long *enabled; u32 modem_tx_count; struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX]; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 564a209f75a0f..ea9ed2da4ff0c 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1666,6 +1666,7 @@ static void ipa_endpoint_program(struct ipa_endpoint *endpoint) int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint) { + u32 endpoint_id = endpoint->endpoint_id; struct ipa *ipa = endpoint->ipa; struct gsi *gsi = &ipa->gsi; int ret; @@ -1675,37 +1676,35 @@ int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint) dev_err(&ipa->pdev->dev, "error %d starting %cX channel %u for endpoint %u\n", ret, endpoint->toward_ipa ? 'T' : 'R', - endpoint->channel_id, endpoint->endpoint_id); + endpoint->channel_id, endpoint_id); return ret; } if (!endpoint->toward_ipa) { - ipa_interrupt_suspend_enable(ipa->interrupt, - endpoint->endpoint_id); + ipa_interrupt_suspend_enable(ipa->interrupt, endpoint_id); ipa_endpoint_replenish_enable(endpoint); } - ipa->enabled |= BIT(endpoint->endpoint_id); + __set_bit(endpoint_id, ipa->enabled); return 0; } void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint) { - u32 mask = BIT(endpoint->endpoint_id); + u32 endpoint_id = endpoint->endpoint_id; struct ipa *ipa = endpoint->ipa; struct gsi *gsi = &ipa->gsi; int ret; - if (!(ipa->enabled & mask)) + if (!test_bit(endpoint_id, ipa->enabled)) return; - ipa->enabled ^= mask; + __clear_bit(endpoint_id, endpoint->ipa->enabled); if (!endpoint->toward_ipa) { ipa_endpoint_replenish_disable(endpoint); - ipa_interrupt_suspend_disable(ipa->interrupt, - endpoint->endpoint_id); + ipa_interrupt_suspend_disable(ipa->interrupt, endpoint_id); } /* Note that if stop fails, the channel's state is not well-defined */ @@ -1713,7 +1712,7 @@ void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint) if (ret) dev_err(&ipa->pdev->dev, "error %d attempting to stop endpoint %u\n", ret, - endpoint->endpoint_id); + endpoint_id); } void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) @@ -1722,7 +1721,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) struct gsi *gsi = &endpoint->ipa->gsi; int ret; - if (!(endpoint->ipa->enabled & BIT(endpoint->endpoint_id))) + if (!test_bit(endpoint->endpoint_id, endpoint->ipa->enabled)) return; if (!endpoint->toward_ipa) { @@ -1742,7 +1741,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) struct gsi *gsi = &endpoint->ipa->gsi; int ret; - if (!(endpoint->ipa->enabled & BIT(endpoint->endpoint_id))) + if (!test_bit(endpoint->endpoint_id, endpoint->ipa->enabled)) return; if (!endpoint->toward_ipa) @@ -1970,8 +1969,10 @@ void ipa_endpoint_exit(struct ipa *ipa) for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_exit_one(&ipa->endpoint[endpoint_id]); + bitmap_free(ipa->enabled); bitmap_free(ipa->set_up); bitmap_free(ipa->defined); + ipa->enabled = NULL; ipa->set_up = NULL; ipa->defined = NULL; @@ -1997,8 +1998,11 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, /* Set up the defined endpoint bitmap */ ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); ipa->set_up = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + ipa->enabled = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); if (!ipa->defined || !ipa->set_up) { dev_err(dev, "unable to allocate endpoint bitmaps\n"); + bitmap_free(ipa->set_up); + ipa->set_up = NULL; bitmap_free(ipa->defined); ipa->defined = NULL; return -ENOMEM;