All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	eric.auger@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	philmd@linaro.org, qemu-ppc@nongnu.org
Subject: Re: [PATCH v5 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM
Date: Thu, 19 Mar 2026 09:33:18 +0100	[thread overview]
Message-ID: <0fe351a8-e08c-401a-af43-578c7be9ab2a@redhat.com> (raw)
In-Reply-To: <20260318174733.1717643-6-pierrick.bouvier@linaro.org>

On 3/18/26 18:47, Pierrick Bouvier wrote:
> We just need to add kvm_enabled() guard when calling concerned
> functions, but no need to extract those kvm functions since they are not
> using any kvm specific types that would not be visible at compilation
> time.
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   hw/vfio/pci.c | 28 ++++++++++------------------
>   1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index df617f1fe46..811e5001de5 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -152,7 +152,6 @@ void vfio_pci_intx_eoi(VFIODevice *vbasedev)
>   
>   static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
>   {
> -#ifdef CONFIG_KVM
>       PCIDevice *pdev = PCI_DEVICE(vdev);
>       int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
>   
> @@ -206,14 +205,10 @@ fail:
>       qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev);
>       vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
>       return false;
> -#else
> -    return true;
> -#endif
>   }
>   
>   static bool vfio_cpr_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
>   {
> -#ifdef CONFIG_KVM
>       if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
>           vdev->intx.route.mode != PCI_INTX_ENABLED ||
>           !kvm_resamplefds_enabled()) {
> @@ -236,14 +231,10 @@ static bool vfio_cpr_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
>       vdev->intx.kvm_accel = true;
>       trace_vfio_intx_enable_kvm(vdev->vbasedev.name);
>       return true;
> -#else
> -    return true;
> -#endif
>   }
>   
>   static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
>   {
> -#ifdef CONFIG_KVM
>       PCIDevice *pdev = PCI_DEVICE(vdev);
>   
>       if (!vdev->intx.kvm_accel) {
> @@ -277,7 +268,6 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
>       vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
>   
>       trace_vfio_intx_disable_kvm(vdev->vbasedev.name);
> -#endif
>   }
>   
>   static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
> @@ -287,7 +277,9 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
>       trace_vfio_intx_update(vdev->vbasedev.name,
>                              vdev->intx.route.irq, route->irq);
>   
> -    vfio_intx_disable_kvm(vdev);
> +    if (kvm_enabled()) {
> +        vfio_intx_disable_kvm(vdev);
> +    }
>   
>       vdev->intx.route = *route;
>   
> @@ -295,7 +287,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
>           return;
>       }
>   
> -    if (!vfio_intx_enable_kvm(vdev, &err)) {
> +    if (kvm_enabled() && !vfio_intx_enable_kvm(vdev, &err)) {
>           warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
>       }
>   
> @@ -350,16 +342,14 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
>       vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */
>       pci_config_set_interrupt_pin(pdev->config, pin);
>   
> -#ifdef CONFIG_KVM
>       /*
>        * Only conditional to avoid generating error messages on platforms
>        * where we won't actually use the result anyway.
>        */
> -    if (kvm_irqfds_enabled() && kvm_resamplefds_enabled()) {
> +    if (kvm_enabled() && kvm_irqfds_enabled() && kvm_resamplefds_enabled()) {
>           vdev->intx.route = pci_device_route_intx_to_irq(pdev,
>                                                           vdev->intx.pin);
>       }
> -#endif
>   
>       if (!vfio_notifier_init(vdev, &vdev->intx.interrupt, "intx-interrupt", 0,
>                               errp)) {
> @@ -370,7 +360,7 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
>   
>   
>       if (cpr_is_incoming()) {
> -        if (!vfio_cpr_intx_enable_kvm(vdev, &err)) {
> +        if (kvm_enabled() && !vfio_cpr_intx_enable_kvm(vdev, &err)) {
>               warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
>           }
>           goto skip_signaling;
> @@ -383,7 +373,7 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
>           return false;
>       }
>   
> -    if (!vfio_intx_enable_kvm(vdev, &err)) {
> +    if (kvm_enabled() && !vfio_intx_enable_kvm(vdev, &err)) {
>           warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
>       }
>   
> @@ -400,7 +390,9 @@ static void vfio_intx_disable(VFIOPCIDevice *vdev)
>       int fd;
>   
>       timer_del(vdev->intx.mmap_timer);
> -    vfio_intx_disable_kvm(vdev);
> +    if (kvm_enabled()) {
> +        vfio_intx_disable_kvm(vdev);
> +    }
>       vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
>       vdev->intx.pending = false;
>       pci_irq_deassert(pdev);



Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.



  reply	other threads:[~2026-03-19  8:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 17:47 [PATCH v5 0/8] hw/vfio: single-binary Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources Pierrick Bouvier
2026-03-19  8:32   ` Cédric Le Goater
2026-03-18 17:47 ` [PATCH v5 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM Pierrick Bouvier
2026-03-19  8:33   ` Cédric Le Goater [this message]
2026-03-18 17:47 ` [PATCH v5 6/8] hw/vfio/ap.c: use full path for target specific header Pierrick Bouvier
2026-03-18 17:47 ` [PATCH v5 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
2026-03-19  8:32   ` Cédric Le Goater
2026-03-18 17:47 ` [PATCH v5 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
2026-03-19  7:45 ` [PATCH v5 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
2026-03-19  8:33 ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0fe351a8-e08c-401a-af43-578c7be9ab2a@redhat.com \
    --to=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.