Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 07:54 AM, Benjamin Herrenschmidt wrote: > On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: >> >> I do not understand why @val is considered LE here and need to be >> converted >> to CPU. Really. I truly believe it should be cpu_to_le32(). > > No. Both are slightly

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Benjamin Herrenschmidt
On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: > > I do not understand why @val is considered LE here and need to be > converted > to CPU. Really. I truly believe it should be cpu_to_le32(). No. Both are slightly wrong semantically but le32_to_cpu() is less wrong :-) iowrite32

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Benjamin Herrenschmidt
On Tue, 2014-06-24 at 12:41 +0200, Alexander Graf wrote: > Is there actually any difference in generated code with this patch > applied and without? I would hope that iowrite..() is inlined and > cancels out the cpu_to_le..() calls that are also inlined? No, the former uses byteswapping asm,

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 12:43 AM, Alex Williamson wrote: > On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: >> On 06/25/2014 12:21 AM, Alex Williamson wrote: >>> On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: On 24.06.14 15:01, Alexey Kardashevskiy wrote: > On 06/24/2014

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alex Williamson
On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: > On 06/25/2014 12:21 AM, Alex Williamson wrote: > > On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: > >> On 24.06.14 15:01, Alexey Kardashevskiy wrote: > >>> On 06/24/2014 10:52 PM, Alexander Graf wrote: > On 24.06.14

RE: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread David Laight
From: Alexey Kardashevskiy ... > >> So IMHO we should either create new, generic iowrite helpers that don't > >> do any endian swapping at all or do iowrite32(cpu_to_le32(val)) calls. > > > > I'm one of those people for whom iowrite32(le32_to_cpu(val)) makes sense > > > I do not understand why

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 12:21 AM, Alex Williamson wrote: > On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: >> On 24.06.14 15:01, Alexey Kardashevskiy wrote: >>> On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: > On 06/24/2014 08:41 PM, Alexander

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alex Williamson
On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: > On 24.06.14 15:01, Alexey Kardashevskiy wrote: > > On 06/24/2014 10:52 PM, Alexander Graf wrote: > >> On 24.06.14 14:50, Alexey Kardashevskiy wrote: > >>> On 06/24/2014 08:41 PM, Alexander Graf wrote: > On 24.06.14 12:11, Alexey

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/24/2014 10:52 PM, Alexander Graf wrote: > > On 24.06.14 14:50, Alexey Kardashevskiy wrote: >> On 06/24/2014 08:41 PM, Alexander Graf wrote: >>> On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: > On Thu, 2014-06-19 at 21:21 -0600,

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/24/2014 08:41 PM, Alexander Graf wrote: > > On 24.06.14 12:11, Alexey Kardashevskiy wrote: >> On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: >>> On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: >>> Working on big endian being an accident may be a matter of perspective

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an accident may be a matter of perspective :-) The comment remains that this patch doesn't actually

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: > On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: > >> Working on big endian being an accident may be a matter of perspective > > :-) > >> The comment remains that this patch doesn't actually fix anything except >> the overhead on

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an accident may be a matter of perspective :-) The comment remains that this patch doesn't actually fix anything except the overhead on big endian

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an accident may be a matter of perspective :-) The comment remains that this patch doesn't actually

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an accident may be a matter of perspective :-) The

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexander Graf
On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote: On 06/21/2014 09:12 AM, Benjamin Herrenschmidt wrote: On

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alex Williamson
On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On 24.06.14 12:11, Alexey Kardashevskiy wrote:

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 12:21 AM, Alex Williamson wrote: On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey Kardashevskiy wrote: On 06/24/2014 08:41 PM, Alexander Graf wrote: On

