qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock
@ 2025-06-11 21:12 Rorie Reyes
  2025-06-12  4:44 ` Thomas Huth
  2025-06-12  6:18 ` Cédric Le Goater
  0 siblings, 2 replies; 5+ messages in thread
From: Rorie Reyes @ 2025-06-11 21:12 UTC (permalink / raw)
  To: qemu-devel, qemu-s390x
  Cc: pbonzini, cohuck, pasic, jjherne, borntraeger, alex.williamson,
	clg, thuth, akrowiak, rreyes

Created an attribute constructor for cfg_chg_events_lock for locking
mechanism when storing event information for an AP configuration change
event

Fixes: fd03360215 ("Storing event information for an AP configuration change event")
Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
---
 hw/vfio/ap.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 874e0d1eaf..1df4438149 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =
 
 static QemuMutex cfg_chg_events_lock;
 
+static void __attribute__((constructor)) vfio_ap_global_init(void)
+{
+    qemu_mutex_init(&cfg_chg_events_lock);
+}
+
 OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
 
 static void vfio_ap_compute_needs_reset(VFIODevice *vdev)
@@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
     VFIOAPDevice *vapdev = VFIO_AP_DEVICE(dev);
     VFIODevice *vbasedev = &vapdev->vdev;
 
-    static bool lock_initialized;
-
-    if (!lock_initialized) {
-        qemu_mutex_init(&cfg_chg_events_lock);
-        lock_initialized = true;
-    }
-
     if (!vfio_device_get_name(vbasedev, errp)) {
         return;
     }
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock
  2025-06-11 21:12 [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock Rorie Reyes
@ 2025-06-12  4:44 ` Thomas Huth
  2025-06-12 14:28   ` Rorie Reyes
  2025-06-12  6:18 ` Cédric Le Goater
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2025-06-12  4:44 UTC (permalink / raw)
  To: Rorie Reyes, qemu-devel, qemu-s390x
  Cc: pbonzini, cohuck, pasic, jjherne, borntraeger, alex.williamson,
	clg, akrowiak

On 11/06/2025 23.12, Rorie Reyes wrote:
> Created an attribute constructor for cfg_chg_events_lock for locking
> mechanism when storing event information for an AP configuration change
> event
> 
> Fixes: fd03360215 ("Storing event information for an AP configuration change event")
> Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
> ---
>   hw/vfio/ap.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 874e0d1eaf..1df4438149 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =
>   
>   static QemuMutex cfg_chg_events_lock;
>   
> +static void __attribute__((constructor)) vfio_ap_global_init(void)
> +{
> +    qemu_mutex_init(&cfg_chg_events_lock);
> +}

I wonder why we don't have a macro for this yet (there are many other spots 
in the code that initialize a mutex like this).

Anyway, for your patch:
Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock
  2025-06-11 21:12 [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock Rorie Reyes
  2025-06-12  4:44 ` Thomas Huth
@ 2025-06-12  6:18 ` Cédric Le Goater
  2025-06-12 14:29   ` Rorie Reyes
  1 sibling, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2025-06-12  6:18 UTC (permalink / raw)
  To: Rorie Reyes, qemu-devel, qemu-s390x
  Cc: pbonzini, cohuck, pasic, jjherne, borntraeger, alex.williamson,
	thuth, akrowiak

On 6/11/25 23:12, Rorie Reyes wrote:
> Created an attribute constructor for cfg_chg_events_lock for locking
> mechanism when storing event information for an AP configuration change
> event
> 
> Fixes: fd03360215 ("Storing event information for an AP configuration change event")
> Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
> ---
>   hw/vfio/ap.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index 874e0d1eaf..1df4438149 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =
>   
>   static QemuMutex cfg_chg_events_lock;
>   
> +static void __attribute__((constructor)) vfio_ap_global_init(void)
> +{
> +    qemu_mutex_init(&cfg_chg_events_lock);
> +}
> +
>   OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
>   
>   static void vfio_ap_compute_needs_reset(VFIODevice *vdev)
> @@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(dev);
>       VFIODevice *vbasedev = &vapdev->vdev;
>   
> -    static bool lock_initialized;
> -
> -    if (!lock_initialized) {
> -        qemu_mutex_init(&cfg_chg_events_lock);
> -        lock_initialized = true;
> -    }
> -
>       if (!vfio_device_get_name(vbasedev, errp)) {
>           return;
>       }


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

Applied to vfio-next.

Thanks,

C.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock
  2025-06-12  4:44 ` Thomas Huth
@ 2025-06-12 14:28   ` Rorie Reyes
  0 siblings, 0 replies; 5+ messages in thread
From: Rorie Reyes @ 2025-06-12 14:28 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, qemu-s390x
  Cc: pbonzini, cohuck, pasic, jjherne, borntraeger, alex.williamson,
	clg, akrowiak


On 6/12/25 12:44 AM, Thomas Huth wrote:
> On 11/06/2025 23.12, Rorie Reyes wrote:
>> Created an attribute constructor for cfg_chg_events_lock for locking
>> mechanism when storing event information for an AP configuration change
>> event
>>
>> Fixes: fd03360215 ("Storing event information for an AP configuration 
>> change event")
>> Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
>> ---
>>   hw/vfio/ap.c | 12 +++++-------
>>   1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
>> index 874e0d1eaf..1df4438149 100644
>> --- a/hw/vfio/ap.c
>> +++ b/hw/vfio/ap.c
>> @@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) 
>> cfg_chg_events =
>>     static QemuMutex cfg_chg_events_lock;
>>   +static void __attribute__((constructor)) vfio_ap_global_init(void)
>> +{
>> +    qemu_mutex_init(&cfg_chg_events_lock);
>> +}
>
> I wonder why we don't have a macro for this yet (there are many other 
> spots in the code that initialize a mutex like this).
>
> Anyway, for your patch:
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
Thank you!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock
  2025-06-12  6:18 ` Cédric Le Goater
@ 2025-06-12 14:29   ` Rorie Reyes
  0 siblings, 0 replies; 5+ messages in thread
