diff mbox series

[v2,3/9] drm/i915: Split i9xx_read_lut_8() to gmch vs. ilk variants

Message ID 20200303173313.28117-4-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Gamma cleanups | expand

Commit Message

Ville Syrjälä March 3, 2020, 5:33 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

To mirror the load_luts path let's clone an ilk+ version
from i9xx_read_lut_8(). I guess the extra branch isn't a huge
issue but feels better to make a clean split.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c | 41 ++++++++++++++++++----
 1 file changed, 35 insertions(+), 6 deletions(-)

Comments

kernel test robot March 4, 2020, 2:54 a.m. UTC | #1
Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip]
[cannot apply to v5.6-rc4 next-20200303]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ville-Syrjala/drm-i915-Gamma-cleanups/20200304-043847
base:   git://anongit.freedesktop.org/drm-intel for-linux-next

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

New smatch warnings:
drivers/gpu/drm/i915/display/intel_color.c:1840 ilk_read_lut_8() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)

Old smatch warnings:
drivers/gpu/drm/i915/display/intel_color.c:1706 i9xx_read_lut_8() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
drivers/gpu/drm/i915/display/intel_color.c:1747 i965_read_lut_10p6() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
drivers/gpu/drm/i915/display/intel_color.c:1799 chv_read_cgm_lut() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
drivers/gpu/drm/i915/display/intel_color.c:1873 ilk_read_lut_10() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
drivers/gpu/drm/i915/display/intel_color.c:1920 glk_read_lut_10() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)

vim +/blob +1840 drivers/gpu/drm/i915/display/intel_color.c

  1823	
  1824	static struct drm_property_blob *
  1825	ilk_read_lut_8(const struct intel_crtc_state *crtc_state)
  1826	{
  1827		struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
  1828		struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
  1829		enum pipe pipe = crtc->pipe;
  1830		struct drm_property_blob *blob;
  1831		struct drm_color_lut *blob_data;
  1832		u32 i, val;
  1833	
  1834		blob = drm_property_create_blob(&dev_priv->drm,
  1835						sizeof(struct drm_color_lut) * LEGACY_LUT_LENGTH,
  1836						NULL);
  1837		if (IS_ERR(blob))
  1838			return NULL;
  1839	
> 1840		blob_data = blob->data;
  1841	
  1842		for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
  1843			val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
  1844	
  1845			blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
  1846								LGC_PALETTE_RED_MASK, val), 8);
  1847			blob_data[i].green = intel_color_lut_pack(REG_FIELD_GET(
  1848								  LGC_PALETTE_GREEN_MASK, val), 8);
  1849			blob_data[i].blue = intel_color_lut_pack(REG_FIELD_GET(
  1850								 LGC_PALETTE_BLUE_MASK, val), 8);
  1851		}
  1852	
  1853		return blob;
  1854	}
  1855	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Ville Syrjälä March 4, 2020, 11:51 a.m. UTC | #2
On Wed, Mar 04, 2020 at 10:54:44AM +0800, kbuild test robot wrote:
> Hi Ville,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on drm-intel/for-linux-next]
> [also build test WARNING on drm-tip/drm-tip]
> [cannot apply to v5.6-rc4 next-20200303]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> 
> url:    https://github.com/0day-ci/linux/commits/Ville-Syrjala/drm-i915-Gamma-cleanups/20200304-043847
> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> New smatch warnings:
> drivers/gpu/drm/i915/display/intel_color.c:1840 ilk_read_lut_8() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)

drm_property_create_blob() does _not_ return NULL. Why does this thing
think it does?

