[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210608054857.18963-6-ameynarkhede03@gmail.com>
Date: Tue, 8 Jun 2021 11:18:54 +0530
From: Amey Narkhede <ameynarkhede03@...il.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: alex.williamson@...hat.com,
Raphael Norwitz <raphael.norwitz@...anix.com>,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
kw@...ux.com, Shanker Donthineni <sdonthineni@...dia.com>,
Sinan Kaya <okaya@...nel.org>, Len Brown <lenb@...nel.org>,
"Rafael J . Wysocki" <rjw@...ysocki.net>
Subject: [PATCH v7 5/8] PCI: Setup ACPI_COMPANION early
From: Shanker Donthineni <sdonthineni@...dia.com>
Currently, the ACPI_COMPANION is not available until device_add().
The software features which have dependency on ACPI fwnode properties
and needs to be handled before device_add() will not work. One use
case, software has to check the existence of _RST method to support
ACPI based reset mechanism.
This patch adds a new function pci_set_acpi_fwnode() for setting the
ACPI_COMPANION, same code which is available in acpi_pci_bridge_d3().
Call pci_set_acpi_fwnode() from pci_scan_device() to fix the issue.
Signed-off-by: Shanker Donthineni <sdonthineni@...dia.com>
---
drivers/pci/pci-acpi.c | 12 ++++++++----
drivers/pci/pci.h | 2 ++
drivers/pci/probe.c | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 36bc23e21..eaddbf701 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -934,6 +934,13 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
static struct acpi_device *acpi_pci_find_companion(struct device *dev);
+void pci_set_acpi_fwnode(struct pci_dev *dev)
+{
+ if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))
+ ACPI_COMPANION_SET(&dev->dev,
+ acpi_pci_find_companion(&dev->dev));
+}
+
static bool acpi_pci_bridge_d3(struct pci_dev *dev)
{
const struct fwnode_handle *fwnode;
@@ -945,11 +952,8 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev)
return false;
/* Assume D3 support if the bridge is power-manageable by ACPI. */
+ pci_set_acpi_fwnode(dev);
adev = ACPI_COMPANION(&dev->dev);
- if (!adev && !pci_dev_is_added(dev)) {
- adev = acpi_pci_find_companion(&dev->dev);
- ACPI_COMPANION_SET(&dev->dev, adev);
- }
if (adev && acpi_device_power_manageable(adev))
return true;
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 13ec6bd6f..d22da6d3c 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -703,7 +703,9 @@ static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL
#ifdef CONFIG_ACPI
int pci_acpi_program_hp_params(struct pci_dev *dev);
extern const struct attribute_group pci_dev_acpi_attr_group;
+void pci_set_acpi_fwnode(struct pci_dev *dev);
#else
+static inline void pci_set_acpi_fwnode(struct pci_dev *dev) {}
static inline int pci_acpi_program_hp_params(struct pci_dev *dev)
{
return -ENODEV;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 90fd4f61f..dfefa5ed0 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2359,6 +2359,8 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
return NULL;
}
+ pci_set_acpi_fwnode(dev);
+
return dev;
}
--
2.31.1
Powered by blists - more mailing lists