[Intel-gfx] [PATCH 7/8] drm/i915: Add i915_save/load_pci_state helpers
tilak.tangudu at intel.com
tilak.tangudu at intel.com
Thu Jul 21 09:59:54 UTC 2022
From: Aravind Iddamsetty <aravind.iddamsetty at intel.com>
Add i915_save/load_pci_state helpers which saves
pci config state and restores the saved state.
Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty at intel.com>
Signed-off-by: Tilak Tangudu <tilak.tangudu at intel.com>
---
drivers/gpu/drm/i915/i915_driver.c | 34 ++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/i915_driver.h | 2 ++
drivers/gpu/drm/i915/i915_drv.h | 1 +
3 files changed, 37 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 2b2e9563f149..3697ecb2c138 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -105,6 +105,40 @@ static const char irst_name[] = "INT3392";
static const struct drm_driver i915_drm_driver;
+bool i915_save_pci_state(struct pci_dev *pdev)
+{
+ struct drm_i915_private *i915 = pci_get_drvdata(pdev);
+
+ if (pci_save_state(pdev))
+ return false;
+
+ kfree(i915->pci_state);
+
+ i915->pci_state = pci_store_saved_state(pdev);
+
+ if (!i915->pci_state) {
+ drm_err(&i915->drm, "Failed to store PCI saved state\n");
+ return false;
+ }
+
+ return true;
+}
+
+void i915_load_pci_state(struct pci_dev *pdev)
+{
+ struct drm_i915_private *i915 = pci_get_drvdata(pdev);
+ int ret;
+
+ if (!i915->pci_state)
+ return;
+
+ ret = pci_load_saved_state(pdev, i915->pci_state);
+ if (!ret) {
+ pci_restore_state(pdev);
+ } else {
+ drm_warn(&i915->drm, "Failed to load PCI state, err:%d\n", ret);
+ }
+}
static int i915_get_bridge_dev(struct drm_i915_private *dev_priv)
{
int domain = pci_domain_nr(to_pci_dev(dev_priv->drm.dev)->bus);
diff --git a/drivers/gpu/drm/i915/i915_driver.h b/drivers/gpu/drm/i915/i915_driver.h
index 44ec543d92cb..fb19db69bc3f 100644
--- a/drivers/gpu/drm/i915/i915_driver.h
+++ b/drivers/gpu/drm/i915/i915_driver.h
@@ -26,6 +26,8 @@ void i915_driver_shutdown(struct drm_i915_private *i915);
int i915_driver_resume_switcheroo(struct drm_i915_private *i915);
int i915_driver_suspend_switcheroo(struct drm_i915_private *i915, pm_message_t state);
+bool i915_save_pci_state(struct pci_dev *pdev);
+void i915_load_pci_state(struct pci_dev *pdev);
void
i915_print_iommu_status(struct drm_i915_private *i915, struct drm_printer *p);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d25647be25d1..c30ac9219b7f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -777,6 +777,7 @@ struct drm_i915_private {
* NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
* will be rejected. Instead look for a better place.
*/
+ struct pci_saved_state *pci_state;
};
static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
--
2.25.1
More information about the Intel-gfx
mailing list