From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52A99606A33F for ; Fri, 4 Dec 2026 17:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=l6WNCzYU; dkim=pass (2048-bit key, unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector1 header.b=ZGdjWoTE DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To: Content-Type:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=qlz9OJPCf3Oo41q3CKffSoMOuiXsqb2ADjj3k4X0eLQ=; b=l6WNCzYUsJVTQSGJurSih7eTAs bnuPk71DRT72UzqbcWZ3n71EPDwQ0O7Nr9lZX436JWA0aeoPmippubDee5kz4SjxeML9GZbhJuFuZ +Fw3O3ZWj4RF9F/eaJafU8Up4gmmlwRLmMuCEG1MivWbpAT0DaO1/UnSrV9bqFHky2tEAwju2Xb1E JT3YXvbaxfrtjYCkX9+hObwpeMViMd16AzT1JMC3j3RcN75JwjTXLigezg79+Vjsk7ry83A4XQxyi fWK+VqhgbwWk4S3rhcqDq16yUFfN0gI3dWQkLEe52dNtEDyuIKXxFWb6/qsVXC2o+CEM4Boyp/T7/ MvGKnpkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZWle-000000010sH-2hbQ; Fri, 04 Dec 2026 17:08:39 +0000 Received: from mail-norwayeastazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c20f::7] helo=OSPPR02CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZWjn-000000010ks-32m8 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 17:07:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tjj2+3LX0OCxObd/gNEuqIH/8OB8f0y5NbVAQrmP9Gm/ibpcK+Dln29HfyUDJtNdyrIWUBwTv1TyAXctmedYbtjElJ+/kLmn55nNuhIzQUlHLVWOnchxztxE6CZMMuK4hQVmXgx0kJxgyN6M38gIBNKygStNmgTI0yXpHJ7+awemcwXbpH/n9iL+TcyCpknLiLQKA5GFSvjT03PUs8Mqbp/6uy9qeOCcK0hUPIhZ7MoaXM/ivvARXY1oUB+Gax0PybzEOFGLaVA8rPbTWbMcZ6ZANLE6TcbsRrYMNaiZ9GTN+xE/94eFW0zYmnKo/SYmY4jh+q2yv6un1O9Os2trqQ== 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=qlz9OJPCf3Oo41q3CKffSoMOuiXsqb2ADjj3k4X0eLQ=; b=b/YpsfaNKin3/ffvYDbAEqHrHyNu5OpV1E9bTVlXdJeqpZOXsOE17HXEivU/qpT+n5ykBqGw4iWpQvExLziB3mJnPdPBN4njBRVtvLolXJuDQxsXQMIQ6CSQPRwJ0nRktOFqUxHJo/ctxN0dGwC9rXyJZubqo1YM+daydjteT/WdbKDyKa4PDnosSrCWOx3VYjXl/Wr3kqmOp/aTGoX9Sd56BxMAhHpxe1ud7gm5hAS94hgSB+3RbIpLSzWAesgIjCeoZf6SzGhRUEuZDh4wAmoHcb54RoXnzpjccUumOn1GOuKlpLVvlfv60RS54ZXXBwkX740th6SKxD4YpP0Z7g== 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=qlz9OJPCf3Oo41q3CKffSoMOuiXsqb2ADjj3k4X0eLQ=; b=ZGdjWoTEVDmZZ6VETt/uOUUs9n8n/s7qyB0RxSbhQnhdAomTQYB8DUBB2cD9zPnD0PG5cEYO0kd8T4lq/f8fWEofN2r6EsLCmsjF/xPSJWpLqF+ZfBzK7syiHG8gi2rkY41KmA4Itqd0ccmW3MHwwATyg6F9jEbhu1fnxu8JrF8w+PtQLgGOs32dAriFe3CH3VLkuu9zPd85FfZYihY9DNdhAw9wdYNdr2yaHqxhVLC1gRHLr1yzAapLBnD7gFDbUeCGtt6aa8cUlrY8FAAq8uO6y+RNTvHzk3Y9SGBkdc6v/R1Ek6mxuFNapbst4D0FPoC2CNDkPrj/RQdbY3g01Q== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6900.eurprd04.prod.outlook.com (2603:10a6:208:17d::10) by AS4PR04MB086827.eurprd04.prod.outlook.com (2603:10a6:20b:4f7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 17:06:08 +0000 Received: from AM0PR04MB6900.eurprd04.prod.outlook.com ([fe80::7fda:8431:ca1b:b023]) by AM0PR04MB6900.eurprd04.prod.outlook.com ([fe80::7fda:8431:ca1b:b023%4]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 17:06:07 +0000 Date: Fri, 4 Dec 2026 19:06:03 +0200 From: Vladimir Oltean To: Anthony Pighin Cc: Madalin Bucur , "Christophe Leroy (CS GROUP)" , Claudiu Manoil , Camelia Groza , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] soc: fsl: qbman: flush the private memory before enabling QMan and BMan Message-ID: References: <20261204140329.2269842-1-anthony.pighin@nokia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204140329.2269842-1-anthony.pighin@nokia.com> X-ClientProxiedBy: FR4P281CA0219.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e4::9) To AM0PR04MB6900.eurprd04.prod.outlook.com (2603:10a6:208:17d::10) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6900:EE_|AS4PR04MB086827:EE_ X-MS-Office365-Filtering-Correlation-Id: e9a79914-a839-4183-8ef2-08df5228e344 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|376014|10070799003|19092799006|1800799024|18002099003|22082099003|10067099003|56012099006|261028144727099003|261102123227099003|261021121427099003|261026121527099003|261022105027099003|261021123027099003|261022075727099003|261026140227099003|261009223027099003|4143699003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: 3vhNiO5WXg2v4m/SAheBScEr8fcxhMjHXlUmQFHgaMpmlUfVBlqCK11si5TXmpW5upDYiQAL1pwBs/V2+mDJK7LuvdRFw4xjtdr+MPSCcW8D93y4iytaVCklTBC/CWxL8xlNIlUSIjZs7/ZX/2Ym1t5vTbR5etByPj5aOUv8Cfi5EroDFX/yxsj26IGg69z0R+P11SNWiIUJelXd8mGAA09HsBkQWkTxYym+r7AfshU3L7hqWVKXGIl6WI2NNGeU+l3URF2otR45NlYeG56xFl73KEYuDMDzx2eJnRlixWdhUNkf/NmOtLDWWhd/xmJxbbMEywRL1r746M8JDZdu50kMnQd4sdFzvrHgYSv0Al9dDWP2/q6UxLcEXZHy/aJxAWInxVxuhYvK4vtcA5V3ho1vMSZdyVzl1RSgoSJoYoIZCAHMR1kIdb7RhhaGIZwUrDj0De2H7l9vJDn+BWyq2tGI696ABsCgLYoZCoD7PTTF6aR3yXjVrYxa+gmFLVnFw198ftTHOSBfCOY8D93sMiaUjhGjrEmTka9y/7u/jAIEm/1J9bPhWuqHloXwlz9qGEbxS547YYqUJtZyj/B2nzIU0O9+CW+lyY5XxFGSMKgUv85uiy7tKUvwscCWa4yki8Ce52TFtKvOMErrD0wZ0Bi3UJyXxYNxpFFxWj/Euh4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6900.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(376014)(10070799003)(19092799006)(1800799024)(18002099003)(22082099003)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261021121427099003)(261026121527099003)(261022105027099003)(261021123027099003)(261022075727099003)(261026140227099003)(261009223027099003)(4143699003)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?AbcRkKeZUMl5ZLoWjpKjuNftmGq6BjJcbxozmJ9yiVDntobpbhBQLRG6XlYP?= =?us-ascii?Q?HWMNQ77YPUORmaWAfKLHUvc7Y/0QWtpa02++8NYiEYMQOght5YG0sTtSECDI?= =?us-ascii?Q?Zq3N6tUE6cRhAF77JKVRupU8RMSRR3mbEYKVvfOS/OBOiYULTpyt5j2qYV/L?= =?us-ascii?Q?Vu4GoTJrl1yR4NSM11ZmYaIFzwn+4hKTuRGp/WPK81EtPiVJI3WkEaFKf8wb?= =?us-ascii?Q?aYR8XjsZHz4cRjPYe1ifWJeqpQEhtJnWKlAZBD+YsW+NY5zaNykgaEnz84/M?= =?us-ascii?Q?agKIpVdW/ZywI19sltVMiH3W2kMaPSazand311M8Q9Frke9wW5HvuOkbNUcj?= =?us-ascii?Q?UsCQZRDBRBXpPM5nMiC7Zus4O3wfLdDG2asdKV4DL7JFn1r9u/270mcQVnNx?= =?us-ascii?Q?JeOHUZtFCrdL+Ld+vWI07V1FLQlXH+Bfh94OnuGvFBv0RCus/ReK3JgzSMgV?= =?us-ascii?Q?0lAGoLS7jLvUEfO0VvYkunpOsOwGlUMy+/4vsIe8g+GSnXlKfB8ifMjhLXgT?= =?us-ascii?Q?w9pJ+vwjC2x5wEvBF6Kkr7850Bv20RH3atUQgZ/yX5BBL7MITfozV1iJnFfn?= =?us-ascii?Q?4/iDAN90ySSHGp4ZiEZEn9CR++MMyqGugaj06/aJVTrZdQr8iP99i29qvZFg?= =?us-ascii?Q?aE+Ps6w4P2jv0vjMAHhqOaFJttOQE89pVB/2mrfcYr7g8j2vmlXFg2WOE7cV?= =?us-ascii?Q?4uCI0aCvhr9shZLobxFkE1ZICRiJGNoMdyTOcqWVpmuthKwJwz/63SeeZiXL?= =?us-ascii?Q?IdtNajJ199sY2mQhHYZvugQjNdn6czLFpNV8RRLsxDbjf+Opv3ZHG2vo/AKg?= =?us-ascii?Q?vQG4mG8M+idEeez/N4TfK+DHNE3BUswY53iyc441Es/+cZV27zX61ILQRMCq?= =?us-ascii?Q?hTL1L/xmkm2FHc2WaNPWN+aR8GDqWbnN2NMMBUPFUlIA+MkAFI4F7tkShdQ4?= =?us-ascii?Q?T6a8K3NzxJvduIc6CV5eJeoZRoYnOXkmbtLdbHqlUgkGt4o+tYLRh+O2UH/5?= =?us-ascii?Q?b6zQoh7eDR1fv+xMSTnIXvsUj3Kouq6qsL4m+5/z8Wmc5Q73rUTG2fbU8s/s?= =?us-ascii?Q?4stiMORkYtljVCzr4KLJ21wO4XqA5AmhqeXO05GeAt3BmqtPr8O+Ni3JRxPO?= =?us-ascii?Q?cnpTE5I1Zot5hHB9Wevpqq7ttkuDMy4ETzbrbpCsNQIJNVMcdVPh6CpA0ym3?= =?us-ascii?Q?zlIxQCRRmtbMr6JBqMu83fnYkVwjmOVsYJQNrfmmJR5QYxa/vLXSsFMHU1Rz?= =?us-ascii?Q?KTb8emIsMURsT4CXOcVr387lb2sL2oV2tUW0dbfuLwjM7v+romf9rwmTR6Y+?= =?us-ascii?Q?JGi+opFnBUNPv+Ebj7mm5k3KqQE5PwcKoPVsExCv14b8HAmWIHNPckPTdtw6?= =?us-ascii?Q?hcdOQXUvKYFfJSGhl7/c0F1QgYpL9bTw5w79xFeUW82SY698s5b0/QzEZhNj?= =?us-ascii?Q?EWglf1s2Mnt1vCCgAYwmjKTzQhGHTtU+VbwTw9cFGDRw5+m4a6+5ZX+JupZx?= =?us-ascii?Q?Obf72c2x2hZvn/tajRNr1xNQUAsGmnPzJOp/P2MbBBNg8vO8M9+xGHbsqa18?= =?us-ascii?Q?MHskpxwmN/dZWhygeAo9FLo2ErvnN46HIUOF7Pkd/EMqMvrlBMSsEfItsw36?= =?us-ascii?Q?u1lahQY5MBau+u/m45KlcC8lhVL7jNv6OtTufVJ8wMwlred19K9JGnV5UHYh?= =?us-ascii?Q?FGEyvWOKcsKOUfMHKBAAMc4ifYTFLvb3lcQCf2YLBvKiyQF4df/kSVQAq19H?= =?us-ascii?Q?39P9cKZYa2f5DqxSu1yXgYjwQFHFXcVwlYKK9a9FjFWZDA/z9VBonnYuaego?= X-MS-Exchange-AntiSpam-MessageData-1: eNS/HPy8cN5DHeS8zUyP4NF4M+E21/07oUs= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9a79914-a839-4183-8ef2-08df5228e344 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6900.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 17:06:07.6771 (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: zRxoK4Od6ItPk96K/1YvT4DnCwwopbjfUSs6agrPyjpuU8mFOvuh4ptMHq/llq+LGKBAsgyDv+hZS0Ew7+FUKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB086827 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_090709_568165_E9403410 X-CRM114-Status: GOOD ( 40.47 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Fri, Dec 04, 2026 at 09:03:29AM -0500, Anthony Pighin wrote: > Hi Vladimir, > > On Fri, Dec 04, 2026 at 12:35:23PM +0200, Vladimir Oltean wrote: > > The fact is that I don't see how a zeroed FBPR could possibly fit your > > symptoms. > > You are right. I tested it on an LS1043A with a private pool (BPID 1) > of 4096 dummy addresses. I rewrote one stored FBPR in DRAM through a > non-cacheable mapping, then drained the pool, with EMCI masked in > ERR_IER so its status stayed latched: > > FBPR rewrite zero addresses EMCI buffers lost > BP0-BP7 zeroed 8 no 0 > BP0-BP7 and FBPR_BPA zeroed 0 yes 3200 > BP0-BP7 and BPID zeroed 0 yes 2856 > all 64 bytes zeroed 0 yes 2904 > > Each time, CEAR held the index of the FBPR I had rewritten. A zeroed > FBPR drops the rest of the list and never yields zero addresses. The > reproducer behind my commit message zeroed only BP0-BP7, which is the > crafted case, so it does not support the field symptom. The BMan half > of the patch has no basis, and I'll drop it. If I'm right it also means your patch does not fix the bug you're actually trying to track down, correct? > > Did you ever reproduce this problem with the upstream driver > > that you're patching? > > We hit it with the upstream dpaa_eth driver (fsl_dpa). The oops was on > v5.15.135. The NULL buffer log is from v6.6.52, after we added the > check, which only drops and logs. > > > You also didn't mention which interface was receiving traffic, and what > > BPID it was using? > > mgmt/eth0, which is fm1-mac3 and the only DPAA interface on the board. > Its bpids file reads 0. > > > To me, the more mundane explanation that > > someone is handing buffers with address 0 to bman_release() seems > > infinitely more likely than such an accidental corruption. > > Releasing address 0 does reproduce the symptom, but not by any path I > can match to the field log. One all-zero FD enqueued to mgmt/eth0's Rx > error FQ gave: > > fsl_dpaa_mac 1ae4000.ethernet mgmt: Err FD status = 0x00000000 > rx_default_dqrr(mgmt): NULL buffer! format=0, offset=256, length=590, status=0x4 > > dpaa_fd_release() put address 0 into pool 0, and FMan received the next > frame into it. But that path logs "Err FD status" first, mgmt/eth0's > message level includes hw, and the field log has only the NULL buffer > lines. An all-zero FD on a Tx FQ was dropped without releasing > anything. I have not found what released the zero addresses on the > failing boot. There is clearly a misunderstanding here. I never said an all-zero frame descriptor. I said the buffer address is zero. They are not one and the same data structure. The FD is a QMan data structure, and its ADDRESS field may point towards the address of a buffer that FMan acquired from BMan on RX, or to something else (system memory that was never in BMan; a scatter/gather table, etc). I have no idea what "one all-zero FD enqueued to mgmt/eth0's Rx error FQ" means and therefore what you tested. I meant that inside the struct bm_buffer that gets passed to bman_release(), the "hi" and "lo" fields (in a union with "data") are zero. That was my suspicion. This way, a buffer address of 0 enters the BMan BPID that fm1-mac3 uses, and FMan will acquire this buffer address when it receives frames. No all-zero frame descriptor involved - none is needed. The important caller of bman_release() is dpaa_bp_add_8_bufs(), called from dpaa_bp_seed() and dpaa_eth_refill_bpool(). I am ignoring the other callers from dpaa_fd_release(), those are just some opportunistic buffer recycling schemes added for received packets that are otherwise errored and their underlying buffers shouldn't be delivered to the network stack, so what else to do better with them than to send them back to BMan right away, shunting the kernel memory allocator. I was never suspecting these other call paths, as there would have been other signs you would have noticed first. Anyway, the explanation from the previous paragraph is irrelevant, because what I didn't take into consideration in my previous email is the fact that bman_release() itself may be buggy, not the caller. That you may tell it to release a valid buffer address in the pool and it puts zero instead. After reviewing bman_release() itself, that seems even more likely. I have a suspicion that your problem may be fixed by the patch below. Please try. ------------------------ >8 ------------------------ >From 59c6172e11768cf49f90232a97994392f503c133 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Fri, 4 Dec 2026 17:18:40 +0200 Subject: [PATCH] soc: fsl: qbman: fix race between finding and filling an RCR entry Software interacts with the BMan through a thing called Software Portal (struct bm_portal). There are enough such portals that the driver keeps one affine to each CPU, and the locking scheme is such that get_affine_portal() calls get_cpu_var() (this disables task preemption and thus migration) and local_irq_save() avoids hardirq/softirq context from trying to acquire the same portal, resulting in a deadlock. The created context ensures nobody else may concurrently interact with the portal as long as they keep using the same affine scheme. One of the things that the BMan software portal contains is the Release Command Ring (RCR) with 8 entries, used by bman_release(). Software is the producer and QMan the consumer, so bman_release() has logic to wait for rcr->available to be updated, indicating that the ring may hold the new RCR entry. If the RCR is not available, bman_release() relinquishes the software portal before retrying. If available, bm_rcr_start() gives the RCR entry that is available for writing. The problem is that bman_release() relinquishes the software portal even if a RCR entry is available, to quickly re-enter another atomic section which actually performs the RCR write outside the "do {} while (--timeout)" loop. In the window between the first and the second atomic sections, another bman_release() call on the same software portal can run concurrently (the calling context may be from the task that runs dpaa_eth_probe() -> ... -> dpaa_bp_seed(), so both preemptible and interruptible). This second bman_release() will find the same RCR entry "r" to be available, as returned by bm_rcr_start(). The preempt/interrupt train can continue ad infinitum, but let's assume the second bman_release() call, which interrupted the first, manages to enter the second critical section, populate and commit the RCR entry. bm_rcr_pvb_commit() increments rcr->cursor by calling rcr_inc(). Execution resumes in the first bman_release() context, and this still has a hold on the 'r' local variable (representing a RCR entry already committed). What's really problematic is that bm_rcr_pvb_commit() does not take this 'r' local variable, but it re-reads rcr->cursor, which was already advanced earlier rcr_inc()!! So a RCR entry that nobody wrote anything valid to got committed to BMan. If the race condition happens quickly after boot (like, during the first 8 dpaa_bp_add_8_bufs() calls), the rcr->cursor committed by the preempted bman_release() call will probably be all zeroes, so this will release 8 buffers with address zero to BMan. If the race happens later than that, the stale contents of rcr->cursor, from 8 bman_release() calls ago, will be recommitted to BMan, resulting in even more hard-to-debug chaos. The fix seems to be rather simple: if bm_rcr_start() gave us a valid RCR entry, keep a tight grip onto the atomic context until we commit it to hardware. No two-step nonsense. The vaguely-similar-in-principle qman_enqueue() does the same thing when "eq" is non-NULL. Fixes: 1f9c0a77278b ("soc/fsl: Introduce DPAA 1.x BMan device driver") Signed-off-by: Vladimir Oltean --- drivers/soc/fsl/qbman/bman.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c index f22eff294122..d929c2ce8a5e 100644 --- a/drivers/soc/fsl/qbman/bman.c +++ b/drivers/soc/fsl/qbman/bman.c @@ -752,19 +752,17 @@ int bman_release(struct bman_pool *pool, const struct bm_buffer *bufs, u8 num) if (avail < 2) update_rcr_ci(p, avail); r = bm_rcr_start(&p->p); - local_irq_restore(irqflags); - put_affine_portal(); if (likely(r)) break; + local_irq_restore(irqflags); + put_affine_portal(); udelay(1); } while (--timeout); if (unlikely(!timeout)) return -ETIMEDOUT; - p = get_affine_portal(); - local_irq_save(irqflags); /* * we can copy all but the first entry, as this can trigger badness * with the valid-bit -- 2.53.0 ------------------------ >8 ------------------------