From patchwork Thu Jun 10 19:23: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: 457866 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp752240jae; Thu, 10 Jun 2021 12:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSK6GvJnMRhS51c1XOeC4xQdc/ouOwTyuavEYv41QKDBHoedZeFhiWi77GNpxNJh/1BIo+ X-Received: by 2002:a17:906:17c4:: with SMTP id u4mr158307eje.481.1623353089825; Thu, 10 Jun 2021 12:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353089; cv=none; d=google.com; s=arc-20160816; b=Gs0fn8DeThpnSksVL+ye+EdbgLM4pp+pAMyBZEv+Cq2x0M7bx7eGXJD3sCC8lm7KYM 1oDFD76xIupUzbvHO97MTSU9kKHM1iQXvj6/yi7LVaPz7w+75h4dfZqQRt4DNvyQh+yW decwObJKMw/FoOli5xmFj9nWduKRZ5wynqykwFNHp8XV/TUGK5k1NPqqYVUIhgHFHkZY 1OEbikwP7eFMXWryyokIhi40Cod1PhF01pBo1b1ieNst1vFHk+5JXpnvDdu8KRu5AccH fwl4bHuFeSTC0wkE7CtDzYmB+wJGU32HgHRcLR8+4cILoSIL2W+8GJ0zubvsAyaT2OfJ Z01A== 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=TgCXcwikD7YOZc4EH2kp/99Pj/MYR+EhW4Nm3Stgz2A=; b=YfPP+LjpRsGyD/JzD0IbvJsbVMJRuJ36IhWO98x1zGeYhqF9EpmRI69bNF2qXUEeWX 64ZCKh3ImeY4+kCwZ1uh8/P6t9e5h6PnO2joFhYJ8B85NZz4nSPaYvM1TP2VN7bPiVM6 Bx2MHaVEJFHrHFrn5bI87KNi7YJ1oJx3CEbJ/SPxD/FULkTCWvFZK5d3GE7fjxBXoJXv li4dbcy+Ic18qQ5uOztrwAKLzb4hEf823+uYmFijBjSlug09qKEiTUv5g0NAkcpj4miY BfNNiEGD0v7fZgEcbqZ0G9mXoQQE7L8rApriyBfxjEvVtvBOhO+s03AvqDGVJx5BwdtY +2vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMLFIfuP; 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 l2si2813531eji.562.2021.06.10.12.24.49; Thu, 10 Jun 2021 12:24:49 -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=PMLFIfuP; 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 S231217AbhFJT0U (ORCPT + 8 others); Thu, 10 Jun 2021 15:26:20 -0400 Received: from mail-io1-f52.google.com ([209.85.166.52]:35683 "EHLO mail-io1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbhFJT0R (ORCPT ); Thu, 10 Jun 2021 15:26:17 -0400 Received: by mail-io1-f52.google.com with SMTP id d9so28273242ioo.2 for ; Thu, 10 Jun 2021 12:24: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=TgCXcwikD7YOZc4EH2kp/99Pj/MYR+EhW4Nm3Stgz2A=; b=PMLFIfuP55Qo2ENFeYxAlLv5stNrgAnVD7EwtddQLlrGL0Y+pURXgyzq72UEEDiH97 H4Q3dn5xLRAdRKTWze4blcgN/INaLiEhQ7MUdxg0QqaGvdqYupw60fnlKYuU2gu+6tTw TmKDix6C0U1DSiIwSjRKL2aPbNLoixW35LNKd/Ws7SZk4QdcUP5EcsL72KNCJ6lZybs7 BZ9VFqEUPwQqG4neRyFftWBuWQjLV/BIA3yrvbip4kCS/DPAyiWEfXgScO2q1PLw23ks CN6+SM/ILr/3hLkx7/aVAAZx5tJDarOKH3zazS0kwnEYHEgWDAwF8rHNsj274ruZ1KgX h7Wg== 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=TgCXcwikD7YOZc4EH2kp/99Pj/MYR+EhW4Nm3Stgz2A=; b=sR7OkjOiwHXDIstptMRAHMA1K3xDoIwadIIvinOVKZnmczVctn6yF1/CiLgAIDZ+Zk 1D9qDuOoUsSJNBAMWZMgIJOQDxFAd0deR6l0mE9auEE84Rdi4xLpRfJ6v/YHJ9zQVUbw 1G8gxNQFpDjAESSVks5o7amqEhMVm+0r2hey4JtAeaQ2WlDXirIGP/BOurZgqYE3bJbx BeBuZhkXKRB8Catw1nWkTNrjEI0fbBjUkvw4nhzrSo6XUcPRcmpLvZ1zrF/ptyKJkfuA Xs0lz/1RfHdck+PrQE3Ac/falhujkwITfR+lYG7LVxl295++u6kOab45PmuIQfVpXXW4 bjcg== X-Gm-Message-State: AOAM5303pep7ZmLNauSt0YH0zizq9ifAsmJkU2ELeh/LEvFKI6RVFjGN k7rvmpknMrpu1CVurRHFYHwhkw== X-Received: by 2002:a6b:cd08:: with SMTP id d8mr114858iog.86.1623352993715; Thu, 10 Jun 2021 12:23: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 w21sm2028684iol.52.2021.06.10.12.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23: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 1/8] net: ipa: don't assume mem array indexed by ID Date: Thu, 10 Jun 2021 14:23:01 -0500 Message-Id: <20210610192308.2739540-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Change ipa_mem_valid() to iterate over the entries using a u32 index variable rather than using a memory region ID. Use the ID found inside the memory descriptor rather than the loop index. Change ipa_mem_size_valid() to iterate over the entries but without assuming the array index is the memory region ID. "Empty" entries will have zero size; and we'll temporarily assume such entries have zero offset as well (they all do, currently). Similarly, don't assume the mem[] array is indexed by ID in ipa_mem_config(). There, "empty" entries will have a zero canary count, so no special assumptions are needed to handle them correctly. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index ef9fdd3b88750..9e504ec278179 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -220,6 +220,7 @@ 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; + u32 i; if (mem_data->local_count > IPA_MEM_COUNT) { dev_err(dev, "too many memory regions (%u > %u)\n", @@ -227,10 +228,10 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) return false; } - for (mem_id = 0; mem_id < mem_data->local_count; mem_id++) { - const struct ipa_mem *mem = &mem_data->local[mem_id]; + for (i = 0; i < mem_data->local_count; i++) { + const struct ipa_mem *mem = &mem_data->local[i]; - if (mem_id == IPA_MEM_UNDEFINED) + if (mem->id == IPA_MEM_UNDEFINED) continue; if (__test_and_set_bit(mem->id, regions)) { @@ -248,7 +249,7 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) /* 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); + mem->id); } /* Now see if any required regions are not defined */ @@ -268,16 +269,16 @@ 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; + u32 i; - for (mem_id = 0; mem_id < ipa->mem_count; mem_id++) { - const struct ipa_mem *mem = &ipa->mem[mem_id]; + for (i = 0; i < ipa->mem_count; i++) { + const struct ipa_mem *mem = &ipa->mem[i]; if (mem->offset + mem->size <= limit) continue; dev_err(dev, "region %u ends beyond memory limit (0x%08x)\n", - mem_id, limit); + mem->id, limit); return false; } @@ -294,11 +295,11 @@ static bool ipa_mem_size_valid(struct ipa *ipa) int ipa_mem_config(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; - enum ipa_mem_id mem_id; dma_addr_t addr; u32 mem_size; void *virt; u32 val; + u32 i; /* Check the advertised location and size of the shared memory area */ val = ioread32(ipa->reg_virt + IPA_REG_SHARED_MEM_SIZE_OFFSET); @@ -330,11 +331,11 @@ int ipa_mem_config(struct ipa *ipa) ipa->zero_virt = virt; ipa->zero_size = IPA_MEM_MAX; - /* For each region, write "canary" values in the space prior to - * the region's base address if indicated. + /* For each defined 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]; + for (i = 0; i < ipa->mem_count; i++) { + const struct ipa_mem *mem = &ipa->mem[i]; u16 canary_count; __le32 *canary; From patchwork Thu Jun 10 19:23: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: 457861 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp751736jae; Thu, 10 Jun 2021 12:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0pvTiaVb0RmtgSJHoiMhFIGjEKn/P1HcJ3bI2L3AO4e7gJJhhkfizyKd++2yraBFGeFLo X-Received: by 2002:a05:6402:10d7:: with SMTP id p23mr73294edu.74.1623353028593; Thu, 10 Jun 2021 12:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353028; cv=none; d=google.com; s=arc-20160816; b=t29C/i+WkKtLBNpsru0y/RsmisYm7pUhI3sM5aLQykqxQ5K5OSQOBepgK6KhAByJaU 7LDejWrC/9oQdURjjSb83zYJrEXmxTAOExMIP7/LvNRzcQX3uKKL94XeL29ngJVEDgZO x4PnLM4T7Q+iWx4nhyc56VXz1rp4+c2EpY8reulwRujhdISTZ6RBmR3niVGC7llewa8m POETU/KK6YLhTHgpUslFJBmn6/qDIGYuIkVpQgRKsqNW4oiZqseYweQnjz5l6i/gM327 l+fMqs8V+1DpTFDFB+Gr1RyqppIO40Cc5gggTedOGziOcb9MhHi0NAwpQVWgRmIbpO48 VWzg== 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=6lzDnIEiuHeqKMSHR2kedCosArXsL218NPTCRDYpYD8=; b=BkjbcKH/ZvMXGjGKtD6dq5YyF9xvzfGBO1U+8kz6Zy7gHkojq4YW49QKagUbOBcODr H7gOfaK3hQgsgivLM2rYoQFscWI3wYedM2i5+mGUXEUqGCw19lji6vm5deKDIqXm8oXp PjjziK+CiXgR7hLqzV8w3kLXVkd/mT02fmG0YhwSkEOgWfRAx9hyhwg8tQcHgfNhqYem zwLfLKf2udZKd6wTfSB/ReW2PxG+bgR8uMcAIrYx7tV9MDZaybBHWR0wAlvpg3NNqdpK poYer+dmCsvbxk2Pqxz3fM9eC0e+2JSxaYqoBCaPUYpXhbka/XDV8zJfzUCimd5Qe3/B 1T2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kDAqS9nl; 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 bz20si3523532ejc.486.2021.06.10.12.23.48; Thu, 10 Jun 2021 12:23:48 -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=kDAqS9nl; 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 S230265AbhFJTZM (ORCPT + 8 others); Thu, 10 Jun 2021 15:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbhFJTZL (ORCPT ); Thu, 10 Jun 2021 15:25:11 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D30DC061760 for ; Thu, 10 Jun 2021 12:23:15 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id b25so28242820iot.5 for ; Thu, 10 Jun 2021 12:23: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=6lzDnIEiuHeqKMSHR2kedCosArXsL218NPTCRDYpYD8=; b=kDAqS9nlvRXkAdNWf2DNRxD/rQ5ly86VqTrzfW6Mhwtt/5N2v7XQz2UGGT/KrxUbWs 6RVFcH4c33YI9ze+uik0zrtKh/7Ry1b8mM5qTj/uHzeQZkQE8iX4qlVIYQ/GmU7alHKj 37lleMphxA+w4GVDIX2Yp25onaTEB0oNinRGjMhu7EldtoVjjqNNVhTFqGGFpIc+85xb Jo/xstiUaTW1eTPhqJROWdr6GLkRZWknQrQleUVARNtsmsVv5G4zf0N+WrmBInqXLG/S UnVqJZrFHtVPeAV+rJCN2FsKo7NM7ES81cqRLnrN0FU9nbafIyMr8GTQ1REAbcRL5iDQ dYbQ== 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=6lzDnIEiuHeqKMSHR2kedCosArXsL218NPTCRDYpYD8=; b=Nz5UoJuBu+4ocF88Oq/BD6uamn0TPWP6z2L7kk59X7YvT2kD58gBIdfPnkBTTNjahM DwSQPvlMXQVjcwyGT8crfEsYdT6nI5C4mSBl2wdwwBZWpYSY/5zQMKn3W6ZKBFQkAvMD Ds6u6ZehA35b2zqixt+RRKAXZIAoef8DL1LqkoQB+kn6omQebNmIWoRnC7r9KS+xJCA+ 6tG94p+MdzWWaFayX4b7VLOwXc5bKCWs6wnIKqYqto+8dNHUP6WrxmhZoMA8JSZN8W81 +fJiJw9DbjrIAsVXC+lA8m3SMMvqT3OCrL9/mnC35+ZLHOyF+fij/98BWClXTNO0itcA s2iw== X-Gm-Message-State: AOAM533SmhealxV6khpazoenwRprb7etvqCBjT9mbMiLv+tAEhtlvewe t25wrklS5qkZpuTJjzwb4pFqyA== X-Received: by 2002:a05:6638:140c:: with SMTP id k12mr201699jad.126.1623352994670; Thu, 10 Jun 2021 12:23: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 w21sm2028684iol.52.2021.06.10.12.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23: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 2/8] net: ipa: clean up header memory validation Date: Thu, 10 Jun 2021 14:23:02 -0500 Message-Id: <20210610192308.2739540-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Do some general cleanup in ipa_cmd_header_valid(): - Delay assigning the mem variable until just before it's used. - Assign the maximum offset and size values together. - Improve comments explaining the single range of memory being made up of a modem portion and an AP portion. - Record the offset of the combined range in a local variable. - Do the initial size assignment right after assigning the offset. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 46 ++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 525cdf28d9ea7..3e5f10d3c131d 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -200,41 +200,53 @@ bool ipa_cmd_table_valid(struct ipa *ipa, const struct ipa_mem *mem, /* Validate the memory region that holds headers */ static bool ipa_cmd_header_valid(struct ipa *ipa) { - const struct ipa_mem *mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; struct device *dev = &ipa->pdev->dev; + const struct ipa_mem *mem; u32 offset_max; u32 size_max; + u32 offset; u32 size; - /* In ipa_cmd_hdr_init_local_add() we record the offset and size - * of the header table memory area. Make sure the offset and size - * fit in the fields that need to hold them, and that the entire - * range is within the overall IPA memory range. + /* In ipa_cmd_hdr_init_local_add() we record the offset and size of + * the header table memory area in an immediate command. Make sure + * the offset and size fit in the fields that need to hold them, and + * that the entire range is within the overall IPA memory range. */ offset_max = field_max(HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK); - if (mem->offset > offset_max || - ipa->mem_offset > offset_max - mem->offset) { - dev_err(dev, "header table region offset too large\n"); - dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n", - ipa->mem_offset, mem->offset, offset_max); - - return false; - } - size_max = field_max(HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK); - size = ipa->mem[IPA_MEM_MODEM_HEADER].size; + + /* The header memory area contains both the modem and AP header + * regions. The modem portion defines the address of the region. + */ + mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; + offset = mem->offset; + size = mem->size; + + /* Make sure the offset fits in the IPA command */ + if (offset > offset_max || ipa->mem_offset > offset_max - offset) { + dev_err(dev, "header table region offset too large\n"); + dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n", + ipa->mem_offset, offset, offset_max); + + return false; + } + + /* Add the size of the AP portion to the combined size */ size += ipa->mem[IPA_MEM_AP_HEADER].size; + /* Make sure the combined size fits in the IPA command */ if (size > size_max) { dev_err(dev, "header table region size too large\n"); dev_err(dev, " (0x%04x > 0x%08x)\n", size, size_max); return false; } - if (size > ipa->mem_size || mem->offset > ipa->mem_size - size) { + + /* Make sure the entire combined area fits in IPA memory */ + if (size > ipa->mem_size || offset > ipa->mem_size - size) { dev_err(dev, "header table region out of range\n"); dev_err(dev, " (0x%04x + 0x%04x > 0x%04x)\n", - mem->offset, size, ipa->mem_size); + offset, size, ipa->mem_size); return false; } From patchwork Thu Jun 10 19:23: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: 457863 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp751760jae; Thu, 10 Jun 2021 12:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8W5f1VfwwE7ypBceTjj2umez3UfbYiVbjZDXALCTejGZEeBxbrZN7lI0yoesNNkxbtXM4 X-Received: by 2002:aa7:d612:: with SMTP id c18mr91394edr.80.1623353031019; Thu, 10 Jun 2021 12:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353031; cv=none; d=google.com; s=arc-20160816; b=U6vQoNg9Lb0yE7D56CGjtIc0kJrrc9iXfi2NXPiGRp5qgP8OALVU4xWV5SHzkuymzz E0Zr1IQhgiOuEU3ljCEGeDm15siiYZf9yjKQyHi6ElhUwIG64euBp5BCc4zjYqQoU3sE wrr8xj7TknAUVG/iuoxEMbDQLCTDy0jlTy5XGPBN2oH0w5+7j4fyiQkTtDryZJd+mN+V YORPxyH2EX4HXKPF4wI9uV5sqI/y5zSrUR1rCKrPRTqDYb0Sth6aK5BvD6RoGsjdfpta FvHK/Hj53MNLjlPEYa9pKEoBmeJVJua15djG44NrZ3JgC2/G1rrq23pE7cyftqL01Ola jamA== 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=4/t4sCO8hQSs7ROFTaaBJV7ulZEJYwQ8iet8BnuZgGk=; b=uVLJ5bRpnUjpa3Ja2q6T9sPsqX53gTry3wsOKuKRZrCALMcAZd5zDW8PBzQjlJYItG gYt/MyHzwcj/9+6JqJ4v8HvYMsj1GDBFBoYxF+kBJsy8GM8ELLmGUJVBnSt4Fr58eCCu 1GFJdKwK0HA9nZeFqpoZ07ewS0Cuj0up1oW9AIHNSh1MEnzpzhiDjswd8UN15PzXpfLQ WYrc0hLMdCz/gLSvNjCkGdnNlmt8P+7Un0beHpahF929A7zSNy8bYfRh1Qhm9eLguE90 CzN2YvmPcZwZlW+PZxjDAuT+FFAhuq+bR15YQQ+znpCq35JefEfiVQdekgca0zOapuz/ bEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RzSk2322; 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 bz20si3523532ejc.486.2021.06.10.12.23.50; Thu, 10 Jun 2021 12:23:51 -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=RzSk2322; 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 S230483AbhFJTZc (ORCPT + 8 others); Thu, 10 Jun 2021 15:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbhFJTZ1 (ORCPT ); Thu, 10 Jun 2021 15:25:27 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3B1C0617A8 for ; Thu, 10 Jun 2021 12:23:17 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id i17so2887157ilj.11 for ; Thu, 10 Jun 2021 12:23: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=4/t4sCO8hQSs7ROFTaaBJV7ulZEJYwQ8iet8BnuZgGk=; b=RzSk2322WnM1iVkHW1uBofB1ujueFj1W/pbj0oQ2e9XYC+ffyOtiSS4kMWtvPX6zUG eLR1VgahrCCM7Yqgr6Jy8wO9/zwc10QL4Ms+L43O/d7zdjs2kQwrp+52k143QMfcq+n7 G3hvUUSFBwkXH8e1r9RAUaVlvI3bpjOFSaVyABM8lG6NGpUBhPumilBO+yX02NscqIvS VN2Q3naCo3yfuo1Ekeaq+kF7dD7+ozJPcA9HpDJ+iA3YoiTkftdFgv//glx8aM0jDIwj LS37PTvGmATkNhAWDjqGG5LgI19Fr7As1LSnlBLhTw7beMIsfGATFH7VAN4RGEKwgM7A qrIQ== 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=4/t4sCO8hQSs7ROFTaaBJV7ulZEJYwQ8iet8BnuZgGk=; b=Zae6WCR2ZFEq2cPIx3IrcOdSGfZM2MwZdx+2UenglDWIgG1p3z/NCYGfPkFm4BePz8 LSRz53XDqbZL1WvwtzOYcAquK6ed/Ovsbr28z+tSgbFowS5HVAYkW8IfUjaM8XsA0TXg 1tIIx6lpyC9e5IPR7PH/Cq7psC/loU4NhqhtCH18MLEzppt0OzBHFjFsQKO79iDLkoAe KNOQNzJf8MuCp+/9jcw++h1wHmvE/nsfddJAJP6uccnC2UQGeZ8oZqEnsi970zRCglH5 gdOGypZAtsBeiaSZ4uEB6E7KfiaO6O0l9kFXBjyGq+TVHpdrrefy2raDi9tcIUaN/J1R a3BQ== X-Gm-Message-State: AOAM533mgzuHIbXly8PIrvtQbskSl2C3CfyxVtGUoYnmYeGdVJeDUreT zOUtyyLU+b52H6n4wQupUxo1YQ== X-Received: by 2002:a05:6e02:c4:: with SMTP id r4mr300184ilq.76.1623352995686; Thu, 10 Jun 2021 12:23: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 w21sm2028684iol.52.2021.06.10.12.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23: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 3/8] net: ipa: pass mem_id to ipa_filter_reset_table() Date: Thu, 10 Jun 2021 14:23:03 -0500 Message-Id: <20210610192308.2739540-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass a memory region ID rather than the address of a memory region descriptor to ipa_filter_reset_table(), to simplify callers. We can eliminate the check for a zero region size in this function because ipa_table_reset_add() checks that before adding anything to the transaction. Note that here and in subsequent commits there is no need to check whether a memory region exists, because we will have already verified that during initialization. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 3168d72f42450..95a4c2aceb010 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -282,16 +282,14 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, * for the IPv4 and IPv6 non-hashed and hashed filter tables. */ static int -ipa_filter_reset_table(struct ipa *ipa, const struct ipa_mem *mem, bool modem) +ipa_filter_reset_table(struct ipa *ipa, enum ipa_mem_id mem_id, bool modem) { + const struct ipa_mem *mem = &ipa->mem[mem_id]; u32 ep_mask = ipa->filter_map; u32 count = hweight32(ep_mask); struct gsi_trans *trans; enum gsi_ee_id ee_id; - if (!mem->size) - return 0; - trans = ipa_cmd_trans_alloc(ipa, count); if (!trans) { dev_err(&ipa->pdev->dev, @@ -327,20 +325,18 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem) { int ret; - ret = ipa_filter_reset_table(ipa, &ipa->mem[IPA_MEM_V4_FILTER], modem); + ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, &ipa->mem[IPA_MEM_V4_FILTER_HASHED], - modem); + ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER_HASHED, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, &ipa->mem[IPA_MEM_V6_FILTER], modem); + ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER, modem); if (ret) return ret; - ret = ipa_filter_reset_table(ipa, &ipa->mem[IPA_MEM_V6_FILTER_HASHED], - modem); + ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER_HASHED, modem); return ret; } From patchwork Thu Jun 10 19:23:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 457868 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp752270jae; Thu, 10 Jun 2021 12:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFplFX3oHVME7GTtopaQfnLWjln+86YiHKXq00m7XVsv0wN9AGtaG3rLRtUlEr6hOJm8sm X-Received: by 2002:a17:906:51d8:: with SMTP id v24mr178712ejk.264.1623353091600; Thu, 10 Jun 2021 12:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353091; cv=none; d=google.com; s=arc-20160816; b=xmZNx/v1xDEP3lpHh/iX/DolCgYMZzTdPTjhPLerdyI9WHNLExa5o3G6w3z6dZNX28 sL9wPE3aijBEDtqRnIlGWFAgeyReP1ZnLxmq0QhpVJk7jGUTldKZWr9SY5gS7oQm5akv bnLAAqTWRcDwnXTh3E9IwyJzgX6TnXq9CdQiDIJfHzm/GU7voTf7SV6mfbDhRyDqkDWK iOWjiYndhsVR2/3jfKfGXrdE7Pr05JnUQz/vagHCruqfV7HA1dX4iQmNGZJ2XdloFPqD DiNig6JMXRheH4HAwF6KAyFNTLv48VzC3Na1MhzYO7e0ZVdxfrVO3FhGi043O+++fhIv hgcA== 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=LSNscCRP7JfsjOWiGj3ECcyfzJq/+6gwkjgojdezt6g=; b=BDk1DPDU3pa9dkw0Wwvr1oQvMla6UbcWNlTXJndz7zOePkZIhLg2YmT8kbBAxJskxz QUpbYNi/CR3j9CRE8Jzeup8BkJVmKGN2lIyaDsGKBGMcGrHP4GPebZPhCP0tTyN9p7fD SQo3Z2AFeYXNi9T3TxWPtMg46dwIcabLcBS88x78ONXjzaOqdai6wrR3JviyR9W9uXiA aZWPFZnzDPYnbl/oCmIOEUIh3EICnGfG3/Qioyf4sMTP4j4VjrJQV3snU3ryJGPo9DWR cwquYAqUrZ1Q3/iV8a6eqNEuv/MfvaUoMZ90tjUOU6fyHWnWUcgosg8yROJwr2bcg/EB caiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DDFz+Tgs; 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 l2si2813531eji.562.2021.06.10.12.24.51; Thu, 10 Jun 2021 12:24:51 -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=DDFz+Tgs; 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 S231261AbhFJT0f (ORCPT + 8 others); Thu, 10 Jun 2021 15:26:35 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:38617 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbhFJT00 (ORCPT ); Thu, 10 Jun 2021 15:26:26 -0400 Received: by mail-io1-f42.google.com with SMTP id b25so28242922iot.5 for ; Thu, 10 Jun 2021 12:24: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=LSNscCRP7JfsjOWiGj3ECcyfzJq/+6gwkjgojdezt6g=; b=DDFz+TgsEfq8Q9Kx50srPZd+fk4kD9yQBXU2gcl3I1G0prMIdeRMgv1HKbUJyETaFz uYD0UUeZcTZyach78CSN1FySvlydoeUikv+Rk7dEX6jItSvMX40wEUY+DFaCelW1Ywsx My1aG94zsXXfktL1BSa9BLHw2F0nk8fpBnTNtwrlWsMhOvpBzbtBDstbpQszudxcuMAQ G6hadkwdufYzwFLyN/5T8oP/YSSx+Ah3FXoPumjvlIogRtk4d/puiTCxzKABZ48ThEnx ZIlOA4KoA3vWOrDiSSn7FaceSVv3KKanUnwLrnqQX1a0Z6LzkdyD2xOk37uOVcKn+QPn IPlg== 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=LSNscCRP7JfsjOWiGj3ECcyfzJq/+6gwkjgojdezt6g=; b=TkeBU24mdvx0td1md5yk5Qz9L5KUPmjsV1aIDVFbKgnV102e2vTBEZZ151SG7PjxVV EgVtudVEhbdXcjejSzotqxbLR7Mn5DlZ+HyOfo4sQmhJAICKTxAiGMwYX+jKNm3S7quv 1bFDcKfbJLjCkytqpycDaxZ0P2WiV5Hd0iOxyEtgJKY33umPl9doOn98c8gEdzprqsD3 miPTQ4TfjhluEeVlCgGtEb/1aSn+3uK7szFVrmUyEBmdCTC6CgCZWD3eKvLNJSDsJemr Nu7+vT1phyISifCrbSoFjTpBL4fE4pfaMVB6ZqvEm20R0KbtLwaP9CdBvcFHzccmGcql n4iw== X-Gm-Message-State: AOAM530rirwIm8CKmSKzigF3zyX6gxGKLfxkWtyv3tPQc5SOBmaQ3Djb pN7ofFyOwH6P4TlxQZPTiyvDMg== X-Received: by 2002:a05:6638:3393:: with SMTP id h19mr222269jav.0.1623352996717; Thu, 10 Jun 2021 12:23: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 w21sm2028684iol.52.2021.06.10.12.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23: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 4/8] net: ipa: pass mem ID to ipa_mem_zero_region_add() Date: Thu, 10 Jun 2021 14:23:04 -0500 Message-Id: <20210610192308.2739540-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass a memory region ID rather than the address of a memory region descriptor to ipa_mem_zero_region_add() to simplify callers. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 9e504ec278179..7df5496bdc2e4 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -28,9 +28,10 @@ /* Add an immediate command to a transaction that zeroes a memory region */ static void -ipa_mem_zero_region_add(struct gsi_trans *trans, const struct ipa_mem *mem) +ipa_mem_zero_region_add(struct gsi_trans *trans, enum ipa_mem_id mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); + const struct ipa_mem *mem = &ipa->mem[mem_id]; dma_addr_t addr = ipa->zero_addr; if (!mem->size) @@ -83,11 +84,9 @@ int ipa_mem_setup(struct ipa *ipa) ipa_cmd_hdr_init_local_add(trans, offset, size, addr); - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_MODEM_PROC_CTX]); - - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_AP_PROC_CTX]); - - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_MODEM]); + ipa_mem_zero_region_add(trans, IPA_MEM_MODEM_PROC_CTX); + ipa_mem_zero_region_add(trans, IPA_MEM_AP_PROC_CTX); + ipa_mem_zero_region_add(trans, IPA_MEM_MODEM); gsi_trans_commit_wait(trans); @@ -411,11 +410,9 @@ int ipa_mem_zero_modem(struct ipa *ipa) return -EBUSY; } - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_MODEM_HEADER]); - - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_MODEM_PROC_CTX]); - - ipa_mem_zero_region_add(trans, &ipa->mem[IPA_MEM_MODEM]); + ipa_mem_zero_region_add(trans, IPA_MEM_MODEM_HEADER); + ipa_mem_zero_region_add(trans, IPA_MEM_MODEM_PROC_CTX); + ipa_mem_zero_region_add(trans, IPA_MEM_MODEM); gsi_trans_commit_wait(trans); From patchwork Thu Jun 10 19:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 457862 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp751742jae; Thu, 10 Jun 2021 12:23:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWDNX039ZLRHJfgJddMpzab6SdlPRRwEtCQbkmSGo9ZSl46V4FZe81Z1Zbgd8w8d/T9S5Z X-Received: by 2002:a05:6402:144d:: with SMTP id d13mr64601edx.288.1623353029050; Thu, 10 Jun 2021 12:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353029; cv=none; d=google.com; s=arc-20160816; b=I8yCdw4c7apVBPlkLG0evfNOWFnU5WqAPGWaWk6ARooBsdquoKg8AiKrQWPk4H5ZB8 a6LNgflzMxi+DbwpeXKZjz+YNosvhmh6f1VOTvvj766qYPvGqa3u39HAONRv7jeMTb9D z3PhsR3GP8bokNCVUYrdHfHzuk43EykBa0jQfAjHw4ALl3V4K604ju4W8QIBy3Q1IKyG i6onhziI8qfB8lMofiZNFSou8hrYWja7v3+mw6Cmhlxp3Th/wFHjJrJ6MRQTRBu4xMOp DTX3K/NoZEBk42jxycdB9F4KnGhVn52CBQ+KnAHMNx9da51nkb2myWE/tMIKAZgDaD9/ K6xA== 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=ZO4h+PYJOf6ZfOfwhNt7/7Z/XLn2xofEcctKVO8NNKs=; b=D5+NWOb1nnPVW6ohbPQNoc4zIyDZ57ullYQhO0CHp7T5ZVXLRaThArVgJpTRbW8f4T VP9i8IXSxOhzwRdxLHmUHTJCB/RLUq9v95vE1BgHKOA5HJD6e24hNq7bgClgRRPqAkxn f5U0HmJ7EvqcG/mIEsCwVMWPLP2Wb1Y7y0L9k0CloJk0SVT7P6NoeGjbdVSmhZSMgZZp SkcIHB/e1hx7PXXjOqOFQtrOauZmOb+rOwwiDsM/dxf4Illl1zi6bRRYNEHb5NwqKII0 nMDdfVwBoBJA52hU97t1W495yUYcMj00IzaTerogNuUn9+EHOBbzSS4OKyza5naFrvHb X6Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kW3vUZ34; 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 bz20si3523532ejc.486.2021.06.10.12.23.48; Thu, 10 Jun 2021 12:23:49 -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=kW3vUZ34; 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 S230363AbhFJTZQ (ORCPT + 8 others); Thu, 10 Jun 2021 15:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbhFJTZO (ORCPT ); Thu, 10 Jun 2021 15:25:14 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB55C0617AD for ; Thu, 10 Jun 2021 12:23:18 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id x18so2891905ila.10 for ; Thu, 10 Jun 2021 12:23:18 -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=ZO4h+PYJOf6ZfOfwhNt7/7Z/XLn2xofEcctKVO8NNKs=; b=kW3vUZ34Jg0z7b8YWn5WOik7kunMU2bkK85BgKtIcOiZPG4VRqpj5Y9dCv7fb/7EIG 0CPfmSBIItmGNF4ni4gSZ/VIsSMQNref054WRaGh3xhJB8Pna4/u27bBGe/t6/ZU2Vj4 diUyLXA3BKhNQn8OJaYmwNcwMpDJ3ktNFJh/WCMHqACgUVGqgM3hh+7q7jPl2HLhEZU7 th2gddESeNyzgbJGKvZeQIg7CEKVacq0Es6SAQcwf5aFP91c+vy7prFQeb8Adt/RAk6C Ye+D9XdueFYLCUEKrkQMFXAmYVzi+CYZcSPQkrPfU1nKH1iTYvMFvRycbOg+k1NJE9bT c23g== 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=ZO4h+PYJOf6ZfOfwhNt7/7Z/XLn2xofEcctKVO8NNKs=; b=SFoYF2K7jsDUXRlqZpXfHeFKEkWTB+0JKdxbRpZYoLWTgaVZojb4NOzzu5DzmLnlJt OYhBM5TO43cdBHpYR7EDzQAWUJl/5A2IPD7Pr0Z48FuRroGav36oMYtSjukEkYf9nbml YpAr0+z43rOTgO4+K3iCNHLLOhgEFtirXGQa8wBf1AuGbmL3G5sSLb6G4JO6kQtPIOHz Oj5r2gw9xxGHeUaDDaHoA32XMdxr2i6qx5iPjBy+Np9mbyz9IoEAn9CvU60vYTo9WSaa KDNdX2NDr+pTJehMunvDBFDDh733FcS0J7m6I5pEB9g9Rm5XITsvylqt4DPiYuETuyZv K+Tg== X-Gm-Message-State: AOAM5334V4JBJciypIQbbexVu3XiXMEbdRaIcF1waBmFVDjixs2wGMDi 1xaOwPLsBP/kJCzFABb57u+9Qg== X-Received: by 2002:a05:6e02:1068:: with SMTP id q8mr276336ilj.276.1623352997667; Thu, 10 Jun 2021 12:23: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 w21sm2028684iol.52.2021.06.10.12.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23:17 -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 5/8] net: ipa: pass mem_id to ipa_table_reset_add() Date: Thu, 10 Jun 2021 14:23:05 -0500 Message-Id: <20210610192308.2739540-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass a memory region ID rather than the address of a memory region descriptor to ipa_table_reset_add() to simplify callers. Similarly, pass memory region IDs to ipa_table_init_add(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 95a4c2aceb010..f7ee75bfba748 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -256,14 +256,15 @@ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) } static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, - u16 first, u16 count, const struct ipa_mem *mem) + u16 first, u16 count, enum ipa_mem_id mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); + const struct ipa_mem *mem = &ipa->mem[mem_id]; dma_addr_t addr; u32 offset; u16 size; - /* Nothing to do if the table memory regions is empty */ + /* Nothing to do if the table memory region is empty */ if (!mem->size) return; @@ -284,7 +285,6 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, static int ipa_filter_reset_table(struct ipa *ipa, enum ipa_mem_id mem_id, bool modem) { - const struct ipa_mem *mem = &ipa->mem[mem_id]; u32 ep_mask = ipa->filter_map; u32 count = hweight32(ep_mask); struct gsi_trans *trans; @@ -309,7 +309,7 @@ ipa_filter_reset_table(struct ipa *ipa, enum ipa_mem_id mem_id, bool modem) if (endpoint->ee_id != ee_id) continue; - ipa_table_reset_add(trans, true, endpoint_id, 1, mem); + ipa_table_reset_add(trans, true, endpoint_id, 1, mem_id); } gsi_trans_commit_wait(trans); @@ -367,15 +367,13 @@ static int ipa_route_reset(struct ipa *ipa, bool modem) count = IPA_ROUTE_AP_COUNT; } + ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE); ipa_table_reset_add(trans, false, first, count, - &ipa->mem[IPA_MEM_V4_ROUTE]); - ipa_table_reset_add(trans, false, first, count, - &ipa->mem[IPA_MEM_V4_ROUTE_HASHED]); + IPA_MEM_V4_ROUTE_HASHED); + ipa_table_reset_add(trans, false, first, count, IPA_MEM_V6_ROUTE); ipa_table_reset_add(trans, false, first, count, - &ipa->mem[IPA_MEM_V6_ROUTE]); - ipa_table_reset_add(trans, false, first, count, - &ipa->mem[IPA_MEM_V6_ROUTE_HASHED]); + IPA_MEM_V6_ROUTE_HASHED); gsi_trans_commit_wait(trans); @@ -429,10 +427,12 @@ int ipa_table_hash_flush(struct ipa *ipa) static void ipa_table_init_add(struct gsi_trans *trans, bool filter, enum ipa_cmd_opcode opcode, - const struct ipa_mem *mem, - const struct ipa_mem *hash_mem) + enum ipa_mem_id mem_id, + enum ipa_mem_id hash_mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); + const struct ipa_mem *hash_mem = &ipa->mem[hash_mem_id]; + const struct ipa_mem *mem = &ipa->mem[mem_id]; dma_addr_t hash_addr; dma_addr_t addr; u16 hash_count; @@ -473,20 +473,16 @@ int ipa_table_setup(struct ipa *ipa) } ipa_table_init_add(trans, false, IPA_CMD_IP_V4_ROUTING_INIT, - &ipa->mem[IPA_MEM_V4_ROUTE], - &ipa->mem[IPA_MEM_V4_ROUTE_HASHED]); + IPA_MEM_V4_ROUTE, IPA_MEM_V4_ROUTE_HASHED); ipa_table_init_add(trans, false, IPA_CMD_IP_V6_ROUTING_INIT, - &ipa->mem[IPA_MEM_V6_ROUTE], - &ipa->mem[IPA_MEM_V6_ROUTE_HASHED]); + IPA_MEM_V6_ROUTE, IPA_MEM_V6_ROUTE_HASHED); ipa_table_init_add(trans, true, IPA_CMD_IP_V4_FILTER_INIT, - &ipa->mem[IPA_MEM_V4_FILTER], - &ipa->mem[IPA_MEM_V4_FILTER_HASHED]); + IPA_MEM_V4_FILTER, IPA_MEM_V4_FILTER_HASHED); ipa_table_init_add(trans, true, IPA_CMD_IP_V6_FILTER_INIT, - &ipa->mem[IPA_MEM_V6_FILTER], - &ipa->mem[IPA_MEM_V6_FILTER_HASHED]); + IPA_MEM_V6_FILTER, IPA_MEM_V6_FILTER_HASHED); gsi_trans_commit_wait(trans); From patchwork Thu Jun 10 19:23:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 457864 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp751753jae; Thu, 10 Jun 2021 12:23:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU2OZ2rnMOvqMNsyMMzW0hDXODXLMlZEO65L1blhSYcxk1mw2jjbRKRlGnk+cDTZmt1mXu X-Received: by 2002:a17:906:1814:: with SMTP id v20mr180696eje.152.1623353030510; Thu, 10 Jun 2021 12:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353030; cv=none; d=google.com; s=arc-20160816; b=DRo7SLV089zEKsQNHH7olBviUMp1bmrhO8/OP2f+9Kgo2DaBXzDNWJ+6IbVQ7EjPnB tKChRv9qXA11AOs2cGZfj7PfJj9s1fCnf7aRxdLsHKbO919dUGDIRCPfLtuqnOr/MtWB FJ4qEHeEiRm7Um6ubemuKIGCb1QOJNCylW+JrjcHj/IaUZFNyrho1Z/WHLv8/c3imK+g B5cQV88AWkefCMoi+7GpOnyLKCAAiyLevXX1bHJWw7GswJrecIKE8MpManbKwfhZCjti hu+cIMWKtw41NPzn8k1AgOEnogzT853kPoQgNpdlmyBAojSjpX3ytE337DkwtrZNAdDr jW+g== 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=HL9o9ctxrHknoeR61K9dgQ4l+oTFbtzywLTa0WvXVK4=; b=GKyH+VN9qbBF02W2AE0lJ/NHOpBkRiTFWB5RBVFwA9FkVMievmIbXnoQmIV9DjOuyM GAbieK3xRvRJHHX6etxedLgxyuhbKhHMildfF+6AnZI/I7NRWE2EoEcfiVS9Vi3Akab6 NgWk+mx2zNV9bEQ6GhpfZ/37BzjCUmL4ff5F2Uk4Kcn7/ul8I7q4dbRTj5sIt9vyvu4B 3t9d85SCNzgrMaI6eFeogIKsJQXnV6eBSZWR/G1pMvHDpN4LwPl8ll3wzMpvtmN/pOOh siIzgN4LK//nTA9JL0F8dDYiLkNcqYOwXuPZ6/6e6ALpDTbsQG094jajCghmYxdG6vnU tbhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V3iQh2Cj; 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 bz20si3523532ejc.486.2021.06.10.12.23.50; Thu, 10 Jun 2021 12:23:50 -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=V3iQh2Cj; 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 S230460AbhFJTZ3 (ORCPT + 8 others); Thu, 10 Jun 2021 15:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbhFJTZP (ORCPT ); Thu, 10 Jun 2021 15:25:15 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472ECC0617AD for ; Thu, 10 Jun 2021 12:23:19 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id k22so28299519ioa.9 for ; Thu, 10 Jun 2021 12:23:19 -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=HL9o9ctxrHknoeR61K9dgQ4l+oTFbtzywLTa0WvXVK4=; b=V3iQh2CjsxmYxYGd5hCEgcOBM7sZS0HvKHFoLXi8Cbk1sgvDD71iZ5U8R/rieoh4lT bbA+bywVRsFbXHz5BuIcB444Xa7ujBo9uqopLIwuik90lIfbkrF0dEDzsdBqC+qkEkd/ r46DWGHEM233gdrx6RyoUfrvEyzN+Y+QczU1mhZWGbWBPdWa3fRH5TR8o8XKtWwttekA uabxkM8MjFbeasUqF9n/nxvNb7N+vLGbuA4+d13scN+TpBNy77s2v3p+u8oLBitMTGk5 Vii0MU2S8tKH6VOrZnkqz5W9fUaC3EMNpzP0V+HtVUdDqOfq9NSlEBzFXkYdZtE+H0hl ZwXw== 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=HL9o9ctxrHknoeR61K9dgQ4l+oTFbtzywLTa0WvXVK4=; b=Y64xdQktQOeLZr3Z9GJHm3edQmfR4oXyn4KYaBQ9aMhXt66vZk2Bw3nYqefYQzpMun jFx4brdH8ZidIW/pxuCg5qA9EyFBi9G1DZIKp3KnxoazhQ+Y5EQVVhzkED+QrAZxacld IlReTo8pOlEDS62TUvQkxlT7Wsa34vhXzXwuMyu8NMT1E8i8JMI+I8X4KuZ8hc/Nv/d9 Nbf+T4gsBVuqxbwk9wkNpeiVcwDzxIkrvkcRuwVvTrVNo8Ek4i6x9QbCYGw1WBsFbzDf v565/eWpLjmmbMXG1NEonS+dS3fqIqCsJDUV96sGeYxjNPMbO0ICYTxZgmqcerf5C+cc 6wRQ== X-Gm-Message-State: AOAM531GWjZ1wrEgC59M69X/kS9th6h2DtmnEcyn9pCdcH148vqpKmrw qmmLl/ln6baUwLy0xKkyi0e7ZA== X-Received: by 2002:a05:6638:3885:: with SMTP id b5mr206110jav.68.1623352998699; Thu, 10 Jun 2021 12:23:18 -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 w21sm2028684iol.52.2021.06.10.12.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23:18 -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 6/8] net: ipa: pass memory id to ipa_table_valid_one() Date: Thu, 10 Jun 2021 14:23:06 -0500 Message-Id: <20210610192308.2739540-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Stop passing most of the Boolean flags to ipa_table_valid_one(), and just pass a memory region ID to it instead. We still need to indicate whether we're operating on a routing or filter table. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 44 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 29 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index f7ee75bfba748..679855b1d5495 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -150,29 +150,16 @@ static void ipa_table_validate_build(void) } static bool -ipa_table_valid_one(struct ipa *ipa, bool route, bool ipv6, bool hashed) +ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) { + const struct ipa_mem *mem = &ipa->mem[mem_id]; struct device *dev = &ipa->pdev->dev; - const struct ipa_mem *mem; u32 size; - if (route) { - if (ipv6) - mem = hashed ? &ipa->mem[IPA_MEM_V6_ROUTE_HASHED] - : &ipa->mem[IPA_MEM_V6_ROUTE]; - else - mem = hashed ? &ipa->mem[IPA_MEM_V4_ROUTE_HASHED] - : &ipa->mem[IPA_MEM_V4_ROUTE]; + if (route) size = IPA_ROUTE_COUNT_MAX * sizeof(__le64); - } else { - if (ipv6) - mem = hashed ? &ipa->mem[IPA_MEM_V6_FILTER_HASHED] - : &ipa->mem[IPA_MEM_V6_FILTER]; - else - mem = hashed ? &ipa->mem[IPA_MEM_V4_FILTER_HASHED] - : &ipa->mem[IPA_MEM_V4_FILTER]; + else size = (1 + IPA_FILTER_COUNT_MAX) * sizeof(__le64); - } if (!ipa_cmd_table_valid(ipa, mem, route, ipv6, hashed)) return false; @@ -185,9 +172,8 @@ ipa_table_valid_one(struct ipa *ipa, bool route, bool ipv6, bool hashed) if (hashed && !mem->size) return true; - dev_err(dev, "IPv%c %s%s table region size 0x%02x, expected 0x%02x\n", - ipv6 ? '6' : '4', hashed ? "hashed " : "", - route ? "route" : "filter", mem->size, size); + dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n", + route ? "route" : "filter", mem_id, mem->size, size); return false; } @@ -195,16 +181,16 @@ ipa_table_valid_one(struct ipa *ipa, bool route, bool ipv6, bool hashed) /* Verify the filter and route table memory regions are the expected size */ bool ipa_table_valid(struct ipa *ipa) { - bool valid = true; + bool valid; - valid = valid && ipa_table_valid_one(ipa, false, false, false); - valid = valid && ipa_table_valid_one(ipa, false, false, true); - valid = valid && ipa_table_valid_one(ipa, false, true, false); - valid = valid && ipa_table_valid_one(ipa, false, true, true); - valid = valid && ipa_table_valid_one(ipa, true, false, false); - valid = valid && ipa_table_valid_one(ipa, true, false, true); - valid = valid && ipa_table_valid_one(ipa, true, true, false); - valid = valid && ipa_table_valid_one(ipa, true, true, true); + valid = ipa_table_valid_one(IPA_MEM_V4_FILTER, false); + valid = valid && ipa_table_valid_one(IPA_MEM_V4_FILTER_HASHED, false); + valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER, false); + valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER_HASHED, false); + valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE, true); + valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE_HASHED, true); + valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE, true); + valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE_HASHED, true); return valid; } From patchwork Thu Jun 10 19:23:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 457865 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp752234jae; Thu, 10 Jun 2021 12:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDhWKw+YC9atXTRece1/Tvruuq4DhOnqEBauW91xhw33aC3H/X5hQfX+GDg3g4CrYH25vx X-Received: by 2002:a05:6402:348f:: with SMTP id v15mr44537edc.135.1623353089367; Thu, 10 Jun 2021 12:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353089; cv=none; d=google.com; s=arc-20160816; b=w3lzsT3DyxkDwCuIfELHYjcJi+2BYwfpGgrondA1VwU6t8he+aXtlqC1J806wIcghk XSdFAtfpXdLlum99ZBe6EeNjFV8swKWZ/qDJH2LbkjGlPzYgg20uMb0QxOo3C4OmuA4/ PYkN9alIt4C8DwaK9zUIefmx50O4i95DP+RUiQtnasNRCYliVjNEhY/sPbxvZpl3KS3m jCxZIOsAFDjnKvazCHLQkUeRSvzNb+iDNZQYGCg+o94VTgb1Jc6UYdLTS31CYS5Ipuwu Xa3PQkSfOZZSl3cKSHyb9ow+Nvg8DPY3yJFR72H6ITHGU4usD485LyNNQJHcoBOuzPoR K/FQ== 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=GibQpwTu7Gu2O4wvPi+ttQ643kWB9j7PW3V83M+EmQU=; b=vDSdymmRKqCRja34GxKuLFFPJhMw05riJ5VGB6CS+9RhOFiGYNAHY/F+JX+qPu8G2z YA3xB55Yf9FFWT34nxcTxhTuzDI6ko1T9bB8M+MlTZEW44sGwxP0CiJqZLuMr2xTzAtJ HqsgJAp1ckd/92NDH0/wKZgVCZPz6M58+R2smaPB7l32ckb+V89mehzYEXL3SRToKoP4 sP0+hQWZXBDiqETY5L188OEprcJIOk7hcCKyws2qYqqncVWhByB8bj1bLqB4nmwjoP+X S2BRs1Ma5pF08Qg6sIPbcAvXsJQE0mC9+jiEW4/3qDm+sjnAi9CrPOGpSoFsmJs19zdH QIfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oLctMQxy; 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 l2si2813531eji.562.2021.06.10.12.24.49; Thu, 10 Jun 2021 12:24:49 -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=oLctMQxy; 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 S231186AbhFJT0S (ORCPT + 8 others); Thu, 10 Jun 2021 15:26:18 -0400 Received: from mail-io1-f48.google.com ([209.85.166.48]:39656 "EHLO mail-io1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhFJT0Q (ORCPT ); Thu, 10 Jun 2021 15:26:16 -0400 Received: by mail-io1-f48.google.com with SMTP id f10so13753376iok.6 for ; Thu, 10 Jun 2021 12:24:20 -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=GibQpwTu7Gu2O4wvPi+ttQ643kWB9j7PW3V83M+EmQU=; b=oLctMQxynwtBH2x3am2LvVkTVI9PXH9QMQNzGQbQ8f3If2NsFcpbMD8EkD7sYsluRp ft41+2/zW/O9YgxWKpwDmZk+e5Cg2OaRj1Usg1KcIMoMvWDwNlrMbMLusJQbOS272HXl 42aVECEKtI7/Qn8TnuLgMHxyPKQ7XC6Lmn0M8Rhy79O2emV91vGma6FgOHgm4zlptIaT Ca0yJGn1Tf4F0jljgqbfVaRU9YihQuntQevjxkLK9GBklSXZcWW53VjKvoJbm9xQbHOu /5lZlYyM208Yl1HgJlPbdoICVwlxGKnmoOL23ZaoTKEl7NpUC+I+KgfGanb1rm+5vtkO 06gw== 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=GibQpwTu7Gu2O4wvPi+ttQ643kWB9j7PW3V83M+EmQU=; b=K5y/XWzPz67HqgngoUZxxkfIfJewtXSaJN5mv+tWv9H1LM2YDIJZSs6U9+wfKGcdCS B+4fBG9xdguGl7PYD8lJKL6/p2YfTMgx1i8NYjfO6x8Si7i1PJmM72A+qz5ajpKR2zM2 J5qw5CGE8MOB3KUb8txP1h+jQTkjaiGCgh5bIjuH5jZoo3OEnG8rLbIzAt20nNs4otKk E3s3RDtTszdE7KgvXAMNCD/JO+sxTzo9ujN2WXMPKfYm1Dw1iOnFaNgmp13NIwSreI9j QpyR+OxHUGmcLp0UlsskwiChVe7zbPjTMwoNLOUX7t6/pL02tJAzDxTmnnxMe/CeogR9 9eoA== X-Gm-Message-State: AOAM532D7qODFTIWYoG9sc79AyQ0AR4jqeOd9sa4rPUu/nVD0a1HH9xT d3xYFUb6mYn1goKLnXKIyANR6w== X-Received: by 2002:a05:6638:616:: with SMTP id g22mr200647jar.88.1623352999708; Thu, 10 Jun 2021 12:23:19 -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 w21sm2028684iol.52.2021.06.10.12.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23:19 -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 7/8] net: ipa: introduce ipa_mem_find() Date: Thu, 10 Jun 2021 14:23:07 -0500 Message-Id: <20210610192308.2739540-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce a new function that abstracts finding information about a region in IPA-local memory, given its memory region ID. For now it simply uses the region ID as an index into the IPA memory array. If the region is not defined, ipa_mem_find() returns a null pointer. Update all code that accesses the ipa->mem[] array directly to use ipa_mem_find() instead. The return value must be checked for null when optional memory regions are sought. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_cmd.c | 8 +++++--- drivers/net/ipa/ipa_mem.c | 38 ++++++++++++++++++++++++++----------- drivers/net/ipa/ipa_mem.h | 2 ++ drivers/net/ipa/ipa_qmi.c | 32 +++++++++++++++---------------- drivers/net/ipa/ipa_table.c | 8 ++++---- drivers/net/ipa/ipa_uc.c | 3 ++- 6 files changed, 56 insertions(+), 35 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 3e5f10d3c131d..af44ca41189e3 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -218,7 +218,7 @@ static bool ipa_cmd_header_valid(struct ipa *ipa) /* The header memory area contains both the modem and AP header * regions. The modem portion defines the address of the region. */ - mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER); offset = mem->offset; size = mem->size; @@ -231,8 +231,10 @@ static bool ipa_cmd_header_valid(struct ipa *ipa) return false; } - /* Add the size of the AP portion to the combined size */ - size += ipa->mem[IPA_MEM_AP_HEADER].size; + /* Add the size of the AP portion (if defined) to the combined size */ + mem = ipa_mem_find(ipa, IPA_MEM_AP_HEADER); + if (mem) + size += mem->size; /* Make sure the combined size fits in the IPA command */ if (size > size_max) { diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 7df5496bdc2e4..633895fc67b66 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -26,12 +26,20 @@ /* SMEM host id representing the modem. */ #define QCOM_SMEM_HOST_MODEM 1 +const struct ipa_mem *ipa_mem_find(struct ipa *ipa, enum ipa_mem_id mem_id) +{ + if (mem_id < IPA_MEM_COUNT) + return &ipa->mem[mem_id]; + + return NULL; +} + /* Add an immediate command to a transaction that zeroes a memory region */ static void ipa_mem_zero_region_add(struct gsi_trans *trans, enum ipa_mem_id mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *mem = &ipa->mem[mem_id]; + const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); dma_addr_t addr = ipa->zero_addr; if (!mem->size) @@ -61,6 +69,7 @@ ipa_mem_zero_region_add(struct gsi_trans *trans, enum ipa_mem_id mem_id) int ipa_mem_setup(struct ipa *ipa) { dma_addr_t addr = ipa->zero_addr; + const struct ipa_mem *mem; struct gsi_trans *trans; u32 offset; u16 size; @@ -75,12 +84,16 @@ int ipa_mem_setup(struct ipa *ipa) return -EBUSY; } - /* Initialize IPA-local header memory. The modem and AP header - * regions are contiguous, and initialized together. + /* Initialize IPA-local header memory. The AP header region, if + * present, is contiguous with and follows the modem header region, + * and they are initialized together. */ - offset = ipa->mem[IPA_MEM_MODEM_HEADER].offset; - size = ipa->mem[IPA_MEM_MODEM_HEADER].size; - size += ipa->mem[IPA_MEM_AP_HEADER].size; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER); + offset = mem->offset; + size = mem->size; + mem = ipa_mem_find(ipa, IPA_MEM_AP_HEADER); + if (mem) + size += mem->size; ipa_cmd_hdr_init_local_add(trans, offset, size, addr); @@ -91,7 +104,8 @@ int ipa_mem_setup(struct ipa *ipa) gsi_trans_commit_wait(trans); /* Tell the hardware where the processing context area is located */ - offset = ipa->mem_offset + ipa->mem[IPA_MEM_MODEM_PROC_CTX].offset; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_PROC_CTX); + offset = ipa->mem_offset + mem->offset; val = proc_cntxt_base_addr_encoded(ipa->version, offset); iowrite32(val, ipa->reg_virt + IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET); @@ -294,6 +308,7 @@ static bool ipa_mem_size_valid(struct ipa *ipa) int ipa_mem_config(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; + const struct ipa_mem *mem; dma_addr_t addr; u32 mem_size; void *virt; @@ -334,11 +349,11 @@ int ipa_mem_config(struct ipa *ipa) * space prior to the region's base address if indicated. */ for (i = 0; i < ipa->mem_count; i++) { - const struct ipa_mem *mem = &ipa->mem[i]; u16 canary_count; __le32 *canary; /* Skip over undefined regions */ + mem = &ipa->mem[i]; if (!mem->offset && !mem->size) continue; @@ -361,8 +376,9 @@ int ipa_mem_config(struct ipa *ipa) if (!ipa_cmd_data_valid(ipa)) goto err_dma_free; - /* Verify the microcontroller ring alignment (0 is OK too) */ - if (ipa->mem[IPA_MEM_UC_EVENT_RING].offset % 1024) { + /* Verify the microcontroller ring alignment (if defined) */ + mem = ipa_mem_find(ipa, IPA_MEM_UC_EVENT_RING); + if (mem && mem->offset % 1024) { dev_err(dev, "microcontroller ring not 1024-byte aligned\n"); goto err_dma_free; } @@ -527,7 +543,7 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) * (in this case, the modem). An allocation from SMEM is persistent * until the AP reboots; there is no way to free an allocated SMEM * region. Allocation only reserves the space; to use it you need - * to "get" a pointer it (this implies no reference counting). + * to "get" a pointer it (this does not imply reference counting). * The item might have already been allocated, in which case we * use it unless the size isn't what we expect. */ diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index effe01f7310a2..712b2881be0c2 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -90,6 +90,8 @@ struct ipa_mem { u16 canary_count; }; +const struct ipa_mem *ipa_mem_find(struct ipa *ipa, enum ipa_mem_id mem_id); + int ipa_mem_config(struct ipa *ipa); void ipa_mem_deconfig(struct ipa *ipa); diff --git a/drivers/net/ipa/ipa_qmi.c b/drivers/net/ipa/ipa_qmi.c index 593665efbcf99..4661105ce7ab2 100644 --- a/drivers/net/ipa/ipa_qmi.c +++ b/drivers/net/ipa/ipa_qmi.c @@ -298,32 +298,32 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.platform_type_valid = 1; req.platform_type = IPA_QMI_PLATFORM_TYPE_MSM_ANDROID; - mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER); if (mem->size) { req.hdr_tbl_info_valid = 1; req.hdr_tbl_info.start = ipa->mem_offset + mem->offset; req.hdr_tbl_info.end = req.hdr_tbl_info.start + mem->size - 1; } - mem = &ipa->mem[IPA_MEM_V4_ROUTE]; + mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE); req.v4_route_tbl_info_valid = 1; req.v4_route_tbl_info.start = ipa->mem_offset + mem->offset; req.v4_route_tbl_info.count = mem->size / sizeof(__le64); - mem = &ipa->mem[IPA_MEM_V6_ROUTE]; + mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE); req.v6_route_tbl_info_valid = 1; req.v6_route_tbl_info.start = ipa->mem_offset + mem->offset; req.v6_route_tbl_info.count = mem->size / sizeof(__le64); - mem = &ipa->mem[IPA_MEM_V4_FILTER]; + mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER); req.v4_filter_tbl_start_valid = 1; req.v4_filter_tbl_start = ipa->mem_offset + mem->offset; - mem = &ipa->mem[IPA_MEM_V6_FILTER]; + mem = ipa_mem_find(ipa, IPA_MEM_V6_FILTER); req.v6_filter_tbl_start_valid = 1; req.v6_filter_tbl_start = ipa->mem_offset + mem->offset; - mem = &ipa->mem[IPA_MEM_MODEM]; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM); if (mem->size) { req.modem_mem_info_valid = 1; req.modem_mem_info.start = ipa->mem_offset + mem->offset; @@ -336,7 +336,7 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) /* skip_uc_load_valid and skip_uc_load are set above */ - mem = &ipa->mem[IPA_MEM_MODEM_PROC_CTX]; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_PROC_CTX); if (mem->size) { req.hdr_proc_ctx_tbl_info_valid = 1; req.hdr_proc_ctx_tbl_info.start = @@ -347,7 +347,7 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) /* Nothing to report for the compression table (zip_tbl_info) */ - mem = &ipa->mem[IPA_MEM_V4_ROUTE_HASHED]; + mem = ipa_mem_find(ipa, IPA_MEM_V4_ROUTE_HASHED); if (mem->size) { req.v4_hash_route_tbl_info_valid = 1; req.v4_hash_route_tbl_info.start = @@ -355,7 +355,7 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v4_hash_route_tbl_info.count = mem->size / sizeof(__le64); } - mem = &ipa->mem[IPA_MEM_V6_ROUTE_HASHED]; + mem = ipa_mem_find(ipa, IPA_MEM_V6_ROUTE_HASHED); if (mem->size) { req.v6_hash_route_tbl_info_valid = 1; req.v6_hash_route_tbl_info.start = @@ -363,22 +363,21 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.v6_hash_route_tbl_info.count = mem->size / sizeof(__le64); } - mem = &ipa->mem[IPA_MEM_V4_FILTER_HASHED]; + mem = ipa_mem_find(ipa, IPA_MEM_V4_FILTER_HASHED); if (mem->size) { req.v4_hash_filter_tbl_start_valid = 1; req.v4_hash_filter_tbl_start = ipa->mem_offset + mem->offset; } - mem = &ipa->mem[IPA_MEM_V6_FILTER_HASHED]; + mem = ipa_mem_find(ipa, IPA_MEM_V6_FILTER_HASHED); if (mem->size) { req.v6_hash_filter_tbl_start_valid = 1; req.v6_hash_filter_tbl_start = ipa->mem_offset + mem->offset; } - /* None of the stats fields are valid (IPA v4.0 and above) */ - + /* The stats fields are only valid for IPA v4.0+ */ if (ipa->version >= IPA_VERSION_4_0) { - mem = &ipa->mem[IPA_MEM_STATS_QUOTA_MODEM]; + mem = ipa_mem_find(ipa, IPA_MEM_STATS_QUOTA_MODEM); if (mem->size) { req.hw_stats_quota_base_addr_valid = 1; req.hw_stats_quota_base_addr = @@ -387,8 +386,9 @@ init_modem_driver_req(struct ipa_qmi *ipa_qmi) req.hw_stats_quota_size = ipa->mem_offset + mem->size; } - mem = &ipa->mem[IPA_MEM_STATS_DROP]; - if (mem->size) { + /* If the DROP stats region is defined, include it */ + mem = ipa_mem_find(ipa, IPA_MEM_STATS_DROP); + if (mem && mem->size) { req.hw_stats_drop_base_addr_valid = 1; req.hw_stats_drop_base_addr = ipa->mem_offset + mem->offset; diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 679855b1d5495..c617a9156f26d 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -152,7 +152,7 @@ static void ipa_table_validate_build(void) static bool ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) { - const struct ipa_mem *mem = &ipa->mem[mem_id]; + const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); struct device *dev = &ipa->pdev->dev; u32 size; @@ -245,7 +245,7 @@ static void ipa_table_reset_add(struct gsi_trans *trans, bool filter, u16 first, u16 count, enum ipa_mem_id mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *mem = &ipa->mem[mem_id]; + const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); dma_addr_t addr; u32 offset; u16 size; @@ -417,8 +417,8 @@ static void ipa_table_init_add(struct gsi_trans *trans, bool filter, enum ipa_mem_id hash_mem_id) { struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); - const struct ipa_mem *hash_mem = &ipa->mem[hash_mem_id]; - const struct ipa_mem *mem = &ipa->mem[mem_id]; + const struct ipa_mem *hash_mem = ipa_mem_find(ipa, hash_mem_id); + const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); dma_addr_t hash_addr; dma_addr_t addr; u16 hash_count; diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 2756363e69385..fd9219863234c 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -116,7 +116,8 @@ enum ipa_uc_event { static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) { - u32 offset = ipa->mem_offset + ipa->mem[IPA_MEM_UC_SHARED].offset; + const struct ipa_mem *mem = ipa_mem_find(ipa, IPA_MEM_UC_SHARED); + u32 offset = ipa->mem_offset + mem->offset; return ipa->mem_virt + offset; } From patchwork Thu Jun 10 19:23:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 457869 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp752280jae; Thu, 10 Jun 2021 12:24:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvOjkb29xQysJyHlHP8YuzFyuhA/U2aNN290OUPCkW3bra7dGvVXONuswFGBU5w4nR6kkb X-Received: by 2002:a05:6402:35d1:: with SMTP id z17mr43585edc.159.1623353092004; Thu, 10 Jun 2021 12:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623353091; cv=none; d=google.com; s=arc-20160816; b=pAFjUuu/kgJKK2JBVpWMCW4dFUDI+tJ6+v8NzlIPtCnPO0OGHyISdL2xk5jqvpDJKH eQto9PhxFVibi0DMsaBdohYeNWBQnSBAg3oVPrMKGFfctTa0/hgPiZlskTMb/x6aUSdi UzRJI+d438U7UuA9pTIh0sB5fmW4R2qgfMzb5FNCAt5Od1guncDQntnof9PC5w85rfl9 6lskkT1dJ6J8XrHXJBUgjtDlp9sE0N9fRtkaj29gVC5xJ/RgTiKv/M80fj+LrVwvHN5o 0lVyyJdV5xmZDd7ZYN+xKkAFzIga9qqSDs7Qtechu+SKX2k8NFYR8oh3NAgQiVys18IN yvzA== 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=Mxka3eMJUwTPeteIeRjKaea94F4dngtVdMYl3o+TuPI=; b=A95CK7H8oR8ZxS+40AjKxMVfReEWUxO8OUojctzgBQ24JjZAzg11mg5d0cYfNunYxw 7wcEqCGHL+mz5VD/D7dqc3I3ASrXkYsujqj4e/cup96+kJdRqD+8NBHht9fYyFAMCRJ8 NFlEBUYA+8fpWjrG0MAR7/WTC2wtZtP4RF51OPZFXU3nGfgaAElp9T8Bvq8xwnU8Ixb7 4tuDgDW0i5gwHLcVg5li3vA2EXNvKJfrWYqdrTp64tDCzHhhoitihyQHp+CLQTykfUM3 VATIIYT9RGV6cuHQOLKvMSxaHBb3B9C2xGnR5MeR0YhcPW+/HbzdUHuctJSPfoUkKf/a XDCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gXDCAZA6; 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 l2si2813531eji.562.2021.06.10.12.24.51; Thu, 10 Jun 2021 12:24:51 -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=gXDCAZA6; 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 S231246AbhFJT0h (ORCPT + 8 others); Thu, 10 Jun 2021 15:26:37 -0400 Received: from mail-io1-f49.google.com ([209.85.166.49]:37409 "EHLO mail-io1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbhFJT03 (ORCPT ); Thu, 10 Jun 2021 15:26:29 -0400 Received: by mail-io1-f49.google.com with SMTP id q7so28310844iob.4 for ; Thu, 10 Jun 2021 12:24:21 -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=Mxka3eMJUwTPeteIeRjKaea94F4dngtVdMYl3o+TuPI=; b=gXDCAZA6EDXnxIxX1gXSGr4VHMFWQmpb3pzB1qvSa0gYFQos/sSIYeFJ+57pgiznd5 W1LU6MWZ68XGgo4F1eGLLzm9o2niSYATbQoIfo52ysjA1qGoQtFZqPhKj5DgpOC77ZzQ GC77okvraxmQUSK9F5b8AEbZjGoPrVfUhDEyiPGe0R13DfTUbX2xupEuPqu+mSSDifF/ 87YmnySBH0XrMFckc5oJt+Imv/N3nXEeB3yNBhVSt4Aj+OJFCrN2Cv7tH+tUgYb5zBd/ nxIfOqoysr7C3pZxLslgMvtYkJ/dICF73WqrTW2FnTrZY4O1QCzkaolZepoNUE/9t+U3 3dnQ== 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=Mxka3eMJUwTPeteIeRjKaea94F4dngtVdMYl3o+TuPI=; b=ea0jmFEL2SsUkGa6EzCT/o+rOPuecJY85C20RKr7zRMtgVvmoR6A4o+x1pSa2TLzHw ZydzOhqqTnWHyVb1JKiR7gBDYWed3yhnXqqkvZB73/EYp7nq13IniR2uVg0VmIcBG8Je xiIn4yveARFP7crqTTdYIRxoa2PtxbrHvPXtx+m/PQpMe5eM9R8mi/tVPZ2TQno4Md/f 9G5DN3vvMkN+UXRcV4+VKelPdNQg0fEfPz3kcgoJIwjdR7NyiwP6+x7tH+eE+Ayklftq N/lUeY3WGZ46+sYSZiggeUt121ZUMtE6XSY0rj8+rPsm8BedJkjvgCsZ31UnepqFfFsN ViqA== X-Gm-Message-State: AOAM531xkxPPvW83iC/esocGgQH6nanU/bH9XH8YtUZM3c1lFuhMchky 5+y71JvHQUZjuwRPN7QdAv6eXw== X-Received: by 2002:a02:a318:: with SMTP id q24mr200868jai.100.1623353000832; Thu, 10 Jun 2021 12:23:20 -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 w21sm2028684iol.52.2021.06.10.12.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 12:23:20 -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 8/8] net: ipa: don't index mem data array by ID Date: Thu, 10 Jun 2021 14:23:08 -0500 Message-Id: <20210610192308.2739540-9-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210610192308.2739540-1-elder@linaro.org> References: <20210610192308.2739540-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Finally the code handles the IPA memory region array in the configuration data without assuming it is indexed by region ID. Get rid of the array index designators where these arrays are initialized. As a result, there's no more need to define an explicitly undefined memory region ID, so get rid of that. Change ipa_mem_find() so it no longer assumes the ipa->mem[] array is indexed by memory region ID. Instead, have it search the array for the entry having the requested memory ID, and return the address of the descriptor if found. Otherwise return NULL. Stop allowing memory regions to be defined with zero size and zero canary value. Check for this condition in ipa_mem_valid_one(). As a result, it is not necessary to check for this case in ipa_mem_config(). Finally, there is no need for IPA_MEM_UNDEFINED to be defined any more, so get rid of it. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_data-v3.5.1.c | 30 ++++++++++---------- drivers/net/ipa/ipa_data-v4.11.c | 44 ++++++++++++++--------------- drivers/net/ipa/ipa_data-v4.2.c | 36 ++++++++++++------------ drivers/net/ipa/ipa_data-v4.5.c | 46 +++++++++++++++---------------- drivers/net/ipa/ipa_data-v4.9.c | 46 +++++++++++++++---------------- drivers/net/ipa/ipa_mem.c | 38 +++++++++++-------------- drivers/net/ipa/ipa_mem.h | 1 - 7 files changed, 117 insertions(+), 124 deletions(-) -- 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 945d45b72b247..af536ef8c1209 100644 --- a/drivers/net/ipa/ipa_data-v3.5.1.c +++ b/drivers/net/ipa/ipa_data-v3.5.1.c @@ -271,91 +271,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, diff --git a/drivers/net/ipa/ipa_data-v4.11.c b/drivers/net/ipa/ipa_data-v4.11.c index 2ff3fcf4e21fa..9353efbd504fb 100644 --- a/drivers/net/ipa/ipa_data-v4.11.c +++ b/drivers/net/ipa/ipa_data-v4.11.c @@ -220,133 +220,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, diff --git a/drivers/net/ipa/ipa_data-v4.2.c b/drivers/net/ipa/ipa_data-v4.2.c index f06eb07a7895d..3b09b7baa95f4 100644 --- a/drivers/net/ipa/ipa_data-v4.2.c +++ b/drivers/net/ipa/ipa_data-v4.2.c @@ -219,109 +219,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, diff --git a/drivers/net/ipa/ipa_data-v4.5.c b/drivers/net/ipa/ipa_data-v4.5.c index 1c8a9099639ab..a99b6478fa3a5 100644 --- a/drivers/net/ipa/ipa_data-v4.5.c +++ b/drivers/net/ipa/ipa_data-v4.5.c @@ -265,139 +265,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, diff --git a/drivers/net/ipa/ipa_data-v4.9.c b/drivers/net/ipa/ipa_data-v4.9.c index f77169709eb2a..798d43e1eb133 100644 --- a/drivers/net/ipa/ipa_data-v4.9.c +++ b/drivers/net/ipa/ipa_data-v4.9.c @@ -263,139 +263,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] = { + { .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, diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 633895fc67b66..4337b0920d3d7 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -28,8 +28,14 @@ const struct ipa_mem *ipa_mem_find(struct ipa *ipa, enum ipa_mem_id mem_id) { - if (mem_id < IPA_MEM_COUNT) - return &ipa->mem[mem_id]; + u32 i; + + for (i = 0; i < ipa->mem_count; i++) { + const struct ipa_mem *mem = &ipa->mem[i]; + + if (mem->id == mem_id) + return mem; + } return NULL; } @@ -209,6 +215,11 @@ static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) return false; } + if (!mem->size && !mem->canary_count) { + dev_err(dev, "empty memory region %u\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) @@ -244,25 +255,14 @@ static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) for (i = 0; i < mem_data->local_count; i++) { const struct ipa_mem *mem = &mem_data->local[i]; - 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)) - continue; + if (!ipa_mem_valid_one(ipa, mem)) 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); } /* Now see if any required regions are not defined */ @@ -349,20 +349,14 @@ int ipa_mem_config(struct ipa *ipa) * space prior to the region's base address if indicated. */ for (i = 0; i < ipa->mem_count; i++) { - u16 canary_count; + u16 canary_count = ipa->mem[i].canary_count; __le32 *canary; - /* Skip over undefined regions */ - mem = &ipa->mem[i]; - if (!mem->offset && !mem->size) - continue; - - canary_count = mem->canary_count; if (!canary_count) continue; /* Write canary values in the space before the region */ - canary = ipa->mem_virt + ipa->mem_offset + mem->offset; + canary = ipa->mem_virt + ipa->mem_offset + ipa->mem[i].offset; do *--canary = IPA_MEM_CANARY_VAL; while (--canary_count); diff --git a/drivers/net/ipa/ipa_mem.h b/drivers/net/ipa/ipa_mem.h index 712b2881be0c2..570bfdd99bffb 100644 --- a/drivers/net/ipa/ipa_mem.h +++ b/drivers/net/ipa/ipa_mem.h @@ -43,7 +43,6 @@ 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 */