mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] NTB: epf: propagate memory window command errors
@ 2026-10-27 15:49 Avi Weiss
  2026-10-28  5:47 ` Koichiro Den
  0 siblings, 1 reply; 2+ messages in thread
From: Avi Weiss @ 2026-10-27 15:49 UTC (permalink / raw)
  To: Jon Mason
  Cc: Dave Jiang, Allen Hubbe, Koichiro Den, Frank Li, ntb,
	linux-kernel, Avi Weiss

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@gmail.com>
---
 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);
 }
 
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] NTB: epf: propagate memory window command errors
  2026-10-27 15:49 [PATCH] NTB: epf: propagate memory window command errors Avi Weiss
@ 2026-10-28  5:47 ` Koichiro Den
  0 siblings, 0 replies; 2+ messages in thread
From: Koichiro Den @ 2026-10-28  5:47 UTC (permalink / raw)
  To: Avi Weiss; +Cc: Jon Mason, Dave Jiang, Allen Hubbe, Frank Li, ntb, linux-kernel

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@gmail.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-28  5:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 15:49 [PATCH] NTB: epf: propagate memory window command errors Avi Weiss
2026-10-28  5:47 ` Koichiro Den

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®