From patchwork Wed May 18 13:19:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 12853654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD2FDC433FE for ; Wed, 18 May 2022 13:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237638AbiERNTe (ORCPT ); Wed, 18 May 2022 09:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237631AbiERNTd (ORCPT ); Wed, 18 May 2022 09:19:33 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3998E1157C7 for ; Wed, 18 May 2022 06:19:32 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id x143so2097860pfc.11 for ; Wed, 18 May 2022 06:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lKZB/6RoNEosL1ZhhmdbCbJfaDZXTaYhcWk4wRoTqMQ=; b=TiZdooj/E3kGV+m+IxCHD//i1RFktljM4yI8thLxPLyttdCBD2pBRVy7gdWTxNfkdY MIjn5bmaUDce3ZkI4A8aN4Pdl+3MRqua4jF5FHfFXsiofGpZwDYiLJyNSNsdqMKrLAVm /qYtqby/etpEIQQub4ftdleYWh+d3048sBGe63NY9+ficUbuADiprl137BLlintNcq2v A802YuD/nvdQCEodGIgt2Lxdd6aAO90Penhum1XMmJXCCci0/hwAK1evFeqpxOh1mky1 3We60ppHBCx+SUjtjg30CX6iBDLw3IwowCK+TuqDKyOR9GjLaPqG8eIZHAjHkbVmW5D/ PhbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lKZB/6RoNEosL1ZhhmdbCbJfaDZXTaYhcWk4wRoTqMQ=; b=NXY79mQeX42MbJBSIrSeIpJvsT/6Gl7Z9MABZ61641a/K1nidsnhPuKhmE40PvGSiF ZVMhcrrT2INNKhWgVVtNeB+LiW/GMsNuQz9em0ohQlZ1TjBkRidCU2SdRM6CuKh5MuWS KLIDoV0jvwVXDSGE8Du9ZCQ9D4wV4UUj+lU6kTVIK3H8LwyFP/ufE8EcC1+yTT015ntp MVEDgWspBPzOJ91DfwmymkVNP7Q7d6fUOUndqaRfRXwds3gwb7aAIfDgf3nbx/khYLbR u7DopQx9/gMltGp22CTqe3wckFsPSyo9lXrbewlvHutaFNjGkKj5O+8kXhDzGNaDX/Sf 4V9Q== X-Gm-Message-State: AOAM530csd6ANhMesuxiIaaiJSlr5EgjPQA8B3s9pCPYX6QhNW9oBjIO Azcwk0m9Kv8eLcwJtJedGv9x X-Google-Smtp-Source: ABdhPJzzQNNyHE5cV8P7ycPwOWKLxudFG57eELbtV3RDyDz7x8L67cxSujGCQ0pczbQTtKmXHHLCpg== X-Received: by 2002:a05:6a00:f8b:b0:518:137a:112c with SMTP id ct11-20020a056a000f8b00b00518137a112cmr5629794pfb.8.1652879971672; Wed, 18 May 2022 06:19:31 -0700 (PDT) Received: from localhost.localdomain ([117.217.181.192]) by smtp.gmail.com with ESMTPSA id b5-20020a170903228500b0015e8d4eb27esm1663908plh.200.2022.05.18.06.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 06:19:31 -0700 (PDT) From: Manivannan Sadhasivam To: bhelgaas@google.com, lorenzo.pieralisi@arm.com, kbusch@kernel.org, hch@lst.de Cc: linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, svarbanov@mm-sol.com, bjorn.andersson@linaro.org, axboe@fb.com, quic_vbadigan@quicinc.com, quic_krichai@quicinc.com, quic_nitirawa@quicinc.com, vidyas@nvidia.com, sagi@grimberg.me, linux-pm@vger.kernel.org, rafael@kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 0/3] PCI: Notify PCI drivers about powerdown during suspend Date: Wed, 18 May 2022 18:49:10 +0530 Message-Id: <20220518131913.26974-1-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hi, This series adds support for notifying the PCI drivers like NVMe about the transition of PCI devices into powerdown mode during system suspend. Background ---------- On Qcom SC7280 based Chrome platforms, the RPMh will turn off the power to all PCIe devices during system suspend for aggressive powersaving. Currently, there is no way for the PCI device drivers to learn about this situation. Some of the drivers assume that the power will be retained and some others assume that the power may be taken down. We faced the issue with NVMe PCI driver, where the driver expects the NVMe device to be in APST (Autonomous Power State Transition) state for power saving during system suspend. So when the power goes down, the NVMe driver fails to bringup the device during resume. Previous work ------------- We tried to fix this issue in a couple of ways: 1. The NVMe PCI driver checks for the existence of "StorageD3Enable" ACPI property in the suspend path. If the property is found, the driver assumes that the device may go to poweroff state and shutdowns the device accordingly. As like the ACPI based systems, we also tried to get the support in place for DT based systems. But that didn't get accepted: https://lore.kernel.org/all/Yl+6V3pWuyRYuVV8@infradead.org/T/ 2. Keith Busch proposed a module params based approach. The parameter when set, will allow the driver to support APST during suspend. Absence of that parameter will let the driver shutdown the device. This also did not get accepted: https://lore.kernel.org/linux-nvme/20220201165006.3074615-1-kbusch@kernel.org/ Proposal -------- Christoph suggested to add a notification in the PCI/PM core to let the NVMe driver know that the device will go into powerdown state during suspend. https://lore.kernel.org/all/Yg0wklcJ3ed76Jbk@infradead.org/ Hence in this series, a "suspend_poweroff" flag is introduced in the host bridge struct. When this flag is set by the PCI RC drivers, the PCI device driver like NVMe can shutdown the device during suspend. In the coming days, the usage of this flag could be extended to other PCI drivers as well. In this series, the system suspend/resume support is also added to the Qcom PCIe RC driver for SC7280. During the suspend time, the RC driver will put the device into D3cold and recover it during resume. So even though RPMh is cutting off the power to PCIe domain, it is necessary to put the device in D3cold by the PCIe RC driver for proper working. Testing ------- This series has been tested on SC7280 IDP board connected to a NVMe PCI device. Thanks, Mani Manivannan Sadhasivam (2): PCI: Add a flag to notify PCI drivers about powerdown during suspend nvme-pci: Make use of "suspend_poweroff" flag during system suspend Prasad Malisetty (1): PCI: qcom: Add system PM support drivers/nvme/host/pci.c | 3 +- drivers/pci/controller/dwc/pcie-qcom.c | 108 +++++++++++++++++++++++++ include/linux/pci.h | 2 + 3 files changed, 112 insertions(+), 1 deletion(-)