From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLTeh-00072i-9T for qemu-devel@nongnu.org; Tue, 19 Jan 2016 05:37:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLTeG-0007Ya-1D for qemu-devel@nongnu.org; Tue, 19 Jan 2016 05:36:55 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLTeF-0007XJ-M0 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 05:36:27 -0500 Received: by mail-wm0-x241.google.com with SMTP id b14so22343093wmb.1 for ; Tue, 19 Jan 2016 02:36:27 -0800 (PST) References: <1453138550-1096-1-git-send-email-leonid.bloch@ravellosystems.com> <1453138550-1096-3-git-send-email-leonid.bloch@ravellosystems.com> From: Marcel Apfelbaum Message-ID: <569E11A8.7050200@gmail.com> Date: Tue, 19 Jan 2016 12:36:24 +0200 MIME-Version: 1.0 In-Reply-To: <1453138550-1096-3-git-send-email-leonid.bloch@ravellosystems.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2 02/10] pci: Introduce function for PCI PM capability creation Reply-To: marcel@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leonid Bloch , qemu-devel@nongnu.org Cc: Dmitry Fleytman , Jason Wang , Leonid Bloch , Shmulik Ladkani , "Michael S. Tsirkin" On 01/18/2016 07:35 PM, Leonid Bloch wrote: > From: Dmitry Fleytman > > Signed-off-by: Dmitry Fleytman > Signed-off-by: Leonid Bloch > --- > hw/pci/pci.c | 21 +++++++++++++++++++++ > include/hw/pci/pci.h | 2 ++ > include/hw/pci/pci_regs.h | 1 + > 3 files changed, 24 insertions(+) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index b3d5100..3aaf86c 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -2050,6 +2050,27 @@ static void pci_del_option_rom(PCIDevice *pdev) > pdev->has_rom = false; > } > > +int pci_add_pm_capability(PCIDevice *pdev, uint8_t offset, uint16_t pmc) > +{ > + int ret = pci_add_capability(pdev, PCI_CAP_ID_PM, offset, PCI_PM_SIZEOF); > + > + if (ret >= 0) { > + pci_set_word(pdev->config + offset + PCI_PM_PMC, > + PCI_PM_CAP_VER_1_1 | Hi, Why not ver 1.2 ? just wondering > + pmc); > + > + pci_set_word(pdev->wmask + offset + PCI_PM_CTRL, > + PCI_PM_CTRL_STATE_MASK | > + PCI_PM_CTRL_PME_ENABLE | PME_ENABLE and PME_STATUS are writable only if the function supports PME# generation from D3cold > + PCI_PM_CTRL_DATA_SEL_MASK And Data_Select is writable only if the data register is implemented. My point is this seems to be a standard capability function, but it depends on optional function features. Thanks, Marcel ); > + > + pci_set_word(pdev->w1cmask + offset + PCI_PM_CTRL, > + PCI_PM_CTRL_PME_STATUS); > + } > + > + return ret; > +} > + > /* > * if !offset > * Reserve space and add capability to the linked list in pci config space > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > index b97c295..cec7234 100644 > --- a/include/hw/pci/pci.h > +++ b/include/hw/pci/pci.h > @@ -319,6 +319,8 @@ int pci_add_capability2(PCIDevice *pdev, uint8_t cap_id, > uint8_t offset, uint8_t size, > Error **errp); > > +int pci_add_pm_capability(PCIDevice *pdev, uint8_t offset, uint16_t pmc); > + > void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size); > > uint8_t pci_find_capability(PCIDevice *pci_dev, uint8_t cap_id); > diff --git a/include/hw/pci/pci_regs.h b/include/hw/pci/pci_regs.h > index 56a404b..2bd3ac9 100644 > --- a/include/hw/pci/pci_regs.h > +++ b/include/hw/pci/pci_regs.h > @@ -221,6 +221,7 @@ > > #define PCI_PM_PMC 2 /* PM Capabilities Register */ > #define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ > +#define PCI_PM_CAP_VER_1_1 0x0002 /* PCI PM spec ver. 1.1 */ > #define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ > #define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ > #define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ >