Re: [PATCH v11 4/7] powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned

2017-04-18 Thread Yongji Xie
On 19 April 2017 at 09:47, Michael Ellerman <m...@ellerman.id.au> wrote: > Bjorn Helgaas <bhelg...@google.com> writes: > >> On Mon, Apr 17, 2017 at 4:36 PM, Bjorn Helgaas <bhelg...@google.com> wrote: >>> From: Yongji Xie <elohi...@gmail.com> >&g

Re: [PATCH v11 2/7] PCI: A fix for caculating bridge window's size and alignment

2017-04-17 Thread Yongji Xie
Hi Yinghai, On 18 April 2017 at 05:45, Yinghai Lu <ying...@kernel.org> wrote: > On Mon, Apr 17, 2017 at 2:36 PM, Bjorn Helgaas <bhelg...@google.com> wrote: >> From: Yongji Xie <elohi...@gmail.com> >> >> In case that one device's alignment is greater than it

Re: [PATCH v10 4/4] PCI: Don't extend device's size when using default alignment for all devices

2017-04-17 Thread Yongji Xie
2017-04-15 6:54 GMT+08:00 Bjorn Helgaas <helg...@kernel.org>: > On Mon, Apr 10, 2017 at 07:58:14PM +0800, Yongji Xie wrote: > > Currently we reassign the alignment by extending resources' size in > > pci_reassigndev_resource_alignment(). This could potentially break

[PATCH v10 4/4] PCI: Don't extend device's size when using default alignment for all devices

2017-04-10 Thread Yongji Xie
in this case. So this patch tries to use START_ALIGNMENT to identify the resource's alignment without extending the size when the alignment reassigning is caused by the default alignment. Signed-off-by: Yongji Xie <elohi...@gmail.com> --- drivers/pci/pci.c | 34

[PATCH v10 3/4] powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned

2017-04-10 Thread Yongji Xie
This overrides pcibios_default_alignment() to set default alignment to PAGE_SIZE for all PCI devices on PowerNV platform. Thus sub-page BARs would not share a page and could be mapped into guest when VFIO passthrough them. Signed-off-by: Yongji Xie <elohi...@gmail.com> --- arch/powerpc/i

[PATCH v10 2/4] PCI: Add pcibios_default_alignment() for arch-specific alignment control

2017-04-10 Thread Yongji Xie
alignment for all PCI devices. An arch can override it to force the PCI core to place memory BARs on their own pages. Signed-off-by: Yongji Xie <elohi...@gmail.com> --- drivers/pci/pci.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drive

[PATCH v10 1/4] PCI: A fix for caculating bridge window's size and alignment

2017-04-10 Thread Yongji Xie
In case that one device's alignment is greater than its size, we may get an incorrect size and alignment for its bus's memory window in pbus_size_mem(). This patch fixes this case. Signed-off-by: Yongji Xie <elohi...@gmail.com> --- drivers/pci/setup-bus.c |4 ++-- 1 file chan

[PATCH v10 0/4] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-04-10 Thread Yongji Xie
rovements Changelog v3: - Ignore enforced alignment to fixed BARs - Fix issue that disabling memory decoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongj

Re: [PATCH v9 3/3] PCI: Don't extend device's size when using default alignment for all devices

2017-03-25 Thread Yongji Xie
On Thu, Mar 23, 2017 at 04:55:58PM -0500, Bjorn Helgaas wrote: > > On Wed, Feb 15, 2017 at 02:45:06PM +0800, Yongji Xie wrote: >> Currently we reassign the alignment by extending resources' size in >> pci_reassigndev_resource_alignment(). This could potentially break &g

Re: [PATCH v9 2/3] PCI: Add a macro to set default alignment for all PCI devices

2017-03-25 Thread Yongji Xie
On Thu, Mar 23, 2017 at 03:53:42PM -0500, Bjorn Helgaas wrote: > Hi Yongji, > > On Wed, Feb 15, 2017 at 02:45:05PM +0800, Yongji Xie wrote: >> When vfio passthroughs a PCI device of which MMIO BARs are >> smaller than PAGE_SIZE, guest will not handle the mmio >> acces

