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 2C36E45843; Fri, 23 Aug 2024 09:33:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 765CF42FD9; Fri, 23 Aug 2024 09:33:02 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012061.outbound.protection.outlook.com [52.101.66.61]) by mails.dpdk.org (Postfix) with ESMTP id 66F7540150; Fri, 23 Aug 2024 09:33:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eSo61jqTINHUwxC13QjssEwOo8CZTq7oQQ75ZFckz3XtaoTbxRgS4nEh1d41l+joEDyUQuZShYb8nQG/lW2yAgEojTDhj7K/qnoXbrMYyc05Ag9ag37ytLVy9jW5JT+MQSORKsspnWjB+5dZj/OBDpeyXm1ciH3pZUaVT9ux1714ndrs90OiuXxyOoiKCyJ8tLbsOgv+1BXVXD6X2MjvsmkyuC/qttomw52eWdNo87kArCYgBMizXl0VKLzD8z7/NWhKbPs+TiVmtPeliQuU5dCKzhb0GTUpqAMjlScWdEFOpfNbCxLoPIVtzchzlLGOfO+wgsy0ksSK4Zeo+YvFJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VQTBFf6iffqhdrfBDCMQV7dbsStZ0GSTY+9yhr9iFJw=; b=TDik1P+TJPqOxkwZEhhggh8V9+f58Ofk8VZl+wIIb48Jwe3PBrv/pFgm7k4R2r5SIzjY23Md92NUdAFUnTXs40qaWJlM1d1QAFpx3r78SQPfGaJhW054butxQdr/AFLxwE0tRlv43qQG6BpGNrub1gLW/6l9o6f98xKBA2ye5Gynl+hOCYoN3XPJud/vr1KciNOrgZmtfp1TIDSuZVPRuBy806wYBELOVFOjYmfP8WFsXt2pJ52S85rghcISF6v40Ai3QU1k7vF7tkbdN+5269RqKsm7m6dY/IWTzG4Jc5YeczYFbQjC1fdQB4aQcJnSz4vHuNKQHD4NcyzJqoMJCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VQTBFf6iffqhdrfBDCMQV7dbsStZ0GSTY+9yhr9iFJw=; b=czdTpbIuKQ92cmavI1LMryUagFV/UWL9Ax/v6tLL6qVt5nWhjN7mAH6KEsa30kmOaRua+sKX8NnoDBhiXy8MzlHn9i5Xo1Bpqj4PFk6ul1aquREjbCggfWbU9e4+qdLa506SAxwYwNR+4DwsXEM9/YpUjAPCe7aLyOKwUzsHMk6TVoYMD+hwazSy5oM3URoZPz9WiXC426Ci1oAZzktjckX/r6uGfAewy3h9NVneEsyZWRYZtGYuZWZuQY5V/GMm0JUkeoxxXt0HMqarR55M+IUPMaq/by1VcKg0MAoCQKYmIlYKQhE9crqLNsbZq0RgBJiKUl1oi7CgCb043rp+AQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) by DBBPR04MB7547.eurprd04.prod.outlook.com (2603:10a6:10:208::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 07:32:59 +0000 Received: from PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87]) by PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87%3]) with mapi id 15.20.7875.019; Fri, 23 Aug 2024 07:32:59 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Gagandeep Singh , stable@dpdk.org Subject: [PATCH v2 01/18] bus/dpaa: fix PFDRs leaks due to FQRNIs Date: Fri, 23 Aug 2024 13:02:23 +0530 Message-Id: <20240823073240.3708320-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823073240.3708320-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> <20240823073240.3708320-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0028.apcprd02.prod.outlook.com (2603:1096:3:18::16) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|DBBPR04MB7547:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d820f0e-e97e-4b1b-8c1e-08dcc345d022 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5Y3MNhabsHyrWD749jXCahiyAtW5lUat5DdxPxV0eMd88jB+clQabS6b6P54?= =?us-ascii?Q?y5p6IWbVGF/toy8ZRvBNg5TJsrKB2suI4Z8G9GppJyPgKxb0wVsYfIAS3EBA?= =?us-ascii?Q?QJ0TdeX/j/vAyHh1hDQu0T9Zwz1GeWOJAHMgkg6I9LjnlIJm8fLOnszTyVVS?= =?us-ascii?Q?1Pb3RF7tkx550gdR6CjROqPL946voN0poIKohouJVehNTrB/+vuTvPP7M2XF?= =?us-ascii?Q?485MJQa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0?= =?us-ascii?Q?PUBCgCLa7r0MYXFK1MQODZ6oVL369WtdDbk9fHDvumIatgMLXIBMDEMW/dr8?= =?us-ascii?Q?EWaOaTef+q+nz+k8KB3+yvZC90lDMLaYeVFxVeqkwQxtVnEjA9bCMB0BCo75?= =?us-ascii?Q?f+V6OT6q98xysLRatrnMM+q/BlocoExwBPdY/BUIdo0OnxIUzeAdg6mraFDg?= =?us-ascii?Q?QSjqfwlPIMgONQwYXP0rtmZqqRAFqC7IUD5NXD/ZNlzBazrmHBOxYMgho0BM?= =?us-ascii?Q?+6rxK5HBu/tiksNQwZHxVtkaguRsHLTswQjmFylhBre3NnhZyg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9328.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Z4VIRm38hhuB1UXxjGvpqFUvRt8IOsR1FROIWNqKu9RBF+Z/dCqIYIQvKQqt?= =?us-ascii?Q?ZtB5A6fxwQgNlOpVsRxicHK/AE95JEoY+U9Jj2YWKKORHfHGLHfyUL3M8125?= =?us-ascii?Q?4G0NLpgf5TSlBisr2fLal53I4oH379cpohgJfEprpNwAqCB+0d8JYAxA16wp?= =?us-ascii?Q?1gmpkID5w4jssDnwsi8oHr5vWEiAsiedykO01GIrySl8Q3WCUf5xC1z9TKW9?= =?us-ascii?Q?+ebOmECYExzkhrhdKFMPjpazGk/mtoC5NQkyRi7pSlTsHUTEj6XVKO8unREJ?= =?us-ascii?Q?FQKRSA8cm2xnmExP8uUODy8Ws0JElWIYygp/SHWpmgldCFDv0NJl3e1M0fnT?= =?us-ascii?Q?69JNRgkYBVPJ+cN1+JRavK8RVVu2PJUROVl1SDBNx9N3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4tLOPprDmLA3K76CbHUkCv7Va+a3hQ2SeAnhUZB17LRX088?= =?us-ascii?Q?lBmOlE/0rNe7T7Qnfeyc8gPoaPN7OzbWjni5Pswo7tTsmrglowBN/lfp3utw?= =?us-ascii?Q?rAQmU/aCvnRwEytl/keB2df03lc9AdY1Kmn+RQwfAV41r8Zgi3Sl39b3a2OP?= =?us-ascii?Q?VqZGZZwbUWqFrtYXvpZNTSEJlchxW3XR+v6HezSYt3rRiG80O0wLcthZhogR?= =?us-ascii?Q?1yjRHWjR2UJudihoWJoCZK1FyXGhAngHXRxqHB8T2nt+mI2xsr6YvnLhbgKD?= =?us-ascii?Q?3tiYKu3tzmNYuSd6YWijU/VQ1JZZWLjMIn69agFX7oaJ98hskPd/khrCsLjB?= =?us-ascii?Q?3A=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d820f0e-e97e-4b1b-8c1e-08dcc345d022 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:32:59.3168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D4cjh75n1S21cYl4gPpw4yfGHqYFUhQnxiOEGgZR1/affY0q5NZG2w8lcc3+qXQnY55f/aZmUYGPayOmBp8DWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7547 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Gagandeep Singh 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 experienace 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") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- 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 301057723e..9c90ee25a6 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -292,10 +292,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) { /* @@ -317,6 +339,7 @@ static int drain_mr_fqrni(struct qm_portal *p) do { now = mfatb(); } while ((then + 10000) > now); + qm_mr_pvb_update(p); msg = qm_mr_current(p); if (!msg) return 0; @@ -479,27 +502,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, @@ -1794,6 +1796,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.25.1