diff mbox series

[v4,3/4] pci: Honour wmask when resetting PCI_INTERRUPT_LINE

Message ID 5e372f6a73d4f45c0c18a264e986c29fc075f2d4.1583867210.git.balaton@eik.bme.hu
State New
Headers show
Series Implement "non 100% native mode" in via-ide | expand

Commit Message

BALATON Zoltan March 10, 2020, 7:06 p.m. UTC
The pci_do_device_reset() function (called from pci_device_reset)
clears the PCI_INTERRUPT_LINE config reg of devices on the bus but did
this without taking wmask into account. We'll have a device model now
that needs to set a constant value for this reg and this patch allows
to do that without additional workaround in device emulation to
reverse the effect of this PCI bus reset function.

Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/pci/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael S. Tsirkin March 10, 2020, 9:18 p.m. UTC | #1
On Tue, Mar 10, 2020 at 08:06:50PM +0100, BALATON Zoltan wrote:
> The pci_do_device_reset() function (called from pci_device_reset)
> clears the PCI_INTERRUPT_LINE config reg of devices on the bus but did
> this without taking wmask into account. We'll have a device model now
> that needs to set a constant value for this reg and this patch allows
> to do that without additional workaround in device emulation to
> reverse the effect of this PCI bus reset function.
> 
> Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Looks ok to me

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

Feel free to merge with the rest of the series.


> ---
>  hw/pci/pci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index e1ed6677e1..b5bc842fac 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -302,8 +302,11 @@ static void pci_do_device_reset(PCIDevice *dev)
>      pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
>                                   pci_get_word(dev->wmask + PCI_STATUS) |
>                                   pci_get_word(dev->w1cmask + PCI_STATUS));
> +    /* Some devices make bits of PCI_INTERRUPT_LINE read only */
> +    pci_byte_test_and_clear_mask(dev->config + PCI_INTERRUPT_LINE,
> +                              pci_get_word(dev->wmask + PCI_INTERRUPT_LINE) |
> +                              pci_get_word(dev->w1cmask + PCI_INTERRUPT_LINE));
>      dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
> -    dev->config[PCI_INTERRUPT_LINE] = 0x0;
>      for (r = 0; r < PCI_NUM_REGIONS; ++r) {
>          PCIIORegion *region = &dev->io_regions[r];
>          if (!region->size) {
> -- 
> 2.21.1
Mark Cave-Ayland March 11, 2020, 8:58 p.m. UTC | #2
On 10/03/2020 19:06, BALATON Zoltan wrote:

> The pci_do_device_reset() function (called from pci_device_reset)
> clears the PCI_INTERRUPT_LINE config reg of devices on the bus but did
> this without taking wmask into account. We'll have a device model now
> that needs to set a constant value for this reg and this patch allows
> to do that without additional workaround in device emulation to
> reverse the effect of this PCI bus reset function.
> 
> Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>  hw/pci/pci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index e1ed6677e1..b5bc842fac 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -302,8 +302,11 @@ static void pci_do_device_reset(PCIDevice *dev)
>      pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
>                                   pci_get_word(dev->wmask + PCI_STATUS) |
>                                   pci_get_word(dev->w1cmask + PCI_STATUS));
> +    /* Some devices make bits of PCI_INTERRUPT_LINE read only */
> +    pci_byte_test_and_clear_mask(dev->config + PCI_INTERRUPT_LINE,
> +                              pci_get_word(dev->wmask + PCI_INTERRUPT_LINE) |
> +                              pci_get_word(dev->w1cmask + PCI_INTERRUPT_LINE));
>      dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
> -    dev->config[PCI_INTERRUPT_LINE] = 0x0;
>      for (r = 0; r < PCI_NUM_REGIONS; ++r) {
>          PCIIORegion *region = &dev->io_regions[r];
>          if (!region->size) {
> 

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
diff mbox series

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e1ed6677e1..b5bc842fac 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -302,8 +302,11 @@  static void pci_do_device_reset(PCIDevice *dev)
     pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
                                  pci_get_word(dev->wmask + PCI_STATUS) |
                                  pci_get_word(dev->w1cmask + PCI_STATUS));
+    /* Some devices make bits of PCI_INTERRUPT_LINE read only */
+    pci_byte_test_and_clear_mask(dev->config + PCI_INTERRUPT_LINE,
+                              pci_get_word(dev->wmask + PCI_INTERRUPT_LINE) |
+                              pci_get_word(dev->w1cmask + PCI_INTERRUPT_LINE));
     dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
-    dev->config[PCI_INTERRUPT_LINE] = 0x0;
     for (r = 0; r < PCI_NUM_REGIONS; ++r) {
         PCIIORegion *region = &dev->io_regions[r];
         if (!region->size) {