Commit 4119bd55 authored by Tomi Valkeinen's avatar Tomi Valkeinen

drm/omap: pll: fix iteration loop check

If the PLL calc function is given bad parameters, n_start/m_start may be
higher than n_stop/m_stop, which leads to the loops iterating through
the whole u32 number space.

Fix this by failing early on such cases.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-59-tomi.valkeinen@ti.com
parent 0073b8cd
...@@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, ...@@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max); n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
n_inc = 1; n_inc = 1;
if (n_start > n_stop)
return false;
if (hw->errata_i886) { if (hw->errata_i886) {
swap(n_start, n_stop); swap(n_start, n_stop);
n_inc = -1; n_inc = -1;
...@@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, ...@@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
hw->m_max); hw->m_max);
m_inc = 1; m_inc = 1;
if (m_start > m_stop)
continue;
if (hw->errata_i886) { if (hw->errata_i886) {
swap(m_start, m_stop); swap(m_start, m_stop);
m_inc = -1; m_inc = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment