nfp: correct cleanup related to DCB resources
Subsystems (3)
PATCH 1/1 nfp: correct cleanup related to DCB resources
From: Huayu Chen <[email protected]>
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.
--- 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(-)
drivers/net/ethernet/netronome/nfp/nic/main.c +6 -2
@@ -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, };
drivers/net/ethernet/netronome/nfp/nic/main.h +1 -1
@@ -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
Signature · 1 line
2.30.2
Quoted 51 lines · Simon Horman
From: Huayu Chen <[email protected]>
This patch corrects two oversights relating to releasing resources and DCB initialisation.
1. If mapping of the
dcbcfg_tblarea fails: an error should be propagated, allowing partial initialisation (probe) to be unwound.2. Conversely, if where
dcbcfg_tblis successfully mapped: it should be unmapped innfp_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 <[email protected]>Reviewed-by Niklas Söderlund <[email protected]>Signed-off-by Simon Horman <[email protected]>--- 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(-)drivers/net/ethernet/netronome/nfp/nic/main.c +6
-2@@ -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, };drivers/net/ethernet/netronome/nfp/nic/main.h +0
-0
drivers/net/ethernet/netronome/nfp/nic/main.h struct nfp_dcb { · line 36
Quoted 5 lines
drivers/net/ethernet/netronome/nfp/nic/main.h +1
-1@@ -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,
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 31 Jan 2023 17:30:33 +0100 you wrote:
From: Huayu Chen <[email protected]>
This patch corrects two oversights relating to releasing resources and DCB initialisation.
1. If mapping of the
dcbcfg_tblarea 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html