lists.linaro.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
List overview
Download
Y2038
April 2015
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
y2038@lists.linaro.org
11 participants
38 discussions
Start a n
N
ew thread
Re: [Y2038] [PATCH v4 06/10] cec: add HDMI CEC framework: y2038 question
by Hans Verkuil
Added the y2038 mailinglist since I would like to get their input for this API. Y2038 experts, can you take a look at my comments in the code below? Thanks! On 04/23/2015 03:03 PM, Kamil Debski wrote: > From: Hans Verkuil <hansverk(a)cisco.com> > > The added HDMI CEC framework provides a generic kernel interface for > HDMI CEC devices. > > Signed-off-by: Hans Verkuil <hansverk(a)cisco.com> > [k.debski(a)samsung.com: Merged CEC Updates commit by Hans Verkuil] > [k.debski(a)samsung.com: Merged Update author commit by Hans Verkuil] > [k.debski(a)samsung.com: change kthread handling when setting logical > address] > [k.debski(a)samsung.com: code cleanup and fixes] > [k.debski(a)samsung.com: add missing CEC commands to match spec] > [k.debski(a)samsung.com: add RC framework support] > [k.debski(a)samsung.com: move and edit documentation] > [k.debski(a)samsung.com: add vendor id reporting] > [k.debski(a)samsung.com: add possibility to clear assigned logical > addresses] > [k.debski(a)samsung.com: documentation fixes, clenaup and expansion] > [k.debski(a)samsung.com: reorder of API structs and add reserved fields] > [k.debski(a)samsung.com: fix handling of events and fix 32/64bit timespec > problem] > [k.debski(a)samsung.com: add cec.h to include/uapi/linux/Kbuild] > Signed-off-by: Kamil Debski <k.debski(a)samsung.com> > --- > Documentation/cec.txt | 396 ++++++++++++++++ > drivers/media/Kconfig | 6 + > drivers/media/Makefile | 2 + > drivers/media/cec.c | 1161 +++++++++++++++++++++++++++++++++++++++++++++ > include/media/cec.h | 140 ++++++ > include/uapi/linux/Kbuild | 1 + > include/uapi/linux/cec.h | 303 ++++++++++++ > 7 files changed, 2009 insertions(+) > create mode 100644 Documentation/cec.txt > create mode 100644 drivers/media/cec.c > create mode 100644 include/media/cec.h > create mode 100644 include/uapi/linux/cec.h > <snip> > diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild > index 4842a98..5854cfd 100644 > --- a/include/uapi/linux/Kbuild > +++ b/include/uapi/linux/Kbuild > @@ -81,6 +81,7 @@ header-y += capi.h > header-y += cciss_defs.h > header-y += cciss_ioctl.h > header-y += cdrom.h > +header-y += cec.h > header-y += cgroupstats.h > header-y += chio.h > header-y += cm4000_cs.h > diff --git a/include/uapi/linux/cec.h b/include/uapi/linux/cec.h > new file mode 100644 > index 0000000..bb6d66c > --- /dev/null > +++ b/include/uapi/linux/cec.h > @@ -0,0 +1,303 @@ > +#ifndef _CEC_H > +#define _CEC_H > + > +#include <linux/types.h> > + > +struct cec_time { > + __u64 sec; > + __u64 nsec; > +}; I don't like having to introduce a new struct for time here. Basically we are only doing this because there is still no public struct timespec64. When will that struct become available for use in a public API? If it is 4.2, then we can start using it. If it will take longer, then what alternative can we use to prevent having to change the API later? One alternative might be to drop it for now and just reserve space in the structs to add it later. Input from the y2038 experts will be welcome! Regards, Hans > + > +struct cec_msg { > + struct cec_time ts; > + __u32 len; > + __u32 status; > + __u32 timeout; > + /* timeout (in ms) is used to timeout CEC_RECEIVE. > + Set to 0 if you want to wait forever. */ > + __u8 msg[16]; > + __u8 reply; > + /* If non-zero, then wait for a reply with this opcode. > + If there was an error when sending the msg or FeatureAbort > + was returned, then reply is set to 0. > + If reply is non-zero upon return, then len/msg are set to > + the received message. > + If reply is zero upon return and status has the > + CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to the > + received feature abort message. > + If reply is zero upon return and status has the > + CEC_TX_STATUS_REPLY_TIMEOUT > + bit set, then no reply was seen at all. > + This field is ignored with CEC_RECEIVE. > + If reply is non-zero for CEC_TRANSMIT and the message is a broadcast, > + then -EINVAL is returned. > + if reply is non-zero, then timeout is set to 1000 (the required > + maximum response time). > + */ > + __u8 reserved[31]; > +}; > + > +static inline __u8 cec_msg_initiator(const struct cec_msg *msg) > +{ > + return msg->msg[0] >> 4; > +} > + > +static inline __u8 cec_msg_destination(const struct cec_msg *msg) > +{ > + return msg->msg[0] & 0xf; > +} > + > +static inline bool cec_msg_is_broadcast(const struct cec_msg *msg) > +{ > + return (msg->msg[0] & 0xf) == 0xf; > +} > + > +/* cec status field */ > +#define CEC_TX_STATUS_OK (0) > +#define CEC_TX_STATUS_ARB_LOST (1 << 0) > +#define CEC_TX_STATUS_RETRY_TIMEOUT (1 << 1) > +#define CEC_TX_STATUS_FEATURE_ABORT (1 << 2) > +#define CEC_TX_STATUS_REPLY_TIMEOUT (1 << 3) > +#define CEC_RX_STATUS_READY (0) > + > +#define CEC_LOG_ADDR_INVALID 0xff > + > +/* The maximum number of logical addresses one device can be assigned to. > + * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The > + * Analog Devices CEC hardware supports 3. So let's go wild and go for 4. */ > +#define CEC_MAX_LOG_ADDRS 4 > + > +/* The "Primary Device Type" */ > +#define CEC_PRIM_DEVTYPE_TV 0 > +#define CEC_PRIM_DEVTYPE_RECORD 1 > +#define CEC_PRIM_DEVTYPE_TUNER 3 > +#define CEC_PRIM_DEVTYPE_PLAYBACK 4 > +#define CEC_PRIM_DEVTYPE_AUDIOSYSTEM 5 > +#define CEC_PRIM_DEVTYPE_SWITCH 6 > +#define CEC_PRIM_DEVTYPE_VIDEOPROC 7 > + > +/* The "All Device Types" flags (CEC 2.0) */ > +#define CEC_FL_ALL_DEVTYPE_TV (1 << 7) > +#define CEC_FL_ALL_DEVTYPE_RECORD (1 << 6) > +#define CEC_FL_ALL_DEVTYPE_TUNER (1 << 5) > +#define CEC_FL_ALL_DEVTYPE_PLAYBACK (1 << 4) > +#define CEC_FL_ALL_DEVTYPE_AUDIOSYSTEM (1 << 3) > +#define CEC_FL_ALL_DEVTYPE_SWITCH (1 << 2) > +/* And if you wondering what happened to VIDEOPROC devices: those should > + * be mapped to a SWITCH. */ > + > +/* The logical address types that the CEC device wants to claim */ > +#define CEC_LOG_ADDR_TYPE_TV 0 > +#define CEC_LOG_ADDR_TYPE_RECORD 1 > +#define CEC_LOG_ADDR_TYPE_TUNER 2 > +#define CEC_LOG_ADDR_TYPE_PLAYBACK 3 > +#define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM 4 > +#define CEC_LOG_ADDR_TYPE_SPECIFIC 5 > +#define CEC_LOG_ADDR_TYPE_UNREGISTERED 6 > +/* Switches should use UNREGISTERED. > + * Video processors should use SPECIFIC. */ > + > +/* The CEC version */ > +#define CEC_VERSION_1_4B 5 > +#define CEC_VERSION_2_0 6 > + > +struct cec_event { > + struct cec_time ts; > + __u32 event; > + __u8 reserved[4]; > +}; > + > +/* The CEC state */ > +#define CEC_STATE_DISABLED 0 > +#define CEC_STATE_ENABLED 1 > + > +/* Userspace has to configure the adapter state (enable/disable) */ > +#define CEC_CAP_STATE (1 << 0) > +/* Userspace has to configure the physical address */ > +#define CEC_CAP_PHYS_ADDR (1 << 1) > +/* Userspace has to configure the logical addresses */ > +#define CEC_CAP_LOG_ADDRS (1 << 2) > +/* Userspace can transmit messages */ > +#define CEC_CAP_TRANSMIT (1 << 3) > +/* Userspace can receive messages */ > +#define CEC_CAP_RECEIVE (1 << 4) > +/* Userspace has to configure the vendor id */ > +#define CEC_CAP_VENDOR_ID (1 << 5) > +/* The hardware has the possibility to work in the promiscuous mode */ > +#define CEC_CAP_PROMISCUOUS (1 << 6) > + > +struct cec_caps { > + __u32 available_log_addrs; > + __u32 capabilities; > + __u32 vendor_id; > + __u8 version; > + __u8 reserved[11]; > +}; > + > +struct cec_log_addrs { > + __u8 cec_version; > + __u8 num_log_addrs; > + __u8 primary_device_type[CEC_MAX_LOG_ADDRS]; > + __u8 log_addr_type[CEC_MAX_LOG_ADDRS]; > + __u8 log_addr[CEC_MAX_LOG_ADDRS]; > + > + /* CEC 2.0 */ > + __u8 all_device_types; > + __u8 features[CEC_MAX_LOG_ADDRS][12]; > + > + __u8 reserved[9]; > +}; > + > +/* Commands */ > + > +/* One Touch Play Feature */ > +#define CEC_OP_ACTIVE_SOURCE 0x82 > +#define CEC_OP_IMAGE_VIEW_ON 0x04 > +#define CEC_OP_TEXT_VIEW_ON 0x0d > + > +/* Routing Control Feature */ > +#define CEC_OP_ACTIVE_SOURCE 0x82 > +#define CEC_OP_INACTIVE_SOURCE 0x9d > +#define CEC_OP_REQUEST_ACTIVE_SOURCE 0x85 > +#define CEC_OP_ROUTING_CHANGE 0x80 > +#define CEC_OP_ROUTING_INFORMATION 0x81 > +#define CEC_OP_SET_STREAM_PATH 0x86 > + > +/* Standby Feature */ > +#define CEC_OP_STANDBY 0x36 > + > +/* One Touch Record Feature */ > +#define CEC_OP_RECORD_OFF 0x0b > +#define CEC_OP_RECORD_ON 0x09 > +#define CEC_OP_RECORD_STATUS 0x0a > +#define CEC_OP_RECORD_TV_SCREEN 0x0f > + > +/* Timer Programming Feature */ > +#define CEC_OP_CLEAR_ANALOGUE_TIMER 0x33 > +#define CEC_OP_CLEAR_DIGITAL_TIMER 0x99 > +#define CEC_OP_CLEAR_EXT_TIMER 0xa1 > +#define CEC_OP_SET_ANALOGUE_TIMER 0x34 > +#define CEC_OP_SET_DIGITAL_TIMER 0x97 > +#define CEC_OP_SET_EXT_TIMER 0xa2 > +#define CEC_OP_SET_EXT_PROGRAM_TIMER 0x67 > +#define CEC_OP_TIMER_CLEARED_STATUS 0x43 > +#define CEC_OP_TIMER_STATUS 0x35 > + > +/* System Information Feature */ > +#define CEC_OP_CEC_VERSION 0x9e > +#define CEC_OP_GET_CEC_VERSION 0x9f > +#define CEC_OP_GIVE_PHYSICAL_ADDR 0x83 > +#define CEC_OP_GET_MENU_LANGUAGE 0x91 > +#define CEC_OP_REPORT_PHYSICAL_ADDR 0x84 > +#define CEC_OP_SET_MENU_LANGUAGE 0x32 > + > +/* Deck Control Feature */ > +#define CEC_OP_DECK_CONTROL 0x42 > +#define CEC_OP_DECK_STATUS 0x1b > +#define CEC_OP_GIVE_DECK_STATUS 0x1a > +#define CEC_OP_PLAY 0x41 > + > +/* Tuner Control Feature */ > +#define CEC_OP_GIVE_TUNER_DEVICE_STATUS 0x08 > +#define CEC_OP_SELECT_ANALOGUE_SERVICE 0x92 > +#define CEC_OP_SELECT_DIGITAL_SERVICE 0x93 > +#define CEC_OP_TUNER_DEVICE_STATUS 0x07 > +#define CEC_OP_TUNER_STEP_DECREMENT 0x06 > +#define CEC_OP_TUNER_STEP_INCREMENT 0x05 > + > +/* Vendor Specific Commands Feature */ > +#define CEC_OP_CEC_VERSION 0x9e > +#define CEC_OP_DEVICE_VENDOR_ID 0x87 > +#define CEC_OP_GET_CEC_VERSION 0x9f > +#define CEC_OP_GIVE_DEVICE_VENDOR_ID 0x8c > +#define CEC_OP_VENDOR_COMMAND 0x89 > +#define CEC_OP_VENDOR_COMMAND_WITH_ID 0xa0 > +#define CEC_OP_VENDOR_REMOTE_BUTTON_DOWN 0x8a > +#define CEC_OP_VENDOR_REMOTE_BUTTON_UP 0x8b > + > +/* OSD Display Feature */ > +#define CEC_OP_SET_OSD_STRING 0x64 > + > +/* Device OSD Transfer Feature */ > +#define CEC_OP_GIVE_OSD_NAME 0x46 > +#define CEC_OP_SET_OSD_NAME 0x47 > + > +/* Device Menu Control Feature */ > +#define CEC_OP_MENU_REQUEST 0x8d > +#define CEC_OP_MENU_STATUS 0x8e > +#define CEC_OP_USER_CONTROL_PRESSED 0x44 > +#define CEC_OP_USER_CONTROL_RELEASED 0x45 > + > +/* Power Status Feature */ > +#define CEC_OP_GIVE_DEVICE_POWER_STATUS 0x8f > +#define CEC_OP_REPORT_POWER_STATUS 0x90 > +#define CEC_OP_FEATURE_ABORT 0x00 > +#define CEC_OP_ABORT 0xff > + > +/* System Audio Control Feature */ > +#define CEC_OP_GIVE_AUDIO_STATUS 0x71 > +#define CEC_OP_GIVE_SYSTEM_AUDIO_MODE_STATUS 0x7d > +#define CEC_OP_REPORT_AUDIO_STATUS 0x7a > +#define CEC_OP_SET_SYSTEM_AUDIO_MODE 0x72 > +#define CEC_OP_SYSTEM_AUDIO_MODE_REQUEST 0x70 > +#define CEC_OP_SYSTEM_AUDIO_MODE_STATUS 0x7e > + > +/* Audio Rate Control Feature */ > +#define CEC_OP_SET_AUDIO_RATE 0x9a > + > +/* Events */ > +/* Event that occurs when a cable is connected */ > +#define CEC_EVENT_CONNECT 1 > +/* Event that occurs when all logical addresses were claimed */ > +#define CEC_EVENT_READY 2 > +/* Event that is sent when the cable is disconnected */ > +#define CEC_EVENT_DISCONNECT 3 > + > +/* ioctls */ > + > +/* issue a CEC command */ > +#define CEC_G_CAPS _IOWR('a', 0, struct cec_caps) > +#define CEC_TRANSMIT _IOWR('a', 1, struct cec_msg) > +#define CEC_RECEIVE _IOWR('a', 2, struct cec_msg) > + > +/* > + Configure the CEC adapter. It sets the device type and which > + logical types it will try to claim. It will return which > + logical addresses it could actually claim. > + An error is returned if the adapter is disabled or if there > + is no physical address assigned. > + */ > + > +#define CEC_G_ADAP_LOG_ADDRS _IOR('a', 3, struct cec_log_addrs) > +#define CEC_S_ADAP_LOG_ADDRS _IOWR('a', 4, struct cec_log_addrs) > + > +/* > + Enable/disable the adapter. The Set state ioctl may not > + be available if that is handled internally. > + */ > +#define CEC_G_ADAP_STATE _IOR('a', 5, __u32) > +#define CEC_S_ADAP_STATE _IOW('a', 6, __u32) > + > +/* > + phys_addr is either 0 (if this is the CEC root device) > + or a valid physical address obtained from the sink's EDID > + as read by this CEC device (if this is a source device) > + or a physical address obtained and modified from a sink > + EDID and used for a sink CEC device. > + If nothing is connected, then phys_addr is 0xffff. > + See HDMI 1.4b, section 8.7 (Physical Address). > + > + The Set ioctl may not be available if that is handled > + internally. > + */ > +#define CEC_G_ADAP_PHYS_ADDR _IOR('a', 7, __u16) > +#define CEC_S_ADAP_PHYS_ADDR _IOW('a', 8, __u16) > + > +#define CEC_G_EVENT _IOWR('a', 9, struct cec_event) > +/* > + Read and set the vendor ID of the CEC adapter. > + */ > +#define CEC_G_VENDOR_ID _IOR('a', 9, __u32) > +#define CEC_S_VENDOR_ID _IOW('a', 10, __u32) > + > +#endif >
9 years, 6 months
2
4
0
0
[PATCH v2 04/15] posix timers:Introduce the 64bit methods with timespec64 type for k_clock structure
by Baolin Wang
This patch introduces the new methods with timespec64/itimerspec64 type for k_clcok structure,converts the timepsec type to timespec64 type in k_clock structure and converts the itimerspec type to itimerspec64 type to ready for 2038 issue. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- include/linux/posix-timers.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 907f3fd..35786c5 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -98,9 +98,13 @@ struct k_itimer { struct k_clock { int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); + int (*clock_getres64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_set) (const clockid_t which_clock, const struct timespec *tp); + int (*clock_set64) (const clockid_t which_clock, + const struct timespec64 *tp); int (*clock_get) (const clockid_t which_clock, struct timespec * tp); + int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); int (*nsleep) (const clockid_t which_clock, int flags, @@ -109,10 +113,15 @@ struct k_clock { int (*timer_set) (struct k_itimer * timr, int flags, struct itimerspec * new_setting, struct itimerspec * old_setting); + int (*timer_set64) (struct k_itimer *timr, int flags, + struct itimerspec64 *new_setting, + struct itimerspec64 *old_setting); int (*timer_del) (struct k_itimer * timr); #define TIMER_RETRY 1 void (*timer_get) (struct k_itimer * timr, struct itimerspec * cur_setting); + void (*timer_get64) (struct k_itimer *timr, + struct itimerspec64 *cur_setting); }; extern struct k_clock clock_posix_cpu; -- 1.7.9.5
9 years, 6 months
2
4
0
0
[PATCH] Staging: rts5208: Replace timeval with timespec64
by Ksenija Stanojevic
struct timeval tv is used to get current time. 32-bit systems using 'struct timeval' will break in the year 2038, so we have to replace that code with more appropriate types. Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic(a)gmail.com> Reviewed-by: Arnd Bergmann <arnd(a)arndb.de> --- drivers/staging/rts5208/rtsx.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index 9e6ecb7..f768fc0 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -37,7 +37,7 @@ #include <linux/cdrom.h> #include <linux/workqueue.h> #include <linux/timer.h> -#include <linux/time.h> +#include <linux/time64.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -151,21 +151,24 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host) static inline void get_current_time(u8 *timeval_buf, int buf_len) { - struct timeval tv; + struct timespec64 ts64; + u32 tv_usec; if (!timeval_buf || (buf_len < 8)) return; - do_gettimeofday(&tv); + getnstimeofday64(&ts64); - timeval_buf[0] = (u8)(tv.tv_sec >> 24); - timeval_buf[1] = (u8)(tv.tv_sec >> 16); - timeval_buf[2] = (u8)(tv.tv_sec >> 8); - timeval_buf[3] = (u8)(tv.tv_sec); - timeval_buf[4] = (u8)(tv.tv_usec >> 24); - timeval_buf[5] = (u8)(tv.tv_usec >> 16); - timeval_buf[6] = (u8)(tv.tv_usec >> 8); - timeval_buf[7] = (u8)(tv.tv_usec); + tv_usec = ts64.tv_nsec/NSEC_PER_USEC; + + timeval_buf[0] = (u8)(ts64.tv_sec >> 24); + timeval_buf[1] = (u8)(ts64.tv_sec >> 16); + timeval_buf[2] = (u8)(ts64.tv_sec >> 8); + timeval_buf[3] = (u8)(ts64.tv_sec); + timeval_buf[4] = (u8)(tv_usec >> 24); + timeval_buf[5] = (u8)(tv_usec >> 16); + timeval_buf[6] = (u8)(tv_usec >> 8); + timeval_buf[7] = (u8)(tv_usec); } /* The scsi_lock() and scsi_unlock() macros protect the sm_state and the -- 1.9.1
9 years, 7 months
1
0
0
0
[PATCH v2 15/15] k_clock:Remove the 32bit methods with timespec/itimerspec type
by Baolin Wang
All of the k_clock users have been converted to the new methods. This patch removes the older methods with timepsec/itimerspec type. As a result, the k_clock structure is ready for the year 2038. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- include/linux/posix-timers.h | 9 ----- kernel/time/posix-timers.c | 74 +++--------------------------------------- 2 files changed, 5 insertions(+), 78 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 35786c5..7c3dae2 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -97,29 +97,20 @@ struct k_itimer { }; struct k_clock { - int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); int (*clock_getres64) (const clockid_t which_clock, struct timespec64 *tp); - int (*clock_set) (const clockid_t which_clock, - const struct timespec *tp); int (*clock_set64) (const clockid_t which_clock, const struct timespec64 *tp); - int (*clock_get) (const clockid_t which_clock, struct timespec * tp); int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); int (*nsleep) (const clockid_t which_clock, int flags, struct timespec *, struct timespec __user *); long (*nsleep_restart) (struct restart_block *restart_block); - int (*timer_set) (struct k_itimer * timr, int flags, - struct itimerspec * new_setting, - struct itimerspec * old_setting); int (*timer_set64) (struct k_itimer *timr, int flags, struct itimerspec64 *new_setting, struct itimerspec64 *old_setting); int (*timer_del) (struct k_itimer * timr); #define TIMER_RETRY 1 - void (*timer_get) (struct k_itimer * timr, - struct itimerspec * cur_setting); void (*timer_get64) (struct k_itimer *timr, struct itimerspec64 *cur_setting); }; diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 8ced634..ba95172 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -140,7 +140,6 @@ static int common_timer_del(struct k_itimer *timer); static enum hrtimer_restart posix_timer_fn(struct hrtimer *data); static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags); -static struct k_clock *clockid_to_kclock(const clockid_t id); #define lock_timer(tid, flags) \ ({ struct k_itimer *__timr; \ @@ -514,57 +513,6 @@ static struct pid *good_sigevent(sigevent_t * event) return task_pid(rtn); } -static int default_timer_get64(struct k_itimer *timr, - struct itimerspec64 *cur_setting64) -{ - struct itimerspec cur_setting; - struct k_clock *kc = clockid_to_kclock(timr->it_clock); - - kc->timer_get(timr, &cur_setting); - return 0; -} - -static int default_timer_set64(struct k_itimer *timr, int flags, - struct itimerspec64 *new_setting64, - struct itimerspec64 *old_setting64) -{ - struct k_clock *kc = clockid_to_kclock(timr->it_clock); - struct itimerspec new_setting, old_setting; - - kc->timer_set(timr, flags, &new_setting, &old_setting); - return 0; -} - -static int default_clock_set64(const clockid_t which_clock, - const struct timespec64 *tp64) -{ - struct k_clock *kc = clockid_to_kclock(which_clock); - struct timespec tp; - - kc->clock_set(which_clock, &tp); - return 0; -} - -static int default_clock_get64(const clockid_t which_clock, - struct timespec64 *tp64) -{ - struct k_clock *kc = clockid_to_kclock(which_clock); - struct timespec tp; - - kc->clock_get(which_clock, &tp); - return 0; -} - -static int default_clock_getres64(const clockid_t which_clock, - struct timespec64 *tp64) -{ - struct k_clock *kc = clockid_to_kclock(which_clock); - struct timespec tp; - - kc->clock_getres(which_clock, &tp); - return 0; -} - void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -574,28 +522,17 @@ void posix_timers_register_clock(const clockid_t clock_id, return; } - if (!new_clock->clock_get && !new_clock->clock_get64) { - printk(KERN_WARNING "POSIX clock id %d lacks clock_get() and clock_get64()\n", + if (!new_clock->clock_get64) { + printk(KERN_WARNING "POSIX clock id %d lacks clock_get64()\n", clock_id); return; } - if (!new_clock->clock_getres && !new_clock->clock_getres64) { - printk(KERN_WARNING "POSIX clock id %d lacks clock_getres() and clock_getres64()\n", + if (!new_clock->clock_getres64) { + printk(KERN_WARNING "POSIX clock id %d lacks clock_getres64()\n", clock_id); return; } - if (new_clock->timer_get && !new_clock->timer_get64) - new_clock->timer_get64 = default_timer_get64; - if (new_clock->timer_set && !new_clock->timer_set64) - new_clock->timer_set64 = default_timer_set64; - if (new_clock->clock_set && !new_clock->clock_set64) - new_clock->clock_set64 = default_clock_set64; - if (new_clock->clock_get && !new_clock->clock_get64) - new_clock->clock_get64 = default_clock_get64; - if (new_clock->clock_getres && !new_clock->clock_getres64) - new_clock->clock_getres64 = default_clock_getres64; - posix_clocks[clock_id] = *new_clock; } EXPORT_SYMBOL_GPL(posix_timers_register_clock); @@ -642,8 +579,7 @@ static struct k_clock *clockid_to_kclock(const clockid_t id) return (id & CLOCKFD_MASK) == CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu; - if (id >= MAX_CLOCKS || (!posix_clocks[id].clock_getres - && !posix_clocks[id].clock_getres64)) + if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres64) return NULL; return &posix_clocks[id]; } -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 14/15] time/posix-cpu-timers:Convert to the 64bit methods for k_clock structure
by Baolin Wang
This patch changes to the new methods of k_clock structure with timespec64 type, converts the timespec/itimerspec type to timespec64/itimerspec64 type for the callback function in posix-cpu-timers.c file. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- kernel/time/posix-cpu-timers.c | 83 +++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 0075da7..a4651cd 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -52,7 +52,7 @@ static int check_clock(const clockid_t which_clock) } static inline unsigned long long -timespec_to_sample(const clockid_t which_clock, const struct timespec *tp) +timespec64_to_sample(const clockid_t which_clock, const struct timespec64 *tp) { unsigned long long ret; @@ -60,19 +60,19 @@ timespec_to_sample(const clockid_t which_clock, const struct timespec *tp) if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { ret = (unsigned long long)tp->tv_sec * NSEC_PER_SEC + tp->tv_nsec; } else { - ret = cputime_to_expires(timespec_to_cputime(tp)); + ret = cputime_to_expires(timespec64_to_cputime(tp)); } return ret; } -static void sample_to_timespec(const clockid_t which_clock, +static void sample_to_timespec64(const clockid_t which_clock, unsigned long long expires, - struct timespec *tp) + struct timespec64 *tp) { if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) - *tp = ns_to_timespec(expires); + *tp = ns_to_timespec64(expires); else - cputime_to_timespec((__force cputime_t)expires, tp); + cputime_to_timespec64((__force cputime_t)expires, tp); } /* @@ -141,7 +141,7 @@ static inline unsigned long long virt_ticks(struct task_struct *p) } static int -posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp) +posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp) { int error = check_clock(which_clock); if (!error) { @@ -160,7 +160,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp) } static int -posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp) +posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp) { /* * You can never reset a CPU clock, but we check for other errors @@ -263,7 +263,7 @@ static int cpu_clock_sample_group(const clockid_t which_clock, static int posix_cpu_clock_get_task(struct task_struct *tsk, const clockid_t which_clock, - struct timespec *tp) + struct timespec64 *tp) { int err = -EINVAL; unsigned long long rtn; @@ -277,13 +277,14 @@ static int posix_cpu_clock_get_task(struct task_struct *tsk, } if (!err) - sample_to_timespec(which_clock, rtn, tp); + sample_to_timespec64(which_clock, rtn, tp); return err; } -static int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp) +static int posix_cpu_clock_get(const clockid_t which_clock, + struct timespec64 *tp) { const pid_t pid = CPUCLOCK_PID(which_clock); int err = -EINVAL; @@ -598,7 +599,7 @@ static inline void posix_cpu_timer_kick_nohz(void) { } * and try again. (This happens when the timer is in the middle of firing.) */ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, - struct itimerspec *new, struct itimerspec *old) + struct itimerspec64 *new, struct itimerspec64 *old) { unsigned long flags; struct sighand_struct *sighand; @@ -608,7 +609,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, WARN_ON_ONCE(p == NULL); - new_expires = timespec_to_sample(timer->it_clock, &new->it_value); + new_expires = timespec64_to_sample(timer->it_clock, &new->it_value); /* * Protect against sighand release/switch in exit/exec and p->cpu_timers @@ -669,7 +670,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, bump_cpu_timer(timer, val); if (val < timer->it.cpu.expires) { old_expires = timer->it.cpu.expires - val; - sample_to_timespec(timer->it_clock, + sample_to_timespec64(timer->it_clock, old_expires, &old->it_value); } else { @@ -709,7 +710,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, * Install the new reload setting, and * set up the signal and overrun bookkeeping. */ - timer->it.cpu.incr = timespec_to_sample(timer->it_clock, + timer->it.cpu.incr = timespec64_to_sample(timer->it_clock, &new->it_interval); /* @@ -734,7 +735,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ret = 0; out: if (old) { - sample_to_timespec(timer->it_clock, + sample_to_timespec64(timer->it_clock, old_incr, &old->it_interval); } if (!ret) @@ -742,7 +743,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, return ret; } -static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp) +static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp) { unsigned long long now; struct task_struct *p = timer->it.cpu.task; @@ -752,7 +753,7 @@ static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp) /* * Easy part: convert the reload time. */ - sample_to_timespec(timer->it_clock, + sample_to_timespec64(timer->it_clock, timer->it.cpu.incr, &itp->it_interval); if (timer->it.cpu.expires == 0) { /* Timer not armed at all. */ @@ -782,7 +783,7 @@ static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp) * Call the timer disarmed, nothing else to do. */ timer->it.cpu.expires = 0; - sample_to_timespec(timer->it_clock, timer->it.cpu.expires, + sample_to_timespec64(timer->it_clock, timer->it.cpu.expires, &itp->it_value); } else { cpu_timer_sample_group(timer->it_clock, p, &now); @@ -791,7 +792,7 @@ static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp) } if (now < timer->it.cpu.expires) { - sample_to_timespec(timer->it_clock, + sample_to_timespec64(timer->it_clock, timer->it.cpu.expires - now, &itp->it_value); } else { @@ -1248,6 +1249,8 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags, struct timespec *rqtp, struct itimerspec *it) { struct k_itimer timer; + struct timespec64 ts64; + struct itimerspec64 *it64; int error; /* @@ -1260,13 +1263,14 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags, error = posix_cpu_timer_create(&timer); timer.it_process = current; if (!error) { - static struct itimerspec zero_it; + static struct itimerspec64 zero_it; memset(it, 0, sizeof *it); it->it_value = *rqtp; spin_lock_irq(&timer.it_lock); - error = posix_cpu_timer_set(&timer, flags, it, NULL); + *it64 = itimerspec_to_itimerspec64(it); + error = posix_cpu_timer_set(&timer, flags, it64, NULL); if (error) { spin_unlock_irq(&timer.it_lock); return error; @@ -1295,8 +1299,9 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags, /* * We were interrupted by a signal. */ - sample_to_timespec(which_clock, timer.it.cpu.expires, rqtp); - error = posix_cpu_timer_set(&timer, 0, &zero_it, it); + sample_to_timespec64(which_clock, timer.it.cpu.expires, &ts64); + *rqtp = timespec64_to_timespec(ts64); + error = posix_cpu_timer_set(&timer, 0, &zero_it, it64); if (!error) { /* * Timer is now unarmed, deletion can not fail. @@ -1395,12 +1400,12 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block) #define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED) static int process_cpu_clock_getres(const clockid_t which_clock, - struct timespec *tp) + struct timespec64 *tp) { return posix_cpu_clock_getres(PROCESS_CLOCK, tp); } static int process_cpu_clock_get(const clockid_t which_clock, - struct timespec *tp) + struct timespec64 *tp) { return posix_cpu_clock_get(PROCESS_CLOCK, tp); } @@ -1420,12 +1425,12 @@ static long process_cpu_nsleep_restart(struct restart_block *restart_block) return -EINVAL; } static int thread_cpu_clock_getres(const clockid_t which_clock, - struct timespec *tp) + struct timespec64 *tp) { return posix_cpu_clock_getres(THREAD_CLOCK, tp); } static int thread_cpu_clock_get(const clockid_t which_clock, - struct timespec *tp) + struct timespec64 *tp) { return posix_cpu_clock_get(THREAD_CLOCK, tp); } @@ -1436,37 +1441,37 @@ static int thread_cpu_timer_create(struct k_itimer *timer) } struct k_clock clock_posix_cpu = { - .clock_getres = posix_cpu_clock_getres, - .clock_set = posix_cpu_clock_set, - .clock_get = posix_cpu_clock_get, + .clock_getres64 = posix_cpu_clock_getres, + .clock_set64 = posix_cpu_clock_set, + .clock_get64 = posix_cpu_clock_get, .timer_create = posix_cpu_timer_create, .nsleep = posix_cpu_nsleep, .nsleep_restart = posix_cpu_nsleep_restart, - .timer_set = posix_cpu_timer_set, + .timer_set64 = posix_cpu_timer_set, .timer_del = posix_cpu_timer_del, - .timer_get = posix_cpu_timer_get, + .timer_get64 = posix_cpu_timer_get, }; static __init int init_posix_cpu_timers(void) { struct k_clock process = { - .clock_getres = process_cpu_clock_getres, - .clock_get = process_cpu_clock_get, + .clock_getres64 = process_cpu_clock_getres, + .clock_get64 = process_cpu_clock_get, .timer_create = process_cpu_timer_create, .nsleep = process_cpu_nsleep, .nsleep_restart = process_cpu_nsleep_restart, }; struct k_clock thread = { - .clock_getres = thread_cpu_clock_getres, - .clock_get = thread_cpu_clock_get, + .clock_getres64 = thread_cpu_clock_getres, + .clock_get64 = thread_cpu_clock_get, .timer_create = thread_cpu_timer_create, }; - struct timespec ts; + struct timespec64 ts; posix_timers_register_clock(CLOCK_PROCESS_CPUTIME_ID, &process); posix_timers_register_clock(CLOCK_THREAD_CPUTIME_ID, &thread); - cputime_to_timespec(cputime_one_jiffy, &ts); + cputime_to_timespec64(cputime_one_jiffy, &ts); onecputick = ts.tv_nsec; WARN_ON(ts.tv_sec != 0); -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 13/15] cputime:Introduce the cputime_to_timespec64/timespec64_to_cputime function
by Baolin Wang
This patch introduces some functions for converting cputime to timespec64 and back, that repalce the timespec type with timespec64 type, as well as for arch/s390 and arch/powerpc architecture. And these new methods will replace the old cputime_to_timespec/timespec_to_cputime function to ready for 2038 issue. The cputime_to_timespec/timespec_to_cputime functions are moved to include/linux/cputime.h file for removing conveniently. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- arch/powerpc/include/asm/cputime.h | 6 +++--- arch/s390/include/asm/cputime.h | 8 ++++---- include/asm-generic/cputime_jiffies.h | 10 +++++----- include/asm-generic/cputime_nsecs.h | 4 ++-- include/linux/cputime.h | 15 +++++++++++++++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index e245255..5dda5c0 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -154,9 +154,9 @@ static inline cputime_t secs_to_cputime(const unsigned long sec) } /* - * Convert cputime <-> timespec + * Convert cputime <-> timespec64 */ -static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p) +static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 *p) { u64 x = (__force u64) ct; unsigned int frac; @@ -168,7 +168,7 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p) p->tv_nsec = x; } -static inline cputime_t timespec_to_cputime(const struct timespec *p) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *p) { u64 ct; diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h index b91e960..1266697 100644 --- a/arch/s390/include/asm/cputime.h +++ b/arch/s390/include/asm/cputime.h @@ -89,16 +89,16 @@ static inline cputime_t secs_to_cputime(const unsigned int s) } /* - * Convert cputime to timespec and back. + * Convert cputime to timespec64 and back. */ -static inline cputime_t timespec_to_cputime(const struct timespec *value) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *value) { unsigned long long ret = value->tv_sec * CPUTIME_PER_SEC; return (__force cputime_t)(ret + __div(value->tv_nsec * CPUTIME_PER_USEC, NSEC_PER_USEC)); } -static inline void cputime_to_timespec(const cputime_t cputime, - struct timespec *value) +static inline void cputime_to_timespec64(const cputime_t cputime, + struct timespec64 *value) { unsigned long long __cputime = (__force unsigned long long) cputime; #ifndef CONFIG_64BIT diff --git a/include/asm-generic/cputime_jiffies.h b/include/asm-generic/cputime_jiffies.h index fe386fc..54e034c 100644 --- a/include/asm-generic/cputime_jiffies.h +++ b/include/asm-generic/cputime_jiffies.h @@ -44,12 +44,12 @@ typedef u64 __nocast cputime64_t; #define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ) /* - * Convert cputime to timespec and back. + * Convert cputime to timespec64 and back. */ -#define timespec_to_cputime(__val) \ - jiffies_to_cputime(timespec_to_jiffies(__val)) -#define cputime_to_timespec(__ct,__val) \ - jiffies_to_timespec(cputime_to_jiffies(__ct),__val) +#define timespec64_to_cputime(__val) \ + jiffies_to_cputime(timespec64_to_jiffies(__val)) +#define cputime_to_timespec64(__ct,__val) \ + jiffies_to_timespec64(cputime_to_jiffies(__ct),__val) /* * Convert cputime to timeval and back. diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h index 0419485..65c875b 100644 --- a/include/asm-generic/cputime_nsecs.h +++ b/include/asm-generic/cputime_nsecs.h @@ -73,12 +73,12 @@ typedef u64 __nocast cputime64_t; /* * Convert cputime <-> timespec (nsec) */ -static inline cputime_t timespec_to_cputime(const struct timespec *val) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *val) { u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_nsec; return (__force cputime_t) ret; } -static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) +static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 *val) { u32 rem; diff --git a/include/linux/cputime.h b/include/linux/cputime.h index f2eb2ee..f01896f 100644 --- a/include/linux/cputime.h +++ b/include/linux/cputime.h @@ -13,4 +13,19 @@ usecs_to_cputime((__nsecs) / NSEC_PER_USEC) #endif +static inline cputime_t timespec_to_cputime(const struct timespec *ts) +{ + struct timespec64 ts64 = timespec_to_timespec64(*ts); + return timespec64_to_cputime(&ts64); +} + +static inline void cputime_to_timespec(const cputime_t cputime, + struct timespec *value) +{ + struct timespec64 *ts64; + + *ts64 = timespec_to_timespec64(*value); + cputime_to_timespec64(cputime, ts64); +} + #endif /* __LINUX_CPUTIME_H */ -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 12/15] time/time:Introduce the timespec64_to_jiffies/jiffies_to_timespec64 function
by Baolin Wang
This patch introduces the timespec64_to_jiffies() and jiffies_to_timespec64() functions, that implement the conversion between cputime and timespec64. And remove the old functions timespec64_to_jiffies()/jiffies_to_timespec64() to jiffies.h file. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- include/linux/jiffies.h | 21 ++++++++++++++++++--- kernel/time/time.c | 12 ++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index c367cbd..16a30c1 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -290,9 +290,24 @@ static inline u64 jiffies_to_nsecs(const unsigned long j) extern unsigned long msecs_to_jiffies(const unsigned int m); extern unsigned long usecs_to_jiffies(const unsigned int u); -extern unsigned long timespec_to_jiffies(const struct timespec *value); -extern void jiffies_to_timespec(const unsigned long jiffies, - struct timespec *value); +extern unsigned long __timespec_to_jiffies(unsigned long sec, long nsec); +extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); +extern void jiffies_to_timespec64(const unsigned long jiffies, + struct timespec64 *value); +static inline unsigned long timespec_to_jiffies(const struct timespec *value) +{ + return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); +} + +static inline void jiffies_to_timespec(const unsigned long jiffies, + struct timespec *value) +{ + struct timespec64 *ts; + + *ts = timespec_to_timespec64(*value); + jiffies_to_timespec64(jiffies, ts); +} + extern unsigned long timeval_to_jiffies(const struct timeval *value); extern void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value); diff --git a/kernel/time/time.c b/kernel/time/time.c index f43011b..3aba16f 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -571,7 +571,7 @@ EXPORT_SYMBOL(usecs_to_jiffies); * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec * value to a scaled second value. */ -static unsigned long +unsigned long __timespec_to_jiffies(unsigned long sec, long nsec) { nsec = nsec + TICK_NSEC - 1; @@ -585,17 +585,17 @@ __timespec_to_jiffies(unsigned long sec, long nsec) (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; } +EXPORT_SYMBOL(__timespec_to_jiffies); unsigned long -timespec_to_jiffies(const struct timespec *value) +timespec64_to_jiffies(const struct timespec64 *value) { return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); } - -EXPORT_SYMBOL(timespec_to_jiffies); +EXPORT_SYMBOL(timespec64_to_jiffies); void -jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) +jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value) { /* * Convert jiffies to nanoseconds and separate with @@ -606,7 +606,7 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) NSEC_PER_SEC, &rem); value->tv_nsec = rem; } -EXPORT_SYMBOL(jiffies_to_timespec); +EXPORT_SYMBOL(jiffies_to_timespec64); /* * We could use a similar algorithm to timespec_to_jiffies (with a -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 11/15] time/posix-clock:Convert to the 64bit methods for k_clock and posix_clock_operations structure
by Baolin Wang
This patch converts the posix clock operations over to the new methods with timespec64/itimerspec64 type to making them ready for 2038, and it is based on the ptp patch series. And also changes to the 64bit methods for k_clock structure, that converts the timespec/itimerspec type to timespec64/itimerspec64 type. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- drivers/ptp/ptp_clock.c | 26 ++++++++------------------ include/linux/posix-clock.h | 10 +++++----- kernel/time/posix-clock.c | 20 ++++++++++---------- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index bee8270..8c086e7 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -97,32 +97,24 @@ static s32 scaled_ppm_to_ppb(long ppm) /* posix clock implementation */ -static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp) +static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp) { tp->tv_sec = 0; tp->tv_nsec = 1; return 0; } -static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp) +static int ptp_clock_settime(struct posix_clock *pc, + const struct timespec64 *tp) { struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); - struct timespec64 ts = timespec_to_timespec64(*tp); - - return ptp->info->settime64(ptp->info, &ts); + return ptp->info->settime64(ptp->info, tp); } -static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp) +static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp) { struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); - struct timespec64 ts; - int err; - - err = ptp->info->gettime64(ptp->info, &ts); - if (!err) - *tp = timespec64_to_timespec(ts); - - return err; + return ptp->info->gettime64(ptp->info, tp); } static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx) @@ -134,8 +126,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx) ops = ptp->info; if (tx->modes & ADJ_SETOFFSET) { - struct timespec ts; - ktime_t kt; + struct timespec64 ts; s64 delta; ts.tv_sec = tx->time.tv_sec; @@ -147,8 +138,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx) if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC) return -EINVAL; - kt = timespec_to_ktime(ts); - delta = ktime_to_ns(kt); + delta = timespec64_to_ns(&ts); err = ops->adjtime(ops, delta); } else if (tx->modes & ADJ_FREQUENCY) { s32 ppb = scaled_ppm_to_ppb(tx->freq); diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h index 34c4498..fd7e22c 100644 --- a/include/linux/posix-clock.h +++ b/include/linux/posix-clock.h @@ -59,23 +59,23 @@ struct posix_clock_operations { int (*clock_adjtime)(struct posix_clock *pc, struct timex *tx); - int (*clock_gettime)(struct posix_clock *pc, struct timespec *ts); + int (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts); - int (*clock_getres) (struct posix_clock *pc, struct timespec *ts); + int (*clock_getres)(struct posix_clock *pc, struct timespec64 *ts); int (*clock_settime)(struct posix_clock *pc, - const struct timespec *ts); + const struct timespec64 *ts); int (*timer_create) (struct posix_clock *pc, struct k_itimer *kit); int (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit); void (*timer_gettime)(struct posix_clock *pc, - struct k_itimer *kit, struct itimerspec *tsp); + struct k_itimer *kit, struct itimerspec64 *tsp); int (*timer_settime)(struct posix_clock *pc, struct k_itimer *kit, int flags, - struct itimerspec *tsp, struct itimerspec *old); + struct itimerspec64 *tsp, struct itimerspec64 *old); /* * Optional character device methods: */ diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index ce033c7..e21e4c1 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c @@ -297,7 +297,7 @@ out: return err; } -static int pc_clock_gettime(clockid_t id, struct timespec *ts) +static int pc_clock_gettime(clockid_t id, struct timespec64 *ts) { struct posix_clock_desc cd; int err; @@ -316,7 +316,7 @@ static int pc_clock_gettime(clockid_t id, struct timespec *ts) return err; } -static int pc_clock_getres(clockid_t id, struct timespec *ts) +static int pc_clock_getres(clockid_t id, struct timespec64 *ts) { struct posix_clock_desc cd; int err; @@ -335,7 +335,7 @@ static int pc_clock_getres(clockid_t id, struct timespec *ts) return err; } -static int pc_clock_settime(clockid_t id, const struct timespec *ts) +static int pc_clock_settime(clockid_t id, const struct timespec64 *ts) { struct posix_clock_desc cd; int err; @@ -399,7 +399,7 @@ static int pc_timer_delete(struct k_itimer *kit) return err; } -static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec *ts) +static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec64 *ts) { clockid_t id = kit->it_clock; struct posix_clock_desc cd; @@ -414,7 +414,7 @@ static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec *ts) } static int pc_timer_settime(struct k_itimer *kit, int flags, - struct itimerspec *ts, struct itimerspec *old) + struct itimerspec64 *ts, struct itimerspec64 *old) { clockid_t id = kit->it_clock; struct posix_clock_desc cd; @@ -435,12 +435,12 @@ static int pc_timer_settime(struct k_itimer *kit, int flags, } struct k_clock clock_posix_dynamic = { - .clock_getres = pc_clock_getres, - .clock_set = pc_clock_settime, - .clock_get = pc_clock_gettime, + .clock_getres64 = pc_clock_getres, + .clock_set64 = pc_clock_settime, + .clock_get64 = pc_clock_gettime, .clock_adj = pc_clock_adjtime, .timer_create = pc_timer_create, - .timer_set = pc_timer_settime, + .timer_set64 = pc_timer_settime, .timer_del = pc_timer_delete, - .timer_get = pc_timer_gettime, + .timer_get64 = pc_timer_gettime, }; -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 10/15] time/alarmtimer:Convert to the new methods for k_clock structure
by Baolin Wang
This patch changes to the new methods with timespec64/itimerspec64 type of k_clock structure, and converts the timespec/itimerspec type to timespec64/itimerspec64 typein alarmtimer.c file. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- kernel/time/alarmtimer.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 1b001ed..68186e1 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -489,35 +489,36 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, /** * alarm_clock_getres - posix getres interface * @which_clock: clockid - * @tp: timespec to fill + * @tp: timespec64 to fill * * Returns the granularity of underlying alarm base clock */ -static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp) +static int alarm_clock_getres(const clockid_t which_clock, + struct timespec64 *tp) { clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid; if (!alarmtimer_get_rtcdev()) return -EINVAL; - return hrtimer_get_res(baseid, tp); + return hrtimer_get_res64(baseid, tp); } /** * alarm_clock_get - posix clock_get interface * @which_clock: clockid - * @tp: timespec to fill. + * @tp: timespec64 to fill. * * Provides the underlying alarm base time. */ -static int alarm_clock_get(clockid_t which_clock, struct timespec *tp) +static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp) { struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)]; if (!alarmtimer_get_rtcdev()) return -EINVAL; - *tp = ktime_to_timespec(base->gettime()); + *tp = ktime_to_timespec64(base->gettime()); return 0; } @@ -547,24 +548,24 @@ static int alarm_timer_create(struct k_itimer *new_timer) /** * alarm_timer_get - posix timer_get interface * @new_timer: k_itimer pointer - * @cur_setting: itimerspec data to fill + * @cur_setting: itimerspec64 data to fill * * Copies out the current itimerspec data */ static void alarm_timer_get(struct k_itimer *timr, - struct itimerspec *cur_setting) + struct itimerspec64 *cur_setting) { ktime_t relative_expiry_time = alarm_expires_remaining(&(timr->it.alarm.alarmtimer)); if (ktime_to_ns(relative_expiry_time) > 0) { - cur_setting->it_value = ktime_to_timespec(relative_expiry_time); + cur_setting->it_value = ktime_to_timespec64(relative_expiry_time); } else { cur_setting->it_value.tv_sec = 0; cur_setting->it_value.tv_nsec = 0; } - cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval); + cur_setting->it_interval = ktime_to_timespec64(timr->it.alarm.interval); } /** @@ -588,14 +589,14 @@ static int alarm_timer_del(struct k_itimer *timr) * alarm_timer_set - posix timer_set interface * @timr: k_itimer pointer to be deleted * @flags: timer flags - * @new_setting: itimerspec to be used - * @old_setting: itimerspec being replaced + * @new_setting: itimerspec64 to be used + * @old_setting: itimerspec64 being replaced * * Sets the timer to new_setting, and starts the timer. */ static int alarm_timer_set(struct k_itimer *timr, int flags, - struct itimerspec *new_setting, - struct itimerspec *old_setting) + struct itimerspec64 *new_setting, + struct itimerspec64 *old_setting) { ktime_t exp; @@ -613,8 +614,8 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, return TIMER_RETRY; /* start the timer */ - timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval); - exp = timespec_to_ktime(new_setting->it_value); + timr->it.alarm.interval = timespec64_to_ktime(new_setting->it_interval); + exp = timespec64_to_ktime(new_setting->it_value); /* Convert (if necessary) to absolute time */ if (flags != TIMER_ABSTIME) { ktime_t now; @@ -670,7 +671,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp) /** - * update_rmtp - Update remaining timespec value + * update_rmtp - Update remaining timespec64 value * @exp: expiration time * @type: timer type * @rmtp: user pointer to remaining timepsec value @@ -824,12 +825,12 @@ static int __init alarmtimer_init(void) int error = 0; int i; struct k_clock alarm_clock = { - .clock_getres = alarm_clock_getres, - .clock_get = alarm_clock_get, + .clock_getres64 = alarm_clock_getres, + .clock_get64 = alarm_clock_get, .timer_create = alarm_timer_create, - .timer_set = alarm_timer_set, + .timer_set64 = alarm_timer_set, .timer_del = alarm_timer_del, - .timer_get = alarm_timer_get, + .timer_get64 = alarm_timer_get, .nsleep = alarm_timer_nsleep, }; -- 1.7.9.5
9 years, 7 months
1
0
0
0
[PATCH v2 09/15] char/mmtimer:Convert to the 64bit methods for k_clock callback function
by Baolin Wang
This patch converts to the 64bit methods for k_clock callback function, that converts the timespec type to timespec64 type and converts the itimerspec type to itimerspec64 type. Signed-off-by: Baolin Wang <baolin.wang(a)linaro.org> --- drivers/char/mmtimer.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 3d6c067..213d0bb 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -478,18 +478,18 @@ static int sgi_clock_period; static struct timespec sgi_clock_offset; static int sgi_clock_period; -static int sgi_clock_get(clockid_t clockid, struct timespec *tp) +static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp) { u64 nsec; nsec = rtc_time() * sgi_clock_period + sgi_clock_offset.tv_nsec; - *tp = ns_to_timespec(nsec); + *tp = ns_to_timespec64(nsec); tp->tv_sec += sgi_clock_offset.tv_sec; return 0; }; -static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp) +static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp) { u64 nsec; @@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr) } /* Assumption: it_lock is already held with irq's disabled */ -static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) +static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting) { if (timr->it.mmtimer.clock == TIMER_OFF) { @@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) return; } - cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * sgi_clock_period); - cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period); + cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * sgi_clock_period); + cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period); } static int sgi_timer_set(struct k_itimer *timr, int flags, - struct itimerspec * new_setting, - struct itimerspec * old_setting) + struct itimerspec64 *new_setting, + struct itimerspec64 *old_setting) { unsigned long when, period, irqflags; int err = 0; @@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, sgi_timer_get(timr, old_setting); sgi_timer_del(timr); - when = timespec_to_ns(&new_setting->it_value); - period = timespec_to_ns(&new_setting->it_interval); + when = timespec64_to_ns(&new_setting->it_value); + period = timespec64_to_ns(&new_setting->it_interval); if (when == 0) /* Clear timer */ @@ -699,11 +699,9 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, return -ENOMEM; if (flags & TIMER_ABSTIME) { - struct timespec n; unsigned long now; - getnstimeofday(&n); - now = timespec_to_ns(&n); + now = ktime_get_real_ns(); if (when > now) when -= now; else @@ -765,7 +763,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, return err; } -static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp) +static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp) { tp->tv_sec = 0; tp->tv_nsec = sgi_clock_period; @@ -773,13 +771,13 @@ static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp) } static struct k_clock sgi_clock = { - .clock_set = sgi_clock_set, - .clock_get = sgi_clock_get, - .clock_getres = sgi_clock_getres, + .clock_set64 = sgi_clock_set, + .clock_get64 = sgi_clock_get, + .clock_getres64 = sgi_clock_getres, .timer_create = sgi_timer_create, - .timer_set = sgi_timer_set, + .timer_set64 = sgi_timer_set, .timer_del = sgi_timer_del, - .timer_get = sgi_timer_get + .timer_get64 = sgi_timer_get }; /** -- 1.7.9.5
9 years, 7 months
1
0
0
0
← Newer
1
2
3
4
Older →
Jump to page:
1
2
3
4
Results per page:
10
25
50
100
200