-
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 <dave.stevenson@raspberrypi.com>
3b8126e
to
8b8afcd
Compare
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Applies and updates the patch from
https://github.com/zlab-pub/wifi-ptp/blob/main/ath9k.diff