mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v8 2/8] drm/mediatevk: Add crtc path enum for all_drm_priv array
       [not found] ` <20230802144802.751-3-jason-jh.lin@mediatek.com>
@ 2023-08-03 13:18   ` Eugen Hristev
  2023-08-05  7:27     ` Jason-JH Lin (林睿祥)
  0 siblings, 1 reply; 6+ messages in thread
From: Eugen Hristev @ 2023-08-03 13:18 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group

On 8/2/23 17:47, Jason-JH.Lin wrote:
> Add mtk_drm_crtc_path enum for eatch display path.

Typo: each

> 
> Instead of using array index of all_drm_priv in mtk_drm_kms_init(),
> mtk_drm_crtc_path enum can make more readable.

can make *code* more readable ?
> 
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c | 6 +++---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.h | 8 +++++++-
>   2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 249c9fd6347e..89a38561ba27 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -465,21 +465,21 @@ static int mtk_drm_kms_init(struct drm_device *drm)
>   		for (j = 0; j < private->data->mmsys_dev_num; j++) {
>   			priv_n = private->all_drm_private[j];
>   
> -			if (i == 0 && priv_n->data->main_len) {
> +			if (i == CRTC_MAIN && priv_n->data->main_len) {
>   				ret = mtk_drm_crtc_create(drm, priv_n->data->main_path,
>   							  priv_n->data->main_len, j);
>   				if (ret)
>   					goto err_component_unbind;
>   
>   				continue;
> -			} else if (i == 1 && priv_n->data->ext_len) {
> +			} else if (i == CRTC_EXT && priv_n->data->ext_len) {
>   				ret = mtk_drm_crtc_create(drm, priv_n->data->ext_path,
>   							  priv_n->data->ext_len, j);
>   				if (ret)
>   					goto err_component_unbind;
>   
>   				continue;
> -			} else if (i == 2 && priv_n->data->third_len) {
> +			} else if (i == CRTC_THIRD && priv_n->data->third_len) {
>   				ret = mtk_drm_crtc_create(drm, priv_n->data->third_path,
>   							  priv_n->data->third_len, j);
>   				if (ret)
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> index eb2fd45941f0..f4de8bb27685 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> @@ -9,11 +9,17 @@
>   #include <linux/io.h>
>   #include "mtk_drm_ddp_comp.h"
>   
> -#define MAX_CRTC	3
>   #define MAX_CONNECTOR	2
>   #define DDP_COMPONENT_DRM_OVL_ADAPTOR (DDP_COMPONENT_ID_MAX + 1)
>   #define DDP_COMPONENT_DRM_ID_MAX (DDP_COMPONENT_DRM_OVL_ADAPTOR + 1)
>   
> +enum mtk_drm_crtc_path {
> +	CRTC_MAIN,
> +	CRTC_EXT,
> +	CRTC_THIRD,
> +	MAX_CRTC,
> +};
> +
>   struct device;
>   struct device_node;
>   struct drm_crtc;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v8 3/8] drm/mediatek: Fix using wrong drm private data to bind mediatek-drm
       [not found] ` <20230802144802.751-4-jason-jh.lin@mediatek.com>
@ 2023-08-03 13:22   ` Eugen Hristev
  2023-08-05  8:05     ` Jason-JH Lin (林睿祥)
  0 siblings, 1 reply; 6+ messages in thread
From: Eugen Hristev @ 2023-08-03 13:22 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group

On 8/2/23 17:47, Jason-JH.Lin wrote:
> In mtk_drm_kms_init(), each element in all_drm_priv should has one
> display path private data only, such as:
> all_drm_priv[CRTC_MAIN] should has main_path data only
> all_drm_priv[CRTC_EXT] should has ext_path data only
> all_drm_priv[CRTC_THIRD] should has third_path data only

s/should has/should have/ ?

