qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Zhenzhong Duan" <zhenzhong.duan@intel.com>,
	qemu-devel@nongnu.org
Cc: chao.p.peng@intel.com, Paolo Bonzini <pbonzini@redhat.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Daniel Henrique Barboza <danielhb413@gmail.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	Harsh Prateek Bora <harshpb@linux.ibm.com>,
	"open list:PowerPC TCG CPUs" <qemu-ppc@nongnu.org>
Subject: Re: [PATCH] hw/ppc: Improve build for PPC VFIO
Date: Thu, 23 Nov 2023 14:45:39 +0100	[thread overview]
Message-ID: <95739695-ce1d-458d-802d-91346cf10025@redhat.com> (raw)
In-Reply-To: <8a95349c-4005-484f-b623-a1898a224896@linaro.org>

On 11/23/23 11:19, Philippe Mathieu-Daudé wrote:
> Hi Cédric,
> 
> On 23/11/23 08:33, Cédric Le Goater wrote:
>> On 11/23/23 07:01, Zhenzhong Duan wrote:
>>> VFIO is not a required subsystem for the pseries machine but it's
>>> force enabled currently. When --without-default-devices is used
>>> to drop some default devices including vfio-pci, vfio core code
>>> is still kept which is unnecessary.
>>>
>>> Introduce a stub file to hold stub functions of VFIO EEH hooks,
>>> then vfio core could be compiled out.
>>>
>>> Suggested-by: Cédric Le Goater <clg@redhat.com>
>>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>
>>
>> Nick,
>>
>> I will take this patch through the vfio tree if that's OK for you.
>>
>>> ---
>>> Based on vfio-next/vfio-8.2
>>>
>>>   hw/ppc/spapr_pci_vfio_stub.c | 33 +++++++++++++++++++++++++++++++++
>>>   hw/ppc/Kconfig               |  2 +-
>>>   hw/ppc/meson.build           |  6 +++---
>>>   3 files changed, 37 insertions(+), 4 deletions(-)
>>>   create mode 100644 hw/ppc/spapr_pci_vfio_stub.c
> 
> We are trying to remove stubs: instead of checking late in the callee,
> we shouldn't let the caller call functions depending on an unavailable
> feature. So I'm a bit reluctant with this patch.
>
> Can we add a simple 'bool pci_vfio_available(void);' helper? Or rework a
> bit. For example looking quickly, we already have:
> 
>      #ifdef CONFIG_LINUX
>      int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
>      #else
>      static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
>      {
>          return false;
>      }
>      #endif
> 
> This should be enough to protect the other calls.

The problem is that CONFIG_VFIO_PCI is not a target option and you can't
use the define as we do with CONFIG_LINUX. The define poisoning does its
job there.


> 
> Maybe we just need:> 
> -- >8 --
> --- a/include/hw/pci-host/spapr.h
> +++ b/include/hw/pci-host/spapr.h
> @@ -122,41 +122,20 @@ int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
>                             void *fdt, int *fdt_start_offset, Error **errp);
> 
>   /* VFIO EEH hooks */
> -#ifdef CONFIG_LINUX
> +#if defined(CONFIG_LINUX) && defined(CONFIG_VFIO_PCI)
>   bool spapr_phb_eeh_available(SpaprPhbState *sphb);
> +#else
> +static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
> +{
> +    return false;
> +}
> +#endif
>   int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
>                                     unsigned int addr, int option);
>   int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state);
>   int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option);
>   int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb);
>   void spapr_phb_vfio_reset(DeviceState *qdev);
> -#else
> -static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
> -{
> -    return false;
> -}
> -static inline int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
> -                                                unsigned int addr, int option)
> -{
> -    return RTAS_OUT_HW_ERROR;
> -}
> -static inline int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb,
> -                                               int *state)
> -{
> -    return RTAS_OUT_HW_ERROR;
> -}
> -static inline int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option)
> -{
> -    return RTAS_OUT_HW_ERROR;
> -}
> -static inline int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb)
> -{
> -    return RTAS_OUT_HW_ERROR;
> -}
> -static inline void spapr_phb_vfio_reset(DeviceState *qdev)
> -{
> -}
> -#endif
> 
>   void spapr_phb_dma_reset(SpaprPhbState *sphb);
> ---
> 
> and massage a bit the calls not protected by spapr_phb_eeh_available().

How about what's below  instead ?


Thanks,

C.



--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -26,10 +26,12 @@
  #include "hw/pci/pci_device.h"
  #include "hw/vfio/vfio-common.h"
  #include "qemu/error-report.h"
+#include CONFIG_DEVICES /* CONFIG_VFIO_PCI */
  
  /*
   * Interfaces for IBM EEH (Enhanced Error Handling)
   */
+#ifdef CONFIG_VFIO_PCI
  static bool vfio_eeh_container_ok(VFIOContainer *container)
  {
      /*
@@ -314,3 +316,37 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb)
  
      return RTAS_OUT_SUCCESS;
  }
+
+#else
+
+bool spapr_phb_eeh_available(SpaprPhbState *sphb)
+{
+    return false;
+}
+
+void spapr_phb_vfio_reset(DeviceState *qdev)
+{
+}
+
+int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
+                                  unsigned int addr, int option)
+{
+    return RTAS_OUT_NOT_SUPPORTED;
+}
+
+int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state)
+{
+    return RTAS_OUT_NOT_SUPPORTED;
+}
+
+int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option)
+{
+    return RTAS_OUT_NOT_SUPPORTED;
+}
+
+int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb)
+{
+    return RTAS_OUT_NOT_SUPPORTED;
+}
+
+#endif /* CONFIG_VFIO_PCI */




  reply	other threads:[~2023-11-23 13:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23  6:01 [PATCH] hw/ppc: Improve build for PPC VFIO Zhenzhong Duan
2023-11-23  7:33 ` Cédric Le Goater
2023-11-23  7:48   ` Duan, Zhenzhong
2023-11-23 10:19   ` Philippe Mathieu-Daudé
2023-11-23 13:45     ` Cédric Le Goater [this message]
2023-11-24  7:59       ` Cédric Le Goater
2023-11-24  8:01         ` Duan, Zhenzhong
2023-11-24  6:01   ` Nicholas Piggin

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=95739695-ce1d-458d-802d-91346cf10025@redhat.com \
    --to=clg@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=harshpb@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=zhenzhong.duan@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).