diff mbox series

[1/2] drm/i915/gvt: stop using drm_edid_block_valid()

Message ID 20240530124352.362736-1-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915/gvt: stop using drm_edid_block_valid() | expand

Commit Message

Jani Nikula May 30, 2024, 12:43 p.m. UTC
We'll want to stop drm_edid_block_valid() usage. KVMGT is the last
user. Replace with drm_edid_valid(), which unfortunately requires an
allocated drm_edid. However, on the plus side, this would be required to
handle the TODO comment about EDID extension block support.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.wang.linux@gmail.com>
Cc: intel-gvt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Zhi Wang May 30, 2024, 5:14 p.m. UTC | #1
On Thu, 30 May 2024 15:43:51 +0300
Jani Nikula <jani.nikula@intel.com> wrote:

> We'll want to stop drm_edid_block_valid() usage. KVMGT is the last
> user. Replace with drm_edid_valid(), which unfortunately requires an
> allocated drm_edid. However, on the plus side, this would be required
> to handle the TODO comment about EDID extension block support.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> 
> ---
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Zhi Wang <zhi.wang.linux@gmail.com>
> Cc: intel-gvt-dev@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/i915/gvt/kvmgt.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c
> b/drivers/gpu/drm/i915/gvt/kvmgt.c index 4f74d867fe1a..7e3e5382c0c0
> 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -425,6 +425,18 @@ static const struct intel_vgpu_regops
> intel_vgpu_regops_opregion = { .release =
> intel_vgpu_reg_release_opregion, };
>  
> +static bool edid_valid(const void *edid, size_t size)
> +{
> +	const struct drm_edid *drm_edid;
> +	bool is_valid;
> +
> +	drm_edid = drm_edid_alloc(edid, size);
> +	is_valid = drm_edid_valid(drm_edid);
> +	drm_edid_free(drm_edid);
> +
> +	return is_valid;
> +}
> +
>  static int handle_edid_regs(struct intel_vgpu *vgpu,
>  			struct vfio_edid_region *region, char *buf,
>  			size_t count, u16 offset, bool is_write)
> @@ -443,11 +455,7 @@ static int handle_edid_regs(struct intel_vgpu
> *vgpu, switch (offset) {
>  		case offsetof(struct vfio_region_gfx_edid,
> link_state): if (data == VFIO_DEVICE_GFX_LINK_STATE_UP) {
> -				if (!drm_edid_block_valid(
> -					(u8 *)region->edid_blob,
> -					0,
> -					true,
> -					NULL)) {
> +				if (!edid_valid(region->edid_blob,
> EDID_SIZE)) { gvt_vgpu_err("invalid EDID blob\n");
>  					return -EINVAL;
>  				}

Acked-by: Zhi Wang <zhiwang@kernel.org>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4f74d867fe1a..7e3e5382c0c0 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -425,6 +425,18 @@  static const struct intel_vgpu_regops intel_vgpu_regops_opregion = {
 	.release = intel_vgpu_reg_release_opregion,
 };
 
+static bool edid_valid(const void *edid, size_t size)
+{
+	const struct drm_edid *drm_edid;
+	bool is_valid;
+
+	drm_edid = drm_edid_alloc(edid, size);
+	is_valid = drm_edid_valid(drm_edid);
+	drm_edid_free(drm_edid);
+
+	return is_valid;
+}
+
 static int handle_edid_regs(struct intel_vgpu *vgpu,
 			struct vfio_edid_region *region, char *buf,
 			size_t count, u16 offset, bool is_write)
@@ -443,11 +455,7 @@  static int handle_edid_regs(struct intel_vgpu *vgpu,
 		switch (offset) {
 		case offsetof(struct vfio_region_gfx_edid, link_state):
 			if (data == VFIO_DEVICE_GFX_LINK_STATE_UP) {
-				if (!drm_edid_block_valid(
-					(u8 *)region->edid_blob,
-					0,
-					true,
-					NULL)) {
+				if (!edid_valid(region->edid_blob, EDID_SIZE)) {
 					gvt_vgpu_err("invalid EDID blob\n");
 					return -EINVAL;
 				}