> 
> Old smatch warnings:
> drivers/gpu/drm/i915/display/intel_color.c:1706 i9xx_read_lut_8() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
> drivers/gpu/drm/i915/display/intel_color.c:1747 i965_read_lut_10p6() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
> drivers/gpu/drm/i915/display/intel_color.c:1799 chv_read_cgm_lut() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
> drivers/gpu/drm/i915/display/intel_color.c:1873 ilk_read_lut_10() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
> drivers/gpu/drm/i915/display/intel_color.c:1920 glk_read_lut_10() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)
> 
> vim +/blob +1840 drivers/gpu/drm/i915/display/intel_color.c
> 
>   1823	
>   1824	static struct drm_property_blob *
>   1825	ilk_read_lut_8(const struct intel_crtc_state *crtc_state)
>   1826	{
>   1827		struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>   1828		struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>   1829		enum pipe pipe = crtc->pipe;
>   1830		struct drm_property_blob *blob;
>   1831		struct drm_color_lut *blob_data;
>   1832		u32 i, val;
>   1833	
>   1834		blob = drm_property_create_blob(&dev_priv->drm,
>   1835						sizeof(struct drm_color_lut) * LEGACY_LUT_LENGTH,
>   1836						NULL);
>   1837		if (IS_ERR(blob))
>   1838			return NULL;
>   1839	
> > 1840		blob_data = blob->data;
>   1841	
>   1842		for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
>   1843			val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
>   1844	
>   1845			blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
>   1846								LGC_PALETTE_RED_MASK, val), 8);
>   1847			blob_data[i].green = intel_color_lut_pack(REG_FIELD_GET(
>   1848								  LGC_PALETTE_GREEN_MASK, val), 8);
>   1849			blob_data[i].blue = intel_color_lut_pack(REG_FIELD_GET(
>   1850								 LGC_PALETTE_BLUE_MASK, val), 8);
>   1851		}
>   1852	
>   1853		return blob;
>   1854	}
>   1855	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Sharma, Swati2 March 6, 2020, 3 p.m. UTC | #3
On 03-Mar-20 11:03 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> To mirror the load_luts path let's clone an ilk+ version
> from i9xx_read_lut_8(). I guess the extra branch isn't a huge
> issue but feels better to make a clean split.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Swati Sharma <swati2.sharma@intel.com>

> ---
>   drivers/gpu/drm/i915/display/intel_color.c | 41 ++++++++++++++++++----
>   1 file changed, 35 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
> index cf8ed4e2ae13..e3abaa1908a9 100644
> --- a/drivers/gpu/drm/i915/display/intel_color.c
> +++ b/drivers/gpu/drm/i915/display/intel_color.c
> @@ -1706,10 +1706,7 @@ i9xx_read_lut_8(const struct intel_crtc_state *crtc_state)
>   	blob_data = blob->data;
>   
>   	for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
> -		if (HAS_GMCH(dev_priv))
> -			val = intel_de_read(dev_priv, PALETTE(pipe, i));
> -		else
> -			val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
> +		val = intel_de_read(dev_priv, PALETTE(pipe, i));
>   
>   		blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
>   							LGC_PALETTE_RED_MASK, val), 8);
> @@ -1824,6 +1821,38 @@ static void chv_read_luts(struct intel_crtc_state *crtc_state)
>   		i965_read_luts(crtc_state);
>   }
>   
> +static struct drm_property_blob *
> +ilk_read_lut_8(const struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> +	enum pipe pipe = crtc->pipe;
> +	struct drm_property_blob *blob;
> +	struct drm_color_lut *blob_data;
> +	u32 i, val;
> +
> +	blob = drm_property_create_blob(&dev_priv->drm,
> +					sizeof(struct drm_color_lut) * LEGACY_LUT_LENGTH,
> +					NULL);
> +	if (IS_ERR(blob))
> +		return NULL;
> +
> +	blob_data = blob->data;
> +
> +	for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
> +		val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
> +
> +		blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
> +							LGC_PALETTE_RED_MASK, val), 8);
> +		blob_data[i].green = intel_color_lut_pack(REG_FIELD_GET(
> +							  LGC_PALETTE_GREEN_MASK, val), 8);
> +		blob_data[i].blue = intel_color_lut_pack(REG_FIELD_GET(
> +							 LGC_PALETTE_BLUE_MASK, val), 8);
> +	}
> +
> +	return blob;
> +}
> +
>   static struct drm_property_blob *
>   ilk_read_lut_10(const struct intel_crtc_state *crtc_state)
>   {
> @@ -1866,7 +1895,7 @@ static void ilk_read_luts(struct intel_crtc_state *crtc_state)
>   		return;
>   
>   	if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT)
> -		crtc_state->hw.gamma_lut = i9xx_read_lut_8(crtc_state);
> +		crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc_state);
>   	else
>   		crtc_state->hw.gamma_lut = ilk_read_lut_10(crtc_state);
>   }
> @@ -1915,7 +1944,7 @@ static void glk_read_luts(struct intel_crtc_state *crtc_state)
>   		return;
>   
>   	if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT)
> -		crtc_state->hw.gamma_lut = i9xx_read_lut_8(crtc_state);
> +		crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc_state);
>   	else
>   		crtc_state->hw.gamma_lut = glk_read_lut_10(crtc_state, PAL_PREC_INDEX_VALUE(0));
>   }
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index cf8ed4e2ae13..e3abaa1908a9 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1706,10 +1706,7 @@  i9xx_read_lut_8(const struct intel_crtc_state *crtc_state)
 	blob_data = blob->data;
 
 	for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