> 
> So we need to add the length checking for each display path before
> assigning their drm private data into all_drm_priv array.
> 
> Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys support")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Reviewed-by: CK Hu <ck.hu@mediatek.com>
> ---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 +++++++++++++---
>   1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 89a38561ba27..c12886f31e54 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -351,6 +351,7 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
>   {
>   	struct mtk_drm_private *drm_priv = dev_get_drvdata(dev);
>   	struct mtk_drm_private *all_drm_priv[MAX_CRTC];
> +	struct mtk_drm_private *temp_drm_priv;
>   	struct device_node *phandle = dev->parent->of_node;
>   	const struct of_device_id *of_id;
>   	struct device_node *node;
> @@ -373,9 +374,18 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
>   		if (!drm_dev || !dev_get_drvdata(drm_dev))
>   			continue;
>   
> -		all_drm_priv[cnt] = dev_get_drvdata(drm_dev);
> -		if (all_drm_priv[cnt] && all_drm_priv[cnt]->mtk_drm_bound)
> -			cnt++;
> +		temp_drm_priv = dev_get_drvdata(drm_dev);
> +		if (temp_drm_priv) {

This is inside a 'for' loop right ?
Why don't you just 'continue' if temp_drm_priv is null ?


> +			if (temp_drm_priv->mtk_drm_bound)
> +				cnt++;
> +
> +			if (temp_drm_priv->data->main_len)
> +				all_drm_priv[CRTC_MAIN] = temp_drm_priv;
> +			else if (temp_drm_priv->data->ext_len)
> +				all_drm_priv[CRTC_EXT] = temp_drm_priv;
> +			else if (temp_drm_priv->data->third_len)
> +				all_drm_priv[CRTC_THIRD] = temp_drm_priv;
> +		}
>   	}
>   
>   	if (drm_priv->data->mmsys_dev_num == cnt) {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v8 4/8] drm/mediatek: Add encoder_index function to mtk_ddp_comp_funcs
       [not found] ` <20230802144802.751-5-jason-jh.lin@mediatek.com>
@ 2023-08-03 13:27   ` Eugen Hristev
  2023-08-05  7:40     ` Jason-JH Lin (林睿祥)
  0 siblings, 1 reply; 6+ messages in thread
From: Eugen Hristev @ 2023-08-03 13:27 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group

On 8/2/23 17:47, Jason-JH.Lin wrote:
> 1. Add encoder_index function to mtk_ddp_comp_funcs to support dynamic
> connector selection for some ddp_comp who has encoder_index.
> 2. Add mtk_ddp_comp_encoder_index_set function to set encoder_index to
> each comp.
> 

Usually a commit that does two things in a list is supposed to be two 
actual commits.


> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> index febcaeef16a1..8428baca70f4 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> @@ -80,6 +80,7 @@ struct mtk_ddp_comp_funcs {
>   	void (*disconnect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
>   	void (*add)(struct device *dev, struct mtk_mutex *mutex);
>   	void (*remove)(struct device *dev, struct mtk_mutex *mutex);
> +	unsigned int (*encoder_index)(struct device *dev);
>   };
>   
>   struct mtk_ddp_comp {
> @@ -87,6 +88,7 @@ struct mtk_ddp_comp {
>   	int irq;
>   	unsigned int id;
>   	const struct mtk_ddp_comp_funcs *funcs;
> +	unsigned int encoder_index;

For better alignment I would suggest variables to be declared together 
and pointers afterwards, not mixed up

>   };
>   
>   static inline int mtk_ddp_comp_clk_enable(struct mtk_ddp_comp *comp)
> @@ -275,6 +277,12 @@ static inline bool mtk_ddp_comp_disconnect(struct mtk_ddp_comp *comp, struct dev
>   	return false;
>   }
>   
> +static inline void mtk_ddp_comp_encoder_index_set(struct mtk_ddp_comp *comp)
> +{
> +	if (comp->funcs && comp->funcs->encoder_index)
> +		comp->encoder_index = comp->funcs->encoder_index(comp->dev);
> +}

it's also a bit strange that you added a function that is not used 
anywhere. Don't you get like a compiler warning for it ?

> +
>   int mtk_ddp_comp_get_id(struct device_node *node,
>   			enum mtk_ddp_comp_type comp_type);
>   unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v8 2/8] drm/mediatevk: Add crtc path enum for all_drm_priv array
  2023-08-03 13:18   ` [PATCH v8 2/8] drm/mediatevk: Add crtc path enum for all_drm_priv array Eugen Hristev
@ 2023-08-05  7:27     ` Jason-JH Lin (林睿祥)
  0 siblings, 0 replies; 6+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2023-08-05  7:27 UTC (permalink / raw)
  To: chunkuang.hu, angelogioacchino.delregno, eugen.hristev
  Cc: linux-mediatek, Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	linux-kernel, Nancy Lin (林欣螢),
	dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel, matthias.bgg

Hi Eugen,

Thanks for the reviews.

On Thu, 2023-08-03 at 16:18 +0300, Eugen Hristev wrote:
> > 

> On 8/2/23 17:47, Jason-JH.Lin wrote:
> > Add mtk_drm_crtc_path enum for eatch display path.
> 
> Typo: each
> 
I'll fix it.

> > 
> > Instead of using array index of all_drm_priv in mtk_drm_kms_init(),
> > mtk_drm_crtc_path enum can make more readable.
> 
> can make *code* more readable ?

Yes, I'll correct it at the next version.
Thanks.

Regards,
Jason-JH.Lin

> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > ---

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v8 4/8] drm/mediatek: Add encoder_index function to mtk_ddp_comp_funcs
  2023-08-03 13:27   ` [PATCH v8 4/8] drm/mediatek: Add encoder_index function to mtk_ddp_comp_funcs Eugen Hristev