[PATCH v9 3/3] PCI: Don't extend device's size when using default alignment for all devices

2017-02-14 Thread Yongji Xie
tries to use START_ALIGNMENT to identify the resource's alignment without extending the size when the alignment reassigning is caused by the default alignment. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 34 -- 1 files changed, 24

[PATCH v9 2/3] PCI: Add a macro to set default alignment for all PCI devices

2017-02-14 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |3 +++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h

[PATCH v9 1/3] PCI: A fix for caculating bridge window's size and alignment

2017-02-14 Thread Yongji Xie
In case that one device's alignment is greater than its size, we may get an incorrect size and alignment for its bus's memory window in pbus_size_mem(). This patch fixes this case. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/setup-bus.c |4 ++-- 1 files chan

[PATCH v9 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-02-14 Thread Yongji Xie
rNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (3): PCI: A fix for caculating bridge window's size and alignment PCI: Add a macro to set default alignment for all PCI devices PCI: Don't extend device's size when using de

[PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices

2017-01-19 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index e9bd6cf..5

[PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()

2017-01-19 Thread Yongji Xie
d if we need the allocated size, resource_size()(or we can introuce a new helper function) can be used to get it. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |1 + include/linux/pci.h |6 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff -

[PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs

2017-01-19 Thread Yongji Xie
-by: Yongji Xie <xyj...@linux.vnet.ibm.com> Reviewed-by: Gavin Shan <gws...@linux.vnet.ibm.com> --- drivers/pci/pci.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a881c0d..220c31e 100644 --- a/drivers/pci/pci.c +++ b/drive

[PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-01-19 Thread Yongji Xie
coding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (3): PCI: Ignore requested alignment for IOV BARs PCI: Make sure the driver could get correct BAR size from p

Re: [RFC PATCH v7 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-11-14 Thread Yongji Xie
Hi Bjorn, Kindly ping. What do you think of the way to fix the bug that resources's size is changed when using resource_alignment. Thanks. On 2016/10/26 14:53, Yongji Xie wrote: This series introduces a way for PCI resource allocator to force MMIO BARs not to share PAGE_SIZE. This would

[RFC PATCH v7 3/3] PCI: Add a macro to set default alignment for all PCI devices

2016-10-26 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index e9bd6cf..5

[RFC PATCH v7 2/3] PCI: Restore resource's size if we expand it by using resource_alignment

2016-10-26 Thread Yongji Xie
in pci_reassigndev_resource_alignment() and restores to original sizes after PCI resource sizing/assigning are done. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |1 + drivers/pci/setup-bus.c | 19 +++ include/linux/pci.h |

[RFC PATCH v7 1/3] PCI: Ignore requested alignment for IOV BARs

2016-10-26 Thread Yongji Xie
We would call pci_reassigndev_resource_alignment() before pci_init_capabilities(). So the requested alignment would never work for IOV BARs. And it's also meaningless to do so. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |2 +- 1 file changed, 1 ins

[RFC PATCH v7 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-10-26 Thread Yongji Xie
g v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (3): PCI: Ignore requested alignment for IOV BARs PCI: Restore resource's size if we expand it by using resource_alignment PCI: Add a macro to set default alignment for all PCI devices arch/powerpc/i

Re: [PATCH v5 4/4] PCI: Add a macro to set default alignment for all PCI devices

2016-09-29 Thread Yongji Xie
On 2016/9/29 22:00, Bjorn Helgaas wrote: On Tue, Sep 13, 2016 at 05:00:34PM +0800, Yongji Xie wrote: When vfio passthroughs a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because

Re: [PATCH v5 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-09-29 Thread Yongji Xie
On 2016/9/29 19:54, Bjorn Helgaas wrote: On Thu, Sep 29, 2016 at 10:38:01AM +0800, Yongji Xie wrote: On 2016/9/29 6:42, Bjorn Helgaas wrote: On Tue, Sep 13, 2016 at 05:00:33PM +0800, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns

[PATCH v6 4/4] PCI: Add a macro to set default alignment for all PCI devices

2016-09-29 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index e9bd6cf..5

[PATCH v6 3/4] PCI: Don't change resources' size when using resource_alignment

2016-09-29 Thread Yongji Xie
IORESOURCE_STARTALIGN to specify the alignment instead of IORESOURCE_SIZEALIGN. Thus, we can reassign the alignment without changing resources's size. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff

[PATCH v6 2/4] PCI: Ignore enforced alignment to VF BARs

2016-09-29 Thread Yongji Xie
and will release the allocated resources which leads to a bug. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2d85a96..b8357d7 100644 --- a/drivers/pci/pci.c +++ b/d

[PATCH v6 1/4] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-09-29 Thread Yongji Xie
and not re-allocated. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aab9d51..2d85a96 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4959,6 +4

[PATCH v6 0/4] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-09-29 Thread Yongji Xie
rced alignment to fixed BARs - Fix issue that disabling memory decoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore enforced alignment wh

Re: [PATCH v5 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-09-28 Thread Yongji Xie
On 2016/9/29 6:42, Bjorn Helgaas wrote: On Tue, Sep 13, 2016 at 05:00:33PM +0800, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. For example, the driver uses

Re: [PATCH v5 0/4] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-09-26 Thread Yongji Xie
Hi Bjorn, Kindly Ping... Any comment on V5? Thanks, Yongji On 2016/9/13 17:00, Yongji Xie wrote: This series introduces a way for PCI resource allocator to force MMIO BARs not to share PAGE_SIZE. This would make sense to VFIO driver. Because current VFIO implementation disallows to mmap sub

[PATCH v5 4/4] PCI: Add a macro to set default alignment for all PCI devices

2016-09-13 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |4 2 files changed, 8 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index e9bd6cf..5

[PATCH v5 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-09-13 Thread Yongji Xie
"noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |9 ++--- drivers/pci/pci.c | 37 +-- 2 files changed, 33 insertions(+), 13 de

[PATCH v5 2/4] PCI: Ignore enforced alignment to VF BARs

2016-09-13 Thread Yongji Xie
and will release the allocated resources which leads to a bug. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2d85a96..b8357d7 100644 --- a/drivers/pci/pci.c +++ b/d

[PATCH v5 1/4] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-09-13 Thread Yongji Xie
and not re-allocated. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aab9d51..2d85a96 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4959,6 +4

[PATCH v5 0/4] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-09-13 Thread Yongji Xie
decoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore enforced alignment when kernel uses existing firmware setup PCI: Ignore enforced al

Re: [PATCH v4 3/5] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-09-07 Thread Yongji Xie
On 2016/9/7 0:56, Bjorn Helgaas wrote: On Fri, Aug 12, 2016 at 01:42:24PM +0800, Yongji Xie wrote: We should not disable memory decoding when we reassign alignment in pci_reassigndev_resource_alignment(). It's meaningless and have some side effects. For example, we found it would break

Re: [PATCH v4 5/5] PCI: Add a macro to set default alignment for all PCI devices

2016-09-06 Thread Yongji Xie
On 2016/9/7 0:59, Bjorn Helgaas wrote: On Fri, Aug 12, 2016 at 01:42:26PM +0800, Yongji Xie wrote: When vfio passthroughs a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because

Re: [PATCH v4 0/5] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-09-05 Thread Yongji Xie
Ping? On 2016/8/12 13:42, Yongji Xie wrote: This series introduces a way for PCI resource allocator to force MMIO BARs not to share PAGE_SIZE. This would make sense to VFIO driver. Because current VFIO implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs which may sh

[PATCH v4 4/5] PCI: Add a new option for resource_alignment to reassign alignment

2016-08-11 Thread Yongji Xie
"noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |9 ++--- drivers/pci/pci.c | 37 +-- 2 files changed, 33 insertions(+), 13 de

[PATCH v4 5/5] PCI: Add a macro to set default alignment for all PCI devices

2016-08-11 Thread Yongji Xie
as PAGE_SIZE. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- arch/powerpc/include/asm/pci.h |4 drivers/pci/pci.c |4 2 files changed, 8 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index e9bd6cf..5

[PATCH v4 3/5] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-08-11 Thread Yongji Xie
by the firmware or not. Disabling memory decoding would cause the one initialized by firmware may not be set as the default VGA device when more than one graphics adapter is present. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |8 +--- 1 file chan

[PATCH v4 2/5] PCI: Ignore enforced alignment to VF BARs

2016-08-11 Thread Yongji Xie
and will release the allocated resources which leads to a bug. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2d85a96..b8357d7 100644 --- a/drivers/pci/pci.c +++ b/d

[PATCH v4 0/5] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2016-08-11 Thread Yongji Xie
nt to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (5): PCI: Ignore enforced alignment when kernel uses existing firmware setup PCI: Ignore enforced alignment to VF BARs PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment() PCI: Add a new option for resou

[PATCH v4 1/5] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-08-11 Thread Yongji Xie
and not re-allocated. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aab9d51..2d85a96 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4959,6 +4

Re: [PATCH v3 0/7] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-07-11 Thread Yongji Xie
Hi Bjorn, Any comment on V3? Thanks, Yongji On 2016/6/30 18:53, Yongji Xie wrote: This series aims to add an option for PCI resource allocator to force BARs not to share PAGE_SIZE. This would make sense to VFIO driver. Because current VFIO implementation disallows to mmap sub-page(size

Re: [PATCH v3 5/7] PCI: Do not use IORESOURCE_STARTALIGN to identify bridge resources

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 10:34, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:11PM +0800, Yongji Xie wrote: Now we use the IORESOURCE_STARTALIGN to identify bridge resources in __assign_resources_sorted(). That's quite fragile. We may also set flag IORESOURCE_STARTALIGN for SR-IOV resources

Re: [PATCH v3 4/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 10:25, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:10PM +0800, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. For example

Re: [PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 14:05, Gavin Shan wrote: On Fri, Jul 01, 2016 at 01:27:17PM +0800, Yongji Xie wrote: On Thu, Jun 30, 2016 at 06:53:08PM +0800, Yongji Xie wrote: VF BARs are read-only zeroes according to SRIOV spec, the normal way(writing BARs) of allocating resources wouldn't

Re: [PATCH v3 3/7] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:50, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:09PM +0800, Yongji Xie wrote: We should not disable memory decoding when we reassign alignment in pci_reassigndev_resource_alignment(). It's meaningless and have some side effect. For example, some fixup functions

Re: [PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:39, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:08PM +0800, Yongji Xie wrote: VF BARs are read-only zeroes according to SRIOV spec, the normal way(writing BARs) of allocating resources wouldn't be applied to VFs. The VFs' resources would be allocated when we enable

Re: [PATCH v3 1/7] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:28, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:07PM +0800, Yongji Xie wrote: PCI resources allocator will use firmware setup and not try to reassign resource when PCI_PROBE_ONLY or IORESOURCE_PCI_FIXED is set. The enforced alignment

[PATCH v3 7/7] PCI: Add a macro to set default alignment for all PCI devices

2016-06-30 Thread Yongji Xie
fault on some platforms such as PowerNV platform which would easily see those sub-page BARs because of its 64K page. To achieve that, we add a macro PCIBIOS_DEFAULT_ALIGNMENT to set default alignment for all PCI devices and define it on PowerNV platform. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ib

[PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-06-30 Thread Yongji Xie
and will release the allocated resources which leads to a bug. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index be8f72c..6ae02de 100644 --- a/drivers/pci/pci.c +++ b/drive

[PATCH v3 6/7] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-06-30 Thread Yongji Xie
ent of all MMIO BARs to be at least PAGE_SIZE so that one BAR's mmio page would not be shared with other BARs. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |2 ++ drivers/pci/pci.c | 60

[PATCH v3 5/7] PCI: Do not use IORESOURCE_STARTALIGN to identify bridge resources

2016-06-30 Thread Yongji Xie
. In this patch, we try to use a more robust way to identify bridge resources. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/setup-bus.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bu

[PATCH v3 3/7] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-06-30 Thread Yongji Xie
. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6ae02de..6241cfc 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4820,7 +4820,6 @

[PATCH v3 4/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-06-30 Thread Yongji Xie
"noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 35 +-- 2 files changed, 29 insertions(+), 11 deletion

[PATCH v3 1/7] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-06-30 Thread Yongji Xie
and not re-allocated. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c8b4dbd..be8f72c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4760,6 +4

[PATCH v3 0/7] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-06-30 Thread Yongji Xie
ory decoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (7): PCI: Ignore enforced alignment when kernel uses existing firmware setup PCI: Ignore enfor

Re: [RESEND PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set\\

2016-06-21 Thread Yongji Xie
On 2016/6/21 10:16, Yongji Xie wrote: On 2016/6/21 9:43, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:48PM +0800, Yongji Xie wrote: The resource_alignment will releases memory resources allocated by firmware so that kernel can reassign new resources later on. But this will cause

Re: [RESEND PATCH v2 4/4] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-06-21 Thread Yongji Xie
On 2016/6/21 10:26, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:51PM +0800, Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because

Re: [RESEND PATCH v2 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:57, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:50PM +0800, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. For example, the driver uses

Re: [RESEND PATCH v2 2/4] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:50, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:49PM +0800, Yongji Xie wrote: Now we use the IORESOURCE_STARTALIGN to identify bridge resources in __assign_resources_sorted(). That's quite fragile. We can't make sure that the PCI devices' resources will not use

Re: [RESEND PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set\\

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:43, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:48PM +0800, Yongji Xie wrote: The resource_alignment will releases memory resources allocated by firmware so that kernel can reassign new resources later on. But this will cause the problem that no resources can be allocated

Re: [RESEND PATCH v2 0/6] vfio-pci: Add support for mmapping MSI-X table

2016-06-08 Thread Yongji Xie
Hi, Eric On 2016/6/8 15:41, Auger Eric wrote: Hi Yongji, Le 02/06/2016 à 08:09, Yongji Xie a écrit : Current vfio-pci implementation disallows to mmap the page containing MSI-X table in case that users can write directly to MSI-X table and generate an incorrect MSIs. However

Re: [RESEND PATCH v2 2/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping

2016-06-06 Thread Yongji Xie
-ci/linux/commits/Yongji-Xie/PCI-Add-a-new-PCI_BUS_FLAGS_MSI_REMAP-flag/20160530-215348 base: https://github.com/awilliam/linux-vfio.git next config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205 reproduce: wget https

Re: [RESEND PATCH v2 2/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping

2016-06-06 Thread Yongji Xie
-ci/linux/commits/Yongji-Xie/PCI-Add-a-new-PCI_BUS_FLAGS_MSI_REMAP-flag/20160530-215348 base: https://github.com/awilliam/linux-vfio.git next config: arm-sa1100 (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205 reproduce: wget https://git.kernel.org

Re: [RESEND PATCH v2 0/6] vfio-pci: Add support for mmapping MSI-X table

2016-06-02 Thread Yongji Xie
2016 14:09:57 +0800 Yongji Xie <xyj...@linux.vnet.ibm.com> wrote: Current vfio-pci implementation disallows to mmap the page containing MSI-X table in case that users can write directly to MSI-X table and generate an incorrect MSIs. However, this will cause some performance issu

[RESEND PATCH v2 2/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping

2016-06-02 Thread Yongji Xie
. [1] https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/msi.c | 15 +++ drivers/pci/probe.c |3 +++ include/linux/msi.h |5 - 3 files changed, 22 insertions(+), 1 de

[RESEND PATCH v2 6/6] vfio-pci: Allow to expose MSI-X table to userspace if interrupt remapping is enabled

2016-06-02 Thread Yongji Xie
directly. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/vfio/pci/vfio_pci.c | 17 ++--- drivers/vfio/pci/vfio_pci_rdwr.c |3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c

[RESEND PATCH v2 4/6] iommu: Set PCI_BUS_FLAGS_MSI_REMAP on iommu driver initialization

2016-06-02 Thread Yongji Xie
Some iommu drivers would be initialized after PCI device enumeration. So PCI_BUS_FLAGS_MSI_REMAP would not be set when probing PCI devices although IOMMU enables capability of IRQ remapping. This patch tests this capability and set the flag when iommu driver is initialized. Signed-off-by: Yongji

[RESEND PATCH v2 1/6] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-06-02 Thread Yongji Xie
chs. With this flag enabled, we can easily know whether it's safe to expose MSI-X tables of PCI BARs to userspace. Some usespace drivers such as VFIO may benefit from this. [1] https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Signed-off-by: Yongji Xie &

[RESEND PATCH v2 5/6] pci-ioda: Set PCI_BUS_FLAGS_MSI_REMAP for IODA host bridge

2016-06-02 Thread Yongji Xie
Any IODA host bridge have the capability of IRQ remapping. So we set PCI_BUS_FLAGS_MSI_REMAP when this kind of host birdge is detected. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> Reviewed-by: Alexey Kardashevskiy <a...@ozlabs.ru> --- arch/powerpc/platforms/powernv/pci-i

[RESEND PATCH v2 3/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping

2016-06-02 Thread Yongji Xie
. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/probe.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2b9e3ba..15a33e2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -16,6 +16,7 @@ #include #i

[RESEND PATCH v2 0/6] vfio-pci: Add support for mmapping MSI-X table

2016-06-02 Thread Yongji Xie
://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Yongji Xie (6): PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping PCI: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping iommu: Set

[RESEND PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-06-02 Thread Yongji Xie
to use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/p

[RESEND PATCH v2 4/4] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-06-02 Thread Yongji Xie
be applied to VFs whose BARs are always page aligned and should be never reassigned according to SRIOV spec. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |2 ++ arch/powerpc/include/asm/pci.h |2 ++ drivers/pci/pci.c

[RESEND PATCH v2 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-06-01 Thread Yongji Xie
"noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 35 +-- 2 files changed, 29 insertions(+), 11 deletion

[RESEND PATCH v2 2/4] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-06-01 Thread Yongji Xie
. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/setup-bus.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 55641a3..216ddbc 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup

[RESEND PATCH v2 0/4] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-06-01 Thread Yongji Xie
ARs; patch 4 modified resource_alignment to support syntax which can be used to enforce the alignment of all MMIO BARs to be at least PAGE_SIZE. Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore resource_alignm

[PATCH v2 6/6] vfio-pci: Allow to expose MSI-X table to userspace if interrupt remapping is enabled

2016-05-30 Thread Yongji Xie
directly. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/vfio/pci/vfio_pci.c | 17 ++--- drivers/vfio/pci/vfio_pci_rdwr.c |3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c

[PATCH v2 3/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping

2016-05-30 Thread Yongji Xie
. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/probe.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2b9e3ba..15a33e2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -16,6 +16,7 @@ #include #i

[PATCH v2 5/6] pci-ioda: Set PCI_BUS_FLAGS_MSI_REMAP for IODA host bridge

2016-05-30 Thread Yongji Xie
Any IODA host bridge have the capability of IRQ remapping. So we set PCI_BUS_FLAGS_MSI_REMAP when this kind of host birdge is detected. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> Reviewed-by: Alexey Kardashevskiy <a...@ozlabs.ru> --- arch/powerpc/platforms/powernv/pci-i

[PATCH v2 4/6] iommu: Set PCI_BUS_FLAGS_MSI_REMAP on iommu driver initialization

2016-05-30 Thread Yongji Xie
Some iommu drivers would be initialized after PCI device enumeration. So PCI_BUS_FLAGS_MSI_REMAP would not be set when probing PCI devices although IOMMU enables capability of IRQ remapping. This patch tests this capability and set the flag when iommu driver is initialized. Signed-off-by: Yongji

[PATCH v2 2/6] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping

2016-05-30 Thread Yongji Xie
. [1] https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/msi.c | 15 +++ drivers/pci/probe.c |3 +++ include/linux/msi.h |5 - 3 files changed, 22 insertions(+), 1 de

[PATCH v2 0/6] vfio-pci: Add support for mmapping MSI-X table

2016-05-30 Thread Yongji Xie
://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Yongji Xie (6): PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller enables IRQ remapping PCI: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping iommu: Set

[PATCH v2 1/6] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-05-30 Thread Yongji Xie
chs. With this flag enabled, we can easily know whether it's safe to expose MSI-X tables of PCI BARs to userspace. Some usespace drivers such as VFIO may benefit from this. [1] https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1138820.html Signed-off-by: Yongji Xie &

[PATCH v2 4/4] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-05-30 Thread Yongji Xie
be applied to VFs whose BARs are always page aligned and should be never reassigned according to SRIOV spec. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |2 ++ arch/powerpc/include/asm/pci.h |2 ++ drivers/pci/pci.c

[PATCH v2 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-05-30 Thread Yongji Xie
"noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 35 +-- 2 files changed, 29 insertions(+), 11 deletion

[PATCH v2 2/4] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-05-30 Thread Yongji Xie
. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/setup-bus.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 55641a3..216ddbc 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup

[PATCH v2 0/4] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-05-30 Thread Yongji Xie
ARs; patch 4 modified resource_alignment to support syntax which can be used to enforce the alignment of all MMIO BARs to be at least PAGE_SIZE. Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore resource_alignm

[PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-05-30 Thread Yongji Xie
to use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com> --- drivers/pci/pci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/p

Re: [PATCH 2/5] iommu: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping

2016-05-24 Thread Yongji Xie
On 2016/5/25 5:11, Bjorn Helgaas wrote: On Wed, Apr 27, 2016 at 08:43:27PM +0800, Yongji Xie wrote: The capability of IRQ remapping is abstracted on IOMMU side on some archs. There is a existing flag IOMMU_CAP_INTR_REMAP for this. To have a universal flag to test this capability for different

Re: [PATCH 3/5] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller supports IRQ remapping

2016-05-24 Thread Yongji Xie
On 2016/5/25 5:04, Bjorn Helgaas wrote: On Wed, Apr 27, 2016 at 08:43:28PM +0800, Yongji Xie wrote: On ARM HW the capability of IRQ remapping is abstracted on MSI controller side. MSI_FLAG_IRQ_REMAPPING is used to advertise this [1]. To have a universal flag to test this capability

Re: [PATCH 1/5] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-05-24 Thread Yongji Xie
On 2016/5/25 4:55, Bjorn Helgaas wrote: On Wed, Apr 27, 2016 at 08:43:26PM +0800, Yongji Xie wrote: We introduce a new pci_bus_flags, PCI_BUS_FLAGS_MSI_REMAP which indicates all devices on the bus are protected by the hardware which supports IRQ remapping(intel naming). This changelog

Re: [PATCH 5/5] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-05-05 Thread Yongji Xie
On 2016/5/5 20:15, Tian, Kevin wrote: From: Yongji Xie [mailto:xyj...@linux.vnet.ibm.com] Sent: Thursday, May 05, 2016 7:43 PM Hi David and Kevin, On 2016/5/5 17:54, David Laight wrote: From: Tian, Kevin Sent: 05 May 2016 10:37 ... Acutually, we are not aimed at accessing MSI-X table

Re: [PATCH 5/5] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-05-05 Thread Yongji Xie
On 2016/5/5 17:36, Tian, Kevin wrote: From: Yongji Xie Sent: Tuesday, May 03, 2016 3:34 PM On 2016/5/3 14:22, Tian, Kevin wrote: From: Yongji Xie [mailto:xyj...@linux.vnet.ibm.com] Sent: Tuesday, May 03, 2016 2:08 PM On 2016/5/3 13:34, Tian, Kevin wrote: From: Yongji Xie Sent: Wednesday

Re: [PATCH 5/5] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-05-05 Thread Yongji Xie
Hi David and Kevin, On 2016/5/5 17:54, David Laight wrote: From: Tian, Kevin Sent: 05 May 2016 10:37 ... Acutually, we are not aimed at accessing MSI-X table from guest. So I think it's safe to passthrough MSI-X table if we can make sure guest kernel would not touch MSI-X table in normal

  1   2   >