From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42900 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAFMI-0000X7-6U for qemu-devel@nongnu.org; Mon, 25 Oct 2010 01:12:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAFMH-0004Xy-0N for qemu-devel@nongnu.org; Mon, 25 Oct 2010 01:12:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAFMG-0004Xo-OI for qemu-devel@nongnu.org; Mon, 25 Oct 2010 01:12:32 -0400 Date: Mon, 25 Oct 2010 07:05:51 +0200 From: "Michael S. Tsirkin" Message-ID: <20101025050551.GA2383@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH rfc] pcie: get rid of range checks List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: yamahata@valinux.co.jp, qemu-devel@nongnu.org config cycle operations should be idempotent, so there's no need to complicate code with range checks. Signed-off-by: Michael S. Tsirkin --- Untested. Pls comment. hw/pcie.c | 96 ++++++++++++++++++++++++++++++------------------------------- 1 files changed, 47 insertions(+), 49 deletions(-) diff --git a/hw/pcie.c b/hw/pcie.c index 53d1fce..c972337 100644 --- a/hw/pcie.c +++ b/hw/pcie.c @@ -302,59 +302,57 @@ void pcie_cap_slot_write_config(PCIDevice *dev, addr, val, len, sltctl_prev, sltctl, sltsta); /* SLTCTL */ - if (ranges_overlap(addr, len, pos + PCI_EXP_SLTCTL, 2)) { - PCIE_DEV_PRINTF(dev, "sltctl: 0x%02"PRIx16" -> 0x%02"PRIx16"\n", - sltctl_prev, sltctl); - if (pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTCTL, - PCI_EXP_SLTCTL_EIC)) { - sltsta ^= PCI_EXP_SLTSTA_EIS; /* toggle PCI_EXP_SLTSTA_EIS bit */ - pci_set_word(exp_cap + PCI_EXP_SLTSTA, sltsta); - PCIE_DEV_PRINTF(dev, "PCI_EXP_SLTCTL_EIC: " - "sltsta -> 0x%02"PRIx16"\n", - sltsta); - } - - /* - * The events control bits might be enabled or disabled, - * Check if the software notificastion condition is satisfied - * or disatisfied. - * - * 6.7.3.4 Software Notification of Hot-plug events - */ - if (pci_msi_enabled(dev)) { - bool msi_trigger = - (sltctl & PCI_EXP_SLTCTL_HPIE) && - ((sltctl_prev ^ sltctl) & sltctl & /* stlctl: 0 -> 1 */ - sltsta & PCI_EXP_HP_EV_SUPPORTED); - if (msi_trigger) { - pci_msi_notify(dev, pcie_cap_flags_get_vector(dev)); - } - } else { - int int_level = - (sltctl & PCI_EXP_SLTCTL_HPIE) && - (sltctl & sltsta & PCI_EXP_HP_EV_SUPPORTED); - qemu_set_irq(dev->irq[dev->exp.hpev_intx], int_level); - } + PCIE_DEV_PRINTF(dev, "sltctl: 0x%02"PRIx16" -> 0x%02"PRIx16"\n", + sltctl_prev, sltctl); + if (pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTCTL, + PCI_EXP_SLTCTL_EIC)) { + sltsta ^= PCI_EXP_SLTSTA_EIS; /* toggle PCI_EXP_SLTSTA_EIS bit */ + pci_set_word(exp_cap + PCI_EXP_SLTSTA, sltsta); + PCIE_DEV_PRINTF(dev, "PCI_EXP_SLTCTL_EIC: " + "sltsta -> 0x%02"PRIx16"\n", + sltsta); + } - if (!((sltctl_prev ^ sltctl) & PCI_EXP_SLTCTL_SUPPORTED)) { - PCIE_DEV_PRINTF(dev, - "sprious command completion slctl " - "0x%"PRIx16" -> 0x%"PRIx16"\n", - sltctl_prev, sltctl); + /* + * The events control bits might be enabled or disabled, + * Check if the software notificastion condition is satisfied + * or disatisfied. + * + * 6.7.3.4 Software Notification of Hot-plug events + */ + if (pci_msi_enabled(dev)) { + bool msi_trigger = + (sltctl & PCI_EXP_SLTCTL_HPIE) && + ((sltctl_prev ^ sltctl) & sltctl & /* stlctl: 0 -> 1 */ + sltsta & PCI_EXP_HP_EV_SUPPORTED); + if (msi_trigger) { + pci_msi_notify(dev, pcie_cap_flags_get_vector(dev)); } + } else { + int int_level = + (sltctl & PCI_EXP_SLTCTL_HPIE) && + (sltctl & sltsta & PCI_EXP_HP_EV_SUPPORTED); + qemu_set_irq(dev->irq[dev->exp.hpev_intx], int_level); + } - /* command completion. - * Real hardware might take a while to complete - * requested command because physical movement would be involved - * like locking the electromechanical lock. - * However in our case, command is completed instantaneously above, - * so send a command completion event right now. - * - * 6.7.3.2 Command Completed Events - */ - /* set command completed bit */ - pcie_cap_slot_event(dev, PCI_EXP_HP_EV_CCI); + if (!((sltctl_prev ^ sltctl) & PCI_EXP_SLTCTL_SUPPORTED)) { + PCIE_DEV_PRINTF(dev, + "sprious command completion slctl " + "0x%"PRIx16" -> 0x%"PRIx16"\n", + sltctl_prev, sltctl); } + + /* command completion. + * Real hardware might take a while to complete + * requested command because physical movement would be involved + * like locking the electromechanical lock. + * However in our case, command is completed instantaneously above, + * so send a command completion event right now. + * + * 6.7.3.2 Command Completed Events + */ + /* set command completed bit */ + pcie_cap_slot_event(dev, PCI_EXP_HP_EV_CCI); } void pcie_cap_slot_push_attention_button(PCIDevice *dev) -- 1.7.3-rc1