From 7b2e46a8e4339ab9e7dbe0e8f7dbd9a38c3adeb9 Mon Sep 17 00:00:00 2001
From: Alex Williamson <alex.williamson@redhat.com>
Date: Tue, 24 Jan 2012 15:45:23 +0100
Subject: [PATCH 2/5] pci-assign: Fix PCIe lnkcap

RH-Author: Alex Williamson <alex.williamson@redhat.com>
Message-id: <20120124154522.27090.46026.stgit@bling.home>
Patchwork-id: 36787
O-Subject: [PATCH 2/4] pci-assign: Fix PCIe lnkcap
Bugzilla: 754565
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=754565
Upstream commit: 21f5a19a10c8f6a10d79a415bf640de85acede78

Another Coverity found issue, lnkcap is a 32bit register and
we're masking bits 16 & 17.  Fix to uint32_t.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---

 hw/device-assignment.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/device-assignment.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 388cd2f..7c0740c 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1422,8 +1422,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
 
     if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0))) {
         uint8_t version, size = 0;
-        uint16_t type, devctl, lnkcap, lnksta;
-        uint32_t devcap;
+        uint16_t type, devctl, lnksta;
+        uint32_t devcap, lnkcap;
 
         version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
         version &= PCI_EXP_FLAGS_VERS;
@@ -1506,11 +1506,11 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
         pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0);
 
         /* Link capabilities, expose links and latencues, clear reporting */
-        lnkcap = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKCAP);
+        lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP);
         lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |
                    PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |
                    PCI_EXP_LNKCAP_L1EL);
-        pci_set_word(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);
+        pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);
         pci_set_word(pci_dev->wmask + pos + PCI_EXP_LNKCAP,
                      PCI_EXP_LNKCTL_ASPMC | PCI_EXP_LNKCTL_RCB |
                      PCI_EXP_LNKCTL_CCC | PCI_EXP_LNKCTL_ES |
-- 
1.7.7.5

