From: sashiko-bot@kernel.org
To: "Yanze Zhang" <zhang.yanze@zte.com.cn>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma v10 6/7] RDMA/zrdma: Add device probe and remove logic
Date: Thu, 03 Dec 2026 13:28:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-247858@kernel.org> (raw)
In-Reply-To: <20261203124928.48716-7-zhang.yanze@zte.com.cn>
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 <zhang.yanze@zte.com.cn>
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/infiniband/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_table);
> 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 =
> + 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 = 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/infiniband/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 <linux/etherdevice.h>
> #include <linux/rtnetlink.h>
>
> +/* 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 *zdev)
> if (ret)
> return ret;
>
> + ret = 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 = &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 = 1;
> +
> ret = ib_register_device(&zdev->ibdev, "zrdma%d", zdev->rf->hw.device);
> if (ret)
> goto error;
>
> + 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().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203124928.48716-1-zhang.yanze@zte.com.cn?part=6
next prev parent reply other threads:[~2026-12-03 13:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:49 [PATCH rdma v10 0/7] Add ZTE DingHai Ethernet Protocol Driver for RDMA Yanze Zhang
2026-12-03 12:49 ` [PATCH rdma v10 1/7] RDMA/zrdma: Add build infrastructure and module skeleton Yanze Zhang
2026-12-03 13:19 ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 2/7] RDMA/zrdma: Add core data structures and ABI definitions Yanze Zhang
2026-12-03 13:21 ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 3/7] RDMA/zrdma: Add internal headers and hardware register definitions Yanze Zhang
2026-12-03 13:17 ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 4/7] RDMA/zrdma: Add hardware resource initialization and verbs skeleton Yanze Zhang
2026-12-03 13:20 ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 5/7] RDMA/zrdma: Implement device and port query operations Yanze Zhang
2026-12-03 12:49 ` [PATCH rdma v10 6/7] RDMA/zrdma: Add device probe and remove logic Yanze Zhang
2026-12-03 13:28 ` sashiko-bot [this message]
2026-12-03 12:49 ` [PATCH rdma v10 7/7] RDMA/zrdma: Implement context, PD, and mmap operations Yanze Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-247858@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhang.yanze@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox