pci: allow PCI devices to fix address space
RFC PATCH 1/1 pci: allow PCI devices to fix address space
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.
---
Hello Michael,
Could you please take a look at this? I'm out of my field here.
The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).
The second part makes existing code conditional on that value.
Regards,
Andreas
hw/pci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
hw/pci.c +14 -8
@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {
@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ -pci_word_test_and_clear_mask (dev->config +PCI_COMMAND , -pci_get_word (dev->wmask +PCI_COMMAND ) | -pci_get_word (dev->w1cmask +PCI_COMMAND )); + cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd);pci_word_test_and_clear_mask (dev->config +PCI_STATUS ,pci_get_word (dev->wmask +PCI_STATUS ) |pci_get_word (dev->w1cmask +PCI_STATUS ));
@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ; } -if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { -pci_set_quad (dev->config +pci_bar (dev, r), region->type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region->type); +if ((region->type ==PCI_BASE_ADDRESS_SPACE_IO && !(cmd &PCI_COMMAND_MEMORY )) || + (region->type ==PCI_BASE_ADDRESS_SPACE_MEMORY && !(cmd &PCI_COMMAND_IO ))) { +/* Reset region address, as it it is not read-only */ +if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +pci_set_quad (dev->config +pci_bar (dev, r), region->type); + }else { +pci_set_long (dev->config +pci_bar (dev, r), region->type); + } } }pci_update_mappings (dev);
Signature · 1 line
1.7.3.4
Quoted 8 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>
Quoted 8 lines
---
Hello Michael,
Could you please take a look at this? I'm out of my field here.
The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.
thanks,
Quoted 58 lines
Regards,
Andreashw/pci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)hw/pci.c +14
-8@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ -pci_word_test_and_clear_mask (dev->config +PCI_COMMAND , -pci_get_word (dev->wmask +PCI_COMMAND ) | -pci_get_word (dev->w1cmask +PCI_COMMAND )); + cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd);pci_word_test_and_clear_mask (dev->config +PCI_STATUS ,pci_get_word (dev->wmask +PCI_STATUS ) |pci_get_word (dev->w1cmask +PCI_STATUS ));@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ; } -if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { -pci_set_quad (dev->config +pci_bar (dev, r), region->type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region->type); +if ((region->type ==PCI_BASE_ADDRESS_SPACE_IO && !(cmd &PCI_COMMAND_MEMORY )) || + (region->type ==PCI_BASE_ADDRESS_SPACE_MEMORY && !(cmd &PCI_COMMAND_IO ))) { +/* Reset region address, as it it is not read-only */ +if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +pci_set_quad (dev->config +pci_bar (dev, r), region->type); + }else { +pci_set_long (dev->config +pci_bar (dev, r), region->type); + } } }pci_update_mappings (dev);Signature · 1 line
1.7.3.4
Signature · 1 line
yamahata
Quoted 25 lines · Isaku Yamahata
Quoted 8 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>Quoted 8 lines
---
Hello Michael,
Could you please take a look at this? I'm out of my field here.
The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.
Quoted 3 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Yes I'd like to know that too:
Quoted 46 lines
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.thanks,
Quoted 37 lines
Regards,
Andreashw/pci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)hw/pci.c +5
-3@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ -pci_word_test_and_clear_mask (dev->config +PCI_COMMAND , -pci_get_word (dev->wmask +PCI_COMMAND ) | -pci_get_word (dev->w1cmask +PCI_COMMAND )); + cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd);pci_word_test_and_clear_mask (dev->config +PCI_STATUS ,pci_get_word (dev->wmask +PCI_STATUS ) |pci_get_word (dev->w1cmask +PCI_STATUS ));@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ; }
Quoted 7 lines
hw/pci.c static void pci_device_reset(PCIDevice *dev) · line 169
Quoted 7 lines
hw/pci.c +2
-5-if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { -pci_set_quad (dev->config +pci_bar (dev, r), region->type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region->type); +if ((region->type ==PCI_BASE_ADDRESS_SPACE_IO && !(cmd &PCI_COMMAND_MEMORY )) || + (region->type ==PCI_BASE_ADDRESS_SPACE_MEMORY && !(cmd &PCI_COMMAND_IO ))) {
You want to make memory/io bits in the command register read-only and hardwired to 1? This seems out of spec, no?
Quoted 17 lines
Quoted 14 lines
hw/pci.c +7
-0+/* Reset region address, as it it is not read-only */ +if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +pci_set_quad (dev->config +pci_bar (dev, r), region->type); + }else { +pci_set_long (dev->config +pci_bar (dev, r), region->type); + } } }pci_update_mappings (dev);Signature · 1 line
1.7.3.4Signature · 1 line
yamahata
Quoted 31 lines · Isaku Yamahata
Quoted 8 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>Quoted 9 lines
---
Hello Michael,
Could you please take a look at this? I'm out of my field here.
The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.Quoted 2 lines
The second part makes existing code conditional on that value.
Quoted 11 lines
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.thanks,
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address. In that case, the device keeps PCI_COMMAND_MEMORY and/or PCI_COMMAND_IO flags as read-only.
Hervé
Quoted 61 lines
Quoted 59 lines
Regards,
Andreashw/pci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)hw/pci.c +14
-8@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ -pci_word_test_and_clear_mask (dev->config +PCI_COMMAND , -pci_get_word (dev->wmask +PCI_COMMAND ) | -pci_get_word (dev->w1cmask +PCI_COMMAND )); + cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd);pci_word_test_and_clear_mask (dev->config +PCI_STATUS ,pci_get_word (dev->wmask +PCI_STATUS ) |pci_get_word (dev->w1cmask +PCI_STATUS ));@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ; } -if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { -pci_set_quad (dev->config +pci_bar (dev, r), region->type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region->type); +if ((region->type ==PCI_BASE_ADDRESS_SPACE_IO && !(cmd &PCI_COMMAND_MEMORY )) || + (region->type ==PCI_BASE_ADDRESS_SPACE_MEMORY && !(cmd &PCI_COMMAND_IO ))) { +/* Reset region address, as it it is not read-only */ +if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +pci_set_quad (dev->config +pci_bar (dev, r), region->type); + }else { +pci_set_long (dev->config +pci_bar (dev, r), region->type); + } } }pci_update_mappings (dev);Signature · 1 line
1.7.3.4
Quoted 16 lines · Hervé Poussineau
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).
Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.
What about this first chunk? Is it necessary.
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.thanks,
Quoted 7 lines
As you have seen, the intend here is to be able to keep BARs over resets. It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
Also I would like the above text (maybe a bit shortened) to replace the comment:
/* Reset region address, as it it is not read-only */
the general idea is to document the reason the code is what it is, not restate what it does.
Something similar should also go into the commit message I think.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Regards,
Andreashw/pci.c| 22 ++++++++++++++--------1 files changed, 14 insertions(+), 8 deletions(-)hw/pci.c +5
-3@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ -pci_word_test_and_clear_mask (dev->config +PCI_COMMAND , -pci_get_word (dev->wmask +PCI_COMMAND ) | -pci_get_word (dev->w1cmask +PCI_COMMAND )); + cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd);pci_word_test_and_clear_mask (dev->config +PCI_STATUS ,pci_get_word (dev->wmask +PCI_STATUS ) |pci_get_word (dev->w1cmask +PCI_STATUS ));@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ;
Quoted 8 lines
Quoted 8 lines
hw/pci.c static void pci_device_reset(PCIDevice *dev) · line 169
Quoted 8 lines
hw/pci.c +2
-5} -if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { -pci_set_quad (dev->config +pci_bar (dev, r), region->type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region->type); +if ((region->type ==PCI_BASE_ADDRESS_SPACE_IO && !(cmd &PCI_COMMAND_MEMORY )) || + (region->type ==PCI_BASE_ADDRESS_SPACE_MEMORY && !(cmd &PCI_COMMAND_IO ))) {
These lines are too long.
Quoted 1 line
Quoted 1 line
hw/pci.c static void pci_device_reset(PCIDevice *dev) · line 170
Quoted 1 line
hw/pci.c +1
-0+/* Reset region address, as it it is not read-only */
Checking wmask would be more straight-forward?
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
hw/pci.c +6
-0+if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +pci_set_quad (dev->config +pci_bar (dev, r), region->type); + }else { +pci_set_long (dev->config +pci_bar (dev, r), region->type); + } } }pci_update_mappings (dev);Signature · 1 line
1.7.3.4
Hervé,
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 44 lines · Hervé Poussineau
Quoted 16 lines
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 18 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.thanks,
As you have seen, the intend here is to be able to keep BARs over resets. It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.
Quoted 5 lines
Quoted 1 line
Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?
Thanks,
Andreas
Quoted 83 lines
Also I would like the above text (maybe a bit shortened) to replace the comment:
/* Reset region address, as it it is not read-only */the general idea is to document the reason the code is what it is, not restate what it does.
Something similar should also go into the commit message I think.
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Regards,
Andreashw/pci.c| 22 ++++++++++++++--------1 files changed, 14 insertions(+), 8 deletions(-)hw/pci.c +1
-0@@ -140,6 +140,7 @@ static void pci_update_irq_status(PCIDevice *dev)static void pci_device_reset (PCIDevice *dev) {int r; +uint16_t cmd;/* TODO: call the below unconditionally once all pci devices * are qdevified */ if (dev->qdev.info) {hw/pci.c +0
-2@@ -149,9 +150,10 @@ static void pci_device_reset(PCIDevice *dev) dev->irq_state =0 ;pci_update_irq_status (dev);/* Clear all writeable bits */ - pci_word_test_and_clear_mask(dev->config + PCI_COMMAND, - pci_get_word(dev->wmask +
PCI_COMMAND) |
- pci_get_word(dev->w1cmask +PCI_COMMAND));hw/pci.c +4
-0+ cmd =pci_get_word (dev->config +PCI_COMMAND ); + cmd &= ~(pci_get_word (dev->wmask +PCI_COMMAND ) | +pci_get_word (dev->w1cmask +PCI_COMMAND )); +pci_set_word (dev->config +PCI_COMMAND , cmd); pci_word_test_and_clear_mask(dev->config + PCI_STATUS, pci_get_word(dev->wmask +
PCI_STATUS) |pci_get_word(dev->w1cmask +
PCI_STATUS));hw/pci.c +0
-3@@ -163,11 +165,15 @@ static void pci_device_reset(PCIDevice *dev)continue ; } -if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && - region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { - pci_set_quad(dev->config + pci_bar(dev, r), region-Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
hw/pci.c +1
-2>type); - }else { -pci_set_long (dev->config +pci_bar (dev, r), region- >type); + if ((region->type == PCI_BASE_ADDRESS_SPACE_IO && !(cmd&
PCI_COMMAND_MEMORY)) ||
+ (region->type==PCI_BASE_ADDRESS_SPACE_MEMORY&& !
(cmd &PCI_COMMAND_IO))) {These lines are too long.
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ /* Reset region address, as it it is not read-only */
Checking wmask would be more straight-forward?
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
hw/pci.c +3
-0+if (!(region->type &PCI_BASE_ADDRESS_SPACE_IO ) && + region->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { + pci_set_quad(dev->config + pci_bar(dev, r),
region->type);hw/pci.c +2
-0+ }else { + pci_set_long(dev->config + pci_bar(dev, r),
region->type);
+ }}}
pci_update_mappings(dev);Signature · 1 line
1.7.3.4
Andreas,
Quoted 55 lines · Andreas Färber
Hervé,
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 44 lines · Hervé Poussineau
Quoted 16 lines
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 18 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.thanks,
As you have seen, the intend here is to be able to keep BARs over resets. It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 5 lines
Quoted 1 line
Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
Quoted 8 lines
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Thanks,
Andreas
Try do do info qtree with and without this patch, and check the i82378 device With this patch, I have:
bar 0: mem at 0x80000000 [0x8000ffff]
bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe]
bar 1: mem at 0xffffffffffffffff [0xfffffe]I think that firmware doesn't initialize BARs for this device. However, I don't know what can be the consequences of not doing it.
Regards,
Hervé
Am 12.06.2011 um 14:40 schrieb Hervé Poussineau:
Quoted 53 lines
Quoted 43 lines · Andreas Färber
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 41 lines · Hervé Poussineau
Quoted 16 lines
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 14 lines
Quoted 9 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.As you have seen, the intend here is to be able to keep BARs over resets. It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 8 lines
Quoted 3 lines
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?
Quoted 8 lines
Try do do info qtree with and without this patch, and check the i82378 device With this patch, I have:
bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]
That I can confirm.
Quoted 1 line
I think that firmware doesn't initialize BARs for this device. However, I don't know what can be the consequences of not doing it.
Re-testing this after a rebase, I don't get any graphics at all without this patch. Must've done something wrong earlier...
So, how to tell if the BARs are "still writable"? (mst's question)
Andreas
Quoted 65 lines · Andreas Färber
Am 12.06.2011 um 14:40 schrieb Hervé Poussineau:
Quoted 53 lines
Quoted 43 lines · Andreas Färber
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 41 lines · Hervé Poussineau
Quoted 16 lines
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 14 lines
Quoted 9 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers after reset, the current code assumes that almost all the pci devices clear those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter. You, however, seem to want to keep BARs over resets.As you have seen, the intend here is to be able to keep BARs over resets. It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 8 lines
Quoted 3 lines
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Quoted 8 lines
Try do do info qtree with and without this patch, and check the i82378 device With this patch, I have:
bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]
Quoted 8 lines
That I can confirm.
Quoted 1 line
I think that firmware doesn't initialize BARs for this device. However, I don't know what can be the consequences of not doing it.
Re-testing this after a rebase, I don't get any graphics at all without this patch. Must've done something wrong earlier...
So, how to tell if the BARs are "still writable"? (mst's question)
I don't know if the BARs are hardwired to some value, or if they have default values. I've no real information on this aspect, so you might take a look at the datasheet:
http://www.datasheetcatalog.org/datasheets2/10/1064845_1.pdf
Regarding PCI command register, it is explicitly said page 33 that "Bus Master Enable", "Memory Space Enable" and "I/O Space Enable" are hardwired to 1.
Regards,
Hervé
Quoted 85 lines · Hervé Poussineau
Quoted 84 lines · Andreas Färber
Am 12.06.2011 um 14:40 schrieb Hervé Poussineau:
Quoted 65 lines
Quoted 53 lines · Andreas Färber
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 46 lines · Hervé Poussineau
Quoted 17 lines
Quoted 16 lines · Isaku Yamahata
Quoted 14 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask),
whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers
after reset, the current code assumes that almost all the pci devices clear
those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter.
You, however, seem to want to keep BARs over resets.Quoted 6 lines
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 4 lines
Aha. Are the BARs still writeable? If not maybe that's the right thing
to check? If yes maybe the device simply should have a reset handler to rewrite them?Quoted 7 lines
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Try do do info qtree with and without this patch, and check the i82378 device
With this patch, I have:Quoted 6 lines
bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]That I can confirm.
Quoted 3 lines
I think that firmware doesn't initialize BARs for this device. However, I don't know what can be the consequences of not doing it.
Re-testing this after a rebase, I don't get any graphics at all without this patch. Must've done something wrong earlier...
Quoted 7 lines
Quoted 2 lines
So, how to tell if the BARs are "still writable"? (mst's question)
I don't know if the BARs are hardwired to some value, or if they have default values.
I've no real information on this aspect, so you might take a look at the datasheet:
http://www.datasheetcatalog.org/datasheets2/10/1064845_1.pdf
This doesn't say anything about BARs.
Quoted 7 lines
Regarding PCI command register, it is explicitly said page 33 that "Bus Master Enable", "Memory Space Enable" and "I/O Space Enable" are hardwired to 1.
Regards,
Hervé
Right. It would seem that the only way this can be safe is if the device has no BARs (only legacy ranges) or if the BARs are initializaed to a safe value somehow.
Signature · 1 line
MST
Quoted 80 lines · Andreas Färber
Am 12.06.2011 um 14:40 schrieb Hervé Poussineau:
Quoted 65 lines
Quoted 53 lines · Andreas Färber
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 46 lines · Hervé Poussineau
Quoted 17 lines
Quoted 16 lines · Isaku Yamahata
Quoted 14 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask),
whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers
after reset, the current code assumes that almost all the pci devices clear
those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter.
You, however, seem to want to keep BARs over resets.Quoted 6 lines
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 4 lines
Aha. Are the BARs still writeable? If not maybe that's the right thing
to check? If yes maybe the device simply should have a reset handler to rewrite them?Quoted 7 lines
I haven't noticed a follow-up patch of yours.
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Try do do info qtree with and without this patch, and check the i82378 device
With this patch, I have:Quoted 6 lines
bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]That I can confirm.
Quoted 3 lines
I think that firmware doesn't initialize BARs for this device. However, I don't know what can be the consequences of not doing it.
Quoted 6 lines
Re-testing this after a rebase, I don't get any graphics at all without this patch. Must've done something wrong earlier...
So, how to tell if the BARs are "still writable"? (mst's question)
Andreas
I'm just asking what exactly happens with the patch?
- After first boot, firmware writes something into BARs, then triggers a reset and then avoids writing there?
- After first boot, firmware writes something into BARs, but does not enable memory/io/bus master?
- Something else?
Signature · 1 line
MST
Quoted 77 lines · Hervé Poussineau
Andreas,
Quoted 61 lines · Andreas Färber
Hervé,
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 48 lines · Hervé Poussineau
Quoted 16 lines
Quoted 15 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 22 lines
Quoted 12 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers
after reset, the current code assumes that almost all the pci devices clear
those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter.
You, however, seem to want to keep BARs over resets.Quoted 3 lines
thanks,
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 5 lines
Quoted 1 line
Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Quoted 9 lines
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Thanks,
AndreasTry do do info qtree with and without this patch, and check the i82378 device
With this patch, I have:
Quoted 8 lines
bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]I think that firmware doesn't initialize BARs for this device.
Interesting. So what set the BARs to these values (0x80000000 and 0xc0000000)?
Quoted 5 lines
However, I don't know what can be the consequences of not doing it.
Regards,
Hervé
Quoted 92 lines · Michael S. Tsirkin
Quoted 90 lines · Hervé Poussineau
Andreas,
Quoted 66 lines · Andreas Färber
Hervé,
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 53 lines · Hervé Poussineau
Quoted 19 lines
Quoted 16 lines · Isaku Yamahata
Quoted 14 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 7 lines
Quoted 7 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 23 lines
Quoted 12 lines
Quoted 2 lines
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers
after reset, the current code assumes that almost all the pci devices clear
those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter.
You, however, seem to want to keep BARs over resets.Quoted 4 lines
thanks,
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 6 lines
Quoted 2 lines
Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Quoted 10 lines
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Thanks,
AndreasTry do do info qtree with and without this patch, and check the i82378 device
With this patch, I have:bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]
Quoted 5 lines
Quoted 2 lines
I think that firmware doesn't initialize BARs for this device.
Interesting. So what set the BARs to these values (
0x80000000and0xc0000000)
Currently, those default values are stored in qdev properties of device, and device fills in BARs addresses in its init function
+static int pci_i82378_init(PCIDevice *pci_dev)
...
+ /* Make addresses read only */
+ pci_set_word(pci_dev->wmask + PCI_COMMAND,
+ PCI_COMMAND_SPECIAL);
+ pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 0 * 4, pci->isa_io_base);
+ pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 1 * 4, pci->isa_mem_base);
Regards
Hervé
Quoted 94 lines · Hervé Poussineau
Quoted 74 lines · Michael S. Tsirkin
Quoted 73 lines · Hervé Poussineau
Andreas,
Quoted 55 lines · Andreas Färber
Hervé,
Am 22.12.2010 um 07:49 schrieb Michael S. Tsirkin:
Quoted 45 lines · Hervé Poussineau
Quoted 15 lines
Quoted 14 lines · Isaku Yamahata
Quoted 13 lines · Andreas Färber
From: Hervé Poussineau <[email protected]>
v1:
* Rebased.Signed-off-by Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Hello Michael,
Could you please take a look at this? I'm out of my field here. The intention of the first part appears to be to save (val & ~mask), whereas the inline helper would've returned (val & mask).Quoted 6 lines
Quoted 6 lines
Such behavior is intended.
The returned value is just discarded in this case. test-and-clear means
clear the bits
return if those cleared bits were really set.What about this first chunk? Is it necessary.
Quoted 21 lines
Quoted 11 lines
Quoted 1 line
The second part makes existing code conditional on that value.
What issue are you addressing?
Although the spec doesn't says about the default value of BAR registers
after reset, the current code assumes that almost all the pci devices clear
those registers.
Anyway after cold/warm reset firmware sets up BARs, so it doesn't matter.
You, however, seem to want to keep BARs over resets.Quoted 3 lines
thanks,
As you have seen, the intend here is to be able to keep BARs over resets.
It is required for some really specific devices, like a PCI to ISA bridge, where MMIO is always at the same address.
In that case, the device keepsPCI_COMMAND_MEMORYand/orPCI_COMMAND_IOflags as read-only.Quoted 4 lines
Quoted 1 line
Hervé
Aha. Are the BARs still writeable? If not maybe that's the right thing to check? If yes maybe the device simply should have a reset handler to rewrite them?
I haven't noticed a follow-up patch of yours.
Quoted 9 lines
Since I don't know what to do here, I'll have to take this out of the PReP queue for now.
Without this patch, I get to at least the second bootloader icon, the PCI graphics still work. What particular symptoms did you observe wrt the i82378 that we can reproduce?Thanks,
AndreasTry do do info qtree with and without this patch, and check the i82378 device
With this patch, I have:bar 0: mem at 0x80000000 [0x8000ffff] bar 1: mem at 0xc0000000 [0xc0ffffff]Quoted 8 lines
Quoted 5 lines
Without it, I have:
bar 0: mem at 0xffffffffffffffff [0xfffe] bar 1: mem at 0xffffffffffffffff [0xfffffe]I think that firmware doesn't initialize BARs for this device.
Interesting. So what set the BARs to these values (
0x80000000and0xc0000000)Currently, those default values are stored in qdev properties of device, and device fills in BARs addresses in its init function
(quoted diff) +6
-0+static int pci_i82378_init(PCIDevice *pci_dev) + /* Make addresses read only */ + pci_set_word(pci_dev->wmask + PCI_COMMAND, + PCI_COMMAND_SPECIAL); + pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 0 * 4, pci->isa_io_base); + pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 1 * 4, pci->isa_mem_base);
Quoted 4 lines
Regards
Hervé
I see. So the right thing to do wrt BARs is probably to restore these values on system reset as well?
It might be a good idea to replace 'Make addresses read only' with 'only special cycle enable bit is writeable'.
Signature · 1 line
MST