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 1743A45710; Thu, 1 Aug 2024 12:53:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA6F543366; Thu, 1 Aug 2024 12:53:33 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012024.outbound.protection.outlook.com [52.101.66.24]) by mails.dpdk.org (Postfix) with ESMTP id 7CE4742FE7; Thu, 1 Aug 2024 12:53:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W1HtL0+f9O6wGnVAu0yiY/eaLJFq8BbGGNQwqBjkBBQNZ8FbEsGLPCAvr1WaQ//n4iwQMnBl2BUwzBlRk5FoS6c+SiCbcj3IOQkmnDjRj/XtEjsJekwz95JM98c1ifsbFCXIf1f6Fo/4nV22f1BTeXVQDVUnAnrdtrVW1fla13b3qrTMFfxXWQe5i3y33i9Uk4JieyiLmrxS3xXBphbjx4Y+CpS6l6UzfFukkdZJu/C+yOtwrQqJb/tJi11FnY23awXU1xLINjyK4YUM953ZWrHMWwrzkdEi3oKiPzrc7eoZb425PyU8qj+N06d9TrdcPBEwCm4k+fKGzqpqwqzs8A== 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=f/I15r4bl4w9S9NHALJ5Wl7UAdQbbyEv36wyTlgcSGoIPOB/1QgI0hnHhHyN87kuLZpotwcy1tSaHAb/cBul/XHL6DNf7YpYaWpSTMGo7IFr6HL5o2cTizIEnf2wjvOps7bIknChVsjuqnyiqtkI2hoTH5BwEA31W3giHCMfpmHnWX93qGdjUo0Drtg3IJO/CZOd6BPNjFv+1bfnKRMLKEwVMt3GboMHWNmnWFyXXqrctzcC/j3UV2M5fSMcg0O/I5XCTrjiJMUhnIXgLL3SQ7IVKklhHBWDAjBHbi/YLuJUN/AvtkIUPJFgY2XGr6tFnfhLfVfgsttj0ZgBst4RMQ== 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=Hu6iZgkRj3Ywu9kxq18GCa44uIhOQlhZsZfDlt5syIK6o/4o6pZe/lmZLoibNVD4WtOuvPwMQPZJQWaTqQ77+EbL5b4dlfEAqImoa9UMcLlmSoNplOVo1qRurC4e0NUgXEsXj1WKnaZ6x1OGA+RuthaMpIc9GvaEvvrQ+/QqqW/SkJY3tH6/3T+AJ8p9e5nc98bID3I3K5Yj2H+NrkQHVBNtuL1sWuqRSbWDwfmpmLGuIrDHXML3B/LVZo8oq2WshaAzPCvUO/tbmDXqIpJob7tXgmjvF40qnWBrX0GYSPbdFz8K/NR6Q1pjzKpCjJJlKYnbXXPkkNgxRo2fg07epg== 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 AS8PR04MB8433.eurprd04.prod.outlook.com (2603:10a6:20b:407::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Thu, 1 Aug 2024 10:53:29 +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.7828.021; Thu, 1 Aug 2024 10:53:29 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Gagandeep Singh , stable@dpdk.org Subject: [PATCH 01/17] bus/dpaa: fix PFDRs leaks due to FQRNIs Date: Thu, 1 Aug 2024 16:22:57 +0530 Message-Id: <20240801105313.630280-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240801105313.630280-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0026.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::13) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|AS8PR04MB8433:EE_ X-MS-Office365-Filtering-Correlation-Id: 40a0fb83-7e4e-417a-a219-08dcb2182d6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?f8bWwlH3M6FNbHiGtsvYWxhwi6KI+FeWjlHgbrkKEce2421/BETP070bTeKj?= =?us-ascii?Q?MpqUN8Ovk023VcxE/DCSxQM39g/rNBlmFGAZQbyzxecus7UNmEI2VOoGHaFl?= =?us-ascii?Q?D1aGDVuox1Slp7njgrrsohkevSUjzjsilMjJKUfsI6gC/AH0uzCZ/Fc3TJvt?= =?us-ascii?Q?CAjM8OPfrgXWBOzf8eoqiWAcjIffYiBIfQlDjpG3BeqMYqBIoeGxOxbts/5t?= =?us-ascii?Q?4U89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2xjimAnAzJFLjC?= =?us-ascii?Q?5ZAQbDYLda1IYtioeMJMC6wSTrv96pa6IjKnhCK5NRxrs/LA9uab9C4umD9H?= =?us-ascii?Q?NFj+fmATGaaC81XAPc8axYakKhcSJF5CiTDXu+wtnf1nrUrqXx9DWxFHakLf?= =?us-ascii?Q?LHCOFqTqWg5KSbAUrKpgPPPNqFLm3JMUrOLN7+PuKhKQtANxNP/0zQL1gcIi?= =?us-ascii?Q?qncqMzp1IknnqIiAXyn8VYzvJM6QnnsbgfS6m+87lpMmJm4pBNhIf7ypQ3Y6?= =?us-ascii?Q?h+bL+r24rFMb6T9B3aynq+dOZ+Ml7USTgv8p+sbWP5/gcfH50Q=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)(376014)(366016)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?haom1nVf3tf7ur0IwxFtDz37EcWmNBifqPI9gnTIN7AzHVavQAcYgLqJ/Csv?= =?us-ascii?Q?ngxJ8DxaIdUl8b9lK6zCihxX9AV6fwFLkhrfUOaRderB4NawitVpaSPMUJqj?= =?us-ascii?Q?189FrAMQUXY/U8YivIw7yh7iw0q2lbPVRubLHVP6fqDnpeg9C+XqPAEl6s9z?= =?us-ascii?Q?m8RPn9MRBqUzUoHQJk0GIecMoPkzhtFIOP1lBZnuJkQhlv0bbB7C5LvBiGJI?= =?us-ascii?Q?bigKoEUn3EDnBEkEIuzuF18rZItJkKRoM0GGoaWlzY9OnFj8NYbYbznf3t5m?= =?us-ascii?Q?g3EdCCtS8O0nkoxPrHTNe06PE+6orD6L9ceLeL5P08uRLWCHDlg7ofYi1jUi?= =?us-ascii?Q?iH4oxEeva3nfUjGWSTt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?Q?6MpQnHHvi6rLjFvtbNvJo6EHJcUJ0wdJ7AZSBOzfAuvCDyKUauFhsxzzXtVp?= =?us-ascii?Q?GljkYHGzEPfncN09mSL5371FT1p0vzQVQ+Q8+49sIvRvz+mh8k+Edclrjoho?= =?us-ascii?Q?Kl9zkhx2KTbyc3TH+fOHzPq9SrQZkU4PTH3ZjLi5DHeV7hRM1DKmd1Q2414H?= =?us-ascii?Q?xCv2ESs3jsA3SoQ4yad/uxRKXiDsvqWuO06X6ZpwQJECWq6y81lGIYO/DFSP?= =?us-ascii?Q?eMl+lxVs1hf3y0CHC1aCvc8/eHWI6leKzkWgOZebUgo699EuuDF13xiN9uZ5?= =?us-ascii?Q?Y7HEcDds55/ytxqMZ2YSAEVhBNZLWrxwDimczKgg66YK64Z7Z1TD7PCy31jA?= =?us-ascii?Q?Qw=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40a0fb83-7e4e-417a-a219-08dcb2182d6e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 10:53:29.2638 (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: i8u1bchJNR+FKQuEUGnqKkNeuyKTy8iZ76UzjrrhGN1LPoVKXwtJGMB3sdVKfSfGYVHw9BgBSWyVkXvG901EDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8433 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