From patchwork Fri Oct 21 19:13: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: 6943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp863751wrr; Fri, 21 Oct 2022 12:17:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+mIqOEu1HnuXMqwMd+RiBEGVk/swKXHizbOlyhHn0rmPxrJ87vR3ZrN1OuUlAMnOVn4wB X-Received: by 2002:a17:907:7704:b0:780:da38:4480 with SMTP id kw4-20020a170907770400b00780da384480mr17126011ejc.64.1666379826852; Fri, 21 Oct 2022 12:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379826; cv=none; d=google.com; s=arc-20160816; b=q4LWXmpl62CMprtiycFkV2K0Y07ZPGQcXtk8pYKyi/g9w4U9B/sP233MaIAjP6crxQ hc68zLXEtQMNKvGYxiS91G5RS5/6BEgfgjnZSnLlTyjAGUJkrcAV1zJ26z2NTW9dGn9T 6rtkUKMZUWuMFug3WPKphLoDp2u9o++C+HdRnCh6SmxeGDL2dQOtP/Ory9K+hmW3jm3v NFNqPaWgwLcSem5N+YGtcf0mj95lGZy7+VgBXvy5kwDdDME2iaxvw3qX1gG4FtGJ3JAd IBNEZCyc3N0Rc929EvDT12RVULpky647tdAwUGRiN3bOL77+Ep72U0Wh3KTODiSJ0Bx3 Mt7g== 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=wjt6lwwJr+c+Of6ylCClx8YoFmO2MMnOutK8JcRmLRU=; b=XbCaH1dJnEbi5KlBxyhH0QcgCjucz97o+nhqMnN0wf0OTit1VcYU3moCR8Ml2uDHTs nzL5tO4lSoCbYt6M+LxyYzlyfBx8hLdcJjiOB7HXrZE5HgzlCgwWBnfvitmx0zZTKDm6 qwRPP2SHgGx/Z/t/SjqBpxvC4wM3L/bIFq0mgTbVRF57wAim3wwtJ4jwZc7nrmczQMWq CCwFw25VCaI0N0Rd0njToiywtvJz7Xmcm5/uxPkIdv2dVvHMXOTnopWCweCjnliwRgUY NgZyXitcU5jD8nD/vOs5PBZC2KM35gG1cg41QegwaoIDDVLELLEfrIIj/UEmr6MvpskB YiNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGVqa57u; 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 gt11-20020a1709072d8b00b00783d5a873dcsi22919894ejc.341.2022.10.21.12.16.42; Fri, 21 Oct 2022 12:17:06 -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=bGVqa57u; 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 S230334AbiJUTNx (ORCPT + 99 others); Fri, 21 Oct 2022 15:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbiJUTNs (ORCPT ); Fri, 21 Oct 2022 15:13:48 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29A6F15A8E3 for ; Fri, 21 Oct 2022 12:13:46 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id 187so3102162iov.10 for ; Fri, 21 Oct 2022 12:13: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=wjt6lwwJr+c+Of6ylCClx8YoFmO2MMnOutK8JcRmLRU=; b=bGVqa57u8nMCh9FP/fCjSQ5u0DVbCFa53mamal5/83aBa+kQ4NkoBJE6olw2xjl+iR 88SryQ6n+YSObVt1oVhugpTLoql6ONsHN8dpbzuq6IKR0QnJ7VoGapzT5Dg+GUBCFUGc gmtNIL+EKGGpyw+bgryII70Zi0KZ3zq2Eb/HUmLmmTFfKerAva9QSrOxHZNz+Kq9nH7W eJ8yuXMNzoCh4d5FirqiFX/8Xd4QM9Bj8aa0FXlXStakz2/bJ6h50zSiSJ95faiwNa+A mMI2KXzgwpVhG4zav9XdEcFhfSt1x6A61lGgG56Xvye/5R2q0oCGW4GrpAlkV1ABJdx/ wryw== 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=wjt6lwwJr+c+Of6ylCClx8YoFmO2MMnOutK8JcRmLRU=; b=d5IQgdUxYjiYmoB+Z+VAIruer/YvPX4RrWjJ+wFPfitpS5NZIav7kNzYw2aFEKJYK7 EJsDHk/dmHqVuUPNrPO+OSvJQ9rB9UGcOxfYC9isRQgmfLLrzdhq5L4fcra2xTxLu+QU 7ZeJD2wdwW7vEgn+E6QHqaom/ALqb/vxiLzfQt5WYPAkhx3LlbJW7bNX8mO3DWwKhlaW +FCCIj8M3q8u9EYibfyR9pBVvf6v4Y8AkmePSMK6NVtzz19BbvySGpBo7USUbbTTSfCG dHrJJ8aX0Nnj6ZKwq9slI2KibnZOQxkQ/Rih5hiT4qzb8krWPDxIm9wUYG38gYpLInA5 q34w== X-Gm-Message-State: ACrzQf3UEiVy0K7phzUnY7E1sHaTqifmuSTFy1hJJaa9f3iVunYP3XQd RxjvE0WQNQY7MpNcySIVWUAYjg== X-Received: by 2002:a05:6638:480c:b0:363:aed5:ed3c with SMTP id cp12-20020a056638480c00b00363aed5ed3cmr14275784jab.207.1666379626213; Fri, 21 Oct 2022 12:13:46 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13: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 1/7] net: ipa: kill two constant symbols Date: Fri, 21 Oct 2022 14:13:34 -0500 Message-Id: <20221021191340.4187935-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747325893262702681?= X-GMAIL-MSGID: =?utf-8?q?1747325893262702681?= The entries in each IPA routing table are divided between the modem and the AP. The modem always gets some number of entries located at the base of the table; the AP gets all those that follow. There's no reason to think the modem will use anything different from the first entries in a routing table, so: - Get rid of IPA_ROUTE_MODEM_MIN (just assume it's 0) - Get rid of IPA_ROUTE_AP_MIN (just assume it's IPA_ROUTE_MODEM_COUNT) And finally: - Open-code IPA_ROUTE_AP_COUNT and remove its definition Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 510ff2dc8999a..74d7082b3c5aa 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -106,12 +106,6 @@ * ---------------------- */ -/* Assignment of route table entries to the modem and AP */ -#define IPA_ROUTE_MODEM_MIN 0 -#define IPA_ROUTE_AP_MIN IPA_ROUTE_MODEM_COUNT -#define IPA_ROUTE_AP_COUNT \ - (IPA_ROUTE_COUNT_MAX - IPA_ROUTE_MODEM_COUNT) - /* Filter or route rules consist of a set of 32-bit values followed by a * 32-bit all-zero rule list terminator. The "zero rule" is simply an * all-zero rule followed by the list terminator. @@ -342,11 +336,11 @@ static int ipa_route_reset(struct ipa *ipa, bool modem) } if (modem) { - first = IPA_ROUTE_MODEM_MIN; + first = 0; count = IPA_ROUTE_MODEM_COUNT; } else { - first = IPA_ROUTE_AP_MIN; - count = IPA_ROUTE_AP_COUNT; + first = IPA_ROUTE_MODEM_COUNT; + count = IPA_ROUTE_COUNT_MAX - IPA_ROUTE_MODEM_COUNT; } ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE); @@ -561,8 +555,7 @@ static void ipa_filter_config(struct ipa *ipa, bool modem) static bool ipa_route_id_modem(u32 route_id) { - return route_id >= IPA_ROUTE_MODEM_MIN && - route_id <= IPA_ROUTE_MODEM_MIN + IPA_ROUTE_MODEM_COUNT - 1; + return route_id < IPA_ROUTE_MODEM_COUNT; } /** From patchwork Fri Oct 21 19:13: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: 6949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp864420wrr; Fri, 21 Oct 2022 12:19:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66Kfu8asxBgUgNuMBIVi4mKYHjpD7ZFM7Di2sHXOfUgoGJyfZI06tmrLUIBHGdJy2FZ7zR X-Received: by 2002:aa7:de9a:0:b0:44d:8191:44c5 with SMTP id j26-20020aa7de9a000000b0044d819144c5mr18535165edv.232.1666379943304; Fri, 21 Oct 2022 12:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379943; cv=none; d=google.com; s=arc-20160816; b=si2Mm7/izChOrp5webeKO92RxHLjegd6Ujn9lFgpHaRDBBkKT8xbujle2hEDJ//vPZ OknvbvuUxZTZg8Rud1tvjTlw9W9g7/35U5LWE1W/q6pmWC4XTpWXIKMdo345++RhljS1 cSN8mxqE8Guju5Oy7qEb2hdMX5b186licmUkfkqkwEV4cOxrvL9nbrO2rE/pomrijdAM enhckaUXsWmLnGoHLpTgY0o/HXD0UvI9h6mdXFGYenG7AYJQmu3tgaODqbCUTd1bNIgn yMmMyks06sjZv63/h1791U+Z/c4RiqUyKnFyMtAjxx1Bo82wzWOcmYPpcVgaFcTLP1Mu zXFw== 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=DwurrB7qdNkMpnWeG+ha/LhhiXkd7fDsKvUQoo9Dexw=; b=ADZV32Dk0WCMbrqmwmpM0UINYJuFIru0zc7+qY79EolhDNGLEsdE1JzNaJJ438L3Yj OAplVjEIjtJYrBavgMYxTCTjO7OPYbAJSjUiW7X/BM+CoOcB5eV4IFoJhd7KfwnWdlOY oyOWTfTvQ9u3ekGtsg/HESRGyaLY7bn/oW92s6ssQMz2q8fga0Tfc4lG+V5s+FGjtYnK a6kf0UCU6y77a8K23X1bYlt2G3YtG8LnbvpQbcyY4FxeO1DnImlh023t+Kbt5e2H9frY DBkDAnx9HU3DXAyLuuuzCM84dizkyaD5fTSKDvBRMVH5EeFzQjk1brR6iw8VbZCayQGS TfIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBbpot0z; 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 ds1-20020a170907724100b00757bd7f53dcsi18988996ejc.14.2022.10.21.12.18.38; Fri, 21 Oct 2022 12:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBbpot0z; 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 S230364AbiJUTN4 (ORCPT + 99 others); Fri, 21 Oct 2022 15:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiJUTNt (ORCPT ); Fri, 21 Oct 2022 15:13:49 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715D515A8E2 for ; Fri, 21 Oct 2022 12:13:48 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id o65so3137933iof.4 for ; Fri, 21 Oct 2022 12:13:48 -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=DwurrB7qdNkMpnWeG+ha/LhhiXkd7fDsKvUQoo9Dexw=; b=GBbpot0zp4+XeMgKSqEiFGsGVvyxt8vtlPZJfrtB3MbianLPzdG3fvyx8gmq+A1eiK F4L/j1yYMM0+nGOKtHn7qj1X6GNE/ZvCE4wdz4VA0ZMaiVURkF1XxVzWHNlNW1FYAbDu iqcGFuF08cIhPA0Xm+QfUiQuLJZPb2SIYPwqoqoqHRUrI8zmt7mt41q8xOE2m25OfLBR rFPFHSnHzeSt7ap5bolW/T2ccHm85XACIHUehjyR1NntmJym1N/p6a1t2473aw9Z+H1W E1vfYvdxYpolHCIOCdZH6o9nhyDv13v4JL6306T+B2B+YITr3FZQvUp0bYzCR8vTOL5e Mp1A== 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=DwurrB7qdNkMpnWeG+ha/LhhiXkd7fDsKvUQoo9Dexw=; b=z2hDqDfdClHo7HV+eYlupi19dB65hhD9WBdK6f0f/XYCHkrz0V4I5du0GToPZ8JWt4 lco9owsSoX0MjsEblIT551rM+1agbk5r85lEvQFqtMXJRjiHwpTJCIOejXj05EQsXUH8 sL6qxSQy00Tg0jiOVP8Bc3j1xAwI7ITcyshkvMI5uQGN4DzgiSocjMrTM4yp3I1tvCIB AdAWrVdxUx78/Opdyy2rxAWcCD88C8vZpiOP5u4friVB1P4ICO1DLxqhTwuKXYUVNxWh O3HoFQWlGxYDW6U4Y6nqel29l4SB8T3NYxCxO2GQhjHWm1SyOfuG1e0Mt9cOSFpjFhOz brMA== X-Gm-Message-State: ACrzQf1sOn6KbokhdVyopqOOZa+TvgI/Xto9CXqw9GoAd9TJ8HnRBM2m IBQaO0/I/ENakAvobgajwUPFgA== X-Received: by 2002:a05:6638:4304:b0:343:5953:5fc8 with SMTP id bt4-20020a056638430400b0034359535fc8mr14970008jab.123.1666379627832; Fri, 21 Oct 2022 12:13:47 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13:47 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/7] net: ipa: remove two memory region checks Date: Fri, 21 Oct 2022 14:13:35 -0500 Message-Id: <20221021191340.4187935-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747326015267391390?= X-GMAIL-MSGID: =?utf-8?q?1747326015267391390?= There's no need to ensure table memory regions fit within the IPA-local memory range. And there's no need to ensure the modem header memory region is in range either. These are verified for all memory regions in ipa_mem_size_valid(), once we have settled on the size of IPA memory. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 26c3db9f52b18..e46e8f80b1743 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -197,16 +197,6 @@ bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem, bool route) return false; } - /* Entire memory range must fit within IPA-local memory */ - if (mem->offset > ipa->mem_size || - mem->size > ipa->mem_size - mem->offset) { - dev_err(dev, "%s table region out of range\n", table); - dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n", - mem->offset, mem->size, ipa->mem_size); - - return false; - } - return true; } @@ -257,15 +247,6 @@ static bool ipa_cmd_header_valid(struct ipa *ipa) return false; } - /* Make sure the entire combined area fits in IPA memory */ - if (size > ipa->mem_size || offset > ipa->mem_size - size) { - dev_err(dev, "header table region out of range\n"); - dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n", - offset, size, ipa->mem_size); - - return false; - } - return true; } From patchwork Fri Oct 21 19:13: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: 6945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp863855wrr; Fri, 21 Oct 2022 12:17:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yZTBIwcc2lD5oJe1O7XUh0QpbMa3C7g1rL1E3qHEngiL4WsRjHnZ5tvzwtG8wTll1al8T X-Received: by 2002:a17:907:6d8f:b0:78d:9b5e:1a0f with SMTP id sb15-20020a1709076d8f00b0078d9b5e1a0fmr17671794ejc.23.1666379832555; Fri, 21 Oct 2022 12:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379832; cv=none; d=google.com; s=arc-20160816; b=kQ99LzIuPSQlNmIQ4nbojL3xYkqft8CpU3e4QS9KE/dYu8Db8MdkjJYcfSpWNku6bL fp1hOfZadwBLzu4MaPu8HlflGDObS6TOgXaulqDoZ9OkUoMy5J0Eyk9/pMF4HcUufkFO YA17SnvX2IR9QikX3gttAqzGAiDlnw1nylGRBCe9bbCCZiHqzGw/fZv/dWlh+7ih/PvO kXYcnrp0t6rAaF3HtJ0B6dvNnCoFgdF52OCwH92kqH2DRikCnR22Eq/2W7cI5I0WZ4Lj 9fktKC01RFEB3XoJy6qaOpNx2vkBN4U2h2UedwJRZMNykAFXqOpiPCN3Vo3b6x2Jl248 8HRw== 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=HDw9482diyaFwRrAaQF5T4a7oZwEPZMJMihwz/4kzSA=; b=OvexC0CI1tKdfp49cBrnie/p/62ROmRQhs4r5mONJX1JAMSQ2A9baWLnjRb06qzxxz 6xLqRhzY/7TtWMyK7Ns12LOMq8Sk/bfAQFHFh1p+YCp9wSylpVItQ/2acqoHoNZ73KLD qNHmXXmTqy/J1aca2SY4vCP6DghG2XUfJ7uvDyjScptJlvHJPvKkAA0ty4qX0bgw/ux/ zvepa4a7Eg1SG9hGAgmyRIMlol5q0SU7lzMjICL2Yjk8rYaimx0nNokl5kkXyGcL2HxK Gm4QSceNBgnyxdaWYtDWcSY5YnJsq+qNG57dCrH3Palc5w7HPPO+JwTido1E626dqo2E fGKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnm4oyhA; 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 dp19-20020a170906c15300b0078c47b4478esi19295438ejc.106.2022.10.21.12.16.47; Fri, 21 Oct 2022 12:17:12 -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=tnm4oyhA; 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 S229670AbiJUTOA (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbiJUTNv (ORCPT ); Fri, 21 Oct 2022 15:13:51 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F5215A8E1 for ; Fri, 21 Oct 2022 12:13:49 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id o65so3137981iof.4 for ; Fri, 21 Oct 2022 12:13: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=HDw9482diyaFwRrAaQF5T4a7oZwEPZMJMihwz/4kzSA=; b=tnm4oyhAweSGNma6/aLaMtvbzON+bEe4uWFuVld2RiGTgLSBlMxLLQnfj0q9njaG3q PREJ0hi07Wy5hr8SRHgvU7m+NMLkXaZTt/3M9FzGAMx5jYElQUbFIZY80EsRCBn/hqpk z0OVESh2QlchZmHOxaxxWq2w6i+oLg5ItHMGa8FGvSvMXhbLgu7GdfnosNTMmCEoPF3Y niq+/dvYCZuOlKGpmEzsrJXqh/KINmV0nPZcQVVVG3NWZn1BckFAgcB+MWc9bMEWFj4F M6qjzvaqOM01Edf72LTircEzFozW1vNhM4N4C/q82CHa0dHssjfu0MVAB/BYwnaqngHb A28w== 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=HDw9482diyaFwRrAaQF5T4a7oZwEPZMJMihwz/4kzSA=; b=p0W4TQ3jC0sy70dgBEka4rDovmtNKwpKHMQkuFsVcNZel8BXRZmx/w0PtnwShXT4RN UY2KrV8DoqMi3aBAons4ZJTFJlxquldHgqUKy9lfs523A2zh6ZkxJdjwx/iMVQWE+kz2 TLxIpqWc8qVjzQ7HlmQ9+nOd8Sanz9JQ90zsnXOOspYmtkpHm0q2ecBU6ng6vqZonI1d DuhDkdP53ZtiMzY0JKyeeCmLxOd9tcRzJXydrdhB0p3g3vF7vmG/mTkPEqAVf+JR/Myv xgriqt3uR6jDsJHkVV26EIrOkXVMb89cAj9ViX323lSQuKrSnKAZUjmUG1+2fg9IGWYn VnOw== X-Gm-Message-State: ACrzQf2YBe9L8zrmJKxKaSChfpm2I9k6NAuM6MMkE/cKkW/ilRIPhQEf mrnEsZX0teLgJJbWknZuIToJmg== X-Received: by 2002:a05:6638:490e:b0:363:c0fb:a5ea with SMTP id cx14-20020a056638490e00b00363c0fba5eamr14192375jab.285.1666379629399; Fri, 21 Oct 2022 12:13:49 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13: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 3/7] net: ipa: validate IPA table memory earlier Date: Fri, 21 Oct 2022 14:13:36 -0500 Message-Id: <20221021191340.4187935-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747325899454335842?= X-GMAIL-MSGID: =?utf-8?q?1747325899454335842?= Add checks in ipa_table_init() to ensure the memory regions defined for IPA filter and routing tables are valid. For routing tables, the checks ensure: - The non-hashed IPv4 and IPv6 routing tables are defined - The non-hashed IPv4 and IPv6 routing tables are the same size - The number entries in the non-hashed IPv4 routing table is enough to hold the number entries available to the modem, plus at least one usable by the AP. For filter tables, the checks ensure: - The non-hashed IPv4 and IPv6 filter tables are defined - The non-hashed IPv4 and IPv6 filter tables are the same size - The number entries in the non-hashed IPv4 filter table is enough to hold the endpoint bitmap, plus an entry for each defined endpoint that supports filtering. In addition, for both routing and filter tables: - If hashing isn't supported (IPA v4.2), hashed tables are zero size - If hashing *is* supported, all hashed tables are the same size as their non-hashed counterparts. When validating the size of routing tables, require the AP to have at least one entry (in addition to those used by the modem). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 98 +++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 74d7082b3c5aa..222362a7a2a8c 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -134,9 +134,25 @@ static void ipa_table_validate_build(void) BUILD_BUG_ON(IPA_ROUTE_COUNT_MAX > 32); /* The modem must be allotted at least one route table entry */ BUILD_BUG_ON(!IPA_ROUTE_MODEM_COUNT); - /* But it can't have more than what is available */ - BUILD_BUG_ON(IPA_ROUTE_MODEM_COUNT > IPA_ROUTE_COUNT_MAX); + /* AP must too, but we can't use more than what is available */ + BUILD_BUG_ON(IPA_ROUTE_MODEM_COUNT >= IPA_ROUTE_COUNT_MAX); +} +static const struct ipa_mem * +ipa_table_mem(struct ipa *ipa, bool filter, bool hashed, bool ipv6) +{ + enum ipa_mem_id mem_id; + + mem_id = filter ? hashed ? ipv6 ? IPA_MEM_V6_FILTER_HASHED + : IPA_MEM_V4_FILTER_HASHED + : ipv6 ? IPA_MEM_V6_FILTER + : IPA_MEM_V4_FILTER + : hashed ? ipv6 ? IPA_MEM_V6_ROUTE_HASHED + : IPA_MEM_V4_ROUTE_HASHED + : ipv6 ? IPA_MEM_V6_ROUTE + : IPA_MEM_V4_ROUTE; + + return ipa_mem_find(ipa, mem_id); } static bool @@ -604,8 +620,77 @@ void ipa_table_config(struct ipa *ipa) ipa_route_config(ipa, true); } -/* - * Initialize a coherent DMA allocation containing initialized filter and +/* Zero modem_route_count means filter table memory check */ +static bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) +{ + bool hash_support = ipa_table_hash_support(ipa); + bool filter = !modem_route_count; + const struct ipa_mem *mem_hashed; + const struct ipa_mem *mem_ipv4; + const struct ipa_mem *mem_ipv6; + u32 count; + + /* IPv4 and IPv6 non-hashed tables are expected to be defined and + * have the same size. Both must have at least two entries (and + * would normally have more than that). + */ + mem_ipv4 = ipa_table_mem(ipa, filter, false, false); + if (!mem_ipv4) + return false; + + mem_ipv6 = ipa_table_mem(ipa, filter, false, true); + if (!mem_ipv6) + return false; + + if (mem_ipv4->size != mem_ipv6->size) + return false; + + /* Make sure the regions are big enough */ + count = mem_ipv4->size / sizeof(__le64); + if (count < 2) + return false; + if (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)) + return false; + } else { + /* Routing tables must be able to hold all modem entries, + * plus at least one entry for the AP. + */ + if (count < modem_route_count + 1) + return false; + } + + /* If hashing is supported, hashed tables are expected to be defined, + * and have the same size as non-hashed tables. If hashing is not + * supported, hashed tables are expected to have zero size (or not + * be defined). + */ + mem_hashed = ipa_table_mem(ipa, filter, true, false); + if (hash_support) { + if (!mem_hashed || mem_hashed->size != mem_ipv4->size) + return false; + } else { + if (mem_hashed && mem_hashed->size) + return false; + } + + /* Same check for IPv6 tables */ + mem_hashed = ipa_table_mem(ipa, filter, true, true); + if (hash_support) { + if (!mem_hashed || mem_hashed->size != mem_ipv6->size) + return false; + } else { + if (mem_hashed && mem_hashed->size) + return false; + } + + return true; +} + +/* Initialize a coherent DMA allocation containing initialized filter and * route table data. This is used when initializing or resetting the IPA * filter or route table. * @@ -653,6 +738,11 @@ int ipa_table_init(struct ipa *ipa) ipa_table_validate_build(); + if (!ipa_table_mem_valid(ipa, 0)) + return -EINVAL; + if (!ipa_table_mem_valid(ipa, IPA_ROUTE_MODEM_COUNT)) + return -EINVAL; + /* The IPA hardware requires route and filter table rules to be * aligned on a 128-byte boundary. We put the "zero rule" at the * base of the table area allocated here. The DMA address returned From patchwork Fri Oct 21 19:13: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: 6944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp863840wrr; Fri, 21 Oct 2022 12:17:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CYnjxX2ga0/kTM5HXRjjfEi98vh9ojAMHP+U0vMMQGE973ERE195XRttENaCo967PtYGl X-Received: by 2002:a17:906:db0a:b0:781:f24:a782 with SMTP id xj10-20020a170906db0a00b007810f24a782mr16614634ejb.399.1666379840558; Fri, 21 Oct 2022 12:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379840; cv=none; d=google.com; s=arc-20160816; b=UsK1QLUSyG/fmJOiwfsE/zfCKoNk557JvUcdYYqL/e/kwHL+SeTm1uGnz6aVL82IvX OVgRU/gGYWqxOg3i61Rq/XCOsXsH+nkiltLYn82vuZgNargfy7rmfxMF/MmC3zbUzVi7 zBEtVkXNOwzihtfCnYwP+LAV9zeO/QglvPCxy5WAhKTWOENj6bPD2vcneeenjPTzmT3c tgCP7upFkqMCijiEAfQ5PKVIXGgqR+/ldlJSn21Vvd/MWTI1N24kSh1tmhbdAkT8WDNB iZAnG/jKKU4BvisLC3awj0dgbiHkrMkxuJHCV+ZTDq9gf0S9Ove+FGrRIJrGXhveQMsJ JZmw== 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=CfoX9tfQsNUSpvuUR71Krd80FmBYfkKGaSPZGza3z4Q=; b=mq+s9ejjv5LeZzhlIVsNyzWJBnZDVNmeqDMhwXgKgLiQb60bjn0xZg76vmNz5NUo39 sqD0LFvkwRmsLYn2kAStNMG+/RmzZFtUG53tEd6u32G83jNLC80CcqPCXtu0zB67ryCM ScxRZ0OEgkYYs33nCVtAcZuhKi7ISBqfuVteZ2U8rGwHtgH/wYY8LKq3x5RNEdMrGOVW 9BJRR2SfWNtDuO+kZqqabhej0uSr5XrXsPkSUw6krKgO6zCRkP0wlEy9jiggCRUX1rER IoyfxKAjxETklgtIB+2tyL3A9475RfB5IM/3sd7mECaZchv+Qhv1suSWo/7DrD8U5nP3 uJgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WttBQ15g; 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 hd10-20020a170907968a00b0078d8c03a5a6si24123766ejc.759.2022.10.21.12.16.56; Fri, 21 Oct 2022 12:17:20 -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=WttBQ15g; 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 S229867AbiJUTOH (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbiJUTN5 (ORCPT ); Fri, 21 Oct 2022 15:13:57 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A94315A8EE for ; Fri, 21 Oct 2022 12:13:51 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id l127so3099726iof.12 for ; Fri, 21 Oct 2022 12:13: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=CfoX9tfQsNUSpvuUR71Krd80FmBYfkKGaSPZGza3z4Q=; b=WttBQ15gvxH0FqkWstCC5tRK4HP+SPLOgo6U9mrNAVLQjqwIy+iA2SZz/RkWjBbQbe IfhkQ8ZrzIBvli28qBixTlATAsWltvP0dE96hld/23qwBSiDsDJNokkk6acqes9vco/B QWdhnV3QwMg0Ocis6rOo8AGoZfpSQSDysgLXQi171z26LTnH7TB84sp2h9KNkqrfY9/i iYJaCNvWwMfiGIHkKRGtc+VgEEu6f7So/9Fq1hiAM4U+UFjKebkR+5D3k1P2wF2ywSZ3 4ONxW0bQtNLKlBTjifgvWYCCledj6M2ppP/sfCQCar0sFnnUjMdTLynmYFuqzl2tngQI x9aQ== 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=CfoX9tfQsNUSpvuUR71Krd80FmBYfkKGaSPZGza3z4Q=; b=Kij28M30YDX8ZBnoAFvyrTI6i42CEFt5ZfTEB2SMsKaLJGrPqDk1cQHX1l+e3aDFNc +0e70ijDaBHuZIXQ/LcBOqH/zHnWfmqDimo+1FahjD0WQDbObDhE3jeWD6mp2UtWC/qR KPFpAxoSoEIHtLBo3wGSlhR64/E6Odwfdu6WDEOsKGDLmnRYQrWgfguOn7NRSDCb4GVu OlPCU3NC/4cOBbhliGCH8MP3BKLw/me6znJwgseXACyCcBP3IBOSPlEU11btZcv4DYXt bNA/iRHbQY2j/A50vYcABLvHZH7knlCN0GEJOTxTr0TqTrK3+CAMmncREQQzmxAYJWA8 f25A== X-Gm-Message-State: ACrzQf2p2Mn7iE9oEQ0VuTzvLSiOsPeQyta0OalGKW3cu5SnKZTOmCI+ Xd7W4dIQcICnbKykIYyetfms0w== X-Received: by 2002:a5d:9393:0:b0:6bc:be5a:2ce6 with SMTP id c19-20020a5d9393000000b006bcbe5a2ce6mr14732319iol.214.1666379631003; Fri, 21 Oct 2022 12:13:51 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13: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 4/7] net: ipa: verify table sizes fit in commands early Date: Fri, 21 Oct 2022 14:13:37 -0500 Message-Id: <20221021191340.4187935-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747325907824730400?= X-GMAIL-MSGID: =?utf-8?q?1747325907824730400?= We currently verify the table size and offset fit in the immediate command fields that must encode them in ipa_table_valid_one(). We can now make this check earlier, in ipa_table_mem_valid(). The non-hashed IPv4 filter and route tables will always exist, and their sizes will match the IPv6 tables, as well as the hashed tables (if supported). So it's sufficient to verify the offset and size of the IPv4 non-hashed tables fit into these fields. Rename the function ipa_cmd_table_init_valid(), to reinforce that it is the TABLE_INIT immediate command fields we're checking. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 3 ++- drivers/net/ipa/ipa_cmd.h | 6 +++--- drivers/net/ipa/ipa_table.c | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index e46e8f80b1743..abee6cc018a27 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -171,7 +171,8 @@ static void ipa_cmd_validate_build(void) } /* Validate a memory region holding a table */ -bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem, bool route) +bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, + bool route) { u32 offset_max = field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK); u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); diff --git a/drivers/net/ipa/ipa_cmd.h b/drivers/net/ipa/ipa_cmd.h index 8e4243c1f0bbe..d03cc619e2c31 100644 --- a/drivers/net/ipa/ipa_cmd.h +++ b/drivers/net/ipa/ipa_cmd.h @@ -47,15 +47,15 @@ enum ipa_cmd_opcode { }; /** - * ipa_cmd_table_valid() - Validate a memory region holding a table + * ipa_cmd_table_init_valid() - Validate a memory region holding a table * @ipa: - IPA pointer * @mem: - IPA memory region descriptor * @route: - Whether the region holds a route or filter table * * Return: true if region is valid, false otherwise */ -bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem, - bool route); +bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, + bool route); /** * ipa_cmd_data_valid() - Validate command-realted configuration is valid diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 222362a7a2a8c..9822b18d9ed39 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -166,10 +166,6 @@ ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) size = IPA_ROUTE_COUNT_MAX * sizeof(__le64); else size = (1 + IPA_FILTER_COUNT_MAX) * sizeof(__le64); - - if (!ipa_cmd_table_valid(ipa, mem, route)) - return false; - /* mem->size >= size is sufficient, but we'll demand more */ if (mem->size == size) return true; @@ -645,6 +641,10 @@ static bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) if (mem_ipv4->size != mem_ipv6->size) return false; + /* Table offset and size must fit in TABLE_INIT command fields */ + if (!ipa_cmd_table_init_valid(ipa, mem_ipv4, !filter)) + return false; + /* Make sure the regions are big enough */ count = mem_ipv4->size / sizeof(__le64); if (count < 2) From patchwork Fri Oct 21 19:13: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: 6946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp863967wrr; Fri, 21 Oct 2022 12:17:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4m6WjsCCi5zonZTtfyW4fYFGUXwH4pMDos/yOXULYVdLqMfolR/kbWqJ/5bxMWXP2246Po X-Received: by 2002:a17:907:2d29:b0:78d:cf5c:5774 with SMTP id gs41-20020a1709072d2900b0078dcf5c5774mr16235414ejc.213.1666379861833; Fri, 21 Oct 2022 12:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379861; cv=none; d=google.com; s=arc-20160816; b=WCrLRtCByXNScsXKVSyG2dIzzhTv5o6/JhXgSdEkmivrQJ7hCwVkNtM0ZCxU2yyVzr LowXl/cYU/f+NLqWzgrjsW53W3Q44VlHOSOIdGZYUwuijbkuAMzMWZtXEKUpkuHPdAsu u3tO4L6LTi99is7WVGPGx2Qxgt2Eh3VGDGS6tuRtJdI/uHwdXd7zfcquvhDNBwwUA5n+ vx5OUpAmQhpO0MkmA43Mhe8opxEFmoS+AwEqOQ3nEwRbxv71siKEo6U7jTUHA2OotXLz HVTyniAp+c0nyxxVPGdqSaZCZ6My4e+O4EJqxN6maqyRMwvHZDJGydmXkyVdgnvRCSJp +qgQ== 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=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=k5cKKrUEkujBEzOXK+mdytMkLzGj4JA17KratgYM+EvzLQGy+Lw7qVFAORCUCJvz06 KTvjmvxsVR7J6D/TeKjnqHnLqlCuxUZfy23D3dUKQEQgHkVHWuo5Dzps5rPA04sznsp8 /xw+G+CQG/WkG68CZ/OK0wXOvU21SRXsf5C1Zx14nKI1rTFZu6LXGRDi4lbFUfpVc4oW Xfnks5OWNsX3JbQUvu8gQbVqUnK1MWRQa66fpYNcv+uygnbt6jWiV4TNfRRXIFCh0ST8 TyTa23Ghlo1oPJufPFOnwnrCgLrwliObB15YXRNFDJBTFMcX+Zw0U5rTfnZ4n3oBHFxl AyDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PS/Wz4BQ"; 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 bx23-20020a0564020b5700b0046152a9305dsi1571845edb.184.2022.10.21.12.17.17; Fri, 21 Oct 2022 12:17:41 -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="PS/Wz4BQ"; 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 S230390AbiJUTOL (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiJUTN6 (ORCPT ); Fri, 21 Oct 2022 15:13:58 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA10215A8FD for ; Fri, 21 Oct 2022 12:13:53 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id g13so2190137ile.0 for ; Fri, 21 Oct 2022 12:13: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=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=PS/Wz4BQtvKmYXcEWIIMLP5lDWgUD+5jUBKHAwjBS8EZnQb5ieqXPwP90BrS9c/wGj EZrDcvMyvjQZAxHTVufBLSIqaFLp7l1tFdTEsKtOwhBMjejiX66CybROw9TycWE0mbnq o2lp1bB21+uxwlziKnlp3804hAlPyPr50u+eQ7ZrLqcyyuvdbrXayeQmiWEPduyzQUbE vFijDPYKo0XqvIwlaP/7V3zRkcvzowf2fvjH7BreI09Cqlu7r/aLjX3M+dbsBvOIZ5xn bQv35q4+RG0fkshuj92Ppn/BSO2VErX11J7KToQobkZEx6r///A3Hc+shIQYXw5aOmYZ DB0A== 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=ffjwyYuCoS/NvlnxXJbOzVeqq5rZ9fCi3nXlY5yNU50=; b=H2LQlvNAiSVeDY6JOh0KcZ0fbj7PozyEKLMQX7wFhlLBYWkFYlXgRdW6biBiK6ZjRu vCkgfz9AQeTAK1d5MTC2K23mfbxmr91qw/Gk2aaqGMiC6biTVmR8gxbue9ArNPCL+P4B pQa5X4ZDTGhgChJWf8ZudtQGJ0K8fyuUz616JdOCA6IKgBi9RVl7vCbt7fHamT2fu6+e kDC6KcNkYqbOuopWtmsNhRemY4h0V+WvkSOsfEjdnb+7BkJZttNmsYQYrUB/QWXK6bTj HlFp91VnKWGRAByEDq4HwlBrNo4KIKQBA6Wwfu5jip9cQVMxCeC9CKL4RC5wfgsMXgHt a0oQ== X-Gm-Message-State: ACrzQf38kzqku8gLf+M3UBrzH3jLLD32mJR90/YDL5gRcLQG2BQUA+pD hMYkULZaQ0gKGGVXkuvepxvmzw== X-Received: by 2002:a92:4449:0:b0:2de:95f1:8b80 with SMTP id a9-20020a924449000000b002de95f18b80mr14985942ilm.232.1666379632612; Fri, 21 Oct 2022 12:13:52 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13: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 5/7] net: ipa: introduce ipa_cmd_init() Date: Fri, 21 Oct 2022 14:13:38 -0500 Message-Id: <20221021191340.4187935-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747325929917275777?= X-GMAIL-MSGID: =?utf-8?q?1747325929917275777?= Currently, ipa_cmd_data_valid() is called by ipa_mem_config(). Nothing it does requires access to hardware though, so it can be done during the init phase of IPA driver startup. Create a new function ipa_cmd_init(), whose purpose is to do early initialization related to IPA immediate commands. It will call the build-time validation function, then will make the two calls made previously by ipa_cmd_data_valid(). This make ipa_cmd_data_valid() unnecessary, so get rid of it. Rename ipa_cmd_header_valid() to be ipa_cmd_header_init_local_valid(), so its name is clearer about which IPA immediate command it is associated with. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 31 +++++++++++++++---------------- drivers/net/ipa/ipa_cmd.h | 10 ++++++++++ drivers/net/ipa/ipa_mem.c | 4 ---- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index abee6cc018a27..de2cd86aa9e28 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -202,7 +202,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, } /* Validate the memory region that holds headers */ -static bool ipa_cmd_header_valid(struct ipa *ipa) +static bool ipa_cmd_header_init_local_valid(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; const struct ipa_mem *mem; @@ -318,26 +318,11 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa) return true; } -bool ipa_cmd_data_valid(struct ipa *ipa) -{ - if (!ipa_cmd_header_valid(ipa)) - return false; - - if (!ipa_cmd_register_write_valid(ipa)) - return false; - - return true; -} - - int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max) { struct gsi_trans_info *trans_info = &channel->trans_info; struct device *dev = channel->gsi->dev; - /* This is as good a place as any to validate build constants */ - ipa_cmd_validate_build(); - /* Command payloads are allocated one at a time, but a single * transaction can require up to the maximum supported by the * channel; treat them as if they were allocated all at once. @@ -637,3 +622,17 @@ struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count) return gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id, tre_count, DMA_NONE); } + +/* Init function for immediate commands; there is no ipa_cmd_exit() */ +int ipa_cmd_init(struct ipa *ipa) +{ + ipa_cmd_validate_build(); + + if (!ipa_cmd_header_init_local_valid(ipa)) + return -EINVAL; + + if (!ipa_cmd_register_write_valid(ipa)) + return -EINVAL; + + return 0; +} diff --git a/drivers/net/ipa/ipa_cmd.h b/drivers/net/ipa/ipa_cmd.h index d03cc619e2c31..e2cf1c2b0ef24 100644 --- a/drivers/net/ipa/ipa_cmd.h +++ b/drivers/net/ipa/ipa_cmd.h @@ -162,4 +162,14 @@ void ipa_cmd_pipeline_clear_wait(struct ipa *ipa); */ struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count); +/** + * ipa_cmd_init() - Initialize IPA immediate commands + * @ipa: - IPA pointer + * + * Return: 0 if successful, or a negative error code + * + * There is no need for a matching ipa_cmd_exit() function. + */ +int ipa_cmd_init(struct ipa *ipa); + #endif /* _IPA_CMD_H_ */ diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index f84c6830495a4..2238dac2af07e 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -370,10 +370,6 @@ int ipa_mem_config(struct ipa *ipa) if (!ipa_table_valid(ipa)) goto err_dma_free; - /* Validate memory-related properties relevant to immediate commands */ - if (!ipa_cmd_data_valid(ipa)) - goto err_dma_free; - /* Verify the microcontroller ring alignment (if defined) */ mem = ipa_mem_find(ipa, IPA_MEM_UC_EVENT_RING); if (mem && mem->offset % 1024) { From patchwork Fri Oct 21 19:13: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: 6947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp864063wrr; Fri, 21 Oct 2022 12:17:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6URBFx7qB5uYw+s0myzYhtReiVwmZUyl9EipCe2zlqHRWGepzGIrqlhVVvkeDWoQCd6abu X-Received: by 2002:a17:906:4786:b0:78d:b793:5bf6 with SMTP id cw6-20020a170906478600b0078db7935bf6mr17100270ejc.222.1666379874142; Fri, 21 Oct 2022 12:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666379874; cv=none; d=google.com; s=arc-20160816; b=XjhFd73Tr6nC4hXiRqEGIvdeHSLAPHO/WaIbTK7i1Z9lpqh89yodQKCBpMBdpuh4ZU axTC4P2h43N5ZxXN5lgq/wIR6B91lF4uUvlRXMT+IH511rZJyfV3J981tAUKUtvjLPrv 0HUSenDEYZ0fQVTfwgzPFOzxJusXOGMPqz3qPayfscdqNT1vscQjzGJBJDvDgxT62SuG I2tZfm1WACm+k5c0LazFksrHClprP8ucbIXl4vsxDu0R7HVwh3yNCY6idzevEiDbv3k8 rnJeXXFUP5mW/Mn9zdEl6D+Y3GEAorCMxa5Adq9US63CfXD5k6lcosKCtO6J9fPLz/Ma brsQ== 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=qAM1egPVWVrike9dFWQzNQN7PoIv5TOv3JuxtoXyqE4=; b=ONpRjwGPESVP/r6LCQ+pqmgEngMPqlTgLjYvBf+FqJBowzg7GUy1YLh7rXSA7tVbTw rUFK/1FZ3GT0mAi37fjJH3ey+7PqVSdrPpxvEphcCyjXQQU9Wn5aFuhR+THZElLDjick jasvgKxKXAz9FMojM+R9kIeE/+pSydWVsfcsNTPWuAYKqbzePgsETzIkKoeF51lT4Xgq SvWB5IeUYKsPGMQwYBvQXpp9URoAZ57daQFmelbuhPiMJDgrCSw1JEjfbH4yQv8F/yav BKSNjsxEvTXYwW3lbnMbbeuf9CJM7tWkHobpKlLozqFehi/UCSCZe0q5g5qtdwUMZz8m 5vRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tKJZ9iQB; 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 d7-20020aa7c1c7000000b00457d6a92180si3284637edp.538.2022.10.21.12.17.29; Fri, 21 Oct 2022 12:17: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=tKJZ9iQB; 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 S230422AbiJUTOP (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbiJUTN6 (ORCPT ); Fri, 21 Oct 2022 15:13:58 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692F7295B01 for ; Fri, 21 Oct 2022 12:13:55 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id q18so2143239ils.12 for ; Fri, 21 Oct 2022 12:13:55 -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=qAM1egPVWVrike9dFWQzNQN7PoIv5TOv3JuxtoXyqE4=; b=tKJZ9iQBwxdnhWesKo8avmic9dyQA85QgCdk0ZvCuN+PgentQO+5dk6cYu0zc/5pzM xQCE5VWlKy0kEG6jC2eWdvDx0vlxzzllmRDPNXGktN6DKf4jpnS5tANWx9dPivslbV0B Wp8KULKmHLFfwmOzb58r1ag5hyHuFVgKD97HjhMlq01Bz96t8tbha/P8fjAx9maH+JXr MotJLvZhB0ileRiweiugeyqH5TNppfOLyByU52u+Y3O6JBHkRMhvkdEM3XAOHOSLM6Sg 0SXxteXEYePjK/EwK4/QbPK16mvHs5sTzYI6tiVkQE/6fWkfWFW8teJB0eWOaRxEQUCD rgXw== 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=qAM1egPVWVrike9dFWQzNQN7PoIv5TOv3JuxtoXyqE4=; b=7JzAVP1HvoDOYFqQnA4pyDi0wF5tgOCeJKQysM+BrL7ECDl0dOgx3jBIqUv3ZKNBpQ AHbJoiVlXhsOsZ5jMlwlUQIFpm14p/5JSLHPLmZQG++p3Sj3uLFvafWQuFloBcAPOuHJ 9k+V6KEhDvXqm0dFedfyo1VJCBFKVwxzwrsmg2UKjLww8cRlslC2f7ueVsbZT78Fr2j7 8XGUVEMXyuAbkmirm1yBuO5QRCBn/mK1qHozQ6QNdq26UwhvgEFZL1qaV0UaqceWw8kv nzH5e593idHnh6VHW06rMR6nO/U/RsAUxhNXw82NCnqaY24+OFqQMsUg9eZtxppqZIeH WxRw== X-Gm-Message-State: ACrzQf3zDrvbRxBvVR798EjMimsu3quTvHgiUybLpr+rSaIM39CNSCb3 WAbbqhNG3W81wlH/LWvzrVl5eg== X-Received: by 2002:a05:6e02:170d:b0:2fc:3e76:b262 with SMTP id u13-20020a056e02170d00b002fc3e76b262mr14803311ill.152.1666379634210; Fri, 21 Oct 2022 12:13:54 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13: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 6/7] net: ipa: kill ipa_table_valid() Date: Fri, 21 Oct 2022 14:13:39 -0500 Message-Id: <20221021191340.4187935-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747325942575696727?= X-GMAIL-MSGID: =?utf-8?q?1747325942575696727?= What ipa_table_valid() (and ipa_table_valid_one(), which it calls) does is ensure that the memory regions that hold routing and filter tables have reasonable size. Specifically, it checks that the size of a region is sufficient (or rather, exactly the right size) to hold the maximum number of entries supported by the driver. (There is an additional check that's erroneous, but in practice it is never reached.) Recently ipa_table_mem_valid() was added, which is called by ipa_table_init(). That function verifies that all table memory regions are of sufficient size, and requires hashed tables to have zero size if hashing is not supported. It only ensures the filter table is large enough to hold the number of endpoints that support filtering, but that is adequate. Therefore everything that ipa_table_valid() does is redundant, so get rid of it. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 4 --- drivers/net/ipa/ipa_table.c | 50 ------------------------------------- drivers/net/ipa/ipa_table.h | 8 ------ 3 files changed, 62 deletions(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 2238dac2af07e..4022ae01a1319 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -366,10 +366,6 @@ int ipa_mem_config(struct ipa *ipa) while (--canary_count); } - /* Make sure filter and route table memory regions are valid */ - if (!ipa_table_valid(ipa)) - goto err_dma_free; - /* Verify the microcontroller ring alignment (if defined) */ mem = ipa_mem_find(ipa, IPA_MEM_UC_EVENT_RING); if (mem && mem->offset % 1024) { diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 9822b18d9ed39..7a60f2867de92 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -155,56 +155,6 @@ ipa_table_mem(struct ipa *ipa, bool filter, bool hashed, bool ipv6) return ipa_mem_find(ipa, mem_id); } -static bool -ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) -{ - const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); - struct device *dev = &ipa->pdev->dev; - u32 size; - - if (route) - size = IPA_ROUTE_COUNT_MAX * sizeof(__le64); - else - size = (1 + IPA_FILTER_COUNT_MAX) * sizeof(__le64); - /* mem->size >= size is sufficient, but we'll demand more */ - if (mem->size == size) - return true; - - /* Hashed table regions can be zero size if hashing is not supported */ - if (ipa_table_hash_support(ipa) && !mem->size) - return true; - - dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n", - route ? "route" : "filter", mem_id, mem->size, size); - - return false; -} - -/* Verify the filter and route table memory regions are the expected size */ -bool ipa_table_valid(struct ipa *ipa) -{ - bool valid; - - valid = ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER, false); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER, false); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE, true); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE, true); - - if (!ipa_table_hash_support(ipa)) - return valid; - - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER_HASHED, - false); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER_HASHED, - false); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE_HASHED, - true); - valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE_HASHED, - true); - - return valid; -} - bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) { struct device *dev = &ipa->pdev->dev; diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 395189f75d784..73ca8369c6352 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -19,14 +19,6 @@ struct ipa; /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ #define IPA_ROUTE_COUNT_MAX 15 -/** - * ipa_table_valid() - Validate route and filter table memory regions - * @ipa: IPA pointer - * - * Return: true if all regions are valid, false otherwise - */ -bool ipa_table_valid(struct ipa *ipa); - /** * ipa_filter_map_valid() - Validate a filter table endpoint bitmap * @ipa: IPA pointer From patchwork Fri Oct 21 19:13:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 6951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp864851wrr; Fri, 21 Oct 2022 12:20:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4l6Cd7W5ibB/58RGbNbDnc+hOxJPB4I0KbwI9xNNCtqyGAtT/goDtaMx3dbixU9Dzx46P0 X-Received: by 2002:a05:6402:3509:b0:45d:c25b:b80e with SMTP id b9-20020a056402350900b0045dc25bb80emr19012432edd.250.1666380024436; Fri, 21 Oct 2022 12:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666380024; cv=none; d=google.com; s=arc-20160816; b=z8HcFto4woPIbN90+NNChChJM9e7eOtGxFwsaYkgHvenly6dMTd8/UeUu7Unzb77wM GhezlggIiVfW866aWDK6hXYtkmrTZTnaPJOoNx4KpX3euhoDAvorMvrhRwpGG5kQp+pA Yg5YRlN+l8+DjLjFSVuA2FCKxbEuBgZYX8VoNFxM0iRWG8BS+ZbWo/+2Fy+0QHhwnAFV iTy1c+z8Tc5Y7eZ6WVu17IwF1vkKzKXcwD9JXjgO0gT1TQyeRMcsZ/dKtTlgbiHS/lyT Ra5bNSj5pQZqTDIDj+yBx/F2Kp63Is15DOp76cZ0pc8Tr9g3kxeU9QZ2inL4bUk2ReXF is6w== 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=YuA9mKyzPMTQB96gOrAuldDGglDRxOANAMQpmF9JcZ0=; b=dP/U4NDpFfleBUQ+edEQZIL12x98rZDZMvx1453oJtozvGVLQeHqFfUZ+KLMmMMfgi MdAMHgt0scw+uokdugVN1RAD+DqOaY6pUocwd5FKSQ33WUy4hN/OikTgWpeLrwK7lre5 Sd5w4IkYmwPIDXGNo5A5Rxly71OEoJBZQ9gUL/PEAet7SGVNX0oajEiLxsTX8Ass9Iyu HLHvlnW1M7vt/yh+QfX7j/yTJJ+DXqUKtX2k+0V+0pl4cQnVkDmCd2rHK8GT+aBTwHDX jkbZtHPWAI7Grn/Nr97BQhDttvQI80dAToQPP5ia0gywJUcU248ff4Q36yjZ14hcvmYN buqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYGLvXfJ; 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 p11-20020a056402500b00b0045cca8f9a0asi23794044eda.580.2022.10.21.12.19.58; Fri, 21 Oct 2022 12:20:24 -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=ZYGLvXfJ; 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 S230341AbiJUTOW (ORCPT + 99 others); Fri, 21 Oct 2022 15:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiJUTN7 (ORCPT ); Fri, 21 Oct 2022 15:13:59 -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 425A9295B16 for ; Fri, 21 Oct 2022 12:13:55 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id n73so3090424iod.13 for ; Fri, 21 Oct 2022 12:13:55 -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=YuA9mKyzPMTQB96gOrAuldDGglDRxOANAMQpmF9JcZ0=; b=ZYGLvXfJXfOMImi9z8M402ao5MOo2atA26a8WtkT2ElDHxDj9qZwZJzhTS84cJWfgw MlaG8sgrcqNt8Wy6DqScoGjY95+B61HAHyxFIPeHm3+jzUUq3QrQDnQ+QF2rk8NzorO8 76qfH7T+OZTx2/by5CdMlS2nSIa+YGMvMY24mGu3qJP3WtfQ9MwGkrJTESrvCg5Q09oV ofp+qHQMdyOdInjdsMWJd2i45AsHtCn3Pq/hRt+OorVtY+ixUvMBBncTSCl6FZhiXWjq Qr4z0Uf2ByE/bNTyU8cQ5YEdrpwgq+VNBl/2uZ49tidRenZR9+5H09lNuhje0hIPoObW /7wA== 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=YuA9mKyzPMTQB96gOrAuldDGglDRxOANAMQpmF9JcZ0=; b=LrTSuQUmu8vFurO3NN9rSAmUxB1oNsZBp8dZ3h0fhbATqUlaGrii0LDRCwS3/o0jSF IOm4jG7q7j7aQl/kGsHD0/Y3+lNfOexleQzRhDEgVXur4tmX7GG5N13lLeexd8f/R0Fj 8sa1E3mjjvYoZ8Cag8hDK44NJhbbqyZCGYvGXlT6Q1VdocllH16UvV076oecb9dA96i4 HJAb4vAXvMG57jwSrMG0ETaMFelqOG3/WiSmkL/YHh83KvJWCN7zqagisnGF2cfI1pg9 KZvawkOSepHMjylUt5BqQSYNVQ3XJYZuCJ13Q72dzng8esJIXTBp1wq4s1Y+hsJGIaSb sphA== X-Gm-Message-State: ACrzQf0rDnbURuTm7w8fmDhpplJ5SYsva+yBYHMflhsynhFx2BYbDsCJ ndQOeK9GAkA/MH5Zw/sfdXGUNg== X-Received: by 2002:a05:6602:2c4b:b0:6bc:ab20:2c28 with SMTP id x11-20020a0566022c4b00b006bcab202c28mr14765936iov.70.1666379635622; Fri, 21 Oct 2022 12:13:55 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id e3-20020a022103000000b00363c68aa348sm4439362jaa.72.2022.10.21.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 12:13:55 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/7] net: ipa: check table memory regions earlier Date: Fri, 21 Oct 2022 14:13:40 -0500 Message-Id: <20221021191340.4187935-8-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021191340.4187935-1-elder@linaro.org> References: <20221021191340.4187935-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,URIBL_BLOCKED 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?1747326100620726493?= X-GMAIL-MSGID: =?utf-8?q?1747326100620726493?= Verify that the sizes of the routing and filter table memory regions are valid as part of memory initialization, rather than waiting for table initialization. The main reason to do this is that upcoming patches use these memory region sizes to determine the number of entries in these tables, and we'll want to know these sizes are good sooner. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 6 ++++++ drivers/net/ipa/ipa_table.c | 7 +------ drivers/net/ipa/ipa_table.h | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 4022ae01a1319..a3d2317452ac6 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -617,6 +617,12 @@ int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) ipa->mem_count = mem_data->local_count; ipa->mem = mem_data->local; + /* Check the route and filter table memory regions */ + if (!ipa_table_mem_valid(ipa, 0)) + return -EINVAL; + if (!ipa_table_mem_valid(ipa, IPA_ROUTE_MODEM_COUNT)) + return -EINVAL; + ret = dma_set_mask_and_coherent(&ipa->pdev->dev, DMA_BIT_MASK(64)); if (ret) { dev_err(dev, "error %d setting DMA mask\n", ret); diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 7a60f2867de92..58a1a9da3133e 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -567,7 +567,7 @@ void ipa_table_config(struct ipa *ipa) } /* Zero modem_route_count means filter table memory check */ -static bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) +bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) { bool hash_support = ipa_table_hash_support(ipa); bool filter = !modem_route_count; @@ -688,11 +688,6 @@ int ipa_table_init(struct ipa *ipa) ipa_table_validate_build(); - if (!ipa_table_mem_valid(ipa, 0)) - return -EINVAL; - if (!ipa_table_mem_valid(ipa, IPA_ROUTE_MODEM_COUNT)) - return -EINVAL; - /* The IPA hardware requires route and filter table rules to be * aligned on a 128-byte boundary. We put the "zero rule" at the * base of the table area allocated here. The DMA address returned diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 73ca8369c6352..65d96debd3917 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -78,4 +78,11 @@ int ipa_table_init(struct ipa *ipa); */ void ipa_table_exit(struct ipa *ipa); +/** + * ipa_table_mem_valid() - Validate sizes of table memory regions + * @ipa: IPA pointer + * @modem_route_count: Number of modem route table entries + */ +bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count); + #endif /* _IPA_TABLE_H_ */