All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
@ 2019-03-07  9:33 Arnd Bergmann
  2019-03-07 15:14 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-07  9:33 UTC (permalink / raw)
  To: Christian Benvenuti, Govindarajulu Varadarajan, Parvi Kaustubhi,
	David S. Miller
  Cc: Nick Desaulniers, Arnd Bergmann, netdev, linux-kernel

The enic driver relies on the CONFIG_CPUMASK_OFFSTACK feature to
dynamically allocate a struct member, but this is normally intended for
local variables.

Building with clang, I get a warning for a few locations that check the
address of the cpumask_var_t:

drivers/net/ethernet/cisco/enic/enic_main.c:122:22: error: address of array 'enic->msix[i].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

As far as I can tell, the code is still correct, as the truth value of
the pointer is what we need in this configuration.  To get rid of the
warning, I split out the check into a separate function, and hide that
portion if CONFIG_CPUMASK_OFFSTACK is disabled.

Fixes: 322cf7e3a4e8 ("enic: assign affinity hint to interrupts")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 9a7f70db20c7..f652a8bd163e 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -112,6 +112,15 @@ static struct enic_intr_mod_range mod_range[ENIC_MAX_LINK_SPEEDS] = {
 	{3,  6}, /* 10 - 40 Gbps */
 };
 
