qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH-for-7.0] hw/pci: Don't open-code pci_intx()


From: Jag Raman
Subject: Re: [PATCH-for-7.0] hw/pci: Don't open-code pci_intx()
Date: Wed, 15 Dec 2021 15:01:56 +0000


> 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
> 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]