diff mbox

[02/11] pci: clean up pci_bar_address()

Message ID 1260794906-30168-3-git-send-email-yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata Dec. 14, 2009, 12:48 p.m. UTC
make pci_bar_address independent of PCI_BAR_UNMAPPED value.
PCI_BAR_UNMAPPED could be arbitrary value which doesn't match
possible pci bar. So == PCI_BAR_UNMAPPED check is not good.
This patch cleans it up.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Comments

Michael S. Tsirkin Dec. 14, 2009, 1:36 p.m. UTC | #1
On Mon, Dec 14, 2009 at 09:48:17PM +0900, Isaku Yamahata wrote:
> make pci_bar_address independent of PCI_BAR_UNMAPPED value.
> PCI_BAR_UNMAPPED could be arbitrary value which doesn't match
> possible pci bar. So == PCI_BAR_UNMAPPED check is not good.
> This patch cleans it up.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

I would rather we removed this hack altogether.
I guess proper fix requires Avi's patch to do BAR mapping
from pci.c, and I think we should do just this.

There are no special values in bar
assignment, and guests are free to perform sizing any way they want.
Especially for 64 bit BARs, sizing for high bits is
done separately from low bits.

Also - I think this in fact changes logic.
On 64 bit qemu, we used to compare to 0xffffffff
and now we compare to 0xffffffffffffffff.

> ---
>  hw/pci.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index aed3a24..344d72b 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -857,8 +857,7 @@ static pcibus_t pci_bar_address(PCIDevice *d,
>      /* XXX: as we cannot support really dynamic
>         mappings, we handle specific values as invalid
>         mappings. */
> -    if (last_addr <= new_addr || new_addr == 0 ||
> -        last_addr == PCI_BAR_UNMAPPED) {
> +    if (last_addr <= new_addr || new_addr == 0 || last_addr == ~(pcibus_t)0) {
>          return PCI_BAR_UNMAPPED;
>      }
>  
> -- 
> 1.6.5.4
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index aed3a24..344d72b 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -857,8 +857,7 @@  static pcibus_t pci_bar_address(PCIDevice *d,
     /* XXX: as we cannot support really dynamic
        mappings, we handle specific values as invalid
        mappings. */
-    if (last_addr <= new_addr || new_addr == 0 ||
-        last_addr == PCI_BAR_UNMAPPED) {
+    if (last_addr <= new_addr || new_addr == 0 || last_addr == ~(pcibus_t)0) {
         return PCI_BAR_UNMAPPED;
     }