summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-05-08 22:59:16 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2020-05-08 22:59:16 +0100
commit1bef8acc4b8c09637b3b233ece30a9e9c694bf8c (patch)
treebe7f4387ea4d4e012cbe59e8c2f0ef0f90f13f6f
parent5.6: base on 5.5 patches (diff)
downloadlinux-headers-patches-1bef8acc4b8c09637b3b233ece30a9e9c694bf8c.tar.gz
linux-headers-patches-1bef8acc4b8c09637b3b233ece30a9e9c694bf8c.tar.bz2
linux-headers-patches-1bef8acc4b8c09637b3b233ece30a9e9c694bf8c.zip
5.4: backport from 5.6 time64 alsa patches
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p1.patch49
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p2.patch41
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p3.patch96
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p4.patch47
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p5.patch73
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p6.patch248
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p7.patch68
-rw-r--r--5.4/01_all_backport-5.6-alsa-timespec64-p8.patch53
8 files changed, 675 insertions, 0 deletions
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p1.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p1.patch
new file mode 100644
index 0000000..1195ca2
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p1.patch
@@ -0,0 +1,49 @@
+From a07804cc7472d8aa5db03ea5d75f3d8d80abb687 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Tue, 24 Apr 2018 20:06:09 +0800
+Subject: [PATCH] ALSA: Avoid using timespec for struct snd_timer_status
+
+struct snd_timer_status uses 'timespec' type variables to record
+timestamp, which will be changed to an incompatible layout with
+updated user space using 64-bit time_t.
+
+To handle both the old and the new layout on 32-bit architectures,
+this patch introduces 'struct snd_timer_status32' and 'struct snd_timer_status64'
+to handle 32bit time_t and 64bit time_t in native mode and compat mode,
+which replaces timespec with s64 type.
+
+When glibc changes time_t to 64-bit, any recompiled program will issue
+ioctl commands that the kernel does not understand without this patch.
+
+In the public uapi header, snd_timer_status is now guarded by
+an #ifndef __KERNEL__ to avoid referencing 'struct timespec'.
+The timespec definition will be removed from the kernel to prevent
+new y2038 bugs and to avoid the conflict with an incompatible libc
+type of the same name.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 2 ++
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -761,6 +761,7 @@ struct snd_timer_params {
+ unsigned char reserved[60]; /* reserved */
+ };
+
++#ifndef __KERNEL__
+ struct snd_timer_status {
+ struct timespec tstamp; /* Timestamp - last update */
+ unsigned int resolution; /* current period resolution in ns */
+@@ -769,6 +770,7 @@ struct snd_timer_status {
+ unsigned int queue; /* used queue size */
+ unsigned char reserved[64]; /* reserved */
+ };
++#endif
+
+ #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int)
+ #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id)
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p2.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p2.patch
new file mode 100644
index 0000000..865e118
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p2.patch
@@ -0,0 +1,41 @@
+From a4e7dd35b9dac21fa7b33e8788b51c7fbc7a49f1 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Tue, 24 Apr 2018 20:06:10 +0800
+Subject: [PATCH] ALSA: Avoid using timespec for struct snd_ctl_elem_value
+
+The struct snd_ctl_elem_value will use 'timespec' type variables to record
+timestamp, which is not year 2038 safe on 32bits system.
+
+Since there are no drivers will implemented the tstamp member of the
+struct snd_ctl_elem_value, and also the stucture size will not be changed
+if we change timespec to s64 for tstamp member of struct snd_ctl_elem_value.
+
+From Takashi's comments, "In the library, applications are not expected
+to access to this structure directly. The applications get opaque pointer
+to the structure and must use any control APIs to operate it. Actually the
+library produce no API to handle 'struct snd_ctl_elem_value.tstamp'. This
+means that we can drop this member from alsa-lib without decline of
+functionality." Thus we can simply remove the tstamp member to avoid using
+the type which is not year 2038 safe on 32bits system.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -957,8 +957,7 @@ struct snd_ctl_elem_value {
+ } bytes;
+ struct snd_aes_iec958 iec958;
+ } value; /* RO */
+- struct timespec tstamp;
+- unsigned char reserved[128-sizeof(struct timespec)];
++ unsigned char reserved[128];
+ };
+
+ struct snd_ctl_tlv {
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p3.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p3.patch
new file mode 100644
index 0000000..062cfba
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p3.patch
@@ -0,0 +1,96 @@
+From 3ddee7f88aaf2dee38f7016ac8fd48dd9fdb43e3 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Tue, 24 Apr 2018 20:06:11 +0800
+Subject: [PATCH] ALSA: Avoid using timespec for struct snd_pcm_status
+
+The struct snd_pcm_status will use 'timespec' type variables to record
+timestamp, which is not year 2038 safe on 32bits system.
+
+Userspace will use SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT
+as commands to issue ioctl() to fill the 'snd_pcm_status' structure in
+userspace. The command number is always defined through _IOR/_IOW/IORW,
+so when userspace changes the definition of 'struct timespec' to use
+64-bit types, the command number also changes.
+
+Thus in the kernel, we now need to define two versions of each such ioctl
+and corresponding ioctl commands to handle 32bit time_t and 64bit time_t
+in native mode:
+struct snd_pcm_status32 {
+ ......
+
+ s32 trigger_tstamp_sec;
+ s32 trigger_tstamp_nsec;
+
+ ......
+
+ s32 audio_tstamp_sec;
+ s32 audio_tstamp_nsec;
+
+ ......
+};
+
+struct snd_pcm_status64 {
+ ......
+
+ s32 trigger_tstamp_sec;
+ s32 trigger_tstamp_nsec;
+
+ ......
+
+ s32 audio_tstamp_sec;
+ s32 audio_tstamp_nsec;
+
+ ......
+};
+
+Moreover in compat file, we renamed or introduced new structures to handle
+32bit/64bit time_t in compatible mode. The 'struct snd_pcm_status32' and
+snd_pcm_status_user32() are used to handle 32bit time_t in compat mode.
+'struct compat_snd_pcm_status64' and snd_pcm_status_user_compat64() are used
+to handle 64bit time_t.
+
+The implicit padding before timespec is made explicit to avoid incompatible
+structure layout between 32-bit and 64-bit x86 due to the different
+alignment requirements, and the snd_pcm_status structure is now hidden
+from the kernel to avoid relying on the timespec definitio definitionn
+
+Finally we can replace SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT
+with new commands and introduce new functions to fill new 'struct snd_pcm_status64'
+instead of using unsafe 'struct snd_pcm_status'. Then in future, the new
+commands can be matched when userspace changes 'timespec' to 64bit type
+to make a size change of 'struct snd_pcm_status'. When glibc changes time_t
+to 64-bit, any recompiled program will issue ioctl commands that the kernel
+does not understand without this patch.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 6 ++
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -456,8 +456,13 @@ enum {
+ SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED
+ };
+
++#ifndef __KERNEL__
++/* explicit padding avoids incompatibility between i386 and x86-64 */
++typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] __time_pad;
++
+ struct snd_pcm_status {
+ snd_pcm_state_t state; /* stream state */
++ __time_pad pad1; /* align to timespec */
+ struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
+ struct timespec tstamp; /* reference timestamp */
+ snd_pcm_uframes_t appl_ptr; /* appl ptr */
+@@ -473,6 +478,7 @@ struct snd_pcm_status {
+ __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */
+ unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
+ };
++#endif
+
+ struct snd_pcm_mmap_status {
+ snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p4.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p4.patch
new file mode 100644
index 0000000..03b54d1
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p4.patch
@@ -0,0 +1,47 @@
+From d9e5582c4bb219f3459e39f65410f0e5128fbe91 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Tue, 24 Apr 2018 20:06:12 +0800
+Subject: [PATCH] ALSA: Avoid using timespec for struct snd_rawmidi_status
+
+The struct snd_rawmidi_status will use 'timespec' type variables to record
+timestamp, which is not year 2038 safe on 32bits system.
+
+Thus we introduced 'struct snd_rawmidi_status32' and 'struct snd_rawmidi_status64'
+to handle 32bit time_t and 64bit time_t in native mode, which replace
+timespec with s64 type.
+
+In compat mode, we renamed or introduced new structures to handle 32bit/64bit
+time_t in compatible mode. The 'struct snd_rawmidi_status32' and
+snd_rawmidi_ioctl_status32() are used to handle 32bit time_t in compat mode.
+'struct compat_snd_rawmidi_status64' is used to handle 64bit time_t.
+
+When glibc changes time_t to 64-bit, any recompiled program will issue ioctl
+commands that the kernel does not understand without this patch.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 3 +
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -654,13 +654,16 @@ struct snd_rawmidi_params {
+ unsigned char reserved[16]; /* reserved for future use */
+ };
+
++#ifndef __KERNEL__
+ struct snd_rawmidi_status {
+ int stream;
++ __time_pad pad1;
+ struct timespec tstamp; /* Timestamp */
+ size_t avail; /* available bytes */
+ size_t xruns; /* count of overruns since last status (in bytes) */
+ unsigned char reserved[16]; /* reserved for future use */
+ };
++#endif
+
+ #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
+ #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p5.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p5.patch
new file mode 100644
index 0000000..4c53f28
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p5.patch
@@ -0,0 +1,73 @@
+From 07094ae6f9527279de6fd0c59e88f6d0423585b1 Mon Sep 17 00:00:00 2001
+From: Baolin Wang <baolin.wang@linaro.org>
+Date: Tue, 24 Apr 2018 20:06:13 +0800
+Subject: [PATCH] ALSA: Avoid using timespec for struct snd_timer_tread
+
+The struct snd_timer_tread will use 'timespec' type variables to record
+timestamp, which is not year 2038 safe on 32bits system.
+
+Since the struct snd_timer_tread is passed through read() rather than
+ioctl(), and the read syscall has no command number that lets us pick
+between the 32-bit or 64-bit version of this structure.
+
+Thus we introduced one new command SNDRV_TIMER_IOCTL_TREAD64 and new
+struct snd_timer_tread64 replacing timespec with s64 type to handle
+64bit time_t. That means we will set tu->tread = TREAD_FORMAT_64BIT
+when user space has a 64bit time_t, then we will copy to user with
+struct snd_timer_tread64. Otherwise we will use 32bit time_t variables
+when copying to user.
+
+Moreover this patch replaces timespec type with timespec64 type and
+related y2038 safe APIs.
+
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 15 +++-
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -783,7 +783,7 @@ struct snd_timer_status {
+
+ #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int)
+ #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id)
+-#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
++#define SNDRV_TIMER_IOCTL_TREAD_OLD _IOW('T', 0x02, int)
+ #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo)
+ #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams)
+ #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus)
+@@ -796,6 +796,15 @@ struct snd_timer_status {
+ #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1)
+ #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2)
+ #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3)
++#define SNDRV_TIMER_IOCTL_TREAD64 _IOW('T', 0xa4, int)
++
++#if __BITS_PER_LONG == 64
++#define SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_TREAD_OLD
++#else
++#define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \
++ SNDRV_TIMER_IOCTL_TREAD_OLD : \
++ SNDRV_TIMER_IOCTL_TREAD64)
++#endif
+
+ struct snd_timer_read {
+ unsigned int resolution;
+@@ -821,11 +830,15 @@ enum {
+ SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
+ };
+
++#ifndef __KERNEL__
+ struct snd_timer_tread {
+ int event;
++ __time_pad pad1;
+ struct timespec tstamp;
+ unsigned int val;
++ __time_pad pad2;
+ };
++#endif
+
+ /****************************************************************************
+ * *
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p6.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p6.patch
new file mode 100644
index 0000000..0f7ed72
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p6.patch
@@ -0,0 +1,248 @@
+From 80fe7430c7085951d1246d83f638cc17e6c0be36 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Tue, 24 Apr 2018 20:06:15 +0800
+Subject: [PATCH] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
+
+The snd_pcm_mmap_status and snd_pcm_mmap_control interfaces are one of the
+trickiest areas to get right when moving to 64-bit time_t in user space.
+
+The snd_pcm_mmap_status structure layout is incompatible with user space
+that uses a 64-bit time_t, so we need a new layout for it. Since the
+SNDRV_PCM_IOCTL_SYNC_PTR ioctl combines it with snd_pcm_mmap_control
+into snd_pcm_sync_ptr, we need to change those two as well.
+
+Both structures are also exported via an mmap() operation on certain
+architectures, and this suffers from incompatibility between 32-bit
+and 64-bit user space. As we have to change both structures anyway,
+this is a good opportunity to fix the mmap() problem as well, so let's
+standardize on the existing 64-bit layout of the structure where possible.
+
+The downside is that we lose mmap() support for existing 32-bit x86 and
+powerpc applications, adding that would introduce very noticeable runtime
+overhead and complexity. My assumption here is that not too many people
+will miss the removed feature, given that:
+
+- Almost all x86 and powerpc users these days are on 64-bit kernels,
+the majority of today's 32-bit users are on architectures that never
+supported mmap (ARM, MIPS, ...).
+- It never worked in compat mode (it was intentionally disabled there)
+- The application already needs to work with a fallback to
+SNDRV_PCM_IOCTL_SYNC_PTR, which will keep working with both the old
+and new structure layout.
+
+Both the ioctl() and mmap() based interfaces are changed at the same
+time, as they are based on the same structures. Unlike other interfaces,
+we change the uapi header to export both the traditional structure and
+a version that is portable between 32-bit and 64-bit user space code
+and that corresponds to the existing 64-bit layout. We further check the
+__USE_TIME_BITS64 macro that will be defined by future C library versions
+whenever we use the new time_t definition, so any existing user space
+source code will not see any changes until it gets rebuilt against a new
+C library. However, the new structures are all visible in addition to the
+old ones, allowing applications to explicitly request the new structures.
+
+In order to detect the difference between the old snd_pcm_mmap_status and
+the new __snd_pcm_mmap_status64 structure from the ioctl command number,
+we rely on one quirk in the structure definition: snd_pcm_mmap_status
+must be aligned to alignof(time_t), which leads the compiler to insert
+four bytes of padding in struct snd_pcm_sync_ptr after 'flags' and a
+corresponding change in the size of snd_pcm_sync_ptr itself. On x86-32
+(and only there), the compiler doesn't use 64-bit alignment in structure,
+so I'm adding an explicit pad in the structure that has no effect on the
+existing 64-bit architectures but ensures that the layout matches for x86.
+
+The snd_pcm_uframes_t type compatibility requires another hack: we can't
+easily make that 64 bit wide, so I leave the type as 'unsigned long',
+but add padding before and after it, to ensure that the data is properly
+aligned to the respective 64-bit field in the in-kernel structure.
+
+For the SNDRV_PCM_MMAP_OFFSET_STATUS/CONTROL constants that are used
+as the virtual file offset in the mmap() function, we also have to
+introduce new constants that depend on hte __USE_TIME_BITS64 macro:
+The existing macros are renamed to SNDRV_PCM_MMAP_OFFSET_STATUS_OLD
+and SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, they continue to work fine on
+64-bit architectures, but stop working on native 32-bit user space.
+The replacement _NEW constants are now used by default for user space
+built with __USE_TIME_BITS64, those now work on all new kernels for x86,
+ppc and alpha (32 and 64 bit, native and compat). It might be a good idea
+for a future alsa-lib to support both the _OLD and _NEW macros and use
+the corresponding structures directly. Unmodified alsa-lib source code
+will retain the current behavior, so it will no longer be able to use
+mmap() for the status/control structures on 32-bit systems, until either
+the C library gets updated to 64-bit time_t or alsa-lib gets updated to
+support both mmap() layouts.
+
+Co-developed-with: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 110 ++++++++++++++++++++++++++++++++----
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -35,6 +35,8 @@
+ #include <time.h>
+ #endif
+
++#include <asm/byteorder.h>
++
+ /*
+ * protocol version
+ */
+@@ -301,7 +303,9 @@ typedef int __bitwise snd_pcm_subformat_t;
+ #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */
+ #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
+
+-
++#if (__BITS_PER_LONG == 32 && defined(__USE_TIME_BITS64)) || defined __KERNEL__
++#define __SND_STRUCT_TIME64
++#endif
+
+ typedef int __bitwise snd_pcm_state_t;
+ #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
+@@ -317,8 +321,17 @@ typedef int __bitwise snd_pcm_state_t;
+
+ enum {
+ SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
+- SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
+- SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
++ SNDRV_PCM_MMAP_OFFSET_STATUS_OLD = 0x80000000,
++ SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD = 0x81000000,
++ SNDRV_PCM_MMAP_OFFSET_STATUS_NEW = 0x82000000,
++ SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW = 0x83000000,
++#ifdef __SND_STRUCT_TIME64
++ SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_NEW,
++ SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW,
++#else
++ SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_OLD,
++ SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD,
++#endif
+ };
+
+ union snd_pcm_sync_id {
+@@ -480,16 +493,46 @@ struct snd_pcm_status {
+ };
+ #endif
+
+-struct snd_pcm_mmap_status {
++/*
++ * For mmap operations, we need the 64-bit layout, both for compat mode,
++ * and for y2038 compatibility. For 64-bit applications, the two definitions
++ * are identical, so we keep the traditional version.
++ */
++#ifdef __SND_STRUCT_TIME64
++#define __snd_pcm_mmap_status64 snd_pcm_mmap_status
++#define __snd_pcm_mmap_control64 snd_pcm_mmap_control
++#define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr
++#ifdef __KERNEL__
++#define __snd_timespec64 __kernel_timespec
++#else
++#define __snd_timespec64 timespec
++#endif
++struct __snd_timespec {
++ __s32 tv_sec;
++ __s32 tv_nsec;
++};
++#else
++#define __snd_pcm_mmap_status snd_pcm_mmap_status
++#define __snd_pcm_mmap_control snd_pcm_mmap_control
++#define __snd_pcm_sync_ptr snd_pcm_sync_ptr
++#define __snd_timespec timespec
++struct __snd_timespec64 {
++ __s64 tv_sec;
++ __s64 tv_nsec;
++};
++
++#endif
++
++struct __snd_pcm_mmap_status {
+ snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
+ int pad1; /* Needed for 64 bit alignment */
+ snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
+- struct timespec tstamp; /* Timestamp */
++ struct __snd_timespec tstamp; /* Timestamp */
+ snd_pcm_state_t suspended_state; /* RO: suspended stream state */
+- struct timespec audio_tstamp; /* from sample counter or wall clock */
++ struct __snd_timespec audio_tstamp; /* from sample counter or wall clock */
+ };
+
+-struct snd_pcm_mmap_control {
++struct __snd_pcm_mmap_control {
+ snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
+ snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
+ };
+@@ -498,14 +541,59 @@ struct snd_pcm_mmap_control {
+ #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */
+ #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */
+
+-struct snd_pcm_sync_ptr {
++struct __snd_pcm_sync_ptr {
+ unsigned int flags;
+ union {
+- struct snd_pcm_mmap_status status;
++ struct __snd_pcm_mmap_status status;
++ unsigned char reserved[64];
++ } s;
++ union {
++ struct __snd_pcm_mmap_control control;
++ unsigned char reserved[64];
++ } c;
++};
++
++#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
++typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
++typedef char __pad_after_uframe[0];
++#endif
++
++#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
++typedef char __pad_before_uframe[0];
++typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
++#endif
++
++struct __snd_pcm_mmap_status64 {
++ __s32 state; /* RO: state - SNDRV_PCM_STATE_XXXX */
++ __u32 pad1; /* Needed for 64 bit alignment */
++ __pad_before_uframe __pad1;
++ snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
++ __pad_after_uframe __pad2;
++ struct __snd_timespec64 tstamp; /* Timestamp */
++ __s32 suspended_state; /* RO: suspended stream state */
++ __u32 pad3; /* Needed for 64 bit alignment */
++ struct __snd_timespec64 audio_tstamp; /* sample counter or wall clock */
++};
++
++struct __snd_pcm_mmap_control64 {
++ __pad_before_uframe __pad1;
++ snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
++ __pad_before_uframe __pad2;
++
++ __pad_before_uframe __pad3;
++ snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
++ __pad_after_uframe __pad4;
++};
++
++struct __snd_pcm_sync_ptr64 {
++ __u32 flags;
++ __u32 pad1;
++ union {
++ struct __snd_pcm_mmap_status64 status;
+ unsigned char reserved[64];
+ } s;
+ union {
+- struct snd_pcm_mmap_control control;
++ struct __snd_pcm_mmap_control64 control;
+ unsigned char reserved[64];
+ } c;
+ };
+@@ -590,6 +678,8 @@ enum {
+ #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status)
+ #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t)
+ #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22)
++#define __SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct __snd_pcm_sync_ptr)
++#define __SNDRV_PCM_IOCTL_SYNC_PTR64 _IOWR('A', 0x23, struct __snd_pcm_sync_ptr64)
+ #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
+ #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status)
+ #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info)
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p7.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p7.patch
new file mode 100644
index 0000000..0cea471
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p7.patch
@@ -0,0 +1,68 @@
+From 1cfaef9617033f38eba9cc725809ed32bcdb3dc5 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 13 Nov 2019 17:49:14 +0100
+Subject: [PATCH] ALSA: bump uapi version numbers
+
+Change SNDRV_PCM_VERSION, SNDRV_RAWMIDI_VERSION and SNDRV_TIMER_VERSION
+to indicate the addition of the time64 version of the mmap interface and
+these ioctl commands:
+
+SNDRV_PCM_IOCTL_SYNC
+SNDRV_RAWMIDI_IOCTL_STATUS
+SNDRV_PCM_IOCTL_STATUS
+SNDRV_PCM_IOCTL_STATUS_EXT
+SNDRV_TIMER_IOCTL_TREAD
+SNDRV_TIMER_IOCTL_STATUS
+
+32-bit applications built with 64-bit time_t require both the headers
+and the running kernel to support at least the new API version. When
+built with earlier kernel headers, some of these may not work
+correctly, so applications are encouraged to fail compilation like
+
+ #if SNDRV_PCM_VERSION < SNDRV_PROTOCOL_VERSION(2, 0, 15)
+ extern int __fail_build_for_time_64[sizeof(long) - sizeof(time_t)];
+ #endif
+
+or provide their own updated copy of the header file.
+At runtime, the interface is unchanged for 32-bit time_t, but new
+kernels are required to work with user compiled with 64-bit time_t.
+
+A runtime check can be used to detect old kernel versions and
+warn about those.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+---
+ include/uapi/sound/asound.h | 6 +++---
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -156,7 +156,7 @@ struct snd_hwdep_dsp_image {
+ * *
+ *****************************************************************************/
+
+-#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 14)
++#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15)
+
+ typedef unsigned long snd_pcm_uframes_t;
+ typedef signed long snd_pcm_sframes_t;
+@@ -710,7 +710,7 @@ enum {
+ * Raw MIDI section - /dev/snd/midi??
+ */
+
+-#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0)
++#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1)
+
+ enum {
+ SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
+@@ -766,7 +766,7 @@ struct snd_rawmidi_status {
+ * Timer section - /dev/snd/timer
+ */
+
+-#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
++#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7)
+
+ enum {
+ SNDRV_TIMER_CLASS_NONE = -1,
+--
+2.26.2
+
diff --git a/5.4/01_all_backport-5.6-alsa-timespec64-p8.patch b/5.4/01_all_backport-5.6-alsa-timespec64-p8.patch
new file mode 100644
index 0000000..d9a9530
--- /dev/null
+++ b/5.4/01_all_backport-5.6-alsa-timespec64-p8.patch
@@ -0,0 +1,53 @@
+From 7fd7d6c5045113350fcf78e865ced8a80dbde9fb Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Fri, 20 Dec 2019 16:34:14 +0100
+Subject: [PATCH] ALSA: uapi: Fix typos and header inclusion in asound.h
+
+The recent changes in uapi/asoundlib.h caused some build errors in
+alsa-lib side because of a typo and the new included files.
+Basically asound.h is supposed to be usable also on non-Linux systems,
+so we've tried to avoid the Linux-specific include files.
+
+This patch is an attempt to recover from those changes.
+
+Fixes: 3ddee7f88aaf ("ALSA: Avoid using timespec for struct snd_pcm_status")
+Fixes: 80fe7430c708 ("ALSA: add new 32-bit layout for snd_pcm_mmap_status/control")
+Link: https://lore.kernel.org/r/20191220153415.2740-5-tiwai@suse.de
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+---
+ include/uapi/sound/asound.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/include/uapi/sound/asound.h
++++ b/include/uapi/sound/asound.h
+@@ -26,7 +26,9 @@
+
+ #if defined(__KERNEL__) || defined(__linux__)
+ #include <linux/types.h>
++#include <asm/byteorder.h>
+ #else
++#include <endian.h>
+ #include <sys/ioctl.h>
+ #endif
+
+@@ -35,8 +37,6 @@
+ #include <time.h>
+ #endif
+
+-#include <asm/byteorder.h>
+-
+ /*
+ * protocol version
+ */
+@@ -471,7 +471,7 @@ enum {
+
+ #ifndef __KERNEL__
+ /* explicit padding avoids incompatibility between i386 and x86-64 */
+-typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] __time_pad;
++typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)]; } __time_pad;
+
+ struct snd_pcm_status {
+ snd_pcm_state_t state; /* stream state */
+--
+2.26.2
+