Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4693560pxj; Tue, 25 May 2021 14:08:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRUlVdFgdDMDVQtS36ZpOBtLjX8p8CDAzsSmUdflZwxZnFntCbkwAS3GxsPEcioqbZ839F X-Received: by 2002:a05:6602:229a:: with SMTP id d26mr21581825iod.201.1621976904310; Tue, 25 May 2021 14:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621976904; cv=none; d=google.com; s=arc-20160816; b=dJMdzu0jTcQjlkW0G9ax7+4Lo1cgr0N0E7LjazW6gfN8AbHd2j/DY3JxzLosx3lfdl IrFVWC1/uUbVJmMu/D1XrxmW9QInaQbT4f53T8lSyVt6nQi0eP8tAVwbnpeKAVR2JqbQ xUuxgy2kmFTLq30gXJW3Zcqx1IDK7AV2adjz3gXYdZp38xb8Lga6mFvpPivBnAtqahf1 WrLpyn2VKjpdzOvJqufmqqrPVRSvF/TqJMVCbkLYdnVn/UMf3K5SjJ+qU2UswJA8d8km AAiuuXW8/q88p4TdbSZNMl8pxjeHox98HV288h3E1fLWdCbXnbTBUz1hlCeQL6U6aLe8 7ABg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=YJaCYdrDxV6hFjr7P9dKxuwmpFAJtjJ9oxxDaSIJ6Go=; b=gXbff12MhnDYpibB0RPO+maPInR6doKi18V/iKTX+GeEY441QE0yDuVw25djpBNJY9 a8vLG8KsIlHEpFTWp5/fu/y2FoguKhqtl91KbzdVJ2y1GXS3PfdgfPfrAUcQb4V1+klR auhyM9pJFwky7XhfDG2o1tORmMnpbkqFOAOd+FTrz0c0Fbh0eUupRd1EiyGLFLS3o8LM 9fTAcKkTTkE3pGd+oikM6Scn55mQhBw/VeLMpoeEbmloHTRj249KL5jQcuG3DIKLrfdv Fl5LteQjUReDF3cL5YoyB9zXu1PiXD0iUOuyMXlABi8Iyan/0nRQaDj3FD27nf7NtAe+ XRvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si17830622ior.12.2021.05.25.14.08.11; Tue, 25 May 2021 14:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbhEYQvL (ORCPT + 99 others); Tue, 25 May 2021 12:51:11 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57513 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbhEYQvK (ORCPT ); Tue, 25 May 2021 12:51:10 -0400 Received: from mail-lj1-f200.google.com ([209.85.208.200]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1llaFP-0002aZ-0v for linux-kernel@vger.kernel.org; Tue, 25 May 2021 16:49:39 +0000 Received: by mail-lj1-f200.google.com with SMTP id o5-20020a05651c0505b02900e5a95dd51eso13653933ljp.10 for ; Tue, 25 May 2021 09:49:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YJaCYdrDxV6hFjr7P9dKxuwmpFAJtjJ9oxxDaSIJ6Go=; b=Xg/Ga6lAqjzBux2PecmmEaB1A1bak5d0XT+fCDspRk291tgZLCZrJRwieGx5XAMjt/ orzq0XhPvNem/INbonuKt/90kC9uW6LBNpcW6HKXPxFxq1lgkLUUAFnma2HAVcbbsAeH MVmuHg0ZwChv7A3ifUoH9Pc5DObnYmHomOyx0settOTDHXMLo8bxrCHO/X0YKJKtDvI7 QkpGr77NDozLpuTf5JgGMjC9JJHlrXT3WaKHCVVOxYHrJue4a3okMpxD6hqePdgPt5zN smkEgHvpsytJA9IKdSD95g9/b9n1cy8AZK2L+nsPXS0j/MlQ82mJXxSRhEMYI/7BC/UX M/Sg== X-Gm-Message-State: AOAM530ojPcysfOWSsCJO4otY+Hf01hfFYgXPjpbOIl6CptaIXbibnmI DxAqI1aMD+I7XNeyiXhXE4H02ymQfmMYNxG6Bm8WsEVxzaKTH+9PZFCGvr/l4CqbJpsoP7cr7uV BMvjJMs0TSR6pjDY64RcoxRBpn+dwX9EVfzpGxFg+sq0TeUrTAqssQUOFQg== X-Received: by 2002:a05:6512:1153:: with SMTP id m19mr8111640lfg.290.1621961378502; Tue, 25 May 2021 09:49:38 -0700 (PDT) X-Received: by 2002:a05:6512:1153:: with SMTP id m19mr8111630lfg.290.1621961378269; Tue, 25 May 2021 09:49:38 -0700 (PDT) MIME-Version: 1.0 References: <20210520033315.490584-1-koba.ko@canonical.com> <20210525074426.GA14916@lst.de> In-Reply-To: <20210525074426.GA14916@lst.de> From: Kai-Heng Feng Date: Wed, 26 May 2021 00:49:26 +0800 Message-ID: Subject: Re: [PATCH] nvme-pci: Avoid to go into d3cold if device can't use npss. To: Christoph Hellwig Cc: Koba Ko , Keith Busch , Jens Axboe , Sagi Grimberg , linux-nvme , LKML , Henrik Juul Hansen , Bjorn Helgaas , Linux PCI Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 3:44 PM Christoph Hellwig wrote: > > On Thu, May 20, 2021 at 11:33:15AM +0800, Koba Ko wrote: > > After resume, host can't change power state of the closed controller > > from D3cold to D0. > > Why? IIUC it's a regression introduced by commit b97120b15ebd ("nvme-pci: use simple suspend when a HMB is enabled"). The affected NVMe is using HMB. That commit intentionally put the device to D3hot instead of D0 on suspend, as the root port of the NVMe device has _PR3, the NVMe was put to D3cold as a result. I believe because the other OS doesn't put the NVMe to D3cold, so turning off the power resource is untested by the vendor. I think the proper fix would be reverting that commit, and teardown/setup DMA on suspend/resume for HMB NVMes. Kai-Heng > > > For these devices, just avoid to go deeper than d3hot. > > What are "these devices"? > > > @@ -2958,6 +2959,15 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > > > dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev)); > > > > + if (pm_suspend_via_firmware() || !dev->ctrl.npss || > > + !pcie_aspm_enabled(pdev) || > > + dev->nr_host_mem_descs || > > + (dev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND)) { > > Before we start open coding this in even more places we really want a > little helper function for these checks, which should be accomodated with > the comment near the existing copy of the checks. > > > + pdev->d3cold_allowed = false; > > + pci_d3cold_disable(pdev); > > + pm_runtime_resume(&pdev->dev); > > Why do we need to both set d3cold_allowed and call pci_d3cold_disable? > > What is the pm_runtime_resume doing here?