From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBg5G-0008Ih-DE for qemu-devel@nongnu.org; Thu, 15 Jan 2015 03:47:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBg5B-00053W-Hq for qemu-devel@nongnu.org; Thu, 15 Jan 2015 03:47:18 -0500 Received: from [59.151.112.132] (port=9942 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBg5B-00053O-5Y for qemu-devel@nongnu.org; Thu, 15 Jan 2015 03:47:13 -0500 Message-ID: <54B77D0C.9060802@cn.fujitsu.com> Date: Thu, 15 Jan 2015 16:40:44 +0800 From: Chen Fan MIME-Version: 1.0 References: <1e75bc42628775555cabe140c8438af0093d4ead.1421028274.git.chen.fan.fnst@cn.fujitsu.com> <1421076367.6130.13.camel@redhat.com> In-Reply-To: <1421076367.6130.13.camel@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 3/4] vfio-pci: add aer capability support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: qemu-devel@nongnu.org On 01/12/2015 11:26 PM, Alex Williamson wrote: > On Mon, 2015-01-12 at 11:04 +0800, Chen Fan wrote: > > This patch isn't trivial enough for a blank commit log. Why do we need > to make those bits emulated? Do we only care about AER for now? I think the vfio extend capabilities control registers should be manipulated by qemu self. BTW, it is guest driver's responsibility to set PCI_EXP_DEVCTL bits, right? so here only need to initialize configration sapces and set corresponding bits attributes. I will change it in my next version patches. I think AER is a good start. Thanks, Chen > >> Signed-off-by: Chen Fan >> --- >> hw/vfio/pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 40 insertions(+) >> >> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c >> index b4e73d1..0ee6326 100644 >> --- a/hw/vfio/pci.c >> +++ b/hw/vfio/pci.c >> @@ -2667,6 +2667,41 @@ static int vfio_add_capabilities(VFIOPCIDevice *vdev) >> return vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST]); >> } >> >> +static int vfio_add_ext_capabilities(VFIOPCIDevice *vdev) >> +{ >> + PCIDevice *pdev = &vdev->pdev; >> + PCIExpressDevice *exp; >> + uint32_t header; >> + uint16_t next = PCI_CONFIG_SPACE_SIZE; >> + >> + if (pci_config_size(pdev) <= PCI_CONFIG_SPACE_SIZE) { >> + return 0; >> + } >> + >> + header = pci_get_long(pdev->config + next); >> + while (header) { >> + switch (PCI_EXT_CAP_ID(header)) { >> + case PCI_EXT_CAP_ID_ERR: >> + exp = &pdev->exp; >> + exp->aer_cap = next; >> + >> + /* enable the error report */ >> + vfio_add_emulated_long(vdev, exp->exp_cap + PCI_EXP_DEVCTL, >> + PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | >> + PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE, ~0); >> + break; >> + }; >> + >> + next = PCI_EXT_CAP_NEXT(header); >> + if (!next) { >> + return 0; >> + } >> + header = pci_get_long(pdev->config + next); >> + } >> + >> + return 0; >> +} >> + >> static void vfio_pci_pre_reset(VFIOPCIDevice *vdev) >> { >> PCIDevice *pdev = &vdev->pdev; >> @@ -3293,6 +3328,11 @@ static int vfio_initfn(PCIDevice *pdev) >> goto out_teardown; >> } >> >> + ret = vfio_add_ext_capabilities(vdev); >> + if (ret) { >> + goto out_teardown; >> + } >> + >> /* QEMU emulates all of MSI & MSIX */ >> if (pdev->cap_present & QEMU_PCI_CAP_MSIX) { >> memset(vdev->emulated_config_bits + pdev->msix_cap, 0xff, > > > . >