All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Benvenuti <benve@cisco.com>,
	Govindarajulu Varadarajan <_govind@gmx.com>,
	Parvi Kaustubhi <pkaustub@cisco.com>,
	"David S. Miller" <davem@davemloft.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK
Date: Thu, 7 Mar 2019 08:14:37 -0700	[thread overview]
Message-ID: <20190307151437.GA20201@archlinux-ryzen> (raw)
In-Reply-To: <20190307093311.3406888-1-arnd@arndb.de>

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()").

  reply	other threads:[~2019-03-07 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  9:33 [PATCH] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Arnd Bergmann
2019-03-07 15:14 ` Nathan Chancellor [this message]
2019-03-07 15:50   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190307151437.GA20201@archlinux-ryzen \
    --to=natechancellor@gmail.com \
    --cc=_govind@gmx.com \
    --cc=arnd@arndb.de \
    --cc=benve@cisco.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pkaustub@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.