hw/vfio/ccw: hw: Use QOM macros and remove DO_UPCAST() uses
v3 cover hw/vfio/ccw: hw: Use QOM macros and remove DO_UPCAST() uses
QOM housekeeping series which replace the DO_UPCAST() macro uses by equivalent QOM ones (and few more trivial cleanups).
Since v2:
- Split of bigger series
- Split in simpler patches
- Added Eric R-b tags
v2:
https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (6):
hw/s390x/event-facility: Replace DO_UPCAST(SCLPEvent) by SCLP_EVENT() hw/vfio/ccw: Simplify using DEVICE() macro
hw/vfio/ccw: Use intermediate S390CCWDevice variable hw/vfio/ccw: Replace DO_UPCAST(S390CCWDevice) by S390_CCW_DEVICE() hw/vfio/ccw: Remove pointless S390CCWDevice variable hw/vfio/ccw: Replace DO_UPCAST(VFIOCCWDevice) by VFIO_CCW()
hw/s390x/event-facility.c | 3 +-- hw/vfio/ccw.c | 40 ++++++++++++++++----------------------- 2 files changed, 17 insertions(+), 26 deletions(-)
Signature · 1 line
2.38.1
PATCH v3 1/6 hw/s390x/event-facility: Replace DO_UPCAST(SCLPEvent) by SCLP_EVENT()
Use the SCLP_EVENT() QOM type-checking macro to avoid DO_UPCAST().
--- hw/s390x/event-facility.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/s390x/event-facility.c +1 -2
@@ -64,8 +64,7 @@ static bool event_pending(SCLPEventFacility *ef)SCLPEventClass *event_class; QTAILQ_FOREACH(kid, &ef->sbus.qbus.children, sibling) { -DeviceState *qdev = kid->child; - event =DO_UPCAST (SCLPEvent, qdev, qdev); + event =SCLP_EVENT (kid->child); event_class =SCLP_EVENT_GET_CLASS (event);if (event->event_pending && event_class->get_send_mask () & ef->receive_mask) {
Signature · 1 line
2.38.1
PATCH v3 2/6 hw/vfio/ccw: Simplify using DEVICE() macro
In reply to Philippe Mathieu-DaudéQOM parenthood relationship is:
VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState
We can directly use the QOM DEVICE() macro to get the parent object.
--- hw/vfio/ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/ccw.c +1 -1
@@ -618,7 +618,7 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev, vcdev->vdev.ops = &vfio_ccw_ops; vcdev->vdev.type =VFIO_DEVICE_TYPE_CCW ; vcdev->vdev.name = name; - vcdev->vdev.dev = &vcdev->cdev.parent_obj.parent_obj; + vcdev->vdev.dev =DEVICE (vcdev);return ;
Signature · 1 line
2.38.1
Re: [PATCH v3 2/6] hw/vfio/ccw: Simplify using DEVICE() macro
Quoted 7 lines · Philippe Mathieu-Daudé
QOM parenthood relationship is:
VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState
We can directly use the QOM
DEVICE()macro to get the parent object.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 18 lines
---
hw/vfio/ccw.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/ccw.c +1
-1@@ -618,7 +618,7 @@ static void vfio_ccw_get_device(VFIOGroup *group,VFIOCCWDevice *vcdev, vcdev->vdev.ops = &vfio_ccw_ops; vcdev->vdev.type = VFIO_DEVICE_TYPE_CCW; vcdev->vdev.name = name; - vcdev->vdev.dev = &vcdev->cdev.parent_obj.parent_obj; + vcdev->vdev.dev = DEVICE(vcdev);
return;
PATCH v3 3/6 hw/vfio/ccw: Use intermediate S390CCWDevice variable
In reply to Philippe Mathieu-Daudé'cdev' is VFIOCCWDevice's private parent object.
Access it using the S390_CCW_DEVICE() QOM macro.
--- hw/vfio/ccw.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/vfio/ccw.c +5 -4
@@ -588,9 +588,10 @@ static void vfio_ccw_put_device(VFIOCCWDevice *vcdev)static void vfio_ccw_get_device (VFIOGroup *group,VFIOCCWDevice *vcdev,Error **errp) { -char *name =g_strdup_printf ("%x.%x.%04x" , vcdev->cdev.hostid.cssid, - vcdev->cdev.hostid.ssid, - vcdev->cdev.hostid.devid); +S390CCWDevice *cdev =S390_CCW_DEVICE (vcdev); +char *name =g_strdup_printf ("%x.%x.%04x" , cdev->hostid.cssid, + cdev->hostid.ssid, + cdev->hostid.devid);VFIODevice *vbasedev; QLIST_FOREACH(vbasedev, &group->device_list, next) {
@@ -611,7 +612,7 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,*/ vcdev->vdev.ram_block_discard_allowed = true; -if (vfio_get_device (group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) { +if (vfio_get_device (group, cdev->mdevid, &vcdev->vdev, errp)) { goto out_err; }
Signature · 1 line
2.38.1
Re: [PATCH v3 3/6] hw/vfio/ccw: Use intermediate S390CCWDevice variable
Quoted 4 lines · Philippe Mathieu-Daudé
'cdev' is VFIOCCWDevice's private parent object.
Access it using theS390_CCW_DEVICE()QOM macro.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 36 lines
---
hw/vfio/ccw.c | 9 +++++----1 file changed, 5 insertions(+), 4 deletions(-)hw/vfio/ccw.c +0
-0@@ -588,9 +588,10 @@ static void vfio_ccw_put_device(VFIOCCWDevice *vcdev)static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,
Error **errp)
{
- char *name = g_strdup_printf("%x.%x.%04x", vcdev-Quoted 1 line
cdev.hostid.cssid,
-
vcdev->cdev.hostid.ssid, -vcdev->cdev.hostid.devid); + S390CCWDevice *cdev =S390_CCW_DEVICE(vcdev);
+ char *name = g_strdup_printf("%x.%x.%04x",cdev->hostid.cssid, +cdev->hostid.ssid,
+cdev->hostid.devid); VFIODevice *vbasedev;
QLIST_FOREACH(vbasedev, &group->device_list, next){hw/vfio/ccw.c +0
-0@@ -611,7 +612,7 @@ static void vfio_ccw_get_device(VFIOGroup *group,VFIOCCWDevice *vcdev, */ vcdev->vdev.ram_block_discard_allowed = true;
- if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) {
+ if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, errp)) { gotoout_err;
}
PATCH v3 4/6 hw/vfio/ccw: Replace DO_UPCAST(S390CCWDevice) by S390_CCW_DEVICE()
In reply to Philippe Mathieu-DaudéUse the S390_CCW_DEVICE() QOM type-checking macro to avoid DO_UPCAST().
--- hw/vfio/ccw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/vfio/ccw.c +3 -6
@@ -251,8 +251,7 @@ again:static void vfio_ccw_reset (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);ioctl (vcdev->vdev.fd,VFIO_DEVICE_RESET );
@@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp)static void vfio_ccw_realize (DeviceState *dev,Error **errp) {VFIOGroup *group; -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);Error *err =NULL ;
@@ -729,8 +727,7 @@ out_err_propagate:static void vfio_ccw_unrealize (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);VFIOGroup *group = vcdev->vdev.group;
Signature · 1 line
2.38.1
Re: [PATCH v3 4/6] hw/vfio/ccw: Replace DO_UPCAST(S390CCWDevice) by S390_CCW_DEVICE()
Quoted 2 lines · Philippe Mathieu-Daudé
Use the
S390_CCW_DEVICE()QOM type-checking macro to avoidDO_UPCAST().
I forgot Eric R-b here:
Quoted 39 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/vfio/ccw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/vfio/ccw.c +3
-6@@ -251,8 +251,7 @@ again:static void vfio_ccw_reset (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);ioctl (vcdev->vdev.fd,VFIO_DEVICE_RESET );@@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp)static void vfio_ccw_realize (DeviceState *dev,Error **errp) {VFIOGroup *group; -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);Error *err =NULL ;@@ -729,8 +727,7 @@ out_err_propagate:static void vfio_ccw_unrealize (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);VFIOGroup *group = vcdev->vdev.group;
Re: [PATCH v3 4/6] hw/vfio/ccw: Replace DO_UPCAST(S390CCWDevice) by S390_CCW_DEVICE()
In reply to Philippe Mathieu-DaudéQuoted 32 lines · Philippe Mathieu-Daudé
Use the
S390_CCW_DEVICE()QOM type-checking macro to avoidDO_UPCAST().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/vfio/ccw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/vfio/ccw.c +2
-4@@ -251,8 +251,7 @@ again:static void vfio_ccw_reset (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);ioctl (vcdev->vdev.fd,VFIO_DEVICE_RESET );@@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp)static void vfio_ccw_realize (DeviceState *dev,Error **errp) {VFIOGroup *group; -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);Error *err =NULL ;
hw/vfio/ccw.c out_err_propagate: · line 733
Quoted 9 lines
hw/vfio/ccw.c +1
-2@@ -729,8 +727,7 @@ out_err_propagate:static void vfio_ccw_unrealize (DeviceState *dev) { -CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev); -S390CCWDevice *cdev =DO_UPCAST (S390CCWDevice, parent_obj, ccw_dev); +S390CCWDevice *cdev =S390_CCW_DEVICE (dev);VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);VFIOGroup *group = vcdev->vdev.group;
PATCH v3 5/6 hw/vfio/ccw: Remove pointless S390CCWDevice variable
In reply to Philippe Mathieu-DaudéQOM parenthood relationship is:
VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState
No need to double-cast, call CCW_DEVICE() on VFIOCCWDevice.
--- hw/vfio/ccw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/vfio/ccw.c +1 -2
@@ -314,8 +314,7 @@ static void vfio_ccw_io_notifier_handler(void *opaque) {VFIOCCWDevice *vcdev = opaque;struct ccw_io_region *region = vcdev->io_region; -S390CCWDevice *cdev =S390_CCW_DEVICE (vcdev); -CcwDevice *ccw_dev =CCW_DEVICE (cdev); +CcwDevice *ccw_dev =CCW_DEVICE (vcdev);SubchDev *sch = ccw_dev->sch;SCHIB *schib = &sch->curr_status;SCSW s;
Signature · 1 line
2.38.1
Re: [PATCH v3 5/6] hw/vfio/ccw: Remove pointless S390CCWDevice variable
Quoted 7 lines · Philippe Mathieu-Daudé
QOM parenthood relationship is:
VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState
No need to double-cast, call
CCW_DEVICE()on VFIOCCWDevice.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 19 lines
---
hw/vfio/ccw.c | 3 +--1 file changed, 1 insertion(+), 2 deletions(-)hw/vfio/ccw.c +1
-2@@ -314,8 +314,7 @@ static void vfio_ccw_io_notifier_handler(void *opaque) { VFIOCCWDevice *vcdev = opaque; struct ccw_io_region *region = vcdev->io_region; - S390CCWDevice *cdev = S390_CCW_DEVICE(vcdev); - CcwDevice *ccw_dev = CCW_DEVICE(cdev); + CcwDevice *ccw_dev = CCW_DEVICE(vcdev); SubchDev *sch = ccw_dev->sch; SCHIB *schib = &sch->curr_status;SCSW s;
PATCH v3 6/6 hw/vfio/ccw: Replace DO_UPCAST(VFIOCCWDevice) by VFIO_CCW()
In reply to Philippe Mathieu-DaudéUse the VFIO_CCW() QOM type-checking macro to avoid DO_UPCAST().
--- hw/vfio/ccw.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
hw/vfio/ccw.c +7 -12
@@ -76,8 +76,7 @@ struct VFIODeviceOps vfio_ccw_ops = {static IOInstEnding vfio_ccw_handle_request (SubchDev *sch) { -S390CCWDevice *cdev = sch->driver_data; -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (sch->driver_data);struct ccw_io_region *region = vcdev->io_region;int ret;
@@ -125,8 +124,7 @@ again:static IOInstEnding vfio_ccw_handle_store (SubchDev *sch) { -S390CCWDevice *cdev = sch->driver_data; -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (sch->driver_data);SCHIB *schib = &sch->curr_status;struct ccw_schib_region *region = vcdev->schib_region;SCHIB *s;
@@ -170,8 +168,7 @@ static IOInstEnding vfio_ccw_handle_store(SubchDev *sch)static int vfio_ccw_handle_clear (SubchDev *sch) { -S390CCWDevice *cdev = sch->driver_data; -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (sch->driver_data);struct ccw_cmd_region *region = vcdev->async_cmd_region;int ret;
@@ -210,8 +207,7 @@ again:static int vfio_ccw_handle_halt (SubchDev *sch) { -S390CCWDevice *cdev = sch->driver_data; -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (sch->driver_data);struct ccw_cmd_region *region = vcdev->async_cmd_region;int ret;
@@ -251,8 +247,7 @@ again:static void vfio_ccw_reset (DeviceState *dev) { -S390CCWDevice *cdev =S390_CCW_DEVICE (dev); -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (dev);ioctl (vcdev->vdev.fd,VFIO_DEVICE_RESET ); }
@@ -656,7 +651,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) {VFIOGroup *group;S390CCWDevice *cdev =S390_CCW_DEVICE (dev); -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);Error *err =NULL ;
@@ -727,7 +722,7 @@ out_err_propagate:static void vfio_ccw_unrealize (DeviceState *dev) {S390CCWDevice *cdev =S390_CCW_DEVICE (dev); -VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +VFIOCCWDevice *vcdev =VFIO_CCW (cdev);S390CCWDeviceClass *cdc =S390_CCW_DEVICE_GET_CLASS (cdev);VFIOGroup *group = vcdev->vdev.group;
Signature · 1 line
2.38.1
Hi Alex,
Quoted 8 lines · Philippe Mathieu-Daudé
QOM housekeeping series which replace the
DO_UPCAST()macro uses by equivalent QOM ones (and few more trivial cleanups).Since v2:
- Split of bigger series
- Split in simpler patches
- Added Eric R-b tags
Quoted 5 lines
v2:
https://lore.kernel.org/qemu-devel/[email protected]/Philippe Mathieu-Daudé (6):
hw/s390x/event-facility: Replace DO_UPCAST(SCLPEvent) by SCLP_EVENT()
Thomas took the first patch,
Quoted 5 lines
hw/vfio/ccw: Simplify using
DEVICE()macro
hw/vfio/ccw: Use intermediate S390CCWDevice variable hw/vfio/ccw: ReplaceDO_UPCAST(S390CCWDevice)byS390_CCW_DEVICE()hw/vfio/ccw: Remove pointless S390CCWDevice variable hw/vfio/ccw: ReplaceDO_UPCAST(VFIOCCWDevice)byVFIO_CCW()
Could you take the other ones via your VFIO tree?
(all patches reviewed).
Thanks,
Phil.
Quoted 19 lines · Philippe Mathieu-Daudé
Hi Alex,
Quoted 8 lines · Philippe Mathieu-Daudé
QOM housekeeping series which replace the
DO_UPCAST()macro uses by equivalent QOM ones (and few more trivial cleanups).Since v2:
- Split of bigger series
- Split in simpler patches
- Added Eric R-b tagsQuoted 5 lines
v2:
https://lore.kernel.org/qemu-devel/[email protected]/Philippe Mathieu-Daudé (6):
hw/s390x/event-facility: ReplaceDO_UPCAST(SCLPEvent)bySCLP_EVENT()Thomas took the first patch,
Quoted 8 lines
Quoted 5 lines
hw/vfio/ccw: Simplify using
DEVICE()macro
hw/vfio/ccw: Use intermediate S390CCWDevice variable hw/vfio/ccw: ReplaceDO_UPCAST(S390CCWDevice)byS390_CCW_DEVICE()hw/vfio/ccw: Remove pointless S390CCWDevice variable hw/vfio/ccw: ReplaceDO_UPCAST(VFIOCCWDevice)byVFIO_CCW()Could you take the other ones via your VFIO tree?
(all patches reviewed).
I've picked the other patches now, too (since they've got a Reviewed-by by one of the vfio-ccw maintainers now).
Thomas
Quoted 7 lines · Thomas Huth
Quoted 4 lines · Philippe Mathieu-Daudé
Hi Alex,
Could you take the other ones via your VFIO tree?
(all patches reviewed).I've picked the other patches now, too (since they've got a Reviewed-by by one of the vfio-ccw maintainers now).
Thank you :)