From patchwork Wed Nov 25 20:45:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1406272 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=u0HuCy0O; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb76nZfz9sVC for ; Thu, 26 Nov 2020 07:45:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730689AbgKYUpo (ORCPT ); Wed, 25 Nov 2020 15:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730564AbgKYUpn (ORCPT ); Wed, 25 Nov 2020 15:45:43 -0500 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BBADC0613D4 for ; Wed, 25 Nov 2020 12:45:30 -0800 (PST) Received: by mail-io1-xd42.google.com with SMTP id z5so2754324iob.11 for ; Wed, 25 Nov 2020 12:45:30 -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=17RumLVAn5UfdPbTYAvhoBEDzwtSfk/5DXo1nQgiciA=; b=u0HuCy0OAdlbZLkbvWbfH0HySruX3gBELz07DNub7sPRF2SqRKpsFLfPgrr3RHfKDA WsBGAKLCl8Z0JP2U5fqURn/F++/0+IT3PLI/gImiT7QK9cN4hcefTAR2k0o09dQr7nQC d4BDhDMfaumwZyyOskhxKKn2E8R0ZM63iG6Hf6s6RFPhDLpeiUV1PcK9IEcw02AlFDD8 Gxl+OTZRM5QXmc7QvdP6DxMd6UjGuHCtoJyaSvAe8VB+aH6LwZs1exkPCx+h2QAB/uf8 eLiGs2b/bi/3lYtbUzHN6B5v/yMg31oXGzpIOZHb/LavKQlYcASu14Gj7Xvr0DdgYGFB 4RdQ== 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=17RumLVAn5UfdPbTYAvhoBEDzwtSfk/5DXo1nQgiciA=; b=VAsk/MO6hWAQ07uMSMo6WjCLUJ/o28rLH5ho73vr6BbdjnqQ4FSHFgxtTh/y8lYVmL zpe6qrMaHhqJQ8YtCnSKZ4Y1qFI3pAg5HxmeZOE7Mj9H4yQZWyEbpyCXqLFl5sxwK7iS 1nMYJZiBvZCLrv1Jp+axc47Z2KdX2pPZV4rLzpxNKhhH0bxOcTeyjYtYk/6tJsrDmNrO CkhpkTL6RNSVo7nPHlh1uUk9U/oubrGfGz/PBqqywUCZ+uY00DvLr4leRmGaBRs7dHgc SZAV/xNqR4WatZJSHEPCXF3HUumtjJUyUzGvz51WqIGzqaylhmkIHONe0N7Cp7kUkCaM 2HgA== X-Gm-Message-State: AOAM532yMunI+HOMzLbdIcWJdLpFgCQWT9xUKO3YLU6biBvTbufiMU84 wAGvhBvtUuIO2h6W8Luy0W6CCw== X-Google-Smtp-Source: ABdhPJyjl3KceJVby0AIGPBUf0JmEZ38DfWuiYVJOOoxL1+6TMRzXZsK3M0A4tI0dYUVcSYEXL3Ccw== X-Received: by 2002:a02:4c8:: with SMTP id 191mr12903jab.70.1606337129858; Wed, 25 Nov 2020 12:45:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:29 -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 1/6] net: ipa: reverse logic on escape buffer use Date: Wed, 25 Nov 2020 14:45:17 -0600 Message-Id: <20201125204522.5884-2-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 Starting with IPA v4.2 there is a GSI channel option to use an "escape buffer" instead of prefetch buffers. This should be used for all channels *except* the AP command TX channel. The logic that implements this has it backwards; fix this bug. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index eb4c5d408a835..2cf10c9f0143d 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -781,8 +781,10 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell) if (gsi->version == IPA_VERSION_3_5_1 && doorbell) val |= USE_DB_ENG_FMASK; - /* Starting with IPA v4.0 the command channel uses the escape buffer */ - if (gsi->version != IPA_VERSION_3_5_1 && channel->command) + /* v4.0 introduces an escape buffer for prefetch. We use it + * on all but the AP command channel. + */ + if (gsi->version != IPA_VERSION_3_5_1 && !channel->command) val |= USE_ESCAPE_BUF_ONLY_FMASK; iowrite32(val, gsi->virt + GSI_CH_C_QOS_OFFSET(channel_id)); From patchwork Wed Nov 25 20:45:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1406268 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Oa3UO47u; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb31kBzz9sSn for ; Thu, 26 Nov 2020 07:45:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730467AbgKYUpc (ORCPT ); Wed, 25 Nov 2020 15:45:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730315AbgKYUpb (ORCPT ); Wed, 25 Nov 2020 15:45:31 -0500 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BA2C0617A7 for ; Wed, 25 Nov 2020 12:45:31 -0800 (PST) Received: by mail-io1-xd44.google.com with SMTP id j23so3461313iog.6 for ; Wed, 25 Nov 2020 12:45:31 -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=7W4Hfj48QORt9DT/Mlo5jKfxl+azWhnxx3x7FeknXPA=; b=Oa3UO47uGKMJpNRpNQg9z+P67uHj7fSzm+twSBtR5KYw4B8KCojmqubhMqVx2zWufB HioVqvLu7jRauZ62xdWaE6uBgpM9kWxv2phnt0gbq7GLn/Vlo5fvkllyljLG3wP4ZYy2 35T7nwvvP8kGQVa+KA5T2wNYFhnkSmoa8Ms0ch0yzDBCg8vRYJT+qagirOHQhQ9n9BR8 6QjcWK7R5sIeEgU9lME15VXN8JU1NfzLfYHqeqDlbCqyxP9lFKaJWZlqPkFbV9ARDBf7 /AsC6YHHqkL2VIxkYtZ27vPcBqmemixheHx0pVBGamom0O5n+xnZFHWRWjgLJlKvNAiC e+Vw== 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=7W4Hfj48QORt9DT/Mlo5jKfxl+azWhnxx3x7FeknXPA=; b=rOk1/FpJpLgRoqMB5gccoYpq2dOm5cNwWmutdOgc6pBjum73Y9j8aOnRsMiKJGeveW F1ar2PZKJdYk4SfgqBcocuUsUI9PxszLwRcIjkv6cUUwCqhByKooj6nXTtmqJ+tfUfCm 7n2MGNiHR9Gq57qDNMZKUtXpEjCHTeesJW++QxSJb2oIWXPa2ThmghivknzANk2o6hZA OBLoez4GVIcUinACiY0p24leILcE+nKqHXtWQWJL+78nq/WKFBqepxAPaPIT+KIb05Qa B4YWR4qu9RGhiVwjFkIm6m47huy5yGRj1C6RCL4UCysuYzUq6P4RSzaprnOA2naw+YGw g/mg== X-Gm-Message-State: AOAM532doccVuDMUAxqWTDCvZsjp2S/cmORQBKMfscGDvXc7/+2O8ZVf nGCa8l7xf3y30IWkwKfVkQHfjA== X-Google-Smtp-Source: ABdhPJzNbXzQ2FdtTSWDFffyBpHGrf3WF5R8+y+9RL+FWJbSq8oKbVYK0MDcHVTyZXLQ6h95lOXXqQ== X-Received: by 2002:a02:70ce:: with SMTP id f197mr347jac.120.1606337130996; Wed, 25 Nov 2020 12:45:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:30 -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 2/6] net: ipa: update IPA registers for IPA v4.5 Date: Wed, 25 Nov 2020 14:45:18 -0600 Message-Id: <20201125204522.5884-3-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 Update "ipa_reg.h" so that register definitions support IPA hardware version 4.5, in addition to versions 3.5.1 through v4.2. Most of the register definitions are the same, but in some cases fields are added, changed, or eliminated. Updates for a few IPA v4.5 registers are more complex, and adding those definition will be deferred to separate patches. This patch only updates the register offset and field definitions, and adds informational comments. The only code change avoids accessing the backward compatibility register for IPA version 4.5 in ipa_hardware_config(). Other IPA v4.5-specific code changes will come later. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 15 +++++++++------ drivers/net/ipa/ipa_reg.h | 36 +++++++++++++++++++++++++++++++++-- drivers/net/ipa/ipa_version.h | 1 + 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index e9bd0d72f2db1..7cd7f6cc05b3c 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -310,14 +310,17 @@ static void ipa_hardware_dcd_deconfig(struct ipa *ipa) */ static void ipa_hardware_config(struct ipa *ipa) { + enum ipa_version version = ipa->version; u32 granularity; u32 val; - /* Fill in backward-compatibility register, based on version */ - val = ipa_reg_bcr_val(ipa->version); - iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); + /* IPA v4.5 has no backward compatibility register */ + if (version < IPA_VERSION_4_5) { + val = ipa_reg_bcr_val(version); + iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); + } - if (ipa->version != IPA_VERSION_3_5_1) { + if (version != IPA_VERSION_3_5_1) { /* Enable open global clocks (hardware workaround) */ val = GLOBAL_FMASK; val |= GLOBAL_2X_CLK_FMASK; @@ -340,8 +343,8 @@ static void ipa_hardware_config(struct ipa *ipa) iowrite32(val, ipa->reg_virt + IPA_REG_COUNTER_CFG_OFFSET); /* IPA v4.2 does not support hashed tables, so disable them */ - if (ipa->version == IPA_VERSION_4_2) { - u32 offset = ipa_reg_filt_rout_hash_en_offset(ipa->version); + if (version == IPA_VERSION_4_2) { + u32 offset = ipa_reg_filt_rout_hash_en_offset(version); iowrite32(0, ipa->reg_virt + offset); } diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index d02e7ecc6fc01..f6ac9884fd326 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -65,12 +65,13 @@ struct ipa; * of valid bits for the register. */ -/* The next field is not supported for IPA v4.1 */ #define IPA_REG_COMP_CFG_OFFSET 0x0000003c +/* The next field is not supported for IPA v4.1 */ #define ENABLE_FMASK GENMASK(0, 0) #define GSI_SNOC_BYPASS_DIS_FMASK GENMASK(1, 1) #define GEN_QMB_0_SNOC_BYPASS_DIS_FMASK GENMASK(2, 2) #define GEN_QMB_1_SNOC_BYPASS_DIS_FMASK GENMASK(3, 3) +/* The next field is not present for IPA v4.5 */ #define IPA_DCMP_FAST_CLK_EN_FMASK GENMASK(4, 4) /* The remaining fields are not present for IPA v3.5.1 */ #define IPA_QMB_SELECT_CONS_EN_FMASK GENMASK(5, 5) @@ -86,6 +87,8 @@ struct ipa; #define GSI_MULTI_AXI_MASTERS_DIS_FMASK GENMASK(15, 15) #define IPA_QMB_SELECT_GLOBAL_EN_FMASK GENMASK(16, 16) #define IPA_ATOMIC_FETCHER_ARB_LOCK_DIS_FMASK GENMASK(20, 17) +/* The next field is present for IPA v4.5 */ +#define IPA_FULL_FLUSH_WAIT_RSC_CLOSE_EN_FMASK GENMASK(21, 21) #define IPA_REG_CLKON_CFG_OFFSET 0x00000044 #define RX_FMASK GENMASK(0, 0) @@ -105,6 +108,7 @@ struct ipa; #define ACK_MNGR_FMASK GENMASK(14, 14) #define D_DCPH_FMASK GENMASK(15, 15) #define H_DCPH_FMASK GENMASK(16, 16) +/* The next field is not present for IPA v4.5 */ #define DCMP_FMASK GENMASK(17, 17) #define NTF_TX_CMDQS_FMASK GENMASK(18, 18) #define TX_0_FMASK GENMASK(19, 19) @@ -119,6 +123,8 @@ struct ipa; #define GSI_IF_FMASK GENMASK(27, 27) #define GLOBAL_FMASK GENMASK(28, 28) #define GLOBAL_2X_CLK_FMASK GENMASK(29, 29) +/* The next field is present for IPA v4.5 */ +#define DPL_FIFO_FMASK GENMASK(30, 30) #define IPA_REG_ROUTE_OFFSET 0x00000048 #define ROUTE_DIS_FMASK GENMASK(0, 0) @@ -174,6 +180,7 @@ static inline u32 ipa_reg_state_aggr_active_offset(enum ipa_version version) return 0x000000b4; } +/* The next register is not present for IPA v4.5 */ #define IPA_REG_BCR_OFFSET 0x000001d0 /* The next two fields are not present for IPA v4.2 */ #define BCR_CMDQ_L_LACK_ONE_ENTRY_FMASK GENMASK(0, 0) @@ -205,6 +212,8 @@ static inline u32 ipa_reg_bcr_val(enum ipa_version version) BCR_HOLB_DROP_L2_IRQ_FMASK | BCR_DUAL_TX_FMASK; + /* assert(version != IPA_VERSION_4_5); */ + return 0x00000000; } @@ -241,6 +250,8 @@ static inline u32 ipa_aggr_granularity_val(u32 usec) #define DMAW_MAX_BEATS_256_DIS_FMASK GENMASK(11, 11) #define PA_MASK_EN_FMASK GENMASK(12, 12) #define PREFETCH_ALMOST_EMPTY_SIZE_TX1_FMASK GENMASK(16, 13) +/* The next field is present for IPA v4.5 */ +#define DUAL_TX_ENABLE_FMASK GENMASK(17, 17) /* The next two fields are present for IPA v4.2 only */ #define SSPND_PA_NO_START_STATE_FMASK GENMASK(18, 18) #define SSPND_PA_NO_BQ_STATE_FMASK GENMASK(19, 19) @@ -253,7 +264,7 @@ static inline u32 ipa_aggr_granularity_val(u32 usec) static inline u32 ipa_reg_idle_indication_cfg_offset(enum ipa_version version) { - if (version == IPA_VERSION_4_2) + if (version >= IPA_VERSION_4_2) return 0x00000240; return 0x00000220; @@ -303,12 +314,14 @@ static inline u32 ipa_resource_group_dst_count(enum ipa_version version) (0x00000400 + 0x0020 * (rt)) #define IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(rt) \ (0x00000404 + 0x0020 * (rt)) +/* The next register is only present for IPA v4.5 */ #define IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(rt) \ (0x00000408 + 0x0020 * (rt)) #define IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(rt) \ (0x00000500 + 0x0020 * (rt)) #define IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(rt) \ (0x00000504 + 0x0020 * (rt)) +/* The next register is only present for IPA v4.5 */ #define IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(rt) \ (0x00000508 + 0x0020 * (rt)) /* The next four fields are used for all resource group registers */ @@ -348,7 +361,11 @@ enum ipa_cs_offload_en { #define HDR_OFST_PKT_SIZE_FMASK GENMASK(25, 20) #define HDR_A5_MUX_FMASK GENMASK(26, 26) #define HDR_LEN_INC_DEAGG_HDR_FMASK GENMASK(27, 27) +/* The next field is not present for IPA v4.5 */ #define HDR_METADATA_REG_VALID_FMASK GENMASK(28, 28) +/* The next two fields are present for IPA v4.5 */ +#define HDR_LEN_MSB_FMASK GENMASK(29, 28) +#define HDR_OFST_METADATA_MSB_FMASK GENMASK(31, 30) #define IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET(ep) \ (0x00000814 + 0x0070 * (ep)) @@ -358,6 +375,10 @@ enum ipa_cs_offload_en { #define HDR_PAYLOAD_LEN_INC_PADDING_FMASK GENMASK(3, 3) #define HDR_TOTAL_LEN_OR_PAD_OFFSET_FMASK GENMASK(9, 4) #define HDR_PAD_TO_ALIGNMENT_FMASK GENMASK(13, 10) +/* The next three fields are present for IPA v4.5 */ +#define HDR_TOTAL_LEN_OR_PAD_OFFSET_MSB_FMASK GENMASK(17, 16) +#define HDR_OFST_PKT_SIZE_MSB_FMASK GENMASK(19, 18) +#define HDR_ADDITIONAL_CONST_LEN_MSB_FMASK GENMASK(21, 20) /* Valid only for RX (IPA producer) endpoints */ #define IPA_REG_ENDP_INIT_HDR_METADATA_MASK_N_OFFSET(rxep) \ @@ -367,10 +388,13 @@ enum ipa_cs_offload_en { #define IPA_REG_ENDP_INIT_MODE_N_OFFSET(txep) \ (0x00000820 + 0x0070 * (txep)) #define MODE_FMASK GENMASK(2, 0) +/* The next field is present for IPA v4.5 */ +#define DCPH_ENABLE_FMASK GENMASK(3, 3) #define DEST_PIPE_INDEX_FMASK GENMASK(8, 4) #define BYTE_THRESHOLD_FMASK GENMASK(27, 12) #define PIPE_REPLICATION_EN_FMASK GENMASK(28, 28) #define PAD_EN_FMASK GENMASK(29, 29) +/* The next register is not present for IPA v4.5 */ #define HDR_FTCH_DISABLE_FMASK GENMASK(30, 30) /** enum ipa_mode - mode field in ENDP_INIT_MODE_N */ @@ -421,6 +445,9 @@ enum ipa_aggr_type { /* The next two fields are present for IPA v4.2 only */ #define BASE_VALUE_FMASK GENMASK(4, 0) #define SCALE_FMASK GENMASK(12, 8) +/* The next two fields are present for IPA v4.5 */ +#define TIME_LIMIT_FMASK GENMASK(4, 0) +#define GRAN_SEL_FMASK GENMASK(8, 8) /* Valid only for TX (IPA consumer) endpoints */ #define IPA_REG_ENDP_INIT_DEAGGR_N_OFFSET(txep) \ @@ -440,6 +467,8 @@ static inline u32 rsrc_grp_encoded(enum ipa_version version, u32 rsrc_grp) switch (version) { case IPA_VERSION_4_2: return u32_encode_bits(rsrc_grp, GENMASK(0, 0)); + case IPA_VERSION_4_5: + return u32_encode_bits(rsrc_grp, GENMASK(2, 0)); default: return u32_encode_bits(rsrc_grp, GENMASK(1, 0)); } @@ -476,6 +505,7 @@ enum ipa_seq_type { (0x00000840 + 0x0070 * (ep)) #define STATUS_EN_FMASK GENMASK(0, 0) #define STATUS_ENDP_FMASK GENMASK(5, 1) +/* The next field is not present for IPA v4.5 */ #define STATUS_LOCATION_FMASK GENMASK(8, 8) /* The next field is not present for IPA v3.5.1 */ #define STATUS_PKT_SUPPRESS_FMASK GENMASK(9, 9) @@ -550,6 +580,8 @@ enum ipa_irq_id { IPA_IRQ_GSI_EE = 0x17, IPA_IRQ_GSI_IPA_IF_TLV_RCVD = 0x18, IPA_IRQ_GSI_UC = 0x19, + /* The next bit is present for IPA v4.5 */ + IPA_IRQ_TLV_LEN_MIN_DSM = 0x1a, IPA_IRQ_COUNT, /* Last; not an id */ }; diff --git a/drivers/net/ipa/ipa_version.h b/drivers/net/ipa/ipa_version.h index 85449df0f5124..2944e2a890231 100644 --- a/drivers/net/ipa/ipa_version.h +++ b/drivers/net/ipa/ipa_version.h @@ -18,6 +18,7 @@ enum ipa_version { IPA_VERSION_4_0, /* GSI version 2.0 */ IPA_VERSION_4_1, /* GSI version 2.1 */ IPA_VERSION_4_2, /* GSI version 2.2 */ + IPA_VERSION_4_5, /* GSI version 2.5 */ }; #endif /* _IPA_VERSION_H_ */ From patchwork Wed Nov 25 20:45:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1406269 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=J1uTYtpg; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb35yJ0z9sRR for ; Thu, 26 Nov 2020 07:45:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730119AbgKYUpd (ORCPT ); Wed, 25 Nov 2020 15:45:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730315AbgKYUpc (ORCPT ); Wed, 25 Nov 2020 15:45:32 -0500 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38CBC0617A7 for ; Wed, 25 Nov 2020 12:45:32 -0800 (PST) Received: by mail-il1-x141.google.com with SMTP id x15so3380548ilq.1 for ; Wed, 25 Nov 2020 12:45: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=8+aZd2Qej8dFIrlKd7njZp3GwtYw6UgJ0cCCsnA9q5s=; b=J1uTYtpglpZu1sHO60gS592G+/VwMfgr0dsYa6v4YwCTxVWnuWL0n9SxC83Ph60XUS QASK/y9OWOdjba1ByegdEz1z7W5fxKfuMk0bOo6cg3ddfb7PPKUeusgSSCv1/+Cb5bBP o4Jhz0wVgAJc8RWrkKJcsKEuy5mCjI3C55gucRbar3zrpnM3KqpHDonHs90Vt9HYyi0p QWc4fx3KI+bf+0pkK8S0KEDOryuqM6oQGozf+CpPvV/9YvJIQUp3axt8BiKH1MFK2Vya ae5pIZckkNMB+evC2Wsb/BcpuCPWmbB3a5EgR7LjpvbgId4oZFyTDDFygc+u6qxRY9Xj AuBw== 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=8+aZd2Qej8dFIrlKd7njZp3GwtYw6UgJ0cCCsnA9q5s=; b=uUv2XCNzfdNLLiu6vKG0t2on3cXzHdAdJftAKo4ENXkhNpJVkzmB4Otf/BNLQBM0Ug olsu247kh1KDja6W7+ZQnMRCO23M3B6FM430wMHPtjTjAL6BzIDhY4yoe4wT3Zyl+jL0 eACemgLxuKs0SzC+0bEkVayUX2/dKyICJ+GdKNlzGPmWmptFnBKoPVUR/4VLSsH8RB1P xeKB7u83hryFRx7MgpJMDbsbI5vRM2ZeNS0qTLBUAJtliu6iIesctQJQRJArz6zbvm8y TEm84Z4G8/iSvyyV68EOLXipi3ajPHQdIYLzUi0nNyLFPvAthz1hPoiIloLmODonkap6 iQgQ== X-Gm-Message-State: AOAM533bCROtWkTVJqUUth8YUjczBWo7Heicx6AOPvWSWDHb8wsovWjg EHtLGLBjgWIrkRFV6zhi6QOHNg== X-Google-Smtp-Source: ABdhPJyDO6vOuf8m3r0eS/nZZ2OT6rb3DvPcZDqwIgt/+Ig+1+r94Irp/WHWG1EvolAqS4XCX1bmYA== X-Received: by 2002:a92:cc92:: with SMTP id x18mr4557726ilo.63.1606337132111; Wed, 25 Nov 2020 12:45: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 n10sm1462225iom.36.2020.11.25.12.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:31 -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 3/6] net: ipa: add new most-significant bits to registers Date: Wed, 25 Nov 2020 14:45:19 -0600 Message-Id: <20201125204522.5884-4-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 IPA v4.5 adds a few fields to the endpoint header and extended header configuration registers that represent new high-order bits for certain offsets and sizes. Add code to incorporate these upper bits into the registers for IPA v4.5. This includes creating ipa_header_size_encoded(), which handles encoding the metadata offset field for use in the ENDP_INIT_HDR register in a way appropriate for the hardware version. This and ipa_metadata_offset_encoded() ensure the mask argument passed to u32_encode_bits() is constant. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 39 ++++++++++++++++++++++++++-------- drivers/net/ipa/ipa_reg.h | 38 +++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 9707300457517..f28ea062aaf1d 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -485,28 +485,34 @@ static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint) static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) { u32 offset = IPA_REG_ENDP_INIT_HDR_N_OFFSET(endpoint->endpoint_id); + struct ipa *ipa = endpoint->ipa; u32 val = 0; if (endpoint->data->qmap) { size_t header_size = sizeof(struct rmnet_map_header); + enum ipa_version version = ipa->version; /* We might supply a checksum header after the QMAP header */ if (endpoint->toward_ipa && endpoint->data->checksum) header_size += sizeof(struct rmnet_map_ul_csum_header); - val |= u32_encode_bits(header_size, HDR_LEN_FMASK); + val |= ipa_header_size_encoded(version, header_size); /* Define how to fill fields in a received QMAP header */ if (!endpoint->toward_ipa) { - u32 off; /* Field offset within header */ + u32 offset; /* Field offset within header */ /* Where IPA will write the metadata value */ - off = offsetof(struct rmnet_map_header, mux_id); - val |= u32_encode_bits(off, HDR_OFST_METADATA_FMASK); + offset = offsetof(struct rmnet_map_header, mux_id); + val |= ipa_metadata_offset_encoded(version, offset); /* Where IPA will write the length */ - off = offsetof(struct rmnet_map_header, pkt_len); + offset = offsetof(struct rmnet_map_header, pkt_len); + /* Upper bits are stored in HDR_EXT with IPA v4.5 */ + if (version == IPA_VERSION_4_5) + offset &= field_mask(HDR_OFST_PKT_SIZE_FMASK); + val |= HDR_OFST_PKT_SIZE_VALID_FMASK; - val |= u32_encode_bits(off, HDR_OFST_PKT_SIZE_FMASK); + val |= u32_encode_bits(offset, HDR_OFST_PKT_SIZE_FMASK); } /* For QMAP TX, metadata offset is 0 (modem assumes this) */ val |= HDR_OFST_METADATA_VALID_FMASK; @@ -517,13 +523,14 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) /* HDR_METADATA_REG_VALID is 0 (TX only) */ } - iowrite32(val, endpoint->ipa->reg_virt + offset); + iowrite32(val, ipa->reg_virt + offset); } static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint) { u32 offset = IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET(endpoint->endpoint_id); u32 pad_align = endpoint->data->rx.pad_align; + struct ipa *ipa = endpoint->ipa; u32 val = 0; val |= HDR_ENDIANNESS_FMASK; /* big endian */ @@ -545,9 +552,23 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint) if (!endpoint->toward_ipa) val |= u32_encode_bits(pad_align, HDR_PAD_TO_ALIGNMENT_FMASK); - iowrite32(val, endpoint->ipa->reg_virt + offset); -} + /* IPA v4.5 adds some most-significant bits to a few fields, + * two of which are defined in the HDR (not HDR_EXT) register. + */ + if (ipa->version == IPA_VERSION_4_5) { + /* HDR_TOTAL_LEN_OR_PAD_OFFSET is 0, so MSB is 0 */ + if (endpoint->data->qmap && !endpoint->toward_ipa) { + u32 offset; + offset = offsetof(struct rmnet_map_header, pkt_len); + offset >>= hweight32(HDR_OFST_PKT_SIZE_FMASK); + val |= u32_encode_bits(offset, + HDR_OFST_PKT_SIZE_MSB_FMASK); + /* HDR_ADDITIONAL_CONST_LEN is 0 so MSB is 0 */ + } + } + iowrite32(val, ipa->reg_virt + offset); +} static void ipa_endpoint_init_hdr_metadata_mask(struct ipa_endpoint *endpoint) { diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index f6ac9884fd326..7d10fa6dcbec1 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -367,6 +367,40 @@ enum ipa_cs_offload_en { #define HDR_LEN_MSB_FMASK GENMASK(29, 28) #define HDR_OFST_METADATA_MSB_FMASK GENMASK(31, 30) +/* Encoded value for ENDP_INIT_HDR register HDR_LEN* field(s) */ +static inline u32 ipa_header_size_encoded(enum ipa_version version, + u32 header_size) +{ + u32 val; + + val = u32_encode_bits(header_size, HDR_LEN_FMASK); + if (version < IPA_VERSION_4_5) + return val; + + /* IPA v4.5 adds a few more most-significant bits */ + header_size >>= hweight32(HDR_LEN_FMASK); + val |= u32_encode_bits(header_size, HDR_LEN_MSB_FMASK); + + return val; +} + +/* Encoded value for ENDP_INIT_HDR register OFST_METADATA* field(s) */ +static inline u32 ipa_metadata_offset_encoded(enum ipa_version version, + u32 offset) +{ + u32 val; + + val = u32_encode_bits(offset, HDR_OFST_METADATA_FMASK); + if (version < IPA_VERSION_4_5) + return val; + + /* IPA v4.5 adds a few more most-significant bits */ + offset >>= hweight32(HDR_OFST_METADATA_FMASK); + val |= u32_encode_bits(offset, HDR_OFST_METADATA_MSB_FMASK); + + return val; +} + #define IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET(ep) \ (0x00000814 + 0x0070 * (ep)) #define HDR_ENDIANNESS_FMASK GENMASK(0, 0) @@ -461,7 +495,7 @@ enum ipa_aggr_type { #define IPA_REG_ENDP_INIT_RSRC_GRP_N_OFFSET(ep) \ (0x00000838 + 0x0070 * (ep)) -/* Encoded value for RSRC_GRP endpoint register RSRC_GRP field */ +/* Encoded value for ENDP_INIT_RSRC_GRP register RSRC_GRP field */ static inline u32 rsrc_grp_encoded(enum ipa_version version, u32 rsrc_grp) { switch (version) { @@ -492,7 +526,7 @@ static inline u32 rsrc_grp_encoded(enum ipa_version version, u32 rsrc_grp) * @IPA_SEQ_INVALID: invalid sequencer type * * The values defined here are broken into 4-bit nibbles that are written - * into fields of the INIT_SEQ_N endpoint registers. + * into fields of the ENDP_INIT_SEQ registers. */ enum ipa_seq_type { IPA_SEQ_DMA_ONLY = 0x0000, From patchwork Wed Nov 25 20:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1406273 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cykW1InN; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb94HmTz9sVC for ; Thu, 26 Nov 2020 07:45:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730802AbgKYUpr (ORCPT ); Wed, 25 Nov 2020 15:45:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730564AbgKYUpq (ORCPT ); Wed, 25 Nov 2020 15:45:46 -0500 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A35C0617A7 for ; Wed, 25 Nov 2020 12:45:33 -0800 (PST) Received: by mail-io1-xd43.google.com with SMTP id t8so3456968iov.8 for ; Wed, 25 Nov 2020 12:45: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=vgQIyqQ0Um3ZJgnU52iyAduH0hQXWjJaT01kfmpRZ1w=; b=cykW1InNnzn0FJ7YHyJ5w9LnX9P6Jisz22B/CjBPz96PCnTW0z/EWQS6T+e+slkySM x//75t618tCM6O1Dic/y/eclszBaQox9ZuKtzkvRTQS+Q3tPiUPyad35iCrf8nFq2NQH 2uQHk5ebMZcAriBf7KRpcP5KGBbA+DbfaXCV5MojFcS79RzKISl31yqzwpEGhrrrRv1x 23XlYpCAEPvhuQXlzLvWMQt5ZI32Xu+uBtc2eVgj9aC7ZInwnBCF7bfw9ZOHVbylX7zB b1cjBv6SxgUvU44Fe8esasbKrqNYwzMMts5SQKcD8N9pcC8nB0ffkZJBP2RFxwlSlPcV 8QfA== 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=vgQIyqQ0Um3ZJgnU52iyAduH0hQXWjJaT01kfmpRZ1w=; b=Ow1nSGdmoMnnxNKoW5WbXwB63d+ik/KOOR/h0vux9YIrbhg0JjxecFlDtENhmv2fxk jTji2e99rc1v1x7gITLVu5hAp4DJ4AvEYSd5jJzGaUP1FQdg3CZR1AbhIKVqdrWV3v8E p98PAuoeZknl1pyysqt+kbKRO77G5rwVp4jbSgC6YOokZXReHx2wmeVIxJZoKLf2LtT4 lXN+D7KzyPxKSgmaz31WPTh3Tv9DSamCM1edKGCBbde7eUZBiQXsrfI3nObBh4gGKP7U b/8h8w1ulNecCY+YazBrl6sKdKNVNAlulgIBKq8aHvP6SjtxsasFdBBz3myssWry+jNn hiHg== X-Gm-Message-State: AOAM530Wr6sE1p/67a1v7M0d5krCnd6tjDeCVnIZOGf/szA+PNJvHM+f 7aNkbdbCV8u7aaTk3RFBb/dUNg== X-Google-Smtp-Source: ABdhPJzaSO0tBzGKBG4D5tHvPAhQ/Cj/2pCIjLOO6OaDjf8r2AzN23+161nxY6QKNd6Fy+fvVA0XEw== X-Received: by 2002:a5e:df03:: with SMTP id f3mr4267216ioq.182.1606337133201; Wed, 25 Nov 2020 12:45:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:32 -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 4/6] net: ipa: add support to code for IPA v4.5 Date: Wed, 25 Nov 2020 14:45:20 -0600 Message-Id: <20201125204522.5884-5-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 Update the IPA code to make use of the updated IPA v4.5 register definitions. Generally what this patch does is, if IPA v4.5 hardware is in use: - Ensure new registers or fields in IPA v4.5 are updated where required - Ensure registers or fields not supported in IPA v4.5 are not examined when read, or are set to 0 when written It does this while preserving the existing functionality for IPA versions lower than v4.5. The values to program for QSB_MAX_READS and QSB_MAX_WRITES and the source and destination resource counts are updated to be correct for all versions through v4.5 as well. Note that IPA_RESOURCE_GROUP_SRC_MAX and IPA_RESOURCE_GROUP_DST_MAX already reflect that 5 is an acceptable number of resources (which IPA v4.5 implements). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 10 +++--- drivers/net/ipa/ipa_main.c | 63 ++++++++++++++++++++++++---------- drivers/net/ipa/ipa_reg.h | 7 ++++ 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index f28ea062aaf1d..27f543b6780b1 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -520,7 +520,7 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint) /* HDR_ADDITIONAL_CONST_LEN is 0; (RX only) */ /* HDR_A5_MUX is 0 */ /* HDR_LEN_INC_DEAGG_HDR is 0 */ - /* HDR_METADATA_REG_VALID is 0 (TX only) */ + /* HDR_METADATA_REG_VALID is 0 (TX only, version < v4.5) */ } iowrite32(val, ipa->reg_virt + offset); @@ -655,6 +655,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint) /* other fields ignored */ } /* AGGR_FORCE_CLOSE is 0 */ + /* AGGR_GRAN_SEL is 0 for IPA v4.5 */ } else { val |= u32_encode_bits(IPA_BYPASS_AGGR, AGGR_EN_FMASK); /* other fields ignored */ @@ -865,9 +866,10 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint) val |= u32_encode_bits(status_endpoint_id, STATUS_ENDP_FMASK); } - /* STATUS_LOCATION is 0 (status element precedes packet) */ - /* The next field is present for IPA v4.0 and above */ - /* STATUS_PKT_SUPPRESS_FMASK is 0 */ + /* STATUS_LOCATION is 0, meaning status element precedes + * packet (not present for IPA v4.5) + */ + /* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v3.5.1) */ } iowrite32(val, ipa->reg_virt + offset); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 7cd7f6cc05b3c..f25bcfe51dd4b 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -230,8 +230,10 @@ static void ipa_hardware_config_comp(struct ipa *ipa) val &= ~IPA_QMB_SELECT_CONS_EN_FMASK; val &= ~IPA_QMB_SELECT_PROD_EN_FMASK; val &= ~IPA_QMB_SELECT_GLOBAL_EN_FMASK; - } else { + } else if (ipa->version < IPA_VERSION_4_5) { val |= GSI_MULTI_AXI_MASTERS_DIS_FMASK; + } else { + /* For IPA v4.5 IPA_FULL_FLUSH_WAIT_RSC_CLOSE_EN is 0 */ } val |= GSI_MULTI_INORDER_RD_DIS_FMASK; @@ -243,25 +245,47 @@ static void ipa_hardware_config_comp(struct ipa *ipa) /* Configure DDR and PCIe max read/write QSB values */ static void ipa_hardware_config_qsb(struct ipa *ipa) { + enum ipa_version version = ipa->version; + u32 max0; + u32 max1; u32 val; - /* QMB_0 represents DDR; QMB_1 represents PCIe (not present in 4.2) */ + /* QMB_0 represents DDR; QMB_1 represents PCIe */ val = u32_encode_bits(8, GEN_QMB_0_MAX_WRITES_FMASK); - if (ipa->version == IPA_VERSION_4_2) - val |= u32_encode_bits(0, GEN_QMB_1_MAX_WRITES_FMASK); - else - val |= u32_encode_bits(4, GEN_QMB_1_MAX_WRITES_FMASK); + switch (version) { + case IPA_VERSION_4_2: + max1 = 0; /* PCIe not present */ + break; + case IPA_VERSION_4_5: + max1 = 8; + break; + default: + max1 = 4; + break; + } + val |= u32_encode_bits(max1, GEN_QMB_1_MAX_WRITES_FMASK); iowrite32(val, ipa->reg_virt + IPA_REG_QSB_MAX_WRITES_OFFSET); - if (ipa->version == IPA_VERSION_3_5_1) { - val = u32_encode_bits(8, GEN_QMB_0_MAX_READS_FMASK); - val |= u32_encode_bits(12, GEN_QMB_1_MAX_READS_FMASK); - } else { - val = u32_encode_bits(12, GEN_QMB_0_MAX_READS_FMASK); - if (ipa->version == IPA_VERSION_4_2) - val |= u32_encode_bits(0, GEN_QMB_1_MAX_READS_FMASK); - else - val |= u32_encode_bits(12, GEN_QMB_1_MAX_READS_FMASK); + max1 = 12; + switch (version) { + case IPA_VERSION_3_5_1: + max0 = 8; + break; + case IPA_VERSION_4_0: + case IPA_VERSION_4_1: + max0 = 12; + break; + case IPA_VERSION_4_2: + max0 = 12; + max1 = 0; /* PCIe not present */ + break; + case IPA_VERSION_4_5: + max0 = 16; + break; + } + val = u32_encode_bits(max0, GEN_QMB_0_MAX_READS_FMASK); + val |= u32_encode_bits(max1, GEN_QMB_1_MAX_READS_FMASK); + if (version != IPA_VERSION_3_5_1) { /* GEN_QMB_0_MAX_READS_BEATS is 0 */ /* GEN_QMB_1_MAX_READS_BEATS is 0 */ } @@ -294,7 +318,7 @@ static void ipa_idle_indication_cfg(struct ipa *ipa, */ static void ipa_hardware_dcd_config(struct ipa *ipa) { - /* Recommended values for IPA 3.5 according to IPA HPG */ + /* Recommended values for IPA 3.5 and later according to IPA HPG */ ipa_idle_indication_cfg(ipa, 256, false); } @@ -320,13 +344,14 @@ static void ipa_hardware_config(struct ipa *ipa) iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET); } - if (version != IPA_VERSION_3_5_1) { - /* Enable open global clocks (hardware workaround) */ + /* Implement some hardware workarounds */ + if (version != IPA_VERSION_3_5_1 && version < IPA_VERSION_4_5) { + /* Enable open global clocks (not needed for IPA v4.5) */ val = GLOBAL_FMASK; val |= GLOBAL_2X_CLK_FMASK; iowrite32(val, ipa->reg_virt + IPA_REG_CLKON_CFG_OFFSET); - /* Disable PA mask to allow HOLB drop (hardware workaround) */ + /* Disable PA mask to allow HOLB drop */ val = ioread32(ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); val &= ~PA_MASK_EN_FMASK; iowrite32(val, ipa->reg_virt + IPA_REG_TX_CFG_OFFSET); diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index 7d10fa6dcbec1..3fabafd7e32c6 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -238,6 +238,7 @@ static inline u32 ipa_aggr_granularity_val(u32 usec) return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1; } +/* The next register is not present for IPA v4.5 */ #define IPA_REG_TX_CFG_OFFSET 0x000001fc /* The first three fields are present for IPA v3.5.1 only */ #define TX0_PREFETCH_DISABLE_FMASK GENMASK(0, 0) @@ -285,6 +286,9 @@ static inline u32 ipa_resource_group_src_count(enum ipa_version version) case IPA_VERSION_4_2: return 1; + case IPA_VERSION_4_5: + return 5; + default: return 0; } @@ -304,6 +308,9 @@ static inline u32 ipa_resource_group_dst_count(enum ipa_version version) case IPA_VERSION_4_2: return 1; + case IPA_VERSION_4_5: + return 5; + default: return 0; } From patchwork Wed Nov 25 20:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1406270 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lD5Wynlj; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb46R2pz9sTc for ; Thu, 26 Nov 2020 07:45:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730548AbgKYUpg (ORCPT ); Wed, 25 Nov 2020 15:45:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730411AbgKYUpf (ORCPT ); Wed, 25 Nov 2020 15:45:35 -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 071EEC061A56 for ; Wed, 25 Nov 2020 12:45:35 -0800 (PST) Received: by mail-il1-x142.google.com with SMTP id f5so3342074ilj.9 for ; Wed, 25 Nov 2020 12:45: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=t+pcUwa8+uX7Gms8sS8CjhzNwaiGwtdff9tVgXS26NI=; b=lD5Wynlj0fgifv8wbn4gAKihh4WsBz9SWasE+bkJ/M3WbDzE1YeIkEclAiC8JcYMIh PCCe+twNA3y3cqyo1Jkq4IDjewzTKMh3gXK6fVkPq9cH6bM2DqP0oi/Jvukcuyzxl3lF 3PneiEIib0I9+lcTCPqN/KajmlAsuDVZ3b8Fd1uERKGxZ3YqVL0T1iU1ZucitNcoYSJ9 knIQjyUvB4O8k0qZ3hPqHgF1q++uhBVVG0q6z0AdotS8xNcz2tu7BPj7FKZdIzF2Phij GVsVDh7X5QMDqDR8+XDt6Mm+OW1AvqLNMeJa5lnCQRlzUYas19RQNzfup/tG29n5dKho ZXcg== 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=t+pcUwa8+uX7Gms8sS8CjhzNwaiGwtdff9tVgXS26NI=; b=lfu3X0A7xlmoO9AODgnw11nANJVG8sxEdRR9G9D146BmFPIRwatyE5EkS2xmoKOWet yzecqXg834o9kfkcMx0btecR9S/SN1Hz+fEK6I/v2EABPLGvEzwRc7zrJH41UK6xfRpL D7Fx9Zp0jChXGnpoP8K5yQ2jAoSJdAmjYDqukjsUaDtSWOawcxQZNpNWdPg1DBH/g+ru yKRpui8n/Q21OZSsW8vbpjHCRLdTsCOP6nUmZQLwsEBF1srMILI5eNudNYpagpaE33rz xDprmOX+egrqganEFwr8si9o+LDJ0N3v0UcOCOnn/33OlT1tJuMZKXzzGWduvKhA+7eJ DRow== X-Gm-Message-State: AOAM531lTp151/m/Strodw0BEvesMrdfTW6w7KAKnHEir9NJ5EYUDvw9 L9J4KAR+EM5/Hk8czyrVt8onhg== X-Google-Smtp-Source: ABdhPJxh/HY/b3nwQzS4NMKwmXzP4GY9lzohhMx8DY+H0i0AXRMGq6vKNJ9ynIwnDbVVYFgMr6CyhQ== X-Received: by 2002:a92:aa04:: with SMTP id j4mr4432219ili.218.1606337134392; Wed, 25 Nov 2020 12:45: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 n10sm1462225iom.36.2020.11.25.12.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:45:33 -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 5/6] net: ipa: update gsi registers for IPA v4.5 Date: Wed, 25 Nov 2020 14:45:21 -0600 Message-Id: <20201125204522.5884-6-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 Very few GSI register definitions change for IPA v4.5, however as a group their position in memory shifts a constant amount (handled by the next commit). Add definitions and update comments to the set of GSI registers to support changes that come with IPA v4.5. Update the logic in gsi_channel_program() to accommodate the new (expanded) PREFETCH_MODE field in the CH_C_QOS register. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 10 ++++++++-- drivers/net/ipa/gsi_reg.h | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 2cf10c9f0143d..67e9eb8fe3293 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -784,8 +784,14 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell) /* v4.0 introduces an escape buffer for prefetch. We use it * on all but the AP command channel. */ - if (gsi->version != IPA_VERSION_3_5_1 && !channel->command) - val |= USE_ESCAPE_BUF_ONLY_FMASK; + if (gsi->version != IPA_VERSION_3_5_1 && !channel->command) { + /* If not otherwise set, prefetch buffers are used */ + if (gsi->version < IPA_VERSION_4_5) + val |= USE_ESCAPE_BUF_ONLY_FMASK; + else + val |= u32_encode_bits(GSI_ESCAPE_BUF_ONLY, + PREFETCH_MODE_FMASK); + } iowrite32(val, gsi->virt + GSI_CH_C_QOS_OFFSET(channel_id)); diff --git a/drivers/net/ipa/gsi_reg.h b/drivers/net/ipa/gsi_reg.h index c1799d1e8a837..2aea17f8f5c4e 100644 --- a/drivers/net/ipa/gsi_reg.h +++ b/drivers/net/ipa/gsi_reg.h @@ -105,6 +105,16 @@ enum gsi_channel_type { #define USE_DB_ENG_FMASK GENMASK(9, 9) /* The next field is only present for IPA v4.0, v4.1, and v4.2 */ #define USE_ESCAPE_BUF_ONLY_FMASK GENMASK(10, 10) +/* The next two fields are present for IPA v4.5 and above */ +#define PREFETCH_MODE_FMASK GENMASK(13, 10) +#define EMPTY_LVL_THRSHOLD_FMASK GENMASK(23, 16) +/** enum gsi_prefetch_mode - PREFETCH_MODE field in CH_C_QOS */ +enum gsi_prefetch_mode { + GSI_USE_PREFETCH_BUFS = 0x0, + GSI_ESCAPE_BUF_ONLY = 0x1, + GSI_SMART_PREFETCH = 0x2, + GSI_FREE_PREFETCH = 0x3, +}; #define GSI_CH_C_SCRATCH_0_OFFSET(ch) \ GSI_EE_N_CH_C_SCRATCH_0_OFFSET((ch), GSI_EE_AP) @@ -287,6 +297,9 @@ enum gsi_iram_size { /* The next two values are available for IPA v4.0 and above */ IRAM_SIZE_TWO_N_HALF_KB = 0x2, IRAM_SIZE_THREE_KB = 0x3, + /* The next two values are available for IPA v4.5 and above */ + IRAM_SIZE_THREE_N_HALF_KB = 0x4, + IRAM_SIZE_FOUR_KB = 0x5, }; /* IRQ condition for each type is cleared by writing type-specific register */ 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: 1406271 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=E+i7WsXm; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4ChCb668q0z9sTc for ; Thu, 26 Nov 2020 07:45:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730593AbgKYUph (ORCPT ); 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-Google-Smtp-Source: ABdhPJwJiAwYxtZqgooyC9k8yliQumd46KdUHgTeWyOp+1jwNlcFoW1rvj5AzQfW+8vUi6e6tjr1ZQ== 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(-) 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) \