#
331722 |
|
29-Mar-2018 |
eadler |
Revert r330897:
This was intended to be a non-functional change. It wasn't. The commit message was thus wrong. In addition it broke arm, and merged crypto related code.
Revert with prejudice.
This revert skips files touched in r316370 since that commit was since MFCed. This revert also skips files that require $FreeBSD$ property changes.
Thank you to those who helped me get out of this mess including but not limited to gonzo, kevans, rgrimes.
Requested by: gjb (re)
|
#
331503 |
|
24-Mar-2018 |
ian |
MFC r325233, r328956, r329170, r329172-r329173, r329224, r330403-r330407, r330411-r330412, r330416, r330430-r330431, r330433, r330528-r330529, r330767
r325233: [i2c/clock] add support for EPSON RTC-8583
RTC-8583 is time-of-day clock used in some SOHO routers. This clock has only 2 bits for year values, but thanks to user SRAM it's possible to save year value and keep it up to date via driver code.
Tested on Planex_MZK-W300NAG (SoC is RT2880)
Submitted by: Hiroki Mori <yamori83@yahoo.co.jp> Differential Revision: https://reviews.freebsd.org/D12833
r328956: Use const pointers for input data not modified by clock utility functions.
r329170: Replace the existing print_ct() private debugging function with a set of three public functions to format and print the three major data structures used by realtime clock drivers (clocktime, bcd_clocktime, and timespec).
r329172: Add a set of convenience routines for RTC drivers to use for debug output, and a debug.clock_show_io sysctl to control debugging output.
r329173: Add a new sysctl, debug.clock_do_io, to allow manully triggering a one-shot read or write of all registered realtime clocks. In the read case, the values read are simply discarded. For writes, there's no alternative but to actually write the current system time to the device.
r329224: Fix bad indentation. Whitespace only, no functional changes.
Reported by: bde@
r330403: Add calls to the new clock_dbgprint_xxx() functions.
r330404: Add calls to the new clock_dbgprint_xxx() functions.
r330405: Oops, fix a paste-o.
r330406: Add calls to the new clock_dbgprint_xxx() functions.
r330407: Add calls to the new clock_dbgprint_xxx() functions. Also, stop applying a local .5 second adjustment to the time, since that is now done by the code in subr_rtc.c.
r330411: Convert to the new(ish) bcd_clocktime conversion functions, add calls to the new debug output functions, and when setting the clock, propagate the timespec nsecs to the 1/100ths register.
r330412: Build iicbus/rtc8583 as a module.
r330416: The year is stored in a single byte in sram, in binary format, as a count of years since the century, so strip the century out when converting to or from bcd_clocktime format (the conversion routines will infer century by pivoting on 70).
r330430: Switch to the new bcd_clocktime conversion routines, and add calls to the new clock_dbgprint_xxx() functions.
r330431: Switch to the new bcd_clocktime conversion routines, and add calls to the new clock_dbgprint_xxx() functions.
r330433: Switch to the new bcd_clocktime conversion routines, and add calls to the new clock_dbgprint_xxx() functions.
r330528: Fix a paste-o that broke the build. There is no softc pointer here, just use the dev arg.
Reported by: Jonathan Looney <jonlooney@gmail.com> Pointy hat: ian@
r330529: Build the ds1672 driver as a module. Add a detach() to unregister the rtc.
r330767: Convert atrtc the new style rtc debugging output. Remove the db show command handler which provided much the same information. Removing the possibility of accessing the hardware regs from the debugger context paves the way for simplifying the locking code in the driver.
|
#
331496 |
|
24-Mar-2018 |
ian |
MFC r306288, r314936, r325527, r327971, r328005, r328039, r328068-r328069, r328301-r328303
r306288: Fix ds1307 probing
'compat' can never be NULL, because the compatible check loop ends when compat->ocd_str is NULL. This causes ds1307 to attach to any unclaimed i2c device.
r314936: Validate values read from the RTC before trying BCD decoding
Submitted by: cem Reported by: Michael Gmelin <freebsd@grem.de> Tested by: Oleksandr Tymoshenko <gonzo@bluezbox.com> Sponsored by: Dell EMC
r325527: DS1307: Add the mcp7941x enable bit
Summary: Existing code recognizes the mcp7941x RTC, but this RTC has an enable bit at the same location as the "Clock Halt" bit on the ds1307, with an opposite assertion (set == on, whereas CH set == clock stopped). Thus the current code halts the clock, with no way to enable it.
Reviewed By: ian Differential Revision: https://reviews.freebsd.org/D12961
r327971: Add RTC clock conversions for BCD values, with non-panic validation.
RTC clock hardware frequently uses BCD numbers. Currently the low-level bcd2bin() and bin2bcd() functions will KASSERT if given out-of-range BCD values. Every RTC driver must implement its own code for validating the unreliable data coming from the hardware to avoid a potential kernel panic.
This change introduces two new functions, clock_bcd_to_ts() and clock_ts_to_bcd(). The former validates its inputs and returns EINVAL if any values are out of range. The latter guarantees the returned data will be valid BCD in a known format (4-digit years, etc).
A new bcd_clocktime structure is used with the new functions. It is similar to the original clocktime structure, but defines the fields holding BCD values as uint8_t (uint16_t for year), and adds a PM flag for handling hours using AM/PM mode.
PR: 224813 Differential Revision: https://reviews.freebsd.org/D13730 (no reviewers)
r328005: Convert the x86 RTC driver to use new validated BCD<->timespec conversions.
New common routines were added to kern/subr_clock.c for converting between calendrical time expressed in BCD and struct timespec. The new functions return EINVAL on error, as expected when the clock hardware does not provide valid time.
PR: 224813 Differential Revision: https://reviews.freebsd.org/D13731 (no reviewers)
r328039: Add static inline rtcin_locked() and rtcout_locked() functions for doing a related series of operations without doing a lock/unlock for each byte. Use them when reading and writing the entire set of time registers.
The original rtcin() and writertc() functions which do lock/unlock on each byte still exist, because they are public and called by outside code.
r328068: Move some code around and rename a couple variables; no functional changes.
The static atrtc_set() function was called only from clock_settime(), so just move its contents entirely into clock_settime() and delete atrtc_set().
Rename the struct bcd_clocktime variables from 'ct' to 'bct'. I had originally wanted to emphasize how identical the clocktime and bcd_clocktime structs were, but things evolved to the point where the structs are not at all identical anymore, so now emphasizing the difference seems better.
r328069: Remove redundant critical_enter/exit() calls. The block of code delimited by these calls is now protected by a spin mutex (obscured within the RTC_LOCK/RTC_UNLOCK macros).
Reported by: bde@
r328301: Switch to using the bcd_clocktime conversion functinos that validate the BCD data without panicking, and have common code for handling AM/PM mode.
r328302: Switch to using the bcd_clocktime conversion functions that validate the BCD data without panicking, and have common code for handling AM/PM mode.
r328303: Switch to using the bcd_clocktime conversion functions that validate the BCD data without panicking, and have common code for handling AM/PM mode.
|
#
330897 |
|
14-Mar-2018 |
eadler |
Partial merge of the SPDX changes
These changes are incomplete but are making it difficult to determine what other changes can/should be merged.
No objections from: pfg
|
#
323447 |
|
11-Sep-2017 |
ian |
MFC r320901-r320902, r320996-r320997, r321002, r321048, r321400, r321743, r321745
r320901: Protect access to the AT realtime clock with its own mutex.
The mutex protecting access to the registered realtime clock should not be overloaded to protect access to the atrtc hardware, which might not even be the registered rtc. More importantly, the resettodr mutex needs to be eliminated to remove locking/sleeping restrictions on clock drivers, and that can't happen if MD code for amd64 depends on it. This change moves the protection into what's really being protected: access to the atrtc date and time registers.
This change also adds protection when the clock is accessed from xentimer_settime(), which bypasses the resettodr locking.
Differential Revision: https://reviews.freebsd.org/D11483
r320902: Support multiple realtime clocks, and remove locking/sleeping restrictions on clock drivers.
This tracks multiple concurrent realtime clock drivers in a list sorted by clock resolution. When system time changes (and periodically) the clock_settime() methods of all registered clocks are invoked.
To initialize system time, each driver is tried in turn from best to worst resolution, until one succesfully returns a valid time.
The code no longer holds a mutex while calling the clock_settime() and clock_gettime() methods of the registered clocks. This allows clock drivers to do whatever kind of locking or sleeping is necessary (this is especially important for i2c clock chips since i2c drivers often need to sleep).
A new clock_register_flags() function allows the clock driver to pass flags. The flags currently defined help support drivers that use their own techniques to avoid roundoff errors (prevents the 4/5 rounding done by the subr_rtc code). A driver which may need to wait for resources (such as bus ownership) may pass a flag to indicate that it will obtain system time for itself after waiting for resources; this is merely an optimization to avoid the common code retrieving a timespec that will never get used.
Relnotes: yes Differential Revision: https://reviews.freebsd.org/D11484
r320996: Allow setting debug.clocktime as a tunable. Print 64-bit time_t correctly on 32-bit systems.
r320997: Minor optimization: instead of converting between days and years using loops that start in 1970, assume most conversions are going to be for recent dates and use a precomputed number of days through the end of 2016.
r321002: Revert r320997. There are reports of it getting the wrong results, so clearly my testing was insuffficent, and it's best to just revert it until I get it straightened out.
r321048: Minor optimization: instead of converting between days and years using loops that start in 1970, assume most conversions are going to be for recent dates and use a precomputed number of days through the end of 2016.
This is a do-over of r320997, hopefully this time with 100% more workiness.
The first attempt had an off-by-one error, but instead of just adding another mysterious +1 adjustment, this rearranges the relationship between recent_base_year and recent_base_days so that the latter is the number of days that occurred before the start of the associated year (instead of the count thru the end of that year). This makes the recent_base stuff work more like the original loop logic that didn't need any +1 adjustments.
r321400: Add common code to support realtime clocks that store year without century.
Most realtime clocks store the year as 2 BCD digits. Some add a century bit to extend the range another hundred years. Every clock driver has its own code to determine the century and pass a full year value to clock_ct_to_ts(). Now clock drivers can just convert BCD to bin and store the result in the clocktime struct and let the common code figure out the century. Clocks with a century bit can just add 100 to year if the century bit is on.
r321743: Add taskqueue_enqueue_timeout_sbt(), because sometimes you want more control over the scheduling precision than 'ticks' can offer, and because sometimes you're already working with sbintime_t units and it's dumb to convert them to ticks just so they can get converted back to sbintime_t under the hood.
r321745: Add clock_schedule(), a feature that allows realtime clock drivers to request that their clock_settime() methods be called at a given offset from top-of-second. This adds a timeout_task to the rtc_instance so that each clock can be separately added to taskqueue_thread with the scheduling it prefers, instead of looping through all the clocks at once with a single task on taskqueue_thread. If a driver doesn't call clock_schedule() the default is the old behavior: clock_settime() is queued immediately.
|
#
302408 |
|
07-Jul-2016 |
gjb |
Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle. Prune svn:mergeinfo from the new branch, as nothing has been merged here.
Additional commits post-branch will follow.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation |
#
302251 |
|
28-Jun-2016 |
kib |
Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use private mtx in resettodr(), no implementation of CLOCK_SETTIME() is allowed to sleep.
Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) X-Differential revision: https://reviews.freebsd.org/D6825
|
#
275727 |
|
12-Dec-2014 |
kib |
For architectures where time_t is wide enough, in particular, 64bit platforms, avoid overflow after year 2038 in clock_ct_to_ts().
PR: 195868 Reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
265201 |
|
01-May-2014 |
brooks |
Fix a 2038 bug.
If time_t is 64-bit (i.e. isn't 32-bit) allow any value of year, not just years less than 2038.
Don't bother fixing the underflow in the case of years before 1903.
MFC after: 1 week Sponsored by: DARPA, AFRL
|
#
217195 |
|
09-Jan-2011 |
bz |
Improve style and wording of comments and sysctl descriptions [1].
Move machdep.ct_debug to debug.clocktime as there was no reason to actually put it under machdep in r216340.
Submitted by: bde [1] MFC after: 3 days
|
#
216340 |
|
09-Dec-2010 |
bz |
Don't tie ct_debug to bootverbose. Provide a sysctl to turn it on or off. Switch the default to always off.
Reviewed by: kib
|
#
215304 |
|
14-Nov-2010 |
brucec |
Fix some more style(9) issues.
|
#
215283 |
|
14-Nov-2010 |
brucec |
Fix style(9) issues from r215281 and r215282.
MFC after: 1 week
|
#
215281 |
|
14-Nov-2010 |
brucec |
Add some descriptions to sys/kern sysctls.
PR: kern/148710 Tested by: Chip Camden <sterling at camdensoftware.com> MFC after: 1 week
|
#
213986 |
|
17-Oct-2010 |
nwhitehorn |
Fix an XXX comment by answering 'no'. OS X does not set the day-of-week counter on SMU-based systems, which causes FreeBSD to reject the RTC time when used in a dual-boot environment. Since we don't use the day-of-week counter anyway, solve this by just not checking that it matches.
MFC after: 3 weeks
|
#
178429 |
|
22-Apr-2008 |
phk |
Now that all platforms use genclock, shuffle things around slightly for better structure.
Much of this is related to <sys/clock.h>, which should really have been called <sys/calendar.h>, but unless and until we need the name, the repocopy can wait.
In general the kernel does not know about minutes, hours, days, timezones, daylight savings time, leap-years and such. All that is theoretically a matter for userland only.
Parts of kernel code does however care: badly designed filesystems store timestamps in local time and RTC chips almost universally track time in a YY-MM-DD HH:MM:SS format, and sometimes in local timezone instead of UTC. For this we have <sys/clock.h>
<sys/time.h> on the other hand, deals with time_t, timeval, timespec and so on. These know only seconds and fractions thereof.
Move inittodr() and resettodr() prototypes to <sys/time.h>. Retain the names as it is one of the few surviving PDP/VAX references.
Move startrtclock() to <machine/clock.h> on relevant platforms, it is a MD call between machdep.c/clock.c. Remove references to it elsewhere.
Remove a lot of unnecessary <sys/clock.h> includes.
Move the machdep.disable_rtc_set sysctl to subr_rtc.c where it belongs. XXX: should be kern.disable_rtc_set really, it's not MD.
|
#
178164 |
|
12-Apr-2008 |
phk |
fix printf type confusion on amd64
|
#
178162 |
|
12-Apr-2008 |
phk |
Emit summaries of struct c(alender)t(ime) <-> struct timespec conversions under bootverbose.
Struct ct is used for setting/reading real time clocks and I'm about to Do Things to some of those, so a bit of preemptive debugging is in order.
Remove a pointless __inline.
|
#
171553 |
|
23-Jul-2007 |
dwmalone |
If clock_ct_to_ts fails to convert time time from the real time clock, print a one line error message. Add some comments on not being able to trust the day of week field (I'll act on these comments in a follow up commit).
Approved by: re MFC after: 3 weeks
|
#
162970 |
|
02-Oct-2006 |
phk |
Use utc_offset() where applicable, and hide the internals of it as static variables.
|
#
162962 |
|
02-Oct-2006 |
phk |
Introduce utc_offset() to capture a calculation currently done all over the place.
|
#
162960 |
|
02-Oct-2006 |
phk |
Move tz_minuteswest and tz_dsttime to subr_clock.c
|
#
162958 |
|
02-Oct-2006 |
phk |
Second part of a little cleanup in the calendar/timezone/RTC handling.
Split subr_clock.c in two parts (by repo-copy): subr_clock.c contains generic RTC and calendaric stuff. etc. subr_rtc.c contains the newbus'ified RTC interface.
Centralize the machdep.{adjkerntz,disable_rtc_set,wall_cmos_clock} sysctls and associated variables into subr_clock.c. They are not machine dependent and we have generic code that relies on being present so they are not even optional.
|
#
158450 |
|
11-May-2006 |
phk |
Remove more straggling CPU_ macro references
|
#
139804 |
|
06-Jan-2005 |
imp |
/* -> /*- for copyright notices, minor format tweaks as necessary
|
#
127911 |
|
05-Apr-2004 |
imp |
Remove advertising clause from University of California Regent's license, per letter dated July 22, 1999.
Approved by: core
|
#
116182 |
|
10-Jun-2003 |
obrien |
Use __FBSDID().
|
#
110299 |
|
03-Feb-2003 |
phk |
Split the global timezone structure into two integer fields to prevent the compiler from optimizing assignments into byte-copy operations which might make access to the individual fields non-atomic.
Use the individual fields throughout, and don't bother locking them with Giant: it is no longer needed.
Inspired by: tjr
|
#
101484 |
|
07-Aug-2002 |
tmm |
Use the CPU_* OID constants instead of OID_AUTO for the clock-related sysctls for compatability with old applications.
|
#
93835 |
|
04-Apr-2002 |
tmm |
Add a generic implementation of inittodr() and resettodr(), as well as a set of helper routines to deal with real-time clocks. The generic functions access the clock diver using a kobj interface. This is intended to reduce code reduplication and make it easy to support more than one clock model on a single architecture.
This code is currently only used on sparc64, but it is planned to convert the code of the other architectures to it later.
|