From: Rorie Reyes @ 2025-06-12 14:29 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel, qemu-s390x
  Cc: pbonzini, cohuck, pasic, jjherne, borntraeger, alex.williamson,
	thuth, akrowiak


On 6/12/25 2:18 AM, Cédric Le Goater wrote:
> On 6/11/25 23:12, Rorie Reyes wrote:
>> Created an attribute constructor for cfg_chg_events_lock for locking
>> mechanism when storing event information for an AP configuration change
>> event
>>
>> Fixes: fd03360215 ("Storing event information for an AP configuration 
>> change event")
>> Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
>> ---
>>   hw/vfio/ap.c | 12 +++++-------
>>   1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
>> index 874e0d1eaf..1df4438149 100644
>> --- a/hw/vfio/ap.c
>> +++ b/hw/vfio/ap.c
>> @@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) 
>> cfg_chg_events =
>>     static QemuMutex cfg_chg_events_lock;
>>   +static void __attribute__((constructor)) vfio_ap_global_init(void)
>> +{
>> +    qemu_mutex_init(&cfg_chg_events_lock);
>> +}
>> +
>>   OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
>>     static void vfio_ap_compute_needs_reset(VFIODevice *vdev)
>> @@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, 
>> Error **errp)
>>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(dev);
>>       VFIODevice *vbasedev = &vapdev->vdev;
>>   -    static bool lock_initialized;
>> -
>> -    if (!lock_initialized) {
>> -        qemu_mutex_init(&cfg_chg_events_lock);
>> -        lock_initialized = true;
>> -    }
>> -
>>       if (!vfio_device_get_name(vbasedev, errp)) {
>>           return;
>>       }
>
>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>
> Applied to vfio-next.
>
> Thanks,
>
> C.
>
Thank you!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-12 14:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 21:12 [RFC PATCH v1] hw/vfio/ap: attribute constructor for cfg_chg_events_lock Rorie Reyes
2025-06-12  4:44 ` Thomas Huth
2025-06-12 14:28   ` Rorie Reyes
2025-06-12  6:18 ` Cédric Le Goater
2025-06-12 14:29   ` Rorie Reyes

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