From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJokW-00011i-E5 for qemu-devel@nongnu.org; Thu, 14 Jan 2016 15:44:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJokR-0006yl-VD for qemu-devel@nongnu.org; Thu, 14 Jan 2016 15:44:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJokR-0006yg-Nq for qemu-devel@nongnu.org; Thu, 14 Jan 2016 15:43:59 -0500 Message-ID: <1452804236.14628.91.camel@redhat.com> From: Alex Williamson Date: Thu, 14 Jan 2016 13:43:56 -0700 In-Reply-To: <987de86c87935f379e3447212957a50356d17711.1452564770.git.chen.fan.fnst@cn.fujitsu.com> References: <987de86c87935f379e3447212957a50356d17711.1452564770.git.chen.fan.fnst@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin , qemu-devel@nongnu.org Cc: chen.fan.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com, mst@redhat.com On Tue, 2016-01-12 at 10:43 +0800, Cao jin wrote: > From: Chen Fan >=20 > avoid multi-reset host bus, we introduce sequence id to secify which > bus is resetting. and if one of the dependent devices has been do reset= . > the others should skip. >=20 > Signed-off-by: Chen Fan > --- > =C2=A0hw/vfio/pci.c | 15 +++++++++++++++ > =C2=A0hw/vfio/pci.h |=C2=A0=C2=A03 +++ > =C2=A02 files changed, 18 insertions(+) >=20 > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index ff25c9b..da4815e 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -1914,6 +1914,8 @@ static int vfio_check_host_bus_reset(VFIOPCIDevic= e *vdev) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* List all affected devices by bus reset= */ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0devices =3D &info->devices[0]; > =C2=A0 > +=C2=A0=C2=A0=C2=A0=C2=A0vdev->single_depend_dev =3D (info->count =3D=3D= 1); > + > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Verify that we have all the groups req= uired */ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0for (i =3D 0; i < info->count; i++) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PCIHostDeviceAddr= ess host; > @@ -2249,6 +2251,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev= , bool single) > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vfio_pci_pre_reset(vdev); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vdev->vbasedev.needs_reset =3D false; > +=C2=A0=C2=A0=C2=A0=C2=A0vdev->last_bus_reset_seqid =3D 0; > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ret =3D vfio_get_hot_reset_info(vdev, &in= fo); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (ret) { > @@ -2310,6 +2313,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev= , bool single) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vfio_pci_pre_reset(tmp); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0tmp->vbasedev.needs_reset =3D false; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0tmp->last_bus_reset_seqid =3D vdev->pdev.bus->res= et_seqid; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0multi =3D true; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0break; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0} > @@ -3006,6 +3010,17 @@ static void vfio_pci_reset(DeviceState *dev) > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0trace_vfio_pci_reset(vdev->vbasedev.name)= ; > =C2=A0 > +=C2=A0=C2=A0=C2=A0=C2=A0/* if need to do a hot reset */ > +=C2=A0=C2=A0=C2=A0=C2=A0if (pdev->bus->in_reset) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (vdev->last_bus_res= et_seqid =3D=3D pdev->bus->reset_seqid) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= vdev->last_bus_reset_seqid =3D 0; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= return; Why would we ever clear this? =C2=A0You're assuming there will only ever = be one reset callback per device per bus reset. =C2=A0But we really don't ne= ed to make that assumption. > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else if ((vdev->feat= ures & VFIO_FEATURE_ENABLE_AER)) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= vfio_pci_hot_reset(vdev, vdev->single_depend_dev); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= return; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > +=C2=A0=C2=A0=C2=A0=C2=A0} > + > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vfio_pci_pre_reset(vdev); > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (vdev->resetfn && !vdev->resetfn(vdev)= ) { > diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h > index b385f07..728cbb8 100644 > --- a/hw/vfio/pci.h > +++ b/hw/vfio/pci.h > @@ -143,6 +143,9 @@ typedef struct VFIOPCIDevice { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool no_kvm_msi; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool no_kvm_msix; > =C2=A0 > +=C2=A0=C2=A0=C2=A0=C2=A0bool single_depend_dev; > +=C2=A0=C2=A0=C2=A0=C2=A0uint32_t last_bus_reset_seqid; > + > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0NotifierWithReturn hotplug_notifier; > =C2=A0} VFIOPCIDevice; > =C2=A0