From patchwork Wed Oct 28 19:41:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 316167 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 78A01C55179 for ; Wed, 28 Oct 2020 21:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 239792485E for ; Wed, 28 Oct 2020 21:33:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aXL55zqi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725816AbgJ1Vct (ORCPT ); Wed, 28 Oct 2020 17:32:49 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:46179 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgJ1Vcp (ORCPT ); Wed, 28 Oct 2020 17:32:45 -0400 Received: by mail-il1-f194.google.com with SMTP id a20so920580ilk.13 for ; Wed, 28 Oct 2020 14:32:43 -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=s43f85+WbHjGIt0fEgoku0r8l29LSpKBU8YM5eW/h3c=; b=aXL55zqiNE0mMnQt+yR2/P2FG1Gg0c33k6O5L/MPe6rK/dYDoSPeB9CRfPYVPtocEP Ir7yE9gozl5H6q2FsBs6TPu1gIcXByKSIAIo46fcK8rNUnfrAgYKkP7BevUqZaAbFueR j/YGSZq99VWicSeBrDovoycoDIOngbnqGBXrBA/8FQaIBu6rdrc7WtsC+OyYwcMS6tBi Zug3bRiTpPCj8nXR9QaaWMBtCStvwIR2xLI7cGqrL8aAMqOHDXs88KAImgD9N3+Gx04A 4hFwv/Nu3gqQFZ48nPZHGqkyYsDI4NWTQR9R6R7FkC2gLUBR1QQ0vkjlWWd1YF+h++Gd tNbg== 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=s43f85+WbHjGIt0fEgoku0r8l29LSpKBU8YM5eW/h3c=; b=U/yYwA5CVGjNSZnGFIy2Fcq/WzpY5plRh6aqEjvRwxrobROZ6q7SNOcoNixUgUBZ+D quGE9AbwdgNQYJ27aN4RQnk6yd9Za0/1Ny24o9ZObhkhtOxY5SLu3/BVItpYNB9qFleB zSIcGodL04/0kiFvo4COot60UM0rycMuNqfgx/S6Z+U/gk2zorONnzgnLpEq923TwF8c flcVjtpwnZA5o7C0AwnpxVR7i3zAMpO3Kjx2vpmlbBNSh/lL90CkJbjATrWdVFuW+MTf djyqIW2y8RhFGNzx5/Y+XijZIX+1FCy7d0+N7au5Lu9z1ZvA4yxySPUl2F4aFE/TxfN3 XXzw== X-Gm-Message-State: AOAM533+93vpoq4ABbnqVNhteggcX/O3chyAWkiVoFzfxb0AL5GAFOSO 5HMsicOJhPH3EHazv5mo1TBSMowpU15JlgU3 X-Google-Smtp-Source: ABdhPJz67PzC+3Wvsw8DNWphJhyUwxKjOFsLopMwrao+z3oypgBaWbA3EQIOQs6lqOs79QVntzAvyA== X-Received: by 2002:a6b:3c14:: with SMTP id k20mr849364iob.12.1603914114829; Wed, 28 Oct 2020 12:41:54 -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 m66sm359828ill.69.2020.10.28.12.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 12:41:54 -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, sujitka@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net 1/5] net: ipa: assign proper packet context base Date: Wed, 28 Oct 2020 14:41:44 -0500 Message-Id: <20201028194148.6659-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028194148.6659-1-elder@linaro.org> References: <20201028194148.6659-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") Tested-by: Sujit Kautkar 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 Wed Oct 28 19:41:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 311326 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 A5A5FC4363A for ; Wed, 28 Oct 2020 22:14:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5275D246CD for ; Wed, 28 Oct 2020 22:14:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MuGa/5Qy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731064AbgJ1WOx (ORCPT ); Wed, 28 Oct 2020 18:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731053AbgJ1WOs (ORCPT ); Wed, 28 Oct 2020 18:14:48 -0400 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 41F48C0613CF for ; Wed, 28 Oct 2020 15:14:48 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id h21so1159577iob.10 for ; Wed, 28 Oct 2020 15:14:48 -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=vv7cM6cxI+6JCDep4JnUcjGnf8IzXZFWl325bdBt8FU=; b=MuGa/5QyLjLCSan3+a/ID5Uj9b0l5h6XG27Gg1WaLw7OUcCnflsfGrQMtNo7Ajp7dT h9MomlEONXAtrC7V48aXJvKFehNypCfiI1n1CWQ57AsfTJ18jewJRNmKUdNu9/qBQVn1 Z+SRho1wg4HlatqQFjENTymMX96YN4o+GlPhj+rb9E323kWlbbVEUGRCYPyEvB3prWub 6PsIw+8Au+yqpXiIROY9aqetp/v/Web21sNtrwZSFVs9hX5ATrL2zfX33aHfLp/LuMGX WxRlwDzvD12IhYZNN64hpsqN1FwU7dFuEm1QYgeueS7zPZ7Gt6krvaSDMxPEr9Ddbg12 qQ3Q== 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=vv7cM6cxI+6JCDep4JnUcjGnf8IzXZFWl325bdBt8FU=; b=WnAYz2+bTzG7IoJQ22cR1w/zOAg8oUj7tYB0INz+BUm7KYWWTEXH+lYdadeul+lrdG d92e8JlcjqZG/fRG3059LiRoClnnjJ+66JlHZWGjzKiFEbYtKYPfiySTXcfz4Iih4yJY f4v2mCQkVUiz9yilAKX75bjht05KRngY/dUv8AztCXtzJFcTnzCmojvVR7zC0WH9f1W0 SwAYi5BPnV1HzGRse43vgk7SDTuaDgosJsV2jdqXlrxGduNVGe/UKctT/loxk57Aixdw 2xuGpJoNWcBGodwFanjH2MdKsVQJ88OT4NxXli7adumTFBvl6mnQJE1rLgEcBkXw53eh lbfA== X-Gm-Message-State: AOAM532PBUeLpozBj6uaxmevHegsRjdAEbPmy1/s4j6VwnQmL15PfWE7 oBj6WhxvL0NVMkGJ0QHnvMd5TV7Nj0/e1ZHd X-Google-Smtp-Source: ABdhPJw3SgzDh8DIIk28Wo4UBPoho6XScmnSVYzX7wUknzDiLfnO3SO8FAqqIIyaLoqgIQQ6vzsprw== X-Received: by 2002:a05:6602:e:: with SMTP id b14mr838956ioa.114.1603914116152; Wed, 28 Oct 2020 12:41:56 -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 m66sm359828ill.69.2020.10.28.12.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 12:41:55 -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, sujitka@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net 2/5] net: ipa: fix resource group field mask definition Date: Wed, 28 Oct 2020 14:41:45 -0500 Message-Id: <20201028194148.6659-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028194148.6659-1-elder@linaro.org> References: <20201028194148.6659-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") Tested-by: Sujit Kautkar Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_reg.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 Wed Oct 28 19:41:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 316137 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 C7C59C4363A for ; Wed, 28 Oct 2020 22:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BE4220725 for ; Wed, 28 Oct 2020 22:33:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lSUcNG3K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388357AbgJ1WdY (ORCPT ); Wed, 28 Oct 2020 18:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388330AbgJ1WdW (ORCPT ); Wed, 28 Oct 2020 18:33:22 -0400 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 87FABC0613CF for ; Wed, 28 Oct 2020 15:33:22 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id z5so1270657iob.1 for ; Wed, 28 Oct 2020 15:33:22 -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=8qusyvIaw6eTnT926D9tsiv7hSb4Zih6Q4OCXNl7nNo=; b=lSUcNG3KEYFbcgjZQk9QhmEslqabew/HEZ10OIUz6RxVSC+aUBYVSz43txrAFn8Iao N7CK8Wk7O5HNIcyw2nK/w6ouXZ1+ieygFQQYt4IGUiSFyI4aTwXMJJAZsJhBRA3OZWo1 3g8Uk5JjBrVT6ESt7TWi0R+nGgnVSPplJirburmgaaWijaJdcHy+J9/OkGQfINAlHyyc A4VW/w8sWkIvGadDDTU8ir4EFdjByBaES7wWOjCYvMpfgm8+6u10dd8HUNcnlYKKTnxY bV4OG4/y22qDs2ECGpT6Py96UCHXMcYtYhTBk7hqBcp/frw+PSsrNPZx9XiOQxc1cdV+ 8Dow== 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=8qusyvIaw6eTnT926D9tsiv7hSb4Zih6Q4OCXNl7nNo=; b=UXCN6QUB1hmKZBDhIplAuSt3PdDxGkDPVK7qk+mdEJR7n9/ZT0cRncXCQ6sBPSlo5a +XPozEqgyjy1zaoKtOy3Sm34U0PRPaWD+yU9IXu5/NmtFRZxO39V3TxXVEebvz6ez7ep 43TeHHBl+L1zoARpj6RHp38iSlh5Y3YApFsjBawSG43llw4xhAGsMC9D4WZwo1RQz1W1 iLDqEtOEz42ZtvNmWSow1iwaRkqqWpEYmAIwJpU//U/rWDPhmnI+HEI357orjBCt2I6U 6d/pX4Xwf+WwXWT+kLuLmhuFFVl6yCfgo4k3t2RzcmOUut5W6KjprhR8zUEPvEY8CxEj Q0aA== X-Gm-Message-State: AOAM532uvVUkwy9R3SGlNC8w7rDbmhld30g9v7Z8VFxJhajCU29sX8DH ISpfSBF7VCRduvND/fLUGgrkx90qDAA1RBaW X-Google-Smtp-Source: ABdhPJwWbXTfDGdBxT+TvO4YZAL0VRTk/C5BUNkCywDKsvABGAJi1DC0cw3Ntfcz80iXYgEiNEkmwA== X-Received: by 2002:a92:d3cb:: with SMTP id c11mr543689ilh.188.1603914117616; Wed, 28 Oct 2020 12:41:57 -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 m66sm359828ill.69.2020.10.28.12.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 12:41:56 -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, sujitka@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net 3/5] net: ipa: assign endpoint to a resource group Date: Wed, 28 Oct 2020 14:41:46 -0500 Message-Id: <20201028194148.6659-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028194148.6659-1-elder@linaro.org> References: <20201028194148.6659-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") Tested-by: Sujit Kautkar 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 Wed Oct 28 19:41:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 316080 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 0A88FC4363A for ; Thu, 29 Oct 2020 02:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A723120720 for ; Thu, 29 Oct 2020 02:13:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vsrb8aD6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbgJ2CNP (ORCPT ); Wed, 28 Oct 2020 22:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgJ1VgQ (ORCPT ); Wed, 28 Oct 2020 17:36:16 -0400 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 10CD6C0613D1 for ; Wed, 28 Oct 2020 14:36:15 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id y17so985134ilg.4 for ; Wed, 28 Oct 2020 14:36:15 -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=GEvV133sdw+/JHpE5Z4NaSRzUo1ZNlL2BYj4NJ4KAYg=; b=vsrb8aD6MytJrPIR4dKD9Opp9KGvaJaCpqMdjricTyUwFMp43bIN9quPIfhwHPH1l9 mzdAvWrjHTKoAvwsv5ovc+l8AAni9pXtGWdNt5CLdmwdkVqIxNTClQMKx2NaQmsTddVH 2N5bEQ+QRtD2Todg+W4GLbRtn+1iHxfZQpqXKl9LkwL2aUuLVAkTW3fEA9nbMwICl79O yyXbnIvda5ffbgRHvfe/oZmS0Udfb7IMNB6BA1g+W+Hok2X8TNAhbvzgKfjsDO2BW/UE ihC1NhVYBHX5jG1h6i0iaLvvKNhheIuTbGJzfWzSQFmS6Of7E7lPuDHwcWwA+t7DxzxD q7aA== 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=GEvV133sdw+/JHpE5Z4NaSRzUo1ZNlL2BYj4NJ4KAYg=; b=pDA/to3utfXIx7Evp0OG7rgBWJhSiGfIbV+WprYSyWKWVwR7Y65MlgVWSMtt2QP8u/ 4ZzihbPrJYKKWGmgItR7Y4aiHn+eb2tkf2ds6sKbl1Q36O4yJLuNmvqUob82cUImtHYb DovEJsPd4sL/JW14bkgUy7tzO4F36Jy7GXRNO8tzw9KKy4eBVWJ8ixYWvfh5jWCuTv/J avztpGT+m33xr7RSKhijPoleyGEbNwV6/dqWqm477d8TqgLUli/PijdFwLMW9lbfQIXP tSP/dV/MkhviegdgFhWYHZwR9x0etCPlp2HYR6F27nJdtswefBRS0tQcrlQur0vsylzz Kf0A== X-Gm-Message-State: AOAM530VoLRXQ03mt00hzZQpuv2Im4KLhiXaZKVmvi3I0xjkTzskSnPg h1FL98iadQ64oOHrTFKGTQw7HaD1MXCn8E1r X-Google-Smtp-Source: ABdhPJxLIJ182k/ZeRT3Qfm2O5HJF91/ZZ9oupuWiG4o/dR/leD6g8v1SEJfZv8GmBI3B0Kn2LJLWA== X-Received: by 2002:a92:9911:: with SMTP id p17mr534546ili.165.1603914119235; Wed, 28 Oct 2020 12:41:59 -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 m66sm359828ill.69.2020.10.28.12.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 12:41:58 -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, willemdebruijn.kernel@gmail.com, sujitka@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net 4/5] net: ipa: distinguish between resource group types Date: Wed, 28 Oct 2020 14:41:47 -0500 Message-Id: <20201028194148.6659-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028194148.6659-1-elder@linaro.org> References: <20201028194148.6659-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. IPA_RESOURCE_GROUP_COUNT represents the maximum number of resource groups the driver supports for any hardware version. Change that symbol to be two separate constants, one for source and the other for destination resource groups. Rename them to end with "_MAX" rather than "_COUNT", to reflect their true purpose. Fixes: 1ed7d0c0fdbac ("soc: qcom: ipa: configuration data") Tested-by: Sujit Kautkar Signed-off-by: Alex Elder --- v2: Updated description to better explain the meaning of "_MAX". 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(-) 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 Wed Oct 28 19:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 316144 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 AF5F2C56201 for ; Wed, 28 Oct 2020 22:23:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AA0A20731 for ; Wed, 28 Oct 2020 22:23:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sZI9EN1o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733179AbgJ1WXY (ORCPT ); Wed, 28 Oct 2020 18:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732731AbgJ1WWv (ORCPT ); Wed, 28 Oct 2020 18:22:51 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0247C0613CF for ; Wed, 28 Oct 2020 15:22:50 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id b69so506152qkg.8 for ; Wed, 28 Oct 2020 15:22:50 -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=nP3MQU8G+NZhAzitdmwy6AlCbQvBr5GUXkIbmBlAkpw=; b=sZI9EN1o4DdLSN0nkdlMc0F05VxohxEjHcdqbRDc8xUh73UKjUwd+xiZu6dTFBCVhF YlpT0NN4s0boGSj9Wonvwk5teEYQk9svAgU6xXIpfjq43GLV5bcuJRtSW8SEG0lRwAfS 3EfR4NqI81KRV8/ctmHrKu/smncjn2131FU2Mgp6DZPoRxK//WTpn8DAl4+0p7BQP8lH RznzugM8jWV4ZVAkK8dK1H1cJNCgkR2Kp/3W9E4R0iBYNwcTFiwKIQwJwQqdffub0SX3 bOcOIudsYbozLBJaSr8+9UtELeJ1sYtamAuxy95n1FMLJl9qwNxIJbx7AeJBEQMcFVV0 Bi4g== 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=nP3MQU8G+NZhAzitdmwy6AlCbQvBr5GUXkIbmBlAkpw=; b=d0Z5lbr+cltT2EMhmqYa0xonY8LUIyZxHqzJ53YBakCQyfcb82L5TtGFvJtl3bkkZ8 1rMX3K1P6m9ufycWdvxmsDu+GSLzBQ4n5DmhV2VvSa83m3pgHZgUn4KJXdnGwbTzbSL+ zeU7JTi8rpCp4HTY+2JjWZc62lJQB+OW4sfUQ/WQ+7IMgLkE2qnGME+toJomKBCQh4oQ ilmNAHuHVucSjtWDJnnpj2iPDSlVBOo7T/zc/uMfj/4/9wmK+BiJ3nMnmZb9RemyhPZt HOddVa/Mb8VEigey/s9UPsf6elJnqoDNyVB7ap53Z5pTPqWXr/7zv3g/jIa4bf3qqRHQ 98gw== X-Gm-Message-State: AOAM532oNSPDQECi05/urD+/CrCjVPtjEN0jCVU+ELy0G8rxZnNep5g8 nlCb5NzVclkbIyr1cs77W9EbgqpPvfvPYc4R X-Google-Smtp-Source: ABdhPJxWkVqYKo0f/78uYBARYXx/X8aXb6FzydzdsvrrY9i1JSW/wuO7rV4BwSp9AtLC8R/RuTWqmA== X-Received: by 2002:a05:6638:2208:: with SMTP id l8mr740026jas.22.1603914120719; Wed, 28 Oct 2020 12:42:00 -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 m66sm359828ill.69.2020.10.28.12.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 12:42:00 -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, sujitka@chromium.org, willemdebruijn.kernel@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net 5/5] net: ipa: avoid going past end of resource group array Date: Wed, 28 Oct 2020 14:41:48 -0500 Message-Id: <20201028194148.6659-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028194148.6659-1-elder@linaro.org> References: <20201028194148.6659-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") Tested-by: Sujit Kautkar Signed-off-by: Alex Elder Acked-by: Willem de Bruijn --- v2: Fixed comparison error identified by Willem de Bruijn. drivers/net/ipa/ipa_main.c | 89 +++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 74b1e15ebd6b2..f4dd14d9550fe 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; }