@ 2023-08-05  7:40     ` Jason-JH Lin (林睿祥)
  0 siblings, 0 replies; 6+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2023-08-05  7:40 UTC (permalink / raw)
  To: chunkuang.hu, angelogioacchino.delregno, eugen.hristev
  Cc: linux-mediatek, Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	linux-kernel, Nancy Lin (林欣螢),
	dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel, matthias.bgg

Hi Eugen,

Thanks for the reviews.

On Thu, 2023-08-03 at 16:27 +0300, Eugen Hristev wrote:
> On 8/2/23 17:47, Jason-JH.Lin wrote:
> > 1. Add encoder_index function to mtk_ddp_comp_funcs to support
> > dynamic
> > connector selection for some ddp_comp who has encoder_index.
> > 2. Add mtk_ddp_comp_encoder_index_set function to set encoder_index
> > to
> > each comp.
> > 
> 
> Usually a commit that does two things in a list is supposed to be
> two 
> actual commits.
> 
OK, I'll move the second part to [PATCH v8 6/8].

> 
> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > ---
> >   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 8 ++++++++
> >   1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> > b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> > index febcaeef16a1..8428baca70f4 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> > @@ -80,6 +80,7 @@ struct mtk_ddp_comp_funcs {
> >   	void (*disconnect)(struct device *dev, struct device
> > *mmsys_dev, unsigned int next);
> >   	void (*add)(struct device *dev, struct mtk_mutex *mutex);
> >   	void (*remove)(struct device *dev, struct mtk_mutex *mutex);
> > +	unsigned int (*encoder_index)(struct device *dev);
> >   };
> >   
> >   struct mtk_ddp_comp {
> > @@ -87,6 +88,7 @@ struct mtk_ddp_comp {
> >   	int irq;
> >   	unsigned int id;
> >   	const struct mtk_ddp_comp_funcs *funcs;
> > +	unsigned int encoder_index;
> 
> For better alignment I would suggest variables to be declared
> together 
> and pointers afterwards, not mixed up
> 

OK, I'll move it between `unsigned int id` and `const struct
mtk_ddp_comp_funcs *funcs`.


> >   };
> >   
> >   static inline int mtk_ddp_comp_clk_enable(struct mtk_ddp_comp
> > *comp)
> > @@ -275,6 +277,12 @@ static inline bool
> > mtk_ddp_comp_disconnect(struct mtk_ddp_comp *comp, struct dev
> >   	return false;
> >   }
> >   
> > +static inline void mtk_ddp_comp_encoder_index_set(struct
> > mtk_ddp_comp *comp)
> > +{
> > +	if (comp->funcs && comp->funcs->encoder_index)
> > +		comp->encoder_index = comp->funcs->encoder_index(comp-
> > >dev);
> > +}
> 
> it's also a bit strange that you added a function that is not used 
> anywhere. Don't you get like a compiler warning for it ?
> 
Because it's used in mtk_drm_crtc_create() in [PATCH v8 6/8].
I'll move this part into [PATCH v8 6/8].

Regards,
Jason-JH.Lin

> > +
> >   int mtk_ddp_comp_get_id(struct device_node *node,
> >   			enum mtk_ddp_comp_type comp_type);
> >   unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device
> > *drm,
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v8 3/8] drm/mediatek: Fix using wrong drm private data to bind mediatek-drm
  2023-08-03 13:22   ` [PATCH v8 3/8] drm/mediatek: Fix using wrong drm private data to bind mediatek-drm Eugen Hristev
