From: Joakim Zhang <qiangqing.zhang@nxp.com> To: Russell King <linux@armlinux.org.uk> Cc: "davem@davemloft.net" <davem@davemloft.net>, "kuba@kernel.org" <kuba@kernel.org>, "peppe.cavallaro@st.com" <peppe.cavallaro@st.com>, "alexandre.torgue@foss.st.com" <alexandre.torgue@foss.st.com>, "joabreu@synopsys.com" <joabreu@synopsys.com>, "mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-stm32@st-md-mailman.stormreply.com" <linux-stm32@st-md-mailman.stormreply.com>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, dl-linux-imx <linux-imx@nxp.com> Subject: RE: [PATCH net 1/2] net: fec_ptp: add clock rate zero check Date: Wed, 16 Jun 2021 11:40:29 +0000 [thread overview] Message-ID: <VI1PR04MB68004D29895652864B4C1D20E60F9@VI1PR04MB6800.eurprd04.prod.outlook.com> (raw) In-Reply-To: <20210616102038.GB22278@shell.armlinux.org.uk> Hi Russell, > -----Original Message----- > From: Russell King <linux@armlinux.org.uk> > Sent: 2021年6月16日 18:21 > To: Joakim Zhang <qiangqing.zhang@nxp.com> > Cc: davem@davemloft.net; kuba@kernel.org; peppe.cavallaro@st.com; > alexandre.torgue@foss.st.com; joabreu@synopsys.com; > mcoquelin.stm32@gmail.com; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; > linux-arm-kernel@lists.infradead.org; dl-linux-imx <linux-imx@nxp.com> > Subject: Re: [PATCH net 1/2] net: fec_ptp: add clock rate zero check > > On Wed, Jun 16, 2021 at 05:14:25PM +0800, Joakim Zhang wrote: > > From: Fugang Duan <fugang.duan@nxp.com> > > > > Add clock rate zero check to fix coverity issue of "divide by 0". > > > > Fixes: commit 85bd1798b24a ("net: fec: fix spin_lock dead lock") > > Signed-off-by: Fugang Duan <fugang.duan@nxp.com> > > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> > > --- > > drivers/net/ethernet/freescale/fec_ptp.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c > > b/drivers/net/ethernet/freescale/fec_ptp.c > > index 1753807cbf97..7326a0612823 100644 > > --- a/drivers/net/ethernet/freescale/fec_ptp.c > > +++ b/drivers/net/ethernet/freescale/fec_ptp.c > > @@ -604,6 +604,10 @@ void fec_ptp_init(struct platform_device *pdev, int > irq_idx) > > fep->ptp_caps.enable = fec_ptp_enable; > > > > fep->cycle_speed = clk_get_rate(fep->clk_ptp); > > + if (!fep->cycle_speed) { > > + fep->cycle_speed = NSEC_PER_SEC; > > + dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); > > If this is supposed to be an error message, it doesn't convey that something is > really wrong to the user. Maybe something like this would be more meaningful > to the user: > > "PTP clock rate should not be zero, using 1GHz instead. PTP > clock may be unreliable.\n" Make Sense. > It may be appropriate not to publish PTP support for the interface if we don't > have a valid clock rate, which is probably the safer approach and would > probably make the problem more noticable to the end user so it gets fixed. Do you mean that print an error message then return directly? It seems better. if (!fep->cycle_speed) { dev_err(&fep->pdev->dev, "PTP clock rate should not be zero!\n"); return; } Best Regards, Joakim Zhang > -- > RMK's Patch system: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar > mlinux.org.uk%2Fdeveloper%2Fpatches%2F&data=04%7C01%7Cqiangqin > g.zhang%40nxp.com%7Cb3c85322e359446e4eee08d930b06701%7C686ea1d3 > bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637594356476903644%7CUnknow > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > WwiLCJXVCI6Mn0%3D%7C1000&sdata=TH4fZJRu8Ii6w7y05N8CHWoQR > R9OegsYB7VAwgSpTcU%3D&reserved=0 > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
WARNING: multiple messages have this Message-ID (diff)
From: Joakim Zhang <qiangqing.zhang@nxp.com> To: Russell King <linux@armlinux.org.uk> Cc: "davem@davemloft.net" <davem@davemloft.net>, "kuba@kernel.org" <kuba@kernel.org>, "peppe.cavallaro@st.com" <peppe.cavallaro@st.com>, "alexandre.torgue@foss.st.com" <alexandre.torgue@foss.st.com>, "joabreu@synopsys.com" <joabreu@synopsys.com>, "mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-stm32@st-md-mailman.stormreply.com" <linux-stm32@st-md-mailman.stormreply.com>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, dl-linux-imx <linux-imx@nxp.com> Subject: RE: [PATCH net 1/2] net: fec_ptp: add clock rate zero check Date: Wed, 16 Jun 2021 11:40:29 +0000 [thread overview] Message-ID: <VI1PR04MB68004D29895652864B4C1D20E60F9@VI1PR04MB6800.eurprd04.prod.outlook.com> (raw) In-Reply-To: <20210616102038.GB22278@shell.armlinux.org.uk> Hi Russell, > -----Original Message----- > From: Russell King <linux@armlinux.org.uk> > Sent: 2021年6月16日 18:21 > To: Joakim Zhang <qiangqing.zhang@nxp.com> > Cc: davem@davemloft.net; kuba@kernel.org; peppe.cavallaro@st.com; > alexandre.torgue@foss.st.com; joabreu@synopsys.com; > mcoquelin.stm32@gmail.com; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; > linux-arm-kernel@lists.infradead.org; dl-linux-imx <linux-imx@nxp.com> > Subject: Re: [PATCH net 1/2] net: fec_ptp: add clock rate zero check > > On Wed, Jun 16, 2021 at 05:14:25PM +0800, Joakim Zhang wrote: > > From: Fugang Duan <fugang.duan@nxp.com> > > > > Add clock rate zero check to fix coverity issue of "divide by 0". > > > > Fixes: commit 85bd1798b24a ("net: fec: fix spin_lock dead lock") > > Signed-off-by: Fugang Duan <fugang.duan@nxp.com> > > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> > > --- > > drivers/net/ethernet/freescale/fec_ptp.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c > > b/drivers/net/ethernet/freescale/fec_ptp.c > > index 1753807cbf97..7326a0612823 100644 > > --- a/drivers/net/ethernet/freescale/fec_ptp.c > > +++ b/drivers/net/ethernet/freescale/fec_ptp.c > > @@ -604,6 +604,10 @@ void fec_ptp_init(struct platform_device *pdev, int > irq_idx) > > fep->ptp_caps.enable = fec_ptp_enable; > > > > fep->cycle_speed = clk_get_rate(fep->clk_ptp); > > + if (!fep->cycle_speed) { > > + fep->cycle_speed = NSEC_PER_SEC; > > + dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); > > If this is supposed to be an error message, it doesn't convey that something is > really wrong to the user. Maybe something like this would be more meaningful > to the user: > > "PTP clock rate should not be zero, using 1GHz instead. PTP > clock may be unreliable.\n" Make Sense. > It may be appropriate not to publish PTP support for the interface if we don't > have a valid clock rate, which is probably the safer approach and would > probably make the problem more noticable to the end user so it gets fixed. Do you mean that print an error message then return directly? It seems better. if (!fep->cycle_speed) { dev_err(&fep->pdev->dev, "PTP clock rate should not be zero!\n"); return; } Best Regards, Joakim Zhang > -- > RMK's Patch system: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar > mlinux.org.uk%2Fdeveloper%2Fpatches%2F&data=04%7C01%7Cqiangqin > g.zhang%40nxp.com%7Cb3c85322e359446e4eee08d930b06701%7C686ea1d3 > bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637594356476903644%7CUnknow > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > WwiLCJXVCI6Mn0%3D%7C1000&sdata=TH4fZJRu8Ii6w7y05N8CHWoQR > R9OegsYB7VAwgSpTcU%3D&reserved=0 > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-06-16 11:40 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-16 9:14 [PATCH net 0/2] net: fixes for fec ptp Joakim Zhang 2021-06-16 9:14 ` Joakim Zhang 2021-06-16 9:14 ` [PATCH net 1/2] net: fec_ptp: add clock rate zero check Joakim Zhang 2021-06-16 9:14 ` Joakim Zhang 2021-06-16 10:20 ` Russell King (Oracle) 2021-06-16 10:20 ` Russell King (Oracle) 2021-06-16 11:40 ` Joakim Zhang [this message] 2021-06-16 11:40 ` Joakim Zhang 2021-06-16 13:28 ` Russell King (Oracle) 2021-06-16 13:28 ` Russell King (Oracle) 2021-06-16 9:14 ` [PATCH net 2/2] net: fec_ptp: fix issue caused by refactor the fec_devtype Joakim Zhang 2021-06-16 9:14 ` Joakim Zhang 2021-06-16 19:50 ` [PATCH net 0/2] net: fixes for fec ptp patchwork-bot+netdevbpf 2021-06-16 19:50 ` patchwork-bot+netdevbpf
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=VI1PR04MB68004D29895652864B4C1D20E60F9@VI1PR04MB6800.eurprd04.prod.outlook.com \ --to=qiangqing.zhang@nxp.com \ --cc=alexandre.torgue@foss.st.com \ --cc=davem@davemloft.net \ --cc=joabreu@synopsys.com \ --cc=kuba@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=linux@armlinux.org.uk \ --cc=mcoquelin.stm32@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=peppe.cavallaro@st.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.