-		if (HAS_GMCH(dev_priv))
-			val = intel_de_read(dev_priv, PALETTE(pipe, i));
-		else
-			val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
+		val = intel_de_read(dev_priv, PALETTE(pipe, i));
 
 		blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
 							LGC_PALETTE_RED_MASK, val), 8);
@@ -1824,6 +1821,38 @@  static void chv_read_luts(struct intel_crtc_state *crtc_state)
 		i965_read_luts(crtc_state);
 }
 
+static struct drm_property_blob *
+ilk_read_lut_8(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+	enum pipe pipe = crtc->pipe;
+	struct drm_property_blob *blob;
+	struct drm_color_lut *blob_data;
+	u32 i, val;
+
+	blob = drm_property_create_blob(&dev_priv->drm,
+					sizeof(struct drm_color_lut) * LEGACY_LUT_LENGTH,
+					NULL);
+	if (IS_ERR(blob))
+		return NULL;
+
+	blob_data = blob->data;
+
+	for (i = 0; i < LEGACY_LUT_LENGTH; i++) {
+		val = intel_de_read(dev_priv, LGC_PALETTE(pipe, i));
+
+		blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(
+							LGC_PALETTE_RED_MASK, val), 8);
+		blob_data[i].green = intel_color_lut_pack(REG_FIELD_GET(
+							  LGC_PALETTE_GREEN_MASK, val), 8);
+		blob_data[i].blue = intel_color_lut_pack(REG_FIELD_GET(
+							 LGC_PALETTE_BLUE_MASK, val), 8);
+	}
+
+	return blob;
+}
+
 static struct drm_property_blob *
 ilk_read_lut_10(const struct intel_crtc_state *crtc_state)
 {
@@ -1866,7 +1895,7 @@  static void ilk_read_luts(struct intel_crtc_state *crtc_state)
 		return;
 
 	if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT)
-		crtc_state->hw.gamma_lut = i9xx_read_lut_8(crtc_state);
+		crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc_state);
 	else
 		crtc_state->hw.gamma_lut = ilk_read_lut_10(crtc_state);
 }
@@ -1915,7 +1944,7 @@  static void glk_read_luts(struct intel_crtc_state *crtc_state)
 		return;
 
 	if (crtc_state->gamma_mode == GAMMA_MODE_MODE_8BIT)
-		crtc_state->hw.gamma_lut = i9xx_read_lut_8(crtc_state);
+		crtc_state->hw.gamma_lut = ilk_read_lut_8(crtc_state);
 	else
 		crtc_state->hw.gamma_lut = glk_read_lut_10(crtc_state, PAL_PREC_INDEX_VALUE(0));
 }