Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5946827ybp; Tue, 8 Oct 2019 10:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGjhhEvaAHbNPEYHo89pNL3yUzfsJJfAji2H8KrEs7JEx1uV9fQG+JbP2WbiHpQH7NgpX+ X-Received: by 2002:a17:906:6084:: with SMTP id t4mr29924618ejj.164.1570556056985; Tue, 08 Oct 2019 10:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570556056; cv=none; d=google.com; s=arc-20160816; b=tqnUtLJj0Khz09oIZZC5Oj03jeYMXRxZzxFIYQBOjpnSX81KiZyp9L/IS4/3BHgMfO ZXw57yW5xjRoXuSZyRt1VkrlPSq5NQbP8ck47B7p1EQxICeglBKvlFmEdJHwYA8JKHCD tHYrmcqy3FbLn50rTc77hSxTIsldU+0OjgzW1N2fTw5687xhIgfvQsQdEI9zs8pTrpOq WX+Eynyl1OnB+ol9KpN51HhILgxvjcNjgve0kfFEjK2LHkonIg+G+qXskJZQ28Rlv5kY XBQ4qf5A80D+spKjSaR26FA4PVZZvP1V9kN0YHV1u4OPAvJJJ2mF/loTjh7HjYVpP6en Sj6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=c4hzTMbevYK0rJyT4EN9vWdzJMkcFozd0Qjy03mUt+4=; b=iKvio3u6n57vFNEOEBE33t/eitHzhyvUNPh0aGSace8c6YdW6GIkwEvJu+HMqucFAG hYO1EyTdTuWcUMcyhP9H+Kmcd/5gP5K01ZiKKTi2u21e3W+cEZKPv1b6lhXOwU01fWNV o1wz4OFVQjnsMa7soYa2WrfwAonZz/J6BQm7r1XizBiP+BaX9Umo7JhEQkteEgtadu9A FHwECkgg6NO4+kdFzs87kO9csscLCqpZ1j1xOdB9QICUXqMK4KAsUdEZdWLA0rpLRvHl ByxzTk+pVA2V5cdsEyc1086nTTFiakcjjbTfkHFc97roS2zBDk2O4+WLKM19wwsNmug9 /xww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p36si11057602edc.373.2019.10.08.10.33.53; Tue, 08 Oct 2019 10:34:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbfJHRcd (ORCPT + 99 others); Tue, 8 Oct 2019 13:32:33 -0400 Received: from mga03.intel.com ([134.134.136.65]:64562 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726253AbfJHRcd (ORCPT ); Tue, 8 Oct 2019 13:32:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2019 10:32:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,272,1566889200"; d="scan'208";a="193439247" Received: from rjwysock-mobl1.ger.corp.intel.com (HELO [10.249.147.52]) ([10.249.147.52]) by fmsmga007.fm.intel.com with ESMTP; 08 Oct 2019 10:32:28 -0700 Subject: Re: [PATCH v2] PCI: PM: Move to D0 before calling pci_legacy_resume_early() To: Dexuan Cui , Bjorn Helgaas Cc: "lorenzo.pieralisi@arm.com" , "linux-pci@vger.kernel.org" , Michael Kelley , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Sasha Levin , Haiyang Zhang , KY Srinivasan , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , vkuznets , "marcelo.cerri@canonical.com" , Stephen Hemminger , "jackm@mellanox.com" References: <20191007132414.GA19294@google.com> From: "Rafael J. Wysocki" Organization: Intel Technology Poland Sp. z o. o., KRS 101882, ul. Slowackiego 173, 80-298 Gdansk Message-ID: Date: Tue, 8 Oct 2019 19:32:27 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/7/2019 8:57 PM, Dexuan Cui wrote: >> -----Original Message----- >> From: Bjorn Helgaas >> Sent: Monday, October 7, 2019 6:24 AM >> To: Dexuan Cui >> Cc: lorenzo.pieralisi@arm.com; linux-pci@vger.kernel.org; Michael Kelley >> ; linux-hyperv@vger.kernel.org; >> linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org; Sasha >> Levin ; Haiyang Zhang >> ; KY Srinivasan ; >> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; vkuznets >> ; marcelo.cerri@canonical.com; Stephen Hemminger >> ; jackm@mellanox.com >> Subject: Re: [PATCH v2] PCI: PM: Move to D0 before calling >> pci_legacy_resume_early() >> >> On Wed, Aug 14, 2019 at 01:06:55AM +0000, Dexuan Cui wrote: >>> In pci_legacy_suspend_late(), the device state is moved to PCI_UNKNOWN. >>> >>> In pci_pm_thaw_noirq(), the state is supposed to be moved back to PCI_D0, >>> but the current code misses the pci_legacy_resume_early() path, so the >>> state remains in PCI_UNKNOWN in that path. As a result, in the resume >>> phase of hibernation, this causes an error for the Mellanox VF driver, >>> which fails to enable MSI-X because pci_msi_supported() is false due >>> to dev->current_state != PCI_D0: >>> >>> mlx4_core a6d1:00:02.0: Detected virtual function - running in slave mode >>> mlx4_core a6d1:00:02.0: Sending reset >>> mlx4_core a6d1:00:02.0: Sending vhcr0 >>> mlx4_core a6d1:00:02.0: HCA minimum page size:512 >>> mlx4_core a6d1:00:02.0: Timestamping is not supported in slave mode >>> mlx4_core a6d1:00:02.0: INTx is not supported in multi-function mode, >> aborting >>> PM: dpm_run_callback(): pci_pm_thaw+0x0/0xd7 returns -95 >>> PM: Device a6d1:00:02.0 failed to thaw: error -95 >>> >>> To be more accurate, the "resume" phase means the "thaw" callbacks which >>> run before the system enters hibernation: when the user runs the command >>> "echo disk > /sys/power/state" for hibernation, first the kernel "freezes" >>> all the devices and creates a hibernation image, then the kernel "thaws" >>> the devices including the disk/NIC, writes the memory to the disk, and >>> powers down. This patch fixes the error message for the Mellanox VF driver >>> in this phase. >>> >>> When the system starts again, a fresh kernel starts to run, and when the >>> kernel detects that a hibernation image was saved, the kernel "quiesces" >>> the devices, and then "restores" the devices from the saved image. In this >>> path: >>> device_resume_noirq() -> ... -> >>> pci_pm_restore_noirq() -> >>> pci_pm_default_resume_early() -> >>> pci_power_up() moves the device states back to PCI_D0. This path is >>> not broken and doesn't need my patch. >>> >>> Signed-off-by: Dexuan Cui >> This looks like a bugfix for 5839ee7389e8 ("PCI / PM: Force devices to >> D0 in pci_pm_thaw_noirq()") so maybe it should be marked for stable as >> 5839ee7389e8 was? >> >> Rafael, could you confirm? No, it is not a bug fix for that commit.  The underlying issue would be there without that commit too. >>> --- >>> >>> changes in v2: >>> Updated the changelog with more details. >>> >>> drivers/pci/pci-driver.c | 7 ++++--- >>> 1 file changed, 4 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c >>> index 36dbe960306b..27dfc68db9e7 100644 >>> --- a/drivers/pci/pci-driver.c >>> +++ b/drivers/pci/pci-driver.c >>> @@ -1074,15 +1074,16 @@ static int pci_pm_thaw_noirq(struct device >> *dev) >>> return error; >>> } >>> >>> - if (pci_has_legacy_pm_support(pci_dev)) >>> - return pci_legacy_resume_early(dev); >>> - >>> /* >>> * pci_restore_state() requires the device to be in D0 (because of MSI >>> * restoration among other things), so force it into D0 in case the >>> * driver's "freeze" callbacks put it into a low-power state directly. >>> */ >>> pci_set_power_state(pci_dev, PCI_D0); >>> + >>> + if (pci_has_legacy_pm_support(pci_dev)) >>> + return pci_legacy_resume_early(dev); >>> + >>> pci_restore_state(pci_dev); >>> >>> if (drv && drv->pm && drv->pm->thaw_noirq) >>> -- >>> 2.19.1 >>> The patch looks reasonable to me, but the comment above the pci_set_power_state() call needs to be updated too IMO.