From: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: "Jingoo Han" <jingoohan1@gmail.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Will Deacon" <will@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, jonathanh@nvidia.com
Subject: Re: [PATCH 1/3] PCI: host-common: Add shared D3cold eligibility helper for host bridges
Date: Thu, 29 Jan 2026 11:08:57 +0530 [thread overview]
Message-ID: <832e8ea4-2b85-4513-a285-9d4ab1dd66b0@oss.qualcomm.com> (raw)
In-Reply-To: <kztudduots342zz7gnx3twtlvjm5pd7sde627zxcsbe6c2imqk@7mmp7vjght5j>
On 1/28/2026 7:56 PM, Bjorn Andersson wrote:
> On Wed, Jan 28, 2026 at 05:10:41PM +0530, Krishna Chaitanya Chundru wrote:
>> Add a common helper, pci_host_common_can_enter_d3cold(), to determine
>> whether a PCI host bridge can safely transition to D3cold.
> Please read https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
>
> It clearly says that you're supposed to start your commit message with a
> description of the problem you're solving. In fact, even after reading
> the entire commit message a few times I only know what the patch does,
> but it's not clear to me why this patch exists.
>
>> The helper walks all devices on the bridge's bus and only allows the
>> host bridge to enter D3cold if all PCIe endpoints are already in
>> PCI_D3hot.
> The code below does walk the bus, but it doesn't allow/disallow anything
> as far as I can tell, it queries their type, state, and if they are wake
> capable?
>
>> For devices that may wake the system, it additionally
>> requires that the device supports PME wakeup from D3cold(with WAKE#).
>> Devices without wakeup enabled are not restricted by this check and can
>> be allowed to keep device in D3cold.
>>
> Again, this code doesn't perform any action, it doesn't
> allow/disallow/restrict the devices from doing anything, it merely
> queries a bunch of things across all devices, and the commit message
> fails to capture why this is useful.
This is a helper function used by controller drivers, to know if the
controller
driver can keep in D3cold state or not. we use endpoint states and their
wakeup
capability support to determine d3cold can be supported or not. The
return value
of this function will tell controller drivers to know if we can allow
D3cold or not.
>> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
>> ---
>> drivers/pci/controller/pci-host-common.c | 29 +++++++++++++++++++++++++++++
>> drivers/pci/controller/pci-host-common.h | 2 ++
>> 2 files changed, 31 insertions(+)
>>
>> diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
>> index c473e7c03bacad2de07c798768f99652443431e0..225472c5ac82c6c5b44257d68a0fc503ec046ff1 100644
>> --- a/drivers/pci/controller/pci-host-common.c
>> +++ b/drivers/pci/controller/pci-host-common.c
>> @@ -106,5 +106,34 @@ void pci_host_common_remove(struct platform_device *pdev)
>> }
>> EXPORT_SYMBOL_GPL(pci_host_common_remove);
>>
>> +static int pci_host_common_check_d3cold(struct pci_dev *pdev, void *userdata)
>> +{
>> + bool *d3cold_allow = userdata;
>> +
>> + if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ENDPOINT)
>> + return 0;
>> +
>> + if (pdev->current_state != PCI_D3hot)
>> + goto exit;
>> +
>> + if (device_may_wakeup(&pdev->dev) && !pci_pme_capable(pdev, PCI_D3cold))
>> + goto exit;
>> +
>> + return 0;
>> +exit:
>> + *d3cold_allow = false;
>> + return -EBUSY;
>> +}
>> +
>> +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge)
> Please add kernel-doc for any EXPORT_SYMBOL() functions, so that it's
> clear to the next guy what the API does.
Initially, I had a change in my workspace which has kernel-doc, but
after seeing this
file I see none of the exported API's had a kernel-doc. Following it I
dropped the kernel
-doc at last minute. I will add this in v2.
- Krishna Chaitanya.
>
> Regards,
> Bjorn
>
>> +{
>> + bool d3cold_allow = true;
>> +
>> + pci_walk_bus(bridge->bus, pci_host_common_check_d3cold, &d3cold_allow);
>> +
>> + return d3cold_allow;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_host_common_can_enter_d3cold);
>> +
>> MODULE_DESCRIPTION("Common library for PCI host controller drivers");
>> MODULE_LICENSE("GPL v2");
>> diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
>> index b5075d4bd7eb31fbf1dc946ef1a6afd5afb5b3c6..18a731bca058828340bca84776d0e91da1edbbf7 100644
>> --- a/drivers/pci/controller/pci-host-common.h
>> +++ b/drivers/pci/controller/pci-host-common.h
>> @@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
>>
>> struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
>> struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
>> +
>> +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge);
>> #endif
>>
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2026-01-29 5:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 11:40 [PATCH 0/3] PCI: qcom: Add D3cold support Krishna Chaitanya Chundru
2026-01-28 11:40 ` [PATCH 1/3] PCI: host-common: Add shared D3cold eligibility helper for host bridges Krishna Chaitanya Chundru
2026-01-28 14:26 ` Bjorn Andersson
2026-01-29 5:38 ` Krishna Chaitanya Chundru [this message]
2026-01-30 3:30 ` Bjorn Andersson
2026-01-28 11:40 ` [PATCH 2/3] PCI: dwc: Use common D3cold eligibility helper in suspend path Krishna Chaitanya Chundru
2026-01-28 14:28 ` Bjorn Andersson
2026-01-29 5:30 ` Krishna Chaitanya Chundru
2026-01-28 11:40 ` [PATCH 3/3] PCI: qcom: Add D3cold support Krishna Chaitanya Chundru
2026-01-28 12:28 ` Konrad Dybcio
2026-01-29 5:27 ` Krishna Chaitanya Chundru
2026-01-30 11:21 ` Konrad Dybcio
2026-01-28 14:47 ` Bjorn Andersson
2026-01-29 5:29 ` Krishna Chaitanya Chundru
2026-01-28 14:55 ` [PATCH 0/3] " Bjorn Andersson
2026-01-29 5:23 ` Krishna Chaitanya Chundru
2026-01-30 3:39 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=832e8ea4-2b85-4513-a285-9d4ab1dd66b0@oss.qualcomm.com \
--to=krishna.chundru@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=bhelgaas@google.com \
--cc=jingoohan1@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox