diff mbox series

[net] net: dsa: microchip: fix PTP config failure when using multiple ports

Message ID 20240815083814.4273-1-foss@martin-whitaker.me.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dsa: microchip: fix PTP config failure when using multiple ports | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 7 maintainers not CCed: pabeni@redhat.com kuba@kernel.org edumazet@google.com f.fainelli@gmail.com richardcochran@gmail.com olteanv@gmail.com woojung.huh@microchip.com
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-08-15--12-00 (tests: 707)

Commit Message

Martin Whitaker Aug. 15, 2024, 8:38 a.m. UTC
When performing the port_hwtstamp_set operation, ptp_schedule_worker()
will be called if hardware timestamoing is enabled on any of the ports.
When using multiple ports for PTP, port_hwtstamp_set is executed for
each port. When called for the first time ptp_schedule_worker() returns
0. On subsequent calls it returns 1, indicating the worker is already
scheduled. Currently the ksz driver treats 1 as an error and fails to
complete the port_hwtstamp_set operation, thus leaving the timestamping
configuration for those ports unchanged.

This patch fixes this by ignoring the ptp_schedule_worker() return
value.

Link: https://lore.kernel.org/netdev/7aae307a-35ca-4209-a850-7b2749d40f90@martin-whitaker.me.uk/
Signed-off-by: Martin Whitaker <foss@martin-whitaker.me.uk>
---
 drivers/net/dsa/microchip/ksz_ptp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--
2.41.1

Comments

Andrew Lunn Aug. 15, 2024, 2:38 p.m. UTC | #1
On Thu, Aug 15, 2024 at 09:38:14AM +0100, Martin Whitaker wrote:
> When performing the port_hwtstamp_set operation, ptp_schedule_worker()
> will be called if hardware timestamoing is enabled on any of the ports.
> When using multiple ports for PTP, port_hwtstamp_set is executed for
> each port. When called for the first time ptp_schedule_worker() returns
> 0. On subsequent calls it returns 1, indicating the worker is already
> scheduled. Currently the ksz driver treats 1 as an error and fails to
> complete the port_hwtstamp_set operation, thus leaving the timestamping
> configuration for those ports unchanged.
> 
> This patch fixes this by ignoring the ptp_schedule_worker() return
> value.

Hi Martin

Is this your first patch to netdev? Nicely done. A few minor
improvements. You have the correct tree, net, since this is a fix. You
should add a Fixes: tag indicating the patch which added the bug. And
also Cc: stable@stable@vger.kernel.org

Thanks
	Andrew

---
pw-bot: cr
Martin Whitaker Aug. 16, 2024, 5:18 p.m. UTC | #2
On 15/08/2024 15:38, Andrew Lunn wrote:
> On Thu, Aug 15, 2024 at 09:38:14AM +0100, Martin Whitaker wrote:
>> When performing the port_hwtstamp_set operation, ptp_schedule_worker()
>> will be called if hardware timestamoing is enabled on any of the ports.
>> When using multiple ports for PTP, port_hwtstamp_set is executed for
>> each port. When called for the first time ptp_schedule_worker() returns
>> 0. On subsequent calls it returns 1, indicating the worker is already
>> scheduled. Currently the ksz driver treats 1 as an error and fails to
>> complete the port_hwtstamp_set operation, thus leaving the timestamping
>> configuration for those ports unchanged.
>>
>> This patch fixes this by ignoring the ptp_schedule_worker() return
>> value.
>
> Hi Martin
>
> Is this your first patch to netdev? Nicely done. A few minor
> improvements. You have the correct tree, net, since this is a fix. You
> should add a Fixes: tag indicating the patch which added the bug. And
> also Cc: stable@stable@vger.kernel.org
>
> Thanks
> 	Andrew

Hi Andrew,

It's my second patch. Yes, I missed the Fixes: tag. It should be

Fixes: bb01ad30570b0 ("net: dsa: microchip: ptp: manipulating absolute
time using ptp hw clock")

Will you insert this, or do you need me to resend the patch?

Martin
Andrew Lunn Aug. 16, 2024, 9:01 p.m. UTC | #3
On Fri, Aug 16, 2024 at 06:18:46PM +0100, Martin Whitaker wrote:
> On 15/08/2024 15:38, Andrew Lunn wrote:
> > On Thu, Aug 15, 2024 at 09:38:14AM +0100, Martin Whitaker wrote:
> > > When performing the port_hwtstamp_set operation, ptp_schedule_worker()
> > > will be called if hardware timestamoing is enabled on any of the ports.
> > > When using multiple ports for PTP, port_hwtstamp_set is executed for
> > > each port. When called for the first time ptp_schedule_worker() returns
> > > 0. On subsequent calls it returns 1, indicating the worker is already
> > > scheduled. Currently the ksz driver treats 1 as an error and fails to
> > > complete the port_hwtstamp_set operation, thus leaving the timestamping
> > > configuration for those ports unchanged.
> > > 
> > > This patch fixes this by ignoring the ptp_schedule_worker() return
> > > value.
> > 
> > Hi Martin
> > 
> > Is this your first patch to netdev? Nicely done. A few minor
> > improvements. You have the correct tree, net, since this is a fix. You
> > should add a Fixes: tag indicating the patch which added the bug. And
> > also Cc: stable@stable@vger.kernel.org
> > 
> > Thanks
> > 	Andrew
> 
> Hi Andrew,
> 
> It's my second patch. Yes, I missed the Fixes: tag. It should be
> 
> Fixes: bb01ad30570b0 ("net: dsa: microchip: ptp: manipulating absolute
> time using ptp hw clock")
> 
> Will you insert this, or do you need me to resend the patch?

Ideally, please resend it. patchwork might pickup the Fixes: tag from
your reply, but since it was wrapped, it might get it wrong. Sometimes
Jakub fixes things like this when merging patches, but it is easier
for him if there is a new correct version. And it is a good learning
exercise for somebody who i hope will submit more patches in the
future..

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index f0bd46e5d4ec..050f17c43ef6 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -266,7 +266,6 @@  static int ksz_ptp_enable_mode(struct ksz_device *dev)
 	struct ksz_port *prt;
 	struct dsa_port *dp;
 	bool tag_en = false;
-	int ret;

 	dsa_switch_for_each_user_port(dp, dev->ds) {
 		prt = &dev->ports[dp->index];
@@ -277,9 +276,7 @@  static int ksz_ptp_enable_mode(struct ksz_device *dev)
 	}

 	if (tag_en) {
-		ret = ptp_schedule_worker(ptp_data->clock, 0);
-		if (ret)
-			return ret;
+		ptp_schedule_worker(ptp_data->clock, 0);
 	} else {
 		ptp_cancel_worker_sync(ptp_data->clock);
 	}