qemu: Adapter interrupts for virtio-ccw.
Subsystems (3)
RFC PATCH v2 1/1 qemu: Adapter interrupts for virtio-ccw.
Hi,
here's the current implementation of virtio-ccw adapter interrupts in qemu.
Code is unchanged, only rebased against current master.
Cornelia Huck (1):
s390/virtio-ccw: Adapter interrupt support.
hw/s390x/css.c | 10 ++++++++ hw/s390x/css.h | 2 ++ hw/s390x/virtio-ccw.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++- hw/s390x/virtio-ccw.h | 4 ++++ target-s390x/ioinst.h | 2 ++ target-s390x/kvm.c | 8 +++++-- trace-events | 1 + 7 files changed, 88 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
RFC PATCH v2 1/1 s390/virtio-ccw: Adapter interrupt support.
Handle the new CCW_CMD_SET_IND_ADAPTER command enabling adapter interrupts on guest request. When active, host->guest notifications will be handled via global_indicator -> queue indicators instead of queue indicators + subchannel I/O interrupt. Indicators for virtqueues may be present at an offset.
--- hw/s390x/css.c | 10 ++++++++ hw/s390x/css.h | 2 ++ hw/s390x/virtio-ccw.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++- hw/s390x/virtio-ccw.h | 4 ++++ target-s390x/ioinst.h | 2 ++ target-s390x/kvm.c | 8 +++++-- trace-events | 1 + 7 files changed, 88 insertions(+), 3 deletions(-)
hw/s390x/css.c +10 -0
@@ -115,6 +115,15 @@ void css_conditional_io_interrupt(SubchDev *sch) } } +void css_adapter_interrupt (uint8_t isc) +{ +S390CPU *cpu =s390_cpu_addr2state (0 ); +uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ; + +trace_css_adapter_interrupt (isc); +s390_io_interrupt (cpu,0 ,0 ,0 , io_int_word); +} +static void sch_handle_clear_func (SubchDev *sch) {PMCW *p = &sch->curr_status.pmcw;
@@ -1256,6 +1265,7 @@ void css_reset_sch(SubchDev *sch) sch->channel_prog =0x0 ; sch->last_cmd_valid = false; sch->orb =NULL ; + sch->thinint_active = false; }void css_reset (void )
hw/s390x/css.h +2 -0
@@ -77,6 +77,7 @@ struct SubchDev {CCW1 last_cmd;bool last_cmd_valid;ORB *orb; +bool thinint_active;/* transport-provided data: */ int (*ccw_cb) (SubchDev *,CCW1 );SenseId id;
@@ -97,4 +98,5 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid);void css_generate_sch_crws (uint8_t cssid,uint8_t ssid,uint16_t schid,int hotplugged,int add);void css_generate_chp_crws (uint8_t cssid,uint8_t chpid); +void css_adapter_interrupt (uint8_t isc);#endif
hw/s390x/virtio-ccw.c +63 -1
112 lines not on this page · raw message
hw/s390x/virtio-ccw.h +4 -0
@@ -38,6 +38,7 @@#define CCW_CMD_SET_IND 0x43#define CCW_CMD_SET_CONF_IND 0x53#define CCW_CMD_READ_VQ_CONF 0x32 +#define CCW_CMD_SET_IND_ADAPTER 0x63#define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device"#define VIRTIO_CCW_DEVICE (obj) \
@@ -84,9 +85,12 @@ struct VirtioCcwDevice {bool ioeventfd_started;bool ioeventfd_disabled;uint32_t flags; +uint8_t thinint_isc;/* Guest provided values: */ hwaddr indicators;hwaddr indicators2; +hwaddr summary_indicator; +uint16_t ind_shift; };/* virtual css bus type */
target-s390x/ioinst.h +2 -0
@@ -212,6 +212,8 @@ typedef struct IOIntCode {#define IO_INT_WORD_ISC (_int_word) ((_int_word & 0x38000000) >> 24)#define ISC_TO_ISC_BITS (_isc) ((0x80 >> _isc) << 24) +#define IO_INT_WORD_AI 0x80000000 +int ioinst_disassemble_sch_ident (uint32_t value,int *m,int *cssid,int *ssid,int *schid);int ioinst_handle_xsch (CPUS390XState *env,uint64_t reg1);
target-s390x/kvm.c +6 -2
@@ -906,8 +906,12 @@ void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id, {uint32_t type; - type = ((subchannel_id &0xff00 ) <<24 ) | - ((subchannel_id &0x00060 ) <<22 ) | (subchannel_nr <<16 ); +if (io_int_word &IO_INT_WORD_AI ) { + type =KVM_S390_INT_IO (1 ,0 ,0 ,0 ); + }else { + type = ((subchannel_id &0xff00 ) <<24 ) | + ((subchannel_id &0x00060 ) <<22 ) | (subchannel_nr <<16 ); + }kvm_s390_interrupt_internal (cpu, type, ((uint32_t )subchannel_id <<16 ) | subchannel_nr, ((uint64_t )io_int_parm <<32 ) | io_int_word,1 );
trace-events +1 -0
@@ -1152,6 +1152,7 @@ css_chpid_add(uint8_t cssid, uint8_t chpid, uint8_t type) "CSS: add chpid %x.%02 css_new_image(uint8_t cssid, const char *default_cssid) "CSS: add css image %02x %s" css_assign_subch(const char *do_assign, uint8_t cssid, uint8_t ssid, uint16_t schid, uint16_t devno) "CSS: %s %x.%x.%04x (devno %04x)" css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t isc, const char *conditional) "CSS: I/O interrupt on sch %x.%x.%04x (intparm %08x, isc %x) %s" +css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc %x)" # hw/s390x/virtio-ccw.c virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) "VIRTIO-CCW: %x.%x.%04x: interpret command %x"
Signature · 1 line
1.7.9.5
Re: [RFC PATCH v2] s390/virtio-ccw: Adapter interrupt support.
Quoted 6 lines · Cornelia Huck
Handle the new
CCW_CMD_SET_IND_ADAPTERcommand enabling adapter interrupts on guest request. When active,host->guestnotifications will be handled viaglobal_indicator-> queue indicators instead of queue indicators + subchannel I/O interrupt. Indicators for virtqueues may be present at an offset.
You might want to add why we want adapter interrupts:
- no test subchannel -> less qemu mutex contention
- no test subchannel -> we can implement something like irqfd without moving most of ccw device mgmt into the kernel
- interrupt coalescing
- the guest common I/O layer already supports adapter interrupts for all newer hardware
the interesting part of this patch is the guest<->host interface. As far as I can see, we are able to register
- an isc per device
- an arbitrary summary indicator byte per device
- an arbitrary bit position in guest memory where the queue indicator bits of this device start
This allows for packing the indicators for all virtqueues of all devices or spreading them in memory. The layout and amount of coalescing of bits is then an optimization that can be changed all the time without the need to change the interface.
Quoted 1 line
Signed-off-by Cornelia Huck <[email protected]>
Re: [RFC PATCH v2] s390/virtio-ccw: Adapter interrupt support.
Quoted 8 lines · On Tue, 09 Jul 2013 15:27:14 +0200 Christian Borntraeger…
Quoted 6 lines · Cornelia Huck
Handle the new
CCW_CMD_SET_IND_ADAPTERcommand enabling adapter interrupts on guest request. When active,host->guestnotifications will be handled viaglobal_indicator-> queue indicators instead of queue indicators + subchannel I/O interrupt. Indicators for virtqueues may be present at an offset.
Quoted 7 lines
You might want to add why we want adapter interrupts:
- no test subchannel -> less qemu mutex contention
- no test subchannel -> we can implement something like irqfd without moving most of ccw device mgmt into the kernel
- interrupt coalescing
- the guest common I/O layer already supports adapter interrupts for all newer hardware
How about the following:
With traditional I/O interrupts, status needs to be collected from the subchannel via TEST SUBCHANNEL as well. With adapter interrupts, we
- avoid the extra exit due to TEST SUBCHANNEL
- can deliver multiple queue interrupts via the same I/O interrupt
- make it possible to implement irqfds without having to track subchannel status inside kvm
Quoted 9 lines
the interesting part of this patch is the guest<->host interface. As far as I can see, we are able to register
- an isc per device
- an arbitrary summary indicator byte per device
- an arbitrary bit position in guest memory where the queue indicator bits of this device start
Quoted 7 lines
This allows for packing the indicators for all virtqueues of all devices or spreading them in memory. The layout and amount of coalescing of bits is then an optimization that can be changed all the time without the need to change the interface.
Quoted 1 line
Signed-off-by Cornelia Huck <[email protected]>
Thx!
Re: [RFC PATCH v2] s390/virtio-ccw: Adapter interrupt support.
In reply to Cornelia HuckQuoted 6 lines · Cornelia Huck
Handle the new
CCW_CMD_SET_IND_ADAPTERcommand enabling adapter interrupts on guest request. When active,host->guestnotifications will be handled viaglobal_indicator-> queue indicators instead of queue indicators + subchannel I/O interrupt. Indicators for virtqueues may be present at an offset.
You might want to add why we want adapter interrupts:
- no test subchannel -> less qemu mutex contention
- no test subchannel -> we can implement something like irqfd without moving most of ccw device mgmt into the kernel
- interrupt coalescing
- the guest common I/O layer already supports adapter interrupts for all newer hardware
the interesting part of this patch is the guest<->host interface. As far as I can see, we are able to register
- an isc per device
- an arbitrary summary indicator byte per device
- an arbitrary bit position in guest memory where the queue indicator bits of this device start
This allows for packing the indicators for all virtqueues of all devices or spreading them in memory. The layout and amount of coalescing of bits is then an optimization that can be changed all the time without the need to change the interface.
Quoted 1 line
Signed-off-by Cornelia Huck <[email protected]>