* [PATCH-for-7.0] hw/pci: Don't open-code pci_intx()
@ 2021-11-16 17:26 Philippe Mathieu-Daudé
2021-12-15 10:37 ` Philippe Mathieu-Daudé
2021-12-15 15:01 ` Jag Raman
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-16 17:26 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Dmitry Fleytman,
Jagannathan Raman, qemu-trivial, Jason Wang,
Philippe Mathieu-Daudé
Use the pci_intx() helper instead of open-coding it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Based-on: <20211116170133.724751-3-fbarrat@linux.ibm.com>
---
hw/net/vmxnet3.c | 2 +-
hw/remote/iohub.c | 6 ++----
hw/remote/proxy.c | 3 +--
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 41f796a247d..c7fc5f44d8f 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1350,7 +1350,7 @@ static void vmxnet3_update_features(VMXNET3State *s)
static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
{
return s->msix_used || msi_enabled(PCI_DEVICE(s))
- || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;
+ || intx == pci_intx(PCI_DEVICE(s));
}
static void vmxnet3_validate_interrupt_idx(bool is_msix, int idx)
diff --git a/hw/remote/iohub.c b/hw/remote/iohub.c
index 547d597f0fe..0e0bb651d1a 100644
--- a/hw/remote/iohub.c
+++ b/hw/remote/iohub.c
@@ -93,11 +93,9 @@ void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg)
{
RemoteMachineState *machine = REMOTE_MACHINE(current_machine);
RemoteIOHubState *iohub = &machine->iohub;
- int pirq, intx;
+ int pirq;
- intx = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
-
- pirq = remote_iohub_map_irq(pci_dev, intx);
+ pirq = remote_iohub_map_irq(pci_dev, pci_intx(pci_dev));
if (event_notifier_get_fd(&iohub->irqfds[pirq]) != -1) {
qemu_set_fd_handler(event_notifier_get_fd(&iohub->resamplefds[pirq]),
diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
index bad164299dd..22f32a5930b 100644
--- a/hw/remote/proxy.c
+++ b/hw/remote/proxy.c
@@ -32,14 +32,13 @@ static void proxy_intx_update(PCIDevice *pci_dev)
{
PCIProxyDev *dev = PCI_PROXY_DEV(pci_dev);
PCIINTxRoute route;
- int pin = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
if (dev->virq != -1) {
kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &dev->intr, dev->virq);
dev->virq = -1;
}
- route = pci_device_route_intx_to_irq(pci_dev, pin);
+ route = pci_device_route_intx_to_irq(pci_dev, pci_intx(pci_dev));
dev->virq = route.irq;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH-for-7.0] hw/pci: Don't open-code pci_intx()
2021-11-16 17:26 [PATCH-for-7.0] hw/pci: Don't open-code pci_intx() Philippe Mathieu-Daudé
@ 2021-12-15 10:37 ` Philippe Mathieu-Daudé
2021-12-15 15:01 ` Jag Raman
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-15 10:37 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Dmitry Fleytman,
Jagannathan Raman, qemu-trivial, Jason Wang
ping for review?
On 11/16/21 18:26, Philippe Mathieu-Daudé wrote:
> Use the pci_intx() helper instead of open-coding it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Based-on: <20211116170133.724751-3-fbarrat@linux.ibm.com>
> ---
> hw/net/vmxnet3.c | 2 +-
> hw/remote/iohub.c | 6 ++----
> hw/remote/proxy.c | 3 +--
> 3 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index 41f796a247d..c7fc5f44d8f 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -1350,7 +1350,7 @@ static void vmxnet3_update_features(VMXNET3State *s)
> static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
> {
> return s->msix_used || msi_enabled(PCI_DEVICE(s))
> - || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;
> + || intx == pci_intx(PCI_DEVICE(s));
> }
>
> static void vmxnet3_validate_interrupt_idx(bool is_msix, int idx)
> diff --git a/hw/remote/iohub.c b/hw/remote/iohub.c
> index 547d597f0fe..0e0bb651d1a 100644
> --- a/hw/remote/iohub.c
> +++ b/hw/remote/iohub.c
> @@ -93,11 +93,9 @@ void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg)
> {
> RemoteMachineState *machine = REMOTE_MACHINE(current_machine);
> RemoteIOHubState *iohub = &machine->iohub;
> - int pirq, intx;
> + int pirq;
>
> - intx = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
> -
> - pirq = remote_iohub_map_irq(pci_dev, intx);
> + pirq = remote_iohub_map_irq(pci_dev, pci_intx(pci_dev));
>
> if (event_notifier_get_fd(&iohub->irqfds[pirq]) != -1) {
> qemu_set_fd_handler(event_notifier_get_fd(&iohub->resamplefds[pirq]),
> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
> index bad164299dd..22f32a5930b 100644
> --- a/hw/remote/proxy.c
> +++ b/hw/remote/proxy.c
> @@ -32,14 +32,13 @@ static void proxy_intx_update(PCIDevice *pci_dev)
> {
> PCIProxyDev *dev = PCI_PROXY_DEV(pci_dev);
> PCIINTxRoute route;
> - int pin = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
>
> if (dev->virq != -1) {
> kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &dev->intr, dev->virq);
> dev->virq = -1;
> }
>
> - route = pci_device_route_intx_to_irq(pci_dev, pin);
> + route = pci_device_route_intx_to_irq(pci_dev, pci_intx(pci_dev));
>
> dev->virq = route.irq;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH-for-7.0] hw/pci: Don't open-code pci_intx()
2021-11-16 17:26 [PATCH-for-7.0] hw/pci: Don't open-code pci_intx() Philippe Mathieu-Daudé
2021-12-15 10:37 ` Philippe Mathieu-Daudé
@ 2021-12-15 15:01 ` Jag Raman
1 sibling, 0 replies; 3+ messages in thread
From: Jag Raman @ 2021-12-15 15:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John Johnson, Dmitry Fleytman, qemu-trivial,
Jason Wang, qemu-devel
> On Nov 16, 2021, at 12:26 PM, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Use the pci_intx() helper instead of open-coding it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Based-on: <20211116170133.724751-3-fbarrat@linux.ibm.com>
> ---
> hw/net/vmxnet3.c | 2 +-
> hw/remote/iohub.c | 6 ++----
> hw/remote/proxy.c | 3 +--
> 3 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index 41f796a247d..c7fc5f44d8f 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -1350,7 +1350,7 @@ static void vmxnet3_update_features(VMXNET3State *s)
> static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
> {
> return s->msix_used || msi_enabled(PCI_DEVICE(s))
> - || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;
> + || intx == pci_intx(PCI_DEVICE(s));
> }
>
> static void vmxnet3_validate_interrupt_idx(bool is_msix, int idx)
> diff --git a/hw/remote/iohub.c b/hw/remote/iohub.c
> index 547d597f0fe..0e0bb651d1a 100644
> --- a/hw/remote/iohub.c
> +++ b/hw/remote/iohub.c
> @@ -93,11 +93,9 @@ void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg)
> {
> RemoteMachineState *machine = REMOTE_MACHINE(current_machine);
> RemoteIOHubState *iohub = &machine->iohub;
> - int pirq, intx;
> + int pirq;
>
> - intx = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
> -
> - pirq = remote_iohub_map_irq(pci_dev, intx);
> + pirq = remote_iohub_map_irq(pci_dev, pci_intx(pci_dev));
>
> if (event_notifier_get_fd(&iohub->irqfds[pirq]) != -1) {
> qemu_set_fd_handler(event_notifier_get_fd(&iohub->resamplefds[pirq]),
> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
> index bad164299dd..22f32a5930b 100644
> --- a/hw/remote/proxy.c
> +++ b/hw/remote/proxy.c
> @@ -32,14 +32,13 @@ static void proxy_intx_update(PCIDevice *pci_dev)
> {
> PCIProxyDev *dev = PCI_PROXY_DEV(pci_dev);
> PCIINTxRoute route;
> - int pin = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
>
> if (dev->virq != -1) {
> kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &dev->intr, dev->virq);
> dev->virq = -1;
> }
>
> - route = pci_device_route_intx_to_irq(pci_dev, pin);
> + route = pci_device_route_intx_to_irq(pci_dev, pci_intx(pci_dev));
>
> dev->virq = route.irq;
Hi Philippe,
If possible, I’d rename pci_intx() to pci_intx_irq() - to differentiate the pin number
and vector number.
I would add a comment to pci_intx() saying that negative return value means
INTx is not supported.
But it looks like pci_intx() was exported in a different series and not relevant to
this patch.
Acked-by: Jagannathan Raman <jag.raman@oracle.com>
Thank you!
--
Jag
>
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-15 15:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 17:26 [PATCH-for-7.0] hw/pci: Don't open-code pci_intx() Philippe Mathieu-Daudé
2021-12-15 10:37 ` Philippe Mathieu-Daudé
2021-12-15 15:01 ` Jag Raman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.