Skip to contentSkip to conversation

ptp: Set lookup cookie when creating a PTP PPS source.

PATCH Applied Jonathan Lemon 4 participants 8 messages Jun 28, 2021 – Jul 7, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ptp: Set lookup cookie when creating a PTP PPS source.

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

---
 drivers/ptp/ptp_clock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ptp/ptp_clock.c +1 -0
index c176fa82df85..45429853d60f 100644
@@ -240,6 +240,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
 			pr_err("failed to create ptp aux_worker %d\n", err);
 			goto kworker_err;
 		}
+		ptp->pps_source->lookup_cookie = ptp;
 	}
 
 	err = ptp_populate_pin_groups(ptp);
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 5 lines · Jonathan Lemon

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

Setting lookup_cookie is harmless, AFAICT, but I wonder about the use case. The doc for pps_lookup_dev() says,

* This is a bit of a kludge that is currently used only by the PPS
* serial line discipline.

and indeed that is the case.

The PHC devices are never serial ports, so how does this help?

Thanks,
Richard

#2 lore raw
Quoted 10 lines · Richard Cochran
Quoted 5 lines · Jonathan Lemon

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

Setting lookup_cookie is harmless, AFAICT, but I wonder about the use case. The doc for pps_lookup_dev() says,

Quoted 6 lines

* This is a bit of a kludge that is currently used only by the PPS
* serial line discipline.

and indeed that is the case.

The PHC devices are never serial ports, so how does this help?

This is for the ptp_ocp driver, I have an update coming.

The systems I'm using have the OpenCompute time card and several nics, all of which publish PTP/PPS devices.

When there are several PPS devices, this patch allows selecting the correct one.

Signature · 1 line
Joanthan
#3 lore raw
In reply to Richard Cochran
Quoted 9 lines · Richard Cochran
Quoted 5 lines · Jonathan Lemon

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

Setting lookup_cookie is harmless, AFAICT, but I wonder about the use case. The doc for pps_lookup_dev() says,

Harmless you say?

Let's look at the code in a larger context:

struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
struct device *parent)
{
struct ptp_clock *ptp;

...
ptp = kzalloc(...);
...
ptp->info = info;
...

if (ptp->info->do_aux_work) {
...
+ ptp->pps_source->lookup_cookie = ptp;
}

/* Register a new PPS source. */
if (info->pps) {
struct pps_source_info pps;
...
ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
...
}

Notice anything out of the ordinary?
Like perhaps the fact that ptp->pps_source is an arbitrary NULL pointer at the time the assignment to ->lookup_cookie is being made, because it is being created later?

How on earth is this patch supposed to work?

maintainer
#4 lore raw
Quoted 3 lines · Vladimir Oltean

Like perhaps the fact that ptp->pps_source is an arbitrary NULL pointer at the time the assignment to ->lookup_cookie is being made, because it is being created later?

Oops. @Jonathan please submit a fix as soon as you can. This patch is already in net-next.

Thanks,
Richard

#5 lore raw
In reply to Vladimir Oltean
Quoted 39 lines · Vladimir Oltean
Quoted 9 lines · Richard Cochran
Quoted 5 lines · Jonathan Lemon

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

Setting lookup_cookie is harmless, AFAICT, but I wonder about the use case. The doc for pps_lookup_dev() says,

Harmless you say?

Let's look at the code in a larger context:

struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,

(quoted diff) +1 -0
 				     struct device *parent)
 {
 	struct ptp_clock *ptp;
 
...
 	ptp = kzalloc(...);
...
 	ptp->info = info;
...
 
 	if (ptp->info->do_aux_work) {
...
+		ptp->pps_source->lookup_cookie = ptp;
 	}
 
 	/* Register a new PPS source. */
 	if (info->pps) {
 		struct pps_source_info pps;
...
 		ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
...
 	}
Quoted 6 lines

Notice anything out of the ordinary?
Like perhaps the fact that ptp->pps_source is an arbitrary NULL pointer at the time the assignment to ->lookup_cookie is being made, because it is being created later?

How on earth is this patch supposed to work?

It was added to the wrong code block. Checking my tree, I seem to have it located twice - probably a bad patch that I didn't notice, and since I don't have an do_aux_work, the first one didn't trigger.

Correction follows.

Signature · 1 line
Jonathan
#6 lore raw
In reply to Jonathan Lemon
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 9 lines · On Mon, 28 Jun 2021 11:25:33 -0700 you wrote:

When creating a PTP device, the configuration block allows creation of an associated PPS device. However, there isn't any way to associate the two devices after creation.

Set the PPS cookie, so pps_lookup_dev(ptp) performs correctly.

[...]

Here is the summary with links:
- ptp: Set lookup cookie when creating a PTP PPS source.

    https://git.kernel.org/netdev/net-next/c/8602e40fc813

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

maintainer
#7 lore raw
Quoted 3 lines · On Tue, Jun 29, 2021 at 06:40:04PM +0000, [email protected]…

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Why is this bot applying patches to net-next with issues that are under review?

Thanks,
Richard