From nobody Mon Jun 8 09:49:05 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED2CD39183E for ; Thu, 4 Jun 2026 08:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780562100; cv=none; b=UAIYMWx9Yj01S2KpWXhwzqzuYozxowTAz6Xs1QLzfwoQF+eJka/aR/zlBgLAuPPeL2IDM9cG9+Gcx81kswep56bLk7rHW/p7fUrYK1UnaGn67nshXbylLidZPP0VtXaJL/vGavlGquEOIzYXJ0cMlybWr3eW2mb2Q5482sYFkIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780562100; c=relaxed/simple; bh=7xkCNWzTHwH4KjhG82guMkcHYLVCOZWaHOgz2v54Nus=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Els9Ai5xf4xbt6r4Fvi9vnwr82n6icRpY9GSX2A4BGCg1+UP3Mw0dPaSM6yi16QPUoI4jHFss+28M2G+0Rof6dPcleHMDKs2arM4fq7hnRA4mdGsK6fanXu4vO2mcVcj/R1B4Wm3RoMVFLg4VYdwu+v+3gbHWVvqeD3pauXCgf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NFFN72BT; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NFFN72BT" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2c0b944f6edso4715025ad.2 for ; Thu, 04 Jun 2026 01:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780562098; x=1781166898; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2bzSs0ZVqqiauGWrvhNjF8srpvUpc4xJa5mRvzbd3e8=; b=NFFN72BTn8BIZRQulHqCvRxbr7chbmPbBcl0Ob3Ed/cshmZa/GEI68aAk7c/1rGcyD SnkqUyQu0NnAg2vXRbW7DV+LCI++YtCxpTRsEjcEF+QJHP9pzvTsaQ6A501kA41ymJiP /hZnlVReKdBycG3U0uG56IUb8T+/ATrJIbx5Zw2XQO5b/9Cn5i2+4uY5dd+3AJrB2pqi VhDfbtCipagJNclJhxiS7pat/CY/QKkZBcNaMNI21dJmI51LIpdRgGnWZsFomvFrDAWo Sv9Q+hB6TlG/CG++D5uza8sgggqBEe5DawXlv/cKfWU1C5CepeOpN6MbM5mu5Wn6k8A1 Lm4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780562098; x=1781166898; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2bzSs0ZVqqiauGWrvhNjF8srpvUpc4xJa5mRvzbd3e8=; b=soOxWPNXYwOu2KJWm/wAo6axMcEflg2eTMIafy9W0+yAX5GMlknL/F0o04/Cb9gTHn iArwtloCBO6CCqvrtBkDPohbC5zshT8YNJPCmBvD6/+AQlf4JgXm2pbVhdgBz42/w9Pi 07/5Od7QbTWbxG1uKj6rKLxGr2DkG0DklexCZYdbu2vO5ADlRJ9AXrsxG2xHVB3Pz/if m9sHNA726dTs051GrUsdCqBmfyVXG8c64RcNyoO1bHCW9/WgwCIthExTROclLapvvXaY hViDtNiaIBgICvRCyWDF+MFS0rNn3gSMbRTLpci7HZ8Psvoc2gOsZnLJalUYVIUsIyE6 oMug== X-Forwarded-Encrypted: i=1; AFNElJ+WWrXe6w5e7vRR2kQzGBJ7zAk05FRfOcnQrn2NOXD+6Jt8daQTi6i0R+GlBNHw8ZsDMZ6+POKkHvbvIcs=@vger.kernel.org X-Gm-Message-State: AOJu0YxpP7ihD1sdqXcBnxcAF8zHHMXIAP1tZ9OvZU99kFWvnpu6Zjxl nYEFnQ9uIbt6IM8KlxoyDtOHWCw8r7IC25oM1SUDtJT1+Wzsfgtm8KK3 X-Gm-Gg: Acq92OE8MMg5HAssGVCZ2Fh3aDLIIt4hLtRQLmA3oPE4LVi6zCXV8rx42DcNrzjgply wuUATotq+Y5QxHdRo3AVaDQkgXpnp8FvOXKF/Y9n4J+9YzhZgHgoz0gXL7xLFi71PuqY/d2Y7JZ kr6tUaCSOc63B70JS9ueQohIkUicwX6wO9orq+utP3BwDo3pViOurH8OTHeBRfCsxsfLm0p1NhF UD2mZVaxquXOlWk2TcfysoQpG85yCs8xobX+xVTwE4u1p/h252W55k7HojKWxIUyCji9IIunE7m gm50s4WsrhZwmTsu1J4juHqjJQnljo41snYPNmuwH4HoeYQwxKL34HgfEljuYrvUgpmTnbOLqDG mcmUXdI6eZPxmkHxaS3zsDh53djnEDffNbtGak6Zl1S4307upK9cc9kmLgiUezH3kHGR9birWst gN1Hyn+y+jbVWB7bxkDpk74cok9eDYsD9I98RGqTC5VjhTRcGAPOUDwjFy/ilUwtyBRb3Ck1irq RhPG8Am30DBmjTp1vgvUx6Bz6e3YxltymCnGxa1VID4jZ8h4lGtsBZb07/VD6z4G376 X-Received: by 2002:a17:903:1a4e:b0:2c0:c4c9:4cb with SMTP id d9443c01a7336-2c163a592f1mr74142365ad.14.1780562098075; Thu, 04 Jun 2026 01:34:58 -0700 (PDT) Received: from bass-virtual-machine.. ([111.202.175.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f84335sm50117445ad.19.2026.06.04.01.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 01:34:56 -0700 (PDT) From: Gui-Dong Han To: krzysztof.czurylo@intel.com, tatyana.e.nikolova@intel.com, linux-rdma@vger.kernel.org Cc: jgg@ziepe.ca, leon@kernel.org, mustafa.ismail@intel.com, shiraz.saleem@intel.com, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, Gui-Dong Han Subject: [PATCH] RDMA/irdma: Use acquire/release for CQP request completion Date: Thu, 4 Jun 2026 16:34:40 +0800 Message-Id: <20260604083440.426033-1-hanguidong02@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The completion path fills cqp_request->compl_info before marking request_done and waking waiters. irdma_wait_event() waits for request_done before reading compl_info. READ_ONCE()/WRITE_ONCE() do not order these accesses, so a waiter can observe request_done while still seeing stale completion information. Use release/acquire helpers for request_done to publish compl_info to the waiting thread. Clearing request_done does not publish completion information. It only reinitializes a private request before returning it to cqp_avail_reqs under req_lock, so WRITE_ONCE() is enough for the false transition. Fixes: 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitio= ns") Fixes: 915cc7ac0f8e ("RDMA/irdma: Add miscellaneous utility definitions") Signed-off-by: Gui-Dong Han --- Found by auditing READ_ONCE() used for synchronization. A similar fix can be found in 8df672bfe3ec. --- drivers/infiniband/hw/irdma/hw.c | 2 +- drivers/infiniband/hw/irdma/main.h | 22 +++++++++++++++++++++- drivers/infiniband/hw/irdma/utils.c | 6 +++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/irdma/hw.c b/drivers/infiniband/hw/irdma= /hw.c index f9be467d137f..96fecb28af97 100644 --- a/drivers/infiniband/hw/irdma/hw.c +++ b/drivers/infiniband/hw/irdma/hw.c @@ -235,7 +235,7 @@ static void irdma_complete_cqp_request(struct irdma_cqp= *cqp, struct irdma_cqp_request *cqp_request) { if (cqp_request->waiting) { - WRITE_ONCE(cqp_request->request_done, true); + irdma_cqp_request_mark_done(cqp_request); wake_up(&cqp_request->waitq); } else if (cqp_request->callback_fcn) { cqp_request->callback_fcn(cqp_request); diff --git a/drivers/infiniband/hw/irdma/main.h b/drivers/infiniband/hw/ird= ma/main.h index 3d49bd57bae7..57102278ed64 100644 --- a/drivers/infiniband/hw/irdma/main.h +++ b/drivers/infiniband/hw/irdma/main.h @@ -167,12 +167,32 @@ struct irdma_cqp_request { void (*callback_fcn)(struct irdma_cqp_request *cqp_request); void *param; struct irdma_cqp_compl_info compl_info; - bool request_done; /* READ/WRITE_ONCE macros operate on it */ + bool request_done; /* Use irdma_cqp_request_*() helpers. */ bool waiting:1; bool dynamic:1; bool pending:1; }; =20 +static inline void +irdma_cqp_request_clear_done(struct irdma_cqp_request *cqp_request) +{ + WRITE_ONCE(cqp_request->request_done, false); +} + +static inline void +irdma_cqp_request_mark_done(struct irdma_cqp_request *cqp_request) +{ + /* Publish compl_info before waking the waiter. */ + smp_store_release(&cqp_request->request_done, true); +} + +static inline bool +irdma_cqp_request_is_done(struct irdma_cqp_request *cqp_request) +{ + /* Pair with irdma_cqp_request_mark_done(). */ + return smp_load_acquire(&cqp_request->request_done); +} + struct irdma_cqp { struct irdma_sc_cqp sc_cqp; spinlock_t req_lock; /* protect CQP request list */ diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/ir= dma/utils.c index 495e5daff4b4..566f690a4e58 100644 --- a/drivers/infiniband/hw/irdma/utils.c +++ b/drivers/infiniband/hw/irdma/utils.c @@ -480,7 +480,7 @@ void irdma_free_cqp_request(struct irdma_cqp *cqp, if (cqp_request->dynamic) { kfree(cqp_request); } else { - WRITE_ONCE(cqp_request->request_done, false); + irdma_cqp_request_clear_done(cqp_request); cqp_request->callback_fcn =3D NULL; cqp_request->waiting =3D false; cqp_request->pending =3D false; @@ -515,7 +515,7 @@ irdma_free_pending_cqp_request(struct irdma_cqp *cqp, { if (cqp_request->waiting) { cqp_request->compl_info.error =3D true; - WRITE_ONCE(cqp_request->request_done, true); + irdma_cqp_request_mark_done(cqp_request); wake_up(&cqp_request->waitq); } wait_event_timeout(cqp->remove_wq, @@ -610,7 +610,7 @@ static int irdma_wait_event(struct irdma_pci_f *rf, do { irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq); if (wait_event_timeout(cqp_request->waitq, - READ_ONCE(cqp_request->request_done), + irdma_cqp_request_is_done(cqp_request), msecs_to_jiffies(CQP_COMPL_WAIT_TIME_MS))) break; =20 --=20 2.34.1