From: sashiko-bot@kernel.org
To: "Koichiro Den" <den@valinux.co.jp>
Cc: ntb@lists.linux.dev, linux-pci@vger.kernel.org
Subject: Re: [PATCH v4] PCI: endpoint: pci-epf-vntb: Track link state from both sides
Date: Thu, 15 Oct 2026 14:44:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-172985@kernel.org> (raw)
In-Reply-To: <20261015142716.3452900-1-den@valinux.co.jp>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] pci: state desync on link notification failure
--
commit d2ad15704832c4f850d567ba49113c3cd0055435
Author: Koichiro Den <den@valinux.co.jp>
PCI: endpoint: pci-epf-vntb: Track link state from both sides
This commit introduces separate tracking for HOST and VHOST link states to
ensure the effective link is reported as up only when both sides have
enabled it. It ensures both NTB clients observe the proper state by updating
and notifying when transitions complete.
Link: https://lore.kernel.org/r/20261014071448.2473208-1-den@valinux.co.jp/
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index 07ba338732d4e..bebdd93a067c0 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
[ ... ]
> +static int epf_ntb_set_link_enabled(struct epf_ntb *ntb, bool enabled)
> {
> - if (link_up)
> - ntb->reg->link_status |= LINK_STATUS_UP;
> - else
> - ntb->reg->link_status &= ~LINK_STATUS_UP;
> + bool notify;
> +
> + scoped_guard(mutex, &ntb->link_lock) {
> + notify = ntb->host_link_enabled != enabled &&
> + ntb->vhost_link_enabled;
> + ntb->host_link_enabled = enabled;
> + epf_ntb_update_link(ntb);
> + }
> +
> + if (notify)
> + return epf_ntb_notify_link(ntb->ntb);
[Severity: Medium]
If epf_ntb_notify_link() fails (for example, if pci_epc_raise_irq()
returns an error), does the link state become permanently desynchronized?
The host link state is committed inside the scoped_guard, but if the
notification fails, the state is not rolled back. If the enable command is
subsequently retried, the notify flag will evaluate to false because
ntb->host_link_enabled already matches the requested state. This would cause
the function to return 0 without ever attempting to raise the interrupt
again.
[ ... ]
> @@ -1472,11 +1505,29 @@ static int vntb_epf_peer_mw_get_addr(struct ntb_dev *ndev, int idx,
[ ... ]
> +static int vntb_epf_set_link_enabled(struct ntb_dev *ndev, bool enabled)
> +{
> + struct epf_ntb *ntb = ntb_ndev(ndev);
> + bool notify;
> +
> + scoped_guard(mutex, &ntb->link_lock) {
> + notify = ntb->vhost_link_enabled != enabled &&
> + ntb->host_link_enabled;
> + ntb->vhost_link_enabled = enabled;
> + epf_ntb_update_link(ntb);
> + }
> +
> + if (notify)
> + return epf_ntb_notify_link(ndev);
[Severity: Medium]
Similar to epf_ntb_set_link_enabled() above, could a failure in
epf_ntb_notify_link() leave the VHOST link state permanently broken?
If the IRQ fails, the state update remains committed, meaning any
subsequent attempt to enable the link will skip the notification step and
silently succeed without notifying the remote side.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015142716.3452900-1-den@valinux.co.jp?part=1
next prev parent reply other threads:[~2026-10-15 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:27 [PATCH v4] PCI: endpoint: pci-epf-vntb: Track link state from both sides Koichiro Den
2026-10-15 14:44 ` sashiko-bot [this message]
2026-10-15 15:20 ` Manivannan Sadhasivam
2026-10-15 15:22 ` Manivannan Sadhasivam
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-172985@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=den@valinux.co.jp \
--cc=linux-pci@vger.kernel.org \
--cc=ntb@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.