From 39aa4e94ed78e1d767cda4e241b0fe761b395246 Mon Sep 17 00:00:00 2001 From: sf Date: Thu, 14 Jul 2016 12:42:00 +0000 Subject: [PATCH] virtio: Move interrupt handler into transport specific code For MSI-X (and also possibly for other transports), the interrupt handler must do different things. Move it out of virtio.c and into virtio_pci. ARM part tested by patrick@ --- sys/arch/armv7/vexpress/virtio_mmio.c | 7 +++---- sys/dev/pci/if_vio.c | 3 +-- sys/dev/pci/vioblk.c | 3 +-- sys/dev/pci/viomb.c | 3 +-- sys/dev/pci/viornd.c | 3 +-- sys/dev/pci/vioscsi.c | 3 +-- sys/dev/pci/virtio.c | 8 +++----- sys/dev/pci/virtio_pci.c | 8 ++++---- sys/dev/pci/virtiovar.h | 6 ++---- 9 files changed, 17 insertions(+), 27 deletions(-) diff --git a/sys/arch/armv7/vexpress/virtio_mmio.c b/sys/arch/armv7/vexpress/virtio_mmio.c index bee1b5ffe97..99e3384c426 100644 --- a/sys/arch/armv7/vexpress/virtio_mmio.c +++ b/sys/arch/armv7/vexpress/virtio_mmio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio_mmio.c,v 1.2 2016/04/24 00:57:23 patrick Exp $ */ +/* $OpenBSD: virtio_mmio.c,v 1.3 2016/07/14 12:42:00 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -465,9 +465,8 @@ virtio_mmio_intr(void *arg) if ((isr & VIRTIO_MMIO_INT_CONFIG) && (vsc->sc_config_change != NULL)) r = (vsc->sc_config_change)(vsc); - if ((isr & VIRTIO_MMIO_INT_VRING) && - (vsc->sc_intrhand != NULL)) - r |= (vsc->sc_intrhand)(vsc); + if ((isr & VIRTIO_MMIO_INT_VRING)) + r |= virtio_check_vqs(vsc); return r; } diff --git a/sys/dev/pci/if_vio.c b/sys/dev/pci/if_vio.c index f37f760fce1..97af2a2f2bc 100644 --- a/sys/dev/pci/if_vio.c +++ b/sys/dev/pci/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.41 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_vio.c,v 1.42 2016/07/14 12:42:00 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -521,7 +521,6 @@ vio_attach(struct device *parent, struct device *self, void *aux) vsc->sc_ipl = IPL_NET; vsc->sc_vqs = &sc->sc_vq[0]; vsc->sc_config_change = 0; - vsc->sc_intrhand = virtio_vq_intr; features = VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_NET_F_CTRL_VQ | VIRTIO_NET_F_CTRL_RX | diff --git a/sys/dev/pci/vioblk.c b/sys/dev/pci/vioblk.c index cda99ac3542..24cd1c776bf 100644 --- a/sys/dev/pci/vioblk.c +++ b/sys/dev/pci/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.9 2015/12/05 19:57:03 sf Exp $ */ +/* $OpenBSD: vioblk.c,v 1.10 2016/07/14 12:42:00 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -168,7 +168,6 @@ vioblk_attach(struct device *parent, struct device *self, void *aux) panic("already attached to something else"); vsc->sc_child = self; vsc->sc_ipl = IPL_BIO; - vsc->sc_intrhand = virtio_vq_intr; sc->sc_virtio = vsc; features = virtio_negotiate_features(vsc, diff --git a/sys/dev/pci/viomb.c b/sys/dev/pci/viomb.c index 92b1a73389c..4b3bc1f5776 100644 --- a/sys/dev/pci/viomb.c +++ b/sys/dev/pci/viomb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viomb.c,v 1.14 2015/06/11 04:38:23 jsg Exp $ */ +/* $OpenBSD: viomb.c,v 1.15 2016/07/14 12:42:00 sf Exp $ */ /* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -156,7 +156,6 @@ viomb_attach(struct device *parent, struct device *self, void *aux) vsc->sc_child = self; vsc->sc_ipl = IPL_BIO; vsc->sc_config_change = viomb_config_change; - vsc->sc_intrhand = virtio_vq_intr; /* negotiate features */ features = VIRTIO_F_RING_INDIRECT_DESC; diff --git a/sys/dev/pci/viornd.c b/sys/dev/pci/viornd.c index 28cf1af9320..c16fa5f7180 100644 --- a/sys/dev/pci/viornd.c +++ b/sys/dev/pci/viornd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viornd.c,v 1.2 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: viornd.c,v 1.3 2016/07/14 12:42:00 sf Exp $ */ /* * Copyright (c) 2014 Stefan Fritsch @@ -94,7 +94,6 @@ viornd_attach(struct device *parent, struct device *self, void *aux) panic("already attached to something else"); vsc->sc_child = self; vsc->sc_ipl = IPL_NET; - vsc->sc_intrhand = virtio_vq_intr; sc->sc_virtio = vsc; virtio_negotiate_features(vsc, 0, NULL); diff --git a/sys/dev/pci/vioscsi.c b/sys/dev/pci/vioscsi.c index 5008c5c2724..2b5db4264d8 100644 --- a/sys/dev/pci/vioscsi.c +++ b/sys/dev/pci/vioscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: vioscsi.c,v 1.4 2016/07/14 12:42:00 sf Exp $ */ /* * Copyright (c) 2013 Google Inc. * @@ -112,7 +112,6 @@ vioscsi_attach(struct device *parent, struct device *self, void *aux) } vsc->sc_child = &sc->sc_dev; vsc->sc_ipl = IPL_BIO; - vsc->sc_intrhand = virtio_vq_intr; // TODO(matthew): Negotiate hotplug. diff --git a/sys/dev/pci/virtio.c b/sys/dev/pci/virtio.c index 41f5606e746..e560b2a4552 100644 --- a/sys/dev/pci/virtio.c +++ b/sys/dev/pci/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.18 2015/12/05 19:40:34 sf Exp $ */ +/* $OpenBSD: virtio.c,v 1.19 2016/07/14 12:42:00 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -206,15 +206,13 @@ vq_sync_indirect(struct virtio_softc *sc, struct virtqueue *vq, int slot, sizeof(struct vring_desc) * vq->vq_maxnsegs, ops); } -/* - * Can be used as sc_intrhand. - */ /* * Scan vq, bus_dmamap_sync for the vqs (not for the payload), * and calls (*vq_done)() if some entries are consumed. + * For use in transport specific irq handlers. */ int -virtio_vq_intr(struct virtio_softc *sc) +virtio_check_vqs(struct virtio_softc *sc) { struct virtqueue *vq; int i, r = 0; diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c index 489a4493c2e..909f79ef954 100644 --- a/sys/dev/pci/virtio_pci.c +++ b/sys/dev/pci/virtio_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio_pci.c,v 1.12 2015/11/15 16:00:15 deraadt Exp $ */ +/* $OpenBSD: virtio_pci.c,v 1.13 2016/07/14 12:42:00 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -403,10 +403,10 @@ virtio_pci_intr(void *arg) return 0; KERNEL_LOCK(); if ((isr & VIRTIO_CONFIG_ISR_CONFIG_CHANGE) && - (vsc->sc_config_change != NULL)) + (vsc->sc_config_change != NULL)) { r = (vsc->sc_config_change)(vsc); - if (vsc->sc_intrhand != NULL) - r |= (vsc->sc_intrhand)(vsc); + } + r |= virtio_check_vqs(vsc); KERNEL_UNLOCK(); return r; diff --git a/sys/dev/pci/virtiovar.h b/sys/dev/pci/virtiovar.h index c41c263b4be..4a817bc2b23 100644 --- a/sys/dev/pci/virtiovar.h +++ b/sys/dev/pci/virtiovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtiovar.h,v 1.6 2015/12/05 19:40:34 sf Exp $ */ +/* $OpenBSD: virtiovar.h,v 1.7 2016/07/14 12:42:00 sf Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -172,8 +172,6 @@ struct virtio_softc { */ int (*sc_config_change)(struct virtio_softc*); /* set by child */ - int (*sc_intrhand)(struct virtio_softc*); - /* set by child */ }; /* public interface */ @@ -210,7 +208,7 @@ int virtio_dequeue(struct virtio_softc*, struct virtqueue*, int *, int *); int virtio_dequeue_commit(struct virtqueue*, int); int virtio_intr(void *arg); -int virtio_vq_intr(struct virtio_softc *); +int virtio_check_vqs(struct virtio_softc *); void virtio_stop_vq_intr(struct virtio_softc *, struct virtqueue *); int virtio_start_vq_intr(struct virtio_softc *, struct virtqueue *); -- 2.20.1