+static inline int enic_affinity_mask_empty(struct enic *enic, int i)
+{
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!enic->msix[i].affinity_mask)
+		return 1;
+#endif
+	return cpumask_empty(enic->msix[i].affinity_mask);
+}
+
 static void enic_init_affinity_hint(struct enic *enic)
 {
 	int numa_node = dev_to_node(&enic->pdev->dev);
@@ -119,8 +128,7 @@ static void enic_init_affinity_hint(struct enic *enic)
 
 	for (i = 0; i < enic->intr_count; i++) {
 		if (enic_is_err_intr(enic, i) || enic_is_notify_intr(enic, i) ||
-		    (enic->msix[i].affinity_mask &&
-		     !cpumask_empty(enic->msix[i].affinity_mask)))
+		    !enic_affinity_mask_empty(enic, i))
 			continue;
 		if (zalloc_cpumask_var(&enic->msix[i].affinity_mask,
 				       GFP_KERNEL))
@@ -148,8 +156,7 @@ static void enic_set_affinity_hint(struct enic *enic)
 	for (i = 0; i < enic->intr_count; i++) {
 		if (enic_is_err_intr(enic, i)		||
 		    enic_is_notify_intr(enic, i)	||
-		    !enic->msix[i].affinity_mask	||
-		    cpumask_empty(enic->msix[i].affinity_mask))
+		    enic_affinity_mask_empty(enic, i))
 			continue;
 		err = irq_set_affinity_hint(enic->msix_entry[i].vector,
 					    enic->msix[i].affinity_mask);
@@ -161,8 +168,7 @@ static void enic_set_affinity_hint(struct enic *enic)
 	for (i = 0; i < enic->wq_count; i++) {
 		int wq_intr = enic_msix_wq_intr(enic, i);
 
-		if (enic->msix[wq_intr].affinity_mask &&
-		    !cpumask_empty(enic->msix[wq_intr].affinity_mask))
+		if (!enic_affinity_mask_empty(enic, wq_intr))
 			netif_set_xps_queue(enic->netdev,
 					    enic->msix[wq_intr].affinity_mask,
 					    i);
-- 
2.20.0


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

* Re: [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
  2019-03-07  9:33 [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Arnd Bergmann
@ 2019-03-07 15:14 ` Nathan Chancellor
  2019-03-07 15:50   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2019-03-07 15:14 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christian Benvenuti, Govindarajulu Varadarajan, Parvi Kaustubhi,
	David S. Miller, Nick Desaulniers, netdev, linux-kernel

On Thu, Mar 07, 2019 at 10:33:02AM +0100, Arnd Bergmann wrote:
> The enic driver relies on the CONFIG_CPUMASK_OFFSTACK feature to
> dynamically allocate a struct member, but this is normally intended for
> local variables.
> 
> Building with clang, I get a warning for a few locations that check the
> address of the cpumask_var_t:
> 
> drivers/net/ethernet/cisco/enic/enic_main.c:122:22: error: address of array 'enic->msix[i].affinity_mask' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
> 
> As far as I can tell, the code is still correct, as the truth value of
> the pointer is what we need in this configuration.  To get rid of the
> warning, I split out the check into a separate function, and hide that
> portion if CONFIG_CPUMASK_OFFSTACK is disabled.
> 
> Fixes: 322cf7e3a4e8 ("enic: assign affinity hint to interrupts")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
> index 9a7f70db20c7..f652a8bd163e 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
> @@ -112,6 +112,15 @@ static struct enic_intr_mod_range mod_range[ENIC_MAX_LINK_SPEEDS] = {
>  	{3,  6}, /* 10 - 40 Gbps */
>  };
>  
> +static inline int enic_affinity_mask_empty(struct enic *enic, int i)
> +{
> +#ifdef CONFIG_CPUMASK_OFFSTACK
> +	if (!enic->msix[i].affinity_mask)
> +		return 1;
> +#endif
> +	return cpumask_empty(enic->msix[i].affinity_mask);
> +}
> +
>  static void enic_init_affinity_hint(struct enic *enic)
>  {
>  	int numa_node = dev_to_node(&enic->pdev->dev);
> @@ -119,8 +128,7 @@ static void enic_init_affinity_hint(struct enic *enic)
>  
>  	for (i = 0; i < enic->intr_count; i++) {
>  		if (enic_is_err_intr(enic, i) || enic_is_notify_intr(enic, i) ||
> -		    (enic->msix[i].affinity_mask &&
> -		     !cpumask_empty(enic->msix[i].affinity_mask)))
> +		    !enic_affinity_mask_empty(enic, i))
>  			continue;
>  		if (zalloc_cpumask_var(&enic->msix[i].affinity_mask,
>  				       GFP_KERNEL))
> @@ -148,8 +156,7 @@ static void enic_set_affinity_hint(struct enic *enic)
>  	for (i = 0; i < enic->intr_count; i++) {
>  		if (enic_is_err_intr(enic, i)		||
>  		    enic_is_notify_intr(enic, i)	||
> -		    !enic->msix[i].affinity_mask	||
> -		    cpumask_empty(enic->msix[i].affinity_mask))
> +		    enic_affinity_mask_empty(enic, i))
>  			continue;
>  		err = irq_set_affinity_hint(enic->msix_entry[i].vector,
>  					    enic->msix[i].affinity_mask);
> @@ -161,8 +168,7 @@ static void enic_set_affinity_hint(struct enic *enic)
>  	for (i = 0; i < enic->wq_count; i++) {
>  		int wq_intr = enic_msix_wq_intr(enic, i);
>  
> -		if (enic->msix[wq_intr].affinity_mask &&
> -		    !cpumask_empty(enic->msix[wq_intr].affinity_mask))
> +		if (!enic_affinity_mask_empty(enic, wq_intr))
>  			netif_set_xps_queue(enic->netdev,
>  					    enic->msix[wq_intr].affinity_mask,
>  					    i);
> -- 
> 2.20.0
> 

A slightly less intrusive change would be using cpumask_available, which
was specifically introduced for this purpose in commit f7e30f01a9e2
("cpumask: Add helper cpumask_available()").

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

* Re: [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
  2019-03-07 15:14 ` Nathan Chancellor
@ 2019-03-07 15:50   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-07 15:50 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Christian Benvenuti, Govindarajulu Varadarajan, Parvi Kaustubhi,
	David S. Miller, Nick Desaulniers, Networking,
	Linux Kernel Mailing List

On Thu, Mar 7, 2019 at 4:14 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> A slightly less intrusive change would be using cpumask_available, which
> was specifically introduced for this purpose in commit f7e30f01a9e2
> ("cpumask: Add helper cpumask_available()").

Ah nice, I wasn't aware of that function. I'll send a v2.

     Arnd

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

end of thread, other threads:[~2019-03-07 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07  9:33 [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Arnd Bergmann
2019-03-07 15:14 ` Nathan Chancellor
2019-03-07 15:50   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.