From patchwork Tue Oct 1 10:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13817728 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49D1F1A0706 for ; Tue, 1 Oct 2024 10:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727777452; cv=none; b=QJB8CrEI+5mm2pv/vJ/RQe6/2OyMgUjAko8v3R1DirhiFlY2P84OqRARxmFwO6g5vqXy4K+gJR6KUkrzDM0Vi5IRCIKGyCYhKQZFbT3WflszJF+PKGBVrdU8qnJKXR921b3eXIYU/kCp10uF6bVCvjzA4h0i/9EdVpEAJcxOLBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727777452; c=relaxed/simple; bh=W6wULZcZ5C4DDBfQh8g6Wi4ct5rID7NuhckJWgjalGk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I6UJX5uLm1fqOlX8Fgago/laeGlrFotCyXA/mAvtU1SCvygv8S3WQv6litHbHOdnzY+rxamAgTD7QhMpb+OF41HcWpnVb3iideP0I8dItjhwHUu5mlLCBBs/xUDFGoMYw443Q5YMqSzHc2Ew0ItFWJtZRHfMxoraxqJHLc5U22I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AznayJHD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AznayJHD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8769C4CECE; Tue, 1 Oct 2024 10:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727777452; bh=W6wULZcZ5C4DDBfQh8g6Wi4ct5rID7NuhckJWgjalGk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AznayJHDDdX1qWlWQeaEjiOEiy26RjISy5rQNjJ6JbaI9GcFH+mJJ83M8kEKlWn87 +vMit4ZrjublxSwLhUSWlCDoGHB0d2dJ5CdxZiwzOlhzR8AcVGKw3rOlOSmQeTss72 j+vuQ4I8U/zqpVGo5ed8PPMwqZKx76HtE5NP815Pc05xjJ2u9Nqq/YBWgFrFh0OxkQ KXhQ5UwI7CEv6JxgVMGtduTvL/3n5JoQDxP0eJsl3OgeCcZqvy+42GG6Q9ayZIovmL 9BvISfrMtBUhkSQ53wAENuBMkg0UiQFp1yYTTPfkgGqEyLQTAaAFljjlmOyegTRhr1 AjUy7Lz0O1+0g== From: Lorenzo Bianconi Date: Tue, 01 Oct 2024 12:10:24 +0200 Subject: [PATCH net-next v2 1/2] net: airoha: read default PSE reserved pages value before updating Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241001-airoha-eth-pse-fix-v2-1-9a56cdffd074@kernel.org> References: <20241001-airoha-eth-pse-fix-v2-0-9a56cdffd074@kernel.org> In-Reply-To: <20241001-airoha-eth-pse-fix-v2-0-9a56cdffd074@kernel.org> To: Lorenzo Bianconi , Felix Fietkau , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, Simon Horman , upstream@airoha.com X-Mailer: b4 0.14.1 X-Patchwork-Delegate: kuba@kernel.org Store the default value for the number of PSE reserved pages in orig_val at the beginning of airoha_fe_set_pse_oq_rsv routine, before updating it with airoha_fe_set_pse_queue_rsv_pages(). Introduce airoha_fe_get_pse_all_rsv utility routine. Introduced by commit 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC") Signed-off-by: Lorenzo Bianconi Reviewed-by: Simon Horman --- drivers/net/ethernet/mediatek/airoha_eth.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c index 930f180688e5..480540526bdb 100644 --- a/drivers/net/ethernet/mediatek/airoha_eth.c +++ b/drivers/net/ethernet/mediatek/airoha_eth.c @@ -1116,17 +1116,23 @@ static void airoha_fe_set_pse_queue_rsv_pages(struct airoha_eth *eth, PSE_CFG_WR_EN_MASK | PSE_CFG_OQRSV_SEL_MASK); } +static u32 airoha_fe_get_pse_all_rsv(struct airoha_eth *eth) +{ + u32 val = airoha_fe_rr(eth, REG_FE_PSE_BUF_SET); + + return FIELD_GET(PSE_ALLRSV_MASK, val); +} + static int airoha_fe_set_pse_oq_rsv(struct airoha_eth *eth, u32 port, u32 queue, u32 val) { - u32 orig_val, tmp, all_rsv, fq_limit; + u32 orig_val = airoha_fe_get_pse_queue_rsv_pages(eth, port, queue); + u32 tmp, all_rsv, fq_limit; airoha_fe_set_pse_queue_rsv_pages(eth, port, queue, val); /* modify all rsv */ - orig_val = airoha_fe_get_pse_queue_rsv_pages(eth, port, queue); - tmp = airoha_fe_rr(eth, REG_FE_PSE_BUF_SET); - all_rsv = FIELD_GET(PSE_ALLRSV_MASK, tmp); + all_rsv = airoha_fe_get_pse_all_rsv(eth); all_rsv += (val - orig_val); airoha_fe_rmw(eth, REG_FE_PSE_BUF_SET, PSE_ALLRSV_MASK, FIELD_PREP(PSE_ALLRSV_MASK, all_rsv));