[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH rfc] pcie: get rid of range checks
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCH rfc] pcie: get rid of range checks |
Date: |
Mon, 25 Oct 2010 07:05:51 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
config cycle operations should be idempotent, so
there's no need to complicate code with range checks.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
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
- [Qemu-devel] [PATCH rfc] pcie: get rid of range checks,
Michael S. Tsirkin <=