From patchwork Wed Nov 2 22:11:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp169647wru; Wed, 2 Nov 2022 15:12:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4JQpPJQ3HtEnf0wLSw9w3NS59ITjsdUmnkFCgCSjacTfTSWrEfbAv45LjwT5ot9WprRCN8 X-Received: by 2002:a17:902:bc83:b0:187:85a:28b4 with SMTP id bb3-20020a170902bc8300b00187085a28b4mr25148047plb.96.1667427153696; Wed, 02 Nov 2022 15:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427153; cv=none; d=google.com; s=arc-20160816; b=S3+ayWBZTK5WoZgB42+kDkHRTC7GT057sBRPaCYGKeaC03wBnYO7pAz3PH7QYHpwC/ QhgjiG+tqb9z0eqWz2fNkm3xrevoJXjHtDzHIcRyP88e1xAk5JP5sg/+FgJ2T8zJaAZi FQORM1A+BZmfw3jKwum/Ji1Y2F47Kyk5TcGkTrFwL9frkfuOOytBvjm1keY+z09S8Ov/ ANToW4yW6dcgLymuI6HT0PY7ROxdzqNuess2WV1dOs/eLM1ObEKrRUlD4jeWzq24+JIA I1tdmRMtEpKvrRA8MXVfnmiVQJE4NFjXCr5/69VAUfiuJ83RjW84yeOE9v36ndN8RsIh fB3Q== 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=fjwHy2EOs72mjMgVwnYXgwqloPryk7/HBS2vFoZoA9a4nec3Of0d/OBBRo1quG/f2s hN4hKmlwTKvOyd4rodBLBjKY9m6BeiKkAqg61ocSocQgvRGByLYciVE7OIXkU84ZFdeC 4Y9e3NtblHAn6hcCYV26lNdP8ZBvLmDDL2pO9sidxtHW/vUEMJiJTRELiFZYZmFX1UGB 5EwFd4i4B0uSRqlmHsqb3s73YH5k0f+seqD9OA2ZHPMfCPGhHzASL+Ps6O64D2jcOgnl 7l6L0J64Y84YJsW+TgwGHRUjlCG2bvphVKf5RQuOlBK+KHqAi73W2wgfY8yjhDQNG8lb W0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QWAql5sr; 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 e1-20020a17090301c100b00186a2532cb5si19027453plh.3.2022.11.02.15.12.11; Wed, 02 Nov 2022 15:12: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=QWAql5sr; 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 S231361AbiKBWLu (ORCPT + 99 others); Wed, 2 Nov 2022 18:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231391AbiKBWLq (ORCPT ); Wed, 2 Nov 2022 18:11:46 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 485AA6179 for ; Wed, 2 Nov 2022 15:11:45 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id o65so16238841iof.4 for ; Wed, 02 Nov 2022 15:11: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=P4nuwgGkQOaib3BwT5hOD0oPhyITqBv+siRpxH4LVLA=; b=QWAql5sruNOYapQ8D3iedsH3hR0D8NvgG5miWD7mQ2egdNW9qeymNJSEPbNeqX8rtt PnEoUfiE2PNslqNekLVwrC7U3xCPwCeTTcCA4dlwffSIPNJSlWLtDj1Y84nf6kauIZ7c HzYyXPIiJ7ZTGRMmVnGVBwc/X/mIGvBlCy39CU0WVYa7PndE/GrfDU3ln3aSO/N6lpNR y2rzM8Pkpk0EbIO6LcEkqCcZWBWaO2lhhw6b9FVTMnQ/EphPsPTKhcOrH68qOQHwAmjG 7OkSn79SVka13cLXQrBGRXoHJCrnoLJjoTW2hwLna/uqV0gAS45MOFG9VjcQtcMzW3xx CNxg== 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=gCjNlvdDBx7eBcZs6hySBE1bstZ1hulu7nUVZfMSqTR3r7rlmAaKeP+IbG3U27UNQJ OWCEf+bkwicacJX2UenPPTVbDUY5L3z2avvz2zH7BCUTrNitpdBicgj9uGciaU3eP4dx jEtaTbIKYEbdL54Z5BoKXt2BKOD/O+uisOrvebMpa33ZmuNw/xl8fEFAW87G2UHPTAmG dHwyzTvekD3shK6+DjYqrfEBNZ9wzuxp3mzB4/6NQhqDYBwWmdl53CEZRQYFer24cRjf D2UutROPquliqBathGA0lvqubtI59EX/WSzFRJh0GhBAzBF4pLxQUbezRVnQfGJruP6W E6OQ== X-Gm-Message-State: ACrzQf1e+rja2N0Q7hZxalLApAHpDmNwe9bbiumcRH57A0+Wp5Sz1tbX X8KSV/SNm+YF6HGQpowiki97yQ== X-Received: by 2002:a05:6602:3420:b0:6ce:3066:181a with SMTP id n32-20020a056602342000b006ce3066181amr13433619ioz.98.1667427104655; Wed, 02 Nov 2022 15:11:44 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11: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 v2 1/9] net: ipa: reduce arguments to ipa_table_init_add() Date: Wed, 2 Nov 2022 17:11:31 -0500 Message-Id: <20221102221139.1091510-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424094886429472?= X-GMAIL-MSGID: =?utf-8?q?1748424094886429472?= 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 Wed Nov 2 22:11:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp169764wru; Wed, 2 Nov 2022 15:12:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oob5ArbVfH+TgL+FBznA1mZowv6Kq3UiZhXYig4M+UCOedkIWntA7f14VIF6uOdQ/P6xF X-Received: by 2002:a65:5386:0:b0:46e:dbd3:413 with SMTP id x6-20020a655386000000b0046edbd30413mr22816105pgq.240.1667427165438; Wed, 02 Nov 2022 15:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427165; cv=none; d=google.com; s=arc-20160816; b=YnhjgDJ5INWOWCQDE7yKkkDof6aotgG0O4TV6/7bGackF71EHxYOR7+Ok6GpFPUv7I fasofV75qq6pa+X7hCsqBrP2O9TweXmhpmQEBL5E7dVmHH9/46Ir2g12yck4O2IL7RRL u+R+OMkhKQYJzNC/YUig3QOJboZlacxkR4tykzO/a9OPJmh560lQq8OuAjsvEjOADSuw NAI1jjJ+HURYguSw0KgZsTdzfqkxhl9/XijqXb9YQnN4l4u8b+pC+KeXoYhwyCS7OGzF xCIa5IuKr0isKrHmuhkcpit3LLrwhgkdEwDY1LZRNvriTkzs3CbpEjXFgeFqqli3n6N5 OMPw== 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=TuSIm6zkmedABAvq2UwBAYV4xbyYTMteFf1q6GY7XpAiozo7z5v3EqwSsO/nasEvsO 8KXY6W6CsWsswN5vy81k+ZD4AEf3eDphGTtUtK/0jZoXSEdGZs/BAzun03yPN1fMTIpo 44eX7UYVhjLTP9qmZ+NCxlOQIGSu5r17XRUOtozPYTV2tNAMnc9lb6xzaAnzmzxawujX Co+4KkW4sw2DloyccQ2blNi8JIEZgptLGCQncQryZM4aIJ14a9jk4MyVhxMhjuh+2Waa 92H2008iJ/k1Gkc1FLpo3anXiXN0G9LNdsaqbei1Hc7NFENeE3ajWqNHN5bw+/AATY+0 3YNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SNCDbmVK; 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 mw8-20020a17090b4d0800b0020c4fd9306bsi4090315pjb.166.2022.11.02.15.12.21; Wed, 02 Nov 2022 15:12:45 -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=SNCDbmVK; 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 S231483AbiKBWL7 (ORCPT + 99 others); Wed, 2 Nov 2022 18:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbiKBWLs (ORCPT ); Wed, 2 Nov 2022 18:11: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 9B9586460 for ; Wed, 2 Nov 2022 15:11:46 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id y6so13257409iof.9 for ; Wed, 02 Nov 2022 15:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lCQLB8py1X/NJwP3+BLi4r+G0VNoFsbUa3BWr+xCFoQ=; b=SNCDbmVKKb+oXB9d2PZfmQ6sGlOAEy3WH57N0KnFlaRTGlopsX4RUr79DscWszmB8b PvOTMZ/Zje2FeFenOosF179eV+2gHKT+RhYyJJxeqalnyvaFj/Ko9I0uRe1njB26FVIu if4zwr6/CLuEGz7bb0ftItu0VKeJFDYb3ldhClkNqMbeI75zlVEdeD2DrvgaLePddd8C xZtLIB83w2j6hsppp8THKQDIx0y26rOZuf4miBG9qpshQKHxl9uAt3StG5ztrUC8RoYp S58COHsH9YR141+iYlNzVv3Z8O57oS3p220BASIl8IMnBbddAy2l4VCsEiuLe+OF0x2b tG/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=lCQLB8py1X/NJwP3+BLi4r+G0VNoFsbUa3BWr+xCFoQ=; b=eJrHQQjhKt9gIC6jCMaowxpySZX08t9tO93W4QN7vmp2EjZhfROSwvAD4FewvdLs3R 7Hfvkkjv8B99k07J+wqTh3KKCtJ42IekVs5aveLStKrpVevKpm+RVGvbB3IPTBv/Kapv UNcr3tuugHX2biD4JNpccrjMyFaJmTCBiQPKrKQY76FnVaLN+cdIhF5CZHEtbWjXbeVJ ciUttyRitbefkYPChp8VESBtXshRP6lY+oQFCb8LwJMvjTfn/WuCrfnfY/CXgg3RTa+6 74cDLDHHkhuBRQIlwLw1BnhVgYb8IwPmN8cSIR/W3O9lGvplX1k5AmWeAwSZzyJuChCk zRJA== X-Gm-Message-State: ACrzQf1FT1UHxNVsNK4k9UFPJHv9XRqW1VjoAkcNt+6eAlvvFMYqm1gB ciG+KcL5FB92OOmWX/fYlOE5oL0ja+CDKg== X-Received: by 2002:a05:6602:2dc7:b0:6a5:14e5:d709 with SMTP id l7-20020a0566022dc700b006a514e5d709mr16658698iow.54.1667427105992; Wed, 02 Nov 2022 15:11:45 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11:45 -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 v2 2/9] net: ipa: use ipa_table_mem() in ipa_table_reset_add() Date: Wed, 2 Nov 2022 17:11:32 -0500 Message-Id: <20221102221139.1091510-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424107419257067?= X-GMAIL-MSGID: =?utf-8?q?1748424107419257067?= 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 Wed Nov 2 22:11:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp169898wru; Wed, 2 Nov 2022 15:12:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BGUtKhJYIQhv2hS0DBdYboa3B21JGMMBhcaAuWDIBWV5wwyb/KIkN4eGyPCQ1pcArBYUF X-Received: by 2002:a17:902:aa42:b0:17e:b779:dadb with SMTP id c2-20020a170902aa4200b0017eb779dadbmr27337810plr.11.1667427179032; Wed, 02 Nov 2022 15:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427179; cv=none; d=google.com; s=arc-20160816; b=Q21deAV/OYPvx4TO1DlyKS/796ZK8CKdzl/F1isuiHfzQw8JdZlQ/Ribz6hpcvStA9 YaWkISKmnhvO9iwWkq9KgtwfZQasS+TMEK4CDHBsku0lrCmKWCdVue7ZOfgLnMF0gSpB EbviG842BCJxraOufpubcQDHzeVhOsz4eZC6ItbEiAcIuPC1af+/cpJTNS6A8qBihOUj PfZQ5uKLMLv2nnyR5UC6yuwUANRJXidXJEpA6fRApeRLpo1pNnqPh8uceDGhtzGF+0Vu e5Nnyl/gSDYL+1CAtki4fGzYM6A2KMR8ODO4aesUIBgbNlUHAmXE5I0im+S/kFxOrS+D BqfA== 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=VH5zZ8cf/d9IdZvUdAHqhIXm5lYtmJUVrh01DQlr9HnZKcPULCzmOSGfsJ9sHN1/NV gj8UZw+e6N5gXD8F4YTZdi7Zbbg0PrZ/ht9AeH0pTC80n/w4nxdGQk8ZL3nrOwIpiRie DL6+w7olYSZZ7+Yc5CDmi9TqB38woCLl3zjZih/G4gnPfQuBraqEX+7ZGhimuVwaiILW foqoZafYE3V3Qz1KzNQlYvZr76LHYq7PLUH7NRwbcDr12H7HfZln/cm6dHm7iaOihgkC uxTNaG8E+KAzBtwsuoePOkjwoN+8sgmq4DDd7d3hKnjWMdWc787+bYSVGgxtFxxgduIx +8zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E8zRVS9F; 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 w2-20020a63f502000000b0046f1263abd6si18034196pgh.661.2022.11.02.15.12.35; Wed, 02 Nov 2022 15:12:59 -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=E8zRVS9F; 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 S231478AbiKBWMD (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbiKBWLt (ORCPT ); Wed, 2 Nov 2022 18:11:49 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F01E6445 for ; Wed, 2 Nov 2022 15:11:47 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id p184so16211347iof.11 for ; Wed, 02 Nov 2022 15:11: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=44inpgxMtLGpYTBDTKxPiEfpRDa0k0SEfGcjuP68SFA=; b=E8zRVS9F27rajNfZCJWIwaTxqcrfrRyozWVG3XQoiJ8geI02YDsiE/2sOfBxZJVxVa 77XMug2VsyzU22K+Psprfc76f4gTh5GroQQql8AS8/rwlPm8ohIngsEcqrVz0R0J973P VVDPDtnMWZShk+x9LRnIyJnMzWpM5ohFyjVUCBxfCdlUUbHR1JuIye7p7WGSErPbwF2L K8ZrHNAt28nJUo4rcc4+S7nn/hyabbD0IzRm8pVGxB8lRf1XUSK8K1WI9W5vrd53dC4U IygDp9EIwZOGARqXKtDOows34n75OHdnCz1DrRfPS8RpUVUknEvaIxW81hutDvsFicNy CKdg== 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=ocHmLaaNagvE956T64icCT2AaddDf8fCIJzpH7RxBBAXASr6HVid1M5CbvyWBUB6of /pStHlvAXuJYGdPhbdlouUhMW941nTzB7W5PR9Ll5QWxVfqBBDq4dxi42Ee9UsSD57HZ QZDCoUyXT830/HUGrpMRZ/YQCuRhATtIqg83hTaCWql1rZNayAj3OrHyfx95OL5T2IOW DSqbetIBXbv1plS7+qfMDmwtOykYZn3Ch8ifjkbDxSMdztUcn1Lj26FGLsWM83/D9pQc MHqv43XzCkZWSk/90pKqA7lFSsUTyyNscUJ1IR2oiJwZgSrMGzchlW655GcaX1za370t Srog== X-Gm-Message-State: ACrzQf3CojbHsJWrxJZMreI3Qk1i9aYzWAFh/Q5tNX0u94w6m0tfK7b0 0M0uU0gG3TcK84XjQgmC9T+pyA== X-Received: by 2002:a05:6602:134f:b0:6a5:3fdb:574e with SMTP id i15-20020a056602134f00b006a53fdb574emr17598065iov.218.1667427107220; Wed, 02 Nov 2022 15:11:47 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11: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 v2 3/9] net: ipa: add a parameter to aggregation registers Date: Wed, 2 Nov 2022 17:11:33 -0500 Message-Id: <20221102221139.1091510-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424121979237089?= X-GMAIL-MSGID: =?utf-8?q?1748424121979237089?= 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 Wed Nov 2 22:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp170406wru; Wed, 2 Nov 2022 15:13:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VHn0CHNRx/uY5TMvQP462V3bUBVwsL2q3UBzS7SJMZhtqbqhkpyqrEQIehEoPy3W96yUe X-Received: by 2002:a17:906:fe0b:b0:787:f1d3:2105 with SMTP id wy11-20020a170906fe0b00b00787f1d32105mr26035684ejb.83.1667427234325; Wed, 02 Nov 2022 15:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427234; cv=none; d=google.com; s=arc-20160816; b=oj61enNLlm4g9Sa7G5W9C7vKwP3WakSwSSwPiuGKui9d7DJdn0SsDxttKdF3K2nxzX yO+QRSupU6iA8JvKR9ptOePVJCU4ltzfKXb1TxEk1ZwHfceR9AV7J4EPVocRho+mGRHM g4d6uYURhPDvgoMtIR74MVxdXILU4rhrWWK0LLOSmFnHGxIweH4utv0RzQXrlV41dCne mwdv/CZ4A6eXfL94rei9v/pGQ8E0waGTAxpUvCXNW5IwLv0Wsxz0s2gEomcVsISZerjD 8w4+ZMPnO0rX34kmPke1k9QzAO5tfuGeBa1iN7y/Hec1okI37Ju1KOL6+OunWugrg+ug 9jEA== 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=F6WYGEYWafEUBfOGDR0MccReIt3U1dfujIJdCn7WgXi6bdxgJFLKWrX/UZP8ZysfeH aao+QDWMOeebDzpYTtDyLHub8i0bxmkvAff62I9Erq7AIxpMfjcjdCV0zq0XsNNsaJ7m xMh0R/22Y5lctJTW0eLnKIpA8QcBO+ggS9bLp7iLIq2oVGRmcMZEDZNfDJlH+n+RuiqX 1bIuHC5Akm28eJdeOEaowGY4AjvnrpABLo9hHr1S2arkxBv+j//rwA+qmCcUN4kt/TQ3 BSJm45ybuwKroi2BxADRbKdQE1S0ARZcVaKf6w2fooPtTY7lKWg63tgbttSZS0reiKFe MjXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bkzPZGX8; 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 h14-20020a05640250ce00b00461c8f80e72si6668892edb.629.2022.11.02.15.13.11; Wed, 02 Nov 2022 15:13: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=bkzPZGX8; 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 S231346AbiKBWMH (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiKBWLv (ORCPT ); Wed, 2 Nov 2022 18:11:51 -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 0D00D303 for ; Wed, 2 Nov 2022 15:11:49 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id h18so164003ilq.9 for ; Wed, 02 Nov 2022 15:11: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=ZcCihh0f7Qr/rXNZsx/9L0DCMnXVjeXTxfp8VH2CZiE=; b=bkzPZGX8D5ZtdPtTrfyB8KoUOND6iilJEeMX3Qy+KmyjK+PQWQSuV/2yllmfp/MYR9 1/72vdRe7ywfHXQRHQjmJnyOKjZZqrpe7YNFGK24Bf0pglwqK6lWP+qj4CTvYN5fuq2j TJXJ+67xEeEam6NGevPkZKYG2lQJEwajQe7Toyz/+kmcMmh9eYIHEANngZESkscgE4h8 TfSVlmtWDr1EHybGUzXNJRYxDr+H1tfiIZNXY3VUZpYhimtt3+LpX52QdamxhcP6qhaS 1SZptwnG1pQKlFCdRTvVO13Ox/N8I6l/laM+FDGkiH/edHJHirhIoNEVSpEK+LTjKkrM 9H0Q== 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=K99qeLxQTUy3D8o+DCRaSr2sktvPFBD9b5GjAvX9D8FKfkHQkhuD73VFrUyk9Iw1oH DS+1HGXANNPCgGHYv+bjhirW45n+Wb6fRBg6MiHmeB1uxM2Lq+H5Ou8Gg8enW0+UwcnG cND6JDRMgBkIYu9RDtpoMxao1HI1vHLj+ze9CM0PLf8KAXpxXoc5QZb+z1WuWxKCAW3G Elh7fUZ2vStItckoWLJjryu4YbQnnFuoMzjnOMLCMgWVSq887KrlITADjifZT4p48PuD lBQipKjDBIIdLjxIwb28HoIBjxQIkREeKUSQqVxz5JzQqHdJl7zOZBD81/d0AK8jFzNM RTsg== X-Gm-Message-State: ACrzQf3YMq47a3zTrQbK68iGJrZbeJrS+B8QUvLKlCb3zCU8kNHpYr24 Ox7wR1s+MSkq/AK1CxWY2kApdQ== X-Received: by 2002:a92:c146:0:b0:300:b1b9:dbb0 with SMTP id b6-20020a92c146000000b00300b1b9dbb0mr10302528ilh.73.1667427108335; Wed, 02 Nov 2022 15:11:48 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11: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 v2 4/9] net: ipa: add a parameter to suspend registers Date: Wed, 2 Nov 2022 17:11:34 -0500 Message-Id: <20221102221139.1091510-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424179750171137?= X-GMAIL-MSGID: =?utf-8?q?1748424179750171137?= 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 Wed Nov 2 22:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp170916wru; Wed, 2 Nov 2022 15:14:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ff+O3aDALcI3Z4QUFKONPsFUBz21NnufeFjubsnxsTox2wgdA/X4RSaO0hCI/29tZqCnS X-Received: by 2002:a05:6402:5ca:b0:43b:6e01:482c with SMTP id n10-20020a05640205ca00b0043b6e01482cmr27307324edx.189.1667427299679; Wed, 02 Nov 2022 15:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427299; cv=none; d=google.com; s=arc-20160816; b=ohSecnfqOu1nmnZ8FXTfKBC3CPOaN2qiF6cRdH0dvMdfv3gyYZ6bPOCRJ84ssNYMeY TXVD7BLs/fD9wCVC+GB7QiPE8dlDMuFq4gbUTs1doBMGwep/1CQKEgsaBvaTkuq9l2EF Om7qrv9UpDw5x/9xkRvWMYblOOXHTphtWtrHNQkgdcB+cIFcAqKll+VImMG0SjaKr2yh J1j15Vjpib4yBG0OFeniXy2Q/49YiQLSThVOUVQfzFV5SJ17tKqAZchHp1b/5FS35IX9 GngrmQBF0uDZYXLcCxIhIaUVB6VHfSaFZssWR5mA/1cjOFWGrh8xR1dwAk3N/tqSp0DZ 7Vjw== 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=VEI5E4A3vhqdvxEYC9B1ojiSJqRCvJ6S+f0LRwCXl84=; b=V8Ji8D03uKEbDKGtPAXOmD9UpVAEaBa5anAQqnT4GUDQ6Ota2+vylbKhPCIfkaCouf AICLIQK6PZEuL2RwMeX309oHt8D/otOfZH4zq4PSrELw8e7k1sanZ1fA2ZgZEg/2Kan/ hctNBArIjPKg0gRvXeBg6E8LqoFPD7qFeK52HNUv4HEvq/zWM0bh3opk8+h8jij1MQow bJIdxrxBSUsgVCDFxM1jIkLh7qO2KcYwiooAVSEsTAiTIRfFF4vm+9tSZCVKMT4FQyJ0 o48rar1iKjRCj+zDVarA++Bzz+bs8bf7KFmjoU949g3Zo3IOUv29hHlKTEw6d3Td0ULz HPeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sJgJzXAq; 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 c12-20020a056402120c00b0045a1e2373dbsi13563950edw.44.2022.11.02.15.14.30; Wed, 02 Nov 2022 15:14:59 -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=sJgJzXAq; 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 S231596AbiKBWMK (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbiKBWLz (ORCPT ); Wed, 2 Nov 2022 18:11:55 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF6D2BCAB for ; Wed, 2 Nov 2022 15:11:50 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id p141so16228248iod.6 for ; Wed, 02 Nov 2022 15:11:50 -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=VEI5E4A3vhqdvxEYC9B1ojiSJqRCvJ6S+f0LRwCXl84=; b=sJgJzXAqRNzN7lh5eguknfY6N9k8MNwIdJZU9RBg0YAZftpPvzdYy8wNCGktoNwnTD w8sQ7LkwHni0YBJXn80O/6SAfXlZkiGX4LGlaaYZScGTdQ18cxx3AtmyB1cm3ddt0e2E 5iLlxoXHnT1XX6/vep5twV8gz0QJjjNqqLNvv3qbSwlsKrTZtNPs2PDCGxus0glIZjyP PEDTxiA2D5KesViHh/zHOTE3vNwVFGVKmOH6+n96jE9jHO83/zuUa9T3sGGBrEE78t6X e5ZyoN8sm0b6pFcUJvlGmx3syzJ5y7ptwO2Jwi4Y1y/WzZnalxVxe8R5T4nV278cWFmk 9/KA== 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=VEI5E4A3vhqdvxEYC9B1ojiSJqRCvJ6S+f0LRwCXl84=; b=C4mv2uLt9NV1xUWvaP1wMACLdtTSaJ04ED/KeEIkKKn8RQVXWUw8kRkaq3kIOoLqQJ R+Y8H5lP6OUSuD2Z+2TewD6l4fcw4ZlR62rhrpaFIVe1ggnwa+D+qcckIq1+UD+R/pqg wyaS4+oh4U5zTeUFKqDizcD7/8byeBBx96HZpL6pLW5T3S8LLctHDlySt0YPS7E3AZZE Nw4wHkmqzMRMAx0xI0ofDZLZyDv/HCrcAFiTkKmbFsJasjkW3cavJSrrHMzSjegvYerc wJrxo+zNdKLrG+XFBc/uephqDNMO+IfPkhH04TYdqrBvRl+M2TuoNLy8Asm17to6rTkD fQbA== X-Gm-Message-State: ACrzQf2cBlvjKFAzDNkWumx/YWn9BmBOSxeZ/NHsdC1oOVrF7MoO632f 08fOBP06zRTNU4ujxDiINHwI0Q== X-Received: by 2002:a05:6602:1495:b0:6d4:a262:aeff with SMTP id a21-20020a056602149500b006d4a262aeffmr3399533iow.35.1667427109455; Wed, 02 Nov 2022 15:11:49 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11:49 -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 v2 5/9] net: ipa: use a bitmap for defined endpoints Date: Wed, 2 Nov 2022 17:11:35 -0500 Message-Id: <20221102221139.1091510-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424247983628370?= X-GMAIL-MSGID: =?utf-8?q?1748424247983628370?= 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 --- v2: - Don't print a message on bitmap allocation error drivers/net/ipa/ipa.h | 6 ++--- drivers/net/ipa/ipa_endpoint.c | 46 +++++++++++++--------------------- 2 files changed, 21 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..abc939c272b5a 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)); } @@ -1993,7 +1980,10 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, if (!ipa->endpoint_count) return 0; /* Error */ - ipa->defined = 0; + /* Initialize the defined endpoint bitmap */ + ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + if (!ipa->defined) + return 0; /* Error */ filter_map = 0; for (name = 0; name < count; name++, data++) { From patchwork Wed Nov 2 22:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp173166wru; Wed, 2 Nov 2022 15:19:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46Zo0sMxSe8wBZmDD9XhISbNgYXgLNbwI8d2YEcN18cMsPRQoMVWuyCUY3tNRvgSmIPWjw X-Received: by 2002:a17:907:3d88:b0:7ae:943:1cc2 with SMTP id he8-20020a1709073d8800b007ae09431cc2mr4188406ejc.675.1667427549663; Wed, 02 Nov 2022 15:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427549; cv=none; d=google.com; s=arc-20160816; b=oUxB3D0gNoq4vEa+s+UXs8FsUIPnMX0RtlICPogPH8sAl8btPpO5k5S535Vvw6gXY0 aIxT0i8Uxw3FAaa2dR2QoYw1XWa8WHrRoPcFcjtAAnrZZIqIjti6IU9B1HtV2AqDsrVZ 9tSG6TkPqJPku1FAxVWjdT4AGgRz/IS6plEUnq0blnFh8WBxXtCflLLfVjgmU2DxyUSj eR4jfdhuzMd4wB8ZED/lOD084oAhv1ul4+zTCCc26bGQ6UHJZwgOIA7vqAqgYiWXwaV1 wMg7TcqE5FdVfABrlj9i4GmwhgGQeI6Pn0uznTeyhbUlLw0Wkov8qG7PMEuElkCIZyk7 7huA== 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=awvIszSlBYbQTFNtVRRr363ktjZrC0gWJbbrDOYC/aw=; b=Uv/OKb2ihavxVAwNQQt9ZvHUgpfmRsoG9t4PQnJ1adKTPvUI5napRe9jxH9zRoQ2kV C0Rpj1CzuyJw7OhmjU6Z1yapTTCufpO3wCk6E0LH7wcVL4Gzca3y0m6y4KEv8ROQNE3G EqmpdJIF+SaOIwy/1HkYAfAXW0wBxhmfWVRXZUNdT6aC/tr+muna4GnmmSdoGUy3JUCA I6zMK4K/WYPQkjKbRqVVeQOZrdFK7KKABGyzNurz9qMSmccXQ/gaIf8Zf5b4h+rVm3Ig gk9c/YTJiTqlp1t+cdBivJI7oXJwtQBXSRsf1fL8Xv9Psze/2oX7A8X+QFacakUH1No0 jD3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lebLyog2; 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 ji17-20020a170907981100b0078b41dcf4b8si19236011ejc.479.2022.11.02.15.18.28; Wed, 02 Nov 2022 15:19: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=lebLyog2; 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 S231542AbiKBWM1 (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbiKBWLz (ORCPT ); Wed, 2 Nov 2022 18:11:55 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF69DB4AA for ; Wed, 2 Nov 2022 15:11:51 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id e19so176815ili.4 for ; Wed, 02 Nov 2022 15:11: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=awvIszSlBYbQTFNtVRRr363ktjZrC0gWJbbrDOYC/aw=; b=lebLyog2wztMpEEot55TP04NnKX9SjVNcWNDniFxJiAhXNDUBG7PZtVGfrjk778O8X xJOVjjZ72UBD6RXLHTBI2wD/A4CDaEH/TaGFrmBvlaNVB99bUcU/5kmDICdH3kI9P3jj C81M2wiDcc4ScK75rxHEGG7nk+Aw44LWcjC7PmdL1Wi4e5Px8siVV1FxytzI4/Ac+d5L psS0FXtpoSSYingR6m+H5itkBrsTHOVjXYYyLpnAc2b+4E2am8mcfkCkiiYcwnYC2HSd P5edIo/IpJpOPq7nhlXIjBIFr5HkF2gDPEdizYYQSg3HkEPlzbXeVKJZHdZuLw7U0KPS OOZA== 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=awvIszSlBYbQTFNtVRRr363ktjZrC0gWJbbrDOYC/aw=; b=UCEq2xEEXNWT6LVG4tUOoL/lCtrryFP5DShnIuKyQhz7DZL9zXjaV2/S/qQUjmxt8K NbQ5DzcCVjWvu1SUIBWvLdMeRVSrdeY9ofXlIz8UqF8WJCkh0uYAbGHYWwcGBkt3s1TW yfQUKOX/cl45PTpGXcUHV3bcOj8kVOSUzZetSScb3bR0lNmOnqZbUvzDt0Czu8EbNs8z 9VDdv3TsWAdBB1AV5QbD4UOSmsuQVYwul7jSHA3xN+wDRQ28I+G0EobWPJcXYyJi5RIh 0HsU59BQrVe0s1VfDRdaTaqhvm9NOtF55xHcBCoH8Go08uIBTiAFOI4SiUIjijyd2E4x CQ1g== X-Gm-Message-State: ACrzQf2FIiT622jSizripQangXfJMYo0LS5zRl3HLCcFwhY6jEQKQ4kR Uuv51rew6bEPcbdAG/lGoW2kTg== X-Received: by 2002:a05:6e02:d04:b0:300:8716:e7b1 with SMTP id g4-20020a056e020d0400b003008716e7b1mr16448650ilj.231.1667427110619; Wed, 02 Nov 2022 15:11:50 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11: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 v2 6/9] net: ipa: use a bitmap for available endpoints Date: Wed, 2 Nov 2022 17:11:36 -0500 Message-Id: <20221102221139.1091510-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424509981729887?= X-GMAIL-MSGID: =?utf-8?q?1748424509981729887?= 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. Move ipa_endpoint_deconfig() above ipa_endpoint_config() and use it in the error path of the latter function. Signed-off-by: Alex Elder --- v2: - Use ipa_endpoint_deconfig() in ipa_endpoint_config() cleanup drivers/net/ipa/ipa.h | 8 ++++-- drivers/net/ipa/ipa_endpoint.c | 49 ++++++++++++++++++++++----------- drivers/net/ipa/ipa_interrupt.c | 8 ++++-- 3 files changed, 43 insertions(+), 22 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 abc939c272b5a..a7932e8d0b2bf 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)); @@ -1841,6 +1838,13 @@ void ipa_endpoint_teardown(struct ipa *ipa) ipa->set_up = 0; } +void ipa_endpoint_deconfig(struct ipa *ipa) +{ + ipa->available_count = 0; + bitmap_free(ipa->available); + ipa->available = NULL; +} + int ipa_endpoint_config(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; @@ -1863,7 +1867,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 +1895,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 +1911,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 +1930,15 @@ 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; -} -void ipa_endpoint_deconfig(struct ipa *ipa) -{ - ipa->available = 0; /* Nothing more to do */ +err_free_bitmap: + ipa_endpoint_deconfig(ipa); + + return -EINVAL; } 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 Wed Nov 2 22:11:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp174476wru; Wed, 2 Nov 2022 15:21:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6qrb+5w+hoOtHovPqnsobuyvJodYTtiNLQfTRnEIX50TTH733JDN2pnrajQlEnpNJiWizn X-Received: by 2002:a17:906:4fc3:b0:72e:eab4:d9d7 with SMTP id i3-20020a1709064fc300b0072eeab4d9d7mr25373975ejw.599.1667427713823; Wed, 02 Nov 2022 15:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427713; cv=none; d=google.com; s=arc-20160816; b=isf8zV0KesppWU4hPHCgvL5R1BY8Ad889/p2eJ7xzQYKwJ3LyB30D3yBe4ZmEE2bIJ C7jPzsICMUoVx2JnmEI3f+aS4N9dhl9wlXItK0cwtQNg0GjSNYBuB8p+ADxmEFdwS2LR 11vDie8CC1TiOv5FLre9fEtOty80o5mjOcmnznX96dHLX1jNbbn62iO69CaN2VoaW+7z hKiRvh4vD1KwOX20lPL0KKZgoBV7VpmqirostadPbYPLZQvzAP26oZaVT8/US1CojD/K ZuOaZejslpZaWbPWQwAyIlj4mcPXKptasY4vARh5Md9U3jytAkCuAvsgtucb9XRBWNJJ FcqQ== 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=I2FQR/TZoXdysImvRhkVYhJLndEF88jeNyajxedG2m8=; b=X8JzhkoYDs9+wA0EkYcaBG9LOEyCyXvbuGbiyqfVTf+9PntoAl3zEhhcXRVQ0iQUJm GkwLKYgCsFM0fuxUVfdijj0Esn1to2JVH1KOat/2KlRLhXNyLXY3qlAc+tnSIHIbR3GY twEq7OjMe2xYb9KJtQYZeYMI+w01P4Cey1UUtaO7l/IeX5k+bb6eqxtFyXoAgrm9ed6m ysCkZM8fzn1IWZDCabwHe/WTFcHd+++vko0CyYzP2/a8iNOvz6PG5TuHHLDz6Gh4hgP0 EqUdgfJc4tb9yTePOTPPhCu2l5tWICmFfx55yeZSS9bS2RK998RwsDSt8tPq1LTfn81l z9Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DKGDBHa4; 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 qw18-20020a1709066a1200b00791a67e4c04si19800587ejc.31.2022.11.02.15.21.28; Wed, 02 Nov 2022 15:21:53 -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=DKGDBHa4; 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 S231537AbiKBWMV (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231465AbiKBWL5 (ORCPT ); Wed, 2 Nov 2022 18:11:57 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE954BE37 for ; Wed, 2 Nov 2022 15:11:52 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id n191so16212876iod.13 for ; Wed, 02 Nov 2022 15:11:52 -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=I2FQR/TZoXdysImvRhkVYhJLndEF88jeNyajxedG2m8=; b=DKGDBHa4ChyspX2xHHiAqwSCoi4N6umabEH/mL+vjxCyao5UcLr5/LWPNvxvQzTRsA TQ5cIFIJq7zH9iNQpO8NegI/2BI3pyh4UNK9DtFnwEER9RX1TpSu7YTs6AwP2R36ktPM QwHTRTUVeTuGvNlfJrc0MY+5OkobF1EKSACqf51zQFDbT1l0SvcZo9TLxZAZcFq/hq6Y uKcxj3CpQWPB8jWcctK94NTmtyv8w4QUOoSkUGnpnnG0hIpCi/JYJe40xsFpzzdrRybo 1/kEbdIUyJYZO6fFG4ZJBgax82U63sf4/jDMR7l8VN8ypw5nQwq4xCghDZZdgRKUuH8i 7klQ== 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=I2FQR/TZoXdysImvRhkVYhJLndEF88jeNyajxedG2m8=; b=wWetSFOAjzuZg0rqyxz8LkgL1NStP9x5/2ObXbXUtaqP9wYeOf+Epr4vfxfqGtmJrV 4b7+o/nESM0XG87ZD7eXnDNakVPzIA2aQns9BEdk+zWlUmkvPgC/hRpcO3iSX/auMQDP RzfxuXGbgDiCnnCiubxiV9bUv0am2FI2OOFzq24uWq7vAy9KS3FbYcLEFdKScAPZEnVr bJMWoWTpC4dF1g7TaWi6jbxdb0hrdYkzNWLxo+jONXPm/VCgZF/Q37jAWN+LXqVu03S+ /mfnoVZa+FaXl6L5Qm3SN/Ff3tXNLsUU/xHu3vVQw0ij8KO3aLG5t1nZ2swvthLwtVIp qcfA== X-Gm-Message-State: ACrzQf0itB/VK1KovW0kRhAuAhl5EOXfy6kGSQ5SgHzVqIbJ0PgFXy/h IoApWfaePKkNcyTKo2Q57fdL3g== X-Received: by 2002:a05:6602:1491:b0:6d2:c228:a157 with SMTP id a17-20020a056602149100b006d2c228a157mr9917401iow.116.1667427111833; Wed, 02 Nov 2022 15:11:51 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11:51 -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 v2 7/9] net: ipa: support more filtering endpoints Date: Wed, 2 Nov 2022 17:11:37 -0500 Message-Id: <20221102221139.1091510-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424682337982462?= X-GMAIL-MSGID: =?utf-8?q?1748424682337982462?= 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 --- v2: - Don't print a message on bitmap allocation failure - Clean up error handling in ipa_endpoint_init() drivers/net/ipa/ipa.h | 4 ++-- drivers/net/ipa/ipa_endpoint.c | 22 +++++++++++++--------- drivers/net/ipa/ipa_endpoint.h | 2 +- drivers/net/ipa/ipa_main.c | 7 ++----- drivers/net/ipa/ipa_table.c | 23 +++++++++++------------ drivers/net/ipa/ipa_table.h | 6 +++--- 6 files changed, 32 insertions(+), 32 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 a7932e8d0b2bf..03811871dc4aa 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1973,6 +1973,8 @@ void ipa_endpoint_exit(struct ipa *ipa) { u32 endpoint_id; + ipa->filtered = 0; + for_each_set_bit(endpoint_id, ipa->defined, ipa->endpoint_count) ipa_endpoint_exit_one(&ipa->endpoint[endpoint_id]); @@ -1984,25 +1986,25 @@ 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) { 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; /* Initialize the defined endpoint bitmap */ ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); if (!ipa->defined) - return 0; /* Error */ + 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 */ @@ -2010,18 +2012,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..cc9349a1d4df9 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -161,20 +161,20 @@ 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", + dev_err(dev, "too many filtering endpoints (%u > %u)\n", count, ipa->filter_count); return false; @@ -230,12 +230,11 @@ 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; struct gsi_trans *trans; enum gsi_ee_id ee_id; - trans = ipa_cmd_trans_alloc(ipa, count); + trans = ipa_cmd_trans_alloc(ipa, hweight64(ep_mask)); if (!trans) { dev_err(&ipa->pdev->dev, "no transaction for %s filter reset\n", @@ -405,7 +404,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 +502,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 +614,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 +719,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 Wed Nov 2 22:11:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp172335wru; Wed, 2 Nov 2022 15:17:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76JH3rL91Lr594LZ7pRDH4IFGtKJ05+XBz25bCJO9tpFwFLDO46XKvg7/oJtiTGM8OpDha X-Received: by 2002:a17:902:f708:b0:178:9b70:310b with SMTP id h8-20020a170902f70800b001789b70310bmr26603213plo.65.1667427460435; Wed, 02 Nov 2022 15:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427460; cv=none; d=google.com; s=arc-20160816; b=b46F5y9Itfga3w8M1wLTB6w+t9BambgWT0eJ3LqynHTWgWvIr9kWH3KVmuQf4Qqdn/ 467NqeK9HQrTdBu/0T79N+5WPI1iJ6VlD9yDYvK+5UZfuNtPd9Tjno5EUQDo8RuBR1Pa 9h0hnQlEgapZ4yN/XKy+ySUwOT32QaLcN8UOuM/BbgsmDBpoYROeDW/lOCareshyKe9P XANJaFDdNizhh7Fb+wKL2jtz+6xhqV+GnCEJnZbxQVN8k6NlvThAZZieXMA9gPF+jQ4F sCK964/HvZK1VU2BJKWRUQ0XmcKqm4Bu+jxGpi0rv5hfYTzbI/Bq2Lp7WRITw5w/wHcv O0sw== 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=sMa3MR4IUQceb8ba6rkMvJ9Gew5CiKKMun80HjD3sO0=; b=oJtRJfLYpZ/WTfE57KPjVNagfWAXVVRgbjbIFAoHXrbAIEM0ColC8d03LdbWlcC4aU +G0KEuIAYqmDw5hSznN033atOn8kxc60cFdrvAGy+vAfWf49UX8UVrxzSbcTvZ1dBsLm NA5sj4W76AyB8ZRu3BpJBr3RgP8txJ73ssEChSN0gDsV/WbL4Q58yQ4BzgIc9tBga2+9 /ysWuq5samBPZ5dRg23wAvFeId+WL/xHgOaJwmEsr4YGH93HY5fDG61/J/XsVT3/v2/5 vq1Qc5oHT4nUB7E1PZ6Ya+dMl3EhEkip8Z33WQ81wTtOlaHqZUONI87yaMrx9ARR4GEO 305Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="NgarWTE/"; 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 p10-20020a170902e74a00b00176d89d640asi18423659plf.440.2022.11.02.15.17.15; Wed, 02 Nov 2022 15:17:40 -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="NgarWTE/"; 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 S231608AbiKBWMR (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbiKBWL4 (ORCPT ); Wed, 2 Nov 2022 18:11:56 -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 BFEB8C765 for ; Wed, 2 Nov 2022 15:11:53 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id y6so13257607iof.9 for ; Wed, 02 Nov 2022 15:11: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=sMa3MR4IUQceb8ba6rkMvJ9Gew5CiKKMun80HjD3sO0=; b=NgarWTE/Pma1qNwb5MSu5Ed/3/owSCgA8B3RlKb8UXMp3BsqKQivMY3LAck971dflk Oms4bx4d9v2OcM3wrFNq6MbBAm0RdtKrktSzhA7hgaN+NH0MZbObtE/alXTheSkIAlhG 0hCk+cHOtas1NfNI+HC5k43CnBMqGwu/N3eZo5YxF2//q8z9vB3U47o9Bp7gtCaBA+cl 7MTpwCixLD/hraVoWDwQyw9im86lBf5wiPkNwUEUe9I+26N4Qtm67eqIiHaQ/Ps1hiCG EGjNbHhWR8OEWK67jRev5uuDqDjmftRq/D9Jt/OQsdeT+2sSCc5R42/0JW9HPmXif1i4 vbCA== 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=sMa3MR4IUQceb8ba6rkMvJ9Gew5CiKKMun80HjD3sO0=; b=oGOZOpzFhon7iMIteGrddODF5Iap8IUxnsDyfXU7i3l2CEkKlALtWWYs6deo1EhjpZ th5N7AYQGE6uckDBC+ZULveDga1+CL6SZlkSmEPTbJzd67hOx43Z8CuncMW3+2s1jND1 iKGVUwHESGh8cAVZTp8fdIHqWlmpS9KDaw0bteWtFSfRr0AU2VJulQYqfA8Nk/EZ+JTf 5+YmXD7Pqmx64nYN587alOe3ovugpgtxZL90UplqWGhY29xYTymVJ035HQRi5SotZYlE OZfaSCAxGC38Sog+AP7GITM8cYzngsjXquorkvyRh8c2mUgDUIU5dIdBkt3t1fjs9gCw gctQ== X-Gm-Message-State: ACrzQf2LwBBCOx1DK98UAMSSI/Nr0toSa1tVDxV8/HkSCGIC7rT1P6R2 vvfg13MrXd5SidNwMWRv6470Lg== X-Received: by 2002:a6b:7e0b:0:b0:6d1:1d92:90e4 with SMTP id i11-20020a6b7e0b000000b006d11d9290e4mr12102439iom.79.1667427113106; Wed, 02 Nov 2022 15:11:53 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11: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 v2 8/9] net: ipa: use a bitmap for set-up endpoints Date: Wed, 2 Nov 2022 17:11:38 -0500 Message-Id: <20221102221139.1091510-9-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424416868595537?= X-GMAIL-MSGID: =?utf-8?q?1748424416868595537?= 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. Rework the error handling in ipa_endpoint_init() so the defined endpoint bitmap is freed if an error occurs early. Once endpoints have been initialized, ipa_endpoint_exit() is used to recover if the set of filtered endpoints is invalid. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 4 ++-- drivers/net/ipa/ipa_endpoint.c | 38 +++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 19 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 03811871dc4aa..3fe20b4d9c90b 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; } void ipa_endpoint_deconfig(struct ipa *ipa) @@ -1978,6 +1971,8 @@ 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); + ipa->set_up = NULL; bitmap_free(ipa->defined); ipa->defined = NULL; @@ -1999,11 +1994,15 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, if (!ipa->endpoint_count) return -EINVAL; - /* Initialize the defined endpoint bitmap */ + /* Initialize endpoint state bitmaps */ ipa->defined = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); if (!ipa->defined) return -ENOMEM; + ipa->set_up = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + if (!ipa->set_up) + goto err_free_defined; + filtered = 0; for (name = 0; name < count; name++, data++) { if (ipa_gsi_endpoint_data_empty(data)) @@ -2017,15 +2016,20 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, ipa->modem_tx_count++; } - if (!ipa_filtered_valid(ipa, filtered)) - goto err_endpoint_exit; + /* Make sure the set of filtered endpoints is valid */ + if (!ipa_filtered_valid(ipa, filtered)) { + ipa_endpoint_exit(ipa); + + return -EINVAL; + } ipa->filtered = filtered; return 0; -err_endpoint_exit: - ipa_endpoint_exit(ipa); +err_free_defined: + bitmap_free(ipa->defined); + ipa->defined = NULL; - return -EINVAL; + return -ENOMEM; } From patchwork Wed Nov 2 22:11:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 14508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp173395wru; Wed, 2 Nov 2022 15:19:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78jSvH4iwFXHVR1cs3x5c7JSkCtA1A9E/i1M68imHLTZX1OXJQyMlNGn0KCQtsLcm5QyB0 X-Received: by 2002:a17:907:7da5:b0:78e:2c3b:55a2 with SMTP id oz37-20020a1709077da500b0078e2c3b55a2mr25835253ejc.96.1667427571031; Wed, 02 Nov 2022 15:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667427571; cv=none; d=google.com; s=arc-20160816; b=pg4psCpV5EaLwEe5XHNhKrXBxdmOjBwKNJNHlj1wl5IQ2cFWWfuRkcYQOfjmjCxq8W VfbiiWKG+V9W4+zXzCUxZsXLOJq/O19sRLw9QSF5Jy505jfAjdKoonWlLE0xNPhBT1K3 nfEUuIzpnQXVfCphyFY3XJSQkGujvf2pI11NhW4NykW5NUf1mSfHaPdkktNmYvXoWUrh vrrT6KF2Sycl+GGiDxdqBZIi7Tb1reiVFybtRxhrB/O9WHcvwpAPNoI+DECYxlc2uvBc cr9fDi8NT0yqLXpyoGlUP6o+XHOcLZGSKzHq9+aDVOfEyxhB3pI1wGSHF1xfzfO923u9 3zWA== 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=+xtIdRfPlPgVtPzZBa18RgWUGmJjs2ni8p7EMA1XR/M=; b=YdpR5P4Hv96R1JFHCGMswn0tImH+RoFsF3aG2s4X/9UUYNaQJE0qToj51x5ZeRLPG1 YpYE3ymx87HVjl/utbUTB+x1pvmVBcJQ71WmDrpUVRmKwjqfyzk7MpBUQPMcuEJKmrWQ ntR7L84oConHpKMeax7AO5R0MJTqNnECs8c+C3jsQSTE5NCPj8nnkGXtVjcAbv8WTsi4 jRU8/PCFQtIBIUbvEYZJLa9prW7rbaUKMr1E6Z9E//kwvKaPdy0PrKNpUueufEeSfJLq XOcsNt0h9SJveDxTd7ARspGcBgKvnXzwmmXYtCvPUoBZQcgM8jwUJcZrUDLNuUpUGZ7B q+/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wlu9sAWk; 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 y19-20020a056402441300b00456d901922bsi18173295eda.510.2022.11.02.15.19.06; Wed, 02 Nov 2022 15:19:31 -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=Wlu9sAWk; 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 S231321AbiKBWMb (ORCPT + 99 others); Wed, 2 Nov 2022 18:12:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231544AbiKBWL7 (ORCPT ); Wed, 2 Nov 2022 18:11:59 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F210CE0D for ; Wed, 2 Nov 2022 15:11:54 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id g13so205732ile.0 for ; Wed, 02 Nov 2022 15:11:54 -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=+xtIdRfPlPgVtPzZBa18RgWUGmJjs2ni8p7EMA1XR/M=; b=Wlu9sAWkAYKtytrHJSptm5bLfYhtqmKOZxq0vQB6Xbe7ISfAnAYy3/64MSTJM6tnGT uoyWm89UIrjUA3iKlbny0wiZOM1NldRVWeNRm+P1poTzL/o6MCBqVPmoZfnxTG6HZwgF C6Hd5sFMJwyIEs+OzyfP4FkG5EBzAxxIJDMJBQCJYcn7FGAX+8qRf4b/JCbJ1A1Z2yl3 esI3uryzAWE4aLokITyfVozcEd5Bd70+Dz+NZg5PTINEKObVeAHMpnpRUBBjTkEUVTWq YABaR371XFKMe1dpmRaOKNEPoHNZqpGvDZtcJbO02wU9OmxzumrypjtakiYovO06m6tq USbw== 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=+xtIdRfPlPgVtPzZBa18RgWUGmJjs2ni8p7EMA1XR/M=; b=va0M/trYPACuEG9s8XYBUzAZia0WgCCYjNEZZq03ga6yww9fAlc1W9ZCGR9/WkMrHs ol6aCSzAvhTnYFtnkTXp1tk6EOgrWBhuNcC9wPbxMuaXrdQ+r5W/TJ6XHcCcdh8U0pbq +q77lmmdMcZFfrWmfIkg5qG8WRpfyp2r/dKFKjlDam2HSZtM1PGNSzGBITy5o4oSndfJ qyW3l6BXtxMLuG4MIkpZaDXyY9huVlWmbR0v5XqNgqknlKdCKDQZAgTCJ/512JLl5/eK D/iZVE30nq+9gEjGCDK3bJ7CQsymQU5hqAxOS0t/HhWdWjRbbiXJzVcuiTa8to3NfUDJ 2Ojw== X-Gm-Message-State: ACrzQf3NQ0kce9qLk7CYKDwr5Pp5h439H69r2xdJ62fxHljKx3Lpu3qh NTeOlmC0CuWL9ViS1VxcxYeivQ== X-Received: by 2002:a92:dac2:0:b0:300:c4e1:8b76 with SMTP id o2-20020a92dac2000000b00300c4e18b76mr6512177ilq.319.1667427114261; Wed, 02 Nov 2022 15:11:54 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id f8-20020a02a108000000b0037465a1dd3fsm5073974jag.156.2022.11.02.15.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 15:11:53 -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 v2 9/9] net: ipa: use a bitmap for enabled endpoints Date: Wed, 2 Nov 2022 17:11:39 -0500 Message-Id: <20221102221139.1091510-10-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221102221139.1091510-1-elder@linaro.org> References: <20221102221139.1091510-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?1748424532868631329?= X-GMAIL-MSGID: =?utf-8?q?1748424532868631329?= 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 | 32 ++++++++++++++++++++------------ 2 files changed, 22 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 3fe20b4d9c90b..136932464261c 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) @@ -1971,6 +1970,8 @@ 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); + ipa->enabled = NULL; bitmap_free(ipa->set_up); ipa->set_up = NULL; bitmap_free(ipa->defined); @@ -2003,6 +2004,10 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, if (!ipa->set_up) goto err_free_defined; + ipa->enabled = bitmap_zalloc(ipa->endpoint_count, GFP_KERNEL); + if (!ipa->enabled) + goto err_free_set_up; + filtered = 0; for (name = 0; name < count; name++, data++) { if (ipa_gsi_endpoint_data_empty(data)) @@ -2027,6 +2032,9 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count, return 0; +err_free_set_up: + bitmap_free(ipa->set_up); + ipa->set_up = NULL; err_free_defined: bitmap_free(ipa->defined); ipa->defined = NULL;