From: Dave Jiang <dave.jiang@intel.com>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>, jdmason@kudzu.us
Cc: alok.a.tiwari@oracle.com, u.kleine-koenig@baylibre.com,
den@valinux.co.jp, bhelgaas@google.com, mani@kernel.org,
Frank.Li@nxp.com, Maciej.Grochowski@sony.com,
linux-kernel@vger.kernel.org, trivial@kernel.org
Subject: Re: [PATCH] ntb: fix peer_spad_read() returning -EINVAL instead of 0
Date: Fri, 20 Nov 2026 08:36:42 -0700 [thread overview]
Message-ID: <cc1192ff-e8b1-40c9-b24a-c03f3e85ab20@intel.com> (raw)
In-Reply-To: <20261120084546.2018-1-zhangjiao2@cmss.chinamobile.com>
On 11/20/26 1:45 AM, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> The amd_ntb_peer_spad_read(), ntb_epf_peer_spad_read() and
> switchtec_ntb_peer_spad_read() functions have a return type of u32
> but return -EINVAL on error, which results in a garbage value
> (0xFFFFFFEA) being returned to callers. Other NTB hardware drivers
> (e.g. Intel's ndev_spad_read) correctly return 0 for out-of-range
> scratchpad indices.
>
> Fix all three functions to return 0 on error, matching the
> established convention in the NTB subsystem.
>
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/ntb/hw/amd/ntb_hw_amd.c | 2 +-
> drivers/ntb/hw/epf/ntb_hw_epf.c | 4 ++--
> drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
> index 36bee0d8ac6c..40ced4043340 100644
> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c
> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
> @@ -529,7 +529,7 @@ static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
> u32 offset;
>
> if (sidx < 0 || sidx >= ndev->spad_count)
> - return -EINVAL;
> + return 0;
>
> offset = ndev->peer_spad + (sidx << 2);
> return readl(mmio + AMD_SPAD_OFFSET + offset);
> diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
> index c47607d4f8a7..dcc5eb4bea74 100644
> --- a/drivers/ntb/hw/epf/ntb_hw_epf.c
> +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
> @@ -273,12 +273,12 @@ static u32 ntb_epf_peer_spad_read(struct ntb_dev *ntb, int pidx, int idx)
>
> if (pidx != NTB_DEF_PEER_IDX) {
> dev_err(dev, "Unsupported Peer ID %d\n", pidx);
> - return -EINVAL;
> + return 0;
> }
>
> if (idx < 0 || idx >= ndev->spad_count) {
> dev_err(dev, "WRITE: Invalid Peer ScratchPad Index %d\n", idx);
> - return -EINVAL;
> + return 0;
> }
>
> offset = (idx << 2);
> diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> index e38540b92716..a9fc94869aeb 100644
> --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
> @@ -762,7 +762,7 @@ static u32 switchtec_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx,
> struct switchtec_ntb *sndev = ntb_sndev(ntb);
>
> if (pidx != NTB_DEF_PEER_IDX)
> - return -EINVAL;
> + return 0;
>
> if (sidx < 0 || sidx >= ARRAY_SIZE(sndev->peer_shared->spad))
> return 0;
next prev parent reply other threads:[~2026-11-20 15:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 8:45 zhangjiao2
2026-11-20 15:36 ` Dave Jiang [this message]
2026-11-20 16:34 ` Koichiro Den
2026-11-20 16:45 ` Dave Jiang
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=cc1192ff-e8b1-40c9-b24a-c03f3e85ab20@intel.com \
--to=dave.jiang@intel.com \
--cc=Frank.Li@nxp.com \
--cc=Maciej.Grochowski@sony.com \
--cc=alok.a.tiwari@oracle.com \
--cc=bhelgaas@google.com \
--cc=den@valinux.co.jp \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
--cc=trivial@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=zhangjiao2@cmss.chinamobile.com \
/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
all inboxes | Powered by JetHome®