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_ */