* [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment
@ 2016-11-25 10:29 Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 1/2] pci: Remove redundant alignment of BAR size Alexander Gordeev
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Gordeev @ 2016-11-25 10:29 UTC (permalink / raw)
To: kvm; +Cc: Alexander Gordeev, Thomas Huth, Andrew Jones
Andrew Jones reported 'edu' device fails to operate on addresses
assigned by PCI memory allocation. This series should fix the issue.
Cc: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Alexander Gordeev (2):
pci: Remove redundant alignment of BAR size
pci: Align PCI addresses on BAR size boundary
lib/pci-host-generic.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [kvm-unit-tests PATCH 1/2] pci: Remove redundant alignment of BAR size
2016-11-25 10:29 [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Alexander Gordeev
@ 2016-11-25 10:29 ` Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 2/2] pci: Align PCI addresses on BAR size boundary Alexander Gordeev
2016-11-25 15:06 ` [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Andrew Jones
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Gordeev @ 2016-11-25 10:29 UTC (permalink / raw)
To: kvm; +Cc: Alexander Gordeev, Thomas Huth, Andrew Jones
Size of a BAR is naturally aligned so there is no need
to align it explicitly.
Cc: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
lib/pci-host-generic.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c
index 6ac0f15faa90..df66bd4741e6 100644
--- a/lib/pci-host-generic.c
+++ b/lib/pci-host-generic.c
@@ -169,7 +169,7 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
{
struct pci_host_bridge *host = pci_host_bridge;
struct pci_addr_space *as = &host->addr_space[0];
- u32 mask, bar;
+ u32 bar;
u64 size;
int type, i;
@@ -199,10 +199,7 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
return false;
}
- mask = pci_bar_mask(bar);
- size = ALIGN(size, ~mask + 1);
assert(as->allocated + size <= as->size);
-
*addr = as->pci_start + as->allocated;
as->allocated += size;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [kvm-unit-tests PATCH 2/2] pci: Align PCI addresses on BAR size boundary
2016-11-25 10:29 [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 1/2] pci: Remove redundant alignment of BAR size Alexander Gordeev
@ 2016-11-25 10:29 ` Alexander Gordeev
2016-11-25 15:06 ` [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Andrew Jones
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Gordeev @ 2016-11-25 10:29 UTC (permalink / raw)
To: kvm; +Cc: Alexander Gordeev, Thomas Huth, Andrew Jones
PCI I/O and Memory must be allocated to a device in a naturally
aligned way. For example, if a device asks for 0xB0 of PCI I/O
space then it must be aligned on an address that is a multiple
of 0xB0 (http://www.tldp.org/LDP/tlk/dd/pci.html)
Cc: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Reported-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
lib/pci-host-generic.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c
index df66bd4741e6..d57b47ee4c53 100644
--- a/lib/pci-host-generic.c
+++ b/lib/pci-host-generic.c
@@ -170,7 +170,7 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
struct pci_host_bridge *host = pci_host_bridge;
struct pci_addr_space *as = &host->addr_space[0];
u32 bar;
- u64 size;
+ u64 size, pci_addr;
int type, i;
*addr = ~0;
@@ -199,8 +199,10 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
return false;
}
+ pci_addr = ALIGN(as->pci_start + as->allocated, size);
+ size += pci_addr - (as->pci_start + as->allocated);
assert(as->allocated + size <= as->size);
- *addr = as->pci_start + as->allocated;
+ *addr = pci_addr;
as->allocated += size;
return true;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment
2016-11-25 10:29 [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 1/2] pci: Remove redundant alignment of BAR size Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 2/2] pci: Align PCI addresses on BAR size boundary Alexander Gordeev
@ 2016-11-25 15:06 ` Andrew Jones
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Jones @ 2016-11-25 15:06 UTC (permalink / raw)
To: Alexander Gordeev; +Cc: kvm, Thomas Huth
On Fri, Nov 25, 2016 at 11:29:42AM +0100, Alexander Gordeev wrote:
> Andrew Jones reported 'edu' device fails to operate on addresses
> assigned by PCI memory allocation. This series should fix the issue.
>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Andrew Jones <drjones@redhat.com>
>
> Alexander Gordeev (2):
> pci: Remove redundant alignment of BAR size
> pci: Align PCI addresses on BAR size boundary
>
> lib/pci-host-generic.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
Thanks, applied to https://github.com/rhdrjones/kvm-unit-tests arm/next
which will be the branch I'll start using for PULL requests.
drew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-25 15:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25 10:29 [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 1/2] pci: Remove redundant alignment of BAR size Alexander Gordeev
2016-11-25 10:29 ` [kvm-unit-tests PATCH 2/2] pci: Align PCI addresses on BAR size boundary Alexander Gordeev
2016-11-25 15:06 ` [kvm-unit-tests PATCH 0/2] pci: Fix PCI BAR alignment Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox