From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751169AbdEaMno (ORCPT ); Wed, 31 May 2017 08:43:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55776 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbdEaMnm (ORCPT ); Wed, 31 May 2017 08:43:42 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0C8214E4F3 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=alex.williamson@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0C8214E4F3 Date: Wed, 31 May 2017 06:43:40 -0600 From: Alex Williamson To: Geetha sowjanya Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, jcm@redhat.com, sgoutham@cavium.com, geethasowjanya.akula@gmail.com, robert.richter@cavium.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] PCI/PM: Set D3 power state only if the end device supports it. Message-ID: <20170531064340.0dcec477@w520.home> In-Reply-To: <1496230412-19028-1-git-send-email-gakula@caviumnetworks.com> References: <1496230412-19028-1-git-send-email-gakula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 12:43:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 May 2017 17:03:32 +0530 Geetha sowjanya wrote: > Pci driver doesn't check if the device supports D3hot/D3cold power states > while setting these power states. The device that doesn't support these > states will fail when a driver like vfio try to do D0->D3 power transition. That's because support for D0 and D3 device states is REQUIRED by the PCIe spec (Rev 3.1a, 7.6). Is this yet more non-spec compliance? Thanks, Alex > This patch adds a check that allows to set D3 power state only > for the supported devices. > > Signed-off-by: Geetha sowjanya > --- > drivers/pci/pci.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 563901c..cadd046 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -661,7 +661,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) > > /* check if this device supports the desired state */ > if ((state == PCI_D1 && !dev->d1_support) > - || (state == PCI_D2 && !dev->d2_support)) > + || (state == PCI_D2 && !dev->d2_support) > + || (state == PCI_D3hot && !pci_pme_capable(dev, state))) > return -EIO; > > pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);