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=1796304485; b=oQ0VNcn3cdjibvZgBbxT4We85kfh+rI4x2OVTO+ZRckDGi04smEZBLzGnuWvOZcAGdW/ 921k2eqOaQxDaENn3VuzdugV0Oep/YhQBFDwOTOTojL9PvuXlYcxpwquc4c9WTQUwPjkF zslZNA5PY45y1VaqyANHqxX77ZB1zM4K5geX6nI0wUjniWbUrEnLK27a2BYRn/zFoTTE8 OcGKV0fVVVM/2Ap2NrV7KDRcDybju5hAK+Uz4P34Yi4RSoKdy+3Ks2MB8tpt9RI07y6tF Z1UFEeQvJI9qO1ZLj0ZFFLoiXIgpiujxj/6toUEVmRPXYZauvS2LKs054qfp3rccKyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796304485; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ljiTG/GkQ1k5NW52Q82fPe0DbYCTNT5LK/ps+mF+HYc=; b=A1qO0r+UAEZOelC5lAYtL/KM1EEI31LIWz05tXbNAiMz1o07qzpP8A0RVjkLrrQbE0Sx ATrGJAtJSrRwjPYAqeSN9GzKXRNWht6EaZjuoJDRP8TlEvdjxWuIvuQmzdf0sqr3z7BoY mrnPIuhyUY5TE4YIsumIyw/HvROC8/OTYkIl/t6UJ3qHMIkVzhQMrM7kdb0ozVeZ5EQkO fgJ09W9xoDsndRP9H0x3EfINnWpGebCQtcWJFs4dKQDAeTlGe/5STB+9WMrkAlwwZUg++ 2GnxiKqfViFF4YmN1T+58g/HnfUmqPgZt81DNXVRvdsWrIZqfO8bfXNfEZbslalhqcw== 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=JC+QIIOd; 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 ACD18606A322 for ; Thu, 3 Dec 2026 13:28:05 +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=JC+QIIOd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2562F1F00893; Thu, 3 Dec 2026 13:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796304485; bh=ljiTG/GkQ1k5NW52Q82fPe0DbYCTNT5LK/ps+mF+HYc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JC+QIIOdoBedF9Yx/euUQm8E4kC2Xl+v2abNTEt/nBi4D2roCfuDXvv6h2l8Rcui6 srW9dgHxqnj4lgMnZFUMe0rFkqeNlHoBa0h1nZffdHWl4EodmZE2nEQ2bBpLnIvQoa j5ptLDJTZuPGjOzvKqUBTXpeoIUXXDIKIpmBqw1W+Z0MNoQiAkST7jLweGkZ+6vgiQ Z6iFGTse8c/jkeyCVMOVzQ4zb58Yn2t4diNx7z5xj9WeVlXSfCOj9Wn03sJGNNp9uo roi23dEBqM+ba485LT/TEzINP9emw0f2caHjeZW45k9uK2JU9+Pl6aWuRSqhyoVVZN ChkG+khblwTiw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH rdma v10 6/7] RDMA/zrdma: Add device probe and remove logic Reply-To: sashiko-reviews@lists.linux.dev To: "Yanze Zhang" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261203124928.48716-7-zhang.yanze@zte.com.cn> References: <20261203124928.48716-1-zhang.yanze@zte.com.cn> <20261203124928.48716-7-zhang.yanze@zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 13:28:04 +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: - [High] RDMA/zrdma: missing NETDEV_UNREGISTER handling and raw netdev dereference - [Medium] RDMA/zrdma: private aux ABI structs lack shared header and in-tree producer - [Medium] RDMA/zrdma: unconditional IB_EVENT_PORT_ACTIVE in zxdh_ib_register_device() - [Low] RDMA/zrdma: comment in zxdh_remove() references external cover letter - [Low] RDMA/zrdma: unnecessary external linkage on zxdh_ib_dealloc_device() -- commit ad31754b639afef102a3dab9f8f998599b93d10f Author: Yanze Zhang RDMA/zrdma: Add device probe and remove logic This commit implements the auxiliary bus probe and remove callbacks for zrdma, initializing hardware resources, binding the netdev, and registering the IB device with its dealloc_driver hook. > diff --git a/drivers/infiniband/hw/zrdma/zrdma_main.c b/drivers/infiniban= d/hw/zrdma/zrdma_main.c > index da42494a43c69..fe4187cef68f5 100644 > --- a/drivers/infiniband/hw/zrdma/zrdma_main.c > +++ b/drivers/infiniband/hw/zrdma/zrdma_main.c [ ... ] > @@ -26,14 +111,95 @@ MODULE_DEVICE_TABLE(auxiliary, zxdh_auxiliary_id_tab= le); > static int zxdh_probe(struct auxiliary_device *aux_dev, > const struct auxiliary_device_id *id) > { > - /* Placeholder: Real probe logic will be added in subsequent patches */ > - dev_info(&aux_dev->dev, "ZTE DingHai RDMA device detected (stub)\n"); > + struct zxdh_auxiliary_dev *zxdh_adev =3D > + container_of(aux_dev, struct zxdh_auxiliary_dev, adev); > + struct zxdh_device *zdev; > + struct zxdh_pci_f *rf; > + struct net_device *netdev; > + int err; > + > + if (!zxdh_adev->rdma_ops || !zxdh_adev->rdma_ops->get_rdma_netdev) { > + pr_err("zrdma: rdma_ops or get_rdma_netdev is NULL\n"); > + return -EINVAL; > + } > + > + if (!zxdh_adev->zxdh_info) { > + pr_err("zrdma: zxdh_info is NULL\n"); > + return -EINVAL; > + } > + > + /* The pci device is the DMA capable device of the IB device and > + * the source of the vendor id, so it has to be there. > + */ > + if (!zxdh_adev->zxdh_info->pdev) { > + pr_err("zrdma: pci device is NULL\n"); > + return -EINVAL; > + } > + > + netdev =3D zxdh_adev->rdma_ops->get_rdma_netdev(zxdh_adev->parent); [Severity: Medium] Should struct zxdh_auxiliary_dev and its ops live in a shared header under include/linux/ rather than privately in zrdma_type.h? The in-tree DINGHAI_PF driver (zxdh_pf_probe() in drivers/net/ethernet/zte/dinghai/en_pf.c) never creates a net_device or registers dinghai10e.rdma_aux, so zxdh_probe() is unreachable in-tree. Keeping the auxiliary struct layout and untyped void * callbacks private to the RDMA driver also removes compile-time type checking across the PF/RDMA boundary, risking memory corruption or bad indirect calls if the two sides diverge. [ ... ] > + /* No 'get' on the ib_device, so the _and_put variant would > + * underflow ib_device.refcount; see cover letter. > + */ > + ib_unregister_device(&zdev->ibdev); [Severity: Low] This isn't a bug, but the "see cover letter" reference will be dangling once committed since cover letters are not stored in git. The first clause already explains why ib_unregister_device() is used, so that trailing reference can be dropped. > diff --git a/drivers/infiniband/hw/zrdma/zrdma_verbs.c b/drivers/infiniba= nd/hw/zrdma/zrdma_verbs.c > index b5322a8e129bb..a410ef4521ad5 100644 > --- a/drivers/infiniband/hw/zrdma/zrdma_verbs.c > +++ b/drivers/infiniband/hw/zrdma/zrdma_verbs.c > @@ -11,6 +11,31 @@ > #include > #include > =20 > +/* Release everything the probe path may have allocated. The hook is > + * called from ib_dealloc_device(), so it must tolerate a partially > + * initialised device. > + */ > +void zxdh_ib_dealloc_device(struct ib_device *ibdev) [Severity: Low] Can zxdh_ib_dealloc_device() be marked static and its prototype removed from zrdma_verbs.h? Its only caller is zxdh_dev_ops.dealloc_driver in this file. [ ... ] > @@ -325,13 +361,32 @@ int zxdh_ib_register_device(struct zxdh_device *zde= v) > if (ret) > return ret; > =20 > + ret =3D ib_device_set_netdev(&zdev->ibdev, zdev->netdev, 1); > + if (ret) > + goto error; [Severity: High] Does binding zdev->netdev without a netdevice_notifier hang netdev teardown on NETDEV_UNREGISTER? ib_device_set_netdev() takes a netdev reference and requires detaching with NULL or unregistering the ib_device on NETDEV_UNREGISTER. Because zxdh_get_drvinfo() supports a bond master, deleting the bond with "ip link del" leaves unregister_netdevice() hung in netdev_wait_allrefs_any(). Also, zxdh_get_drvinfo(), zxdh_query_device(), and zxdh_query_port() dereference raw zdev->netdev instead of using ib_device_get_netdev(). If the PF tears down the aux device asynchronously, zxdh_get_drvinfo() can call ethtool_ops->get_drvinfo() on an unregistered netdev. > + zdev->rf->hw.device =3D &zdev->rf->pcidev->dev; > + dma_set_max_seg_size(zdev->rf->hw.device, SZ_1G); > + > + /* Publish the link state before the device becomes visible to > + * userspace, so a racing ULP never observes a stale status. > + */ > + zdev->ibdev_status =3D 1; > + > ret =3D ib_register_device(&zdev->ibdev, "zrdma%d", zdev->rf->hw.device= ); > if (ret) > goto error; > =20 > + zxdh_port_ibevent(zdev); [Severity: Medium] Should zdev->ibdev_status reflect the actual netdev link state instead of unconditionally reporting IB_EVENT_PORT_ACTIVE? When zxdh_probe() runs while zdev->netdev is down or lacks carrier, zxdh_port_ibevent() still queues IB_EVENT_PORT_ACTIVE, while zxdh_query_port() checks netif_carrier_ok() and netif_running() and populates the port cache with IB_PORT_DOWN. The comment above zdev->ibdev_status is also inaccurate since nothing outside zxdh_port_ibevent() reads it. Deriving it from netif_running(zdev->netdev) && netif_carrier_ok(zdev->netdev) would keep the initial event consistent with zxdh_query_port(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203124928.4871= 6-1-zhang.yanze@zte.com.cn?part=3D6