From: Daniel Machon <daniel.machon@microchip.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
<UNGLinuxDriver@microchip.com>,
"Richard Cochran" <richardcochran@gmail.com>,
<maxime.chevallier@bootlin.com>, <rmk+kernel@armlinux.org.uk>
Cc: <netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next v2 7/9] net: sparx5: move PTP IRQ handling out of sparx5_start()
Date: Fri, 27 Feb 2026 15:56:45 +0100 [thread overview]
Message-ID: <20260227-sparx5-init-deinit-v2-7-10ba54ccf005@microchip.com> (raw)
In-Reply-To: <20260227-sparx5-init-deinit-v2-0-10ba54ccf005@microchip.com>
Move the PTP IRQ request into sparx5_ptp_init() so all PTP setup is
done in one place.
Also move the sparx5_ptp_init() call to right before
sparx5_register_netdevs() and add a cleanup_ptp label. Update remove()
to disable the PTP IRQ and reorder ptp_deinit accordingly.
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../net/ethernet/microchip/sparx5/sparx5_main.c | 34 +++++++---------------
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 18 ++++++++++++
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index d37f34197e84..f359008d2205 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -761,18 +761,6 @@ static int sparx5_start(struct sparx5 *sparx5)
sparx5->xtr_irq = -ENXIO;
}
- if (sparx5->ptp_irq >= 0 &&
- sparx5_has_feature(sparx5, SPX5_FEATURE_PTP)) {
- err = devm_request_threaded_irq(sparx5->dev, sparx5->ptp_irq,
- NULL, ops->ptp_irq_handler,
- IRQF_ONESHOT, "sparx5-ptp",
- sparx5);
- if (err)
- sparx5->ptp_irq = -ENXIO;
-
- sparx5->ptp = 1;
- }
-
return err;
}
@@ -957,16 +945,10 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
goto cleanup_ports;
}
- err = sparx5_ptp_init(sparx5);
- if (err) {
- dev_err(sparx5->dev, "PTP failed\n");
- goto cleanup_ports;
- }
-
err = sparx5_vcap_init(sparx5);
if (err) {
dev_err(sparx5->dev, "Failed to initialize VCAP\n");
- goto cleanup_ptp;
+ goto cleanup_ports;
}
err = sparx5_mact_init(sparx5);
@@ -983,10 +965,16 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&sparx5->mall_entries);
+ err = sparx5_ptp_init(sparx5);
+ if (err) {
+ dev_err(sparx5->dev, "Failed to initialize PTP\n");
+ goto cleanup_stats;
+ }
+
err = sparx5_register_netdevs(sparx5);
if (err) {
dev_err(sparx5->dev, "Failed to register net devices\n");
- goto cleanup_stats;
+ goto cleanup_ptp;
}
err = sparx5_register_notifier_blocks(sparx5);
@@ -999,14 +987,14 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
cleanup_netdevs:
sparx5_unregister_netdevs(sparx5);
+cleanup_ptp:
+ sparx5_ptp_deinit(sparx5);
cleanup_stats:
sparx5_stats_deinit(sparx5);
cleanup_mact:
sparx5_mact_deinit(sparx5);
cleanup_vcap:
sparx5_vcap_deinit(sparx5);
-cleanup_ptp:
- sparx5_ptp_deinit(sparx5);
cleanup_ports:
sparx5_destroy_netdevs(sparx5);
cleanup_config:
@@ -1032,10 +1020,10 @@ static void mchp_sparx5_remove(struct platform_device *pdev)
}
sparx5_unregister_notifier_blocks(sparx5);
sparx5_unregister_netdevs(sparx5);
+ sparx5_ptp_deinit(sparx5);
sparx5_stats_deinit(sparx5);
sparx5_mact_deinit(sparx5);
sparx5_vcap_deinit(sparx5);
- sparx5_ptp_deinit(sparx5);
ops->fdma_deinit(sparx5);
sparx5_destroy_netdevs(sparx5);
}
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
index 8b2e07821a95..a16ec8136d6d 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
@@ -606,9 +606,22 @@ static int sparx5_ptp_phc_init(struct sparx5 *sparx5,
int sparx5_ptp_init(struct sparx5 *sparx5)
{
u64 tod_adj = sparx5_ptp_get_nominal_value(sparx5);
+ const struct sparx5_ops *ops = sparx5->data->ops;
struct sparx5_port *port;
int err, i;
+ if (sparx5->ptp_irq >= 0 &&
+ sparx5_has_feature(sparx5, SPX5_FEATURE_PTP)) {
+ err = devm_request_threaded_irq(sparx5->dev, sparx5->ptp_irq,
+ NULL, ops->ptp_irq_handler,
+ IRQF_ONESHOT, "sparx5-ptp",
+ sparx5);
+ if (err)
+ sparx5->ptp_irq = -ENXIO;
+
+ sparx5->ptp = 1;
+ }
+
if (!sparx5->ptp)
return 0;
@@ -660,6 +673,11 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5)
struct sparx5_port *port;
int i;
+ if (sparx5->ptp_irq >= 0) {
+ disable_irq(sparx5->ptp_irq);
+ sparx5->ptp_irq = -ENXIO;
+ }
+
for (i = 0; i < sparx5->data->consts->n_ports; i++) {
port = sparx5->ports[i];
if (!port)
--
2.34.1
next prev parent reply other threads:[~2026-02-27 14:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 14:56 [PATCH net-next v2 0/9] net: sparx5: clean up probe/remove init and deinit paths Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 1/9] net: sparx5: move netdev and notifier block registration to probe Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 2/9] net: sparx5: move VCAP initialization " Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 3/9] net: sparx5: move MAC table initialization and add deinit function Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 4/9] net: sparx5: move stats " Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 5/9] net: sparx5: move calendar initialization to probe Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 6/9] net: sparx5: move remaining init functions from start() to probe() Daniel Machon
2026-02-27 14:56 ` Daniel Machon [this message]
2026-02-27 14:56 ` [PATCH net-next v2 8/9] net: sparx5: move FDMA/XTR initialization out of sparx5_start() Daniel Machon
2026-02-27 14:56 ` [PATCH net-next v2 9/9] net: sparx5: replace sparx5_start() with sparx5_forwarding_init() Daniel Machon
2026-03-03 4:46 ` [PATCH net-next v2 0/9] net: sparx5: clean up probe/remove init and deinit paths 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=20260227-sparx5-init-deinit-v2-7-10ba54ccf005@microchip.com \
--to=daniel.machon@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
/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