RE: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread David Laight
From: Alexey Kardashevskiy ... So IMHO we should either create new, generic iowrite helpers that don't do any endian swapping at all or do iowrite32(cpu_to_le32(val)) calls. I'm one of those people for whom iowrite32(le32_to_cpu(val)) makes sense I do not understand why @val is

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alex Williamson
On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: On 06/25/2014 12:21 AM, Alex Williamson wrote: On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM, Alexander Graf wrote: On 24.06.14 14:50, Alexey

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 12:43 AM, Alex Williamson wrote: On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: On 06/25/2014 12:21 AM, Alex Williamson wrote: On Tue, 2014-06-24 at 15:22 +0200, Alexander Graf wrote: On 24.06.14 15:01, Alexey Kardashevskiy wrote: On 06/24/2014 10:52 PM,

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Benjamin Herrenschmidt
On Tue, 2014-06-24 at 12:41 +0200, Alexander Graf wrote: Is there actually any difference in generated code with this patch applied and without? I would hope that iowrite..() is inlined and cancels out the cpu_to_le..() calls that are also inlined? No, the former uses byteswapping asm, the

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Benjamin Herrenschmidt
On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: I do not understand why @val is considered LE here and need to be converted to CPU. Really. I truly believe it should be cpu_to_le32(). No. Both are slightly wrong semantically but le32_to_cpu() is less wrong :-) iowrite32

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-24 Thread Alexey Kardashevskiy
On 06/25/2014 07:54 AM, Benjamin Herrenschmidt wrote: On Wed, 2014-06-25 at 00:33 +1000, Alexey Kardashevskiy wrote: I do not understand why @val is considered LE here and need to be converted to CPU. Really. I truly believe it should be cpu_to_le32(). No. Both are slightly wrong

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Benjamin Herrenschmidt
On Sat, 2014-06-21 at 00:14 +1000, Alexey Kardashevskiy wrote: > We can still use __raw_writel, would that be ok? No unless you understand precisely what kind of memory barriers each platform require for these. Cheers, Ben. -- To unsubscribe from this list: send the line "unsubscribe

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Benjamin Herrenschmidt
On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: > Working on big endian being an accident may be a matter of perspective :-) > The comment remains that this patch doesn't actually fix anything except > the overhead on big endian systems doing redundant byte swapping and > maybe the

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Alexey Kardashevskiy
On 06/20/2014 01:21 PM, Alex Williamson wrote: > On Thu, 2014-06-19 at 13:48 +1000, Alexey Kardashevskiy wrote: >> On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: >>> On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: > On Wed,

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Alexey Kardashevskiy
On 06/20/2014 01:21 PM, Alex Williamson wrote: On Thu, 2014-06-19 at 13:48 +1000, Alexey Kardashevskiy wrote: On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Benjamin Herrenschmidt
On Thu, 2014-06-19 at 21:21 -0600, Alex Williamson wrote: Working on big endian being an accident may be a matter of perspective :-) The comment remains that this patch doesn't actually fix anything except the overhead on big endian systems doing redundant byte swapping and maybe the

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-20 Thread Benjamin Herrenschmidt
On Sat, 2014-06-21 at 00:14 +1000, Alexey Kardashevskiy wrote: We can still use __raw_writelco, would that be ok? No unless you understand precisely what kind of memory barriers each platform require for these. Cheers, Ben. -- To unsubscribe from this list: send the line unsubscribe

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-19 Thread Alex Williamson
On Thu, 2014-06-19 at 13:48 +1000, Alexey Kardashevskiy wrote: > On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: > > On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > >> On 06/19/2014 04:35 AM, Alex Williamson wrote: > >>> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-19 Thread Alexey Kardashevskiy
2014 9:18 AM >> To: Alex Williamson >> Cc: k...@vger.kernel.org; Nikunj A Dadhania; linux-kernel@vger.kernel.org; >> Alexander Graf; linuxppc-...@lists.ozlabs.org >> Subject: Re: [PATCH] vfio: Fix endianness handling for emulated BARs >> >> On 06/19/2014

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-19 Thread Alexey Kardashevskiy
...@vger.kernel.org; Nikunj A Dadhania; linux-kernel@vger.kernel.org; Alexander Graf; linuxppc-...@lists.ozlabs.org Subject: Re: [PATCH] vfio: Fix endianness handling for emulated BARs On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-19 Thread Alex Williamson
On Thu, 2014-06-19 at 13:48 +1000, Alexey Kardashevskiy wrote: On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes

RE: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread bharat.bhus...@freescale.com
adhania; linux-kernel@vger.kernel.org; > Alexander Graf; linuxppc-...@lists.ozlabs.org > Subject: Re: [PATCH] vfio: Fix endianness handling for emulated BARs > > On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: > > On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > >&g

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: >> On 06/19/2014 04:35 AM, Alex Williamson wrote: >>> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 04:35 AM, Alex Williamson wrote: >> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >>> VFIO exposes BARs to user space as a byte stream so userspace can >>> read it using pread()/pwrite(). Since this is a byte

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 04:35 AM, Alex Williamson wrote: >> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >>> VFIO exposes BARs to user space as a byte stream so userspace can >>> read it using pread()/pwrite(). Since this is a byte

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 04:35 AM, Alex Williamson wrote: > On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >> VFIO exposes BARs to user space as a byte stream so userspace can >> read it using pread()/pwrite(). Since this is a byte stream, VFIO should >> not do byte swapping and simply return

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alex Williamson
On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: > VFIO exposes BARs to user space as a byte stream so userspace can > read it using pread()/pwrite(). Since this is a byte stream, VFIO should > not do byte swapping and simply return values as it gets them from > PCI device. > >

[PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO should not do byte swapping and simply return values as it gets them from PCI device. Instead, the existing code assumes that byte stream in read/write is

[PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO should not do byte swapping and simply return values as it gets them from PCI device. Instead, the existing code assumes that byte stream in read/write is

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alex Williamson
On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO should not do byte swapping and simply return values as it gets them from PCI device. Instead,

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO should not do byte swapping and simply return values

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can read it using pread()/pwrite(). Since this is a byte stream, VFIO

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can read it using

RE: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread bharat.bhus...@freescale.com
; Alexander Graf; linuxppc-...@lists.ozlabs.org Subject: Re: [PATCH] vfio: Fix endianness handling for emulated BARs On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: On 06/19/2014 04:35 AM, Alex Williamson wrote: On Wed, 2014-06-18