From patchwork Wed Nov 25 20:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 332389 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp757655ilb; Wed, 25 Nov 2020 12:45:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw21LoyOpxI8E6zl5UWy920YuABGrPp4iCzSPuo0Nc2t2OI34if2UK4FspI5aQeS9WinJkP X-Received: by 2002:a05:6402:2373:: with SMTP id a19mr5176788eda.212.1606337145334; Wed, 25 Nov 2020 12:45:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606337145; cv=none; d=google.com; s=arc-20160816; b=U+FXjZMd4IoEfpl/nTrc+1Vw41AwoLKEHRIZoAdBUS47nLZZUuztNruOvJoQevCNjQ CA6seJsYyOzkuHS4zQ97eb1D0JE3/Gu8xiGliIzRmnEqoF2JnmOMX13UBn1xA9UKm09/ WbW7hCg/r5fG3aFeu7LBkRsmE/J7gZrB94ZxDzQrmg4RGyH6nyxwgAOJde47lzO/dfyn 44HdJPDLjDdys6QXZ+fdEG/OOtrn0b1ZjwXHuOcHwMPVc8OFqy7eW7vUJ4wmGaaBciaR yfP0ECs/Bq61O1JdOHOM0zvsGbAliIX2vAGHmMC2Zgl4tOYGDYtk5Bz6CV8fW4+GlJU2 3a9A== 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=/upjsjCvyzOg9GBdsHQFUu14Ofl+KQlS4nrUSr/KaPg=; b=yey+4QIridzTUyWsovbo3dhpG6GZ+Y0whN/CwgPAOGxR10bWhbTYMeup4KGlADZhRd qa9c6jCFaPLJQzy1lloBexSvVF7dmfa/OciiSRsZ7fMY30zqPlV+LN9wd3sOpUfURlAU dAXNWza1CwrhFh6uC2OPGhVWVjELm/YKLY5YmJYyxoX7hycpGO/YcedrfUgXYSzmdp8Q DWmFRnuH6DoTFNvvEpKC/JsvkdnNWKY7c8fFMJZPE+B3cUFz2b/pBec7NilOPMcwzM5t x1Z2hCRs/5fXVNomnS+1hvpPbjGow1nwNScnnEElgo0CUAkt44k+IYlhDbjKXXh+m2tT xEBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E+i7WsXm; 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 w10si1886422ejc.434.2020.11.25.12.45.45; Wed, 25 Nov 2020 12:45:45 -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=E+i7WsXm; 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 S1730593AbgKYUph (ORCPT + 8 others); Wed, 25 Nov 2020 15:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730411AbgKYUpg (ORCPT ); Wed, 25 Nov 2020 15:45:36 -0500 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E13AC061A54 for ; Wed, 25 Nov 2020 12:45:36 -0800 (PST) Received: by mail-il1-x142.google.com with SMTP id p5so1869329iln.8 for ; Wed, 25 Nov 2020 12:45: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=/upjsjCvyzOg9GBdsHQFUu14Ofl+KQlS4nrUSr/KaPg=; b=E+i7WsXm6Y7oURsktvENeeZaTN4Ztia3P6CWNkL6EakTOis82LfETd3aOphBHLPmRR gIMAp8PRpCVrxxZi7WRQPeFdx7CDAbyAoNdMnh1ZwIIohok0OVh4q7Ugq0ROJVDvxaBG fn4mhBGs8rMaHey2HCywjLks6IvJvvBsbEeJ7PbJav7B069LvoBeQtguiHa4w+h0vUcf rwM7EXQV8+PsIJiB/4vNVZTaazetpsUaVrVkkOBDvIftp5qWF210KuUpTcAgy0UkgI2y ElHoNreosnqIhFsh0k+lU71O22011xUm6YaBDkrF89Zu/Gxkb0M9S3P0Ppo0TkZzER8j RaeQ== 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=/upjsjCvyzOg9GBdsHQFUu14Ofl+KQlS4nrUSr/KaPg=; b=eSESJiUK84RlHyilYl5+/svLjIJYLHKdNsegZr6/znUgG5A9tIF6OyzzYn+hh7tVHy Ro+D/2kdqHlhT6tRYSqEyPidne/nTQQfN6MPaCIxyT9uG0RbqPtBJY4o226kk48dCWrR Hm8tRJ0xQm7qzavSAzsgePtr3NFaZw/pu4U0ObRGqKSOqk2ed/KoRhmIr+E+Hsmg6aKK 529sZ5ed7HQ0aMUfQDEHk3RgZw3wDGkb0/Os87fOtURwrbHHd55aCFooSLudo58RmjST TkDTt+pARDhecVQq75V8jMkxtKgSWAMVEY0UuHcJYTXSfNXOhfl3i5oehk2msvDguJQ2 5eAQ== X-Gm-Message-State: AOAM531cNcQkK74jrjIKHNrC8TqhyII+yLiRO7WROpdR1K787lb7SZRD k7ycKkoOzOMi+daLNV7pdCVoKSjQT82KAQ== X-Received: by 2002:a92:cc90:: with SMTP id x16mr1650255ilo.153.1606337135398; Wed, 25 Nov 2020 12:45: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 n10sm1462225iom.36.2020.11.25.12.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:34 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/6] net: ipa: adjust GSI register addresses Date: Wed, 25 Nov 2020 14:45:22 -0600 Message-Id: <20201125204522.5884-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201125204522.5884-1-elder@linaro.org> References: <20201125204522.5884-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The offsets for almost all GSI registers we use have different offsets starting at IPA version 4.5. Only two registers remain in their original location. In a way though, the new register locations are not *that* different. The entire group of affected registers has simply been shifted down in memory by a fixed amount (0xd000). So for example, the channel context 0 register that has a base offset of 0x0001c000 for "older" hardware now has a base offset of 0x0000f000. This patch aims to add support for IPA v4.5 registers at their new offets in a way that minimizes the amount of code that needs to change. It is not ideal, but it avoids the need to maintain a nearly complete set of additional register offset definitions. The approach takes advantage of the fact that when accessing GSI registers we do not access any of memory at lower end of the "gsi" memory range (with two exceptions already noted). In particular, we do not access anything within the bottom 0xd000 bytes of the GSI memory range. For IPA version 4.5, after we map the GSI memory, we adjust the virtual memory pointer downward by the fixed amount (0xd000). That way, register accesses using the offsets defined by the existing GSI_REG_*() macros will resolve to the proper locations for IPA version 4.5. The two registers *not* affected by this offset are accessed only in gsi_irq_setup(). There, for IPA version 4.5, we undo the general register adjustment by adding the fixed amount back to the virtual address to access these registers. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 21 +++++++++++++++++++-- drivers/net/ipa/gsi_reg.h | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 67e9eb8fe3293..c4795249719d4 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -195,6 +195,8 @@ 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); @@ -203,8 +205,12 @@ static void gsi_irq_setup(struct gsi *gsi) iowrite32(0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); iowrite32(0, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(0, gsi->virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET); - iowrite32(0, gsi->virt + GSI_INTER_EE_SRC_CH_IRQ_OFFSET); - iowrite32(0, gsi->virt + GSI_INTER_EE_SRC_EV_CH_IRQ_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); + iowrite32(0, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET); } @@ -2089,6 +2095,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, struct device *dev = &pdev->dev; struct resource *res; resource_size_t size; + u32 adjust; int ret; gsi_validate_build(); @@ -2115,11 +2122,21 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, return -EINVAL; } + /* Make sure we can make our pointer adjustment if necessary */ + adjust = gsi->version < IPA_VERSION_4_5 ? 0 : GSI_EE_REG_ADJUST; + if (res->start < adjust) { + dev_err(dev, "DT memory resource \"gsi\" too low (< %u)\n", + adjust); + return -EINVAL; + } + gsi->virt = ioremap(res->start, size); if (!gsi->virt) { dev_err(dev, "unable to remap \"gsi\" memory\n"); return -ENOMEM; } + /* Adjust register range pointer downward for newer IPA versions */ + gsi->virt -= adjust; init_completion(&gsi->completion); diff --git a/drivers/net/ipa/gsi_reg.h b/drivers/net/ipa/gsi_reg.h index 2aea17f8f5c4e..0e138bbd82053 100644 --- a/drivers/net/ipa/gsi_reg.h +++ b/drivers/net/ipa/gsi_reg.h @@ -38,6 +38,17 @@ * (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. + * + * 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. + */ +#define GSI_EE_REG_ADJUST 0x0000d000 /* IPA v4.5+ */ + #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) \