From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303868; b=t/grjdnDjVFz056AD8ROWAEEiL/jIOYi7W7uumjBCNQP9b00VHHUFE+8wHCl035QjNbt BKFh5Q0Z1wdXKc3886wE4y34mDLAntb5bDSNSnI8b1GJXVdbqv85gP79rsFBcgosjsdxn azb2z1Kp8p8nnHK0Sdpaabx+Sr/nToIrsloTCKFY4H4BvshXqUuKGPnk13/aHF8/ZZySR 1FYKqkXKln+wz8eGXUB3dMxLy5pA6LYr4+CzAhAan2roZUMwyFlwcZg+xc70YYhISgOyu Anw8UDNYVWHy74XrufY8LOlCWwp5sdk6QY6Ai4gW7oNNQzUJ561B51Cim3YQ2wTUlfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303868; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=B45IgOtNaA8y5pwjSvTLC2zsXSBSH9YkvksJXsGtS60=; b=KVD5JzbwlNX344KTIHl+wycebRgxxgYMiUvuWYrWhaUtIpY1bQie0bqS0fBnAlLbtDfy 5OLRDxXI5EIGN5IAHA6ouAIvcL+5+yWtYMNABDffzBpGMNNWXrJnvFB2FiVg578yXg4cL IU4K5ipTfgrQCJrNyjYbgUWN14zN8GY2pNBJf5heub87+I3a3yzWbVl6bv6yff0SWPcVT TU2hVl6jqFEqyYAs+0vsDyOB3xoUY26i4TTQZofUFMgmoIo8e7Pi0VdriYDcwl2mZmhLF D7DAiWoeRAshVSwcEhJVdvUIc2rngASi1mPf/1F2MC8piqvvBse8p7k7AA74EkIGSIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lUMdFd6B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED9EE606A322 for ; Thu, 3 Dec 2026 13:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lUMdFd6B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AA951F000C1; Thu, 3 Dec 2026 13:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796303867; bh=B45IgOtNaA8y5pwjSvTLC2zsXSBSH9YkvksJXsGtS60=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lUMdFd6B2eXe+Bdg/NgHhfEvBV3U8f2o0aWlPCNQBusRxa5geVadQ9I9MN0rFzosQ 7KtKWlG9BPRX2q95KBvippukAemJvWmMuiPIMLpGY07UyCpLHqKuJm27a1rC232da8 Tm+Krxsvou0XVugEgNl7xqwhc2NAhlYT7jLUYwh1BaiNLmEZVmfyazD8YKNRk1oiDv HQM6TKjX6R1ijqbWL8xm/bWu449G8KplU46oRqieJ9q/+/xaXyWawED0fD11bY2oia 5CKHfM9Mf5DjrhGiogbm/IHVB1cntiDaTyX5o52plRMFKBUIxc8jcycD9ZxT+c6NqT PXbYnjzhcrG+g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH rdma v10 3/7] RDMA/zrdma: Add internal headers and hardware register definitions Reply-To: sashiko-reviews@lists.linux.dev To: "Yanze Zhang" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261203124928.48716-4-zhang.yanze@zte.com.cn> References: <20261203124928.48716-1-zhang.yanze@zte.com.cn> <20261203124928.48716-4-zhang.yanze@zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 13:17:46 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] RDMA/zrdma: private duplication of DingHai PF auxiliary device structures - [Medium] RDMA/zrdma: unratelimited pr_err() on pool exhaustion in zxdh_alloc_rsrc() - [Medium] RDMA/zrdma: redundant double bitmap scan under IRQ lock in zxdh_alloc_rsrc() - [Low] RDMA/zrdma: custom bitmap allocator in zxdh_alloc_rsrc() duplicates IDA - [Low] RDMA/zrdma: inaccurate commit message and unused include in zrdma_hw.h -- commit 4aa7f9886978b5ae50f8e49fdf3985cfb3bc918d Author: Yanze Zhang RDMA/zrdma: Add internal headers and hardware register definitions This commit adds zrdma_hw.h and zrdma_main.h with resource capacity limits, driver state structures, and inline resource bitmap helpers, and adds a comment to zrdma_type.h describing the auxiliary device layout. > diff --git a/drivers/infiniband/hw/zrdma/zrdma_hw.h b/drivers/infiniband/= hw/zrdma/zrdma_hw.h > new file mode 100644 > index 0000000000000..16c5041ac0757 > --- /dev/null > +++ b/drivers/infiniband/hw/zrdma/zrdma_hw.h > @@ -0,0 +1,21 @@ > +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB > + * > + * ZTE DingHai Rdma driver > + * Copyright (c) 2022-2026, ZTE Corporation > + */ > + > +#ifndef ZRDMA_HW_H > +#define ZRDMA_HW_H > +#include "zrdma_main.h" > + > +#define ZXDH_MAX_CQE 0x200000 > +#define ZXDH_MAX_QP 0x4000 > +#define ZXDH_MAX_MR 0x10000 > +#define ZXDH_MAX_CQ 0x4000 > +#define ZXDH_MAX_SRQ 0x2000 > +#define ZXDH_MAX_PD 0x100000 > +#define ZXDH_MAX_AH 0x10000 > +#define ZXDH_MAX_MCG 0x4000 > +#define ZXDH_MAX_8K_IDX 0x1c0 > + > +#endif /* ZRDMA_HW_H */ [Severity: Low] Does zrdma_hw.h need to include zrdma_main.h? It references nothing from zrdma_main.h, and pulling it in here prevents zrdma_main.h from including zrdma_hw.h without a circular include. Also, the commit subject and message state that this adds hardware register definitions, whereas zrdma_hw.h only defines ZXDH_MAX_* resource capacity limits and the message does not mention the comment added to zrdma_type.h. > diff --git a/drivers/infiniband/hw/zrdma/zrdma_main.h b/drivers/infiniban= d/hw/zrdma/zrdma_main.h > new file mode 100644 > index 0000000000000..d65811735e74e > --- /dev/null > +++ b/drivers/infiniband/hw/zrdma/zrdma_main.h > @@ -0,0 +1,177 @@ [ ... ] > + unsigned long *allocated_qps; > + unsigned long *allocated_cqs; > + unsigned long *allocated_mrs; > + unsigned long *allocated_pds; > + unsigned long *allocated_mcgs; > + unsigned long *allocated_ahs; > + unsigned long *allocated_srqs; > + unsigned long *allocated_pris; > + unsigned long *allocated_8k_idx; [Severity: Low] Can these nine resource bitmaps and zxdh_alloc_rsrc()/zxdh_free_rsrc() use struct ida or XArray instead of a custom bitmap allocator? Per-pool IDA avoids allocating 128 KiB upfront for allocated_pds (ZXDH_MAX_PD) when few PDs are used and removes cross-pool contention on rsrc_lock. In zxdh_alloc_rsrc(), scoped_guard(spinlock_irqsave, &rf->rsrc_lock) would also avoid the bare compound block around guard(), and -ENOSPC or -ENOMEM would fit pool exhaustion better than -EOVERFLOW. [ ... ] > +static inline int zxdh_alloc_rsrc(struct zxdh_pci_f *rf, > + unsigned long *rsrc_array, u32 max_rsrc, > + u32 *req_rsrc_num, u32 *next, > + const char *rsrc_name) > +{ [ ... ] > + { > + guard(spinlock_irqsave)(&rf->rsrc_lock); > + > + rsrc_num =3D find_next_zero_bit(rsrc_array, max_rsrc, *next); > + if (rsrc_num >=3D max_rsrc) > + rsrc_num =3D find_first_zero_bit(rsrc_array, max_rsrc); [Severity: Medium] Why does the wrap-around call to find_first_zero_bit() scan up to max_rsrc instead of *next? Since rf->rsrc_lock is held across both calls, the range [*next, max_rsrc) is still all-ones and is scanned twice. For a full PD pool (ZXDH_MAX_PD =3D 0x100000, a 128 KiB bitmap), this scans= up to 256 KiB with local IRQs disabled while stalling zxdh_free_rsrc() and all other pools sharing rf->rsrc_lock. Bounding the second scan to min(*next, max_rsrc) would avoid the redundant pass. [ ... ] > + if (ret) > + pr_err("zrdma: %s pool exhausted (capacity %u)\n", > + rsrc_name, max_rsrc); [Severity: Medium] Can userspace flood the kernel log through this unratelimited pr_err()? Once a pool is full, repeated allocation requests from /dev/infiniband/uver= bs will emit an unbounded stream of error messages without device context. Using ibdev_dbg() (as irdma_alloc_rsrc() does) or ibdev_err_ratelimited(), or leaving logging to the callers, would prevent log flooding. > diff --git a/drivers/infiniband/hw/zrdma/zrdma_type.h b/drivers/infiniban= d/hw/zrdma/zrdma_type.h > index ded4052453455..c6ad2be17c159 100644 > --- a/drivers/infiniband/hw/zrdma/zrdma_type.h > +++ b/drivers/infiniband/hw/zrdma/zrdma_type.h > @@ -21,6 +21,12 @@ enum zxdh_function_type { > ZXDH_FUNCTION_TYPE_VF, > }; > =20 > +/* > + * The structures below describe the auxiliary device of the DingHai PF > + * driver. Their layout has to match the definition of the PF driver > + * exactly, because the probe path reads them through the auxiliary devi= ce > + * that the PF driver provides. > + */ > struct zxdh_rdma_core_dev; [Severity: Medium] Should struct zxdh_auxiliary_dev and struct zxdh_rdma_core_dev live in a shared header under include/linux/ instead of being duplicated here? Priva= te copies drop compile-time layout checks across modules, so any PF struct cha= nge or CONFIG_RANDSTRUCT corrupts memory on container_of() in probe. This also breaks the rule in include/linux/auxiliary_bus.h that the parent wrapper and shared objects live in a shared header, and the in-tree DingHai PF driver (drivers/net/ethernet/zte/dinghai/en_pf.c) neither defines these structures nor registers an auxiliary device. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203124928.4871= 6-1-zhang.yanze@zte.com.cn?part=3D3