From patchwork Wed Jun 9 22:34:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456836 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721047jae; Wed, 9 Jun 2021 15:35:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn9zU26/328vFLf5AnANLeFRaCiuoRdv7Fq84Oo2Kdo/SN6i2ZjrINcm1UstHxtpS76IFJ X-Received: by 2002:aa7:c04e:: with SMTP id k14mr1508174edo.157.1623278157789; Wed, 09 Jun 2021 15:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278157; cv=none; d=google.com; s=arc-20160816; b=sPFDAwZRy1a7B8IrnIl6zdqjw9Dgrtqvb6oGbndQN6evSEPKtBNW+6ruD9Hsa+mX4m 1WBZisnFWFHJFlUAFAESfNhhvHtVFWZY1+2/De7OdydDymkBnZhDN0OcDLXW9N5WvEG7 pifXpSaLNcAwcwijJpdEjoocS11qruAE9/m1/ay9gDEvT/3GD/5pvdK5nHyhTkNPS2I8 xgxU7Pi2LGOmK63O20MJTgjSikUU70aS4oZBC7I2nYmvfdau59Q4ySUodE/40CyPyDUr 7IMiayLUvGEiwLhtSbgc+Ktkh5SpcySonXLhBqBuQDwtB5Tqsx5PxTwm2hm3s3zQsKYg RW9g== 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=+3Be2aADV7uPp72IR6w8DJQv7KxaXAQZAy5ctN+CH2I=; b=MTRZvjiga+fSuM0WUDAga+38s0r2j3RnZ+7KFTc/cQwycUdy1S0kqzXPRJ44iUYU/S AIAnYcu7hbYV1PPfFB7a277CAAzL1tpKT+jb2T2mcRyxNXb1G1gV5bmY6NRHa3OzGwkj xKqw5dJh0E4F+5ho6DKnLQ5Aoyj52yBiNKXbjAxReotgLj1WgWUm4B9leDJzrIPKgrdy ME+nZbJ3EwoshTLY5vS09I3bNUt3QzO43dnywubKEU37B3GHz/OzyyV/mBKrJEbvj6yU T17mgTDhQTB3ARLKe0Kpm9jVsIBGtsgvAZlUd+y6nH5ml6s5X+ISOXQA1Vp+osG+gRj7 97ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TXn397a5; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.35.57; Wed, 09 Jun 2021 15:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TXn397a5; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230103AbhFIWhP (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhFIWhO (ORCPT ); Wed, 9 Jun 2021 18:37:14 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D78F4C061574 for ; Wed, 9 Jun 2021 15:35:07 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id w14so18549264ilv.1 for ; Wed, 09 Jun 2021 15:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+3Be2aADV7uPp72IR6w8DJQv7KxaXAQZAy5ctN+CH2I=; b=TXn397a52FqS+L7I4Ntuv2ciaDVD91K3vP+UR+IcwqhrvxeTGvnpgzwwXrTBRQO9cC diTaTT/wnrPLokSDh3i0Is5LZkUP8TDPCpq1IyrzCFjR74GLALa3X+WmZiWhE9E4ZanJ /71/x+n75SkYmA+Ldd1I+tuBBdlylmMwUdGIyDY3EV5r4ii6LrmbAjEdLmhx7MybAl2y GRBLoIKrKjhBWCcBCaVyXA4K036RGzf6hwxTZzP4xguADk3+jPO5UuU3ITr7VEMNyI73 PbYN8sDoWPwzartr8NPoOIX77BbCPGt1ElMUndBqhPoZThYScyHY0janswYE1ph3iqia V97Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+3Be2aADV7uPp72IR6w8DJQv7KxaXAQZAy5ctN+CH2I=; b=Bux3ZGg5PeKtpVvgxrfGUK4bem0mdaI+G72xGV4MKcPoMBUDAmd+Q6MDLnHKQ6CCDG ev2ZdKJRW+nDM3KvMaEX+FaeNje544KcAy6USvSJT6ZF5oM9npLURnYW+OgnYFvi8msW x6fsp758A8yVgphgTudUW7muLDMawGSKNaSQ1UvbN1irA7QHIx/fl+BzGQ1r+rgg0nYL CuvnhHjGINKM207oJAYR7YchIM2r/+n+jDP1HcLucKhaFVfcK+zRiD5arRKaZoqNa1Xm c8SnVakpaUMqw2HQ8YEzVRCi0OShKgPy9sEu4pmx9cBAlSD48kZmd4G9bYiaFhhUz1Cj uvWg== X-Gm-Message-State: AOAM530MsDJsRGsyqOS6ermW76IgMyHQ+rjyq9mptu7OY2lajOKu2Jqm EY4wEPHBusmpv+huNPwgbDmu5Q== X-Received: by 2002:a05:6e02:219d:: with SMTP id j29mr670381ila.64.1623278107318; Wed, 09 Jun 2021 15:35:07 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:07 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 01/11] net: ipa: define IPA_MEM_END_MARKER Date: Wed, 9 Jun 2021 17:34:53 -0500 Message-Id: <20210609223503.2649114-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define a new pseudo memory region identifer that specifies the offset at the end of IPA resident memory. Use it instead of IPA_MEM_UC_EVENT_RING in places where the size of that region was defined to be 0. The size of the IPA_MEM_END_MARKER pseudo region must be zero. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_data-v4.11.c | 2 +- drivers/net/ipa/ipa_data-v4.2.c | 2 +- drivers/net/ipa/ipa_mem.c | 2 ++ drivers/net/ipa/ipa_mem.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_data-v4.11.c b/drivers/net/ipa/ipa_data-v4.11.c index 05806ceae8b54..e7bdb8b4400e7 100644 --- a/drivers/net/ipa/ipa_data-v4.11.c +++ b/drivers/net/ipa/ipa_data-v4.11.c @@ -325,7 +325,7 @@ static const struct ipa_mem ipa_mem_local_data[] = { .size = 0x100c, .canary_count = 2, }, - [IPA_MEM_UC_EVENT_RING] = { + [IPA_MEM_END_MARKER] = { .offset = 0x3000, .size = 0x0000, .canary_count = 1, diff --git a/drivers/net/ipa/ipa_data-v4.2.c b/drivers/net/ipa/ipa_data-v4.2.c index 8744f19c64011..95f75dbc3c3bc 100644 --- a/drivers/net/ipa/ipa_data-v4.2.c +++ b/drivers/net/ipa/ipa_data-v4.2.c @@ -304,7 +304,7 @@ static const struct ipa_mem ipa_mem_local_data[] = { .size = 0x140c, .canary_count = 0, }, - [IPA_MEM_UC_EVENT_RING] = { + [IPA_MEM_END_MARKER] = { .offset = 0x2000, .size = 0, .canary_count = 1, diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 1624125e7459f..e3c43cf6e4412 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -120,6 +120,8 @@ static bool ipa_mem_valid(struct ipa *ipa, enum ipa_mem_id mem_id) else if (mem->offset + mem->size > ipa->mem_size) dev_err(dev, "region %u ends beyond memory limit (0x%08x)\n", mem_id, ipa->mem_size); + else if (mem_id == IPA_MEM_END_MARKER && mem->size) + dev_err(dev, "non-zero end marker region size\n"); else return true; diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index a422aec69e5da..5a4f865a45afa 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -70,6 +70,7 @@ enum ipa_mem_id { IPA_MEM_STATS_DROP, /* 0 canaries (IPA v4.0 and above) */ IPA_MEM_MODEM, /* 0/2 canaries */ IPA_MEM_UC_EVENT_RING, /* 1 canary */ + IPA_MEM_END_MARKER, /* 1 canary (not a real region) */ IPA_MEM_COUNT, /* Number of regions (not an index) */ }; From patchwork Wed Jun 9 22:34:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456841 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721081jae; Wed, 9 Jun 2021 15:36:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbcKEp/3NDExVVfanRtHzmtLZ5zsQZwEGvqpSsMG3z+O2kCep374D4f6Xj4P3ZUsEjti1F X-Received: by 2002:aa7:d6cc:: with SMTP id x12mr1589793edr.55.1623278160853; Wed, 09 Jun 2021 15:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278160; cv=none; d=google.com; s=arc-20160816; b=t9i3XtK17fN3VbqniegHTect05mH6nR5FUVvQYQIPDYPTdbAx3WexpILe+K+xira95 agQQmYzw6OVAtDzy/wFm80QE1RS4y88s/GkDGW3FH2Knj2kKU0dfBI2A8mvStapTC90s gd3YIhNkzX5/KVkC5vY2T5+8Xz0SNKR4i9kCV9g6a4Cc2mzsC/AJCZAoVzFOJwVYGOoj NlKzoneH4dhB1BzvNQXN/lmknZ/SgZctj88hMVx6Vb6+87joB0xrfiY4XGwlkIGk38KQ zaZCwAmQP68RoaKiQMStP6QF01+4DOWlnXDgnGMGPhi8dVvrM/n79Vk69hDh5R9uyfSR ESFw== 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=DoVedes8aza4XbMfRyN+dmWQLI3QtjACwFQ/YsnMRHY=; b=z29e2Z/3JferSfTe378mK8HnSbgts0LUnsvtKLfuYAc/GhUFEHfubWU2DhXoNcJN1K 1CK4EeNKrK40hfJYD1Eb6YyOCM4bxanWH99M61g+B8qmbPeTpSpKQ75qfz5NIqUXJ00g urQcffjeJxLl3g4Hhz2/z/6Vyq3X27JygqjrkauEO9a/aTmCJOOnogcmOFIeNK6J8nDH U6j8/X9isOzHJfMqet43ByNgVc/ng6U6El0uIoZE2BViKKnb0mebuduLLQb8djM+yZ1J 4Q7tXrdg3hkJExqDnbGBkCAPtpZXoD/N0yQ/1sBM+ERxwtMBOREDcVc+nNrQvMk7dw9L EIzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V9uiK2Yz; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.36.00; Wed, 09 Jun 2021 15:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V9uiK2Yz; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230212AbhFIWh0 (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbhFIWhQ (ORCPT ); Wed, 9 Jun 2021 18:37:16 -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 F1EF8C06175F for ; Wed, 9 Jun 2021 15:35:08 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id i17so28135694ilj.11 for ; Wed, 09 Jun 2021 15:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DoVedes8aza4XbMfRyN+dmWQLI3QtjACwFQ/YsnMRHY=; b=V9uiK2YzOXjx6eGXKkaB3OXMmx7G6C0bUntsmLdJU0PNDAbd4hciqVmHv4rcfqt0zf Os44L7bG9I6+vUVCT0o1tmMlt9z294ZdYiLGtEGqiSx4TW3BNG5vjb2r9j2TyJ1f8voS V87XLEzVjxzK1B15+SYA5KvvACq45tMTCUTN6JTTpxsR0zBClI7t0/bXSgn/4oXnXYdJ tNdZHNnfl0+Gy4/BITFYAx0QXC4KsXFkSe4QwiXRKobuHLH4zIt11jjrKm7afAHMkE/1 efvni8Rs5oprPzySHiRhaDEnmPPL4HgMmjtR+bT1eEmMK21PEZ3gV78uW+mMNDCnnm0L ZHLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DoVedes8aza4XbMfRyN+dmWQLI3QtjACwFQ/YsnMRHY=; b=r1RVIkPo1QltqNQyAcT9k2c7mEGgHtcetcuzu2nlu6AqWgwsCE0Gdzi1YXtdA793f5 7GmsIXWPpwot4XKBOX9PYWz57mF89HbdH3he0i+zuwwupBelFhakYGKcfL2olouRl70V KRCCUeAseXfaL0cw9c77h1vy+jmhf9ijKfO+kck0lOLnFEeukWZbDG1zeaUR8DwcOzdF mUt06V63LslVux1sP9W+2/IFTwkS65oI1FMkqFzRmkduNmbIXrfom9zDWpoju1HZJnL5 8ykr8aWQV1zdNISliOaj8dA09z8aJaUrkQvE8pxNCKvr7gexjDJW+0QnMDkxlzo9WxwE wOgA== X-Gm-Message-State: AOAM530SSR5O8fluVvrJrrczMzyU90j7dJ43CjmoA6rYE/MPmeENkK8H 18vEAbNtJCCqVXeT7jBYXQ3mkg== X-Received: by 2002:a05:6e02:5ce:: with SMTP id l14mr1521252ils.94.1623278108345; Wed, 09 Jun 2021 15:35:08 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:08 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 02/11] net: ipa: store memory region id in descriptor Date: Wed, 9 Jun 2021 17:34:54 -0500 Message-Id: <20210609223503.2649114-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Store the memory region ID in the memory descriptor structure. This is a move toward *not* indexing the array by the ID, but for now we must still specify those index values. Define an explicitly undefined region ID, value 0, so uninitialized entries in the array won't use an otherwise valid ID. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_data-v3.5.1.c | 15 +++++++++++++++ drivers/net/ipa/ipa_data-v4.11.c | 22 ++++++++++++++++++++++ drivers/net/ipa/ipa_data-v4.2.c | 18 ++++++++++++++++++ drivers/net/ipa/ipa_data-v4.5.c | 23 +++++++++++++++++++++++ drivers/net/ipa/ipa_data-v4.9.c | 26 +++++++++++++++++++++++++- drivers/net/ipa/ipa_mem.h | 3 +++ 6 files changed, 106 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_data-v3.5.1.c b/drivers/net/ipa/ipa_data-v3.5.1.c index ead1a82f32f5c..945d45b72b247 100644 --- a/drivers/net/ipa/ipa_data-v3.5.1.c +++ b/drivers/net/ipa/ipa_data-v3.5.1.c @@ -272,76 +272,91 @@ static const struct ipa_resource_data ipa_resource_data = { /* IPA-resident memory region data for an SoC having IPA v3.5.1 */ static const struct ipa_mem ipa_mem_local_data[] = { [IPA_MEM_UC_SHARED] = { + .id = IPA_MEM_UC_SHARED, .offset = 0x0000, .size = 0x0080, .canary_count = 0, }, [IPA_MEM_UC_INFO] = { + .id = IPA_MEM_UC_INFO, .offset = 0x0080, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_V4_FILTER_HASHED] = { + .id = IPA_MEM_V4_FILTER_HASHED, .offset = 0x0288, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_FILTER] = { + .id = IPA_MEM_V4_FILTER, .offset = 0x0308, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER_HASHED] = { + .id = IPA_MEM_V6_FILTER_HASHED, .offset = 0x0388, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER] = { + .id = IPA_MEM_V6_FILTER, .offset = 0x0408, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE_HASHED] = { + .id = IPA_MEM_V4_ROUTE_HASHED, .offset = 0x0488, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE] = { + .id = IPA_MEM_V4_ROUTE, .offset = 0x0508, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE_HASHED] = { + .id = IPA_MEM_V6_ROUTE_HASHED, .offset = 0x0588, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE] = { + .id = IPA_MEM_V6_ROUTE, .offset = 0x0608, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_MODEM_HEADER] = { + .id = IPA_MEM_MODEM_HEADER, .offset = 0x0688, .size = 0x0140, .canary_count = 2, }, [IPA_MEM_MODEM_PROC_CTX] = { + .id = IPA_MEM_MODEM_PROC_CTX, .offset = 0x07d0, .size = 0x0200, .canary_count = 2, }, [IPA_MEM_AP_PROC_CTX] = { + .id = IPA_MEM_AP_PROC_CTX, .offset = 0x09d0, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_MODEM] = { + .id = IPA_MEM_MODEM, .offset = 0x0bd8, .size = 0x1024, .canary_count = 0, }, [IPA_MEM_UC_EVENT_RING] = { + .id = IPA_MEM_UC_EVENT_RING, .offset = 0x1c00, .size = 0x0400, .canary_count = 1, diff --git a/drivers/net/ipa/ipa_data-v4.11.c b/drivers/net/ipa/ipa_data-v4.11.c index e7bdb8b4400e7..2ff3fcf4e21fa 100644 --- a/drivers/net/ipa/ipa_data-v4.11.c +++ b/drivers/net/ipa/ipa_data-v4.11.c @@ -221,111 +221,133 @@ static const struct ipa_resource_data ipa_resource_data = { /* IPA-resident memory region data for an SoC having IPA v4.11 */ static const struct ipa_mem ipa_mem_local_data[] = { [IPA_MEM_UC_SHARED] = { + .id = IPA_MEM_UC_SHARED, .offset = 0x0000, .size = 0x0080, .canary_count = 0, }, [IPA_MEM_UC_INFO] = { + .id = IPA_MEM_UC_INFO, .offset = 0x0080, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_V4_FILTER_HASHED] = { + .id = IPA_MEM_V4_FILTER_HASHED, .offset = 0x0288, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_FILTER] = { + .id = IPA_MEM_V4_FILTER, .offset = 0x0308, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER_HASHED] = { + .id = IPA_MEM_V6_FILTER_HASHED, .offset = 0x0388, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER] = { + .id = IPA_MEM_V6_FILTER, .offset = 0x0408, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE_HASHED] = { + .id = IPA_MEM_V4_ROUTE_HASHED, .offset = 0x0488, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE] = { + .id = IPA_MEM_V4_ROUTE, .offset = 0x0508, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE_HASHED] = { + .id = IPA_MEM_V6_ROUTE_HASHED, .offset = 0x0588, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE] = { + .id = IPA_MEM_V6_ROUTE, .offset = 0x0608, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_MODEM_HEADER] = { + .id = IPA_MEM_MODEM_HEADER, .offset = 0x0688, .size = 0x0240, .canary_count = 2, }, [IPA_MEM_AP_HEADER] = { + .id = IPA_MEM_AP_HEADER, .offset = 0x08c8, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_MODEM_PROC_CTX] = { + .id = IPA_MEM_MODEM_PROC_CTX, .offset = 0x0ad0, .size = 0x0200, .canary_count = 2, }, [IPA_MEM_AP_PROC_CTX] = { + .id = IPA_MEM_AP_PROC_CTX, .offset = 0x0cd0, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_NAT_TABLE] = { + .id = IPA_MEM_NAT_TABLE, .offset = 0x0ee0, .size = 0x0d00, .canary_count = 4, }, [IPA_MEM_PDN_CONFIG] = { + .id = IPA_MEM_PDN_CONFIG, .offset = 0x1be8, .size = 0x0050, .canary_count = 0, }, [IPA_MEM_STATS_QUOTA_MODEM] = { + .id = IPA_MEM_STATS_QUOTA_MODEM, .offset = 0x1c40, .size = 0x0030, .canary_count = 4, }, [IPA_MEM_STATS_QUOTA_AP] = { + .id = IPA_MEM_STATS_QUOTA_AP, .offset = 0x1c70, .size = 0x0048, .canary_count = 0, }, [IPA_MEM_STATS_TETHERING] = { + .id = IPA_MEM_STATS_TETHERING, .offset = 0x1cb8, .size = 0x0238, .canary_count = 0, }, [IPA_MEM_STATS_DROP] = { + .id = IPA_MEM_STATS_DROP, .offset = 0x1ef0, .size = 0x0020, .canary_count = 0, }, [IPA_MEM_MODEM] = { + .id = IPA_MEM_MODEM, .offset = 0x1f18, .size = 0x100c, .canary_count = 2, }, [IPA_MEM_END_MARKER] = { + .id = IPA_MEM_END_MARKER, .offset = 0x3000, .size = 0x0000, .canary_count = 1, diff --git a/drivers/net/ipa/ipa_data-v4.2.c b/drivers/net/ipa/ipa_data-v4.2.c index 95f75dbc3c3bc..f06eb07a7895d 100644 --- a/drivers/net/ipa/ipa_data-v4.2.c +++ b/drivers/net/ipa/ipa_data-v4.2.c @@ -220,91 +220,109 @@ static const struct ipa_resource_data ipa_resource_data = { /* IPA-resident memory region data for an SoC having IPA v4.2 */ static const struct ipa_mem ipa_mem_local_data[] = { [IPA_MEM_UC_SHARED] = { + .id = IPA_MEM_UC_SHARED, .offset = 0x0000, .size = 0x0080, .canary_count = 0, }, [IPA_MEM_UC_INFO] = { + .id = IPA_MEM_UC_INFO, .offset = 0x0080, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_V4_FILTER_HASHED] = { + .id = IPA_MEM_V4_FILTER_HASHED, .offset = 0x0288, .size = 0, .canary_count = 2, }, [IPA_MEM_V4_FILTER] = { + .id = IPA_MEM_V4_FILTER, .offset = 0x0290, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER_HASHED] = { + .id = IPA_MEM_V6_FILTER_HASHED, .offset = 0x0310, .size = 0, .canary_count = 2, }, [IPA_MEM_V6_FILTER] = { + .id = IPA_MEM_V6_FILTER, .offset = 0x0318, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE_HASHED] = { + .id = IPA_MEM_V4_ROUTE_HASHED, .offset = 0x0398, .size = 0, .canary_count = 2, }, [IPA_MEM_V4_ROUTE] = { + .id = IPA_MEM_V4_ROUTE, .offset = 0x03a0, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE_HASHED] = { + .id = IPA_MEM_V6_ROUTE_HASHED, .offset = 0x0420, .size = 0, .canary_count = 2, }, [IPA_MEM_V6_ROUTE] = { + .id = IPA_MEM_V6_ROUTE, .offset = 0x0428, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_MODEM_HEADER] = { + .id = IPA_MEM_MODEM_HEADER, .offset = 0x04a8, .size = 0x0140, .canary_count = 2, }, [IPA_MEM_MODEM_PROC_CTX] = { + .id = IPA_MEM_MODEM_PROC_CTX, .offset = 0x05f0, .size = 0x0200, .canary_count = 2, }, [IPA_MEM_AP_PROC_CTX] = { + .id = IPA_MEM_AP_PROC_CTX, .offset = 0x07f0, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_PDN_CONFIG] = { + .id = IPA_MEM_PDN_CONFIG, .offset = 0x09f8, .size = 0x0050, .canary_count = 2, }, [IPA_MEM_STATS_QUOTA_MODEM] = { + .id = IPA_MEM_STATS_QUOTA_MODEM, .offset = 0x0a50, .size = 0x0060, .canary_count = 2, }, [IPA_MEM_STATS_TETHERING] = { + .id = IPA_MEM_STATS_TETHERING, .offset = 0x0ab0, .size = 0x0140, .canary_count = 0, }, [IPA_MEM_MODEM] = { + .id = IPA_MEM_MODEM, .offset = 0x0bf0, .size = 0x140c, .canary_count = 0, }, [IPA_MEM_END_MARKER] = { + .id = IPA_MEM_END_MARKER, .offset = 0x2000, .size = 0, .canary_count = 1, diff --git a/drivers/net/ipa/ipa_data-v4.5.c b/drivers/net/ipa/ipa_data-v4.5.c index 5f67a3a909ee0..1c8a9099639ab 100644 --- a/drivers/net/ipa/ipa_data-v4.5.c +++ b/drivers/net/ipa/ipa_data-v4.5.c @@ -266,116 +266,139 @@ static const struct ipa_resource_data ipa_resource_data = { /* IPA-resident memory region data for an SoC having IPA v4.5 */ static const struct ipa_mem ipa_mem_local_data[] = { [IPA_MEM_UC_SHARED] = { + .id = IPA_MEM_UC_SHARED, .offset = 0x0000, .size = 0x0080, .canary_count = 0, }, [IPA_MEM_UC_INFO] = { + .id = IPA_MEM_UC_INFO, .offset = 0x0080, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_V4_FILTER_HASHED] = { + .id = IPA_MEM_V4_FILTER_HASHED, .offset = 0x0288, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_FILTER] = { + .id = IPA_MEM_V4_FILTER, .offset = 0x0308, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER_HASHED] = { + .id = IPA_MEM_V6_FILTER_HASHED, .offset = 0x0388, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER] = { + .id = IPA_MEM_V6_FILTER, .offset = 0x0408, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE_HASHED] = { + .id = IPA_MEM_V4_ROUTE_HASHED, .offset = 0x0488, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE] = { + .id = IPA_MEM_V4_ROUTE, .offset = 0x0508, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE_HASHED] = { + .id = IPA_MEM_V6_ROUTE_HASHED, .offset = 0x0588, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE] = { + .id = IPA_MEM_V6_ROUTE, .offset = 0x0608, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_MODEM_HEADER] = { + .id = IPA_MEM_MODEM_HEADER, .offset = 0x0688, .size = 0x0240, .canary_count = 2, }, [IPA_MEM_AP_HEADER] = { + .id = IPA_MEM_AP_HEADER, .offset = 0x08c8, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_MODEM_PROC_CTX] = { + .id = IPA_MEM_MODEM_PROC_CTX, .offset = 0x0ad0, .size = 0x0b20, .canary_count = 2, }, [IPA_MEM_AP_PROC_CTX] = { + .id = IPA_MEM_AP_PROC_CTX, .offset = 0x15f0, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_NAT_TABLE] = { + .id = IPA_MEM_NAT_TABLE, .offset = 0x1800, .size = 0x0d00, .canary_count = 4, }, [IPA_MEM_STATS_QUOTA_MODEM] = { + .id = IPA_MEM_STATS_QUOTA_MODEM, .offset = 0x2510, .size = 0x0030, .canary_count = 4, }, [IPA_MEM_STATS_QUOTA_AP] = { + .id = IPA_MEM_STATS_QUOTA_AP, .offset = 0x2540, .size = 0x0048, .canary_count = 0, }, [IPA_MEM_STATS_TETHERING] = { + .id = IPA_MEM_STATS_TETHERING, .offset = 0x2588, .size = 0x0238, .canary_count = 0, }, [IPA_MEM_STATS_FILTER_ROUTE] = { + .id = IPA_MEM_STATS_FILTER_ROUTE, .offset = 0x27c0, .size = 0x0800, .canary_count = 0, }, [IPA_MEM_STATS_DROP] = { + .id = IPA_MEM_STATS_DROP, .offset = 0x2fc0, .size = 0x0020, .canary_count = 0, }, [IPA_MEM_MODEM] = { + .id = IPA_MEM_MODEM, .offset = 0x2fe8, .size = 0x0800, .canary_count = 2, }, [IPA_MEM_UC_EVENT_RING] = { + .id = IPA_MEM_UC_EVENT_RING, .offset = 0x3800, .size = 0x1000, .canary_count = 1, }, [IPA_MEM_PDN_CONFIG] = { + .id = IPA_MEM_PDN_CONFIG, .offset = 0x4800, .size = 0x0050, .canary_count = 0, diff --git a/drivers/net/ipa/ipa_data-v4.9.c b/drivers/net/ipa/ipa_data-v4.9.c index e41be790f45e5..f77169709eb2a 100644 --- a/drivers/net/ipa/ipa_data-v4.9.c +++ b/drivers/net/ipa/ipa_data-v4.9.c @@ -264,115 +264,139 @@ static const struct ipa_resource_data ipa_resource_data = { /* IPA-resident memory region data for an SoC having IPA v4.9 */ static const struct ipa_mem ipa_mem_local_data[] = { [IPA_MEM_UC_SHARED] = { + .id = IPA_MEM_UC_SHARED, .offset = 0x0000, .size = 0x0080, .canary_count = 0, }, [IPA_MEM_UC_INFO] = { + .id = IPA_MEM_UC_INFO, .offset = 0x0080, .size = 0x0200, .canary_count = 0, }, - [IPA_MEM_V4_FILTER_HASHED] = { .offset = 0x0288, + [IPA_MEM_V4_FILTER_HASHED] = { + .id = IPA_MEM_V4_FILTER_HASHED, + .offset = 0x0288, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_FILTER] = { + .id = IPA_MEM_V4_FILTER, .offset = 0x0308, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER_HASHED] = { + .id = IPA_MEM_V6_FILTER_HASHED, .offset = 0x0388, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_FILTER] = { + .id = IPA_MEM_V6_FILTER, .offset = 0x0408, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE_HASHED] = { + .id = IPA_MEM_V4_ROUTE_HASHED, .offset = 0x0488, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V4_ROUTE] = { + .id = IPA_MEM_V4_ROUTE, .offset = 0x0508, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE_HASHED] = { + .id = IPA_MEM_V6_ROUTE_HASHED, .offset = 0x0588, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_V6_ROUTE] = { + .id = IPA_MEM_V6_ROUTE, .offset = 0x0608, .size = 0x0078, .canary_count = 2, }, [IPA_MEM_MODEM_HEADER] = { + .id = IPA_MEM_MODEM_HEADER, .offset = 0x0688, .size = 0x0240, .canary_count = 2, }, [IPA_MEM_AP_HEADER] = { + .id = IPA_MEM_AP_HEADER, .offset = 0x08c8, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_MODEM_PROC_CTX] = { + .id = IPA_MEM_MODEM_PROC_CTX, .offset = 0x0ad0, .size = 0x0b20, .canary_count = 2, }, [IPA_MEM_AP_PROC_CTX] = { + .id = IPA_MEM_AP_PROC_CTX, .offset = 0x15f0, .size = 0x0200, .canary_count = 0, }, [IPA_MEM_NAT_TABLE] = { + .id = IPA_MEM_NAT_TABLE, .offset = 0x1800, .size = 0x0d00, .canary_count = 4, }, [IPA_MEM_STATS_QUOTA_MODEM] = { + .id = IPA_MEM_STATS_QUOTA_MODEM, .offset = 0x2510, .size = 0x0030, .canary_count = 4, }, [IPA_MEM_STATS_QUOTA_AP] = { + .id = IPA_MEM_STATS_QUOTA_AP, .offset = 0x2540, .size = 0x0048, .canary_count = 0, }, [IPA_MEM_STATS_TETHERING] = { + .id = IPA_MEM_STATS_TETHERING, .offset = 0x2588, .size = 0x0238, .canary_count = 0, }, [IPA_MEM_STATS_FILTER_ROUTE] = { + .id = IPA_MEM_STATS_FILTER_ROUTE, .offset = 0x27c0, .size = 0x0800, .canary_count = 0, }, [IPA_MEM_STATS_DROP] = { + .id = IPA_MEM_STATS_DROP, .offset = 0x2fc0, .size = 0x0020, .canary_count = 0, }, [IPA_MEM_MODEM] = { + .id = IPA_MEM_MODEM, .offset = 0x2fe8, .size = 0x0800, .canary_count = 2, }, [IPA_MEM_UC_EVENT_RING] = { + .id = IPA_MEM_UC_EVENT_RING, .offset = 0x3800, .size = 0x1000, .canary_count = 1, }, [IPA_MEM_PDN_CONFIG] = { + .id = IPA_MEM_PDN_CONFIG, .offset = 0x4800, .size = 0x0050, .canary_count = 0, diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index 5a4f865a45afa..ce692f948d59a 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -43,6 +43,7 @@ struct ipa_mem_data; /* IPA-resident memory region ids */ enum ipa_mem_id { + IPA_MEM_UNDEFINED = 0, /* undefined region */ IPA_MEM_UC_SHARED, /* 0 canaries */ IPA_MEM_UC_INFO, /* 0 canaries */ IPA_MEM_V4_FILTER_HASHED, /* 2 canaries */ @@ -76,11 +77,13 @@ enum ipa_mem_id { /** * struct ipa_mem - IPA local memory region description + * @id: memory region identifier * @offset: offset in IPA memory space to base of the region * @size: size in bytes base of the region * @canary_count: Number of 32-bit "canary" values that precede region */ struct ipa_mem { + enum ipa_mem_id id; u32 offset; u16 size; u16 canary_count; From patchwork Wed Jun 9 22:34:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456842 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721749jae; Wed, 9 Jun 2021 15:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqnQlz/cqeSaJN15MfY18wSjLdE4GG9+41bGt2cnetkZxE5R6UBt0Jm3qyTmdbStRXh/xP X-Received: by 2002:aa7:dbc9:: with SMTP id v9mr1571900edt.183.1623278235518; Wed, 09 Jun 2021 15:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278235; cv=none; d=google.com; s=arc-20160816; b=fos9QaJSwmvVKmLqS3JecQ9hPooCuX0ApFZFA5Wm/dsC6Fd9Qt2m8+FerairbIVUFq Bcioiiu87MLon7hloaSA2dePD4EGK8wR/Sr4dVRBt3dVDWsWvm92VobQmT7YJ/IvIj5m 4KQMCwird1c/QLiJTI8ZdM89Mks7BV/3iClM/YIwiIOysbHobaLNDVHs0PDNJcqQBVWZ nn61K/KZOrm+GwKQhFpc+XEw4Jt8O6FXGD4lpg1QX0TJBpRaeGHQeXlDQYTqxylMtRCO j6sYIJfqGwCnoiVYY+tTQf2XBEyVvAUwJTsCMDjJu2R6wHsXY7XpSwczEKMOXqtnmTGc keGw== 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=ZdGgujJpSC16NOxebiYpelihKJZiijAWNHIUEf3thoc=; b=rBfHAainZj2e1BLqH9j1RHUvqlG8RZK5NeP7l15WGm0JSCMMSWWoisZrW3DPcoCCxL ggxfOb4MrrPqtHsUndDeaPoTZQglbgsibbhc4pHfQwLzdGFqNy84a2G+M4vN5vtcRFqf krLak5RDTx8v1h3L2dbavjqDREcP2/KUgcVU08wutjDDBrsdXfVVMfhxAooClAK/i2n4 smAsWTkQZND6uIgGqSb9entgLUc9hr4a+xX3Xm5FCV7Pz7LL0bkJBMGrdrMCld3mdaZt BKoV2k47545CYphJjh5XqtV4TefATrjl0SDvrC0netju0kkP5d/lotWQbWZqDRd4cQAz 6S4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PyZ4Dwy/"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si912205eje.551.2021.06.09.15.37.15; Wed, 09 Jun 2021 15:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PyZ4Dwy/"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230395AbhFIWiG (ORCPT + 8 others); Wed, 9 Jun 2021 18:38:06 -0400 Received: from mail-il1-f181.google.com ([209.85.166.181]:33613 "EHLO mail-il1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbhFIWiE (ORCPT ); Wed, 9 Jun 2021 18:38:04 -0400 Received: by mail-il1-f181.google.com with SMTP id z1so28254015ils.0 for ; Wed, 09 Jun 2021 15:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZdGgujJpSC16NOxebiYpelihKJZiijAWNHIUEf3thoc=; b=PyZ4Dwy/Ji4+qoTMeTUJ0rNteKjCfXFM3ownSvTQJmutDCQtnbAi84HuQR6k+Qg4lP 4MxYuwVSJTuIA3ly1lp08vSnW7/LTDh9ZIPOUZthrRmuyXeHTnsV/m6rAG90Lk7IvOoW FOYb2zecLrKjpdF9VYTXZArDCHX/7+/uAw3GX+8tX1Cw82FmzN5NNy+TleA969OSZ3Mk 7higtOO33cqmuE7JWLeA6kSKf+AlCWXMF2oNBTGkw/dRcB8uEf/4NjNIjMt51ZwuVy82 ViZ/S8TptmiuUkhJb4AbVI4Nk3sXNaz9b3MI8HvVkv1W4SJ3OP8+rFjyhaNW9QMfRIVL qHYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZdGgujJpSC16NOxebiYpelihKJZiijAWNHIUEf3thoc=; b=m4NX/DfFO72JF+/CepoIpFU422C3AozsW13CqBF74bhOwDgQBp6ptCPThm9vbkqNhs HrRHwKKYkHWZIaEKyWDBAPfWKOHsV+ZdFvkYSCC5u42BnKdjKVW9UyuWbUHrf7252e05 LAPKNrwJTwvleuzmtlTiWpq1UGCzFQAQNGEomXlTBQUomSZ1v/0GYmU1KC5EAal28sm3 RC0K53wcYqQqi32ch9sQR/QfzWnKVrXOMGsz28SNYVU2zZDWOiotVGyVOjSwpxSvdKLG tEb2Tpo9nRFzDoKyenW6KwQl7dzWJlA7/WHKVZ0cJu3R3kgfrQtw6qpfvqg2hvMUALTy 44zQ== X-Gm-Message-State: AOAM531VzmLboDTnN2S6qN3ZaR2jpTIN3rr/AklCSeVvtCeZ1CfiZ8tT So+E3nKFrpinZ+JG4qJHBxFCsg== X-Received: by 2002:a05:6e02:1447:: with SMTP id p7mr1373513ilo.131.1623278109340; Wed, 09 Jun 2021 15:35:09 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:09 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 03/11] net: ipa: validate memory regions unconditionally Date: Wed, 9 Jun 2021 17:34:55 -0500 Message-Id: <20210609223503.2649114-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Do memory region descriptor validation unconditionally, rather than having it depend on IPA_VALIDATION being defined. Pass the address of a memory region descriptor rather than a memory ID to ipa_mem_valid(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index e3c43cf6e4412..effaa745a4061 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -99,12 +99,10 @@ int ipa_mem_setup(struct ipa *ipa) return 0; } -#ifdef IPA_VALIDATE - -static bool ipa_mem_valid(struct ipa *ipa, enum ipa_mem_id mem_id) +static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem *mem) { - const struct ipa_mem *mem = &ipa->mem[mem_id]; struct device *dev = &ipa->pdev->dev; + enum ipa_mem_id mem_id = mem->id; u16 size_multiple; /* Other than modem memory, sizes must be a multiple of 8 */ @@ -128,15 +126,6 @@ static bool ipa_mem_valid(struct ipa *ipa, enum ipa_mem_id mem_id) return false; } -#else /* !IPA_VALIDATE */ - -static bool ipa_mem_valid(struct ipa *ipa, enum ipa_mem_id mem_id) -{ - return true; -} - -#endif /*! IPA_VALIDATE */ - /** * ipa_mem_config() - Configure IPA shared memory * @ipa: IPA pointer @@ -188,7 +177,7 @@ int ipa_mem_config(struct ipa *ipa) __le32 *canary; /* Validate all regions (even undefined ones) */ - if (!ipa_mem_valid(ipa, mem_id)) + if (!ipa_mem_valid(ipa, mem)) goto err_dma_free; /* Skip over undefined regions */ From patchwork Wed Jun 9 22:34:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456839 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721066jae; Wed, 9 Jun 2021 15:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBG7tAINKO89yHq1X0vHqjPf4eUhUXUyfyes9o5IiS5/fae6O8EZX03WB3tWXpWKORP5UN X-Received: by 2002:a05:6402:2217:: with SMTP id cq23mr1563203edb.292.1623278159560; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278159; cv=none; d=google.com; s=arc-20160816; b=URCDycjmZ1AKOjKFhyWjja3SY6QtPEAfEjwIhDkcsjFLFq3m8Ybakhzi+VfyfO+qKm RxzeM/ID+MLcMWACxKRjRNMYl9p+zGvXI941MhCbszLXbdQryzLbDyfyW+7pXjbh1qj+ uVHMs8vVrBIqrDfcXcssPY4fsNQnFca109M3FgoGUxjVGj5mZVUl1UucCbTJ7GR0TKRj apjf3LqndI5Ibxuq9yJyYkhz7FpcUQnBQrVKcUroN0eTQpRhTOWolluxMWnQ31uWjzfk dHWQUm7u0aqO4FbhdmqU/SPQmMmqle4C74dU8gxRQXj4OX5h5nj31by+F6WN99kHsv5J 2cSg== 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=Efo2gR8r+knWoJXWPdLdHsqFiu2EgVFjf/ge0HSla8U=; b=l/4FI+K40b/2g4d11wzhUXPSQnoAHzWEJg+vkKB5uJX2GxqM0iafBK8z22Pt3krj6d MYTNdPUbdY3UX7rGZ1IF5bLwg0n7iVX+hGmhXu0fCHK3TnTKG16HbyZEuh19YRCW3f1+ FGllGsi6uZNGD/pQ0F1Jz3dWH6DpChufkb1JIGvTr0WVX//wxb8KXIumdi2y8nZBzCLj LW7QJstGOongDnKr4fHKhYwCyBpZRNxGM58evHQNE6eqCR2xkO1nUeHYrNjqwnbJ5/Sh 6Y7EN2NX4dKrJTCgHfxja9yrB25PMItVMAXbyqAxrrKKY3jG7vzH1vHSXiMSXCLICbGQ uTwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KVKhqx4M; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.35.59; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KVKhqx4M; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230250AbhFIWhT (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbhFIWhQ (ORCPT ); Wed, 9 Jun 2021 18:37:16 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5ADAC0617A8 for ; Wed, 9 Jun 2021 15:35:10 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id w14so18549365ilv.1 for ; Wed, 09 Jun 2021 15:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Efo2gR8r+knWoJXWPdLdHsqFiu2EgVFjf/ge0HSla8U=; b=KVKhqx4Mnv3fjswbSoNCoQbwzPRlJ4ZGiyZNmLd7mAQ5fJXSxiIN6GtCXdDG6Wp+O6 sSuLmIVGMue/FN+BnQhmgJsQ4y5Ff6+OPCXHtzVItZGgoPUkaMF/MUjedaFy7Bb6Ssrj SqvYas93GrdCzrJgver2lOfGenlBsJ6/9+iOOQMZwiLpA5SbPhRlVqS0fCI2C1gPGZ4z ssPcjutvtjDUcR0mnjuThp3dN/HPvJUl3+e3fnS4vleg7FuzDKt8dNLL8k02CYJygS+c PHbOCrN26tfxXImd7uRdNK1znvjC+uP/oKZjY3w0wyyaQSG/zbeFtSZ0A/2iRqtcTbMP bojw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Efo2gR8r+knWoJXWPdLdHsqFiu2EgVFjf/ge0HSla8U=; b=se6G1MxeiMSyasZc1kKdR4mvqzjFu31TH2KqSWqqWZT90NbVZnBBndYKKzmX2ymPQR KKgpCU5q3DlH8gKiRgKj0qvzIAKGIkfCtgpWAMXBKx6ro6LP5gPi3xRR2ETro4LcrMuv v6wtEguVviXtAa0sMx+4ln+Lwi4A6okmkCf8zSqz8/IjSnbxalvH9rU5VUug16YiJ+81 5qHzTGVhhfju0dHddTvnrx4r1nOT8zlF03b1UEhg8xZPqFp2/uXleSZ3rBqvYWsIJIDk o8CE5jEmr7jWQ4gEwwg/rCeJDfI+BBrCrjIi+7h5kepVreUZQLP5iMddVLxspLCfujp8 YKig== X-Gm-Message-State: AOAM532VDrq1pyEdh0ODO9wLurb6C2/psthunhMaNC9vZmMYllVd+wXe Cd8lL5fCIkYSuUrjS3tu7uc1UA== X-Received: by 2002:a92:d245:: with SMTP id v5mr1436873ilg.245.1623278110263; Wed, 09 Jun 2021 15:35:10 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:09 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 04/11] net: ipa: separate memory validation from initialization Date: Wed, 9 Jun 2021 17:34:56 -0500 Message-Id: <20210609223503.2649114-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, memory regions are validated in the loop that initializes them. Instead, validate them separately. Rename ipa_mem_valid() to be ipa_mem_valid_one(). Define a *new* function named ipa_mem_valid() that performs validation of the array of memory regions provided. This function calls ipa_mem_valid_one() for each region in turn. Skip validation for any "empty" region descriptors, which have zero size and are not preceded by any canary values. Issue a warning for such descriptors if the offset is non-zero. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index effaa745a4061..62e1b8280d982 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -99,7 +99,7 @@ int ipa_mem_setup(struct ipa *ipa) return 0; } -static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem *mem) +static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) { struct device *dev = &ipa->pdev->dev; enum ipa_mem_id mem_id = mem->id; @@ -126,6 +126,31 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem *mem) return false; } +/* Verify each defined memory region is valid. */ +static bool ipa_mem_valid(struct ipa *ipa) +{ + struct device *dev = &ipa->pdev->dev; + enum ipa_mem_id mem_id; + + for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { + const struct ipa_mem *mem = &ipa->mem[mem_id]; + + /* Defined regions have non-zero size and/or canary count */ + if (mem->size || mem->canary_count) { + if (ipa_mem_valid_one(ipa, mem)) + continue; + return false; + } + + /* It's harmless, but warn if an offset is provided */ + if (mem->offset) + dev_warn(dev, "empty region %u has non-zero offset\n", + mem_id); + } + + return true; +} + /** * ipa_mem_config() - Configure IPA shared memory * @ipa: IPA pointer @@ -167,19 +192,18 @@ int ipa_mem_config(struct ipa *ipa) ipa->zero_virt = virt; ipa->zero_size = IPA_MEM_MAX; - /* Verify each defined memory region is valid, and if indicated - * for the region, write "canary" values in the space prior to - * the region's base address. + /* Make sure all defined memory regions are valid */ + if (!ipa_mem_valid(ipa)) + goto err_dma_free; + + /* For each region, write "canary" values in the space prior to + * the region's base address if indicated. */ for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { const struct ipa_mem *mem = &ipa->mem[mem_id]; u16 canary_count; __le32 *canary; - /* Validate all regions (even undefined ones) */ - if (!ipa_mem_valid(ipa, mem)) - goto err_dma_free; - /* Skip over undefined regions */ if (!mem->offset && !mem->size) continue; From patchwork Wed Jun 9 22:34:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456843 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721754jae; Wed, 9 Jun 2021 15:37:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHkdqp2krg4ctFd4ZT3RADJZoKjhXMQcQTYTGoTRjxd9DcB6FXwbmuX6a8FGs6qc7JplrK X-Received: by 2002:a05:6402:1d38:: with SMTP id dh24mr1658102edb.18.1623278235952; Wed, 09 Jun 2021 15:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278235; cv=none; d=google.com; s=arc-20160816; b=EB0Vd3XsB5Ab6ohD/yIgkdXmm2qweyGTB2SWLGnedJV8CSg0om3oGKAcrZOoSbmbS7 6nSZB6rZxlAf4QxZ3mZAUCmuNOh2Cb60BaiboK5ua2TjgLFGkcTYmiRoHw49Xcr/BIFi xPwZJnsw+XknIlYQSTzxW8tWgF0fbfFOL+7L0RVBh8ue0Hnvx7lJ8NsTayDomAdg2+Hu EfC9uIFfTCvFzZ+dd8Zsm2qHGWsbLbeHbHtgn4c0BZee90318EWK9NJ2aZPKX9LaQD2d /TjKVwc9o92gPqCL15eRNGvsB8pgsHp+HQgbJ0ayRL6WpcrqBNZZU/oWtn13Lp4upUCP TYXQ== 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=7yhJsF4sf6g0J5+Wkc48fcn32kH/upZlX3LD7ehd/r4=; b=c83PDcThMuQxgdTU42WEO1XbcdKkokbKcLVbXjdSdSJk10O08OjmNLxT8ygFwRj0+n tCeNjj7n5Ia5J94RDZ/u0jZmUPcrfus2Chw81uHHF66Ct3QxlxO+sJ7QgsDrxMMlqkXf bOsfflbtGYCYgjrCisUG8XWkmgSF7t21YOJZ40eoKDmu3SKDsy3o5v1X+z6VsY1PHEvE 7ZckWLRI5829vrJzg59n4t94TuOgsmzvIsWcOig2h96VzdJr8sBLLj7YL6suqSXqFkfN pZQprZxD56GNim98PEgjqIvfk6vfslYZbAklQQy/C1r7P+sX43VXCIIBjNCycuG5zpTl JKFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iFlIBZ5M; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si912205eje.551.2021.06.09.15.37.15; Wed, 09 Jun 2021 15:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iFlIBZ5M; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230406AbhFIWiL (ORCPT + 8 others); Wed, 9 Jun 2021 18:38:11 -0400 Received: from mail-il1-f171.google.com ([209.85.166.171]:38612 "EHLO mail-il1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhFIWiG (ORCPT ); Wed, 9 Jun 2021 18:38:06 -0400 Received: by mail-il1-f171.google.com with SMTP id d1so25078646ils.5 for ; Wed, 09 Jun 2021 15:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7yhJsF4sf6g0J5+Wkc48fcn32kH/upZlX3LD7ehd/r4=; b=iFlIBZ5Mfm422uNt/F8WgwSdZtKGzWTZh3G+ld6B0meYU3+rtqEvJwkYq5NhfktNke tkk/L11PPenB5WKqj3hbau+He4BwCZLpvF+B260RFmumja1p5XwcAjuaHLJVIyk+0hrv OOvc3tgadnFuw53wVD8up3iVlfVpZKHRESVMUU+d0ta4zDkuD0tm/pnsTJT0X2E14atw NPWGHoNq3NBGPaCeijG0gd4hJZX2TN302h+RNeQ5bJf75ss5NEMvaAHNoDsu3/M9GE9Y ysRYR/+1yGXPZ3kQMb5TYlzXh1JrlafbyhCFIrpdiP5jr7O7L+meOkhxmBiEamgOtTZL fKPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7yhJsF4sf6g0J5+Wkc48fcn32kH/upZlX3LD7ehd/r4=; b=Jy9Xe+sjR+KD2cGuiVy337roAM2RL0kRCT/r41VSRd3yDfomA2YBbTY09/6DDPy7CX yIdCFy5HdbZw7ggbMLAZB8BV+o9qkwm8UVJPzBYh7g24NBCOaApClqOXbaXPKcvLEt2h HlqIPXtdmc1l1fUWyyjQKHbArbzhJLeWzRChNoroc6cUT07PNS9Zv0Xbyl+VtcuL4USS QPV8BspLkl9axGA6dLaNcHL18JZZgZZHZ2eFZQ/pAHKNjxB42B8ClSZlJI8BJRmG4xDR RH4FRvJsJpRqM5aLJsyeow4GP/2YzuKH6EuBfNNOlWpZuPdksMn6pds/vg71igKqseD9 7nAw== X-Gm-Message-State: AOAM531FCzfPBYS7SyX9xR85DGvq1DosHqaYgU82PgMu6M1wkWhRY0s5 quvIM4EdUdPnP7ueqdfq7t5rpw== X-Received: by 2002:a05:6e02:108f:: with SMTP id r15mr1390270ilj.86.1623278111240; Wed, 09 Jun 2021 15:35:11 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:10 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 05/11] net: ipa: separate region range check from other validation Date: Wed, 9 Jun 2021 17:34:57 -0500 Message-Id: <20210609223503.2649114-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The only thing done by ipa_mem_valid_one() that requires hardware access is the check for whether all regions fit within the size of IPA local memory specified by an IPA register. Introduce ipa_mem_size_valid() to implement this verification and stop doing so in ipa_mem_valid_one(). Call the new function from ipa_mem_config() (which is also the caller of ipa_mem_valid()). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 62e1b8280d982..f245e1a60a44b 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -115,9 +115,6 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) else if (mem->offset < mem->canary_count * sizeof(__le32)) dev_err(dev, "region %u offset too small for %hu canaries\n", mem_id, mem->canary_count); - else if (mem->offset + mem->size > ipa->mem_size) - dev_err(dev, "region %u ends beyond memory limit (0x%08x)\n", - mem_id, ipa->mem_size); else if (mem_id == IPA_MEM_END_MARKER && mem->size) dev_err(dev, "non-zero end marker region size\n"); else @@ -151,6 +148,28 @@ static bool ipa_mem_valid(struct ipa *ipa) return true; } +/* Do all memory regions fit within the IPA local memory? */ +static bool ipa_mem_size_valid(struct ipa *ipa) +{ + struct device *dev = &ipa->pdev->dev; + u32 limit = ipa->mem_size; + enum ipa_mem_id mem_id; + + for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { + const struct ipa_mem *mem = &ipa->mem[mem_id]; + + if (mem->offset + mem->size <= limit) + continue; + + dev_err(dev, "region %u ends beyond memory limit (0x%08x)\n", + mem_id, limit); + + return false; + } + + return true; +} + /** * ipa_mem_config() - Configure IPA shared memory * @ipa: IPA pointer @@ -184,6 +203,10 @@ int ipa_mem_config(struct ipa *ipa) mem_size); } + /* We know our memory size; make sure regions are all in range */ + if (!ipa_mem_size_valid(ipa)) + return -EINVAL; + /* Prealloc DMA memory for zeroing regions */ virt = dma_alloc_coherent(dev, IPA_MEM_MAX, &addr, GFP_KERNEL); if (!virt) From patchwork Wed Jun 9 22:34:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456846 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721797jae; Wed, 9 Jun 2021 15:37:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEj3rs7QyXcsTh6Qi8SXOwt9/zYi9PxeyFpUljRO4TzhEEK2sPWQHz1e1Bm0v0hK7sPfxz X-Received: by 2002:aa7:db93:: with SMTP id u19mr1570547edt.227.1623278239533; Wed, 09 Jun 2021 15:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278239; cv=none; d=google.com; s=arc-20160816; b=BKqdKIKohzfxAvjP8TmBp1wF6Mu9jBeNobyA2DLXRhVGeDIBEj9aypkSadznWRKAQi 7koOsRf5+1r+nnze6ann0SmmU8eTZImfzwAZwdLXecn0Q5gXPYNKdXk0aig1V5TkcprV 8torpT0SmUlcNJuAPsphval+V9Jq+sf2G4KTof5wkrl0KptZeSQPoF9h7I3oUglawveG nP9azar0nS705QGxNWMhxvqD6NSzaJjz29vHRkVQuaFXY76PsXLXFunZESFGQg9bKorE nEsIefnA+kZdevrushEuDZo67GwarEXHtgfjzIZoEjvVLHji7woXIfh1ZxRBQmxH4yor oYQA== 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=LZrDcpMMlqQu3fRlEZdQrN5iR4OJZ5NusdCMN67AVgE=; b=vLPhak52bHulkSpsMCjPv7jflduYO5w/IfBsEAniI4mDU8xGq2kzSeYC35GGsCx8ZU h5qNlCpX78rnR6YL2BJRjBn3BFeLIJ8S7TeKZSJhAiXKbPvaq65kfMCcMfRZUxGmncqF rrq3imswNjB5tCmuNbMKygzWVAiiQhc4YNUQ/FTNz4MeObjPMcTcCE8NlOqpb05SGpvG owzxpNeVPTXhen/Rh7/32kg8KTNlAvGWgOhcuxh8oOzvwwiioK/ke2GjzfGnvIzTto95 7JxL5KQ4MbPDX3m2gokJ9wpiTWzlcYRmDg4GUbPZ5g6YJym4FR9uC5HvUkttwC/fpAsa r2vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VbBBEnLk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si912205eje.551.2021.06.09.15.37.19; Wed, 09 Jun 2021 15:37:19 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VbBBEnLk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230477AbhFIWi1 (ORCPT + 8 others); Wed, 9 Jun 2021 18:38:27 -0400 Received: from mail-il1-f180.google.com ([209.85.166.180]:38622 "EHLO mail-il1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbhFIWiW (ORCPT ); Wed, 9 Jun 2021 18:38:22 -0400 Received: by mail-il1-f180.google.com with SMTP id d1so25078676ils.5 for ; Wed, 09 Jun 2021 15:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LZrDcpMMlqQu3fRlEZdQrN5iR4OJZ5NusdCMN67AVgE=; b=VbBBEnLk5xTZzb/Cb2h0QG052xVazdTaNFC9Ne4MPDWmHwZVI1eml2LfDSVsYrPYzQ 0Lwmhh8zfTil+/PVpu9d1BOEVunxHLuNarzy7Iu61t+0fKku3GUIpX4Rl00/iqyxm2my yJ+lwHU61V8PmRCLijwoGkjbWG4X3OrQktTMo41JXZTvoVQDGAFpkQJTIa/x+lbWCt7k gLk/3Qyu2F4/jh/6hHojgXRgHXt8/AwPXwGWKhh5hWDsfVUrec6yNXI0vRyPK4n0iErD bCPNw+VgqJ1+D75PXzcjr60A4vpI3Gk0IPYrXTAyufM/i+SjmDtXKghUokm461nAXGFO 8YPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LZrDcpMMlqQu3fRlEZdQrN5iR4OJZ5NusdCMN67AVgE=; b=Oj1/AeQgg0qXES8soNElCqULOolhg+6IYzuWQpGjSIy8SQfEO4Z0WgQWINpan5bAIM sNylUJx5BL7TSw1V0cLpqVmIvyBIWd5RIDm8hgEmXgeFZuerujSmGRZ3LNMexa+BDvwM FnuBIMbf18wGaSIPYGTPZioenQuH5TfIniQAtnCjv583PZqD1B+kZdncfBo8yE4Wixqu 7S569z1bG6n0w/LzxFBxH13FySn37fhubeQu1cE6ZkOh/SKXnRU3kS1F/GBqLL3pKw+s N2KTD34GQKhD3640NSvE230jXnhE1Dl/tLaH3DhrzJ78emUFve9Oc6LD3Fe/PThjxYFh 25kw== X-Gm-Message-State: AOAM532XtxEZJBFZI+tMzv4cfZOFf/UxHTSDKnXOLzBy2iacML+38iX7 whgRigmfSOqZSfbXLiMslCzasw== X-Received: by 2002:a92:c68c:: with SMTP id o12mr1473796ilg.6.1623278112288; Wed, 09 Jun 2021 15:35:12 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:11 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 06/11] net: ipa: validate memory regions at init time Date: Wed, 9 Jun 2021 17:34:58 -0500 Message-Id: <20210609223503.2649114-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the memory region validation check so it happens earlier when initializing the driver, at init time rather than config time (i.e., before access to hardware is required). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index f245e1a60a44b..b2d149e7c5f0e 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -215,10 +215,6 @@ int ipa_mem_config(struct ipa *ipa) ipa->zero_virt = virt; ipa->zero_size = IPA_MEM_MAX; - /* Make sure all defined memory regions are valid */ - if (!ipa_mem_valid(ipa)) - goto err_dma_free; - /* For each region, write "canary" values in the space prior to * the region's base address if indicated. */ @@ -528,6 +524,10 @@ 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; + /* Make sure all defined memory regions are valid */ + if (!ipa_mem_valid(ipa)) + goto err_unmap; + ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size); if (ret) goto err_unmap; From patchwork Wed Jun 9 22:34:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456845 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721790jae; Wed, 9 Jun 2021 15:37:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdAGbS762xjmAh/3nI9frZtRckj8obMEsdiT56CumscEAY2AAoOUohUthbcuO+siebUJQM X-Received: by 2002:aa7:d7cf:: with SMTP id e15mr1649654eds.114.1623278239099; Wed, 09 Jun 2021 15:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278239; cv=none; d=google.com; s=arc-20160816; b=IVYl/MevSvM4Y4aq3IEmdk0SjgW1UFVY03MccJkxc7MypX2O0cdT56zGi6J9LdTpHe 0qq/KcsG0fjLQWAox/8m4mwlt07rZQk3tD1ZdKF+AvR0ztJsOi6ZZ0feqUXdEjRUFEUo TNMWTBN3kR8DTFmVA14J6rP3KRHmsH7mUY99p4O6V/CkShdCU40z3rXrXBeFbtiq3RyL X+TCZAZzSHXv/QMbmYxns1cQrbvAOuSSZM6CbxwCANjuJ5r7pPK4BkvSHZO8pBZy0/8b vUZK23DgSGDbCWUbAD2lrwWPA3tSQD8oSuR8RbPaZx/UUXt4NtkilvxjfW/kLa8WCQA3 FZqg== 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=TjKUrGqs9xe9MyXfICOgQmSpFyOBKRzcUd08/8kZ4/0=; b=01PJctSxjxzfz04yLCbP6fuVy3hAjFYnB7vTMBPgDu+cOHzipufx2N7xneKMQspAyP MFl3HbRqZ9D0isTA0+xL9M3RHCIa/96PDrMNFHq8THPNIDpc8VrifXFCqV7TNcDaRakv 6fieOwfBucf8BU2Xim/KHc8N4uMZjqWm5ZdXWwEh9XOTDiQEfGNLyzV2HKT+sWMF/Qak 59zcNMuVUIOOi4/yQR8Dcs3V0Z9YQERV5NYrW5s6lEedHmMYlDPHdzVMTLRCADg0b6Hb fu5e1nq6dymQrXXrzEQU52waOSvMjmZZ4Im9LRGfxnTQDwFn+OpLK9K53inp6VR1tpAZ cunA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BnUXMMEm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si912205eje.551.2021.06.09.15.37.18; Wed, 09 Jun 2021 15:37:19 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BnUXMMEm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230472AbhFIWiU (ORCPT + 8 others); Wed, 9 Jun 2021 18:38:20 -0400 Received: from mail-il1-f170.google.com ([209.85.166.170]:41720 "EHLO mail-il1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbhFIWiU (ORCPT ); Wed, 9 Jun 2021 18:38:20 -0400 Received: by mail-il1-f170.google.com with SMTP id t6so21035925iln.8 for ; Wed, 09 Jun 2021 15:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TjKUrGqs9xe9MyXfICOgQmSpFyOBKRzcUd08/8kZ4/0=; b=BnUXMMEmypsVhA5PMcOInwdRPeZB/JHXrKc/CVIMV370YrKXsS0uNs70Tsn+jfoLHx OCtck0zI+9z4dFaQRvcAoQwVTfu3+Ci1CrQhjrz9L97ARkaUukE8WoEjhVGaZqY82ut3 2lQ5IKXGzE0LV/q/zkJ59rUclKmEz7FvQ503u4JWOFdP0SP4QKVYMC6+zrOVo6EucIfN 0MwgEpHfQFUITWJx12+2GBSccX6HU9vQWhDB4vP81sY5ICsVZrJHIqXr7n6joHFLcp9i yFlktEZ0xOUtw5xbNn/IaAentdi18kJtMIIBOxMTjwqRJqQgQZug2KNRMez/SUVlGpb1 NqkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TjKUrGqs9xe9MyXfICOgQmSpFyOBKRzcUd08/8kZ4/0=; b=mVZZbEDPdutPyXZkkzuISulpd4sHaLe3ky/Y/p1RvV3j+aWUYeUTy2nkgQx4Zf7B5u GEExG6VkKRukxl37YnfARrxOBdgZBWUcS60iu+8jcY5jG8YyB/Ffpu7W0URZbIXRY8mF MC8kkBBwAkJJJS3/pm7XyjKBCuz+q7tWYeAY4wtlKHZtBQTFJ2Q3joLaxIow9n7Qx9Ed hN2fartN+Tpc3EJsGLlaUtw2v9BwIcaz+KCkpI05OWbcboP22MD4rqpzh5j3y3xALdGY UtvTlByMN1j4poYU3Jin30HsRcxChIipZu0vSDvGz19bgSXE+BuDwK0L2nKGK/csv/6q NRYA== X-Gm-Message-State: AOAM5337gF+ZpYVe31gIVOkdC5WsoA4FQcDzR7pTkEOnHi72eo1IYUhr 64yTAnTH5rnH1vbqtltQ5qOEWA== X-Received: by 2002:a92:d902:: with SMTP id s2mr1404875iln.278.1623278113402; Wed, 09 Jun 2021 15:35:13 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:13 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 07/11] net: ipa: pass memory configuration data to ipa_mem_valid() Date: Wed, 9 Jun 2021 17:34:59 -0500 Message-Id: <20210609223503.2649114-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass the memory configuration data array to ipa_mem_valid() for validation, and use that rather than assuming it's already been recorded in the IPA structure. Move the memory data array size check into ipa_mem_valid(). Call ipa_mem_valid() early in ipa_mem_init(), and only proceed with assigning the memory array pointer and size if it is found to be valid. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index b2d149e7c5f0e..cb70f063320c5 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -124,13 +124,19 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) } /* Verify each defined memory region is valid. */ -static bool ipa_mem_valid(struct ipa *ipa) +static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) { struct device *dev = &ipa->pdev->dev; enum ipa_mem_id mem_id; - for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { - const struct ipa_mem *mem = &ipa->mem[mem_id]; + if (mem_data->local_count > IPA_MEM_COUNT) { + dev_err(dev, "too many memory regions (%u > %u)\n", + mem_data->local_count, IPA_MEM_COUNT); + return false; + } + + for (mem_id = 0; mem_id < mem_data->local_count; mem_id++) { + const struct ipa_mem *mem = &mem_data->local[mem_id]; /* Defined regions have non-zero size and/or canary count */ if (mem->size || mem->canary_count) { @@ -491,11 +497,12 @@ int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) struct resource *res; int ret; - if (mem_data->local_count > IPA_MEM_COUNT) { - dev_err(dev, "to many memory regions (%u > %u)\n", - mem_data->local_count, IPA_MEM_COUNT); + /* Make sure the set of defined memory regions is valid */ + if (!ipa_mem_valid(ipa, mem_data)) return -EINVAL; - } + + ipa->mem_count = mem_data->local_count; + ipa->mem = mem_data->local; ret = dma_set_mask_and_coherent(&ipa->pdev->dev, DMA_BIT_MASK(64)); if (ret) { @@ -520,14 +527,6 @@ int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) ipa->mem_addr = res->start; ipa->mem_size = resource_size(res); - /* The ipa->mem[] array is indexed by enum ipa_mem_id values */ - ipa->mem_count = mem_data->local_count; - ipa->mem = mem_data->local; - - /* Make sure all defined memory regions are valid */ - if (!ipa_mem_valid(ipa)) - goto err_unmap; - ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size); if (ret) goto err_unmap; From patchwork Wed Jun 9 22:35:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456840 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721070jae; Wed, 9 Jun 2021 15:36:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcNPW3qTFH+0wMwvzv5wbgLznCsx9qsfRBI7p0270MvP9rA9MbqoifKkYSmBdBX8QZkXT8 X-Received: by 2002:a17:906:278f:: with SMTP id j15mr1851716ejc.388.1623278159938; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278159; cv=none; d=google.com; s=arc-20160816; b=H5wfAbd1+tvUgNRajiJX4ZB71ngvrzmg6g8beSvEnbUBBgX4G8V+OQF3Ej7JpcaSZS sPCnT/NtsBPElr2/SEqo/JpuWQiPkZlWKQ61b3/oRf5OjfyWvbyAPTKp0s3MojMmBWc4 dVeIKckI/9Uu78MZtuwxGvSrMDWqlBq9be7AU+m0hoRzqJBGhTV8PWT233/Bvmiogw0b PPLKOMDGQfq2aerW78pzqzXMerNDF31Inw+si462tRFIdVhtildxF5SEJ/iO5cDy8jYJ yFdoJq2/7snGMsjeCxXlHzr3HAufa8b5rHRzUE0zsSPBuYTjJBqYL3tKv1pCAUgVtBq+ p1Fw== 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=lcMIaajbznc6hYyMRbhNBSraS3zhVHZ7jf9G3+NJR/4=; b=nekEl75d7BDvlpdG4+yHK79Cpnx+HUebbIE3cDHafmbe24U5t06/8UiLz73LOixKa+ NQEk5C8UKFzlOMjkCNc2j1+UPGdfM6R1vsRi3d/995HpAAOPcijuwrpCx+2hzp3NUFxL KOjAH+348Zo+OyM+H00FaBXc7lEg/wmkrHR7SP4tEJByPSanLdi9orChPjGO03kxBTzH scL0RaWe1b3xWRz3UPvfSRny7NLqKQob9ZSoQ7Oh9Ar+2wNRL4jQb9Gtv9QmaDqsQI1u hIQv28e9K3tt6wapnHOXFMuRQqtlmm6Eyjfp6AHTdGa2qvEuivn03k1kYNAeoOB2ceS6 uQsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DpAj19oK; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.35.59; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DpAj19oK; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230322AbhFIWhW (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbhFIWhQ (ORCPT ); Wed, 9 Jun 2021 18:37:16 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24FDC0617AF for ; Wed, 9 Jun 2021 15:35:14 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id i17so28135876ilj.11 for ; Wed, 09 Jun 2021 15:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lcMIaajbznc6hYyMRbhNBSraS3zhVHZ7jf9G3+NJR/4=; b=DpAj19oKFE0na3zpXmKvdXRUqlQCWWA8/ecy5iFrAnEcoNt1HCnmIBTu0/rjeoWS+F NYGEM705Vm0fXIRja9kh2d5MA8qZ3MGOVY+r+BVX4w1QsX2HYK9NmI+NXoJ5ZSuCGy4o gadjjfekDXXY4CwzGg45sL4b+/j6YVp1VYBipBxMb2hpmMOjtUHnIw1a3JmTePDsd4r7 9bdat8SlR43Dx5Um/wcGG5kzgUad0JW2F/vTJrHy9R3agfdVupqFCp4z9g0cJX2gZ5PQ D01uMmdAFWf88LoqP9esn81AUHOpjLR4Pl675uSJ2acHkTIoPaTqMuwTS5GFl7P6Vl+D 0xCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lcMIaajbznc6hYyMRbhNBSraS3zhVHZ7jf9G3+NJR/4=; b=aHVU7xi9TfrfHsXeM+xXVPFXXCTkFdbY6HisZfbUSTAgVGHR7bq2OduvKWoh/IKWuP lu3rLilQeoszN6UwFxYFtIWRbTKF/2ZSEnG0E8pxfwK83Lp3nthcUXE5ow+miXLROihu OZnJFLPzJOBiUsQ3oP0Xnqa/qSwe1lOP09riM6lEIeblWp/I4qEwAO7QcNu7KgkfwZKL bAXkvVcI+ZxNbecYWwm0gD+84gVgN8T2IM/+VaIeiulicb5p6Fd2Oed77nQJNpCFi2u0 570V3X0TvOaytoZ8iY0kiJjhuCOug/QQDMLBxBjcZQgXFYNt9ep6Nyz0kTF+nYyyFwjK Qusw== X-Gm-Message-State: AOAM532YPtWu4q37aAnuzCSnRK/z2CiBsAyTxdHqLyfGs6wWgyTjruC8 fExpsLIyPUlpe7lzlBA3mYOpJw== X-Received: by 2002:a05:6e02:12ef:: with SMTP id l15mr1457316iln.153.1623278114351; Wed, 09 Jun 2021 15:35:14 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:14 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 08/11] net: ipa: introduce ipa_mem_id_optional() Date: Wed, 9 Jun 2021 17:35:00 -0500 Message-Id: <20210609223503.2649114-9-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce a new function that indicates whether a given memory region is required for a given version of IPA hardware. Use it to verify that all required regions are present during initialization. Reorder the definitions of the memory region IDs to be based on the version in which they're first defined. Use "+" rather than "and above" where defining the IPA versions in which memory IDs are used, and indicate which regions are optional (many are not). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 42 +++++++++++++++++++++++++++++++++++++++ drivers/net/ipa/ipa_mem.h | 21 ++++++++++---------- 2 files changed, 53 insertions(+), 10 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index cb70f063320c5..29c626c46abfd 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -99,6 +99,36 @@ int ipa_mem_setup(struct ipa *ipa) return 0; } +/* Must the given memory region be present in the configuration? */ +static bool ipa_mem_id_required(struct ipa *ipa, enum ipa_mem_id mem_id) +{ + switch (mem_id) { + case IPA_MEM_UC_SHARED: + case IPA_MEM_UC_INFO: + case IPA_MEM_V4_FILTER_HASHED: + case IPA_MEM_V4_FILTER: + case IPA_MEM_V6_FILTER_HASHED: + case IPA_MEM_V6_FILTER: + case IPA_MEM_V4_ROUTE_HASHED: + case IPA_MEM_V4_ROUTE: + case IPA_MEM_V6_ROUTE_HASHED: + case IPA_MEM_V6_ROUTE: + case IPA_MEM_MODEM_HEADER: + case IPA_MEM_MODEM_PROC_CTX: + case IPA_MEM_AP_PROC_CTX: + case IPA_MEM_MODEM: + return true; + + case IPA_MEM_PDN_CONFIG: + case IPA_MEM_STATS_QUOTA_MODEM: + case IPA_MEM_STATS_TETHERING: + return ipa->version >= IPA_VERSION_4_0; + + default: + return false; /* Anything else is optional */ + } +} + static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) { struct device *dev = &ipa->pdev->dev; @@ -149,8 +179,20 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) if (mem->offset) dev_warn(dev, "empty region %u has non-zero offset\n", mem_id); + + if (ipa_mem_id_required(ipa, mem_id)) { + dev_err(dev, "required memory region %u missing\n", + mem_id); + return false; + } } + /* Now see if any required regions are not defined */ + while (mem_id < IPA_MEM_COUNT) + if (ipa_mem_id_required(ipa, mem_id++)) + dev_err(dev, "required memory region %u missing\n", + mem_id); + return true; } diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index ce692f948d59a..effe01f7310a2 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -55,22 +55,23 @@ enum ipa_mem_id { IPA_MEM_V6_ROUTE_HASHED, /* 2 canaries */ IPA_MEM_V6_ROUTE, /* 2 canaries */ IPA_MEM_MODEM_HEADER, /* 2 canaries */ - IPA_MEM_AP_HEADER, /* 0 canaries */ + IPA_MEM_AP_HEADER, /* 0 canaries, optional */ IPA_MEM_MODEM_PROC_CTX, /* 2 canaries */ IPA_MEM_AP_PROC_CTX, /* 0 canaries */ - IPA_MEM_NAT_TABLE, /* 4 canaries (IPA v4.5 and above) */ - IPA_MEM_PDN_CONFIG, /* 0/2 canaries (IPA v4.0 and above) */ - IPA_MEM_STATS_QUOTA_MODEM, /* 2/4 canaries (IPA v4.0 and above) */ - IPA_MEM_STATS_QUOTA_AP, /* 0 canaries (IPA v4.0 and above) */ - IPA_MEM_STATS_TETHERING, /* 0 canaries (IPA v4.0 and above) */ + IPA_MEM_MODEM, /* 0/2 canaries */ + IPA_MEM_UC_EVENT_RING, /* 1 canary, optional */ + IPA_MEM_PDN_CONFIG, /* 0/2 canaries (IPA v4.0+) */ + IPA_MEM_STATS_QUOTA_MODEM, /* 2/4 canaries (IPA v4.0+) */ + IPA_MEM_STATS_QUOTA_AP, /* 0 canaries, optional (IPA v4.0+) */ + IPA_MEM_STATS_TETHERING, /* 0 canaries (IPA v4.0+) */ + IPA_MEM_STATS_DROP, /* 0 canaries, optional (IPA v4.0+) */ + /* The next 5 filter and route statistics regions are optional */ IPA_MEM_STATS_V4_FILTER, /* 0 canaries (IPA v4.0-v4.2) */ IPA_MEM_STATS_V6_FILTER, /* 0 canaries (IPA v4.0-v4.2) */ IPA_MEM_STATS_V4_ROUTE, /* 0 canaries (IPA v4.0-v4.2) */ IPA_MEM_STATS_V6_ROUTE, /* 0 canaries (IPA v4.0-v4.2) */ - IPA_MEM_STATS_FILTER_ROUTE, /* 0 canaries (IPA v4.5 and above) */ - IPA_MEM_STATS_DROP, /* 0 canaries (IPA v4.0 and above) */ - IPA_MEM_MODEM, /* 0/2 canaries */ - IPA_MEM_UC_EVENT_RING, /* 1 canary */ + IPA_MEM_STATS_FILTER_ROUTE, /* 0 canaries (IPA v4.5+) */ + IPA_MEM_NAT_TABLE, /* 4 canaries, optional (IPA v4.5+) */ IPA_MEM_END_MARKER, /* 1 canary (not a real region) */ IPA_MEM_COUNT, /* Number of regions (not an index) */ }; From patchwork Wed Jun 9 22:35:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456837 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721053jae; Wed, 9 Jun 2021 15:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZtRIwK9JYw6u0S0iah3mevstIZTzH4DVxTwXOzh7OKH6z3DghCG/pr+bWmcSrFJxBNmHE X-Received: by 2002:a17:906:3644:: with SMTP id r4mr1837408ejb.140.1623278158768; Wed, 09 Jun 2021 15:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278158; cv=none; d=google.com; s=arc-20160816; b=OVsT+0YKvkJYr/mp/gokKe2QvJFRRjZwlWKCQmkLRjI6yWyd3GK18UIF9NBrZ0gBP5 iu7G0gBoZE5+p8cUTcu0hQq7tAarWRojGKLyibTVeuQ6jPCyo+udtLcdXWLlIcWBL7c2 0k704zwoJk5+JN+c0Pv1jUFlRC8QWz55aaTPomLYEl/hERQ/EjBFICr4jPHe949ItbVO oZ4aYysxLhKBUQX8b7WPJxfnXGbr/uFzHsgNfodDs4wLizY+IdH3trxhCmdKbcWqGoHJ rKwzctIJN85ubbe0pL0S3ZYlrP3F6resMWzOAlQBOMPZ8+8f0xyDTlfHZAYNQV5+s/t2 MaiQ== 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=k9I2jKXj/F7lg6Lryp5lxiDkbNlYBHbGPJE5o0sX/HI=; b=wSanvlv2M0M9xPI2Ih4WT9NMXTTqMpEHS/kA8xhQknfTreMEecNFBIt86lbdgRkeDA et6L1F6KayBrHzqq4PLfieV8V1ZohnWj9B3RmGUZS30ZAZ4QOwZSp9ggkaV4+2jMWzj/ Wlw6aK2qq+n492EQdMDXfmfo6U/z37DVc7fKog8OQ+rHpqaBWXYDr1SwihRk1c4aMKE5 dePZ6Aj/lgLBos98QfYupaodGUGQVTinBJi5HyQsSHOmpc1o9jF+dEixt57zuxxrZ7h1 FmkA2JTUrgZ6UKtZSbBdKnnn5mSey9rI/nUz+Gm/i7OBDsbA+PJUNvz81OKzgaoMlbqo Jvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=enyRBi6h; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.35.58; Wed, 09 Jun 2021 15:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=enyRBi6h; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230162AbhFIWhQ (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhFIWhO (ORCPT ); Wed, 9 Jun 2021 18:37:14 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9D9C0613A3 for ; Wed, 9 Jun 2021 15:35:15 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id h16so15316365ila.6 for ; Wed, 09 Jun 2021 15:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k9I2jKXj/F7lg6Lryp5lxiDkbNlYBHbGPJE5o0sX/HI=; b=enyRBi6hcgdDlfUrxsoRQ7fYxmpcaF1aVHd9PlEk89kZdw7Dro52PXd7Ha1xrFUKlr L2jA6OBEN8Z4R8eBNhbmua/4Djzc6w0RcyHAHiq3zinm5NWqwiGXJxf43FN/vnaZjuVQ lESOzLEdqfr4P2FgHrCimB0tR0AiqPPcirAEwjw7FnKMxB8o/6+F1l9iRppAqZ9x2Hl2 nn89r9RDpPKWCQ2BbRk1yl2o2+0rDhc2MbPdfeFk8qM6vwIZ3tu5uQb8CxOzYdtsDAgw ZQKC9bV/FYf6mG45NEtOyLXjtAX5IGJ2O7seMa9bzwmkAr9GlUqhlFRwusD+cXrIpDUw M3rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k9I2jKXj/F7lg6Lryp5lxiDkbNlYBHbGPJE5o0sX/HI=; b=CKVcW51JtT9V4E2C7+b8aAkz7GMRR3Yp1+MdMVSnd4JOkIT0KGOZMD7WMAz6OMDsmF CgGqmNrvVDW5ui4npBS1wsnVpgT68H3s+zAPgqeykSyrCz7Uu+whm7yA84X/dMOIfFJY biAGeg4GnYmshTqFDpYMSq4KTIISoZJC1I3z7pJcv6rZq2lNfJOGHOQ3equFOesj0Fzp kLATJijgeShxHZlc91QHKNn7aytcJmjLHJS5WTEsUIODQI39LN0ZE6GLownaO989lWr0 xV71LTxdMlyaup3YmivOOMaaeW5xz2MDPjsDN0h20UF280Bg0veRNqJem6xS9AcctsNV S3/w== X-Gm-Message-State: AOAM531KjD+kOqjeVTCyNWalkm7pOI3pBwSrM8kH9PXLx73DwqAcKHbj UoIe7rIdtaZ3leeexLeSp59rjw== X-Received: by 2002:a05:6e02:1a03:: with SMTP id s3mr1457518ild.220.1623278115302; Wed, 09 Jun 2021 15:35:15 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:15 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 09/11] net: ipa: validate memory regions based on version Date: Wed, 9 Jun 2021 17:35:01 -0500 Message-Id: <20210609223503.2649114-10-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce ipa_mem_id_valid(), and use it to check defined memory regions to ensure they are valid for a given version of IPA. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 29c626c46abfd..e5ca6a2ac626a 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -99,6 +99,61 @@ int ipa_mem_setup(struct ipa *ipa) return 0; } +/* Is the given memory region ID is valid for the current IPA version? */ +static bool ipa_mem_id_valid(struct ipa *ipa, enum ipa_mem_id mem_id) +{ + enum ipa_version version = ipa->version; + + switch (mem_id) { + case IPA_MEM_UC_SHARED: + case IPA_MEM_UC_INFO: + case IPA_MEM_V4_FILTER_HASHED: + case IPA_MEM_V4_FILTER: + case IPA_MEM_V6_FILTER_HASHED: + case IPA_MEM_V6_FILTER: + case IPA_MEM_V4_ROUTE_HASHED: + case IPA_MEM_V4_ROUTE: + case IPA_MEM_V6_ROUTE_HASHED: + case IPA_MEM_V6_ROUTE: + case IPA_MEM_MODEM_HEADER: + case IPA_MEM_AP_HEADER: + case IPA_MEM_MODEM_PROC_CTX: + case IPA_MEM_AP_PROC_CTX: + case IPA_MEM_MODEM: + case IPA_MEM_UC_EVENT_RING: + case IPA_MEM_PDN_CONFIG: + case IPA_MEM_STATS_QUOTA_MODEM: + case IPA_MEM_STATS_QUOTA_AP: + case IPA_MEM_END_MARKER: /* pseudo region */ + break; + + case IPA_MEM_STATS_TETHERING: + case IPA_MEM_STATS_DROP: + if (version < IPA_VERSION_4_0) + return false; + break; + + case IPA_MEM_STATS_V4_FILTER: + case IPA_MEM_STATS_V6_FILTER: + case IPA_MEM_STATS_V4_ROUTE: + case IPA_MEM_STATS_V6_ROUTE: + if (version < IPA_VERSION_4_0 || version > IPA_VERSION_4_2) + return false; + break; + + case IPA_MEM_NAT_TABLE: + case IPA_MEM_STATS_FILTER_ROUTE: + if (version < IPA_VERSION_4_5) + return false; + break; + + default: + return false; + } + + return true; +} + /* Must the given memory region be present in the configuration? */ static bool ipa_mem_id_required(struct ipa *ipa, enum ipa_mem_id mem_id) { @@ -135,6 +190,12 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) enum ipa_mem_id mem_id = mem->id; u16 size_multiple; + /* Make sure the memory region is valid for this version of IPA */ + if (!ipa_mem_id_valid(ipa, mem_id)) { + dev_err(dev, "region id %u not valid\n", mem_id); + return false; + } + /* Other than modem memory, sizes must be a multiple of 8 */ size_multiple = mem_id == IPA_MEM_MODEM ? 4 : 8; if (mem->size % size_multiple) From patchwork Wed Jun 9 22:35:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456844 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721766jae; Wed, 9 Jun 2021 15:37:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp9WzCZqi0t94mAA+NBLVCsc/U3y3IO9VIvDAMHtQD9Eko4RMJa5q3oU7xMz4Oq4hU3cbr X-Received: by 2002:a50:ec08:: with SMTP id g8mr1620424edr.376.1623278236723; Wed, 09 Jun 2021 15:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278236; cv=none; d=google.com; s=arc-20160816; b=uktL5xe2F2VySGiEX9cSa3i3GqnNHHNOjbQgICi0wloQZ99Mi0U0wqlmxKy6RJHApy GuwlYn7uiir2hVOoXEss1VAEgIHNgByxTZcuG3v2cSItlT6s2OKoYPeUjePp54+5KZel lywaqd8wXnnXHbMYuByn5NSUbPp9K+dS3LZle/vVgmV2eNtYWc+e3wTjHI9XKhI6fanH eXc1do2INBxeu/WuQqGNFWqs5o/ob383QY0hUb+Fu47IgPZ71dUwApwd/dabglx0beVb uRCR8IVz905QX2DY1BD5Br9JyRDcdeDy3iyZBb/+pctu96yjBqjEXAffNJqr78jJg7Jw 9ERw== 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=MjaLCCuhPqeJB8iNJffoDPKJK2p3mA4oFWzwOxWZ3Gw=; b=GK4t1xUZJl1wsjPP14ARFL6AoOgXF8Olb0Q7ELSF4ejYqXL87eXZnxsRBYT3rjcGgX Sm7U21XHNnqebdMB7dsSDE4w6kOtuexUBcTm/JaeKAprkPUP7x6geXwShBjB89GSLkPw KuU+EF0aPlMZDwa5xYuKHvTpwIAFuP4hk6EoaAVjJJDHKb3wBkLL54KKuSf4Bd/tZZhn 2SkLKFG/pzpNPvr1xhRp/SoqJrJhghfkQnzoKOmTqqO7nlJinzBoKcBvBKtIcsv7tPNQ l1QeJo7wk4ei/5ctxgdmM1xaxFM/5EkQjsVYj7NvDsDa4VwwDh1pmPay1PFS4Ciwe0bA xGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2TZ9ZBG; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si912205eje.551.2021.06.09.15.37.16; Wed, 09 Jun 2021 15:37:16 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2TZ9ZBG; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230435AbhFIWiN (ORCPT + 8 others); Wed, 9 Jun 2021 18:38:13 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:42598 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhFIWiL (ORCPT ); Wed, 9 Jun 2021 18:38:11 -0400 Received: by mail-io1-f42.google.com with SMTP id k22so24604647ioa.9 for ; Wed, 09 Jun 2021 15:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MjaLCCuhPqeJB8iNJffoDPKJK2p3mA4oFWzwOxWZ3Gw=; b=E2TZ9ZBGuLHUiQK7Yms2LgZqA8CQbRI52tWDzbVotpLaCpPqFveHfFyQ4JGEVhcRoz Y0Szz2VwkJX+cD0aaqWPL5gADQqxpY6L5DXl6Uhhh0mZVQg4EVoHsfxbQCF/I4B9B7Vn ZHcn0y5Nj862uB7UwJStB4DMxbVJqhCw9iy8fiK391dscbkxWHeLaoyeKvafLsvntoyL cANjDfBL79EJfmEpg/8cV1cZfeuilQxTwD38zBsJ4u6d0PfnCTIcZr10M8g6ugTFO9I3 jCcCs/583CdKsfWlTsf6MgjnL9NL82QS3Bi7YKencTm440dJR1rb4GVKQJYpxKE2+R2I TrCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MjaLCCuhPqeJB8iNJffoDPKJK2p3mA4oFWzwOxWZ3Gw=; b=VPnDemRHeZh6EBCxam9wzcJPg3sQY+2K7dYghYZPpy093iXmHz9KMpNhBIfjiP+CWK fM1oAT3dRN0McvqWiog2p8gxNXMFvMWililMWLV/0OtZr2jK/dG0rz9dL5WS5ptck5sn XUOW7ZXZYUvou6hdQPNNgBpnluWvrDlflV4d1ZNGqu6Tsv55LYJ5tLk7JZdtarAUyvzo K3pmJN6DEu0dGf/bh6a7l6cUTECKS4awcL2l3Ua8pCiSxIYQ8c+Kh92vvZh4wXl4+4mc OknHm0JWRib8ikZwmRfDBXLGriGqhCALeyBZ2Ri3Y7S8xG4ahkK76PQ51DkktmiEO8sg DdPw== X-Gm-Message-State: AOAM533LaqjAbj7al1Egd9topz9IeYzMtsSxUhS+JZevtBCQ035ekmEl RXltWb8dNejQmQqhCQcPkPhsXPcDWSBL911b X-Received: by 2002:a02:8784:: with SMTP id t4mr1614284jai.26.1623278116257; Wed, 09 Jun 2021 15:35:16 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:15 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 10/11] net: ipa: flag duplicate memory regions Date: Wed, 9 Jun 2021 17:35:02 -0500 Message-Id: <20210609223503.2649114-11-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a test in ipa_mem_valid() to ensure no memory region is defined more than once, using a bitmap to record each defined memory region. Skip over undefined regions when checking (we can have any number of those). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index e5ca6a2ac626a..7b79aeb5f68fc 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -217,6 +217,7 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) /* Verify each defined memory region is valid. */ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) { + DECLARE_BITMAP(regions, IPA_MEM_COUNT) = { }; struct device *dev = &ipa->pdev->dev; enum ipa_mem_id mem_id; @@ -229,6 +230,14 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) for (mem_id = 0; mem_id < mem_data->local_count; mem_id++) { const struct ipa_mem *mem = &mem_data->local[mem_id]; + if (mem_id == IPA_MEM_UNDEFINED) + continue; + + if (__test_and_set_bit(mem->id, regions)) { + dev_err(dev, "duplicate memory region %u\n", mem->id); + return false; + } + /* Defined regions have non-zero size and/or canary count */ if (mem->size || mem->canary_count) { if (ipa_mem_valid_one(ipa, mem)) From patchwork Wed Jun 9 22:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 456838 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp5721060jae; Wed, 9 Jun 2021 15:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybpm/dr/ULA0Jt7N/kOE1RtWgterIE1RmywiQ1PIA+09pIyVMKE838je1AC/cxRYIvULSX X-Received: by 2002:a17:906:311a:: with SMTP id 26mr1736054ejx.517.1623278159166; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623278159; cv=none; d=google.com; s=arc-20160816; b=Ex1o75mi8hK9YLE+4NT54BVwrJjGOuiy9DEvpnzMU7aZGPq6NCD7G6cQ21Gr4MBPeC +g8tJ4BhLyqztFDlJc+s7MSgXq5oO7tpeePd2ilDINsFpt3W3W0SlxDQ1dkyB1lVQgTX UsVMGhKv+avruO6euBMbAeLY8mIH1Tj568PZxsoVAeM0hAp907biEGCeldCaAyu+G1vF eqB8+gfCL8NEu+Y6yvQxp02PYh+pD1ImwUuqbdU8aZ0vDqK3oLXSvFhZL38S1GasTbUS y7KFKrpj6O1mTcs0yCbyOlX9SCGzxHgt1DsIOhaobgKu99s73SSPZhI19O5npP/0LVc3 cRpw== 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=LMjjpQs8M9kSqCO6ZvuGUH0+GwK5H/54utg6EraTogs=; b=qhn3L5q4TCgM2Qg34yDIYSw+7yShhN5SvcIq+v+Ei8uMtVh/dNkYhFlVOVnKi2hGcB leks07DZr44P2ReiUUrNM7lYZFGIxjQflVBNo0VgAwTpMh+/bYS5XCQtvtWJ1bPcQaZ5 cxrOTbK56OZuY52iqvg9VwKjpk1KyY6ECiW4DknlwyiswTa0UnBsIGlAzwE9Uht1k0tI 49BsE+8Inil2GNLNX9/lgC9hOBF6MgLENN/eHSdekEabK+qr3kzXNNVeri5wZOQEzdv7 qakU8zGLiMuk6ZljGsYZ5/KhM65R2RCbdYxXDi3csUOTn2lCxApeN2VeHA3k4mP0HVvE 99Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ssxJcMWa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si910300ejd.313.2021.06.09.15.35.58; Wed, 09 Jun 2021 15:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ssxJcMWa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230205AbhFIWhT (ORCPT + 8 others); Wed, 9 Jun 2021 18:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbhFIWhP (ORCPT ); Wed, 9 Jun 2021 18:37:15 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA0F6C061280 for ; Wed, 9 Jun 2021 15:35:17 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id d1so25078820ils.5 for ; Wed, 09 Jun 2021 15:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LMjjpQs8M9kSqCO6ZvuGUH0+GwK5H/54utg6EraTogs=; b=ssxJcMWayGRPdGFk8seuDEbiPT0gGpO8Yt1Vu7q1Y73l7POmJVrKeua49bkoXQJujC mPOTH0J9PcRsj2gwh78uxmLjxnvCVyoaJGVIY3RDupNLbn0PnomToNIx/2/xa4sp6lym MlKcXD+mCCT28Wu5xtquKoJ+9cYjXdbtMrXu4llHa3WGSi9aLDyNLJS1IcDWNjsOkn5d TG3yuiZCDqRZzYPY4iyp8JVtbE37OWZjp7DwaVXjm/vTDUcwRYiGsua0WzHu9pvo1R3m u7eSa+AgD0/Ooy4RuyGkLoqodcKhp4tZrbROb3c5RP4RaOPkS8kAh34nEtOmH0XwZUUD pKdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LMjjpQs8M9kSqCO6ZvuGUH0+GwK5H/54utg6EraTogs=; b=slsuDzvRq6PHfFSEIQAK8B0gVZ2x+TG7yR8I4n2RUlXYNgBWdhwYFLieAn26F5RojU P694BGz932B6T8ijzLtXHx82jtBj0r5SneraUoZxGbMcQ4lfSeWPZChfR7Q/9HdFKcOy mvgTxOeN5NGSxunHMDQEYy/zQ5yY5KAqx/CYAylG3/BnbPgAb9fVnVLDG9VGUsE+grER W/pxJsCJX3eEKrCuS/UTZV2SWalSdeLAFCYMGZv8DYLdHojf1Gf7885JR+PEOTUFuISR 0CXKiGUh3YZS9/k7Pt17+srNIn2EGEYca9NSVdrBQ3Exc+BO+sH94fVxGErWIxnChqep kCdQ== X-Gm-Message-State: AOAM533R62UI1SiHj0xVMxkgCb9GwNfHY1JqQljtzICGlURL++2Nd7oF lYNiPnNmXIIqIjDCdj5XoMj4xUNpdWNcSq/e X-Received: by 2002:a92:cd8d:: with SMTP id r13mr1444229ilb.93.1623278117230; Wed, 09 Jun 2021 15:35:17 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id c19sm750165ili.62.2021.06.09.15.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:35:16 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 11/11] net: ipa: use bitmap to check for missing regions Date: Wed, 9 Jun 2021 17:35:03 -0500 Message-Id: <20210609223503.2649114-12-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210609223503.2649114-1-elder@linaro.org> References: <20210609223503.2649114-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In ipa_mem_valid(), wait until regions have been marked in the memory region bitmap, and check all that are not found there to ensure they are not required. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 7b79aeb5f68fc..ef9fdd3b88750 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -249,19 +249,16 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) if (mem->offset) dev_warn(dev, "empty region %u has non-zero offset\n", mem_id); - - if (ipa_mem_id_required(ipa, mem_id)) { - dev_err(dev, "required memory region %u missing\n", - mem_id); - return false; - } } /* Now see if any required regions are not defined */ - while (mem_id < IPA_MEM_COUNT) - if (ipa_mem_id_required(ipa, mem_id++)) + for (mem_id = find_first_zero_bit(regions, IPA_MEM_COUNT); + mem_id < IPA_MEM_COUNT; + mem_id = find_next_zero_bit(regions, IPA_MEM_COUNT, mem_id + 1)) { + if (ipa_mem_id_required(ipa, mem_id)) dev_err(dev, "required memory region %u missing\n", mem_id); + } return true; }