* [PATCH] powerpc/powernv: Fix sparse data type warnings in pci-ioda.c
@ 2018-03-28 0:44 Paul Mackerras
2018-03-28 1:21 ` Alexey Kardashevskiy
2018-03-28 4:53 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Paul Mackerras @ 2018-03-28 0:44 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy
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);
start += inc;
}
@@ -2055,9 +2057,10 @@ static void pnv_pci_phb3_tce_invalidate_entire(struct pnv_phb *phb, bool rm)
mb(); /* Ensure previous TCE table stores are visible */
if (rm)
- __raw_rm_writeq(cpu_to_be64(val), invalidate);
+ __raw_rm_writeq((__force u64)cpu_to_be64(val), invalidate);
else
- __raw_writeq(cpu_to_be64(val), invalidate);
+ __raw_writeq((__force unsigned long)cpu_to_be64(val),
+ invalidate);
}
static inline void pnv_pci_phb3_tce_invalidate_pe(struct pnv_ioda_pe *pe)
@@ -2067,7 +2070,7 @@ static inline void pnv_pci_phb3_tce_invalidate_pe(struct pnv_ioda_pe *pe)
unsigned long val = PHB3_TCE_KILL_INVAL_PE | (pe->pe_number & 0xFF);
mb(); /* Ensure above stores are visible */
- __raw_writeq(cpu_to_be64(val), invalidate);
+ __raw_writeq((__force unsigned long)cpu_to_be64(val), invalidate);
}
static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
@@ -2090,9 +2093,11 @@ static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
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);
start += inc;
}
}
@@ -2864,7 +2869,8 @@ static void pnv_pci_ioda2_table_do_free_pages(__be64 *addr,
u64 *tmp = (u64 *) addr_ul;
for (i = 0; i < size; ++i) {
- unsigned long hpa = be64_to_cpu(tmp[i]);
+ unsigned long hpa =
+ be64_to_cpu((__force __be64)(tmp[i]));
if (!(hpa & (TCE_PCI_READ | TCE_PCI_WRITE)))
continue;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/powernv: Fix sparse data type warnings in pci-ioda.c
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
1 sibling, 0 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2018-03-28 1:21 UTC (permalink / raw)
To: Paul Mackerras, linuxppc-dev
On 28/3/18 11:44 am, Paul Mackerras wrote:
> 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>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs•ru>
> ---
> 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);
> start += inc;
> }
>
> @@ -2055,9 +2057,10 @@ static void pnv_pci_phb3_tce_invalidate_entire(struct pnv_phb *phb, bool rm)
>
> mb(); /* Ensure previous TCE table stores are visible */
> if (rm)
> - __raw_rm_writeq(cpu_to_be64(val), invalidate);
> + __raw_rm_writeq((__force u64)cpu_to_be64(val), invalidate);
> else
> - __raw_writeq(cpu_to_be64(val), invalidate);
> + __raw_writeq((__force unsigned long)cpu_to_be64(val),
> + invalidate);
> }
>
> static inline void pnv_pci_phb3_tce_invalidate_pe(struct pnv_ioda_pe *pe)
> @@ -2067,7 +2070,7 @@ static inline void pnv_pci_phb3_tce_invalidate_pe(struct pnv_ioda_pe *pe)
> unsigned long val = PHB3_TCE_KILL_INVAL_PE | (pe->pe_number & 0xFF);
>
> mb(); /* Ensure above stores are visible */
> - __raw_writeq(cpu_to_be64(val), invalidate);
> + __raw_writeq((__force unsigned long)cpu_to_be64(val), invalidate);
> }
>
> static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
> @@ -2090,9 +2093,11 @@ static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
>
> 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);
> start += inc;
> }
> }
> @@ -2864,7 +2869,8 @@ static void pnv_pci_ioda2_table_do_free_pages(__be64 *addr,
> u64 *tmp = (u64 *) addr_ul;
>
> for (i = 0; i < size; ++i) {
> - unsigned long hpa = be64_to_cpu(tmp[i]);
> + unsigned long hpa =
> + be64_to_cpu((__force __be64)(tmp[i]));
>
> if (!(hpa & (TCE_PCI_READ | TCE_PCI_WRITE)))
> continue;
>
--
Alexey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/powernv: Fix sparse data type warnings in pci-ioda.c
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
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-03-28 4:53 UTC (permalink / raw)
To: Paul Mackerras, linuxppc-dev; +Cc: Alexey Kardashevskiy
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-28 4:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox