pcie: fixes for pci branch
cover pcie: fixes for pci branch
This patch series fixes isseus which introduced by 5704608988972359473ce609f9e4884808115b58 cd870502e228f8f028f93fb585ae3b208fcb46c7 4b78560503a802eae3663ace9f9cf080319e7265
Isaku Yamahata (6):
pcie: fix pcie_cap_slot_write_config().
pcie/slot: fix hotplug_event_notify().
pcie/slot: clean up of hotplug_event_notify(). pcie/slot: factor out the logic to update hotplug event status. pcie/slot: fix save/load
msix: remove range checks.
hw/ioh3420.c | 1 + hw/msix.c | 5 ----- hw/pcie.c | 46 ++++++++++++++++++++++++++++++---------------- hw/pcie.h | 1 + hw/xio3130_downstream.c | 1 + 5 files changed, 33 insertions(+), 21 deletions(-)
PATCH 1/6 pcie: fix pcie_cap_slot_write_config().
This patch fixes pcie_cap_slot_write_config() which is broken by 5704608988972359473ce609f9e4884808115b58
The command completion event should generated only when the command is issued (and the command is completed).
Quoted 5 lines
From 6.7.3.2
Software issues a command to a hot-plug capable Downstream Port by issuing a write transaction that targets any portion of the Port's Slot Control register. A single write to the Slot Control register is considered to be a single command
...
Quoted 2 lines
The Port must process the command normally even if the status field is already set when the command is issued.
--- hw/pcie.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-)
hw/pcie.c +14 -11
@@ -19,6 +19,7 @@*/ #include "sysemu.h" +#include "range.h" #include "pci_bridge.h" #include "pcie.h" #include "msix.h"
@@ -323,17 +324,19 @@ void pcie_cap_slot_write_config(PCIDevice *dev,hotplug_event_notify (dev); -/* 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 (ranges_overlap (addr, len, pos +PCI_EXP_SLTCTL ,2 )) { +/* 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)
Signature · 1 line
1.7.1.1
PATCH 2/6 pcie/slot: fix hotplug_event_notify().
In reply to Isaku YamahataThis patch fixes the miscondition to trigger slot event which is introduced by cd870502e228f8f028f93fb585ae3b208fcb46c7.
--- hw/pcie.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/pcie.c +1 -1
@@ -148,7 +148,7 @@ static void hotplug_event_notify(PCIDevice *dev)uint16_t sltsta =pci_get_word (exp_cap +PCI_EXP_SLTSTA ); dev->exp.hpev_notified = (sltctl &PCI_EXP_SLTCTL_HPIE ) && - (sltsta &PCI_EXP_HP_EV_SUPPORTED ); + (sltsta & sltctl &PCI_EXP_HP_EV_SUPPORTED );if (prev == dev->exp.hpev_notified) {return ;
Signature · 1 line
1.7.1.1
PATCH 3/6 pcie/slot: clean up of hotplug_event_notify().
In reply to Isaku Yamahataremove redundant return and blank line from hotplug_event_notify().
--- hw/pcie.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
hw/pcie.c +0 -2
@@ -164,9 +164,7 @@ static void hotplug_event_notify(PCIDevice *dev)qemu_set_irq (dev->irq[dev->exp.hpev_intx], dev->exp.hpev_notified); }else if (dev->exp.hpev_notified) {pci_msi_notify (dev,pcie_cap_flags_get_vector (dev)); -return ; } - }/*
Signature · 1 line
1.7.1.1
PATCH 4/6 pcie/slot: factor out the logic to update hotplug event status.
In reply to Isaku YamahataThis patch factors out the hot plug event logic.
--- hw/pcie.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
hw/pcie.c +8 -2
@@ -139,9 +139,8 @@ void pcie_cap_deverr_reset(PCIDevice *dev) PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE); } -static void hotplug_event_notify (PCIDevice *dev) +static void hotplug_event_update_event_status (PCIDevice *dev) { -bool prev = dev->exp.hpev_notified;uint32_t pos = dev->exp.exp_cap;uint8_t *exp_cap = dev->config + pos;uint16_t sltctl =pci_get_word (exp_cap +PCI_EXP_SLTCTL );
@@ -149,6 +148,13 @@ static void hotplug_event_notify(PCIDevice *dev) dev->exp.hpev_notified = (sltctl &PCI_EXP_SLTCTL_HPIE ) && (sltsta & sltctl &PCI_EXP_HP_EV_SUPPORTED ); +} + +static void hotplug_event_notify (PCIDevice *dev) +{ +bool prev = dev->exp.hpev_notified; + +hotplug_event_update_event_status (dev);if (prev == dev->exp.hpev_notified) {return ;
Signature · 1 line
1.7.1.1
PATCH 5/6 pcie/slot: fix save/load
In reply to Isaku YamahataThis patch fixes save/load of pcie slot which was broken by cd870502e228f8f028f93fb585ae3b208fcb46c7.
--- hw/ioh3420.c | 1 + hw/pcie.c | 7 +++++++ hw/pcie.h | 1 + hw/xio3130_downstream.c | 1 + 4 files changed, 10 insertions(+), 0 deletions(-)
hw/ioh3420.c +1 -0
@@ -139,6 +139,7 @@ static const VMStateDescription vmstate_ioh3420 = { .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, + .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) {VMSTATE_PCIE_DEVICE (port.br.dev, PCIESlot),/* TODO: AER */
hw/pcie.c +7 -0
@@ -343,6 +343,13 @@ void pcie_cap_slot_write_config(PCIDevice *dev, } } +int pcie_cap_slot_post_load (void *opaque,int version_id) +{ +PCIDevice *dev = opaque; +hotplug_event_update_event_status (dev); +return 0 ; +} +void pcie_cap_slot_push_attention_button (PCIDevice *dev) {pcie_cap_slot_event (dev,PCI_EXP_HP_EV_ABP );
hw/pcie.h +1 -0
@@ -95,6 +95,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);void pcie_cap_slot_reset (PCIDevice *dev);void pcie_cap_slot_write_config (PCIDevice *dev,uint32_t addr,uint32_t val,int len); +int pcie_cap_slot_post_load (void *opaque,int version_id);void pcie_cap_slot_push_attention_button (PCIDevice *dev);void pcie_cap_root_init (PCIDevice *dev);
hw/xio3130_downstream.c +1 -0
@@ -141,6 +141,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, + .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) {VMSTATE_PCIE_DEVICE (port.br.dev, PCIESlot),/* TODO: AER */
Signature · 1 line
1.7.1.1
PATCH 6/6 msix: remove range checks.
In reply to Isaku YamahataSame as 4b78560503a802eae3663ace9f9cf080319e7265
Quoted 2 lines
config write handlers should be idempotent.
So no need for range checks.
--- hw/msix.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
hw/msix.c +0 -5
@@ -157,14 +157,9 @@ static void msix_handle_mask_update(PCIDevice *dev, int vector)void msix_write_config (PCIDevice *dev,uint32_t addr,uint32_t val,int len) { -unsigned enable_pos = dev->msix_cap +MSIX_CONTROL_OFFSET ;int vector;int i; -if (!range_covers_byte (addr, len, enable_pos)) { -return ; - } -if (!msix_enabled (dev)) {return ; }
Signature · 1 line
1.7.1.1
[Qemu-devel] Re: [PATCH 6/6] msix: remove range checks.
Quoted 5 lines · Isaku Yamahata
Same as
4b78560503a802eae3663ace9f9cf080319e7265Quoted 2 lines
config write handlers should be idempotent.
So no need for range checks.Signed-off-by Isaku Yamahata <[email protected]>
Well I changed my mind on 4b78560503a802eae3663ace9f9cf080319e7265 :) As long as the check is simple, it does not hurt.
Quoted 25 lines
--- hw/msix.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)hw/msix.c +0
-5@@ -157,14 +157,9 @@ static void msix_handle_mask_update(PCIDevice *dev, int vector)void msix_write_config (PCIDevice *dev,uint32_t addr,uint32_t val,int len) { -unsigned enable_pos = dev->msix_cap +MSIX_CONTROL_OFFSET ;int vector;int i; -if (!range_covers_byte (addr, len, enable_pos)) { -return ; - } -if (!msix_enabled (dev)) {return ; }Signature · 1 line
1.7.1.1
Quoted 4 lines · Isaku Yamahata
This patch series fixes isseus which introduced by
5704608988972359473ce609f9e4884808115b58cd870502e228f8f028f93fb585ae3b208fcb46c74b78560503a802eae3663ace9f9cf080319e7265
OK, I applied this, except I basically backed out range check changes. Pls take a look at the branch, and test if possible -
if OK with you I think we can merge this part.
Quoted 14 lines
Isaku Yamahata (6):
pcie: fixpcie_cap_slot_write_config().
pcie/slot: fixhotplug_event_notify().
pcie/slot: clean up ofhotplug_event_notify(). pcie/slot: factor out the logic to update hotplug event status. pcie/slot: fix save/load
msix: remove range checks.hw/ioh3420.c | 1 + hw/msix.c | 5 ----- hw/pcie.c | 46 ++++++++++++++++++++++++++++++---------------- hw/pcie.h | 1 + hw/xio3130_downstream.c | 1 + 5 files changed, 33 insertions(+), 21 deletions(-)
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · Isaku Yamahata
This patch series fixes isseus which introduced by
5704608988972359473ce609f9e4884808115b58cd870502e228f8f028f93fb585ae3b208fcb46c74b78560503a802eae3663ace9f9cf080319e7265OK, I applied this, except I basically backed out range check changes. Pls take a look at the branch, and test if possible -
if OK with you I think we can merge this part.
I took a look at it. It looks good.
Signature · 1 line
yamahata