From patchwork Tue Oct 27 16:11:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 298546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B185DC55178 for ; Tue, 27 Oct 2020 16:13:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61D7B208B8 for ; Tue, 27 Oct 2020 16:13:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yBByF+Vq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1807541AbgJ0QLe (ORCPT ); Tue, 27 Oct 2020 12:11:34 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:37704 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807514AbgJ0QL3 (ORCPT ); Tue, 27 Oct 2020 12:11:29 -0400 Received: by mail-io1-f68.google.com with SMTP id q25so2127285ioh.4 for ; Tue, 27 Oct 2020 09:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K0yM3M4HRHPMW9aRwUGo0JZZrI7I9AQrqcJLw5GYIWw=; b=yBByF+VqG3N+unBFnvTP8XpxBlm1eMtr3vA/X6lLyAmCUJHOjxtXmkxaGWFP1l7FU+ boL7PYJP3IiYakpInMix/CAH+/C97s/iLGYEfWkOXv3QmecirTc+5LZJByjhu8zWdsm5 4gv5PnoLeysZHqVDbb9xxohd2oAzPLFeVIm0uASGap4EC5G55uvOAYyeNeQqJZhFPCZV 2Nd8ZUqb2Uqp5lVsBk0MsDQXISRyqbJBC+36xt8sp6rCZSHTbxQ9BT7mb6bbWlW3cm0J DmwxfZ20FQn3CGPmnCDRjC+uVFv4UtIw/cltlcQs174VRT4WsMuVyHBlC4rMJUM/B7/v E0Ow== 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=K0yM3M4HRHPMW9aRwUGo0JZZrI7I9AQrqcJLw5GYIWw=; b=LPU5x0Kow812L0qzjuh3nZNsmsf1Sm3NxRWcH3J6i2w2Z/NMqqeIvxY47Mi0C7Tssn EXJvKyPwmTBvEx4qRjqv5jzLmcGgB4qrju5kHrCt0nWLCKQheRTHZ1NHSioeLP80pRhM KXr6L2OoDJXXckuUkW/AISTN+wJK4tOty3NvBSZv9Gnb+JT2XCX2tsEsOVhYqUr5GpCF DFnVM8vuVRjHNA2YaMwOhCEt4Npi/50+2m6Lv0qrRvNztMuV+7fS86TN6qLl+X8l4mpo VGpLZhfciLc1LWefSIJ2z14Ut1/6ywygMdXS0eAfHKfrCGreGDQ7tasJ/Ue4lIrjR5RI HQqw== X-Gm-Message-State: AOAM533fjBN8/jxIeXCrcppV5VGguO4vSo9Q7ZKinb1bT9HfB3kH0Vvc jI3EX9Eq/K77cwbsTe86jcRk2g== X-Google-Smtp-Source: ABdhPJx3neAapFqcccbFscS5tFthGTx7+4okWPJS8e8WwQYI0BYSkh9mq6ugrFleyclHe2RZavKZaA== X-Received: by 2002:a02:ec3:: with SMTP id 186mr3081153jae.92.1603815088531; Tue, 27 Oct 2020 09:11:28 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w15sm1082264iom.6.2020.10.27.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:11:27 -0700 (PDT) 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 1/5] net: ipa: assign proper packet context base Date: Tue, 27 Oct 2020 11:11:16 -0500 Message-Id: <20201027161120.5575-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027161120.5575-1-elder@linaro.org> References: <20201027161120.5575-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org At the end of ipa_mem_setup() we write the local packet processing context base register to tell it where the processing context memory is. But we are writing the wrong value. The value written turns out to be the offset of the modem header memory region (assigned earlier in the function). Fix this bug. Fixes: ba764c4dad7bd ("soc: qcom: ipa: clocking, interrupts, and memory") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 2d45c444a67fa..ecfd1f91fce3b 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -89,7 +89,7 @@ int ipa_mem_setup(struct ipa *ipa) gsi_trans_commit_wait(trans); /* Tell the hardware where the processing context area is located */ - iowrite32(ipa->mem_offset + offset, + iowrite32(ipa->mem_offset + ipa->mem[IPA_MEM_MODEM_PROC_CTX].offset, ipa->reg_virt + IPA_REG_LOCAL_PKT_PROC_CNTXT_BASE_OFFSET); return 0; From patchwork Tue Oct 27 16:11: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: 319163 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1709036ilc; Tue, 27 Oct 2020 09:13:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvGIMG66/aCgWa0M64wZ3YINWoTQo9SsazOHdMFxyRsPV/q905DDbjyyIBfkc7AcVboGvX X-Received: by 2002:a05:6402:1585:: with SMTP id c5mr3079402edv.278.1603815193152; Tue, 27 Oct 2020 09:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603815193; cv=none; d=google.com; s=arc-20160816; b=eGWIeq3BppIj0kikAmXL7be5BuYyU6d/xaK1z4VQxS+heYE+34uGRTI7/Ek1OKVJi/ aCVqPDob0ywWklHwl0eeJDZC2rafDZFKHGUE8KZulUuayiZ1Iw/7Lj1U1o175U+FqTXS ra73UzahUMS6XFtdoDnR4tK6eVkm5G93n9ESGgTk7zjAw/7ixOeqRnXEAkipXfoOW+Z1 F3tgwqmYuq4/tWqqNPrZnwgiHYaom7f8TXmTvnB33APMV340T8ZwW9t5H9vkWyaMb/ce 3ElRZwnTOULo2oXKPrjTiy+/to5QkP+wTDD8LHlLGV5t9Uv2urM3eYQXifZXJOxUBo5I MnKQ== 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=sNsja6RVkW4lCiOuiuPXRLZQ8pFPcNRAN/TOMPINMPw=; b=aFGD1x/UJ52I32nM7gkTq/1H8bPQJ37eIh5Py8rqvNbyVNEfMfX+2dKb4KVu/pCLzh A5KR5LDJtKqmFak44CNjRh8S9Hw6wG97Gn73UBwPpprPeFV7KXspzCOPpCl33K3IX7vo e6szR26LZksIDiLMlxX6mb4CDqyFBtpwjyzJ4h8914mhUOSEaxr+1mfmq1Cf39AgYkda rqirfgnP3g4OpnLa+NTykGRvDN/zGwFQLCDtnc9b+YSSRoGQKNt1VpQYI9fzfFgultA0 UqxNmR6kOOha/39hr3PQUHhE9WhDviD5KB/kZVPcPDGjOJ+FACg1pTRy8jXi1xkcUM3X Yd9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kCJEcAdE; 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 bt15si1425884ejb.170.2020.10.27.09.13.12; Tue, 27 Oct 2020 09:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kCJEcAdE; 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 S1807696AbgJ0QNJ (ORCPT + 8 others); Tue, 27 Oct 2020 12:13:09 -0400 Received: from mail-il1-f195.google.com ([209.85.166.195]:44887 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807521AbgJ0QLb (ORCPT ); Tue, 27 Oct 2020 12:11:31 -0400 Received: by mail-il1-f195.google.com with SMTP id z2so1980820ilh.11 for ; Tue, 27 Oct 2020 09:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sNsja6RVkW4lCiOuiuPXRLZQ8pFPcNRAN/TOMPINMPw=; b=kCJEcAdEsNHqBQ8Cjwn1oY56xM29srDtn9h/gH2iJnw90q6FYSMQeB+oXsedzvFvFH Uw61dhZwme9Ws8p/VyvOZoN8nFF2MaLQxTe6XsuLvQOkcgBvpJ59DC0AKpMwc1ZjMEZo VtmKKesT8jz+mWRPt1mzhorgM9GpoXqvJmEugxXO+aV1kCBqCAKpIVDjWZnKEcJtWA42 VQpILjb6Suq8OPuH4aiiPYRwu+bRC/e1DOa4lDsQ1MldvR6GfujUYs4mSmnKzfdOrzwU 1cPd8fLX1dSMvEcvaKdV1NpTlXiiAiPAuuPuN1nGZZ3icwUqX58ANu+vufWOuFH3WTl8 +mgg== 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=sNsja6RVkW4lCiOuiuPXRLZQ8pFPcNRAN/TOMPINMPw=; b=rFx80RkwTO9GxNcjF4FH1GLnQhExFNf1/Pg0FGvtadgpSZ2MYxhsdl4U6t5shcMo3h kYLPwjMxrLxZGwowhC9rHT7330bjzSY4KJIBqvwaWf5lfqOGWVo5Bow/yMn3ZTIzCJr6 ubTIfzWUb1XOf7WEX3DNCI1FzuLXx2URnr2J65vYHSYgmBlB7bPd6GUydmHCqwU+JbEr 0k7CaMkSkdOV43o+egWVCakNhuESea2hT47WxAzstq8II+f+7VUh+fNtlhYihv61A7pe X9wJ57w020bNZtoaK3OijOlr7csNr+LpuXBemhglr8KJkfGxl/O73ow8tJIzGIOfM1ZV o8bA== X-Gm-Message-State: AOAM5324o2ckrF+n9njkP/qjw6eTRL6ldTv8flcjqCfsh4jt3ZTWXjCu bDjFhCQhtLwcJJUyDoqTlexUoUno/x5J+8Lk X-Received: by 2002:a92:740c:: with SMTP id p12mr2306704ilc.277.1603815089887; Tue, 27 Oct 2020 09:11:29 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w15sm1082264iom.6.2020.10.27.09.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:11:29 -0700 (PDT) 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 2/5] net: ipa: fix resource group field mask definition Date: Tue, 27 Oct 2020 11:11:17 -0500 Message-Id: <20201027161120.5575-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027161120.5575-1-elder@linaro.org> References: <20201027161120.5575-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The mask for the RSRC_GRP field in the INIT_RSRC_GRP endpoint initialization register is incorrectly defined for IPA v4.2 (where it is only one bit wide). So we need to fix this. The fix is not straightforward, however. Field masks are passed to functions like u32_encode_bits(), and for that they must be constant. To address this, we define a new inline function that returns the *encoded* value to use for a given RSRC_GRP field, which depends on the IPA version. The caller can then use something like this, to assign a given endpoint resource id 1: u32 offset = IPA_REG_ENDP_INIT_RSRC_GRP_N_OFFSET(endpoint_id); u32 val = rsrc_grp_encoded(ipa->version, 1); iowrite32(val, ipa->reg_virt + offset); The next patch requires this fix. Fixes: cdf2e9419dd91 ("soc: qcom: ipa: main code") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_reg.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index e542598fd7759..7dcfa07180f9f 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -341,7 +341,16 @@ static inline u32 ipa_reg_idle_indication_cfg_offset(enum ipa_version version) #define IPA_REG_ENDP_INIT_RSRC_GRP_N_OFFSET(ep) \ (0x00000838 + 0x0070 * (ep)) -#define RSRC_GRP_FMASK GENMASK(1, 0) +/* Encoded value for RSRC_GRP endpoint register RSRC_GRP field */ +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)); + default: + return u32_encode_bits(rsrc_grp, GENMASK(1, 0)); + } +} /* Valid only for TX (IPA consumer) endpoints */ #define IPA_REG_ENDP_INIT_SEQ_N_OFFSET(txep) \ From patchwork Tue Oct 27 16:11: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: 298545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D235C388F9 for ; Tue, 27 Oct 2020 16:13:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB5AB2225E for ; Tue, 27 Oct 2020 16:13:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VRwwuISi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1807690AbgJ0QNF (ORCPT ); Tue, 27 Oct 2020 12:13:05 -0400 Received: from mail-il1-f196.google.com ([209.85.166.196]:38332 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807528AbgJ0QLc (ORCPT ); Tue, 27 Oct 2020 12:11:32 -0400 Received: by mail-il1-f196.google.com with SMTP id x7so567114ili.5 for ; Tue, 27 Oct 2020 09:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ad72dxioIj0WvztwIzeKe/eV2acq7ZrfSLr7+KsEV38=; b=VRwwuISiYiZN11L+3Px0fVLbhozomhs+sqQ56pf9DCaS76YnvjAoCSbSaXpZ1bj+BU GLUvCOJBOJhbKZgAh26jmy53SJzfZAmgY9Rxnm58kbf93qUmwBpkVVQXpcINgjWbTBx6 CuBWaZt1ZJLkMrtLBqDR0oqlchnUxhGyciwBDRzy4klsq6PXntwT5GoWxbt4SjQ/tT0V QWcrazgS0EIm+inQu975p7lUAI9yXhjh6KdKQOr4CgkifgjCR31jo6EqQUfPzfc0RLi6 lBF+TB7w90/31GTBgyLnKYRxDoL8IiH4cq9OItqOhGykMYpPj4FKnY/4k/2ZciPctSf/ yWKA== 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=Ad72dxioIj0WvztwIzeKe/eV2acq7ZrfSLr7+KsEV38=; b=LMfRZL/aSetsBqoyWA2kfqmmabs8u4kDgzfSoXrXKOpv6UmW5/c9vOTeIS/uOwSO9O WyB+yMZx7gHGMJcoYRfYL06rXxlpqH9hhPMOBVTjNDjiwkIbFeXyOKUIuOhZX9sLmdw8 s+W9S/M9lDyRSeiUnPOvjhaRAweseYcoMP+uaibm7DGLgjPjMi0T7P6GzVioeqFFlVW1 oFgQdoe9izh0E1jGw04zzfcR3i7b7QngafF6nTJTWQuVsqOTAjG7fOlKwq+/dVLM+Xlf vcpIndZotFASIngaO3otyP9mzsXds6xf2cVrrcm5/yIZ2y68iqHYqTkwKDUvmLjXEs0+ BYEQ== X-Gm-Message-State: AOAM530WGUU7YHDPW6prMhuOHkmjlIcYJjFKAxUFw20C5YHls3YL/fqR Ot1/oKb7er2eWAxg4zay53393A== X-Google-Smtp-Source: ABdhPJzk6E0qpw177yElmVAtBNKUbp7dtI1iF/Sy1UZKDvQ56hpn+d3QEKE5N2XORaoJVC7/JKogvA== X-Received: by 2002:a92:494c:: with SMTP id w73mr2514250ila.104.1603815091319; Tue, 27 Oct 2020 09:11:31 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w15sm1082264iom.6.2020.10.27.09.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:11:30 -0700 (PDT) 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 3/5] net: ipa: assign endpoint to a resource group Date: Tue, 27 Oct 2020 11:11:18 -0500 Message-Id: <20201027161120.5575-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027161120.5575-1-elder@linaro.org> References: <20201027161120.5575-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IPA hardware manages various resources (e.g. descriptors) internally to perform its functions. The resources are grouped, allowing different endpoints to use separate resource pools. This way one group of endpoints can be configured to operate unaffected by the resource use of endpoints in a different group. Endpoints should be assigned to a resource group, but we currently don't do that. Define a new resource_group field in the endpoint configuration data, and use it to assign the proper resource group to use for each AP endpoint. Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_data-sc7180.c | 4 ++++ drivers/net/ipa/ipa_data-sdm845.c | 4 ++++ drivers/net/ipa/ipa_data.h | 2 ++ drivers/net/ipa/ipa_endpoint.c | 11 +++++++++++ 4 files changed, 21 insertions(+) diff --git a/drivers/net/ipa/ipa_data-sc7180.c b/drivers/net/ipa/ipa_data-sc7180.c index d4c2bc7ad24bf..37dada4da6808 100644 --- a/drivers/net/ipa/ipa_data-sc7180.c +++ b/drivers/net/ipa/ipa_data-sc7180.c @@ -24,6 +24,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_DMA_ONLY, .config = { + .resource_group = 0, .dma_mode = true, .dma_endpoint = IPA_ENDPOINT_AP_LAN_RX, }, @@ -42,6 +43,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_INVALID, .config = { + .resource_group = 0, .aggregation = true, .status_enable = true, .rx = { @@ -65,6 +67,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .seq_type = IPA_SEQ_PKT_PROCESS_NO_DEC_NO_UCP_DMAP, .config = { + .resource_group = 0, .checksum = true, .qmap = true, .status_enable = true, @@ -88,6 +91,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_INVALID, .config = { + .resource_group = 0, .checksum = true, .qmap = true, .aggregation = true, diff --git a/drivers/net/ipa/ipa_data-sdm845.c b/drivers/net/ipa/ipa_data-sdm845.c index de2768d71ab56..a9a992404b39f 100644 --- a/drivers/net/ipa/ipa_data-sdm845.c +++ b/drivers/net/ipa/ipa_data-sdm845.c @@ -26,6 +26,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_DMA_ONLY, .config = { + .resource_group = 1, .dma_mode = true, .dma_endpoint = IPA_ENDPOINT_AP_LAN_RX, }, @@ -44,6 +45,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_INVALID, .config = { + .resource_group = 1, .aggregation = true, .status_enable = true, .rx = { @@ -67,6 +69,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .seq_type = IPA_SEQ_2ND_PKT_PROCESS_PASS_NO_DEC_UCP, .config = { + .resource_group = 1, .checksum = true, .qmap = true, .status_enable = true, @@ -90,6 +93,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { .endpoint = { .seq_type = IPA_SEQ_INVALID, .config = { + .resource_group = 1, .checksum = true, .qmap = true, .aggregation = true, diff --git a/drivers/net/ipa/ipa_data.h b/drivers/net/ipa/ipa_data.h index 7fc1058a5ca93..d084a83069db2 100644 --- a/drivers/net/ipa/ipa_data.h +++ b/drivers/net/ipa/ipa_data.h @@ -109,6 +109,7 @@ struct ipa_endpoint_rx_data { /** * struct ipa_endpoint_config_data - IPA endpoint hardware configuration + * @resource_group: resource group to assign endpoint to * @checksum: whether checksum offload is enabled * @qmap: whether endpoint uses QMAP protocol * @aggregation: whether endpoint supports aggregation @@ -119,6 +120,7 @@ struct ipa_endpoint_rx_data { * @rx: RX-specific endpoint information (see above) */ struct ipa_endpoint_config_data { + u32 resource_group; bool checksum; bool qmap; bool aggregation; diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index b40b711cf4bd5..7386e10615d99 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -751,6 +751,16 @@ static void ipa_endpoint_init_deaggr(struct ipa_endpoint *endpoint) iowrite32(val, endpoint->ipa->reg_virt + offset); } +static void ipa_endpoint_init_rsrc_grp(struct ipa_endpoint *endpoint) +{ + u32 offset = IPA_REG_ENDP_INIT_RSRC_GRP_N_OFFSET(endpoint->endpoint_id); + struct ipa *ipa = endpoint->ipa; + u32 val; + + val = rsrc_grp_encoded(ipa->version, endpoint->data->resource_group); + iowrite32(val, ipa->reg_virt + offset); +} + static void ipa_endpoint_init_seq(struct ipa_endpoint *endpoint) { u32 offset = IPA_REG_ENDP_INIT_SEQ_N_OFFSET(endpoint->endpoint_id); @@ -1328,6 +1338,7 @@ static void ipa_endpoint_program(struct ipa_endpoint *endpoint) ipa_endpoint_init_mode(endpoint); ipa_endpoint_init_aggr(endpoint); ipa_endpoint_init_deaggr(endpoint); + ipa_endpoint_init_rsrc_grp(endpoint); ipa_endpoint_init_seq(endpoint); ipa_endpoint_status(endpoint); } From patchwork Tue Oct 27 16:11: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: 319161 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1708859ilc; Tue, 27 Oct 2020 09:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdmeJepiZfrwSI1OmvwgJxC9d7vSdgkJov7AF2z+tjmAdZasoel6HqMvOay51Ip1e/S6tm X-Received: by 2002:a17:906:3852:: with SMTP id w18mr2998346ejc.551.1603815183154; Tue, 27 Oct 2020 09:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603815183; cv=none; d=google.com; s=arc-20160816; b=YcNJFZK7cUAtXP4HNT53qwQUHUFpkgBySOVfrKxHnm503eXbHNXomBwfbD41zhS9vY 0LVNGVoR2QvgMG79qr/u4WBbrETxrIMvMku13zJJFS8cYmor982kkb2bbjAsMhvMFAzC CqDI5r1zcacoyI6cuLiGxHQLaoZRhgGcYMy5Zo+6AElB/GfTYjK/WVVplFBFYoy5bmZQ 43g8+7YKw+nkXNaPG2AZattbbdKpOhV6wFCnQToIBxygu1NRdpe5g0n+mzNlnpu6RZu1 E+xGVC7iettHrHEXuEg+v7VQgq+Iax7iObGWg9nAucIJ9WTeoi/r/0SgaTOuKmt5aNsH rimw== 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=g6/eP7D32wbHjS9Fit8dMh9D/knRBX6K/4fHv4DsjHc=; b=hFP71/aut63faqdWtVHsdxnbq3EFOHrJHmFGPlCxo3dAGNAmMhRlswe1dInbnwItaX CaCJRbHFnO/k47xgPuOI0gPySBGp7YLNf85N8RfpNvty84U6nlDa+0aX20yt72CYsBzZ rOaItTQnzIiZ+Cg+VnW/FaZwrrkVP3cciza4cSbWD+gmws3kHAcxwsVXQj1bfguirhOs +tQBKd9yCl3zSCUzztGZTRTQxdVU+aFeDd+pFio/E/Zdx8J1Oi8tFiDZ8U0pRjMawk+c h8QUBHETOxZGTe9ff/sgum9hBjmxRA1cnlKnfbJpyD30/NfUtdFYI54q2fu4GpdCdceb cgaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXfEOyhD; 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 bt15si1425884ejb.170.2020.10.27.09.13.02; Tue, 27 Oct 2020 09:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXfEOyhD; 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 S1807686AbgJ0QNB (ORCPT + 8 others); Tue, 27 Oct 2020 12:13:01 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:39336 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807539AbgJ0QLe (ORCPT ); Tue, 27 Oct 2020 12:11:34 -0400 Received: by mail-io1-f65.google.com with SMTP id p7so2124068ioo.6 for ; Tue, 27 Oct 2020 09:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g6/eP7D32wbHjS9Fit8dMh9D/knRBX6K/4fHv4DsjHc=; b=NXfEOyhDYjcFg2+/bF+542ObdLRkPff1gBSkFjKhpWX5yUOVORwjWYaSKu2Wp2otr9 xiQOs+I3ELTenvH135as/KXJMQRJl7ZCFbjrHW3yIgDIiEH+yrj2WwayNaAMOULzgXlR O5bzLtARdM1FOWOX35rq0Yb4SfV6OX+Zz8v2cuy4YLh2z027Soatjkl9jVDDrOFc5gEI SXckIg5rMi2Y+RQNqoLjbd6r9wx42puvVrGtK1xIaIGJZ1Ox8mah0s0UWS4s4Y0Gwj4d 4OFtEQIeU1WqP3CbQeC1TUG+xJexq6VNUijrtteh/HQyvI9bJ5sB2t3aRTvltQRui/mb ro/Q== 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=g6/eP7D32wbHjS9Fit8dMh9D/knRBX6K/4fHv4DsjHc=; b=XipuTFzNlm4aEUyJrooV+ANZ6xyV2A+A+PyWmE6VljxK2YPjXZ0t0o/U2LcJkcxh45 8Gt9apnV0szLs2mwtcknTWAxFRX0EIaE31l7jV2VNWoAEDuZCP7fRoRMnNgsmPccgU9K WoWSZZjaL2AAYQ7gHIgz8iH9sLpjtWVlnw8hCb0A27p6U9GL9hcBV6KusqrVV6m//fEk qwUxyN0WB9GOjW5cE9I9ua/C4ZiVd1tSuR37C+Zqu5cnuyy7YQp4S8RYOa3BVgvUu0TD sneZQqqLE9mlzeoGnmB1HsRoy5HvWOQZu8cl9Phq/DTHqznrqflXQ8lqEmr+YPk2SpDB 2JHw== X-Gm-Message-State: AOAM531fd1Vgai2oFdTU5Uw9CB+XXp2MdA5KcTy8zslmefxB846vY3ff C3ubKFoIQiATwLC6KOG0rezJrA== X-Received: by 2002:a02:77c4:: with SMTP id g187mr752136jac.65.1603815092830; Tue, 27 Oct 2020 09:11:32 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w15sm1082264iom.6.2020.10.27.09.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:11:32 -0700 (PDT) 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 4/5] net: ipa: distinguish between resource group types Date: Tue, 27 Oct 2020 11:11:19 -0500 Message-Id: <20201027161120.5575-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027161120.5575-1-elder@linaro.org> References: <20201027161120.5575-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The number of resource groups supported by the hardware can be different for source and destination resources. Determine the number supported for each using separate functions. Make the functions inline end move their definitions into "ipa_reg.h", because they determine whether certain register definitions are valid. Pass just the IPA hardware version as argument. Change IPA_RESOURCE_GROUP_COUNT to be two separate constants, one for source and the other for destination resource groups. Rename those to end with "_MAX" rather than "_COUNT", to reflect their true purpose. Fixes: 1ed7d0c0fdbac ("soc: qcom: ipa: configuration data") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_data.h | 10 +++++----- drivers/net/ipa/ipa_main.c | 34 ++++++++++------------------------ drivers/net/ipa/ipa_reg.h | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 29 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_data.h b/drivers/net/ipa/ipa_data.h index d084a83069db2..0225d81d85028 100644 --- a/drivers/net/ipa/ipa_data.h +++ b/drivers/net/ipa/ipa_data.h @@ -45,10 +45,10 @@ * the IPA endpoint. */ -/* The maximum value returned by ipa_resource_group_count() */ -#define IPA_RESOURCE_GROUP_COUNT 4 +/* The maximum value returned by ipa_resource_group_{src,dst}_count() */ +#define IPA_RESOURCE_GROUP_SRC_MAX 4 +#define IPA_RESOURCE_GROUP_DST_MAX 4 -/** enum ipa_resource_type_src - source resource types */ /** * struct gsi_channel_data - GSI channel configuration data * @tre_count: number of TREs in the channel ring @@ -208,7 +208,7 @@ struct ipa_resource_limits { */ struct ipa_resource_src { enum ipa_resource_type_src type; - struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT]; + struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX]; }; /** @@ -218,7 +218,7 @@ struct ipa_resource_src { */ struct ipa_resource_dst { enum ipa_resource_type_dst type; - struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT]; + struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX]; }; /** diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index cd4d993b0bbb2..74b1e15ebd6b2 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -363,52 +363,38 @@ static void ipa_hardware_deconfig(struct ipa *ipa) #ifdef IPA_VALIDATION -/* # IPA resources used based on version (see IPA_RESOURCE_GROUP_COUNT) */ -static int ipa_resource_group_count(struct ipa *ipa) -{ - switch (ipa->version) { - case IPA_VERSION_3_5_1: - return 3; - - case IPA_VERSION_4_0: - case IPA_VERSION_4_1: - return 4; - - case IPA_VERSION_4_2: - return 1; - - default: - return 0; - } -} - static bool ipa_resource_limits_valid(struct ipa *ipa, const struct ipa_resource_data *data) { - u32 group_count = ipa_resource_group_count(ipa); + u32 group_count; u32 i; u32 j; + group_count = ipa_resource_group_src_count(ipa->version); if (!group_count) return false; - /* Return an error if a non-zero resource group limit is specified - * for a resource not supported by hardware. + /* Return an error if a non-zero resource limit is specified + * for a resource group not supported by hardware. */ for (i = 0; i < data->resource_src_count; i++) { const struct ipa_resource_src *resource; resource = &data->resource_src[i]; - for (j = group_count; j < IPA_RESOURCE_GROUP_COUNT; j++) + for (j = group_count; j < IPA_RESOURCE_GROUP_SRC_MAX; j++) if (resource->limits[j].min || resource->limits[j].max) return false; } + group_count = ipa_resource_group_dst_count(ipa->version); + if (!group_count) + return false; + for (i = 0; i < data->resource_dst_count; i++) { const struct ipa_resource_dst *resource; resource = &data->resource_dst[i]; - for (j = group_count; j < IPA_RESOURCE_GROUP_COUNT; j++) + for (j = group_count; j < IPA_RESOURCE_GROUP_DST_MAX; j++) if (resource->limits[j].min || resource->limits[j].max) return false; } diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index 7dcfa07180f9f..8eaf5f2096270 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -244,6 +244,43 @@ static inline u32 ipa_reg_idle_indication_cfg_offset(enum ipa_version version) #define ENTER_IDLE_DEBOUNCE_THRESH_FMASK GENMASK(15, 0) #define CONST_NON_IDLE_ENABLE_FMASK GENMASK(16, 16) +/* # IPA source resource groups available based on version */ +static inline u32 ipa_resource_group_src_count(enum ipa_version version) +{ + switch (version) { + case IPA_VERSION_3_5_1: + case IPA_VERSION_4_0: + case IPA_VERSION_4_1: + return 4; + + case IPA_VERSION_4_2: + return 1; + + default: + return 0; + } +} + +/* # IPA destination resource groups available based on version */ +static inline u32 ipa_resource_group_dst_count(enum ipa_version version) +{ + switch (version) { + case IPA_VERSION_3_5_1: + return 3; + + case IPA_VERSION_4_0: + case IPA_VERSION_4_1: + return 4; + + case IPA_VERSION_4_2: + return 1; + + default: + return 0; + } +} + +/* Not all of the following are valid (depends on the count, above) */ #define IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(rt) \ (0x00000400 + 0x0020 * (rt)) #define IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(rt) \ From patchwork Tue Oct 27 16:11: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: 319159 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1708755ilc; Tue, 27 Oct 2020 09:12:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYQ2P+MIZxdpJYzwsGblw7wJqCAlOaJ5q590l5mJrJ3z08eA3v86DqzQU4BwooJdNB6Hsv X-Received: by 2002:adf:818b:: with SMTP id 11mr3659699wra.74.1603815176739; Tue, 27 Oct 2020 09:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603815176; cv=none; d=google.com; s=arc-20160816; b=L5v1PrXlq4kA2RpfNayvt+x7k19AG2xI6K3BMc8vWQgaNaKs3LsrVep6GIUf+0zM78 rf+E6nnvUrB5HxplHUWbg9Qy32DDmrhDHuEly5u6sImrqLe0jjfRbodkzrYeT65POPdR ttCmuonIF+cGFom6N99uuHNSEGgNwfQdu4mM+zY4n8uAfZEom5l1iwEBD47RA4B3vDbI yz+R1EUB3sTx3hROSPtZ0u56Jg9wy3Oy4uLiiv6cHOVtLygVXeF3GFCwXuMIUBhwyFhZ GQkDpaB2CgpodcC49DdwGQroZQ1ciCBBHz8zVyzTCv0G8AuYyDyI6s8zDYu3n//SKd9Q iJvQ== 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=vdv8LjT2CgfUj8c+ccLLrRWl2zDtGgEY+2d5t9DuZoQ=; b=BAciyIf/t1I6EMmN/Qy/fuT75vsuGAo6h8ZSa7CVXrbwUYyf6hzV7QdwV4CTGn/PIK P12hEx6OyNT0UWJOjIba4dPOyGp4qSP2M8QzIlfeE8VhH7Xy6XY+PTclhS8H30o++PPB COkJWSIv5S3SA+j+uKmP0eWj5RyimioNiYwUuUOj3DYsbQNt3kiCZqI8xGd5WZPl54LT +LkadoCRzsS0FK8EB0zIcf3qHxDkkBLEz6VNstoKghF8Uqoth2ILoHjejMe/WMEOj8hj tQl0mn7nR2ZBzk0CpgF5SKbsSF2n5qvtXutz/Iywbg3+JFpPntvaWMV+lvWK2n50QyZ1 bgSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ezLz5t4W; 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 bt15si1425884ejb.170.2020.10.27.09.12.56; Tue, 27 Oct 2020 09:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ezLz5t4W; 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 S1807673AbgJ0QMz (ORCPT + 8 others); Tue, 27 Oct 2020 12:12:55 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:37918 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807544AbgJ0QLf (ORCPT ); Tue, 27 Oct 2020 12:11:35 -0400 Received: by mail-io1-f67.google.com with SMTP id y20so2127523iod.5 for ; Tue, 27 Oct 2020 09:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vdv8LjT2CgfUj8c+ccLLrRWl2zDtGgEY+2d5t9DuZoQ=; b=ezLz5t4Watnu8iYcnTyQEwoLmhxFfGy4kPGwfZ86E19HsahqY6zaqLXAlmA4z4mVFa MMUz7enZq7mit3DZosxtSNBAntOA6JLb15t04kakk32aYvD0kbkP6t9HPbWpFPYYlpW8 IEp6YbPP8KHlGkh4AlcP11eeWzuAEUTBaZMl1Q4tVPt/bQJL+PYTSrmBPPdrHFqcI/rW BcPd5i9q5KadZobPhBgbPLcfgBms3A+FPf/8VkvE3FpM5v9KwB1n08+t37x5MI/F2o5P u5Ruo8Bh/C2+1OVSyhEe/G8lx8GTCuN747+OfdQwJD8wTge11T7yMRQIw92+hFgU5Qaz yopw== 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=vdv8LjT2CgfUj8c+ccLLrRWl2zDtGgEY+2d5t9DuZoQ=; b=sW8pdKF1kbF3jnDiicNszrGgqund6FH146T7Vd+6oUDpZ2xIrC9V6jZ9Be9GSG/N8U gM+PDwwxVzU2TLzJX85JkRCSCbLlMlm9tQ8BzRnw6L8WmH8k3UMZDvpH1X+fUIBtRCdf KnE3Slu/oAvvs1bVJ7mYHJAC7BKm1/yrKEb5zkC65LetfjuDfB1oVEBGFxij/FIEyCUm sX78r7PIVx5c1kniOkZC8GlnVii3zg09regczoTEkp4okQZH7AmkSn7E3ksaHCwoRWcC cNTBIIpM+zIGGilHP+SNVJQ8nxi0W9Ff6sWk75xfNTVwBbbif/l80pqG7rdQteLVxjqW 0dhw== X-Gm-Message-State: AOAM5324a+aJs5waHCyOQgQP9HozMGiOHmcdUImsojyTFIbvqxfACZmD mHQbhts/dMfAIZlDpWtX6/b1ZQ== X-Received: by 2002:a02:cd2c:: with SMTP id h12mr3176363jaq.138.1603815094306; Tue, 27 Oct 2020 09:11:34 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w15sm1082264iom.6.2020.10.27.09.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:11:33 -0700 (PDT) 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 5/5] net: ipa: avoid going past end of resource group array Date: Tue, 27 Oct 2020 11:11:20 -0500 Message-Id: <20201027161120.5575-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027161120.5575-1-elder@linaro.org> References: <20201027161120.5575-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The minimum and maximum limits for resources assigned to a given resource group are programmed in pairs, with the limits for two groups set in a single register. If the number of supported resource groups is odd, only half of the register that defines these limits is valid for the last group; that group has no second group in the pair. Currently we ignore this constraint, and it turns out to be harmless, but it is not guaranteed to be. This patch addresses that, and adds support for programming the 5th resource group's limits. Rework how the resource group limit registers are programmed by having a single function program all group pairs rather than having one function program each pair. Add the programming of the 4-5 resource group pair limits to this function. If a resource group is not supported, pass a null pointer to ipa_resource_config_common() for that group and have that function write zeroes in that case. Fixes: cdf2e9419dd91 ("soc: qcom: ipa: main code") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 89 +++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 36 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 74b1e15ebd6b2..09c8a16d216df 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -370,8 +370,11 @@ static bool ipa_resource_limits_valid(struct ipa *ipa, u32 i; u32 j; + /* We program at most 6 source or destination resource group limits */ + BUILD_BUG_ON(IPA_RESOURCE_GROUP_SRC_MAX > 6); + group_count = ipa_resource_group_src_count(ipa->version); - if (!group_count) + if (!group_count || group_count >= IPA_RESOURCE_GROUP_SRC_MAX) return false; /* Return an error if a non-zero resource limit is specified @@ -387,7 +390,7 @@ static bool ipa_resource_limits_valid(struct ipa *ipa, } group_count = ipa_resource_group_dst_count(ipa->version); - if (!group_count) + if (!group_count || group_count >= IPA_RESOURCE_GROUP_DST_MAX) return false; for (i = 0; i < data->resource_dst_count; i++) { @@ -421,46 +424,64 @@ ipa_resource_config_common(struct ipa *ipa, u32 offset, val = u32_encode_bits(xlimits->min, X_MIN_LIM_FMASK); val |= u32_encode_bits(xlimits->max, X_MAX_LIM_FMASK); - val |= u32_encode_bits(ylimits->min, Y_MIN_LIM_FMASK); - val |= u32_encode_bits(ylimits->max, Y_MAX_LIM_FMASK); + if (ylimits) { + val |= u32_encode_bits(ylimits->min, Y_MIN_LIM_FMASK); + val |= u32_encode_bits(ylimits->max, Y_MAX_LIM_FMASK); + } iowrite32(val, ipa->reg_virt + offset); } -static void ipa_resource_config_src_01(struct ipa *ipa, - const struct ipa_resource_src *resource) +static void ipa_resource_config_src(struct ipa *ipa, + const struct ipa_resource_src *resource) { - u32 offset = IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); + u32 group_count = ipa_resource_group_src_count(ipa->version); + const struct ipa_resource_limits *ylimits; + u32 offset; - ipa_resource_config_common(ipa, offset, - &resource->limits[0], &resource->limits[1]); -} + offset = IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 1 ? NULL : &resource->limits[1]; + ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); -static void ipa_resource_config_src_23(struct ipa *ipa, - const struct ipa_resource_src *resource) -{ - u32 offset = IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); + if (group_count < 2) + return; - ipa_resource_config_common(ipa, offset, - &resource->limits[2], &resource->limits[3]); -} + offset = IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 3 ? NULL : &resource->limits[3]; + ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); -static void ipa_resource_config_dst_01(struct ipa *ipa, - const struct ipa_resource_dst *resource) -{ - u32 offset = IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); + if (group_count < 4) + return; - ipa_resource_config_common(ipa, offset, - &resource->limits[0], &resource->limits[1]); + offset = IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 5 ? NULL : &resource->limits[5]; + ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); } -static void ipa_resource_config_dst_23(struct ipa *ipa, - const struct ipa_resource_dst *resource) +static void ipa_resource_config_dst(struct ipa *ipa, + const struct ipa_resource_dst *resource) { - u32 offset = IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); + u32 group_count = ipa_resource_group_dst_count(ipa->version); + const struct ipa_resource_limits *ylimits; + u32 offset; + + offset = IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 1 ? NULL : &resource->limits[1]; + ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); + + if (group_count < 2) + return; + + offset = IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 3 ? NULL : &resource->limits[3]; + ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); + + if (group_count < 4) + return; - ipa_resource_config_common(ipa, offset, - &resource->limits[2], &resource->limits[3]); + offset = IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type); + ylimits = group_count == 5 ? NULL : &resource->limits[5]; + ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); } static int @@ -471,15 +492,11 @@ ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data) if (!ipa_resource_limits_valid(ipa, data)) return -EINVAL; - for (i = 0; i < data->resource_src_count; i++) { - ipa_resource_config_src_01(ipa, &data->resource_src[i]); - ipa_resource_config_src_23(ipa, &data->resource_src[i]); - } + for (i = 0; i < data->resource_src_count; i++) + ipa_resource_config_src(ipa, data->resource_src); - for (i = 0; i < data->resource_dst_count; i++) { - ipa_resource_config_dst_01(ipa, &data->resource_dst[i]); - ipa_resource_config_dst_23(ipa, &data->resource_dst[i]); - } + for (i = 0; i < data->resource_dst_count; i++) + ipa_resource_config_dst(ipa, data->resource_dst); return 0; }