diff mbox series

[net-next] nfp: correct cleanup related to DCB resources

Message ID 20230131163033.981937-1-simon.horman@corigine.com (mailing list archive)
State Accepted
Commit ca3daf437d9c261ca498f518090c3ddbf1bf824f
Delegated to: Netdev Maintainers
Headers show
Series [net-next] nfp: correct cleanup related to DCB resources | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: bin.chen@corigine.com; 2 maintainers not CCed: bin.chen@corigine.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Simon Horman Jan. 31, 2023, 4:30 p.m. UTC
From: Huayu Chen <huayu.chen@corigine.com>

This patch corrects two oversights relating to releasing resources
and DCB initialisation.

1. If mapping of the dcbcfg_tbl area fails: an error should be
   propagated, allowing partial initialisation (probe) to be unwound.

2. Conversely, if where dcbcfg_tbl is successfully mapped: it should
   be unmapped in nfp_nic_dcb_clean() which is called via various error
   cleanup paths, and shutdown or removal of the PCIE device.

Fixes: 9b7fe8046d74 ("nfp: add DCB IEEE support")
Signed-off-by: Huayu Chen <huayu.chen@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 drivers/net/ethernet/netronome/nfp/nic/main.c | 8 ++++++--
 drivers/net/ethernet/netronome/nfp/nic/main.h | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Leon Romanovsky Feb. 1, 2023, 9:30 a.m. UTC | #1
On Tue, Jan 31, 2023 at 05:30:33PM +0100, Simon Horman wrote:
> From: Huayu Chen <huayu.chen@corigine.com>
> 
> This patch corrects two oversights relating to releasing resources
> and DCB initialisation.
> 
> 1. If mapping of the dcbcfg_tbl area fails: an error should be
>    propagated, allowing partial initialisation (probe) to be unwound.
> 
> 2. Conversely, if where dcbcfg_tbl is successfully mapped: it should
>    be unmapped in nfp_nic_dcb_clean() which is called via various error
>    cleanup paths, and shutdown or removal of the PCIE device.
> 
> Fixes: 9b7fe8046d74 ("nfp: add DCB IEEE support")
> Signed-off-by: Huayu Chen <huayu.chen@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@corigine.com>
> ---
>  drivers/net/ethernet/netronome/nfp/nic/main.c | 8 ++++++--
>  drivers/net/ethernet/netronome/nfp/nic/main.h | 2 +-
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.c b/drivers/net/ethernet/netronome/nfp/nic/main.c
> index f78c2447d45b..9dd5afe37f6e 100644
> --- a/drivers/net/ethernet/netronome/nfp/nic/main.c
> +++ b/drivers/net/ethernet/netronome/nfp/nic/main.c
> @@ -32,9 +32,12 @@ static void nfp_nic_sriov_disable(struct nfp_app *app)
>  
>  static int nfp_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn)
>  {
> -	nfp_nic_dcb_init(nn);
> +	return nfp_nic_dcb_init(nn);
> +}
>  
> -	return 0;
> +static void nfp_nic_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
> +{
> +	nfp_nic_dcb_clean(nn);
>  }
>  
>  static int nfp_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
> @@ -72,4 +75,5 @@ const struct nfp_app_type app_nic = {
>  	.sriov_disable	= nfp_nic_sriov_disable,
>  
>  	.vnic_init      = nfp_nic_vnic_init,
> +	.vnic_clean     = nfp_nic_vnic_clean,
>  };
> diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.h b/drivers/net/ethernet/netronome/nfp/nic/main.h
> index 7ba04451b8ba..094374df42b8 100644
> --- a/drivers/net/ethernet/netronome/nfp/nic/main.h
> +++ b/drivers/net/ethernet/netronome/nfp/nic/main.h
> @@ -33,7 +33,7 @@ struct nfp_dcb {
>  int nfp_nic_dcb_init(struct nfp_net *nn);
>  void nfp_nic_dcb_clean(struct nfp_net *nn);
>  #else
> -static inline int nfp_nic_dcb_init(struct nfp_net *nn) {return 0; }
> +static inline int nfp_nic_dcb_init(struct nfp_net *nn) { return 0; }

Not related change, but I would do the same.

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
patchwork-bot+netdevbpf@kernel.org Feb. 2, 2023, 4 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 31 Jan 2023 17:30:33 +0100 you wrote:
> From: Huayu Chen <huayu.chen@corigine.com>
> 
> This patch corrects two oversights relating to releasing resources
> and DCB initialisation.
> 
> 1. If mapping of the dcbcfg_tbl area fails: an error should be
>    propagated, allowing partial initialisation (probe) to be unwound.
> 
> [...]

Here is the summary with links:
  - [net-next] nfp: correct cleanup related to DCB resources
    https://git.kernel.org/netdev/net-next/c/ca3daf437d9c

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.c b/drivers/net/ethernet/netronome/nfp/nic/main.c
index f78c2447d45b..9dd5afe37f6e 100644
--- a/drivers/net/ethernet/netronome/nfp/nic/main.c
+++ b/drivers/net/ethernet/netronome/nfp/nic/main.c
@@ -32,9 +32,12 @@  static void nfp_nic_sriov_disable(struct nfp_app *app)
 
 static int nfp_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn)
 {
-	nfp_nic_dcb_init(nn);
+	return nfp_nic_dcb_init(nn);
+}
 
-	return 0;
+static void nfp_nic_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
+{
+	nfp_nic_dcb_clean(nn);
 }
 
 static int nfp_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
@@ -72,4 +75,5 @@  const struct nfp_app_type app_nic = {
 	.sriov_disable	= nfp_nic_sriov_disable,
 
 	.vnic_init      = nfp_nic_vnic_init,
+	.vnic_clean     = nfp_nic_vnic_clean,
 };
diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.h b/drivers/net/ethernet/netronome/nfp/nic/main.h
index 7ba04451b8ba..094374df42b8 100644
--- a/drivers/net/ethernet/netronome/nfp/nic/main.h
+++ b/drivers/net/ethernet/netronome/nfp/nic/main.h
@@ -33,7 +33,7 @@  struct nfp_dcb {
 int nfp_nic_dcb_init(struct nfp_net *nn);
 void nfp_nic_dcb_clean(struct nfp_net *nn);
 #else
-static inline int nfp_nic_dcb_init(struct nfp_net *nn) {return 0; }
+static inline int nfp_nic_dcb_init(struct nfp_net *nn) { return 0; }
 static inline void nfp_nic_dcb_clean(struct nfp_net *nn) {}
 #endif