-
Notifications
You must be signed in to change notification settings - Fork 5.2k
wifi: ath9k: Add PTP patch from wifi-ptp project #6882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rpi-6.12.y
Are you sure you want to change the base?
Conversation
I am NOT proposing that this gets merged here, but created it for #4358 |
a81b104
to
021bac0
Compare
021bac0
to
3b8126e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I think you want to implement, assuming sc->cc_mult is the base multiplier. I also suggested converting the ath_warn to ath_dbg so that its not spammy unless enabled as frequency can be adjusted multiple times per second depending on the synchronization rate. Hope this helps!
drivers/net/wireless/ath/ath9k/ptp.c
Outdated
mult = sc->cc_mult; | ||
adj = mult; | ||
adj *= scaled_ppm; | ||
diff = div_u64(adj, 1000000000ULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mistake here is still using 1,000,000,000 (1 billion). You need to use 1million * 2^16, but you can actually just replace this all with adjust_by_scaled_ppm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
drivers/net/wireless/ath/ath9k/ptp.c
Outdated
#if 0 | ||
struct ath_softc *sc = container_of(ptp, struct ath_softc, ptp_clock_info); | ||
unsigned long flags; | ||
int neg_adj = 0; | ||
u32 mult, diff; | ||
u64 adj; | ||
|
||
if (scaled_ppm < 0) { | ||
neg_adj = -1; | ||
scaled_ppm = -scaled_ppm; | ||
} | ||
mult = sc->cc_mult; | ||
adj = mult; | ||
adj *= scaled_ppm; | ||
diff = div_u64(adj, 1000000000ULL); | ||
|
||
spin_lock_irqsave(&sc->systim_lock, flags); | ||
timecounter_read(&sc->tc); | ||
sc->cc.mult = neg_adj ? mult - diff : mult + diff; | ||
spin_unlock_irqrestore(&sc->systim_lock, flags); | ||
|
||
ath_warn(ath9k_hw_common(sc->sc_ah), "phc adjust adj=%llu freq=%u\n", adj, diff); | ||
#endif | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if 0 | |
struct ath_softc *sc = container_of(ptp, struct ath_softc, ptp_clock_info); | |
unsigned long flags; | |
int neg_adj = 0; | |
u32 mult, diff; | |
u64 adj; | |
if (scaled_ppm < 0) { | |
neg_adj = -1; | |
scaled_ppm = -scaled_ppm; | |
} | |
mult = sc->cc_mult; | |
adj = mult; | |
adj *= scaled_ppm; | |
diff = div_u64(adj, 1000000000ULL); | |
spin_lock_irqsave(&sc->systim_lock, flags); | |
timecounter_read(&sc->tc); | |
sc->cc.mult = neg_adj ? mult - diff : mult + diff; | |
spin_unlock_irqrestore(&sc->systim_lock, flags); | |
ath_warn(ath9k_hw_common(sc->sc_ah), "phc adjust adj=%llu freq=%u\n", adj, diff); | |
#endif | |
return 0; | |
struct ath_softc *sc = container_of(ptp, struct ath_softc, ptp_clock_info); | |
unsigned long flags; | |
spin_lock_irqsave(&sc->systim_lock, flags); | |
timecounter_read(&sc->tc); | |
sc->cc.mult = adjust_by_scaled_ppm(sc->cc_mult, scaled_ppm); | |
spin_unlock_irqrestore(&sc->systim_lock, flags); | |
ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG, "phc adjust adj=%llu freq=%u\n", adj, diff); | |
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whitespace is probably not correct here for kernel style, but you should get the idea. You could also pull adjust_by_scaled_ppm to outside the lock, but I don't think its necessary, since its really just a few multiplications and division.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace and coding style are a bit of a mess generally with these changes, but that can be a task for others to fix up if they were ever to think of upstreaming them (I have no idea if it would even be considered upstream).
I did try a checkpatch --fix-inplace
, but it only addressed a small fraction of the issues.
Applies and updates the patch from https://github.com/zlab-pub/wifi-ptp/blob/main/ath9k.diff
Signed-off-by: Dave Stevenson <[email protected]>
3b8126e
to
8b8afcd
Compare
Signed-off-by: Dave Stevenson <[email protected]>
@jacob-keller @6by9 @CALMorACT When I ran [ 4.181657] ath9k 0000:01:00.0: enabling device (0000 -> 0002) It looks like the device (PCI 0000:01:00.0) tried to load with ath9k but failed. I am wondering if I could have assistance troubleshooting this. Thank you! |
Error 12 is ENOMEM, a pretty fundamental failure while probing. I don't believe it's actually run out of memory, but perhaps it's because of the PCIe space exposed by the card. What does |
Ya. That looks like a pretty fundamental issue with loading the wireless driver. |
|
so isn't this a problem with how the ath9k driver was forward ported? |
@6by9 @pelwell @jacob-keller @CALMorACT If anyone has any advice, I believe something is wrong with the kernel and I am uncertain how to move forward |
Unfortunately I don't have much experience with wireless drivers :( |
I ended up adding |
Try increasing the tx_timestamp_timeout config value for ptp4l. The timestamps may not be returned within the default time, depending on driver/hardware implementation. If a value of 100 or 200 milliseconds still fails then it's likely a bug with the driver never reporting a timestamp for one of the packets. |
100 and 200 result in the same error. I am wondering... when I run it points to:
but then when I run lrwxrwxrwx 1 root root 0 Jul 14 10:39 /sys/class/net/eth0/device -> ../../../fd580000.ethernet lrwxrwxrwx 1 root root 0 Jul 14 10:39 /sys/class/net/wlan0/device -> ../../../0000:01:00.0 lrwxrwxrwx 1 root root 0 Jul 14 10:39 /sys/class/net/wlan1/device -> ../../../mmc1:0001:1 It shows that the ptp0 devices is the onboard ethernet MDIO interface. IF the ath9k driver patch was applied correctly, shouldn't there be a I am looking at this issue: zlab-pub/wifi-ptp#8 "Please ensure the "ls /sys/class/net/${WLAN_DEV}/device/ptp" has the right output, it means there is a available PHC/PTP clock for you and the driver patch successfully. You can read the 'dmesg' output for more info if this step is error for you" I currently do not have a device under wlan0 that is a ptp device. I am thinking that this might indicate a problem with the way the driver patch was applied to this kernel. |
Does your ptp4l command hardcode the ptp device? If so, you should stop doing that and rely on the ethtool -T autodetection. What does ethtool -T show for the wlan0 device? |
If you use the wrong ptp device for a given network interface things will not work. Maybe the ath9k driver didn't implement the get_ts_info appropriately? |
Yes, I don't believe it is implementing as it should. There is no phc_device associated with wlan0. This is what it shows for the
|
You need to make sure the .get_ts_info callback for ethtool is implemented
and reports the clock number. When i am back at a real PC I will take a
look and see if I can propose something
…On Wed, Jul 16, 2025, 11:07 AM OJD ***@***.***> wrote:
*wirelessOJ* left a comment (raspberrypi/linux#6882)
<#6882 (comment)>
This is what it shows for the wlan0 interface
ethtool -T wlan0
Time stamping parameters for wlan0:
Capabilities:
software-receive
software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
—
Reply to this email directly, view it on GitHub
<#6882 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGVRX5BO4NXNLJ2BHLOHOL3I2IHNAVCNFSM6AAAAAB6THDSISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANZZG4YTONBWG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Applies and updates the patch from
https://github.com/zlab-pub/wifi-ptp/blob/main/ath9k.diff