From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv4km-0000BT-TE for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:50:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bv4kh-0005KD-Qm for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:50:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv4kh-0005Jw-K3 for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:50:31 -0400 Date: Fri, 14 Oct 2016 09:50:30 -0600 From: Alex Williamson Message-ID: <20161014095030.1c7c93c7@t450s.home> In-Reply-To: <1476443819-10347-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1476443819-10347-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vfio: fix duplicate function call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin Cc: qemu-devel@nongnu.org On Fri, 14 Oct 2016 19:16:59 +0800 Cao jin wrote: > When vfio device is reset(encounter FLR, or bus reset), if need to do > bus reset(vfio_pci_hot_reset_one is called), vfio_pci_pre_reset & > vfio_pci_post_reset will be called twice. > > Signed-off-by: Cao jin > --- > Also has a little question on vfio_pci_reset. it will be called when encounter > bus reset, or FLR. The reset method's priority in this function now is: > > 1. If has "device specific reset function", then do it > 2. If has FLR, then do it. > 3. If it can do bus reset(only 1 affected device), then do it > 4. If has pm_reset, then do it > > The question is: why pm reset has low priority than bus reset(if it does > can do a bus reset)? why bus reset is not the last choice? In PCI driver > of kernel, pls see __pci_dev_reset, we can see, if device support pm reset, > it won't do bus reset. The PCI spec doesn't really define what sort of reset is done with a PM reset. My thinking was that if a device advertises an FLR capability then the hardware has made a concerted effort to have a per function reset mechanism available. NoSoftRst- is not terribly common and it's not entirely clear to me that the hardware has made a conscious effort to provide this for the purposes of per function reset mechanism. Therefore I've opt'd to prioritize a bus reset over a PM reset. > hw/vfio/pci.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index cce3024..ca4d1c1 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -1930,7 +1930,9 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) > > trace_vfio_pci_hot_reset(vdev->vbasedev.name, single ? "one" : "multi"); > > - vfio_pci_pre_reset(vdev); > + if (!single) { > + vfio_pci_pre_reset(vdev); > + } > vdev->vbasedev.needs_reset = false; > > info = g_malloc0(sizeof(*info)); > @@ -2088,7 +2090,9 @@ out: > } > } > out_single: > - vfio_pci_post_reset(vdev); > + if (!single) { > + vfio_pci_post_reset(vdev); > + } > g_free(info); > > return ret; Looks ok to me, I'll queue it. Thanks, Alex