From: phucduc.bui@gmail.com
To: Wei Fang <wei.fang@nxp.com>, Frank Li <frank.li@nxp.com>,
Shenwei Wang <shenwei.wang@nxp.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
davem@davemloft.net, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
imx@lists.linux.dev, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH net-next v6 1/2] net: fec: Propagate PTP initialization errors
Date: Fri, 11 Sep 2026 11:00:20 +0700 [thread overview]
Message-ID: <20260911040021.12289-1-phucduc.bui@gmail.com> (raw)
From: bui duc phuc <phucduc.bui@gmail.com>
Change fec_ptp_init() to return an error code instead of silently
ignoring failures during PTP initialization.
The PPS IRQ is not required for the FEC/PTP functionality, so its
absence should not make the probe fail. However, an unavailable
optional IRQ should be distinguished from an actual error returned
during the IRQ lookup.
If a platform does not support the PPS IRQ, it can omit the IRQ from
its device tree and the optional lookup will return -ENXIO. Propagate
other errors from the IRQ lookup instead of silently ignoring them.
In particular, silently ignoring -EPROBE_DEFER can cause the driver to
continue probing instead of deferring as required.
Also propagate failures from devm_request_irq() and ptp_clock_register().
Update the function declaration in fec.h accordingly.
Found by manual code inspection.
Reviewed-by: Wei Fang <wei.fang@nxp.com>
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
Link v1:
https://lore.kernel.org/all/20260820111416.97917-1-phucduc.bui@gmail.com/
Link v2:
https://lore.kernel.org/all/20260903092430.354186-1-phucduc.bui@gmail.com/
Link v3:
https://lore.kernel.org/all/20260904105542.70540-1-phucduc.bui@gmail.com/
Link v4:
https://lore.kernel.org/all/20260907034502.12619-1-phucduc.bui@gmail.com/
Link v5:
https://lore.kernel.org/all/20260909064712.22539-1-phucduc.bui@gmail.com/
Changes in v2:
- Squash the two patches into one.
- Add error handling for platform_get_irq_byname_optional().
- Fix error handling for ptp_clock_register().
Changes in v3:
- Retarget the patch to the net tree instead of net-next.
- Add error handling for platform_get_irq_byname_optional()
in fec_probe() for the fec_enet_interrupt IRQ.
Changes in v4:
- Use a goto label for cleanup instead of returning directly on errors
from platform_get_irq_byname_optional() in probe().
- Update the commit message.
Changes in v5:
- Split the optional IRQ handling in fec_main.c into a separate patch.
Changes in v6:
- Add a KDoc comment for fec_ptp_init().
- Repost this series for net-next without the Fixes: tags.
drivers/net/ethernet/freescale/fec.h | 2 +-
drivers/net/ethernet/freescale/fec_main.c | 7 +++++--
drivers/net/ethernet/freescale/fec_ptp.c | 24 +++++++++++++++--------
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 7176803146f3..8831da37326b 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -692,7 +692,7 @@ struct fec_enet_private {
u64 ethtool_stats[];
};
-void fec_ptp_init(struct platform_device *pdev, int irq_idx);
+int fec_ptp_init(struct platform_device *pdev, int irq_idx);
void fec_ptp_restore_state(struct fec_enet_private *fep);
void fec_ptp_save_state(struct fec_enet_private *fep);
void fec_ptp_stop(struct platform_device *pdev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 794ec427b0ee..c6e29b5c2abb 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -5384,8 +5384,11 @@ fec_probe(struct platform_device *pdev)
goto failed_reset;
irq_cnt = fec_enet_get_irq_cnt(pdev);
- if (fep->bufdesc_ex)
- fec_ptp_init(pdev, irq_cnt);
+ if (fep->bufdesc_ex) {
+ ret = fec_ptp_init(pdev, irq_cnt);
+ if (ret)
+ goto failed_reset;
+ }
ret = fec_enet_init(ndev);
if (ret)
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 56801c2009d5..0574a1a18702 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -734,9 +734,11 @@ static irqreturn_t fec_pps_interrupt(int irq, void *dev_id)
* This function performs the required steps for enabling ptp
* support. If ptp support has already been loaded it simply calls the
* cyclecounter init routine and exits.
+ *
+ * Return: 0 on success, or a negative error code on failure.
*/
-void fec_ptp_init(struct platform_device *pdev, int irq_idx)
+int fec_ptp_init(struct platform_device *pdev, int irq_idx)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);
@@ -779,26 +781,32 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
HRTIMER_MODE_REL);
irq = platform_get_irq_byname_optional(pdev, "pps");
- if (irq < 0)
+ if (irq < 0 && irq != -ENXIO)
+ return irq;
+ if (irq == -ENXIO) {
irq = platform_get_irq_optional(pdev, irq_idx);
- /* Failure to get an irq is not fatal,
- * only the PTP_CLOCK_PPS clock events should stop
- */
- if (irq >= 0) {
+ if (irq < 0 && irq != -ENXIO)
+ return irq;
+ }
+
+ if (irq > 0) {
ret = devm_request_irq(&pdev->dev, irq, fec_pps_interrupt,
0, pdev->name, ndev);
if (ret < 0)
- dev_warn(&pdev->dev, "request for pps irq failed(%d)\n",
- ret);
+ return ret;
}
fep->ptp_clock = ptp_clock_register(&fep->ptp_caps, &pdev->dev);
if (IS_ERR(fep->ptp_clock)) {
+ ret = PTR_ERR(fep->ptp_clock);
fep->ptp_clock = NULL;
dev_err(&pdev->dev, "ptp_clock_register failed\n");
+ return ret;
}
schedule_delayed_work(&fep->time_keep, HZ);
+
+ return 0;
}
void fec_ptp_save_state(struct fec_enet_private *fep)
--
2.43.0
next reply other threads:[~2026-09-11 4:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 4:00 phucduc.bui [this message]
2026-09-11 4:00 ` [PATCH net-next v6 2/2] net: fec: Handle optional IRQ lookup errors correctly phucduc.bui
2026-09-12 4:03 ` sashiko-bot
2026-09-12 4:03 ` [PATCH net-next v6 1/2] net: fec: Propagate PTP initialization errors sashiko-bot
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=20260911040021.12289-1-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=shenwei.wang@nxp.com \
--cc=wei.fang@nxp.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 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.