Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"kernel@collabora.com" <kernel@collabora.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Nathan Lu (呂東霖)" <Nathan.Lu@mediatek.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Subject: Re: [PATCH 1/3] drm/mediatek: drm_ddp_comp: Fix and cleanup DDP component CRTC search
Date: Fri, 22 Mar 2024 07:30:30 +0000	[thread overview]
Message-ID: <72a1d501d001899eeac9b4c308a291f0fa86e935.camel@mediatek.com> (raw)
In-Reply-To: <20240201125304.218467-2-angelogioacchino.delregno@collabora.com>

Hi, Angelo:

On Thu, 2024-02-01 at 13:53 +0100, AngeloGioacchino Del Regno wrote:
> Finding a possible CRTC by DDP component is done by first checking
> static routes in three paths (main, external, third/extra path) and
> then, if not found, we check for dynamic connection on a per-route
> basis because, for example, on some SoCs the main route may output
> to either a DSI display or DisplayPort and this is finally done by
> assigning a CRTC mask to `possible_crtcs`, found with function
> mtk_drm_find_comp_in_ddp_conn_path(): being that a mask the possible
> values are BIT(x) and, if no CRTC is possible, zero.
> 
> Problem is, both mtk_drm_find_possible_crtc_by_comp() and the
> aforementioned function are trying to return a negative error value
> (but it's unsigned int!) if no CRTC was found, which is wrong for
> multiple obvious reasons.

I does not find anywhere to return negative value. So this patch just
like a refine patch not bug fix.

Regards,
CK

> 
> Cleanup both functions, so that:
>  - mtk_drm_find_comp_in_ddp_conn_path() returns a signed integer
>    with a negative number for error, or a bit/bitmask of the found
>    possible CRTC; and
>  - mtk_drm_find_possible_crtc_by_comp() always returns either a
>    bitmask of the possible CRTC, or zero if none available.
> 
> Fixes: 01389b324c97 ("drm/mediatek: Add connector dynamic selection
> capability")
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 44 ++++++++++---------
> --
>  1 file changed, 21 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index a9b5a21cde2d..c13359eeb3cd 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -513,29 +513,25 @@ static bool mtk_drm_find_comp_in_ddp(struct
> device *dev,
>  	return false;
>  }
>  
> -static unsigned int mtk_drm_find_comp_in_ddp_conn_path(struct device
> *dev,
> -						       const struct
> mtk_drm_route *routes,
> -						       unsigned int
> num_routes,
> -						       struct
> mtk_ddp_comp *ddp_comp)
> +static int mtk_drm_find_comp_in_ddp_conn_path(struct device *dev,
> +					      const struct
> mtk_drm_route *routes,
> +					      unsigned int num_routes,
> +					      struct mtk_ddp_comp
> *ddp_comp)
>  {
> -	int ret;
> -	unsigned int i;
> +	int i;
>  
> -	if (!routes) {
> -		ret = -EINVAL;
> -		goto err;
> +	if (!routes || !num_routes) {
> +		DRM_ERROR("No connection routes specified!\n");
> +		return -EINVAL;
>  	}
>  
>  	for (i = 0; i < num_routes; i++)
>  		if (dev == ddp_comp[routes[i].route_ddp].dev)
>  			return BIT(routes[i].crtc_id);
>  
> -	ret = -ENODEV;
> -err:
> -
> -	DRM_INFO("Failed to find comp in ddp table, ret = %d\n", ret);
> +	DRM_ERROR("Failed to find component in ddp table\n");
>  
> -	return 0;
> +	return -ENODEV;
>  }
>  
>  int mtk_ddp_comp_get_id(struct device_node *node,
> @@ -557,22 +553,24 @@ unsigned int
> mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
>  						struct device *dev)
>  {
>  	struct mtk_drm_private *private = drm->dev_private;
> -	unsigned int ret = 0;
> +	int ret;
>  
>  	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> private->data->main_len,
>  				     private->ddp_comp))
> -		ret = BIT(0);
> +		return BIT(0);
>  	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
>  					  private->data->ext_len,
> private->ddp_comp))
> -		ret = BIT(1);
> +		return BIT(1);
>  	else if (mtk_drm_find_comp_in_ddp(dev, private->data-
> >third_path,
>  					  private->data->third_len,
> private->ddp_comp))
> -		ret = BIT(2);
> -	else
> -		ret = mtk_drm_find_comp_in_ddp_conn_path(dev,
> -							 private->data-
> >conn_routes,
> -							 private->data-
> >num_conn_routes,
> -							 private-
> >ddp_comp);
> +		return BIT(2);
> +
> +	ret = mtk_drm_find_comp_in_ddp_conn_path(dev, private->data-
> >conn_routes,
> +						 private->data-
> >num_conn_routes,
> +						 private->ddp_comp);
> +	/* No CRTC is available: return a zero mask */
> +	if (ret < 0)
> +		return 0;
>  
>  	return ret;
>  }
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-03-22  7:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 12:53 [PATCH 0/3] drm/mediatek: Fixes for DDP component search/destroy AngeloGioacchino Del Regno
2024-02-01 12:53 ` [PATCH 1/3] drm/mediatek: drm_ddp_comp: Fix and cleanup DDP component CRTC search AngeloGioacchino Del Regno
2024-03-22  7:30   ` CK Hu (胡俊光) [this message]
2024-02-01 12:53 ` [PATCH 2/3] drm/mediatek: Perform iounmap on simple DDP component destruction AngeloGioacchino Del Regno
2024-03-22  8:48   ` CK Hu (胡俊光)
2024-04-01 14:18     ` Chun-Kuang Hu
2024-02-01 12:53 ` [PATCH 3/3] drm/mediatek: drm_ddp_comp: Add mtk_ddp_is_simple_comp() internal helper AngeloGioacchino Del Regno
2024-03-22  8:57   ` CK Hu (胡俊光)
2024-03-21  9:05 ` [PATCH 0/3] drm/mediatek: Fixes for DDP component search/destroy AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72a1d501d001899eeac9b4c308a291f0fa86e935.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Nathan.Lu@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox