* [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be()
@ 2018-05-14 12:50 Michael Ellerman
2018-05-14 12:50 ` [PATCH 2/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c Michael Ellerman
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-05-14 12:50 UTC (permalink / raw)
To: linuxppc-dev; +Cc: alistair, paulus
Add byte-swapping versions of __raw_writeq() and __raw_rm_writeq().
This allows us to avoid sparse warnings caused by passing __be64 to
__raw_writeq(), which takes unsigned long:
arch/powerpc/platforms/powernv/pci-ioda.c:1981:38:
warning: incorrect type in argument 1 (different base types)
expected unsigned long [unsigned] v
got restricted __be64 [usertype] <noident>
It's also generally preferable to use a byte-swapping accessor rather
than doing it by hand in the code, which is more bug prone.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/io.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index af074923d598..e0331e754568 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -367,6 +367,11 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
*(volatile unsigned long __force *)PCI_FIX_ADDR(addr) = v;
}
+static inline void __raw_writeq_be(unsigned long v, volatile void __iomem *addr)
+{
+ __raw_writeq((__force unsigned long)cpu_to_be64(v), addr);
+}
+
/*
* Real mode versions of the above. Those instructions are only supposed
* to be used in hypervisor real mode as per the architecture spec.
@@ -395,6 +400,11 @@ static inline void __raw_rm_writeq(u64 val, volatile void __iomem *paddr)
: : "r" (val), "r" (paddr) : "memory");
}
+static inline void __raw_rm_writeq_be(u64 val, volatile void __iomem *paddr)
+{
+ __raw_rm_writeq((__force u64)cpu_to_be64(val), paddr);
+}
+
static inline u8 __raw_rm_readb(volatile void __iomem *paddr)
{
u8 ret;
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c
2018-05-14 12:50 [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Michael Ellerman
@ 2018-05-14 12:50 ` Michael Ellerman
2018-05-14 12:50 ` [PATCH 3/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in npu-dma.c Michael Ellerman
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-05-14 12:50 UTC (permalink / raw)
To: linuxppc-dev; +Cc: alistair, paulus
This allows us to squash some sparse warnings and also avoids having
to do explicity endian conversions in the code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 3f9c69d7623a..f9f2b1dc9357 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1976,9 +1976,10 @@ 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_be(start, invalidate);
else
- __raw_writeq(cpu_to_be64(start), invalidate);
+ __raw_writeq_be(start, invalidate);
+
start += inc;
}
@@ -2055,9 +2056,9 @@ 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_be(val, invalidate);
else
- __raw_writeq(cpu_to_be64(val), invalidate);
+ __raw_writeq_be(val, invalidate);
}
static inline void pnv_pci_phb3_tce_invalidate_pe(struct pnv_ioda_pe *pe)
@@ -2067,7 +2068,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_be(val, invalidate);
}
static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
@@ -2090,9 +2091,9 @@ 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_be(start, invalidate);
else
- __raw_writeq(cpu_to_be64(start), invalidate);
+ __raw_writeq_be(start, invalidate);
start += inc;
}
}
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in npu-dma.c
2018-05-14 12:50 [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Michael Ellerman
2018-05-14 12:50 ` [PATCH 2/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c Michael Ellerman
@ 2018-05-14 12:50 ` Michael Ellerman
2018-05-18 6:39 ` [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Samuel Mendoza-Jonas
2018-05-21 10:01 ` [1/3] " Michael Ellerman
3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-05-14 12:50 UTC (permalink / raw)
To: linuxppc-dev; +Cc: alistair, paulus
This allows us to squash some sparse warnings and also avoids having
to do explicity endian conversions in the code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/powernv/npu-dma.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 525e966dce34..8cdf91f5d3a4 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -459,10 +459,9 @@ static void mmio_launch_invalidate(struct mmio_atsd_reg *mmio_atsd_reg,
struct npu *npu = mmio_atsd_reg->npu;
int reg = mmio_atsd_reg->reg;
- __raw_writeq(cpu_to_be64(va),
- npu->mmio_atsd_regs[reg] + XTS_ATSD_AVA);
+ __raw_writeq_be(va, npu->mmio_atsd_regs[reg] + XTS_ATSD_AVA);
eieio();
- __raw_writeq(cpu_to_be64(launch), npu->mmio_atsd_regs[reg]);
+ __raw_writeq_be(launch, npu->mmio_atsd_regs[reg]);
}
static void mmio_invalidate_pid(struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS],
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be()
2018-05-14 12:50 [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Michael Ellerman
2018-05-14 12:50 ` [PATCH 2/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c Michael Ellerman
2018-05-14 12:50 ` [PATCH 3/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in npu-dma.c Michael Ellerman
@ 2018-05-18 6:39 ` Samuel Mendoza-Jonas
2018-05-18 12:00 ` Michael Ellerman
2018-05-21 10:01 ` [1/3] " Michael Ellerman
3 siblings, 1 reply; 6+ messages in thread
From: Samuel Mendoza-Jonas @ 2018-05-18 6:39 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: alistair, paulus
On Mon, 2018-05-14 at 22:50 +1000, Michael Ellerman wrote:
> Add byte-swapping versions of __raw_writeq() and __raw_rm_writeq().
>
> This allows us to avoid sparse warnings caused by passing __be64 to
> __raw_writeq(), which takes unsigned long:
>
> arch/powerpc/platforms/powernv/pci-ioda.c:1981:38:
> warning: incorrect type in argument 1 (different base types)
> expected unsigned long [unsigned] v
> got restricted __be64 [usertype] <noident>
>
> It's also generally preferable to use a byte-swapping accessor rather
> than doing it by hand in the code, which is more bug prone.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
For this and the following patches:
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> ---
> arch/powerpc/include/asm/io.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
> index af074923d598..e0331e754568 100644
> --- a/arch/powerpc/include/asm/io.h
> +++ b/arch/powerpc/include/asm/io.h
> @@ -367,6 +367,11 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
> *(volatile unsigned long __force *)PCI_FIX_ADDR(addr) = v;
> }
>
> +static inline void __raw_writeq_be(unsigned long v, volatile void __iomem *addr)
> +{
> + __raw_writeq((__force unsigned long)cpu_to_be64(v), addr);
> +}
> +
> /*
> * Real mode versions of the above. Those instructions are only supposed
> * to be used in hypervisor real mode as per the architecture spec.
> @@ -395,6 +400,11 @@ static inline void __raw_rm_writeq(u64 val, volatile void __iomem *paddr)
> : : "r" (val), "r" (paddr) : "memory");
> }
>
> +static inline void __raw_rm_writeq_be(u64 val, volatile void __iomem *paddr)
> +{
> + __raw_rm_writeq((__force u64)cpu_to_be64(val), paddr);
> +}
> +
> static inline u8 __raw_rm_readb(volatile void __iomem *paddr)
> {
> u8 ret;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be()
2018-05-18 6:39 ` [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Samuel Mendoza-Jonas
@ 2018-05-18 12:00 ` Michael Ellerman
0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-05-18 12:00 UTC (permalink / raw)
To: Samuel Mendoza-Jonas, linuxppc-dev; +Cc: alistair, paulus
Samuel Mendoza-Jonas <sam@mendozajonas.com> writes:
> On Mon, 2018-05-14 at 22:50 +1000, Michael Ellerman wrote:
>> Add byte-swapping versions of __raw_writeq() and __raw_rm_writeq().
>>
>> This allows us to avoid sparse warnings caused by passing __be64 to
>> __raw_writeq(), which takes unsigned long:
>>
>> arch/powerpc/platforms/powernv/pci-ioda.c:1981:38:
>> warning: incorrect type in argument 1 (different base types)
>> expected unsigned long [unsigned] v
>> got restricted __be64 [usertype] <noident>
>>
>> It's also generally preferable to use a byte-swapping accessor rather
>> than doing it by hand in the code, which is more bug prone.
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> For this and the following patches:
>
> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Thanks.
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be()
2018-05-14 12:50 [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Michael Ellerman
` (2 preceding siblings ...)
2018-05-18 6:39 ` [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Samuel Mendoza-Jonas
@ 2018-05-21 10:01 ` Michael Ellerman
3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-05-21 10:01 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: alistair, paulus
On Mon, 2018-05-14 at 12:50:31 UTC, Michael Ellerman wrote:
> Add byte-swapping versions of __raw_writeq() and __raw_rm_writeq().
>
> This allows us to avoid sparse warnings caused by passing __be64 to
> __raw_writeq(), which takes unsigned long:
>
> arch/powerpc/platforms/powernv/pci-ioda.c:1981:38:
> warning: incorrect type in argument 1 (different base types)
> expected unsigned long [unsigned] v
> got restricted __be64 [usertype] <noident>
>
> It's also generally preferable to use a byte-swapping accessor rather
> than doing it by hand in the code, which is more bug prone.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Series applied to powerpc next.
https://git.kernel.org/powerpc/c/8056fe28d04607106e7d418bd9ee2e
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-05-21 10:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 12:50 [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Michael Ellerman
2018-05-14 12:50 ` [PATCH 2/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in pci-ioda.c Michael Ellerman
2018-05-14 12:50 ` [PATCH 3/3] powerpc/powernv: Use __raw_[rm_]writeq_be() in npu-dma.c Michael Ellerman
2018-05-18 6:39 ` [PATCH 1/3] powerpc/io: Add __raw_writeq_be() __raw_rm_writeq_be() Samuel Mendoza-Jonas
2018-05-18 12:00 ` Michael Ellerman
2018-05-21 10:01 ` [1/3] " Michael Ellerman
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.