From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, dongcheng.yan@intel.com
Subject: Re: [PATCH v2 09/11] media: ccs-pll: Better validate VT PLL branch
Date: Mon, 21 Apr 2025 23:24:29 +0300 [thread overview]
Message-ID: <20250421202429.GJ17813@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250417065354.311617-10-sakari.ailus@linux.intel.com>
Hi Sakari,
Thank you for the patch.
On Thu, Apr 17, 2025 at 09:53:52AM +0300, Sakari Ailus wrote:
> Check that the VT PLL dividers are actually found, don't trust they always
> are even though they should be.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/media/i2c/ccs-pll.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c
> index 3f8153fb4af0..fc6f8aff5fd8 100644
> --- a/drivers/media/i2c/ccs-pll.c
> +++ b/drivers/media/i2c/ccs-pll.c
> @@ -449,7 +449,7 @@ static int ccs_pll_calculate_vt_tree(struct device *dev,
> return -EINVAL;
> }
>
> -static void
> +static int
> ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,
> const struct ccs_pll_branch_limits_bk *op_lim_bk,
> struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr,
> @@ -572,6 +572,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,
> if (best_pix_div < SHRT_MAX >> 1)
> break;
> }
> + if (best_pix_div == SHRT_MAX >> 1)
> + return -EINVAL;
I think I would have written
if (vt_div > max_vt_div)
return -EINVAL;
to match the for loop condition, this seems a bit more readable to me.
The result should be the same though, so either way,
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> pll->vt_bk.sys_clk_div = DIV_ROUND_UP(vt_div, best_pix_div);
> pll->vt_bk.pix_clk_div = best_pix_div;
> @@ -584,6 +586,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,
> out_calc_pixel_rate:
> pll->pixel_rate_pixel_array =
> pll->vt_bk.pix_clk_freq_hz * pll->vt_lanes;
> +
> + return 0;
> }
>
> /*
> @@ -863,8 +867,10 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,
> if (pll->flags & CCS_PLL_FLAG_DUAL_PLL)
> break;
>
> - ccs_pll_calculate_vt(dev, lim, op_lim_bk, pll, op_pll_fr,
> - op_pll_bk, cphy, phy_const);
> + rval = ccs_pll_calculate_vt(dev, lim, op_lim_bk, pll, op_pll_fr,
> + op_pll_bk, cphy, phy_const);
> + if (rval)
> + continue;
>
> rval = check_bk_bounds(dev, lim, pll, PLL_VT);
> if (rval)
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2025-04-21 20:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 6:53 [PATCH v2 00/11] CCS PLL fixes and improvements Sakari Ailus
2025-04-17 6:53 ` [PATCH v2 01/11] media: ccs-pll: Start OP pre-PLL multiplier search from correct value Sakari Ailus
2025-04-21 19:50 ` Laurent Pinchart
2025-04-22 11:43 ` Sakari Ailus
2025-04-22 11:50 ` Laurent Pinchart
2025-04-22 12:07 ` Sakari Ailus
2025-04-17 6:53 ` [PATCH v2 02/11] media: ccs-pll: Start VT " Sakari Ailus
2025-04-21 19:53 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 03/11] media: ccs-pll: Check for too high VT PLL multiplier in dual PLL case Sakari Ailus
2025-04-21 19:56 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 04/11] media: ccs-pll: Correctly the upper limit of maximum op_pre_pll_clk_div Sakari Ailus
2025-04-21 20:01 ` Laurent Pinchart
2025-04-23 11:55 ` Sakari Ailus
2025-04-17 6:53 ` [PATCH v2 05/11] media: ccs-pll: Print a debug message on too high VT PLL OP clock Sakari Ailus
2025-04-21 20:02 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 06/11] media: ccs-pll: Drop LINK_DECOUPLED flag Sakari Ailus
2025-04-21 20:03 ` Laurent Pinchart
2025-04-23 12:04 ` Sakari Ailus
2025-04-23 12:22 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 07/11] media: ccs-pll: Print missing PLL flags Sakari Ailus
2025-04-21 20:05 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 08/11] media: ccs-pll: Add a flag for even PLL multipliers Sakari Ailus
2025-04-21 20:19 ` Laurent Pinchart
2025-04-23 10:19 ` Sakari Ailus
2025-04-17 6:53 ` [PATCH v2 09/11] media: ccs-pll: Better validate VT PLL branch Sakari Ailus
2025-04-21 20:24 ` Laurent Pinchart [this message]
2025-04-23 10:26 ` Sakari Ailus
2025-04-17 6:53 ` [PATCH v2 10/11] media: ccs-pll: Print PLL calculator flags in the beginning Sakari Ailus
2025-04-21 20:25 ` Laurent Pinchart
2025-04-17 6:53 ` [PATCH v2 11/11] media: ccs-pll: Document the CCS PLL flags Sakari Ailus
2025-04-21 20:29 ` Laurent Pinchart
2025-04-22 11:49 ` Sakari Ailus
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=20250421202429.GJ17813@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dongcheng.yan@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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