@ 2023-08-05  8:05     ` Jason-JH Lin (林睿祥)
  0 siblings, 0 replies; 6+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2023-08-05  8:05 UTC (permalink / raw)
  To: chunkuang.hu, angelogioacchino.delregno, eugen.hristev
  Cc: linux-mediatek, Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	linux-kernel, Nancy Lin (林欣螢),
	dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel, matthias.bgg

Hi Eugen,

Thanks for the reviews.

On Thu, 2023-08-03 at 16:22 +0300, Eugen Hristev wrote:
> On 8/2/23 17:47, Jason-JH.Lin wrote:
> > In mtk_drm_kms_init(), each element in all_drm_priv should has one
> > display path private data only, such as:
> > all_drm_priv[CRTC_MAIN] should has main_path data only
> > all_drm_priv[CRTC_EXT] should has ext_path data only
> > all_drm_priv[CRTC_THIRD] should has third_path data only
> 
> s/should has/should have/ ?
> 

Although each element is singular, `should have` is correct.

`should` is an auxiliary verb, so we can only use infinitive verbs
after that. 

So this part of comment should be like this:
In mtk_drm_kms_init(), each element in all_drm_priv should have one
display path private data, such as:
all_drm_priv[CRTC_MAIN] should only have main_path data
all_drm_priv[CRTC_EXT] should only have ext_path data
all_drm_priv[CRTC_THIRD] should only have third_path data

Right?

> > 
> > So we need to add the length checking for each display path before
> > assigning their drm private data into all_drm_priv array.
> > 
> > Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195
> > multi mmsys support")
> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > Reviewed-by: AngeloGioacchino Del Regno <
> > angelogioacchino.delregno@collabora.com>
> > Reviewed-by: CK Hu <ck.hu@mediatek.com>
> > ---
> >   drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 +++++++++++++---
> >   1 file changed, 13 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > index 89a38561ba27..c12886f31e54 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > @@ -351,6 +351,7 @@ static bool mtk_drm_get_all_drm_priv(struct
> > device *dev)
> >   {
> >   	struct mtk_drm_private *drm_priv = dev_get_drvdata(dev);
> >   	struct mtk_drm_private *all_drm_priv[MAX_CRTC];
> > +	struct mtk_drm_private *temp_drm_priv;
> >   	struct device_node *phandle = dev->parent->of_node;
> >   	const struct of_device_id *of_id;
> >   	struct device_node *node;
> > @@ -373,9 +374,18 @@ static bool mtk_drm_get_all_drm_priv(struct
> > device *dev)
> >   		if (!drm_dev || !dev_get_drvdata(drm_dev))
> >   			continue;
> >   
> > -		all_drm_priv[cnt] = dev_get_drvdata(drm_dev);
> > -		if (all_drm_priv[cnt] && all_drm_priv[cnt]-
> > >mtk_drm_bound)
> > -			cnt++;
> > +		temp_drm_priv = dev_get_drvdata(drm_dev);
> > +		if (temp_drm_priv) {
> 
> This is inside a 'for' loop right ?
> Why don't you just 'continue' if temp_drm_priv is null ?
> 

Yes, you are right.
I'll use `if (!temp_drm_priv) continue;` to make this statement
simpler. Thanks.

Regards,
Jason-JH.Lin.

> 
> > +			if (temp_drm_priv->mtk_drm_bound)
> > +				cnt++;
> > +
> > +			if (temp_drm_priv->data->main_len)
> > +				all_drm_priv[CRTC_MAIN] =
> > temp_drm_priv;
> > +			else if (temp_drm_priv->data->ext_len)
> > +				all_drm_priv[CRTC_EXT] = temp_drm_priv;
> > +			else if (temp_drm_priv->data->third_len)
> > +				all_drm_priv[CRTC_THIRD] =
> > temp_drm_priv;
> > +		}
> >   	}
> >   
> >   	if (drm_priv->data->mmsys_dev_num == cnt) {
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-05  8:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230802144802.751-1-jason-jh.lin@mediatek.com>
     [not found] ` <20230802144802.751-3-jason-jh.lin@mediatek.com>
2023-08-03 13:18   ` [PATCH v8 2/8] drm/mediatevk: Add crtc path enum for all_drm_priv array Eugen Hristev
2023-08-05  7:27     ` Jason-JH Lin (林睿祥)
     [not found] ` <20230802144802.751-4-jason-jh.lin@mediatek.com>
2023-08-03 13:22   ` [PATCH v8 3/8] drm/mediatek: Fix using wrong drm private data to bind mediatek-drm Eugen Hristev
2023-08-05  8:05     ` Jason-JH Lin (林睿祥)
     [not found] ` <20230802144802.751-5-jason-jh.lin@mediatek.com>
2023-08-03 13:27   ` [PATCH v8 4/8] drm/mediatek: Add encoder_index function to mtk_ddp_comp_funcs Eugen Hristev
2023-08-05  7:40     ` Jason-JH Lin (林睿祥)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®