LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Paul Mackerras <paulus@ozlabs.org>, linuxppc-dev@ozlabs.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Subject: Re: [PATCH] powerpc/powernv: Fix sparse data type warnings in pci-ioda.c
Date: Wed, 28 Mar 2018 15:53:05 +1100	[thread overview]
Message-ID: <87d0zo3ioe.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20180328004442.GA29865@fergus.ozlabs.ibm.com>

Paul Mackerras <paulus@ozlabs.org> writes:
> From: Gavin Shan <gwshan@linux.vnet.ibm.com>
>
> The value passed to __raw_rm_writeq() and __raw_writeq() should be "u64"
> and "unsigned long". This fixes warning reported by sparse:
>
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
>                              arch/powerpc/platforms/powernv/pci-ioda.o
>   arch/powerpc/platforms/powernv/pci-ioda.c:1794:41: \
>   warning: incorrect type in argument 1 (different base types)
>   arch/powerpc/platforms/powernv/pci-ioda.c:1794:41: \
>   expected unsigned long long [unsigned] [usertype] val
>   arch/powerpc/platforms/powernv/pci-ioda.c:1794:41: \
>   got restricted __be64 [usertype] <noident>
>   arch/powerpc/platforms/powernv/pci-ioda.c:1796:38: \
>   warning: incorrect type in argument 1 (different base types)
>   arch/powerpc/platforms/powernv/pci-ioda.c:1796:38: \
>   expected unsigned long [unsigned] v
>   arch/powerpc/platforms/powernv/pci-ioda.c:1796:38: \
>   got restricted __be64 [usertype] <noident>
>
> This also fixes another warning reported by sparse:
>
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
>                              arch/powerpc/platforms/powernv/pci-ioda.o
>         :
>   arch/powerpc/platforms/powernv/pci-ioda.c:2647:45: \
>   warning: cast to restricted __be64
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> ---
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index a6c92c7..71de087 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1976,9 +1976,11 @@ static void pnv_pci_p7ioc_tce_invalidate(struct iommu_table *tbl,
>          mb(); /* Ensure above stores are visible */
>          while (start <= end) {
>  		if (rm)
> -			__raw_rm_writeq(cpu_to_be64(start), invalidate);
> +			__raw_rm_writeq((__force u64)cpu_to_be64(start),
> +					invalidate);
>  		else
> -			__raw_writeq(cpu_to_be64(start), invalidate);
> +			__raw_writeq((__force unsigned long)cpu_to_be64(start),
> +				     invalidate);

I didn't merge this when it was originally sent because sprinkling
__force casts everywhere is not a good strategy for producing
maintainable code IMHO.

There's a writeq_be() which does the byte swap, I think we should
probably just mirror that for these __raw versions.

I'll do a patch.

cheers

      parent reply	other threads:[~2018-03-28  4:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28  0:44 [PATCH] powerpc/powernv: Fix sparse data type warnings in pci-ioda.c Paul Mackerras
2018-03-28  1:21 ` Alexey Kardashevskiy
2018-03-28  4:53 ` Michael Ellerman [this message]

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=87d0zo3ioe.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=aik@ozlabs.ru \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@ozlabs.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox