linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Kishon Vijay Abraham I <kishon@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Guillaume Ranquet <granquet@baylibre.com>,
	linux-mediatek@lists.infradead.org,
	linux-phy@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH] phy: mediatek: Avoid floating point constants
Date: Wed, 17 May 2023 18:21:34 +0530	[thread overview]
Message-ID: <ZGTN1vWnxmaR/XKM@matsya> (raw)
In-Reply-To: <89583b89-ea8c-8096-b083-6ab773e6c281@nvidia.com>

On 17-05-23, 12:59, Jon Hunter wrote:
> Hi Vinod,
> 
> On 19/04/2023 13:21, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > When building with old versions of GCC (6.3 in this case), the compiler
> > stumbles over the floating point constants in this driver:
> > 
> > 	: In function ‘mtk_hdmi_pll_prepare’:
> > 	drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:331:23: error: ‘-mgeneral-regs-only’ is incompatible with floating-point code
> > 	  } else if (pixel_clk >= 74.175 * MEGA && pixel_clk <= 300 * MEGA) {
> > 
> > 	drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:361:12: error: ‘-mgeneral-regs-only’ is incompatible with floating-point code
> > 	 static int mtk_hdmi_pll_prepare(struct clk_hw *hw)
> > 		    ^~~~~~~~~~~~~~~~~~~~
> > 	drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:361:12: error: ‘-mgeneral-regs-only’ is incompatible with floating-point code
> > 
> > Fix this by switching to the KILO macro instead and multiplying the
> > constants by 1000 to get rid of the floating point.
> > 
> > Fixes: 45810d486bb4 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195")
> > Reported-by: Jonathan Hunter <jonathanh@nvidia.com>
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >   drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c
> > index abfc077fb0a8..b10af26cad2f 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c
> > @@ -239,9 +239,9 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw,
> >   		txposdiv = 8;
> >   	else if (tmds_clk >= 54 * MEGA && tmds_clk < 148.35 * MEGA)
> >   		txposdiv = 4;
> > -	else if (tmds_clk >= 148.35 * MEGA && tmds_clk < 296.7 * MEGA)
> > +	else if (tmds_clk >= 148350 * KILO && tmds_clk < 296700 * KILO)
> >   		txposdiv = 2;
> > -	else if (tmds_clk >= 296.7 * MEGA && tmds_clk <= 594 * MEGA)
> > +	else if (tmds_clk >= 296700 * KILO && tmds_clk <= 594 * MEGA)
> >   		txposdiv = 1;
> >   	else
> >   		return -EINVAL;
> > @@ -328,12 +328,12 @@ static int mtk_hdmi_pll_drv_setting(struct clk_hw *hw)
> >   		clk_channel_bias = 0x34; /* 20mA */
> >   		impedance_en = 0xf;
> >   		impedance = 0x36; /* 100ohm */
> > -	} else if (pixel_clk >= 74.175 * MEGA && pixel_clk <= 300 * MEGA) {
> > +	} else if (pixel_clk >= 74175 * KILO && pixel_clk <= 300 * MEGA) {
> >   		data_channel_bias = 0x34; /* 20mA */
> >   		clk_channel_bias = 0x2c; /* 16mA */
> >   		impedance_en = 0xf;
> >   		impedance = 0x36; /* 100ohm */
> > -	} else if (pixel_clk >= 27 * MEGA && pixel_clk < 74.175 * MEGA) {
> > +	} else if (pixel_clk >= 27 * MEGA && pixel_clk < 74175 * KILO) {
> >   		data_channel_bias = 0x14; /* 10mA */
> >   		clk_channel_bias = 0x14; /* 10mA */
> >   		impedance_en = 0x0;
> 
> 
> This is breaking kernel compilation with older compilers such as GCC7. This
> is now in the mainline and older compilers cannot build the kernel with this
> driver enabled. The kernel docs say the min version supported is GCC 5.1
> currently.
> 
> Can we get this merged as a fix for v6.4?

Sorry I missed this one but I have already applied 03262a3f5b5b ("phy:
mediatek: rework the floating point comparisons to fixed point") and
this is in linux-next and should be hopefully in Linus's tree in next rc

Thanks
-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2023-05-17 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19 12:21 [PATCH] phy: mediatek: Avoid floating point constants Thierry Reding
2023-04-19 12:29 ` AngeloGioacchino Del Regno
2023-04-19 13:52 ` Guillaume Ranquet
2023-05-17 11:59 ` Jon Hunter
2023-05-17 12:51   ` Vinod Koul [this message]

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=ZGTN1vWnxmaR/XKM@matsya \
    --to=vkoul@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=granquet@baylibre.com \
    --cc=jonathanh@nvidia.com \
    --cc=kishon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).