diff mbox series

[net,1/3] nfp: use correct macro for LengthSelect in BAR config

Message ID 20240202113719.16171-2-louis.peens@corigine.com (mailing list archive)
State Accepted
Commit b3d4f7f2288901ed2392695919b3c0e24c1b4084
Delegated to: Netdev Maintainers
Headers show
Series nfp: a few simple driver fixes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1064 this patch: 1064
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1081 this patch: 1081
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1081 this patch: 1081
netdev/checkpatch warning CHECK: Lines should not end with a '('
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-04--21-00 (tests: 721)

Commit Message

Louis Peens Feb. 2, 2024, 11:37 a.m. UTC
From: Daniel Basilio <daniel.basilio@corigine.com>

The 1st and 2nd expansion BAR configuration registers are configured,
when the driver starts up, in variables 'barcfg_msix_general' and
'barcfg_msix_xpb', respectively. The 'LengthSelect' field is ORed in
from bit 0, which is incorrect. The 'LengthSelect' field should
start from bit 27.

This has largely gone un-noticed because
NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT happens to be 0.

Fixes: 4cb584e0ee7d ("nfp: add CPP access core")
Cc: stable@vger.kernel.org # 4.11+
Signed-off-by: Daniel Basilio <daniel.basilio@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
---
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Horman Feb. 5, 2024, 1:35 p.m. UTC | #1
On Fri, Feb 02, 2024 at 01:37:17PM +0200, Louis Peens wrote:
> From: Daniel Basilio <daniel.basilio@corigine.com>
> 
> The 1st and 2nd expansion BAR configuration registers are configured,
> when the driver starts up, in variables 'barcfg_msix_general' and
> 'barcfg_msix_xpb', respectively. The 'LengthSelect' field is ORed in
> from bit 0, which is incorrect. The 'LengthSelect' field should
> start from bit 27.
> 
> This has largely gone un-noticed because
> NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT happens to be 0.
> 
> Fixes: 4cb584e0ee7d ("nfp: add CPP access core")
> Cc: stable@vger.kernel.org # 4.11+
> Signed-off-by: Daniel Basilio <daniel.basilio@corigine.com>
> Signed-off-by: Louis Peens <louis.peens@corigine.com>

Hi Daniel and Louis,

If I'm reading this right then this is a code-correctness issue
and there is no runtime effect (because 0 is 0 regardless of shifting and
masking).

If so, I'd suggest that this is net-next material.
And, in turn, if so the Fixes tag should be dropped.

> ---
>  drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
> index 33b4c2856316..3f10c5365c80 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
> @@ -537,11 +537,13 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
>  	const u32 barcfg_msix_general =
>  		NFP_PCIE_BAR_PCIE2CPP_MapType(
>  			NFP_PCIE_BAR_PCIE2CPP_MapType_GENERAL) |
> -		NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT;
> +		NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
> +			NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT);
>  	const u32 barcfg_msix_xpb =
>  		NFP_PCIE_BAR_PCIE2CPP_MapType(
>  			NFP_PCIE_BAR_PCIE2CPP_MapType_BULK) |
> -		NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT |
> +		NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
> +			NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT) |
>  		NFP_PCIE_BAR_PCIE2CPP_Target_BaseAddress(
>  			NFP_CPP_TARGET_ISLAND_XPB);
>  	const u32 barcfg_explicit[4] = {
> -- 
> 2.34.1
> 
>
Louis Peens Feb. 5, 2024, 2:22 p.m. UTC | #2
On Mon, Feb 05, 2024 at 01:35:45PM +0000, Simon Horman wrote:
> On Fri, Feb 02, 2024 at 01:37:17PM +0200, Louis Peens wrote:
> > From: Daniel Basilio <daniel.basilio@corigine.com>
> > 
> > The 1st and 2nd expansion BAR configuration registers are configured,
> > when the driver starts up, in variables 'barcfg_msix_general' and
> > 'barcfg_msix_xpb', respectively. The 'LengthSelect' field is ORed in
> > from bit 0, which is incorrect. The 'LengthSelect' field should
> > start from bit 27.
> > 
> > This has largely gone un-noticed because
> > NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT happens to be 0.
> > 
> > Fixes: 4cb584e0ee7d ("nfp: add CPP access core")
> > Cc: stable@vger.kernel.org # 4.11+
> > Signed-off-by: Daniel Basilio <daniel.basilio@corigine.com>
> > Signed-off-by: Louis Peens <louis.peens@corigine.com>
> 
> Hi Daniel and Louis,
> 
> If I'm reading this right then this is a code-correctness issue
> and there is no runtime effect (because 0 is 0 regardless of shifting and
> masking).
You are reading this correctly yes.
> 
> If so, I'd suggest that this is net-next material.
> And, in turn, if so the Fixes tag should be dropped.
Thanks Simon. I was definitely flip-flopping on which tree to pick when
preparing this, if not already merged I would have gladly dropped it
from this net series. Thinking of it in terms of runtime effect is
probably a useful angle, will try and do this more when picking a tree.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
index 33b4c2856316..3f10c5365c80 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
@@ -537,11 +537,13 @@  static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
 	const u32 barcfg_msix_general =
 		NFP_PCIE_BAR_PCIE2CPP_MapType(
 			NFP_PCIE_BAR_PCIE2CPP_MapType_GENERAL) |
-		NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT;
+		NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
+			NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT);
 	const u32 barcfg_msix_xpb =
 		NFP_PCIE_BAR_PCIE2CPP_MapType(
 			NFP_PCIE_BAR_PCIE2CPP_MapType_BULK) |
-		NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT |
+		NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
+			NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT) |
 		NFP_PCIE_BAR_PCIE2CPP_Target_BaseAddress(
 			NFP_CPP_TARGET_ISLAND_XPB);
 	const u32 barcfg_explicit[4] = {