[Intel-xe] [PATCH 1/4] drm/xe/pm: Add pci d3cold_capable support

Rodrigo Vivi rodrigo.vivi at kernel.org
Fri May 19 22:04:05 UTC 2023


On Fri, May 19, 2023 at 09:55:52PM +0530, Anshuman Gupta wrote:
> Adding pci d3cold_capable check in order to initialize
> d3cold_allowed as false statically.
> It avoids vram save/restore latency during runtime
> suspend/resume
> 
> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device_types.h |  3 +++
>  drivers/gpu/drm/xe/xe_pci.c          |  6 ++++++
>  drivers/gpu/drm/xe/xe_pm.c           | 22 ++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_pm.h           |  1 +
>  4 files changed, 32 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index 77d1cc6514c4..8fd3acf60719 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -266,6 +266,9 @@ struct xe_device {
>  		bool hold_rpm;
>  	} mem_access;
>  
> +	/** d3cold_capable: Indicates if root port is d3cold capable */
> +	bool d3cold_capable;
> +
>  	/** @d3cold_allowed: Indicates if d3cold is a valid device state */
>  	bool d3cold_allowed;
>  
> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index e789a50a1310..96826b4d5fc3 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
> @@ -685,6 +685,7 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	}
>  
>  	xe_pm_runtime_init(xe);
> +	xe_pm_init(xe);
>  
>  	return 0;
>  }
> @@ -789,6 +790,11 @@ static int xe_pci_runtime_idle(struct device *dev)
>  	struct pci_dev *pdev = to_pci_dev(dev);
>  	struct xe_device *xe = pdev_to_xe_device(pdev);
>  
> +	if (!xe->d3cold_capable) {
> +		xe->d3cold_allowed = false;
> +		return 0;
> +	}

for future save we should have a } else { here

> +
>  	/*
>  	 * TODO: d3cold should be allowed (true) if
>  	 * (IS_DGFX(xe) && !xe_device_mem_access_ongoing(xe))

... }

with that

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>


> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> index b7b57f10ba25..534768ac4410 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -117,6 +117,21 @@ int xe_pm_resume(struct xe_device *xe)
>  	return 0;
>  }
>  
> +static bool xe_pm_pci_d3cold_capable(struct pci_dev *pdev)
> +{
> +	struct pci_dev *root_pdev;
> +
> +	root_pdev = pcie_find_root_port(pdev);
> +	if (!root_pdev)
> +		return false;
> +
> +	/* D3Cold requires PME capability and _PR3 power resource */
> +	if (!pci_pme_capable(root_pdev, PCI_D3cold) || !pci_pr3_present(root_pdev))
> +		return false;
> +
> +	return true;
> +}
> +
>  void xe_pm_runtime_init(struct xe_device *xe)
>  {
>  	struct device *dev = xe->drm.dev;
> @@ -129,6 +144,13 @@ void xe_pm_runtime_init(struct xe_device *xe)
>  	pm_runtime_put_autosuspend(dev);
>  }
>  
> +void xe_pm_init(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> +
> +	xe->d3cold_capable = xe_pm_pci_d3cold_capable(pdev);
> +}
> +
>  void xe_pm_runtime_fini(struct xe_device *xe)
>  {
>  	struct device *dev = xe->drm.dev;
> diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
> index 6a885585f653..38764537a566 100644
> --- a/drivers/gpu/drm/xe/xe_pm.h
> +++ b/drivers/gpu/drm/xe/xe_pm.h
> @@ -14,6 +14,7 @@ int xe_pm_suspend(struct xe_device *xe);
>  int xe_pm_resume(struct xe_device *xe);
>  
>  void xe_pm_runtime_init(struct xe_device *xe);
> +void xe_pm_init(struct xe_device *xe);
>  void xe_pm_runtime_fini(struct xe_device *xe);
>  int xe_pm_runtime_suspend(struct xe_device *xe);
>  int xe_pm_runtime_resume(struct xe_device *xe);
> -- 
> 2.38.0
> 


More information about the Intel-xe mailing list