From patchwork Fri Feb 12 14:33: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: 381831 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2984470jah; Fri, 12 Feb 2021 06:36:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJybuinE72vpK9A5v97nikeAgvsDdCGE9YU+qOOCXYRzOzbi2wSheLK5itjyYf/9sDsygOyQ X-Received: by 2002:a17:906:a153:: with SMTP id bu19mr3439993ejb.287.1613140590278; Fri, 12 Feb 2021 06:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613140590; cv=none; d=google.com; s=arc-20160816; b=vYTzRNuMtxUuGZo9VhHjz/ngudHWqiS98TfCfbF1ET7/h8vhYSRtoqQIZI2YqKNAVJ lEZl+f47XMYDjRVQeq05FEt/kZQkE84bDCDQ+8QffsSOjjJsYc+3rxT3AmaKK1UYrZqv h8bqGo976l3Ui7iAr+FSO3hKss8Mrai8L9dyV/OFHgXEFSoVAA0AR4aa0kiGQ8sxcHPL HyTF+fRxNM07P1JNzp/BYg96QqtGrsX25cWH9eQDeES1Zv7jgBtnif4LOla11iBaEogl t5lGQn/6cml+ooG17KeYq7e9C/V8YjeWA09GB9l2GwHhwV08KvInQNzSWnnBHucONWtQ s+Aw== 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=G9KLLEAIyuDdy/RxlAG0smw+AOdUrAqiN6OvOo01Z/o=; b=y7YD5KutF8gAY9+4wSUV7UuJ2msvbvaSBPc9VQxJoamPTmY61r9XrQegESp31Z+Q8w e100/DZbqRS+AE0ZwOAjy9kYEpPWviYmE+lbRqdg96VLhVOK7FlnVPCOKK99JePlvN07 tVZ5Dd0/dRkhiGuitYEdqmLNpSRe/N0v09bLlfwRjD9ayNvC/w5kTJY4lP5zt0d/1gR/ CYr695Ifr0EdJ9E6of1s3BubTgwteoSjVi1gTQTjaSOVeWHDPHFmOD+H1BBKThewF/Fo 1mA4gHTU1WeNkqMd1i1VkzJUlce19b6xNZzz4gthW4T81bqsimFhmEAnyD3KbtHllCXP 6vkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cIFjugAN; 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 q21si6164613edt.445.2021.02.12.06.36.30; Fri, 12 Feb 2021 06:36:30 -0800 (PST) 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=cIFjugAN; 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 S229587AbhBLOfT (ORCPT + 9 others); Fri, 12 Feb 2021 09:35:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbhBLOes (ORCPT ); Fri, 12 Feb 2021 09:34:48 -0500 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 64EB2C0613D6 for ; Fri, 12 Feb 2021 06:34:08 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id d20so3575598ilo.4 for ; Fri, 12 Feb 2021 06:34:08 -0800 (PST) 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=G9KLLEAIyuDdy/RxlAG0smw+AOdUrAqiN6OvOo01Z/o=; b=cIFjugAN/xNyALj4ct3o8lBVv9EKPOpNaMpqSlF5AUedSBnndcIAHR62QOUvmjr6Fj ++k562icwlhBJWfzVp462RYKcou1o2prrjfEVMURUYTclaUjFwBso8hyf4ENQ8yFHdra UaeKZXyHdE/Mra53VJUNjlDcndG0MrgoJktzJHew7Dq2QCYD6pghUK/S0SH2DOvmjynI oqw+DJiUbtpE8YDR3m8FwdWNmkkfJHNYM/309DykP+yNAW0B2TZfr0orvPXr3tkb3TyX dlCUi63NJiLiL2PX9mzGBYGBY/fKtaPEKSGgnNKYpaqamt6Vv5qaIipwVOSbWHpALnhN Zj5w== 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=G9KLLEAIyuDdy/RxlAG0smw+AOdUrAqiN6OvOo01Z/o=; b=iEKQBX8DnepQAPKnNr/I7IhMj2gHyqUSsD+GWbgJf84FIMPezRNLSAJKy3zk+hy3iN 53g6O56OtNC5Egq52mRsBIVJ5w4kKc1xHpsKaxI8SOwb29cfTeibFv4e4s9DmNQ2x7gu lmdRY2mYJKQgaile2Hbe6e3PYu/37osDB9jLGh9s8QR65Y94STV3HkQIyrwVYwO1gA1t cej+Ns/3bSttjncacW93IYKgFlgOD0INQ2xprve4Ee5VgCFFvk9lUi31PkIxs3eFC3rE Ynb/aEv3xsyU8JkAzPq5xy+IAcjDh721iQxsvcseVPH89FEcJCvvlszEkCNTvfg9vVDM pf+Q== X-Gm-Message-State: AOAM533K2ByIwIFKp5GMKNyrfBapwXZnBo4tTJFQJLlpRvDFpgswGqzM u6BOUGyhMSIRDrb6+jhQG3g65Z+qcO5WMw== X-Received: by 2002:a05:6e02:1787:: with SMTP id y7mr2469684ilu.233.1613140447780; Fri, 12 Feb 2021 06:34:07 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id j12sm4387878ila.75.2021.02.12.06.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 06:34:07 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 1/5] net: ipa: use a separate pointer for adjusted GSI memory Date: Fri, 12 Feb 2021 08:33:58 -0600 Message-Id: <20210212143402.2691-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210212143402.2691-1-elder@linaro.org> References: <20210212143402.2691-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch actually fixes a bug, though it doesn't affect the two platforms supported currently. The fix implements GSI memory pointers a bit differently. For IPA version 4.5 and above, the address space for almost all GSI registers is adjusted downward by a fixed amount. This is currently handled by adjusting the I/O virtual address pointer after it has been mapped. The bug is that the pointer is not "de-adjusted" as it should be when it's unmapped. This patch fixes that error, but it does so by maintaining one "raw" pointer for the mapped memory range. This is assigned when the memory is mapped and used to unmap the memory. This pointer is also used to access the two registers that do *not* sit in the "adjusted" memory space. Rather than adjusting *that* pointer, we maintain a separate pointer that's an adjusted copy of the "raw" pointer, and that is used for most GSI register accesses. Signed-off-by: Alex Elder --- v2: - Update copyrights. drivers/net/ipa/gsi.c | 28 ++++++++++++---------------- drivers/net/ipa/gsi.h | 5 +++-- drivers/net/ipa/gsi_reg.h | 21 +++++++++++++-------- 3 files changed, 28 insertions(+), 26 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 4402136461888..9c977f80109a9 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2018-2020 Linaro Ltd. + * Copyright (C) 2018-2021 Linaro Ltd. */ #include @@ -195,8 +195,6 @@ static void gsi_irq_type_disable(struct gsi *gsi, enum gsi_irq_type_id type_id) /* Turn off all GSI interrupts initially */ static void gsi_irq_setup(struct gsi *gsi) { - u32 adjust; - /* Disable all interrupt types */ gsi_irq_type_update(gsi, 0); @@ -206,10 +204,9 @@ static void gsi_irq_setup(struct gsi *gsi) iowrite32(0, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(0, gsi->virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET); - /* Reverse the offset adjustment for inter-EE register offsets */ - adjust = gsi->version < IPA_VERSION_4_5 ? 0 : GSI_EE_REG_ADJUST; - iowrite32(0, gsi->virt + adjust + GSI_INTER_EE_SRC_CH_IRQ_OFFSET); - iowrite32(0, gsi->virt + adjust + GSI_INTER_EE_SRC_EV_CH_IRQ_OFFSET); + /* The inter-EE registers are in the non-adjusted address range */ + iowrite32(0, gsi->virt_raw + GSI_INTER_EE_SRC_CH_IRQ_OFFSET); + iowrite32(0, gsi->virt_raw + GSI_INTER_EE_SRC_EV_CH_IRQ_OFFSET); iowrite32(0, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET); } @@ -2181,9 +2178,8 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, gsi->dev = dev; gsi->version = version; - /* The GSI layer performs NAPI on all endpoints. NAPI requires a - * network device structure, but the GSI layer does not have one, - * so we must create a dummy network device for this purpose. + /* GSI uses NAPI on all channels. Create a dummy network device + * for the channel NAPI contexts to be associated with. */ init_dummy_netdev(&gsi->dummy_dev); @@ -2208,13 +2204,13 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, return -EINVAL; } - gsi->virt = ioremap(res->start, size); - if (!gsi->virt) { + gsi->virt_raw = ioremap(res->start, size); + if (!gsi->virt_raw) { dev_err(dev, "unable to remap \"gsi\" memory\n"); return -ENOMEM; } - /* Adjust register range pointer downward for newer IPA versions */ - gsi->virt -= adjust; + /* Most registers are accessed using an adjusted register range */ + gsi->virt = gsi->virt_raw - adjust; init_completion(&gsi->completion); @@ -2233,7 +2229,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, err_irq_exit: gsi_irq_exit(gsi); err_iounmap: - iounmap(gsi->virt); + iounmap(gsi->virt_raw); return ret; } @@ -2244,7 +2240,7 @@ void gsi_exit(struct gsi *gsi) mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); gsi_irq_exit(gsi); - iounmap(gsi->virt); + iounmap(gsi->virt_raw); } /* The maximum number of outstanding TREs on a channel. This limits diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index d674db0ba4eb0..efc980f96109e 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2018-2020 Linaro Ltd. + * Copyright (C) 2018-2021 Linaro Ltd. */ #ifndef _GSI_H_ #define _GSI_H_ @@ -149,7 +149,8 @@ struct gsi { struct device *dev; /* Same as IPA device */ enum ipa_version version; struct net_device dummy_dev; /* needed for NAPI */ - void __iomem *virt; + void __iomem *virt_raw; /* I/O mapped address range */ + void __iomem *virt; /* Adjusted for most registers */ u32 irq; u32 channel_count; u32 evt_ring_count; diff --git a/drivers/net/ipa/gsi_reg.h b/drivers/net/ipa/gsi_reg.h index 299456e70f286..1622d8cf8dea4 100644 --- a/drivers/net/ipa/gsi_reg.h +++ b/drivers/net/ipa/gsi_reg.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2018-2020 Linaro Ltd. + * Copyright (C) 2018-2021 Linaro Ltd. */ #ifndef _GSI_REG_H_ #define _GSI_REG_H_ @@ -38,17 +38,21 @@ * (though the actual limit is hardware-dependent). */ -/* GSI EE registers as a group are shifted downward by a fixed - * constant amount for IPA versions 4.5 and beyond. This applies - * to all GSI registers we use *except* the ones that disable - * inter-EE interrupts for channels and event channels. +/* GSI EE registers as a group are shifted downward by a fixed constant amount + * for IPA versions 4.5 and beyond. This applies to all GSI registers we use + * *except* the ones that disable inter-EE interrupts for channels and event + * channels. * - * We handle this by adjusting the pointer to the mapped GSI memory - * region downward. Then in the one place we use them (gsi_irq_setup()) - * we undo that adjustment for the inter-EE interrupt registers. + * The "raw" (not adjusted) GSI register range is mapped, and a pointer to + * the mapped range is held in gsi->virt_raw. The inter-EE interrupt + * registers are accessed using that pointer. + * + * Most registers are accessed using gsi->virt, which is a copy of the "raw" + * pointer, adjusted downward by the fixed amount. */ #define GSI_EE_REG_ADJUST 0x0000d000 /* IPA v4.5+ */ +/* The two inter-EE IRQ register offsets are relative to gsi->virt_raw */ #define GSI_INTER_EE_SRC_CH_IRQ_OFFSET \ GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(GSI_EE_AP) #define GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(ee) \ @@ -59,6 +63,7 @@ #define GSI_INTER_EE_N_SRC_EV_CH_IRQ_OFFSET(ee) \ (0x0000c01c + 0x1000 * (ee)) +/* All other register offsets are relative to gsi->virt */ #define GSI_CH_C_CNTXT_0_OFFSET(ch) \ GSI_EE_N_CH_C_CNTXT_0_OFFSET((ch), GSI_EE_AP) #define GSI_EE_N_CH_C_CNTXT_0_OFFSET(ch, ee) \ From patchwork Fri Feb 12 14:33: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: 381832 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2984484jah; Fri, 12 Feb 2021 06:36:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIox8/ekqC1ZSinjK2GKf/YZju/aO7HVDLZlgtVMXyyy3KjpHRNvcKCFNCUwzkHHM3kA2k X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr3631762edt.160.1613140591128; Fri, 12 Feb 2021 06:36:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613140591; cv=none; d=google.com; s=arc-20160816; b=Gu1Gn9hDqjIvTyItLLJKWZfU8J4dpv6t5oEnwlX6OqKBM+YmT7k8xt8FQJNdHGvwgE 6aKy+xuNlU/q3bqhZH1j6ny4Kgfdr8uyat1zAHOs6IDwbpY1ZGLacJpKl+YUtVaLMfr/ yRZHtPco1T9ft0ffK2eRi5XqTu2MKa8aYzvcXok8ZZNjCpQflHf+4MXmIkwTMFlNmSoF 09MhWjs5mpLgkj6nafrqkwUYLQGJeBqE6HFg2xOqU0EfOLgwdNgu4ERhEcerGCj+tWxs 7Ejd1FzN2QiomcSwzkKXOL8W/s7zEvXDJqzwa3r1U9gTZF4BqphIOua8Pusjkmt8YoNK 0UCA== 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=v3Lvt9FFJHAgc4CH+AJ2/GzMVHRqoRH1kZFxTe5Ya9c=; b=N2nvOB3OsWFCW/m715nj1X5+iT0eJCq4pf3bAiV+LsVjv2ZjGGXqBVPwld6gv0EsG/ 4JgnG04EmnLZelALNkyvOecTAjlcPHBc8x6PJgWcds1hA3KHJB94JWqPRAjCi54cniB6 x0mdD9Dd2FUFtcDIoADO8Q//gBeN+Gz7Txb3td2YKAuCfF6SlXctN1WIFvkk5io+8P2g /VW3AYTwIspZZrKeUBaoSXDj9IRLEAHiBkY5NDCCowwjz3/Q/m+zV2F0bb0YaUJ3Q0JJ RIIC/jqOyp7BtvPQ1fR7bTRFFJCjBgqP0YdikfATzG4247FU2xWG358ayxZtQ3toEysL xIuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=loM0zEcw; 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 q21si6164613edt.445.2021.02.12.06.36.30; Fri, 12 Feb 2021 06:36:31 -0800 (PST) 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=loM0zEcw; 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 S231564AbhBLOfv (ORCPT + 9 others); Fri, 12 Feb 2021 09:35:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbhBLOfa (ORCPT ); Fri, 12 Feb 2021 09:35:30 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4090BC06178A for ; Fri, 12 Feb 2021 06:34:09 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id e24so9485211ioc.1 for ; Fri, 12 Feb 2021 06:34:09 -0800 (PST) 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=v3Lvt9FFJHAgc4CH+AJ2/GzMVHRqoRH1kZFxTe5Ya9c=; b=loM0zEcwE53gIO6GfFp/r27LVbl+e3g8ab0FC11KZ9pJqDEBhUnOXKtobAdUeSdrXF xru7IoFTE4kKHcjywxHLXYSgfd7FqntpTIlWTPO9YYG1Rtnga1zBblfwgklcJ+/aqYNj RLfHgddrb0K2uMMZAIpNzXGyl9363c7B6AwzVzJYi27T9c5f1Yr3rjDYXauLZ4o2MpXH A5AtMmDUR4cKlpAJ314J7Vpj2I3oVxWlDeyYww2o47Zlouh6dJRnnUFFcV1gS7iLOcze BOPxnTzWD+TZ5ErTOIEmtZrBnREelyEe8GSL6R8eBqWuigMpd4wQnMhXqadC2r8b6VuR +dsA== 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=v3Lvt9FFJHAgc4CH+AJ2/GzMVHRqoRH1kZFxTe5Ya9c=; b=S4I3GfSiSrRD689AsZ7Xgno2Uj1G09aOqQbFchmM32g63onvnJfUOTw5BmtSw6dc+z iee44FOA14Qp6rulLUeDVJZKYCuM4SW797ec2TxlZNQtatrIXThbCMWMHb7WxRh0OEgv Ku7MwxLJSZPIwCQM2PQlrvZwwtLLgZr9usNIUH3NJvqlaPlL6avytPgF82K67GEj+BGk n+5Ht0fTUe4yLqO9YAY4LchpadeuyVABf4M1yswWGOLX0HPLy15K4Mb7bOobS2+MOZqp jiyq6saBOlxPW4RptOOK1+CNZWRNYbpKiUCCnmbqjfA6onf2J8qzbbamwHSey504FxhW HjKQ== X-Gm-Message-State: AOAM531wx/DbsX6ks5JN++hkbIuoXuR9QQkwi3UAtRwPDZkc8I68DyiJ stWos67VXebz/1LYDR/f/uD6ag== X-Received: by 2002:a6b:ee07:: with SMTP id i7mr2290856ioh.87.1613140448743; Fri, 12 Feb 2021 06:34:08 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id j12sm4387878ila.75.2021.02.12.06.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 06:34:08 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, hkallweit1@gmail.com, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 2/5] net: ipa: use dev_err_probe() in ipa_clock.c Date: Fri, 12 Feb 2021 08:33:59 -0600 Message-Id: <20210212143402.2691-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210212143402.2691-1-elder@linaro.org> References: <20210212143402.2691-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When initializing the IPA core clock and interconnects, it's possible we'll get an EPROBE_DEFER error. This isn't really an error, it's just means we need to be re-probed later. Use dev_err_probe() to report the error rather than dev_err(). This avoids polluting the log with these "error" messages. Signed-off-by: Alex Elder --- v3: - Use dev_err_probe(), as suggested by Heiner Kallweit. v2: - Update copyright. drivers/net/ipa/ipa_clock.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 354675a643db5..69ef6ea41e619 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2018-2020 Linaro Ltd. + * Copyright (C) 2018-2021 Linaro Ltd. */ #include @@ -68,8 +68,8 @@ static int ipa_interconnect_init_one(struct device *dev, if (IS_ERR(path)) { int ret = PTR_ERR(path); - dev_err(dev, "error %d getting %s interconnect\n", ret, - data->name); + dev_err_probe(dev, ret, "error getting %s interconnect\n", + data->name); return ret; } @@ -281,7 +281,8 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data) clk = clk_get(dev, "core"); if (IS_ERR(clk)) { - dev_err(dev, "error %ld getting core clock\n", PTR_ERR(clk)); + dev_err_probe(dev, PTR_ERR(clk), "error getting core clock\n"); + return ERR_CAST(clk); } From patchwork Fri Feb 12 14:34: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: 381833 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2984542jah; Fri, 12 Feb 2021 06:36:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEmaB7HyaRktKWWs3w6gqZzM2TQGJPfCVYWwVXwr5zhMJrf6Yc4Zb3T1E9DmjnRMD7SBPo X-Received: by 2002:a17:906:63c2:: with SMTP id u2mr3299679ejk.346.1613140595983; Fri, 12 Feb 2021 06:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613140595; cv=none; d=google.com; s=arc-20160816; b=bdIHPkittTxrWYTSkqC9d4ShH0bzCT4SmA8StO5HADSjedH7FguKX40OGDmSRUYY3N VtDdyjwr4D4WHUf2ynj0dchHcFmND0pTJQkR1OL5IwHRFxAmx/tx7laNQXlToTNosgg7 Q6m5bT19CZ/vWm14clCnmLxrkPM0y/4g6xwx1khg/P0u71V1aoHYc48bBpkJvhlCPEzl DC3IC1/1GutRGgfKo1Ff/a8ahY5FJTczcO7omesjfXzbptMPyI3bp77YOEjmPpIS3FLR pkU1VHuiqx/uZKkEbcPU4zj0wbrdp9SDQ6X/aeMS949T6rM7j2rf5qUx8lvw21wzMCR3 YHbw== 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=NzF0Z/WT0Iww7BykRJiaFbQQuxI8ckW46WWDqtEbJzw=; b=n8LcNwStQep3HYVxA3tJ/bIIlL+tv/tjTZm3f10M7+iKM9QZRxpy7rtvF5JfER5As0 6mtDlIrzVVrsXB+akcuyogNCzV/kK+s3j/Ry3fCIMPzhChJ/U+BwfhWHtyAfnBSSsHsD ElaGm/j2HQh8LWgLJ+KRpz3ksHpQBs96VQe1p5wOb8Wz12Bi0TJstsaehXqUGnr80WGi a1Ync4qMl3Uo82ra/ECaQmmp0+ojV/cHf65G7Opq5CouFS1rRwoVVXxU4Lzi9vebeRw+ uGTYr+CPz9Jl0HDFbUXEajn9666seV66a3noW6HY0w6J2vIdAVNp/k5mtpFDpUkBVrV3 ru9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gCEH7M3L; 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 q21si6164613edt.445.2021.02.12.06.36.35; Fri, 12 Feb 2021 06:36:35 -0800 (PST) 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=gCEH7M3L; 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 S231604AbhBLOgO (ORCPT + 9 others); Fri, 12 Feb 2021 09:36:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231317AbhBLOfh (ORCPT ); Fri, 12 Feb 2021 09:35:37 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA33C06178C for ; Fri, 12 Feb 2021 06:34:10 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id z18so8298418ile.9 for ; Fri, 12 Feb 2021 06:34:10 -0800 (PST) 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=NzF0Z/WT0Iww7BykRJiaFbQQuxI8ckW46WWDqtEbJzw=; b=gCEH7M3Lg1UCLH9mgtLugfV1AZ8Bjq88W4HRCIwDOaZnqZ3hK0UcGrSxVVJlFfv9Z0 IMAlAsZ8dqCp3Wh+kW4tAW/ycPdrMgmSV9uahXitKHYMqHDUD1MTABk0ieJcPxSdg0AU GXVjpvLX6aJOGOHy3HbHf4Ef+1XLcFepKaDjmMaviJpL6wQ+PQq0OW8ZYu/IIiO9o6ff /zHCgG4XhbcCmCT7QgAyHZvrGGX4SHEGQfDT/BTIVwu3gJ6ojNU8Kb/Tt13lWE+co6Ba Acxfv6V8DU8x8VsQhNW1oP1vWxLkuZ0/wbj9QTAilzxsGRA+JQr4/4Tphf1cC73ZG7Qw G/3g== 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=NzF0Z/WT0Iww7BykRJiaFbQQuxI8ckW46WWDqtEbJzw=; b=TwylMZQxPrgsncY3YZJZ+6gRNKUm1riqY3ABoSD0HIEaMm+e+QYPVXPk7qXlUmaaDC hYmGzdjQKpXes7njXD63fehY9BeQ3C+1rLorX4n6Wb/BASq2r3dJH58AeBL6aHVOY9dU 09ooHxWV7hbePqUnCU3CqLmhUjXqOh3EvFzNsscTchtr4vmNjQD1elK/qq78QBAJRXJq DAkJPPkH3vwMUmAdKLEokiSl9qBlecyMcuDYZErWYCsXkPg8gNyTLr/rJMyunACwLrzb qHCQdulk/5AVL3Y9Jv7BKS8lpu4JfFQJWfWtmc7nvJU5bHufkp1I94jBr7tPQ1p2mHbE KBHA== X-Gm-Message-State: AOAM531kN6RybtSowULLNQyL6GOTEgPbV4DTSiM4xMybmOFUsFstEY/c 1SmXq1/xVbhQeDSCmS8SAmPSgA== X-Received: by 2002:a92:cd8a:: with SMTP id r10mr2531644ilb.110.1613140449627; Fri, 12 Feb 2021 06:34:09 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id j12sm4387878ila.75.2021.02.12.06.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 06:34:09 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 3/5] net: ipa: fix register write command validation Date: Fri, 12 Feb 2021 08:34:00 -0600 Message-Id: <20210212143402.2691-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210212143402.2691-1-elder@linaro.org> References: <20210212143402.2691-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In ipa_cmd_register_write_valid() we verify that values we will supply to a REGISTER_WRITE IPA immediate command will fit in the fields that need to hold them. This patch fixes some issues in that function and ipa_cmd_register_write_offset_valid(). The dev_err() call in ipa_cmd_register_write_offset_valid() has some printf format errors: - The name of the register (corresponding to the string format specifier) was not supplied. - The IPA base offset and offset need to be supplied separately to match the other format specifiers. Also make the ~0 constant used there to compute the maximum supported offset value explicitly unsigned. There are two other issues in ipa_cmd_register_write_valid(): - There's no need to check the hash flush register for platforms (like IPA v4.2) that do not support hashed tables - The highest possible endpoint number, whose status register offset is computed, is COUNT - 1, not COUNT. Fix these problems, and add some additional commentary. Signed-off-by: Alex Elder --- v2: - Update copyright. drivers/net/ipa/ipa_cmd.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 97b50fee60089..fd8bf6468d313 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2019-2020 Linaro Ltd. + * Copyright (C) 2019-2021 Linaro Ltd. */ #include @@ -244,11 +244,15 @@ static bool ipa_cmd_register_write_offset_valid(struct ipa *ipa, if (ipa->version != IPA_VERSION_3_5_1) bit_count += hweight32(REGISTER_WRITE_FLAGS_OFFSET_HIGH_FMASK); BUILD_BUG_ON(bit_count > 32); - offset_max = ~0 >> (32 - bit_count); + offset_max = ~0U >> (32 - bit_count); + /* Make sure the offset can be represented by the field(s) + * that holds it. Also make sure the offset is not outside + * the overall IPA memory range. + */ if (offset > offset_max || ipa->mem_offset > offset_max - offset) { dev_err(dev, "%s offset too large 0x%04x + 0x%04x > 0x%04x)\n", - ipa->mem_offset + offset, offset_max); + name, ipa->mem_offset, offset, offset_max); return false; } @@ -261,12 +265,24 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa) const char *name; u32 offset; - offset = ipa_reg_filt_rout_hash_flush_offset(ipa->version); - name = "filter/route hash flush"; - if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) - return false; + /* If hashed tables are supported, ensure the hash flush register + * offset will fit in a register write IPA immediate command. + */ + if (ipa->version != IPA_VERSION_4_2) { + offset = ipa_reg_filt_rout_hash_flush_offset(ipa->version); + name = "filter/route hash flush"; + if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) + return false; + } - offset = IPA_REG_ENDP_STATUS_N_OFFSET(IPA_ENDPOINT_COUNT); + /* Each endpoint can have a status endpoint associated with it, + * and this is recorded in an endpoint register. If the modem + * crashes, we reset the status endpoint for all modem endpoints + * using a register write IPA immediate command. Make sure the + * worst case (highest endpoint number) offset of that endpoint + * fits in the register write command field(s) that must hold it. + */ + offset = IPA_REG_ENDP_STATUS_N_OFFSET(IPA_ENDPOINT_COUNT - 1); name = "maximal endpoint status"; if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) return false; From patchwork Fri Feb 12 14:34: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: 381834 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2985668jah; Fri, 12 Feb 2021 06:38:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwbBEYk5Ph2tS954ZdfeKcUyZM4Mj0z3fOD2KRsA457pWtXurWj7PoX6clJ2ijzk+RwPLI X-Received: by 2002:a05:6402:1152:: with SMTP id g18mr3784885edw.18.1613140692428; Fri, 12 Feb 2021 06:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613140692; cv=none; d=google.com; s=arc-20160816; b=DdN9T6rcqtj4aEM1Nl/BLYSmUX/XrOZMqe532qwgSFLK1MzUmEmgy+MUEVq8MKcMcF k6RyX+OVdScS/2yy/bWvbn8Xl9m3qMamSNQH79wXSnJ97TXOplZ1qK3FP4zQr5Sua35L JCdbc4FeZIfE3oAKisLc2ZdxzgzNT4MK5kYIcse7R14EksmV2FKelHL0m7W6nzpw2n+o /MtMw4+lvOQKCr5SnHN+K6DzbCI6oBWX5ZX1GZZ+fEgtp6OiRuvRDLZeL1Gc0E2FBRJS 5zZt8PB5Er2qnhKdlGwndeiuyxAyh4Z3IdKIq7UypxlJViw10qq0qkVOcJFOIiC/leFI WV2Q== 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=Ngv77mR7Co8Qy7c/B5fzu3p8H6PwwheqBKQO9srQZxA=; b=NHNJkzWdCPZ6e7bEblsS0f1Kaa1/VVLQte4Ea2kGOZnWMewKp3jgm2pOweKfIf0raD Aw+UpA9kcXfrTgNTpDpUq6yonFjK7+fmS4HaOuGc1/UUu04ex4CUJ0XCVfXVEK9OHRfh /I6TLTuZmynL1sIcUeSnQHEpEHnMfhOcvI8mrQ8rXsQMFOCJxfAcOs64hWzK96H+AxLu 3aej1svy4aZ2QuVsg0pUEB7xE0yrEK8piHYDzKLf89Ol9KufkQCxAGcMNDX4AykTxJMK 8fqb1Bc7hakTohl4DZ8gaLsBik8nr+Mzw3JAPIcUUQyPVhQ/IFY0qYsoyCbkx+TlBv1r Im/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R5u4P04C; 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 m11si6179116ejc.165.2021.02.12.06.38.11; Fri, 12 Feb 2021 06:38:12 -0800 (PST) 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=R5u4P04C; 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 S231627AbhBLOgc (ORCPT + 9 others); Fri, 12 Feb 2021 09:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231330AbhBLOfh (ORCPT ); Fri, 12 Feb 2021 09:35:37 -0500 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 1EB05C061793 for ; Fri, 12 Feb 2021 06:34:11 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id e7so8316117ile.7 for ; Fri, 12 Feb 2021 06:34:11 -0800 (PST) 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=Ngv77mR7Co8Qy7c/B5fzu3p8H6PwwheqBKQO9srQZxA=; b=R5u4P04CZ7grGZ7fbvA5XfXzxSvuYuV+iJYbKZIHQTuGbr4BGsVOCVCdoR5YyXNJdB uhE75wljXlMRAul7Ry+AfoWl0dLgibGYvoBYff+S/ZeuaBW/sd/3JlVW3t0k9n3oowXS lN/HNcuwFhbz3ysUJ2s3xDbofUEBdXK+94CccYL/XC44/fpqCpGG8vSMfY6NQEW0B3Po z34rtbePrU43DaFK4xNu4Qrz8bhGmf9dYk2lyqSDJdI7u33WK6ZfvyvaKyQFBJMvId82 RASkG/mgYVyn3xKJYsr/Zcbz9p07vbK2SKLjdGd5RK5v0KY5cMiLFOj93PVI73TJH1s+ igMQ== 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=Ngv77mR7Co8Qy7c/B5fzu3p8H6PwwheqBKQO9srQZxA=; b=jow4UxA+CCHo87hWPyMGR/f7a8TuS7rG6FnCIcauotDj1H5eFi3VGmqFThc35ZwFDJ /JsH+DrzEMvyorb0K6sp3uUeDrNzhdH6VoqMyV+sEDv4EA2N3f1ypaN++WsoK02eukUZ f/e/uzqTcGPAzo9k8Zb2ueOwqx49yQCPEIQgWl6t4lElI07GdpcfYHgNqkgE/sa+16rT 31RGV8UA1T69JpH9xoCNE8kaPzh3MDlSBcD5K0/Bxl/34eQNedhKoUhflcXDb+2puUOD j8BMxO2zxxJktGzcE7q27loVouywVdOcGyvhhnu4y5HEVnIR8kphCqgpacpXe5OYKynE AKAw== X-Gm-Message-State: AOAM531Jl4snZEKULKtltkIRLrE+PqaSZwqk8zfqrVq/rWAl4povewG6 BYH8Wkwnfgk0RTKbHhqkzKZA8Q== X-Received: by 2002:a92:850d:: with SMTP id f13mr2659960ilh.216.1613140450550; Fri, 12 Feb 2021 06:34:10 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id j12sm4387878ila.75.2021.02.12.06.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 06:34:10 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 4/5] net: ipa: introduce ipa_table_hash_support() Date: Fri, 12 Feb 2021 08:34:01 -0600 Message-Id: <20210212143402.2691-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210212143402.2691-1-elder@linaro.org> References: <20210212143402.2691-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce a new function to abstract the knowledge of whether hashed routing and filter tables are supported for a given IPA instance. IPA v4.2 is the only one that doesn't support hashed tables (now and for the foreseeable future), but the name of the helper function is better for explaining what's going on. Signed-off-by: Alex Elder --- v2: - Update copyrights. drivers/net/ipa/ipa_cmd.c | 2 +- drivers/net/ipa/ipa_table.c | 16 +++++++++------- drivers/net/ipa/ipa_table.h | 8 +++++++- 3 files changed, 17 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index fd8bf6468d313..35e35852c25c5 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -268,7 +268,7 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa) /* If hashed tables are supported, ensure the hash flush register * offset will fit in a register write IPA immediate command. */ - if (ipa->version != IPA_VERSION_4_2) { + if (ipa_table_hash_support(ipa)) { offset = ipa_reg_filt_rout_hash_flush_offset(ipa->version); name = "filter/route hash flush"; if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 32e2d3e052d55..baaab3dd0e63c 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2018-2020 Linaro Ltd. + * Copyright (C) 2018-2021 Linaro Ltd. */ #include @@ -239,6 +239,11 @@ static void ipa_table_validate_build(void) #endif /* !IPA_VALIDATE */ +bool ipa_table_hash_support(struct ipa *ipa) +{ + return ipa->version != IPA_VERSION_4_2; +} + /* Zero entry count means no table, so just return a 0 address */ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) { @@ -412,8 +417,7 @@ int ipa_table_hash_flush(struct ipa *ipa) struct gsi_trans *trans; u32 val; - /* IPA version 4.2 does not support hashed tables */ - if (ipa->version == IPA_VERSION_4_2) + if (!ipa_table_hash_support(ipa)) return 0; trans = ipa_cmd_trans_alloc(ipa, 1); @@ -531,8 +535,7 @@ static void ipa_filter_config(struct ipa *ipa, bool modem) enum gsi_ee_id ee_id = modem ? GSI_EE_MODEM : GSI_EE_AP; u32 ep_mask = ipa->filter_map; - /* IPA version 4.2 has no hashed route tables */ - if (ipa->version == IPA_VERSION_4_2) + if (!ipa_table_hash_support(ipa)) return; while (ep_mask) { @@ -582,8 +585,7 @@ static void ipa_route_config(struct ipa *ipa, bool modem) { u32 route_id; - /* IPA version 4.2 has no hashed route tables */ - if (ipa->version == IPA_VERSION_4_2) + if (!ipa_table_hash_support(ipa)) return; for (route_id = 0; route_id < IPA_ROUTE_COUNT_MAX; route_id++) diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 78038d14fcea9..1a68d20f19d6a 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. - * Copyright (C) 2019-2020 Linaro Ltd. + * Copyright (C) 2019-2021 Linaro Ltd. */ #ifndef _IPA_TABLE_H_ #define _IPA_TABLE_H_ @@ -51,6 +51,12 @@ static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask) #endif /* !IPA_VALIDATE */ +/** + * ipa_table_hash_support() - Return true if hashed tables are supported + * @ipa: IPA pointer + */ +bool ipa_table_hash_support(struct ipa *ipa); + /** * ipa_table_reset() - Reset filter and route tables entries to "none" * @ipa: IPA pointer From patchwork Fri Feb 12 14:34: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: 381835 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2985689jah; Fri, 12 Feb 2021 06:38:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJz43UY9re2uYuNrtYhV/mdVrmrJOUGupDvLKZ0K6HUSY0DcQaYiTxTrQxASIL5J9kofdhTl X-Received: by 2002:adf:ed41:: with SMTP id u1mr3792814wro.73.1613140693622; Fri, 12 Feb 2021 06:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613140693; cv=none; d=google.com; s=arc-20160816; b=k2LGTXH5XWsBACEa3Ot98blATuspm1lSe5uwwcVz1mn3+eDrJTSxpjO8wsPtq6mh06 ePCZkruwTXyngtTdzhqBjjElMYrb8w8U0bpRIEkn3bype5zT0FgbpktPk1y3RpMzmVW8 ZvWqRUCZjTc6E85lS8tk559VWavdwD1aBUNY2EGeqKkfRAZBmEnOkZF6NkyGSuin6Peo 3sP9K477kqiQl8qJhbBq/FvImZOLcFUK/K2/ycWcBA+SiFcTDjeAbrK0tRsKlizCcUBX 4EpM+74XAaYvpPJh52TQPYZHcUsGRXa6gBdCG/uz6Uq7v6+X3aHRsST1t7zDwBwCshY8 5F4A== 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=Ljog9ADMI3z+A1fikGBkRhxkobB8HTkMuLZ8xQG2g7c=; b=fenbcPksbiUzTJby1Nl1ZXUK4kADdJ1EucVw8uhlrPousTy8MDI1pZr5fu52XSYH5h uo/7wpZhcc86W/7UZw8w8+gP6DcaBpIhpHx/lZXaKiDIptIsrb46dPJrJjVqP88uaPUK f+QJPqzyMvP39r3m0Y6MbgV8fnt8Zp/Dk8GxqqjADt1ho+eK8lAfYKyEmibY6QK/8cJv O0647wv0x8i4yCR5HP/K35/Ye0B/rWqfp8zZUmJfcuPRyCyHMMT8bIIuU2JmoYEgKwUM qMJ6eyUHf5OeaG333z+OoS2sfEFjFOhHT8seC+Pfi1qrSimc6QjRwEA2BzTJLR+He4fC 0tSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bZPMogVK; 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 m11si6179116ejc.165.2021.02.12.06.38.12; Fri, 12 Feb 2021 06:38:13 -0800 (PST) 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=bZPMogVK; 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 S229647AbhBLOg4 (ORCPT + 9 others); Fri, 12 Feb 2021 09:36:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbhBLOfj (ORCPT ); Fri, 12 Feb 2021 09:35:39 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F003C061797 for ; Fri, 12 Feb 2021 06:34:12 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id n14so9500493iog.3 for ; Fri, 12 Feb 2021 06:34:12 -0800 (PST) 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=Ljog9ADMI3z+A1fikGBkRhxkobB8HTkMuLZ8xQG2g7c=; b=bZPMogVKVXPc4UeEnREVxKL+YxfNYWyThw2gIao1s47oH9l7EXzOZD1o3VNMOVNub2 MYRhBbFNh/F3dU11b3M8E1W7d0aplL/ybV3BQ0+l1yIJ+P4rCdJ9Sv1DJyHp0vS4kVPR yCQOx3PoTBXERzgBVuslsb2CVrgvOlP3uz8dirHkfIn3OcezU48qv+1eSjI8zUVcb28q epbNpllF8SZPHQdNzV7XDpFcHvvKhJTlz09vVyMKkHk1NX/wyrMS1YGwGry2t3amriAV ynFcFU+9cy//KT2wgJIFa+5w4VqxFnNAkcks8NAZelHuHlusfacvZLbMaucZZbSr1cBB MXxg== 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=Ljog9ADMI3z+A1fikGBkRhxkobB8HTkMuLZ8xQG2g7c=; b=oNRwC5Leg+qVJ5ax08bjfsJXwGms4ibyFhGoGHT5dLP9yoTJoRzYTJKFRr/lJaJrIZ FUXGwuFEqjfiJv8uQLyB5s1UT+VinEgllMWWgjWquJmC16uNMQBoeEkSc4eJi74kphV7 8smzHoTMhFh7gNk+B4tcZMTJvusxXb/vxTHUVcjhXD2bAPDEuSL4V8xghEIHDgvlHn6F WxxdBf8VGd5tdBCrL7m8lKflSmOWNkMGNOpMskoQZ4r6lmaLyUjkKAhgQ6/BNRQgxPrq xlTmFCQiN9FEXy1ydIzc2titjV5kgs79E2OsWmiEdB+ZzN3xKVbDrUK9paVPEn914r1k zlVQ== X-Gm-Message-State: AOAM531zKjV8aOkdKEnCwUgP1DtUy42Lfrs6tsYL6sUnvg9q5+4Th1kV s73O4Wo6ZIAhITjj9nSQg7/IqQ== X-Received: by 2002:a6b:da03:: with SMTP id x3mr2259297iob.127.1613140451517; Fri, 12 Feb 2021 06:34:11 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id j12sm4387878ila.75.2021.02.12.06.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 06:34:11 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 5/5] net: ipa: introduce gsi_channel_initialized() Date: Fri, 12 Feb 2021 08:34:02 -0600 Message-Id: <20210212143402.2691-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210212143402.2691-1-elder@linaro.org> References: <20210212143402.2691-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Create a simple helper function that indicates whether a channel has been initialized. This abstacts/hides the details of how this is determined. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 9c977f80109a9..390d3403386aa 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -175,6 +175,12 @@ static u32 gsi_channel_id(struct gsi_channel *channel) return channel - &channel->gsi->channel[0]; } +/* An initialized channel has a non-null GSI pointer */ +static bool gsi_channel_initialized(struct gsi_channel *channel) +{ + return !!channel->gsi; +} + /* Update the GSI IRQ type register with the cached value */ static void gsi_irq_type_update(struct gsi *gsi, u32 val) { @@ -1638,8 +1644,8 @@ static int gsi_channel_setup_one(struct gsi *gsi, u32 channel_id) u32 evt_ring_id = channel->evt_ring_id; int ret; - if (!channel->gsi) - return 0; /* Ignore uninitialized channels */ + if (!gsi_channel_initialized(channel)) + return 0; ret = gsi_evt_ring_alloc_command(gsi, evt_ring_id); if (ret) @@ -1675,8 +1681,8 @@ static void gsi_channel_teardown_one(struct gsi *gsi, u32 channel_id) struct gsi_channel *channel = &gsi->channel[channel_id]; u32 evt_ring_id = channel->evt_ring_id; - if (!channel->gsi) - return; /* Ignore uninitialized channels */ + if (!gsi_channel_initialized(channel)) + return; netif_napi_del(&channel->napi); @@ -1770,8 +1776,8 @@ static int gsi_channel_setup(struct gsi *gsi) while (channel_id < GSI_CHANNEL_COUNT_MAX) { struct gsi_channel *channel = &gsi->channel[channel_id++]; - if (!channel->gsi) - continue; /* Ignore uninitialized channels */ + if (!gsi_channel_initialized(channel)) + continue; ret = -EINVAL; dev_err(gsi->dev, "channel %u not supported by hardware\n", @@ -2089,8 +2095,8 @@ static int gsi_channel_init_one(struct gsi *gsi, /* Inverse of gsi_channel_init_one() */ static void gsi_channel_exit_one(struct gsi_channel *channel) { - if (!channel->gsi) - return; /* Ignore uninitialized channels */ + if (!gsi_channel_initialized(channel)) + return; if (channel->command) ipa_cmd_pool_exit(channel);