Re: [PATCH] NTB: epf: propagate memory window command errors
From: Koichiro Den
Date: Wed Oct 28 2026 - 01:48:07 EST
On Tue, Oct 27, 2026 at 05:49:53PM +0200, Avi Weiss wrote:
> ntb_epf_mw_set_trans() and ntb_epf_mw_clear_trans() discard the result
> of ntb_epf_send_command() and return success even when the endpoint
> reports a command failure or fails to respond. This prevents NTB
> clients from detecting a failed memory window operation.
>
> Return the command status from both callbacks. Preserve the existing
> teardown error diagnostic.
>
> Fixes: 812ce2f8d14e ("NTB: Add support for EPF PCI Non-Transparent Bridge")
> Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
> ---
> drivers/ntb/hw/epf/ntb_hw_epf.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
> index c47607d4f8a7f..dd10c30bdbec4 100644
> --- a/drivers/ntb/hw/epf/ntb_hw_epf.c
> +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
> @@ -498,18 +498,16 @@ static int ntb_epf_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
> writel(upper_32_bits(addr), ndev->ctrl_reg + NTB_EPF_UPPER_ADDR);
> writel(lower_32_bits(size), ndev->ctrl_reg + NTB_EPF_LOWER_SIZE);
> writel(upper_32_bits(size), ndev->ctrl_reg + NTB_EPF_UPPER_SIZE);
> - ntb_epf_send_command(ndev, CMD_CONFIGURE_MW, idx);
> -
> - return 0;
> + return ntb_epf_send_command(ndev, CMD_CONFIGURE_MW, idx);
I agree with propagating the error, but there's one thing I'm wondering:
On timeout, the endpoint (pci-epf-*ntb) may just be slow and complete
CONFIGURE_MW later. E.g. tool_setup_mw() in ntb_tool frees the buffer when
ntb_mw_set_trans() returns an error. Could this leave an MW pointing at freed
memory?
Previously, it always returned 0, so tool_setup_mw() kept the buffer. I'm
wondering if this change could introduce a subtle regression. To avoid that
risk, how about keeping the existing timeout behavior?
ret = ntb_epf_send_command(ndev, CMD_CONFIGURE_MW, idx);
return ret == -ETIMEDOUT ? 0 : ret;
I'd love to hear your thoughts, thanks!
Best regards,
Koichiro Den
> }
>
> static int ntb_epf_mw_clear_trans(struct ntb_dev *ntb, int pidx, int idx)
> {
> struct ntb_epf_dev *ndev = ntb_ndev(ntb);
> struct device *dev = ndev->dev;
> - int ret = 0;
> + int ret;
>
> - ntb_epf_send_command(ndev, CMD_TEARDOWN_MW, idx);
> + ret = ntb_epf_send_command(ndev, CMD_TEARDOWN_MW, idx);
> if (ret)
> dev_err(dev, "Failed to teardown memory window\n");
>
>
> base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
> --
> 2.43.0
>