From patchwork Thu Feb 11 21:19:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 381045 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2418223jah; Thu, 11 Feb 2021 13:21:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdsmSpe53ekYkAwuGS6YacVF3W9xAz4vDGKhTvI2tmNJsonfB5yCtDE8WqOpVhtmKD0V2T X-Received: by 2002:aa7:d3c7:: with SMTP id o7mr81438edr.23.1613078495991; Thu, 11 Feb 2021 13:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613078495; cv=none; d=google.com; s=arc-20160816; b=QRX6e0KYzLav5fAYDAE23iuuxtqw1ZgcW18Au9zTZYlLUo0uqCm7nQrQD+yeMbpA3O Pn002AJ/ThUl/HWVqmevOgagDNmf0OkHe8jste0asmbjvVbYBQRLkBnPUyCgSbdIkwZS bTYGHMeJjO5q/Pw7hrX6XKsaAj1L6dhJqAHTinNXHs5Ota+aKkeAiN4oFX+HZngtbKxM i7KkUoadQL+i1oi6l/xu4XLFgdzwXYy5wrKBysYuFRgzTAlVJVoRm631QZ17aX4a0aEJ laX1uu6hfeEJolzpmLyqHCBWR4gQbcEUPxkx+zyXV9iQ3yd9WcljQcZ72h4xueOsi+zg sXtg== 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=UgxRMzw4i04XPcEpk6Pwdj0vw8YRReeHuRbWMth6T24=; b=hJ47XHz+VuCvsOMPfny2XaabkHTT86N5ZEohXKjWf0OeKQPskKUVLIt+xdeSiChxBa UsTTMU/8NagYYHq/Sl5gfbBT6WMQVb/vsABdPXqXdn3JXCDJLQBWrv3umuAWsUOZFHgt nPA7gv4jjW9cAwDJCmw1aP0DTZzz7ysJOA/eCR5BUxpEGvmEE8OBres6sZOH4516WAzB U0/SQUm2FQ1nsxP3MgQEWt3tmlxdLPfjch84zgzaTFPRUzUgc3FuK0jtcHP9SeunZafp qYbxtrI6PnLeK2OHSVpWDRKcmOQGNYISCpCksX+froO+dj4olc4zaSbtknciAcedSHp1 A/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sXljozMV; 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 d4si4647314edo.136.2021.02.11.13.21.35; Thu, 11 Feb 2021 13:21: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=sXljozMV; 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 S229903AbhBKVUU (ORCPT + 9 others); Thu, 11 Feb 2021 16:20:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbhBKVUN (ORCPT ); Thu, 11 Feb 2021 16:20:13 -0500 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 B10E6C061786 for ; Thu, 11 Feb 2021 13:19:32 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id u8so7191715ior.13 for ; Thu, 11 Feb 2021 13:19:32 -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=UgxRMzw4i04XPcEpk6Pwdj0vw8YRReeHuRbWMth6T24=; b=sXljozMVw9karaASbIfCqpA2FFP0rM8OpWYwHcthUJbS+1NEwgjN9urvuFBpZP8bhW 3uDAOYhdaAhZ3LOgyMFdYdONdrB1eVdgUDqROhrqbd8KUhxU8lAkPAlQHwl0J/XPxMSL lTcDj9C0gevHOarZASkM+KeFDMXEYS6q90Ht0EIWSP7AweDRVcn4Ji22woYJt1Ymt8Pb KQ5IXPcO9AR4KwWcBNiwXwa2H+KxHHNZ1sl2kKcqSEg4uPFs6yu/Om3BOHVBM1GgQyEI Bzjr5FiLyuLXkttAUjND+vxryHlMeaWNu05EM7JKdwOk5iTynPGww1kaLVit0Ywy+kUP 9I5A== 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=UgxRMzw4i04XPcEpk6Pwdj0vw8YRReeHuRbWMth6T24=; b=szSXMKemWJGIREysmK2cewGL+s6szfDcDJl26c4C22SyNcY7L3fyd56OUmT1uum9a3 k7efnUjsP4YSr0F5zL3uAIA1WTBaaCR3IWvc44ZzNYazOZEcoYpEkTs7F40PBtIWH17a lutqdSDXfrGHURT9I9x0W5CGZDIQoPOLZFh/fC/aiPTStMTOdiba48TYHcCGlZj8eCdn D/nSUPpFckxRTwnBAcmDQ3wdXMUJxigdBtZVnmQ55onIVK1e1mFqOEvGI88NCxZlpaDd j2AvgFbyzhQKBR7pfP4ilmAEmU1J09KZj/0qNxaeIX8dAIMQ9RVNl+sP3y9qopOCn0dT rWBQ== X-Gm-Message-State: AOAM530FYYwr8rMDBP5EEEl3gZM9DQ3fUXrHIlo5upImMwaJaSztnwQI ZELuSMan5PkpXVBqQ5+LISX4HA== X-Received: by 2002:a6b:f30c:: with SMTP id m12mr7143435ioh.136.1613078371935; Thu, 11 Feb 2021 13:19:31 -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 j10sm3155718ilc.50.2021.02.11.13.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 13:19:31 -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 v2 net-next 1/5] net: ipa: use a separate pointer for adjusted GSI memory Date: Thu, 11 Feb 2021 15:19:23 -0600 Message-Id: <20210211211927.28061-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211211927.28061-1-elder@linaro.org> References: <20210211211927.28061-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 --- 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 Thu Feb 11 21:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 381046 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2418238jah; Thu, 11 Feb 2021 13:21:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGdn6v3SvFVORBZNiwO8ySEl5dHPO6hg0aA+6HrdO6lUJAAbdWyh0QWFigivZMr7s7epa1 X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr10375021ejc.408.1613078496865; Thu, 11 Feb 2021 13:21:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613078496; cv=none; d=google.com; s=arc-20160816; b=rLWiCpWGfrj0+J45ATqBdW0gKvWA76c6WhAlpFxt0r5hraoh2cIGprS/I+PYDUoV3+ IDXxL3BTAm6zlgI+3QUmgg7WJ8UlFEhnYQOmM7ieZFJ1oHcqHeZFPDFT4V60GqJGVQMn 98PZL/M/Zcv3jDtmYFOjRr7PMzFHex43ulgkSXVAaTrs4j7s0QdH4/qfzU5VZTEE7KxO HEC1izzEKJzGXCfQhG+NhVDIcvl+52XTWgB824pxDx8v4x4Gagr13VA331rzQu186D4l VfbI5WZUhQk4zuIzVA8W9NKX3CLZhL0aIp7XHXJno0itzCxeKC7NIyd3R9gIYUKwD8kf SpDA== 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=cH4qjKY0CS8cPWsSWSIfB/XmNwAKP+9ETXOQq1WP0+o=; b=qfYZ6cID/FSjy61xMKMkV3/PJG8AEco4Iav/rLFUBBSr0uE3vDvpliTXLE+Nikx0Aa /5ZoTg0nq7K8kCkwWYPnP8/SNAnLytCow83WKA2t5d02uqSbKYiLEDmUFdK4o1HaWado qLsdo+sjMDzur/IQqAlA76pJmL7fdaDHRMivN62Pdhpzzdsz7biblJ5Tp8i6z47QgoQN jIgD6nArgijShwpaIQNsYp/Dt3i8LjuuBLUVSEfrhTZHNftxqnhsY8Qz8gKnAozeRh3I SUSlmO5AhCe2RM3zLM3RsGogrmIRfVAej5fSywiMMFg78uf65h5Pmo3YQHgWELqxPpdK 4Pog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j2q608rJ; 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 d4si4647314edo.136.2021.02.11.13.21.36; Thu, 11 Feb 2021 13:21:36 -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=j2q608rJ; 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 S229946AbhBKVUq (ORCPT + 9 others); Thu, 11 Feb 2021 16:20:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhBKVUd (ORCPT ); Thu, 11 Feb 2021 16:20:33 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A56C06178A for ; Thu, 11 Feb 2021 13:19:33 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id u8so7191771ior.13 for ; Thu, 11 Feb 2021 13:19:33 -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=cH4qjKY0CS8cPWsSWSIfB/XmNwAKP+9ETXOQq1WP0+o=; b=j2q608rJJFE+nLbZ3vJpb510PbN918XLbfooaDSSYI6GuTE/UF93JfR3B5LwQTTFxP 7veyTPNG6WRMMoLkm3oRjH1H8GMiyfjIuXV68XJfnlvu2Yk6ZkPOGUHJE1zJJXO3zhy6 348tcI0DbxjG/x/fQ4SMH8YV45JrB1DoOqXjnLmuPF+C9LYsYZMhxWfmisg0SAfBMM4Z nfpOq+2e/8jPHlRg2CyTSqBcNUoe8LO3yFnmem4ThMfYzc+FGm0GyS9kelhApIj3OZrS n3Ms5UHmi3qqwdQ+UR8SGL8qpZ+1cFsancrcl33ePmMVBAQWzp6kzlX8ho+b3HtVOUjW G9qw== 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=cH4qjKY0CS8cPWsSWSIfB/XmNwAKP+9ETXOQq1WP0+o=; b=a06neAbcMZHlN7sXrODD/g6pnHq0rhSDSCmM5xH/Owk3Wu3Dk3wsaeaH9MqkfQuGjH NBhNjL3nTXCNjGz0ZsBmkoI48S5aDdzzHYbcSsUk+6Y8w22xuRCgW2R+s+GNEI9eTAYG FTR5/miMOxB69WR0iqbZUS8m6AULR27vrEehAaSQivpS9iHkdoPJmGBbeZvdajWP0SV9 4pn1H2KNj3G1dih+QK0ZBuNgW7hps0Ef0S7qvX8dV/fuJVZ+fgdUK4pfrv3xX3EmTJD/ O5tIGcyd2wZfdnucj5aF0Bl/YjfGgYUiW6X1P12eeHr1Gd6ugycKamf10JFRfraWRyob hiwQ== X-Gm-Message-State: AOAM532091OlS7KlR/YSg23o7SVm05a6E/GmTtqylrrqQdYfRwMXnQ0S HhYLv68Zop7Q30lsLAOPmt+38Q== X-Received: by 2002:a5e:9409:: with SMTP id q9mr7011153ioj.54.1613078372886; Thu, 11 Feb 2021 13:19:32 -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 j10sm3155718ilc.50.2021.02.11.13.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 13:19:32 -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 v2 net-next 2/5] net: ipa: don't report EPROBE_DEFER error Date: Thu, 11 Feb 2021 15:19:24 -0600 Message-Id: <20210211211927.28061-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211211927.28061-1-elder@linaro.org> References: <20210211211927.28061-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. Check the return code when initializing these, and if it's EPROBE_DEFER, skip printing the error message. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 354675a643db5..238a713f6b604 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,9 @@ 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); + if (ret != -EPROBE_DEFER) + dev_err(dev, "error %d getting %s interconnect\n", ret, + data->name); return ret; } @@ -281,7 +282,10 @@ 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)); + ret = PTR_ERR(clk); + if (ret != -EPROBE_DEFER) + dev_err(dev, "error %d getting core clock\n", ret); + return ERR_CAST(clk); } From patchwork Thu Feb 11 21:19:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 381047 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2418255jah; Thu, 11 Feb 2021 13:21:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmBEXJ4UM05i4ghj1jFwB/yw7raqCRt+7Q3EkR43njfnhoCgMK3lt9deGB7vXoz7+eYcqX X-Received: by 2002:aa7:d297:: with SMTP id w23mr66395edq.173.1613078498013; Thu, 11 Feb 2021 13:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613078498; cv=none; d=google.com; s=arc-20160816; b=AcAfGXgX9BQxJZIX1TbpQof9PW8153vIdzU3EmonUo1fsfe913CGCaboXb2mRbO0Wl Xl7xfwk7V+w6jJqDZp3g0qwYltJ8r1TNE6uzzpW2sIt+fyCPhLfYZW8637x7MFBAmUyb LUSkwGoLB9tky2znjORTGwp3Q/nITDF6Fqj0Qpr0FUnnO8tN9l6SvHxcmCtaL5jl5v7M PaFglwM3ZTwlTHMo3gEMIWITvJhWHkSI/14uyXPykFdYIawa+FSlqYhzaIUOzpJQy++v hi1ouTMXFJ8PRC4V1PCZOIPSugxqX6HAie0v2vi6usuhT1Zt4nGq9v/rgrJgsfOnuwuT IgVQ== 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=8Qrga60o/lyaLM8rZ05SjxSzhBr8SgrRcVc1JO91zNY=; b=Ntou6NdRyuNqozFzo4w2Qgpy2GVfn/n7cqOg3G1o+046fOagc81OOSk3uxG3uLzQdD 7LhzKT+5telhhb2qSgG0TiqhICC4HNWkEb65V6mMNCU/1CiTbHwh7W7l0Q/00Dc7qwMS a5NNAHi8Vk1DjdtGIfUiXpiasY44bvKpJmxtSEyiaeQ4IIv2sAYRAtiJnavuXafMzK+N BVzfi7etMJqvagnXUFZDaZX91aMnPtVK+DXFVKFc1Kj3iqTc5hfKYLY6eGubc3z1VKwi V8PsdnHHqrks6ars0dDAuJfu/1lghDebhategB6ycToO+s040C0XmMxV7TPhRenjJcl5 C14g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lJxYYFeL; 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 d4si4647314edo.136.2021.02.11.13.21.37; Thu, 11 Feb 2021 13:21:38 -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=lJxYYFeL; 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 S229988AbhBKVVU (ORCPT + 9 others); Thu, 11 Feb 2021 16:21:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhBKVUx (ORCPT ); Thu, 11 Feb 2021 16:20:53 -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 A90FBC061793 for ; Thu, 11 Feb 2021 13:19:34 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id o15so5438716ilt.6 for ; Thu, 11 Feb 2021 13:19:34 -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=8Qrga60o/lyaLM8rZ05SjxSzhBr8SgrRcVc1JO91zNY=; b=lJxYYFeLSvXh8SjWSJ83KiNCbHsmbgYwbUjFxiVKKGQF6Rlo5CNW67Rz6/zxicammH qGn+r9Zrzzfp9lNFWMGnJAZubT8ABGUo9y3qYARNWXfMMhHRHIb35BWs6GcXzwHA3csD 7YcOcpaXDY0iF6bHbdAT1fzR6hyOhfho2k3Lxv7GLERQaIJ3UZDiGU/uGbIjgxI/uOcU +UHKLqEwFE/4Tl/3KhrKln4KvFrQ8HlfqVlYCyEjCz1X179oiZXFatXJFdAqaTXzdsO3 tANwb89LvY3SVIXynhMvxFXt5jwiN8CiMIuL6124HPLD1jnQ+21aw9GJbleHbtY0PAop /OzA== 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=8Qrga60o/lyaLM8rZ05SjxSzhBr8SgrRcVc1JO91zNY=; b=r1YudxlNz+YuI0kEoRUAbLhYTtKlYYSG0b2Shbh7hgJGbKP/1K4n+zc8YU5+TagiyX datgDW1wVODVaYQqHzAl1ovvNQVkv7RcnIeVOKHj8EgIXktH5ZjdFVABt4Q9CTXzOvip WR8OfVu8jB5izXz1m0364oq7ZSEDOLMzvcX6IeeJhxkoYDj3X4CiQuq86/p9ADRn3ulW 49rRXNpGidNOqULwNlYOIf9BgfIjgH5NyinsMr6yab0ULL9BPCBIeuKUC3e+ktUpDuxD KMxVsjkem4VyhmBDIyyBcb9UdduHquIorhcd3CfplXqClMyWOrjDybUTcKOGkyPmm0if 4wlg== X-Gm-Message-State: AOAM531zkbKWWs0gdALMTX+3/r9RSp08iF+ebrWe2n1gCAbPpLPOUfh/ bfEGoXdEFSIjPDnh+UrDPmpzDA== X-Received: by 2002:a92:cb52:: with SMTP id f18mr55476ilq.294.1613078374166; Thu, 11 Feb 2021 13:19:34 -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 j10sm3155718ilc.50.2021.02.11.13.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 13:19:33 -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 v2 net-next 3/5] net: ipa: fix register write command validation Date: Thu, 11 Feb 2021 15:19:25 -0600 Message-Id: <20210211211927.28061-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211211927.28061-1-elder@linaro.org> References: <20210211211927.28061-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 --- 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 Thu Feb 11 21:19:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 381048 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2418293jah; Thu, 11 Feb 2021 13:21:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJz15Rx309RsVI3yhMyiyB44v38Z9M5faRkQIiMGNvvS9kxt8HyNehPlV/c4nniQ0ZI+X0dD X-Received: by 2002:aa7:c901:: with SMTP id b1mr47821edt.329.1613078501578; Thu, 11 Feb 2021 13:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613078501; cv=none; d=google.com; s=arc-20160816; b=DIRl2w9htK+fF7OHS1Mag+fIzobiwP9K5pH5PMx04uCeRNgSIDkpKNo5NTjbc+F8Cx UDiw5EGXyO+pN3VEnsZpbyq9XbqLH8XhCRXEU7QBDI86blAoi58HjT6CWfu3rIVK3TRZ DzSgdQ/nv5yC3XOKyMu2eYBHsajJaAmOoxaGjA9iyrLy71LNIQC49AdOmL77vO84u6kD u7ctDLFanpjsBUaL5kVT8UJLwi2w5+WqABAOcKtAk3rkJxJs84RWmGXfmt5cTWKKt4Ik W7H+cqB5P6bTbdqEOUT8revDc0M/Qg9N8ztIMuEFYJsIgm/+qprLjU12/Ts9BO2w7Yv5 uRPw== 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=IStF8omOtMMIRYTaQJuhUXxte77Gy13HZh8YPRMX9jw=; b=pK58epwwQqQz8P28QU7NfkbQ2xyx6T7VwJBH6Nq52lZ8S8YgTebRCXtUsv/wXnP8pP 18FVhyEsJYC2EkbsyyPjsw7U1qsumR0CJ6Z/pUHwQL0kaPY2s3/3li1gN9R9rDkak5kV J9MZBx5QnkIk9vrp5rnyNDlTRnke8HReINDE6JKb06L07rIITZt2AWjgX2wf13mr3S4l ViQJ6K9AW515Cp0mnSEQYqQWDfy/Ch1m0L+H3TyS/fEoVvY4HMQZSjMBImQB7mn9sB2D wMG5AKNBlm18RX9aGrYvtJx1uDgfU0PBUSK6dN7MvWf1b148k/e/pQML3qfz6ODwxva8 8/NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AaO/WNil"; 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 d4si4647314edo.136.2021.02.11.13.21.41; Thu, 11 Feb 2021 13:21:41 -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="AaO/WNil"; 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 S230003AbhBKVVb (ORCPT + 9 others); Thu, 11 Feb 2021 16:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbhBKVUx (ORCPT ); Thu, 11 Feb 2021 16:20:53 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED69C061797 for ; Thu, 11 Feb 2021 13:19:36 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id u20so7219858iot.9 for ; Thu, 11 Feb 2021 13:19:36 -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=IStF8omOtMMIRYTaQJuhUXxte77Gy13HZh8YPRMX9jw=; b=AaO/WNil1d0IglNbl3EOtwIFStOFY2YUW3SMEvQSQD+OMVyLRPFy9V6y/P7YUPvT13 8OXWvn1FOIzvj/wP8kSMZ3SAHZSVj55fu3estS5ZfZvsNyedgwxNBGz88bS/LXMIINi9 eGVdqchNQv4kiKlVshihBM+9CupkYNlEUVzDLHDq+FEF13WAy3EUZ4DGxaUp7PVJnZ0i 23Fir9SEKbcG799IuMV7vGy+ggQUAHnSTD7/ro/hMnczN/yT1i0O6ILUc7xObuI4qcXC oKOlqKfCQK0ujdSwPtMvT0S2uXhBqwEBEw1DM4BLBfRhPGQBko8klDPodRF5kFxys2z6 zmbw== 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=IStF8omOtMMIRYTaQJuhUXxte77Gy13HZh8YPRMX9jw=; b=Mq5UdSKgdtX7Ko0RJV3Ri+KuCnlDK91+YMpwN0lJXIU3mxXH8y07nd6ppoMcZI1OOH HHcG/183Dr8CL3ljfLeS2JZ7cr7/rSum7quSEUAdg+h1C/CM/UKa35yOdqbSaVuaryBh JK+lqEt//d4v2wDG2eB6/TpdDDnN8SgljS1u3f4GJhRmWsNTXZCSTfTO+JkxOWz79YPx VCDbSOV/ZsPpkf3n8dw3uQW9qRbPmrmuZUBrEF8+lxvf8yGtQ/bH5LN8oe4/MYpvhs8z CgjudUc+3z1/mBVjxBKzQ/z6Gmypeek4f5iKcI7GhH7tXg1KaYhSOS0MgycThcZ3Hjwy s9jg== X-Gm-Message-State: AOAM532QbREDOrYPfOPDDUp6nFBzTSYMlQfNHR8TP+tJqtFFVG5rFzpx Uj/1AXBjSbOFrXnqOvH5/jEU/g== X-Received: by 2002:a5d:8d92:: with SMTP id b18mr7243216ioj.167.1613078375566; Thu, 11 Feb 2021 13:19:35 -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 j10sm3155718ilc.50.2021.02.11.13.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 13:19:34 -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 v2 net-next 4/5] net: ipa: introduce ipa_table_hash_support() Date: Thu, 11 Feb 2021 15:19:26 -0600 Message-Id: <20210211211927.28061-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211211927.28061-1-elder@linaro.org> References: <20210211211927.28061-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 --- 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 Thu Feb 11 21:19:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 381049 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2419164jah; Thu, 11 Feb 2021 13:23:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyMsKFZu84Kh6vVsT9RbzQABcXzBWWyyJesONfpse/4MVFQPwOya5gI8x30pWmPlboW8yA X-Received: by 2002:a17:906:2f07:: with SMTP id v7mr10241360eji.343.1613078597344; Thu, 11 Feb 2021 13:23:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613078597; cv=none; d=google.com; s=arc-20160816; b=v3jWbaXV+hVR0V2wtZkUAZRNqEdm4kHrhMW22je8eYec/XWk0D7jq7zoLoiTQKa3Ig s4j53zcgK+iNe93sRagv19chzp0B8BfOQrCR6h8RS8X35ijdVXS/X9U82OT3Uste79Wr 7FRmRcek/cvhkBUIiI+6NC4dpYa9H2AYQVOPWQldvq2+eRL9wdHfy4y31BJkQEVveLiu sLpDBKfKkAfcX7ZOBYXNRramTZM6ZIF0Nvs/kYJGq8fsjnmNcsd8uuWJs7NkZpBzgnu2 KjFpCPhmm/iwbvdxYcre5RsVyhTJqQzULaf40E91VP8pf5FgxYOjHpvf5NZ33wV0NDsn Qz4Q== 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=Fp5KnlnkY3MqDN+CAyDKKx8bM+HcoMGnJ74VLH7A2RTHlPWzHgU/mrzYmYR0v+09W8 GyjtKmeRSk7UUyALZsanwF+iJk7l7l6abDLnF7D2WQLCpJFzQvrLLdWhvTERizBATey3 iDvwUHZODkHL3sKvEDMJ/DO4n5EUrfBzVNJhR6u0xCWLk8FRrSMulxgzYgorZW87/H4t mgj4d4OrclvnydbfLqrxHezD7QwxUMuhLN3yGlggorub92uRThNdmRUC5W+hIOHR/EGo ljZroQ336pAEIZcu2CPp0dN5OP7/nMeFovn0NsjJMq1Y6LtrGbKu7EG3qN/MpraM5453 ltKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NpUGZf1m; 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 y17si4630711ejh.440.2021.02.11.13.23.16; Thu, 11 Feb 2021 13:23:17 -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=NpUGZf1m; 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 S230019AbhBKVVx (ORCPT + 9 others); Thu, 11 Feb 2021 16:21:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhBKVUz (ORCPT ); Thu, 11 Feb 2021 16:20:55 -0500 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 09D1EC0617A7 for ; Thu, 11 Feb 2021 13:19:37 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id d20so1675423ilo.4 for ; Thu, 11 Feb 2021 13:19:37 -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=NpUGZf1mopmj5Tpd0dM/H7KVszQxZomppQGOYlEOSW+OxA4JhucbdINRb5oHSQKOyO BOknfmz7+CBV8wdqavwRdGTwA8lv1dAroKJHFfAOBq11yIjou6UaOq6LXWIyWOF5r5BN fZfHA/NPdHTS4V4eJ7SUnCq/7AddRliM7B38TaNLOPyamKz0zILcUWvkWfo2ali70tq8 0gubbvzMa8RhyzwhNHvTYfK7PzI9RJyxWBhTw8hGUPPfMZcnG2GNIOnpOZgS9oCOomPM ocrn6oHWvLesVVJvzkEQ44nWRxpv+0Eir0WfokcekXcgXYCc0MKIlgWUYf/xV8VSfDIH yAOA== 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=O9pce4dFobTz5sBxPaSW0tVtrx3OhXzVXXo12wDqWMspjee0IJCPC/um1y++VmOxuD +u+KYJLe5V04pUB83pYjkXSpTwCD0CjVI3CEOZpHPhNbxeane4Gk9XoVoMG6MXph+WW1 2ZBTo1XYx1uHHyhL0+t2+Rb5hZPeIYM46hYDoo7lShkra9wWfIZh+gLrEg5cKvSvNXBI nrlvRgLnPv0BAhXKfKW1ufAxh9nIDjW3BnAvoxu2L3jjntNgvc8iHHi7Ge06oXoytTA7 zw35QU1MFQ2nUwPOsYhjOPrhTn5NEsHl+iKaOdwSx6NaHt7k33kkSI2fYZ/y4PYEdwyG Lkqw== X-Gm-Message-State: AOAM532QkuG6o5aqrGUhAdsR+EhtHXb62DGOrTkoc1m6Bg3fFRejO1JR XRgrd7oQ5ssJwIkoGeG8mRFfjA== X-Received: by 2002:a92:cc03:: with SMTP id s3mr48852ilp.45.1613078376523; Thu, 11 Feb 2021 13:19:36 -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 j10sm3155718ilc.50.2021.02.11.13.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 13:19:36 -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 v2 net-next 5/5] net: ipa: introduce gsi_channel_initialized() Date: Thu, 11 Feb 2021 15:19:27 -0600 Message-Id: <20210211211927.28061-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211211927.28061-1-elder@linaro.org> References: <20210211211927.28061-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);