diff mbox series

[v2,6/6] drm/i915/dgfx: Get VBT from rvda

Message ID 20220215133727.13450-7-anshuman.gupta@intel.com (mailing list archive)
State New, archived
Headers show
Series DGFX OpRegion | expand

Commit Message

Gupta, Anshuman Feb. 15, 2022, 1:37 p.m. UTC
Since OpRegion ver 2.1 MBOX3 RVDA field is Relative address of Raw
VBT data from OpRegion Base.
Populate the opreion->rvda accordingly.
As Intel DGFX cards supports OpRegion version 2.2 or greater,
RVDA as an absolute VBT physical address (Ver 2.0) doesn't applicable
to DGFX cards.

v2:
- Add kzalloc NULL check for opreg_rvda pointer.

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 drivers/gpu/drm/i915/display/intel_opregion.c | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Navare, Manasi Feb. 15, 2022, 7:05 p.m. UTC | #1
On Tue, Feb 15, 2022 at 07:07:27PM +0530, Anshuman Gupta wrote:
> Since OpRegion ver 2.1 MBOX3 RVDA field is Relative address of Raw
> VBT data from OpRegion Base.
> Populate the opreion->rvda accordingly.
> As Intel DGFX cards supports OpRegion version 2.2 or greater,
> RVDA as an absolute VBT physical address (Ver 2.0) doesn't applicable
> to DGFX cards.
> 
> v2:
> - Add kzalloc NULL check for opreg_rvda pointer.
> 
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Uma Shankar <uma.shankar@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_opregion.c | 22 ++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c
> index 8af3a92582cb..9907dae8f3cd 100644
> --- a/drivers/gpu/drm/i915/display/intel_opregion.c
> +++ b/drivers/gpu/drm/i915/display/intel_opregion.c
> @@ -1625,11 +1625,31 @@ static void *intel_dgfx_alloc_opregion(struct drm_i915_private *i915)
>  
>  static void *intel_dgfx_alloc_rvda(struct drm_i915_private *i915)
>  {
> -	return ERR_PTR(-EOPNOTSUPP);
> +	struct intel_opregion *opregion = &i915->opregion;
> +	void *opreg_rvda;
> +
> +	if (!opregion->dgfx_oprom_opreg)
> +		return ERR_PTR(-EINVAL);
> +
> +	opreg_rvda = kzalloc(opregion->asle->rvds, GFP_KERNEL);
> +	if (!opreg_rvda)
> +		return ERR_PTR(-ENOMEM);
> +
> +	memcpy(opreg_rvda, opregion->dgfx_oprom_opreg + opregion->asle->rvda, opregion->asle->rvds);

The suggestion here by Chris Wilson was to replace kzalloc + memcpy with kmemdup

Please add that and give necessary credits for changes done by me in DII and suggested by Chris Wilson

Manasi

> +
> +	/* We got RVDA, OPROM opregion + vbt image not nedded anymore */
> +	kfree(opregion->dgfx_oprom_opreg);
> +	opregion->dgfx_oprom_opreg = NULL;
> +
> +	return opreg_rvda;
>  }
>  
>  static void intel_dgfx_free_rvda(struct drm_i915_private *i915)
>  {
> +	struct intel_opregion *opregion = &i915->opregion;
> +
> +	kfree(opregion->rvda);
> +	opregion->rvda = NULL;
>  }
>  
>  static void intel_dgfx_free_opregion(struct drm_i915_private *i915)
> -- 
> 2.26.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c
index 8af3a92582cb..9907dae8f3cd 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -1625,11 +1625,31 @@  static void *intel_dgfx_alloc_opregion(struct drm_i915_private *i915)
 
 static void *intel_dgfx_alloc_rvda(struct drm_i915_private *i915)
 {
-	return ERR_PTR(-EOPNOTSUPP);
+	struct intel_opregion *opregion = &i915->opregion;
+	void *opreg_rvda;
+
+	if (!opregion->dgfx_oprom_opreg)
+		return ERR_PTR(-EINVAL);
+
+	opreg_rvda = kzalloc(opregion->asle->rvds, GFP_KERNEL);
+	if (!opreg_rvda)
+		return ERR_PTR(-ENOMEM);
+
+	memcpy(opreg_rvda, opregion->dgfx_oprom_opreg + opregion->asle->rvda, opregion->asle->rvds);
+
+	/* We got RVDA, OPROM opregion + vbt image not nedded anymore */
+	kfree(opregion->dgfx_oprom_opreg);
+	opregion->dgfx_oprom_opreg = NULL;
+
+	return opreg_rvda;
 }
 
 static void intel_dgfx_free_rvda(struct drm_i915_private *i915)
 {
+	struct intel_opregion *opregion = &i915->opregion;
+
+	kfree(opregion->rvda);
+	opregion->rvda = NULL;
 }
 
 static void intel_dgfx_free_opregion(struct drm_i915_private *i915)