qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com,
	qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] Re: [PATCH v9 2/8] pci: fix accesses to pci status register
Date: Tue, 16 Nov 2010 12:52:31 +0200	[thread overview]
Message-ID: <20101116105231.GC19668@redhat.com> (raw)
In-Reply-To: <bef1f7bebe5309f5eea5f6cddb51041c0fdaa35c.1289895735.git.yamahata@valinux.co.jp>

On Tue, Nov 16, 2010 at 05:26:06PM +0900, Isaku Yamahata wrote:
> pci status register is 16 bit, not 8 bit.
> So use helper function to manipulate status register.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

At least the subject is wrong: the relevant bit is in the low byte. So
the code is correct as written on BE machines.

> ---
>  hw/pci.c |   21 +++++++++++++--------
>  1 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 2fc8ab1..52fe655 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -127,9 +127,11 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
>  static void pci_update_irq_status(PCIDevice *dev)
>  {
>      if (dev->irq_state) {
> -        dev->config[PCI_STATUS] |= PCI_STATUS_INTERRUPT;
> +        pci_word_test_and_set_mask(dev->config + PCI_STATUS,
> +                                   PCI_STATUS_INTERRUPT);
>      } else {
> -        dev->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
> +        pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
> +                                     PCI_STATUS_INTERRUPT);
>      }
>  }
>  
> @@ -404,7 +406,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)
>       * in irq_state which we are saving.
>       * This makes us compatible with old devices
>       * which never set or clear this bit. */
> -    s->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
> +    pci_word_test_and_clear_mask(s->config + PCI_STATUS, PCI_STATUS_INTERRUPT);
>      vmstate_save_state(f, pci_get_vmstate(s), s);
>      /* Restore the interrupt status bit. */
>      pci_update_irq_status(s);
> @@ -530,7 +532,7 @@ static void pci_init_cmask(PCIDevice *dev)
>  {
>      pci_set_word(dev->cmask + PCI_VENDOR_ID, 0xffff);
>      pci_set_word(dev->cmask + PCI_DEVICE_ID, 0xffff);
> -    dev->cmask[PCI_STATUS] = PCI_STATUS_CAP_LIST;
> +    pci_set_word(dev->cmask + PCI_STATUS, PCI_STATUS_CAP_LIST);
>      dev->cmask[PCI_REVISION_ID] = 0xff;
>      dev->cmask[PCI_CLASS_PROG] = 0xff;
>      pci_set_word(dev->cmask + PCI_CLASS_DEVICE, 0xffff);
> @@ -1697,8 +1699,9 @@ static uint8_t pci_find_capability_list(PCIDevice *pdev, uint8_t cap_id,
>  {
>      uint8_t next, prev;
>  
> -    if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST))
> +    if (!(pci_get_word(pdev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST)) {
>          return 0;
> +    }
>  
>      for (prev = PCI_CAPABILITY_LIST; (next = pdev->config[prev]);
>           prev = next + PCI_CAP_LIST_NEXT)
> @@ -1804,7 +1807,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>      config[PCI_CAP_LIST_ID] = cap_id;
>      config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST];
>      pdev->config[PCI_CAPABILITY_LIST] = offset;
> -    pdev->config[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
> +    pci_word_test_and_set_mask(pdev->config + PCI_STATUS, PCI_STATUS_CAP_LIST);
>      memset(pdev->used + offset, 0xFF, size);
>      /* Make capability read-only by default */
>      memset(pdev->wmask + offset, 0, size);
> @@ -1827,8 +1830,10 @@ void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
>      memset(pdev->cmask + offset, 0, size);
>      memset(pdev->used + offset, 0, size);
>  
> -    if (!pdev->config[PCI_CAPABILITY_LIST])
> -        pdev->config[PCI_STATUS] &= ~PCI_STATUS_CAP_LIST;
> +    if (!pdev->config[PCI_CAPABILITY_LIST]) {
> +        pci_word_test_and_clear_mask(pdev->config + PCI_STATUS,
> +                                     PCI_STATUS_CAP_LIST);
> +    }
>  }
>  
>  /* Reserve space for capability at a known offset (to call after load). */
> -- 
> 1.7.1.1

  reply	other threads:[~2010-11-16 10:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16  8:26 [Qemu-devel] [PATCH v9 0/8] pcie port switch emulators Isaku Yamahata
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 1/8] pci: revise pci command register initialization Isaku Yamahata
2010-11-16 10:50   ` [Qemu-devel] " Michael S. Tsirkin
2010-11-17  2:03     ` Isaku Yamahata
2010-11-17 12:02       ` Michael S. Tsirkin
2010-11-18  2:08         ` Isaku Yamahata
2010-11-18  6:42           ` Michael S. Tsirkin
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 2/8] pci: fix accesses to pci status register Isaku Yamahata
2010-11-16 10:52   ` Michael S. Tsirkin [this message]
2010-11-17  4:17     ` [Qemu-devel] " Isaku Yamahata
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 3/8] pci: clean up of " Isaku Yamahata
2010-11-16 14:01   ` [Qemu-devel] " Michael S. Tsirkin
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 4/8] pcie_regs.h: more constants Isaku Yamahata
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 5/8] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-11-17 14:06   ` [Qemu-devel] [PATCH 0/2] " Michael S. Tsirkin
2010-11-17 14:06     ` [Qemu-devel] [PATCH 1/2] pcie_aer: get rid of recursion Michael S. Tsirkin
2010-11-17 14:06     ` [Qemu-devel] [PATCH 2/2] pcie_aer: complete unwinding recursion Michael S. Tsirkin
2010-11-18  8:11     ` [Qemu-devel] Re: [PATCH 0/2] Re: [PATCH v9 5/8] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-11-18  8:52       ` Michael S. Tsirkin
2010-11-19  9:42     ` Isaku Yamahata
2010-11-19 12:03       ` Michael S. Tsirkin
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 6/8] ioh3420: support aer Isaku Yamahata
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 7/8] x3130/upstream: " Isaku Yamahata
2010-11-16  8:26 ` [Qemu-devel] [PATCH v9 8/8] x3130/downstream: " Isaku Yamahata
     [not found] ` <1289930315.27724.18.camel@etmartin-lnx>
2010-11-16 18:57   ` [Qemu-devel] " Etienne Martineau
2010-11-17  4:07     ` Isaku Yamahata
2010-11-17  5:31       ` Etienne Martineau
2010-11-18  2:19         ` Isaku Yamahata
2010-11-17 14:38 ` [Qemu-devel] Re: [PATCH v9 0/8] pcie port switch emulators Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101116105231.GC19668@redhat.com \
    --to=mst@redhat.com \
    --cc=adnan@khaleel.us \
    --cc=etmartin@cisco.com \
    --cc=qemu-devel@nongnu.org \
    --cc=skandasa@cisco.com \
    --cc=wexu2@cisco.com \
    --cc=yamahata@valinux.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).