virtio/s390: get rid of open-coded kvm hypercall
Subsystems (3)
Heiko Carstens
maintainerPATCH 1/1 virtio/s390: get rid of open-coded kvm hypercall
do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(), and get rid of duplicated code.
--- drivers/s390/virtio/virtio_ccw.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
drivers/s390/virtio/virtio_ccw.c +4 -26
@@ -388,31 +388,6 @@ static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,ccw_device_dma_free (vcdev->cdev, thinint_area,sizeof (*thinint_area)); } -static inline long __do_kvm_notify (struct subchannel_id schid, -unsigned long queue_index, -long cookie) -{ - register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY; - register struct subchannel_id __schid asm("2") = schid; - register unsigned long __index asm("3") = queue_index; - registerlong __rc asm("2" ); - register long __cookie asm("4") = cookie; - - asmvolatile ("diag 2,4,0x500\n" - :"=d" (__rc) :"d" (__nr),"d" (__schid),"d" (__index), -"d" (__cookie) - :"memory" ,"cc" ); -return __rc; -} - -static inline long do_kvm_notify (struct subchannel_id schid, -unsigned long queue_index, -long cookie) -{ -diag_stat_inc (DIAG_STAT_X500 ); -return __do_kvm_notify (schid, queue_index, cookie); -} -static bool virtio_ccw_kvm_notify (struct virtqueue *vq) {struct virtio_ccw_vq_info *info = vq->priv;
@@ -421,7 +396,10 @@ static bool virtio_ccw_kvm_notify(struct virtqueue *vq) vcdev =to_vc_device (info->vq->vdev);ccw_device_get_schid (vcdev->cdev, &schid); - info->cookie =do_kvm_notify (schid, vq->index, info->cookie); +BUILD_BUG_ON (sizeof (struct subchannel_id ) !=sizeof (unsigned int )); + info->cookie =kvm_hypercall3 (KVM_S390_VIRTIO_CCW_NOTIFY , + *((unsigned int *)&schid), + vq->index, info->cookie);if (info->cookie <0 )return false;return true;
Signature · 1 line
2.25.1
Quoted 9 lines · Heiko Carstens
do_kvm_notify()and__do_kvm_notify()are an (exact) open-coded variant ofkvm_hypercall3(). Therefore simply make use ofkvm_hypercall3(), and get rid of duplicated code.Signed-off-by Heiko Carstens <[email protected]>--- drivers/s390/virtio/virtio_ccw.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
Hm, I wonder why I didn't use kvm_hypercall3 in the first place. It's in a header, and therefore should be independent of kvm being configured.
I don't think there's anything else virtio-ccw in flight at the moment, so maybe you can apply this one directly?
Heiko Carstens
maintainerQuoted 12 lines · Cornelia Huck
Quoted 9 lines · Heiko Carstens
do_kvm_notify()and__do_kvm_notify()are an (exact) open-coded variant ofkvm_hypercall3(). Therefore simply make use ofkvm_hypercall3(), and get rid of duplicated code.Signed-off-by Heiko Carstens <[email protected]>--- drivers/s390/virtio/virtio_ccw.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
Quoted 5 lines
Hm, I wonder why I didn't use
kvm_hypercall3in the first place. It's in a header, and therefore should be independent of kvm being configured.I don't think there's anything else virtio-ccw in flight at the moment, so maybe you can apply this one directly?
Yes, sure.
Quoted 1 line
Reviewed-by Cornelia Huck <[email protected]>
Thank you!
Quoted 8 lines · Heiko Carstens
do_kvm_notify()and__do_kvm_notify()are an (exact) open-coded variant ofkvm_hypercall3(). Therefore simply make use ofkvm_hypercall3(), and get rid of duplicated code.Signed-off-by Heiko Carstens <[email protected]>--- drivers/s390/virtio/virtio_ccw.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
Certainly a nice improvement in terms of LOCs.
Quoted 37 lines
drivers/s390/virtio/virtio_ccw.c +0
-25@@ -388,31 +388,6 @@ static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,ccw_device_dma_free (vcdev->cdev, thinint_area,sizeof (*thinint_area)); } -static inline long __do_kvm_notify (struct subchannel_id schid, -unsigned long queue_index, -long cookie) -{ - register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY; - register struct subchannel_id __schid asm("2") = schid; - register unsigned long __index asm("3") = queue_index; - registerlong __rc asm("2" ); - register long __cookie asm("4") = cookie; - - asmvolatile ("diag 2,4,0x500\n" - :"=d" (__rc) :"d" (__nr),"d" (__schid),"d" (__index), -"d" (__cookie) - :"memory" ,"cc" ); -return __rc; -} - -static inline long do_kvm_notify (struct subchannel_id schid, -unsigned long queue_index, -long cookie) -{ -diag_stat_inc (DIAG_STAT_X500 ); -return __do_kvm_notify (schid, queue_index, cookie); -} -static bool virtio_ccw_kvm_notify (struct virtqueue *vq) {struct virtio_ccw_vq_info *info = vq->priv;
drivers/s390/virtio/virtio_ccw.c static bool virtio_ccw_kvm_notify(struct virtqueue *vq) · line 402
Quoted 8 lines
drivers/s390/virtio/virtio_ccw.c +4
-1@@ -421,7 +396,10 @@ static bool virtio_ccw_kvm_notify(struct virtqueue *vq) vcdev =to_vc_device (info->vq->vdev);ccw_device_get_schid (vcdev->cdev, &schid); - info->cookie =do_kvm_notify (schid, vq->index, info->cookie); +BUILD_BUG_ON (sizeof (struct subchannel_id ) !=sizeof (unsigned int )); + info->cookie =kvm_hypercall3 (KVM_S390_VIRTIO_CCW_NOTIFY , + *((unsigned int *)&schid), + vq->index, info->cookie);
if (info->cookie < 0)
Quoted 3 lines
drivers/s390/virtio/virtio_ccw.c +0
-0return false;return true;
Quoted 5 lines · On Mon, 21 Jun 2021 16:45:22 +0200 Heiko Carstens <[email protected]> wrote:
do_kvm_notify()and__do_kvm_notify()are an (exact) open-coded variant ofkvm_hypercall3(). Therefore simply make use ofkvm_hypercall3(), and get rid of duplicated code.Signed-off-by Heiko Carstens <[email protected]>