From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6F6E445BB6 for ; Wed, 23 Oct 2024 23:20:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6928C40261; Wed, 23 Oct 2024 23:20:38 +0200 (CEST) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id 4EBA740261 for ; Wed, 23 Oct 2024 23:20:36 +0200 (CEST) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4315baa51d8so2189275e9.0 for ; Wed, 23 Oct 2024 14:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729718436; x=1730323236; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LQsqPWNBQWdWdIHrPNM3R2nxUDJbRpQk8bNha5MkK+8=; b=QHTOL3T3VewG9U9bjgItvFf+kGV6GT9LioSigFIhMA55Q8Hpj7MdBhoKiR1+MxJMFq 5Dc9yrNqNd40NFILiPKGuse73VUlgPd45VsYFaxm+arAg7Bm2I8W/3fkd2IyktlN2Mq9 U+JoDAYGGyfPU3V25b8FPwAiQoeYqII5FgncvxcjAvM6vlIKHK6NqAgGWG+QL3snDYEf 4VaM0TNCBkGElQTj3agqU1PYjn2odj8xR5YHRQ9aUXcp5OibcS6FLBCskTgffXiRlH0Y UnZDs4gosIhIUOrwu9kMOTnphKPhDbNqsGk2wzga4TlUW4riJLyQf0kwKTnTTsifJtSW eljw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729718436; x=1730323236; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LQsqPWNBQWdWdIHrPNM3R2nxUDJbRpQk8bNha5MkK+8=; b=j8EoiOYd/ybmB/gRQ4q2VWx0fwVg2w0ynLCs/mWnL38ghSWZMxxnJjnJ0ebF83tWku OpbJr6Y6stmWnEu5k2KitVXp+AAreR4ED8gioSr9EjQLGO9FHYw4JzZD0MEewuHrknWS NkyvuN35jdcabIINFiSjGrBIR/EkaJL4AtTbkKPV5ssFU1x+F2TbLcE4ofKj68pn+CLM LfOr3qf3pLifkVZudkQYGnjnQEEfQegWBvotx5+2kWI5aEnPb5RKxmgLlUoeemMVzUK6 0Doqn4WXeQQb4OsPeiZn2ALbEvC8yIM8QXKvLxIa6lPgo7AM6xcGj9rUKxO3/p6Up8/+ 28Zw== X-Forwarded-Encrypted: i=1; AJvYcCVbRX9UODOhgNtu32VdS5Fu3wCS31VX/9dfIsEb9bvE5T1Qm88pOGacHVueXsHWVa8etrXMcIo=@dpdk.org X-Gm-Message-State: AOJu0YzX7Hrwqh/kFTvspWz28yWHKRR6PMdN9FWkn2ke8hLmoZZWz4CN 6Jop83DU/DhjPd9HKDC7He3gNACuaQLye+/smFiSaIh0qA3oASxH X-Google-Smtp-Source: AGHT+IEspwUemIqDDW8XO95tAm2cRbDlxcZ80K5TAC7WHRF7R4M9iaL8RMO9PQg6oUMdHCa+J4zJXw== X-Received: by 2002:a05:600c:6c91:b0:431:5043:87c3 with SMTP id 5b1f17b1804b1-4318419a644mr34924255e9.22.1729718435727; Wed, 23 Oct 2024 14:20:35 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:21cd:def0:a01d:d2aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0b9432fsm9792939f8f.83.2024.10.23.14.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 14:20:35 -0700 (PDT) From: luca.boccassi@gmail.com To: Gagandeep Singh Cc: Hemant Agrawal , dpdk stable Subject: patch 'bus/dpaa: fix PFDRs leaks due to FQRNIs' has been queued to stable release 22.11.7 Date: Wed, 23 Oct 2024 22:16:36 +0100 Message-ID: <20241023211704.1216956-56-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023211704.1216956-1-luca.boccassi@gmail.com> References: <20241023211704.1216956-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/25/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/0c1fd86cee21c314cecba532a87d0ca766f0f13a Thanks. Luca Boccassi --- >From 0c1fd86cee21c314cecba532a87d0ca766f0f13a Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 1 Oct 2024 16:33:08 +0530 Subject: [PATCH] bus/dpaa: fix PFDRs leaks due to FQRNIs [ upstream commit b292acc3c4a8fd5104cfdfa5c6d3d0df95b6543b ] When a Retire FQ command is executed on a FQ in the Tentatively Scheduled or Parked states, in that case FQ is retired immediately and a FQRNI (Frame Queue Retirement Notification Immediate) message is generated. Software must read this message from MR and consume it to free the memory used by it. Although it is not mentioned about which memory to be used by FQRNIs in the RM but through experiments it is proven that it can use PFDRs. So if these messages are allowed to build up indefinitely then PFDR resources can become exhausted and cause enqueues to stall. Therefore software must consume these MR messages on a regular basis to avoid depleting the available PFDR resources. This is the PFDRs leak issue which user can experience while using the DPDK crypto driver and creating and destroying the sessions multiple times. On a session destroy, DPDK calls the qman_retire_fq() for each FQ used by the session, but it does not handle the FQRNIs generated and allowed them to build up indefinitely in MR. This patch fixes this issue by consuming the FQRNIs received from MR immediately after FQ retire by calling drain_mr_fqrni(). Please note that this drain_mr_fqrni() only look for FQRNI type messages to consume. If there are other type of messages like FQRN, FQRL, FQPN, ERN etc. also coming on MR then those messages need to be handled separately. Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines") Signed-off-by: Gagandeep Singh Acked-by: Hemant Agrawal --- drivers/bus/dpaa/base/qbman/qman.c | 46 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c index 83db0a534e..f06992ca48 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -294,10 +294,32 @@ static inline void qman_stop_dequeues_ex(struct qman_portal *p) qm_dqrr_set_maxfill(&p->p, 0); } +static inline void qm_mr_pvb_update(struct qm_portal *portal) +{ + register struct qm_mr *mr = &portal->mr; + const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi); + +#ifdef RTE_LIBRTE_DPAA_HWDEBUG + DPAA_ASSERT(mr->pmode == qm_mr_pvb); +#endif + /* when accessing 'verb', use __raw_readb() to ensure that compiler + * inlining doesn't try to optimise out "excess reads". + */ + if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) { + mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1); + if (!mr->pi) + mr->vbit ^= QM_MR_VERB_VBIT; + mr->fill++; + res = MR_INC(res); + } + dcbit_ro(res); +} + static int drain_mr_fqrni(struct qm_portal *p) { const struct qm_mr_entry *msg; loop: + qm_mr_pvb_update(p); msg = qm_mr_current(p); if (!msg) { /* @@ -319,6 +341,7 @@ loop: do { now = mfatb(); } while ((then + 10000) > now); + qm_mr_pvb_update(p); msg = qm_mr_current(p); if (!msg) return 0; @@ -481,27 +504,6 @@ static inline int qm_mr_init(struct qm_portal *portal, return 0; } -static inline void qm_mr_pvb_update(struct qm_portal *portal) -{ - register struct qm_mr *mr = &portal->mr; - const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi); - -#ifdef RTE_LIBRTE_DPAA_HWDEBUG - DPAA_ASSERT(mr->pmode == qm_mr_pvb); -#endif - /* when accessing 'verb', use __raw_readb() to ensure that compiler - * inlining doesn't try to optimise out "excess reads". - */ - if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) { - mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1); - if (!mr->pi) - mr->vbit ^= QM_MR_VERB_VBIT; - mr->fill++; - res = MR_INC(res); - } - dcbit_ro(res); -} - struct qman_portal * qman_init_portal(struct qman_portal *portal, const struct qm_portal_config *c, @@ -1825,6 +1827,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags) } out: FQUNLOCK(fq); + /* Draining FQRNIs, if any */ + drain_mr_fqrni(&p->p); return rval; } -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-10-23 22:16:42.644755490 +0100 +++ 0056-bus-dpaa-fix-PFDRs-leaks-due-to-FQRNIs.patch 2024-10-23 22:16:40.515943363 +0100 @@ -1 +1 @@ -From b292acc3c4a8fd5104cfdfa5c6d3d0df95b6543b Mon Sep 17 00:00:00 2001 +From 0c1fd86cee21c314cecba532a87d0ca766f0f13a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b292acc3c4a8fd5104cfdfa5c6d3d0df95b6543b ] + @@ -37 +38,0 @@ -Cc: stable@dpdk.org @@ -46 +47 @@ -index 301057723e..9c90ee25a6 100644 +index 83db0a534e..f06992ca48 100644 @@ -49 +50 @@ -@@ -292,10 +292,32 @@ static inline void qman_stop_dequeues_ex(struct qman_portal *p) +@@ -294,10 +294,32 @@ static inline void qman_stop_dequeues_ex(struct qman_portal *p) @@ -82 +83 @@ -@@ -317,6 +339,7 @@ loop: +@@ -319,6 +341,7 @@ loop: @@ -90 +91 @@ -@@ -479,27 +502,6 @@ static inline int qm_mr_init(struct qm_portal *portal, +@@ -481,27 +504,6 @@ static inline int qm_mr_init(struct qm_portal *portal, @@ -118 +119 @@ -@@ -1794,6 +1796,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags) +@@ -1825,6 +1827,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)