Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/2] ice: simplify PF nominal-state checking
@ 2026-09-03 13:20 Yury Norov
  2026-09-03 13:20 ` [PATCH 1/2] ice: simplify ice_pf_state_is_nominal() Yury Norov
  2026-09-03 13:20 ` [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal() Yury Norov
  0 siblings, 2 replies; 7+ messages in thread
From: Yury Norov @ 2026-09-03 13:20 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, open list
  Cc: Yury Norov

Simplify ice_pf_state_is_nominal() by checking the relevant state bits
directly with bitmap_empty(), instead of constructing a temporary bitmap
on the stack.

Two of the three callers dereference the PF before calling the helper.
Move the NULL check to the remaining caller so that
ice_pf_state_is_nominal() becomes a one-liner.

Yury Norov (2):
  ice: simplify ice_pf_state_is_nominal()
  ice: drop pf == NULL check in ice_pf_state_is_nominal()

 drivers/net/ethernet/intel/ice/ice_lib.c  | 11 +----------
 drivers/net/ethernet/intel/ice/ice_main.c |  2 +-
 2 files changed, 2 insertions(+), 11 deletions(-)

-- 
2.53.0

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

* [PATCH 1/2] ice: simplify ice_pf_state_is_nominal()
  2026-09-03 13:20 [PATCH 0/2] ice: simplify PF nominal-state checking Yury Norov
@ 2026-09-03 13:20 ` Yury Norov
  2026-09-03 15:28   ` Temerkhanov, Sergey
  2026-09-05 18:31   ` Simon Horman
  2026-09-03 13:20 ` [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal() Yury Norov
  1 sibling, 2 replies; 7+ messages in thread
From: Yury Norov @ 2026-09-03 13:20 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, open list
  Cc: Yury Norov

The function creates a temporary mask on stack just to check that
first ICE_STATE_NOMINAL_CHECK_BITS is empty. Simplify it by using
the ice_pf_state_is_nominal().

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 9e08db376d3d..73996e3022ef 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1705,16 +1705,10 @@ static void ice_vsi_set_rss_flow_fld(struct ice_vsi *vsi)
  */
 bool ice_pf_state_is_nominal(struct ice_pf *pf)
 {
-	DECLARE_BITMAP(check_bits, ICE_STATE_NBITS) = { 0 };
-
 	if (!pf)
 		return false;
 
-	bitmap_set(check_bits, 0, ICE_STATE_NOMINAL_CHECK_BITS);
-	if (bitmap_intersects(pf->state, check_bits, ICE_STATE_NBITS))
-		return false;
-
-	return true;
+	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
 }
 
 #define ICE_FW_MODE_REC_M BIT(1)
-- 
2.53.0


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

* [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal()
  2026-09-03 13:20 [PATCH 0/2] ice: simplify PF nominal-state checking Yury Norov
  2026-09-03 13:20 ` [PATCH 1/2] ice: simplify ice_pf_state_is_nominal() Yury Norov
@ 2026-09-03 13:20 ` Yury Norov
  2026-09-03 15:29   ` Temerkhanov, Sergey
  2026-09-05 18:32   ` Simon Horman
  1 sibling, 2 replies; 7+ messages in thread
From: Yury Norov @ 2026-09-03 13:20 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, open list
  Cc: Yury Norov

The function has 3 callers, all except one explicitly require
pf != NULL. Add the corresponding check to the remaining caller,
and remove it from the ice_pf_state_is_nominal(). It makse the
fun function a one-liner.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c  | 3 ---
 drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 73996e3022ef..6d5b8acc4764 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1705,9 +1705,6 @@ static void ice_vsi_set_rss_flow_fld(struct ice_vsi *vsi)
  */
 bool ice_pf_state_is_nominal(struct ice_pf *pf)
 {
-	if (!pf)
-		return false;
-
 	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
 }
 
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index d88835482d3a..168d85f9477f 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -5521,7 +5521,7 @@ static int ice_suspend(struct device *dev)
 
 	pf = pci_get_drvdata(pdev);
 
-	if (!ice_pf_state_is_nominal(pf)) {
+	if (!pf || !ice_pf_state_is_nominal(pf)) {
 		dev_err(dev, "Device is not ready, no need to suspend it\n");
 		return -EBUSY;
 	}
-- 
2.53.0


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

* RE: [PATCH 1/2] ice: simplify ice_pf_state_is_nominal()
  2026-09-03 13:20 ` [PATCH 1/2] ice: simplify ice_pf_state_is_nominal() Yury Norov
@ 2026-09-03 15:28   ` Temerkhanov, Sergey
  2026-09-05 18:31   ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Temerkhanov, Sergey @ 2026-09-03 15:28 UTC (permalink / raw)
  To: Yury Norov, Nguyen, Anthony L, Kitszel, Przemyslaw, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	open list

> -----Original Message-----
> From: Yury Norov <ynorov@nvidia.com>
> Sent: Thursday, September 3, 2026 3:21 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; intel-wired-lan@lists.osuosl.org;
> netdev@vger.kernel.org; open list <linux-kernel@vger.kernel.org>
> Cc: Yury Norov <ynorov@nvidia.com>
> Subject: [PATCH 1/2] ice: simplify ice_pf_state_is_nominal()
> 
> The function creates a temporary mask on stack just to check that first
> ICE_STATE_NOMINAL_CHECK_BITS is empty. Simplify it by using the
> ice_pf_state_is_nominal().
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c
> b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 9e08db376d3d..73996e3022ef 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -1705,16 +1705,10 @@ static void ice_vsi_set_rss_flow_fld(struct
> ice_vsi *vsi)
>   */
>  bool ice_pf_state_is_nominal(struct ice_pf *pf)  {
> -	DECLARE_BITMAP(check_bits, ICE_STATE_NBITS) = { 0 };
> -
>  	if (!pf)
>  		return false;
> 
> -	bitmap_set(check_bits, 0, ICE_STATE_NOMINAL_CHECK_BITS);
> -	if (bitmap_intersects(pf->state, check_bits, ICE_STATE_NBITS))
> -		return false;
> -
> -	return true;
> +	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
>  }
> 
>  #define ICE_FW_MODE_REC_M BIT(1)
> --
> 2.53.0

Reviewed-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>

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

* RE: [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal()
  2026-09-03 13:20 ` [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal() Yury Norov
@ 2026-09-03 15:29   ` Temerkhanov, Sergey
  2026-09-05 18:32   ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Temerkhanov, Sergey @ 2026-09-03 15:29 UTC (permalink / raw)
  To: Yury Norov, Nguyen, Anthony L, Kitszel, Przemyslaw, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	open list

> -----Original Message-----
> From: Yury Norov <ynorov@nvidia.com>
> Sent: Thursday, September 3, 2026 3:21 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; intel-wired-lan@lists.osuosl.org;
> netdev@vger.kernel.org; open list <linux-kernel@vger.kernel.org>
> Cc: Yury Norov <ynorov@nvidia.com>
> Subject: [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal()
> 
> The function has 3 callers, all except one explicitly require pf != NULL. Add the
> corresponding check to the remaining caller, and remove it from the
> ice_pf_state_is_nominal(). It makse the fun function a one-liner.
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c  | 3 ---
> drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
>  2 files changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c
> b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 73996e3022ef..6d5b8acc4764 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -1705,9 +1705,6 @@ static void ice_vsi_set_rss_flow_fld(struct ice_vsi
> *vsi)
>   */
>  bool ice_pf_state_is_nominal(struct ice_pf *pf)  {
> -	if (!pf)
> -		return false;
> -
>  	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
> }
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c
> b/drivers/net/ethernet/intel/ice/ice_main.c
> index d88835482d3a..168d85f9477f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5521,7 +5521,7 @@ static int ice_suspend(struct device *dev)
> 
>  	pf = pci_get_drvdata(pdev);
> 
> -	if (!ice_pf_state_is_nominal(pf)) {
> +	if (!pf || !ice_pf_state_is_nominal(pf)) {
>  		dev_err(dev, "Device is not ready, no need to suspend it\n");
>  		return -EBUSY;
>  	}
> --
> 2.53.0

Reviewed-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>

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

* Re: [PATCH 1/2] ice: simplify ice_pf_state_is_nominal()
  2026-09-03 13:20 ` [PATCH 1/2] ice: simplify ice_pf_state_is_nominal() Yury Norov
  2026-09-03 15:28   ` Temerkhanov, Sergey
@ 2026-09-05 18:31   ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Horman @ 2026-09-05 18:31 UTC (permalink / raw)
  To: Yury Norov
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, open list

On Thu, Sep 03, 2026 at 09:20:35AM -0400, Yury Norov wrote:
> The function creates a temporary mask on stack just to check that
> first ICE_STATE_NOMINAL_CHECK_BITS is empty. Simplify it by using
> the ice_pf_state_is_nominal().

maybe s/the ice_pf_state_is_nominal/bitmap_empty/

> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>

The above nit not withstanding this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 9e08db376d3d..73996e3022ef 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -1705,16 +1705,10 @@ static void ice_vsi_set_rss_flow_fld(struct ice_vsi *vsi)
>   */
>  bool ice_pf_state_is_nominal(struct ice_pf *pf)
>  {
> -	DECLARE_BITMAP(check_bits, ICE_STATE_NBITS) = { 0 };
> -
>  	if (!pf)
>  		return false;
>  
> -	bitmap_set(check_bits, 0, ICE_STATE_NOMINAL_CHECK_BITS);
> -	if (bitmap_intersects(pf->state, check_bits, ICE_STATE_NBITS))
> -		return false;
> -
> -	return true;
> +	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
>  }
>  
>  #define ICE_FW_MODE_REC_M BIT(1)
> -- 
> 2.53.0
> 

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

* Re: [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal()
  2026-09-03 13:20 ` [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal() Yury Norov
  2026-09-03 15:29   ` Temerkhanov, Sergey
@ 2026-09-05 18:32   ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Horman @ 2026-09-05 18:32 UTC (permalink / raw)
  To: Yury Norov
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, open list

On Thu, Sep 03, 2026 at 09:20:36AM -0400, Yury Norov wrote:
> The function has 3 callers, all except one explicitly require
> pf != NULL. Add the corresponding check to the remaining caller,
> and remove it from the ice_pf_state_is_nominal(). It makse the
> fun function a one-liner.
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_lib.c  | 3 ---
>  drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
>  2 files changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 73996e3022ef..6d5b8acc4764 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -1705,9 +1705,6 @@ static void ice_vsi_set_rss_flow_fld(struct ice_vsi *vsi)
>   */
>  bool ice_pf_state_is_nominal(struct ice_pf *pf)
>  {
> -	if (!pf)
> -		return false;
> -
>  	return bitmap_empty(pf->state, ICE_STATE_NOMINAL_CHECK_BITS);
>  }
>  
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index d88835482d3a..168d85f9477f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5521,7 +5521,7 @@ static int ice_suspend(struct device *dev)
>  
>  	pf = pci_get_drvdata(pdev);
>  
> -	if (!ice_pf_state_is_nominal(pf)) {
> +	if (!pf || !ice_pf_state_is_nominal(pf)) {
>  		dev_err(dev, "Device is not ready, no need to suspend it\n");
>  		return -EBUSY;
>  	}

Is the new condition necessary in ice_suspend?

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

end of thread, other threads:[~2026-09-05 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 13:20 [PATCH 0/2] ice: simplify PF nominal-state checking Yury Norov
2026-09-03 13:20 ` [PATCH 1/2] ice: simplify ice_pf_state_is_nominal() Yury Norov
2026-09-03 15:28   ` Temerkhanov, Sergey
2026-09-05 18:31   ` Simon Horman
2026-09-03 13:20 ` [PATCH 2/2] ice: drop pf == NULL check in ice_pf_state_is_nominal() Yury Norov
2026-09-03 15:29   ` Temerkhanov, Sergey
2026-09-05 18:32   ` Simon Horman

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