All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports
@ 2023-02-03  8:55 Casper Andersson
  2023-02-03  9:24 ` Horatiu Vultur
  2023-02-06  9:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Casper Andersson @ 2023-02-03  8:55 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Lars Povlsen, Steen Hegelund, Daniel Machon, UNGLinuxDriver,
	Richard Cochran, Horatiu Vultur, netdev

Check all ports instead of just port_count ports. PTP init was only
checking ports 0 to port_count. If the hardware ports are not mapped
starting from 0 then they would be missed, e.g. if only ports 20-30 were
mapped it would attempt to init ports 0-10, resulting in NULL pointers
when attempting to timestamp. Now it will init all mapped ports.

Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping")
Signed-off-by: Casper Andersson <casper.casan@gmail.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
index 0ed1ea7727c5..69e76634f9aa 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
@@ -633,7 +633,7 @@ int sparx5_ptp_init(struct sparx5 *sparx5)
 	/* Enable master counters */
 	spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG);
 
-	for (i = 0; i < sparx5->port_count; i++) {
+	for (i = 0; i < SPX5_PORTS; i++) {
 		port = sparx5->ports[i];
 		if (!port)
 			continue;
@@ -649,7 +649,7 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5)
 	struct sparx5_port *port;
 	int i;
 
-	for (i = 0; i < sparx5->port_count; i++) {
+	for (i = 0; i < SPX5_PORTS; i++) {
 		port = sparx5->ports[i];
 		if (!port)
 			continue;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports
  2023-02-03  8:55 [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports Casper Andersson
@ 2023-02-03  9:24 ` Horatiu Vultur
  2023-02-06  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Horatiu Vultur @ 2023-02-03  9:24 UTC (permalink / raw)
  To: Casper Andersson
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Lars Povlsen, Steen Hegelund, Daniel Machon, UNGLinuxDriver,
	Richard Cochran, netdev

The 02/03/2023 09:55, Casper Andersson wrote:

> 
> Check all ports instead of just port_count ports. PTP init was only
> checking ports 0 to port_count. If the hardware ports are not mapped
> starting from 0 then they would be missed, e.g. if only ports 20-30 were
> mapped it would attempt to init ports 0-10, resulting in NULL pointers
> when attempting to timestamp. Now it will init all mapped ports.
> 
> Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping")
> Signed-off-by: Casper Andersson <casper.casan@gmail.com>

Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>

> ---
>  drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
> index 0ed1ea7727c5..69e76634f9aa 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
> @@ -633,7 +633,7 @@ int sparx5_ptp_init(struct sparx5 *sparx5)
>         /* Enable master counters */
>         spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG);
> 
> -       for (i = 0; i < sparx5->port_count; i++) {
> +       for (i = 0; i < SPX5_PORTS; i++) {
>                 port = sparx5->ports[i];
>                 if (!port)
>                         continue;
> @@ -649,7 +649,7 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5)
>         struct sparx5_port *port;
>         int i;
> 
> -       for (i = 0; i < sparx5->port_count; i++) {
> +       for (i = 0; i < SPX5_PORTS; i++) {
>                 port = sparx5->ports[i];
>                 if (!port)
>                         continue;
> --
> 2.34.1
> 

-- 
/Horatiu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports
  2023-02-03  8:55 [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports Casper Andersson
  2023-02-03  9:24 ` Horatiu Vultur
@ 2023-02-06  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-06  9:30 UTC (permalink / raw)
  To: Casper Andersson
  Cc: davem, edumazet, kuba, pabeni, lars.povlsen, Steen.Hegelund,
	daniel.machon, UNGLinuxDriver, richardcochran, horatiu.vultur,
	netdev

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri,  3 Feb 2023 09:55:57 +0100 you wrote:
> Check all ports instead of just port_count ports. PTP init was only
> checking ports 0 to port_count. If the hardware ports are not mapped
> starting from 0 then they would be missed, e.g. if only ports 20-30 were
> mapped it would attempt to init ports 0-10, resulting in NULL pointers
> when attempting to timestamp. Now it will init all mapped ports.
> 
> Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping")
> Signed-off-by: Casper Andersson <casper.casan@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net] net: microchip: sparx5: fix PTP init/deinit not checking all ports
    https://git.kernel.org/netdev/net/c/d7d94b2612f5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-06  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03  8:55 [PATCH net] net: microchip: sparx5: fix PTP init/deinit not checking all ports Casper Andersson
2023-02-03  9:24 ` Horatiu Vultur
2023-02-06  9:30 ` patchwork-bot+netdevbpf

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.