diff mbox series

[06/15] mei: pxp: support matching with a gfx discrete card

Message ID 20220609231955.3632596-7-daniele.ceraolospurio@intel.com (mailing list archive)
State New, archived
Headers show
Series HuC loading for DG2 | expand

Commit Message

Daniele Ceraolo Spurio June 9, 2022, 11:19 p.m. UTC
From: Tomas Winkler <tomas.winkler@intel.com>

Support matching with a discrete graphics card.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Cc: Vitaly Lubart <vitaly.lubart@intel.com>
---
 drivers/misc/mei/pxp/mei_pxp.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Teres Alexis, Alan Previn July 27, 2022, 1:01 a.m. UTC | #1
On Thu, 2022-06-09 at 16:19 -0700, Ceraolo Spurio, Daniele wrote:
> From: Tomas Winkler <tomas.winkler@intel.com>
> 
> Support matching with a discrete graphics card.
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Vitaly Lubart <vitaly.lubart@intel.com>
> ---
>  drivers/misc/mei/pxp/mei_pxp.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c
> index 94d3ef3cc73a..645862f4bb38 100644
> --- a/drivers/misc/mei/pxp/mei_pxp.c
> +++ b/drivers/misc/mei/pxp/mei_pxp.c
> @@ -162,13 +162,20 @@ static int mei_pxp_component_match(struct device *dev, int subcomponent,
>  	    subcomponent != I915_COMPONENT_PXP)
>  		return 0;
>  
> -	base = base->parent;
> -	if (!base)
> +	if (!dev)
>  		return 0;
> 
This check for !dev seems to be appearing a few lines after this other check below, which looks like a bug coz it means
dev can be null and we are checking for validity after dereferencing it:
	if (!dev->driver || strcmp(dev->driver->name, "i915") ||
	    subcomponent != I915_COMPONENT_PXP)
		return 0;

Im assuming this is an unintentional oversight so conditional RB to move things on (please fix when merging):

Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com>

>  
>  	base = base->parent;
> -	dev = dev->parent;
> +	if (!base) /* mei device */
> +		return 0;
>  
> +	base = base->parent; /* pci device */
> +	/* for dgfx */
> +	if (base && dev == base)
> +		return 1;
> +
> +	/* for pch */
> +	dev = dev->parent;
>  	return (base && dev && dev == base);
>  }
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c
index 94d3ef3cc73a..645862f4bb38 100644
--- a/drivers/misc/mei/pxp/mei_pxp.c
+++ b/drivers/misc/mei/pxp/mei_pxp.c
@@ -162,13 +162,20 @@  static int mei_pxp_component_match(struct device *dev, int subcomponent,
 	    subcomponent != I915_COMPONENT_PXP)
 		return 0;
 
-	base = base->parent;
-	if (!base)
+	if (!dev)
 		return 0;
 
 	base = base->parent;
-	dev = dev->parent;
+	if (!base) /* mei device */
+		return 0;
 
+	base = base->parent; /* pci device */
+	/* for dgfx */
+	if (base && dev == base)
+		return 1;
+
+	/* for pch */
+	dev = dev->parent;
 	return (base && dev && dev == base);
 }