Add i915_save/load_pci_state helpers which saves pci config state and restores the saved state. Signed-off-by: Iddamsetty Aravind <Aravind.Iddamsetty@xxxxxxxxx> Signed-off-by: Tilak Tangudu <tilak.tangudu@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_driver.c | 34 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index 60f6fcc6b71d..669365c2958c 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -102,6 +102,40 @@ 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_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c22f29c3faa0..ec8c7a2af673 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