All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Fix year 2038 issue for sound subsystem
@ 2018-04-24 12:06 Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
                   ` (9 more replies)
  0 siblings, 10 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

Since many structures will use timespec type variables to record time stamp
in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
tries to introduce new structures removing timespec type to compatible native
mode and compat mode.

Moreover this patchset also converts the internal structrures to use timespec64
type and related APIs.

Arnd Bergmann (2):
  ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
  ALSA: add new 32-bit layout for snd_pcm_mmap_status/control

Baolin Wang (6):
  ALSA: Replace timespec with timespec64
  ALSA: Avoid using timespec for struct snd_timer_status
  ALSA: Avoid using timespec for struct snd_ctl_elem_value
  ALSA: Avoid using timespec for struct snd_pcm_status
  ALSA: Avoid using timespec for struct snd_rawmidi_status
  ALSA: Avoid using timespec for struct snd_timer_tread

 include/sound/pcm.h               |   74 +++++++++--
 include/sound/timer.h             |    4 +-
 include/uapi/sound/asound.h       |  114 ++++++++++++++--
 sound/core/pcm.c                  |   12 +-
 sound/core/pcm_compat.c           |  261 ++++++++-----------------------------
 sound/core/pcm_lib.c              |   38 ++++--
 sound/core/pcm_native.c           |  224 +++++++++++++++++++++++++++----
 sound/core/rawmidi.c              |  131 +++++++++++++++----
 sound/core/rawmidi_compat.c       |   87 ++++---------
 sound/core/timer.c                |  224 +++++++++++++++++++++++--------
 sound/core/timer_compat.c         |   59 +--------
 sound/pci/hda/hda_controller.c    |   10 +-
 sound/soc/intel/skylake/skl-pcm.c |    4 +-
 13 files changed, 766 insertions(+), 476 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 1/8] ALSA: Replace timespec with timespec64
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
@ 2018-04-24 12:06   ` Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

Since timespec is not year 2038 safe on 32bit system, and we need to
convert all timespec variables to timespec64 type for sound subsystem.

This patch is used to do preparation for following patches, that will
convert all structures defined in uapi/sound/asound.h to use 64-bit
time_t.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/sound/pcm.h               |   18 +++++++++---------
 include/sound/timer.h             |    4 ++--
 sound/core/pcm_lib.c              |   33 ++++++++++++++++++++-------------
 sound/core/pcm_native.c           |   12 ++++++++----
 sound/core/timer.c                |   28 ++++++++++++++--------------
 sound/pci/hda/hda_controller.c    |   10 +++++-----
 sound/soc/intel/skylake/skl-pcm.c |    4 ++--
 7 files changed, 60 insertions(+), 49 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index e054c58..973d674 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -75,7 +75,7 @@ struct snd_pcm_ops {
 	int (*trigger)(struct snd_pcm_substream *substream, int cmd);
 	snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
 	int (*get_time_info)(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
 	int (*fill_silence)(struct snd_pcm_substream *substream, int channel,
@@ -351,7 +351,7 @@ static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy
 struct snd_pcm_runtime {
 	/* -- Status -- */
 	struct snd_pcm_substream *trigger_master;
-	struct timespec trigger_tstamp;	/* trigger timestamp */
+	struct timespec64 trigger_tstamp;	/* trigger timestamp */
 	bool trigger_tstamp_latched;     /* trigger timestamp latched in low-level driver/hardware */
 	int overrange;
 	snd_pcm_uframes_t avail_max;
@@ -427,7 +427,7 @@ struct snd_pcm_runtime {
 	/* -- audio timestamp config -- */
 	struct snd_pcm_audio_tstamp_config audio_tstamp_config;
 	struct snd_pcm_audio_tstamp_report audio_tstamp_report;
-	struct timespec driver_tstamp;
+	struct timespec64 driver_tstamp;
 
 #if IS_ENABLED(CONFIG_SND_PCM_OSS)
 	/* -- OSS things -- */
@@ -1175,22 +1175,22 @@ static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substrea
 }
 
 /**
- * snd_pcm_gettime - Fill the timespec depending on the timestamp mode
+ * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
  * @runtime: PCM runtime instance
- * @tv: timespec to fill
+ * @tv: timespec64 to fill
  */
 static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
-				   struct timespec *tv)
+				   struct timespec64 *tv)
 {
 	switch (runtime->tstamp_type) {
 	case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC:
-		ktime_get_ts(tv);
+		ktime_get_ts64(tv);
 		break;
 	case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
-		getrawmonotonic(tv);
+		getrawmonotonic64(tv);
 		break;
 	default:
-		getnstimeofday(tv);
+		ktime_get_real_ts64(tv);
 		break;
 	}
 }
diff --git a/include/sound/timer.h b/include/sound/timer.h
index 7ae226a..91b9baa 100644
--- a/include/sound/timer.h
+++ b/include/sound/timer.h
@@ -104,7 +104,7 @@ struct snd_timer_instance {
 			  unsigned long ticks, unsigned long resolution);
 	void (*ccallback) (struct snd_timer_instance * timeri,
 			   int event,
-			   struct timespec * tstamp,
+			   struct timespec64 * tstamp,
 			   unsigned long resolution);
 	void (*disconnect)(struct snd_timer_instance *timeri);
 	void *callback_data;
@@ -128,7 +128,7 @@ struct snd_timer_instance {
  */
 
 int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer);
-void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp);
+void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp);
 int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer);
 int snd_timer_global_free(struct snd_timer *timer);
 int snd_timer_global_register(struct snd_timer *timer);
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index f4a1950..213f0e6 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -158,8 +158,12 @@ static void xrun(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
 	trace_xrun(substream);
-	if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE)
-		snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
+	if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
+		struct timespec64 tstamp;
+
+		snd_pcm_gettime(runtime, &tstamp);
+		runtime->status->tstamp = timespec64_to_timespec(tstamp);
+	}
 	snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
 	if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {
 		char name[16];
@@ -217,12 +221,12 @@ int snd_pcm_update_state(struct snd_pcm_substream *substream,
 }
 
 static void update_audio_tstamp(struct snd_pcm_substream *substream,
-				struct timespec *curr_tstamp,
-				struct timespec *audio_tstamp)
+				struct timespec64 *curr_tstamp,
+				struct timespec64 *audio_tstamp)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	u64 audio_frames, audio_nsecs;
-	struct timespec driver_tstamp;
+	struct timespec64 driver_tstamp;
 
 	if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE)
 		return;
@@ -246,18 +250,21 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
 		}
 		audio_nsecs = div_u64(audio_frames * 1000000000LL,
 				runtime->rate);
-		*audio_tstamp = ns_to_timespec(audio_nsecs);
+		*audio_tstamp = ns_to_timespec64(audio_nsecs);
 	}
+
 	if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
-		runtime->status->audio_tstamp = *audio_tstamp;
-		runtime->status->tstamp = *curr_tstamp;
+		runtime->status->audio_tstamp =
+			timespec64_to_timespec(*audio_tstamp);
+		runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp);
 	}
 
+
 	/*
 	 * re-take a driver timestamp to let apps detect if the reference tstamp
 	 * read by low-level hardware was provided with a delay
 	 */
-	snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp);
+	snd_pcm_gettime(substream->runtime, &driver_tstamp);
 	runtime->driver_tstamp = driver_tstamp;
 }
 
@@ -270,8 +277,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 	snd_pcm_sframes_t hdelta, delta;
 	unsigned long jdelta;
 	unsigned long curr_jiffies;
-	struct timespec curr_tstamp;
-	struct timespec audio_tstamp;
+	struct timespec64 curr_tstamp;
+	struct timespec64 audio_tstamp;
 	int crossed_boundary = 0;
 
 	old_hw_ptr = runtime->status->hw_ptr;
@@ -294,9 +301,9 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 
 			/* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */
 			if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)
-				snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
+				snd_pcm_gettime(runtime, &curr_tstamp);
 		} else
-			snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
+			snd_pcm_gettime(runtime, &curr_tstamp);
 	}
 
 	if (pos == SNDRV_PCM_POS_XRUN) {
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 35ffcce..c57dd4b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -884,12 +884,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 	status->suspended_state = runtime->status->suspended_state;
 	if (status->state == SNDRV_PCM_STATE_OPEN)
 		goto _end;
-	status->trigger_tstamp = runtime->trigger_tstamp;
+	status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp);
 	if (snd_pcm_running(substream)) {
 		snd_pcm_update_hw_ptr(substream);
 		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
 			status->tstamp = runtime->status->tstamp;
-			status->driver_tstamp = runtime->driver_tstamp;
+			status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp);
 			status->audio_tstamp =
 				runtime->status->audio_tstamp;
 			if (runtime->audio_tstamp_report.valid == 1)
@@ -902,8 +902,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 		}
 	} else {
 		/* get tstamp only in fallback mode and only if enabled */
-		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE)
-			snd_pcm_gettime(runtime, &status->tstamp);
+		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
+			struct timespec64 tstamp;
+
+			snd_pcm_gettime(runtime, &tstamp);
+			status->tstamp = timespec64_to_timespec(tstamp);
+		}
 	}
  _tstamp_end:
 	status->appl_ptr = runtime->control->appl_ptr;
diff --git a/sound/core/timer.c b/sound/core/timer.c
index dc87728..a77b461 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -73,7 +73,7 @@ struct snd_timer_user {
 	spinlock_t qlock;
 	unsigned long last_resolution;
 	unsigned int filter;
-	struct timespec tstamp;		/* trigger tstamp */
+	struct timespec64 tstamp;		/* trigger tstamp */
 	wait_queue_head_t qchange_sleep;
 	struct fasync_struct *fasync;
 	struct mutex ioctl_lock;
@@ -448,12 +448,12 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
 	struct snd_timer *timer;
 	unsigned long resolution = 0;
 	struct snd_timer_instance *ts;
-	struct timespec tstamp;
+	struct timespec64 tstamp;
 
 	if (timer_tstamp_monotonic)
-		ktime_get_ts(&tstamp);
+		ktime_get_ts64(&tstamp);
 	else
-		getnstimeofday(&tstamp);
+		ktime_get_real_ts64(&tstamp);
 	if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_START ||
 		       event > SNDRV_TIMER_EVENT_PAUSE))
 		return;
@@ -998,7 +998,7 @@ static int snd_timer_dev_disconnect(struct snd_device *device)
 	return 0;
 }
 
-void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp)
+void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp)
 {
 	unsigned long flags;
 	unsigned long resolution = 0;
@@ -1295,7 +1295,7 @@ static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu,
 
 static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 				     int event,
-				     struct timespec *tstamp,
+				     struct timespec64 *tstamp,
 				     unsigned long resolution)
 {
 	struct snd_timer_user *tu = timeri->callback_data;
@@ -1309,7 +1309,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 		return;
 	memset(&r1, 0, sizeof(r1));
 	r1.event = event;
-	r1.tstamp = *tstamp;
+	r1.tstamp = timespec64_to_timespec(*tstamp);
 	r1.val = resolution;
 	spin_lock_irqsave(&tu->qlock, flags);
 	snd_timer_user_append_to_tqueue(tu, &r1);
@@ -1332,7 +1332,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 {
 	struct snd_timer_user *tu = timeri->callback_data;
 	struct snd_timer_tread *r, r1;
-	struct timespec tstamp;
+	struct timespec64 tstamp;
 	int prev, append = 0;
 
 	memset(&r1, 0, sizeof(r1));
@@ -1345,14 +1345,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 	}
 	if (tu->last_resolution != resolution || ticks > 0) {
 		if (timer_tstamp_monotonic)
-			ktime_get_ts(&tstamp);
+			ktime_get_ts64(&tstamp);
 		else
-			getnstimeofday(&tstamp);
+			ktime_get_real_ts64(&tstamp);
 	}
 	if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) &&
 	    tu->last_resolution != resolution) {
 		r1.event = SNDRV_TIMER_EVENT_RESOLUTION;
-		r1.tstamp = tstamp;
+		r1.tstamp = timespec64_to_timespec(tstamp);
 		r1.val = resolution;
 		snd_timer_user_append_to_tqueue(tu, &r1);
 		tu->last_resolution = resolution;
@@ -1366,14 +1366,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 		prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1;
 		r = &tu->tqueue[prev];
 		if (r->event == SNDRV_TIMER_EVENT_TICK) {
-			r->tstamp = tstamp;
+			r->tstamp = timespec64_to_timespec(tstamp);
 			r->val += ticks;
 			append++;
 			goto __wake;
 		}
 	}
 	r1.event = SNDRV_TIMER_EVENT_TICK;
-	r1.tstamp = tstamp;
+	r1.tstamp = timespec64_to_timespec(tstamp);
 	r1.val = ticks;
 	snd_timer_user_append_to_tqueue(tu, &r1);
 	append++;
@@ -1852,7 +1852,7 @@ static int snd_timer_user_status(struct file *file,
 	if (!tu->timeri)
 		return -EBADFD;
 	memset(&status, 0, sizeof(status));
-	status.tstamp = tu->tstamp;
+	status.tstamp = timespec64_to_timespec(tu->tstamp);
 	status.resolution = snd_timer_resolution(tu->timeri);
 	status.lost = tu->timeri->lost;
 	status.overrun = tu->overrun;
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index d1eb148..c3e4516 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -502,7 +502,7 @@ static inline bool is_link_time_supported(struct snd_pcm_runtime *runtime,
 }
 
 static int azx_get_time_info(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
 {
@@ -522,7 +522,7 @@ static int azx_get_time_info(struct snd_pcm_substream *substream,
 		if (audio_tstamp_config->report_delay)
 			nsec = azx_adjust_codec_delay(substream, nsec);
 
-		*audio_ts = ns_to_timespec(nsec);
+		*audio_ts = ns_to_timespec64(nsec);
 
 		audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
 		audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */
@@ -539,16 +539,16 @@ static int azx_get_time_info(struct snd_pcm_substream *substream,
 			return -EINVAL;
 
 		case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
-			*system_ts = ktime_to_timespec(xtstamp.sys_monoraw);
+			*system_ts = ktime_to_timespec64(xtstamp.sys_monoraw);
 			break;
 
 		default:
-			*system_ts = ktime_to_timespec(xtstamp.sys_realtime);
+			*system_ts = ktime_to_timespec64(xtstamp.sys_realtime);
 			break;
 
 		}
 
-		*audio_ts = ktime_to_timespec(xtstamp.device);
+		*audio_ts = ktime_to_timespec64(xtstamp.device);
 
 		audio_tstamp_report->actual_type =
 			SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED;
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 15cb8ac..a69b56f 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1163,7 +1163,7 @@ static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
 }
 
 static int skl_get_time_info(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
 {
@@ -1181,7 +1181,7 @@ static int skl_get_time_info(struct snd_pcm_substream *substream,
 		if (audio_tstamp_config->report_delay)
 			nsec = skl_adjust_codec_delay(substream, nsec);
 
-		*audio_ts = ns_to_timespec(nsec);
+		*audio_ts = ns_to_timespec64(nsec);
 
 		audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
 		audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 1/8] ALSA: Replace timespec with timespec64
@ 2018-04-24 12:06   ` Baolin Wang
  0 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: fabf, arvind.yadav.cs, linux-kernel, alsa-devel, baolin.wang,
	vinod.koul, hardik.t.shah, guneshwor.o.singh, lgirdwood, elfring,
	gudishax.kranthikumar, broonie, bhumirks, naveen.m, jeeja.kp,
	o-takashi, subhransu.s.prusty, mingo, dan.carpenter

Since timespec is not year 2038 safe on 32bit system, and we need to
convert all timespec variables to timespec64 type for sound subsystem.

This patch is used to do preparation for following patches, that will
convert all structures defined in uapi/sound/asound.h to use 64-bit
time_t.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/sound/pcm.h               |   18 +++++++++---------
 include/sound/timer.h             |    4 ++--
 sound/core/pcm_lib.c              |   33 ++++++++++++++++++++-------------
 sound/core/pcm_native.c           |   12 ++++++++----
 sound/core/timer.c                |   28 ++++++++++++++--------------
 sound/pci/hda/hda_controller.c    |   10 +++++-----
 sound/soc/intel/skylake/skl-pcm.c |    4 ++--
 7 files changed, 60 insertions(+), 49 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index e054c58..973d674 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -75,7 +75,7 @@ struct snd_pcm_ops {
 	int (*trigger)(struct snd_pcm_substream *substream, int cmd);
 	snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
 	int (*get_time_info)(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
 	int (*fill_silence)(struct snd_pcm_substream *substream, int channel,
@@ -351,7 +351,7 @@ static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy
 struct snd_pcm_runtime {
 	/* -- Status -- */
 	struct snd_pcm_substream *trigger_master;
-	struct timespec trigger_tstamp;	/* trigger timestamp */
+	struct timespec64 trigger_tstamp;	/* trigger timestamp */
 	bool trigger_tstamp_latched;     /* trigger timestamp latched in low-level driver/hardware */
 	int overrange;
 	snd_pcm_uframes_t avail_max;
@@ -427,7 +427,7 @@ struct snd_pcm_runtime {
 	/* -- audio timestamp config -- */
 	struct snd_pcm_audio_tstamp_config audio_tstamp_config;
 	struct snd_pcm_audio_tstamp_report audio_tstamp_report;
-	struct timespec driver_tstamp;
+	struct timespec64 driver_tstamp;
 
 #if IS_ENABLED(CONFIG_SND_PCM_OSS)
 	/* -- OSS things -- */
@@ -1175,22 +1175,22 @@ static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substrea
 }
 
 /**
- * snd_pcm_gettime - Fill the timespec depending on the timestamp mode
+ * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
  * @runtime: PCM runtime instance
- * @tv: timespec to fill
+ * @tv: timespec64 to fill
  */
 static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
-				   struct timespec *tv)
+				   struct timespec64 *tv)
 {
 	switch (runtime->tstamp_type) {
 	case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC:
-		ktime_get_ts(tv);
+		ktime_get_ts64(tv);
 		break;
 	case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
-		getrawmonotonic(tv);
+		getrawmonotonic64(tv);
 		break;
 	default:
-		getnstimeofday(tv);
+		ktime_get_real_ts64(tv);
 		break;
 	}
 }
diff --git a/include/sound/timer.h b/include/sound/timer.h
index 7ae226a..91b9baa 100644
--- a/include/sound/timer.h
+++ b/include/sound/timer.h
@@ -104,7 +104,7 @@ struct snd_timer_instance {
 			  unsigned long ticks, unsigned long resolution);
 	void (*ccallback) (struct snd_timer_instance * timeri,
 			   int event,
-			   struct timespec * tstamp,
+			   struct timespec64 * tstamp,
 			   unsigned long resolution);
 	void (*disconnect)(struct snd_timer_instance *timeri);
 	void *callback_data;
@@ -128,7 +128,7 @@ struct snd_timer_instance {
  */
 
 int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer);
-void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp);
+void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp);
 int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer);
 int snd_timer_global_free(struct snd_timer *timer);
 int snd_timer_global_register(struct snd_timer *timer);
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index f4a1950..213f0e6 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -158,8 +158,12 @@ static void xrun(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
 	trace_xrun(substream);
-	if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE)
-		snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
+	if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
+		struct timespec64 tstamp;
+
+		snd_pcm_gettime(runtime, &tstamp);
+		runtime->status->tstamp = timespec64_to_timespec(tstamp);
+	}
 	snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
 	if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {
 		char name[16];
@@ -217,12 +221,12 @@ int snd_pcm_update_state(struct snd_pcm_substream *substream,
 }
 
 static void update_audio_tstamp(struct snd_pcm_substream *substream,
-				struct timespec *curr_tstamp,
-				struct timespec *audio_tstamp)
+				struct timespec64 *curr_tstamp,
+				struct timespec64 *audio_tstamp)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	u64 audio_frames, audio_nsecs;
-	struct timespec driver_tstamp;
+	struct timespec64 driver_tstamp;
 
 	if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE)
 		return;
@@ -246,18 +250,21 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
 		}
 		audio_nsecs = div_u64(audio_frames * 1000000000LL,
 				runtime->rate);
-		*audio_tstamp = ns_to_timespec(audio_nsecs);
+		*audio_tstamp = ns_to_timespec64(audio_nsecs);
 	}
+
 	if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
-		runtime->status->audio_tstamp = *audio_tstamp;
-		runtime->status->tstamp = *curr_tstamp;
+		runtime->status->audio_tstamp =
+			timespec64_to_timespec(*audio_tstamp);
+		runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp);
 	}
 
+
 	/*
 	 * re-take a driver timestamp to let apps detect if the reference tstamp
 	 * read by low-level hardware was provided with a delay
 	 */
-	snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp);
+	snd_pcm_gettime(substream->runtime, &driver_tstamp);
 	runtime->driver_tstamp = driver_tstamp;
 }
 
@@ -270,8 +277,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 	snd_pcm_sframes_t hdelta, delta;
 	unsigned long jdelta;
 	unsigned long curr_jiffies;
-	struct timespec curr_tstamp;
-	struct timespec audio_tstamp;
+	struct timespec64 curr_tstamp;
+	struct timespec64 audio_tstamp;
 	int crossed_boundary = 0;
 
 	old_hw_ptr = runtime->status->hw_ptr;
@@ -294,9 +301,9 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 
 			/* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */
 			if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)
-				snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
+				snd_pcm_gettime(runtime, &curr_tstamp);
 		} else
-			snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
+			snd_pcm_gettime(runtime, &curr_tstamp);
 	}
 
 	if (pos == SNDRV_PCM_POS_XRUN) {
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 35ffcce..c57dd4b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -884,12 +884,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 	status->suspended_state = runtime->status->suspended_state;
 	if (status->state == SNDRV_PCM_STATE_OPEN)
 		goto _end;
-	status->trigger_tstamp = runtime->trigger_tstamp;
+	status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp);
 	if (snd_pcm_running(substream)) {
 		snd_pcm_update_hw_ptr(substream);
 		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
 			status->tstamp = runtime->status->tstamp;
-			status->driver_tstamp = runtime->driver_tstamp;
+			status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp);
 			status->audio_tstamp =
 				runtime->status->audio_tstamp;
 			if (runtime->audio_tstamp_report.valid == 1)
@@ -902,8 +902,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 		}
 	} else {
 		/* get tstamp only in fallback mode and only if enabled */
-		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE)
-			snd_pcm_gettime(runtime, &status->tstamp);
+		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
+			struct timespec64 tstamp;
+
+			snd_pcm_gettime(runtime, &tstamp);
+			status->tstamp = timespec64_to_timespec(tstamp);
+		}
 	}
  _tstamp_end:
 	status->appl_ptr = runtime->control->appl_ptr;
diff --git a/sound/core/timer.c b/sound/core/timer.c
index dc87728..a77b461 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -73,7 +73,7 @@ struct snd_timer_user {
 	spinlock_t qlock;
 	unsigned long last_resolution;
 	unsigned int filter;
-	struct timespec tstamp;		/* trigger tstamp */
+	struct timespec64 tstamp;		/* trigger tstamp */
 	wait_queue_head_t qchange_sleep;
 	struct fasync_struct *fasync;
 	struct mutex ioctl_lock;
@@ -448,12 +448,12 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
 	struct snd_timer *timer;
 	unsigned long resolution = 0;
 	struct snd_timer_instance *ts;
-	struct timespec tstamp;
+	struct timespec64 tstamp;
 
 	if (timer_tstamp_monotonic)
-		ktime_get_ts(&tstamp);
+		ktime_get_ts64(&tstamp);
 	else
-		getnstimeofday(&tstamp);
+		ktime_get_real_ts64(&tstamp);
 	if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_START ||
 		       event > SNDRV_TIMER_EVENT_PAUSE))
 		return;
@@ -998,7 +998,7 @@ static int snd_timer_dev_disconnect(struct snd_device *device)
 	return 0;
 }
 
-void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp)
+void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp)
 {
 	unsigned long flags;
 	unsigned long resolution = 0;
@@ -1295,7 +1295,7 @@ static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu,
 
 static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 				     int event,
-				     struct timespec *tstamp,
+				     struct timespec64 *tstamp,
 				     unsigned long resolution)
 {
 	struct snd_timer_user *tu = timeri->callback_data;
@@ -1309,7 +1309,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 		return;
 	memset(&r1, 0, sizeof(r1));
 	r1.event = event;
-	r1.tstamp = *tstamp;
+	r1.tstamp = timespec64_to_timespec(*tstamp);
 	r1.val = resolution;
 	spin_lock_irqsave(&tu->qlock, flags);
 	snd_timer_user_append_to_tqueue(tu, &r1);
@@ -1332,7 +1332,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 {
 	struct snd_timer_user *tu = timeri->callback_data;
 	struct snd_timer_tread *r, r1;
-	struct timespec tstamp;
+	struct timespec64 tstamp;
 	int prev, append = 0;
 
 	memset(&r1, 0, sizeof(r1));
@@ -1345,14 +1345,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 	}
 	if (tu->last_resolution != resolution || ticks > 0) {
 		if (timer_tstamp_monotonic)
-			ktime_get_ts(&tstamp);
+			ktime_get_ts64(&tstamp);
 		else
-			getnstimeofday(&tstamp);
+			ktime_get_real_ts64(&tstamp);
 	}
 	if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) &&
 	    tu->last_resolution != resolution) {
 		r1.event = SNDRV_TIMER_EVENT_RESOLUTION;
-		r1.tstamp = tstamp;
+		r1.tstamp = timespec64_to_timespec(tstamp);
 		r1.val = resolution;
 		snd_timer_user_append_to_tqueue(tu, &r1);
 		tu->last_resolution = resolution;
@@ -1366,14 +1366,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 		prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1;
 		r = &tu->tqueue[prev];
 		if (r->event == SNDRV_TIMER_EVENT_TICK) {
-			r->tstamp = tstamp;
+			r->tstamp = timespec64_to_timespec(tstamp);
 			r->val += ticks;
 			append++;
 			goto __wake;
 		}
 	}
 	r1.event = SNDRV_TIMER_EVENT_TICK;
-	r1.tstamp = tstamp;
+	r1.tstamp = timespec64_to_timespec(tstamp);
 	r1.val = ticks;
 	snd_timer_user_append_to_tqueue(tu, &r1);
 	append++;
@@ -1852,7 +1852,7 @@ static int snd_timer_user_status(struct file *file,
 	if (!tu->timeri)
 		return -EBADFD;
 	memset(&status, 0, sizeof(status));
-	status.tstamp = tu->tstamp;
+	status.tstamp = timespec64_to_timespec(tu->tstamp);
 	status.resolution = snd_timer_resolution(tu->timeri);
 	status.lost = tu->timeri->lost;
 	status.overrun = tu->overrun;
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index d1eb148..c3e4516 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -502,7 +502,7 @@ static inline bool is_link_time_supported(struct snd_pcm_runtime *runtime,
 }
 
 static int azx_get_time_info(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
 {
@@ -522,7 +522,7 @@ static int azx_get_time_info(struct snd_pcm_substream *substream,
 		if (audio_tstamp_config->report_delay)
 			nsec = azx_adjust_codec_delay(substream, nsec);
 
-		*audio_ts = ns_to_timespec(nsec);
+		*audio_ts = ns_to_timespec64(nsec);
 
 		audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
 		audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */
@@ -539,16 +539,16 @@ static int azx_get_time_info(struct snd_pcm_substream *substream,
 			return -EINVAL;
 
 		case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
-			*system_ts = ktime_to_timespec(xtstamp.sys_monoraw);
+			*system_ts = ktime_to_timespec64(xtstamp.sys_monoraw);
 			break;
 
 		default:
-			*system_ts = ktime_to_timespec(xtstamp.sys_realtime);
+			*system_ts = ktime_to_timespec64(xtstamp.sys_realtime);
 			break;
 
 		}
 
-		*audio_ts = ktime_to_timespec(xtstamp.device);
+		*audio_ts = ktime_to_timespec64(xtstamp.device);
 
 		audio_tstamp_report->actual_type =
 			SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED;
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 15cb8ac..a69b56f 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1163,7 +1163,7 @@ static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
 }
 
 static int skl_get_time_info(struct snd_pcm_substream *substream,
-			struct timespec *system_ts, struct timespec *audio_ts,
+			struct timespec64 *system_ts, struct timespec64 *audio_ts,
 			struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
 			struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
 {
@@ -1181,7 +1181,7 @@ static int skl_get_time_info(struct snd_pcm_substream *substream,
 		if (audio_tstamp_config->report_delay)
 			nsec = skl_adjust_codec_delay(substream, nsec);
 
-		*audio_ts = ns_to_timespec(nsec);
+		*audio_ts = ns_to_timespec64(nsec);
 
 		audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
 		audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/8] ALSA: Avoid using timespec for struct snd_timer_status
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
@ 2018-04-24 12:06   ` Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

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.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 sound/core/timer.c        |   62 ++++++++++++++++++++++++++++++++++++++++-----
 sound/core/timer_compat.c |   57 +++++------------------------------------
 2 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/sound/core/timer.c b/sound/core/timer.c
index a77b461..c9d7ddb 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -79,6 +79,30 @@ struct snd_timer_user {
 	struct mutex ioctl_lock;
 };
 
+struct snd_timer_status32 {
+	s32 tstamp_sec;			/* Timestamp - last update */
+	s32 tstamp_nsec;
+	unsigned int resolution;	/* current period resolution in ns */
+	unsigned int lost;		/* counter of master tick lost */
+	unsigned int overrun;		/* count of read queue overruns */
+	unsigned int queue;		/* used queue size */
+	unsigned char reserved[64];	/* reserved */
+};
+
+#define SNDRV_TIMER_IOCTL_STATUS32	_IOR('T', 0x14, struct snd_timer_status32)
+
+struct snd_timer_status64 {
+	s64 tstamp_sec;			/* Timestamp - last update */
+	s64 tstamp_nsec;
+	unsigned int resolution;	/* current period resolution in ns */
+	unsigned int lost;		/* counter of master tick lost */
+	unsigned int overrun;		/* count of read queue overruns */
+	unsigned int queue;		/* used queue size */
+	unsigned char reserved[64];	/* reserved */
+};
+
+#define SNDRV_TIMER_IOCTL_STATUS64	_IOR('T', 0x14, struct snd_timer_status64)
+
 /* list of timers */
 static LIST_HEAD(snd_timer_list);
 
@@ -1842,17 +1866,41 @@ static int snd_timer_user_params(struct file *file,
 	return err;
 }
 
-static int snd_timer_user_status(struct file *file,
-				 struct snd_timer_status __user *_status)
+static int snd_timer_user_status32(struct file *file,
+				   struct snd_timer_status32 __user *_status)
+ {
+	struct snd_timer_user *tu;
+	struct snd_timer_status32 status;
+
+	tu = file->private_data;
+	if (!tu->timeri)
+		return -EBADFD;
+	memset(&status, 0, sizeof(status));
+	status.tstamp_sec = tu->tstamp.tv_sec;
+	status.tstamp_nsec = tu->tstamp.tv_nsec;
+	status.resolution = snd_timer_resolution(tu->timeri);
+	status.lost = tu->timeri->lost;
+	status.overrun = tu->overrun;
+	spin_lock_irq(&tu->qlock);
+	status.queue = tu->qused;
+	spin_unlock_irq(&tu->qlock);
+	if (copy_to_user(_status, &status, sizeof(status)))
+		return -EFAULT;
+	return 0;
+}
+
+static int snd_timer_user_status64(struct file *file,
+				   struct snd_timer_status64 __user *_status)
 {
 	struct snd_timer_user *tu;
-	struct snd_timer_status status;
+	struct snd_timer_status64 status;
 
 	tu = file->private_data;
 	if (!tu->timeri)
 		return -EBADFD;
 	memset(&status, 0, sizeof(status));
-	status.tstamp = timespec64_to_timespec(tu->tstamp);
+	status.tstamp_sec = tu->tstamp.tv_sec;
+	status.tstamp_nsec = tu->tstamp.tv_nsec;
 	status.resolution = snd_timer_resolution(tu->timeri);
 	status.lost = tu->timeri->lost;
 	status.overrun = tu->overrun;
@@ -1964,8 +2012,10 @@ static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,
 		return snd_timer_user_info(file, argp);
 	case SNDRV_TIMER_IOCTL_PARAMS:
 		return snd_timer_user_params(file, argp);
-	case SNDRV_TIMER_IOCTL_STATUS:
-		return snd_timer_user_status(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS32:
+		return snd_timer_user_status32(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS64:
+		return snd_timer_user_status64(file, argp);
 	case SNDRV_TIMER_IOCTL_START:
 	case SNDRV_TIMER_IOCTL_START_OLD:
 		return snd_timer_user_start(file);
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c
index e00f7e3..0495ede 100644
--- a/sound/core/timer_compat.c
+++ b/sound/core/timer_compat.c
@@ -83,54 +83,11 @@ static int snd_timer_user_info_compat(struct file *file,
 	return 0;
 }
 
-struct snd_timer_status32 {
-	struct compat_timespec tstamp;
-	u32 resolution;
-	u32 lost;
-	u32 overrun;
-	u32 queue;
-	unsigned char reserved[64];
-};
-
-static int snd_timer_user_status_compat(struct file *file,
-					struct snd_timer_status32 __user *_status)
-{
-	struct snd_timer_user *tu;
-	struct snd_timer_status32 status;
-	
-	tu = file->private_data;
-	if (!tu->timeri)
-		return -EBADFD;
-	memset(&status, 0, sizeof(status));
-	status.tstamp.tv_sec = tu->tstamp.tv_sec;
-	status.tstamp.tv_nsec = tu->tstamp.tv_nsec;
-	status.resolution = snd_timer_resolution(tu->timeri);
-	status.lost = tu->timeri->lost;
-	status.overrun = tu->overrun;
-	spin_lock_irq(&tu->qlock);
-	status.queue = tu->qused;
-	spin_unlock_irq(&tu->qlock);
-	if (copy_to_user(_status, &status, sizeof(status)))
-		return -EFAULT;
-	return 0;
-}
-
-#ifdef CONFIG_X86_X32
-/* X32 ABI has the same struct as x86-64 */
-#define snd_timer_user_status_x32(file, s) \
-	snd_timer_user_status(file, s)
-#endif /* CONFIG_X86_X32 */
-
-/*
- */
-
 enum {
 	SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32),
 	SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
-	SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
-#ifdef CONFIG_X86_X32
-	SNDRV_TIMER_IOCTL_STATUS_X32 = _IOW('T', 0x14, struct snd_timer_status),
-#endif /* CONFIG_X86_X32 */
+	SNDRV_TIMER_IOCTL_STATUS_COMPAT32 = _IOW('T', 0x14, struct snd_timer_status32),
+	SNDRV_TIMER_IOCTL_STATUS_COMPAT64 = _IOW('T', 0x14, struct snd_timer_status64),
 };
 
 static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
@@ -159,12 +116,10 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
 		return snd_timer_user_gparams_compat(file, argp);
 	case SNDRV_TIMER_IOCTL_INFO32:
 		return snd_timer_user_info_compat(file, argp);
-	case SNDRV_TIMER_IOCTL_STATUS32:
-		return snd_timer_user_status_compat(file, argp);
-#ifdef CONFIG_X86_X32
-	case SNDRV_TIMER_IOCTL_STATUS_X32:
-		return snd_timer_user_status_x32(file, argp);
-#endif /* CONFIG_X86_X32 */
+	case SNDRV_TIMER_IOCTL_STATUS_COMPAT32:
+		return snd_timer_user_status32(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS_COMPAT64:
+		return snd_timer_user_status64(file, argp);
 	}
 	return -ENOIOCTLCMD;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/8] ALSA: Avoid using timespec for struct snd_timer_status
@ 2018-04-24 12:06   ` Baolin Wang
  0 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: fabf, arvind.yadav.cs, linux-kernel, alsa-devel, baolin.wang,
	vinod.koul, hardik.t.shah, guneshwor.o.singh, lgirdwood, elfring,
	gudishax.kranthikumar, broonie, bhumirks, naveen.m, jeeja.kp,
	o-takashi, subhransu.s.prusty, mingo, dan.carpenter

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.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 sound/core/timer.c        |   62 ++++++++++++++++++++++++++++++++++++++++-----
 sound/core/timer_compat.c |   57 +++++------------------------------------
 2 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/sound/core/timer.c b/sound/core/timer.c
index a77b461..c9d7ddb 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -79,6 +79,30 @@ struct snd_timer_user {
 	struct mutex ioctl_lock;
 };
 
+struct snd_timer_status32 {
+	s32 tstamp_sec;			/* Timestamp - last update */
+	s32 tstamp_nsec;
+	unsigned int resolution;	/* current period resolution in ns */
+	unsigned int lost;		/* counter of master tick lost */
+	unsigned int overrun;		/* count of read queue overruns */
+	unsigned int queue;		/* used queue size */
+	unsigned char reserved[64];	/* reserved */
+};
+
+#define SNDRV_TIMER_IOCTL_STATUS32	_IOR('T', 0x14, struct snd_timer_status32)
+
+struct snd_timer_status64 {
+	s64 tstamp_sec;			/* Timestamp - last update */
+	s64 tstamp_nsec;
+	unsigned int resolution;	/* current period resolution in ns */
+	unsigned int lost;		/* counter of master tick lost */
+	unsigned int overrun;		/* count of read queue overruns */
+	unsigned int queue;		/* used queue size */
+	unsigned char reserved[64];	/* reserved */
+};
+
+#define SNDRV_TIMER_IOCTL_STATUS64	_IOR('T', 0x14, struct snd_timer_status64)
+
 /* list of timers */
 static LIST_HEAD(snd_timer_list);
 
@@ -1842,17 +1866,41 @@ static int snd_timer_user_params(struct file *file,
 	return err;
 }
 
-static int snd_timer_user_status(struct file *file,
-				 struct snd_timer_status __user *_status)
+static int snd_timer_user_status32(struct file *file,
+				   struct snd_timer_status32 __user *_status)
+ {
+	struct snd_timer_user *tu;
+	struct snd_timer_status32 status;
+
+	tu = file->private_data;
+	if (!tu->timeri)
+		return -EBADFD;
+	memset(&status, 0, sizeof(status));
+	status.tstamp_sec = tu->tstamp.tv_sec;
+	status.tstamp_nsec = tu->tstamp.tv_nsec;
+	status.resolution = snd_timer_resolution(tu->timeri);
+	status.lost = tu->timeri->lost;
+	status.overrun = tu->overrun;
+	spin_lock_irq(&tu->qlock);
+	status.queue = tu->qused;
+	spin_unlock_irq(&tu->qlock);
+	if (copy_to_user(_status, &status, sizeof(status)))
+		return -EFAULT;
+	return 0;
+}
+
+static int snd_timer_user_status64(struct file *file,
+				   struct snd_timer_status64 __user *_status)
 {
 	struct snd_timer_user *tu;
-	struct snd_timer_status status;
+	struct snd_timer_status64 status;
 
 	tu = file->private_data;
 	if (!tu->timeri)
 		return -EBADFD;
 	memset(&status, 0, sizeof(status));
-	status.tstamp = timespec64_to_timespec(tu->tstamp);
+	status.tstamp_sec = tu->tstamp.tv_sec;
+	status.tstamp_nsec = tu->tstamp.tv_nsec;
 	status.resolution = snd_timer_resolution(tu->timeri);
 	status.lost = tu->timeri->lost;
 	status.overrun = tu->overrun;
@@ -1964,8 +2012,10 @@ static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,
 		return snd_timer_user_info(file, argp);
 	case SNDRV_TIMER_IOCTL_PARAMS:
 		return snd_timer_user_params(file, argp);
-	case SNDRV_TIMER_IOCTL_STATUS:
-		return snd_timer_user_status(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS32:
+		return snd_timer_user_status32(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS64:
+		return snd_timer_user_status64(file, argp);
 	case SNDRV_TIMER_IOCTL_START:
 	case SNDRV_TIMER_IOCTL_START_OLD:
 		return snd_timer_user_start(file);
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c
index e00f7e3..0495ede 100644
--- a/sound/core/timer_compat.c
+++ b/sound/core/timer_compat.c
@@ -83,54 +83,11 @@ static int snd_timer_user_info_compat(struct file *file,
 	return 0;
 }
 
-struct snd_timer_status32 {
-	struct compat_timespec tstamp;
-	u32 resolution;
-	u32 lost;
-	u32 overrun;
-	u32 queue;
-	unsigned char reserved[64];
-};
-
-static int snd_timer_user_status_compat(struct file *file,
-					struct snd_timer_status32 __user *_status)
-{
-	struct snd_timer_user *tu;
-	struct snd_timer_status32 status;
-	
-	tu = file->private_data;
-	if (!tu->timeri)
-		return -EBADFD;
-	memset(&status, 0, sizeof(status));
-	status.tstamp.tv_sec = tu->tstamp.tv_sec;
-	status.tstamp.tv_nsec = tu->tstamp.tv_nsec;
-	status.resolution = snd_timer_resolution(tu->timeri);
-	status.lost = tu->timeri->lost;
-	status.overrun = tu->overrun;
-	spin_lock_irq(&tu->qlock);
-	status.queue = tu->qused;
-	spin_unlock_irq(&tu->qlock);
-	if (copy_to_user(_status, &status, sizeof(status)))
-		return -EFAULT;
-	return 0;
-}
-
-#ifdef CONFIG_X86_X32
-/* X32 ABI has the same struct as x86-64 */
-#define snd_timer_user_status_x32(file, s) \
-	snd_timer_user_status(file, s)
-#endif /* CONFIG_X86_X32 */
-
-/*
- */
-
 enum {
 	SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32),
 	SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
-	SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
-#ifdef CONFIG_X86_X32
-	SNDRV_TIMER_IOCTL_STATUS_X32 = _IOW('T', 0x14, struct snd_timer_status),
-#endif /* CONFIG_X86_X32 */
+	SNDRV_TIMER_IOCTL_STATUS_COMPAT32 = _IOW('T', 0x14, struct snd_timer_status32),
+	SNDRV_TIMER_IOCTL_STATUS_COMPAT64 = _IOW('T', 0x14, struct snd_timer_status64),
 };
 
 static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
@@ -159,12 +116,10 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
 		return snd_timer_user_gparams_compat(file, argp);
 	case SNDRV_TIMER_IOCTL_INFO32:
 		return snd_timer_user_info_compat(file, argp);
-	case SNDRV_TIMER_IOCTL_STATUS32:
-		return snd_timer_user_status_compat(file, argp);
-#ifdef CONFIG_X86_X32
-	case SNDRV_TIMER_IOCTL_STATUS_X32:
-		return snd_timer_user_status_x32(file, argp);
-#endif /* CONFIG_X86_X32 */
+	case SNDRV_TIMER_IOCTL_STATUS_COMPAT32:
+		return snd_timer_user_status32(file, argp);
+	case SNDRV_TIMER_IOCTL_STATUS_COMPAT64:
+		return snd_timer_user_status64(file, argp);
 	}
 	return -ENOIOCTLCMD;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 3/8] ALSA: Avoid using timespec for struct snd_ctl_elem_value
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
@ 2018-04-24 12:06 ` Baolin Wang
  2018-04-24 12:06 ` [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status Baolin Wang
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

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>
---
 include/uapi/sound/asound.h |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index ed0a120..1231f0a 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -954,8 +954,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 {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
                   ` (2 preceding siblings ...)
  2018-04-24 12:06 ` [PATCH 3/8] ALSA: Avoid using timespec for struct snd_ctl_elem_value Baolin Wang
@ 2018-04-24 12:06 ` Baolin Wang
  2018-04-26  9:20     ` kbuild test robot
  2018-04-24 12:06   ` Baolin Wang
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

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.

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>
---
 include/sound/pcm.h         |   56 +++++++++++++++-
 include/uapi/sound/asound.h |    1 +
 sound/core/pcm.c            |   12 ++--
 sound/core/pcm_compat.c     |  154 +++++++++++++++----------------------------
 sound/core/pcm_native.c     |   96 ++++++++++++++++++++++-----
 5 files changed, 193 insertions(+), 126 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 973d674..398e81d 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -58,6 +58,7 @@ struct snd_pcm_hardware {
 	size_t fifo_size;		/* fifo size in bytes */
 };
 
+struct snd_pcm_status64;
 struct snd_pcm_substream;
 
 struct snd_pcm_audio_tstamp_config; /* definitions further down */
@@ -573,8 +574,8 @@ struct snd_pcm_notify {
 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);
 int snd_pcm_info_user(struct snd_pcm_substream *substream,
 		      struct snd_pcm_info __user *info);
-int snd_pcm_status(struct snd_pcm_substream *substream,
-		   struct snd_pcm_status *status);
+int snd_pcm_status64(struct snd_pcm_substream *substream,
+		     struct snd_pcm_status64 *status);
 int snd_pcm_start(struct snd_pcm_substream *substream);
 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
 int snd_pcm_drain_done(struct snd_pcm_substream *substream);
@@ -1448,4 +1449,55 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
 #define pcm_dbg(pcm, fmt, args...) \
 	dev_dbg((pcm)->card->dev, fmt, ##args)
 
+struct snd_pcm_status64 {
+	snd_pcm_state_t state;		/* stream state */
+	u8 rsvd[sizeof(time_t) - sizeof(snd_pcm_state_t)];
+	s64 trigger_tstamp_sec;		/* time when stream was started/stopped/paused */
+	s64 trigger_tstamp_nsec;
+	s64 tstamp_sec;			/* reference timestamp */
+	s64 tstamp_nsec;
+	snd_pcm_uframes_t appl_ptr;	/* appl ptr */
+	snd_pcm_uframes_t hw_ptr;	/* hw ptr */
+	snd_pcm_sframes_t delay;	/* current delay in frames */
+	snd_pcm_uframes_t avail;	/* number of frames available */
+	snd_pcm_uframes_t avail_max;	/* max frames available on hw since last status */
+	snd_pcm_uframes_t overrange;	/* count of ADC (capture) overrange detections from last status */
+	snd_pcm_state_t suspended_state; /* suspended stream state */
+	__u32 audio_tstamp_data;	 /* needed for 64-bit alignment, used for configs/report to/from userspace */
+	s64 audio_tstamp_sec;		/* sample counter, wall clock, PHC or on-demand sync'ed */
+	s64 audio_tstamp_nsec;
+	s64 driver_tstamp_sec;		/* useful in case reference system tstamp is reported with delay */
+	s64 driver_tstamp_nsec;
+	__u32 audio_tstamp_accuracy;	/* in ns units, only valid if indicated in audio_tstamp_data */
+	unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */
+};
+
+#define SNDRV_PCM_IOCTL_STATUS64	_IOR('A', 0x20, struct snd_pcm_status64)
+#define SNDRV_PCM_IOCTL_STATUS_EXT64	_IOWR('A', 0x24, struct snd_pcm_status64)
+
+struct snd_pcm_status32 {
+	s32 state;		/* stream state */
+	s32 trigger_tstamp_sec;	/* time when stream was started/stopped/paused */
+	s32 trigger_tstamp_nsec;
+	s32 tstamp_sec;		/* reference timestamp */
+	s32 tstamp_nsec;
+	u32 appl_ptr;		/* appl ptr */
+	u32 hw_ptr;		/* hw ptr */
+	s32 delay;		/* current delay in frames */
+	u32 avail;		/* number of frames available */
+	u32 avail_max;		/* max frames available on hw since last status */
+	u32 overrange;		/* count of ADC (capture) overrange detections from last status */
+	s32 suspended_state;	/* suspended stream state */
+	u32 audio_tstamp_data;	/* needed for 64-bit alignment, used for configs/report to/from userspace */
+	s32 audio_tstamp_sec;	/* sample counter, wall clock, PHC or on-demand sync'ed */
+	s32 audio_tstamp_nsec;
+	s32 driver_tstamp_sec;	/* useful in case reference system tstamp is reported with delay */
+	s32 driver_tstamp_nsec;
+	u32 audio_tstamp_accuracy;	/* in ns units, only valid if indicated in audio_tstamp_data */
+	unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */
+};
+
+#define SNDRV_PCM_IOCTL_STATUS32	_IOR('A', 0x20, struct snd_pcm_status32)
+#define SNDRV_PCM_IOCTL_STATUS_EXT32	_IOWR('A', 0x24, struct snd_pcm_status32)
+
 #endif /* __SOUND_PCM_H */
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 1231f0a..c9afde4 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -457,6 +457,7 @@ enum {
 
 struct snd_pcm_status {
 	snd_pcm_state_t state;		/* stream state */
+	unsigned char pad1[sizeof(time_t) - sizeof(snd_pcm_state_t)]; /* 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 */
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 66ac89a..74d2580 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -456,7 +456,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
 {
 	struct snd_pcm_substream *substream = entry->private_data;
 	struct snd_pcm_runtime *runtime;
-	struct snd_pcm_status status;
+	struct snd_pcm_status64 status;
 	int err;
 
 	mutex_lock(&substream->pcm->open_mutex);
@@ -466,17 +466,17 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
 		goto unlock;
 	}
 	memset(&status, 0, sizeof(status));
-	err = snd_pcm_status(substream, &status);
+	err = snd_pcm_status64(substream, &status);
 	if (err < 0) {
 		snd_iprintf(buffer, "error %d\n", err);
 		goto unlock;
 	}
 	snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state));
 	snd_iprintf(buffer, "owner_pid   : %d\n", pid_vnr(substream->pid));
-	snd_iprintf(buffer, "trigger_time: %ld.%09ld\n",
-		status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec);
-	snd_iprintf(buffer, "tstamp      : %ld.%09ld\n",
-		status.tstamp.tv_sec, status.tstamp.tv_nsec);
+	snd_iprintf(buffer, "trigger_time: %lld.%09lld\n",
+		status.trigger_tstamp_sec, status.trigger_tstamp_nsec);
+	snd_iprintf(buffer, "tstamp      : %lld.%09lld\n",
+		status.tstamp_sec, status.tstamp_nsec);
 	snd_iprintf(buffer, "delay       : %ld\n", status.delay);
 	snd_iprintf(buffer, "avail       : %ld\n", status.avail);
 	snd_iprintf(buffer, "avail_max   : %ld\n", status.avail_max);
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index b719d0b..a4ef13b 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -187,73 +187,13 @@ static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream,
 	snd_pcm_channel_info_user(s, p)
 #endif /* CONFIG_X86_X32 */
 
-struct snd_pcm_status32 {
+struct compat_snd_pcm_status64 {
 	s32 state;
-	struct compat_timespec trigger_tstamp;
-	struct compat_timespec tstamp;
-	u32 appl_ptr;
-	u32 hw_ptr;
-	s32 delay;
-	u32 avail;
-	u32 avail_max;
-	u32 overrange;
-	s32 suspended_state;
-	u32 audio_tstamp_data;
-	struct compat_timespec audio_tstamp;
-	struct compat_timespec driver_tstamp;
-	u32 audio_tstamp_accuracy;
-	unsigned char reserved[52-2*sizeof(struct compat_timespec)];
-} __attribute__((packed));
-
-
-static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
-				      struct snd_pcm_status32 __user *src,
-				      bool ext)
-{
-	struct snd_pcm_status status;
-	int err;
-
-	memset(&status, 0, sizeof(status));
-	/*
-	 * with extension, parameters are read/write,
-	 * get audio_tstamp_data from user,
-	 * ignore rest of status structure
-	 */
-	if (ext && get_user(status.audio_tstamp_data,
-				(u32 __user *)(&src->audio_tstamp_data)))
-		return -EFAULT;
-	err = snd_pcm_status(substream, &status);
-	if (err < 0)
-		return err;
-
-	if (clear_user(src, sizeof(*src)))
-		return -EFAULT;
-	if (put_user(status.state, &src->state) ||
-	    compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
-	    compat_put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.appl_ptr, &src->appl_ptr) ||
-	    put_user(status.hw_ptr, &src->hw_ptr) ||
-	    put_user(status.delay, &src->delay) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.avail_max, &src->avail_max) ||
-	    put_user(status.overrange, &src->overrange) ||
-	    put_user(status.suspended_state, &src->suspended_state) ||
-	    put_user(status.audio_tstamp_data, &src->audio_tstamp_data) ||
-	    compat_put_timespec(&status.audio_tstamp, &src->audio_tstamp) ||
-	    compat_put_timespec(&status.driver_tstamp, &src->driver_tstamp) ||
-	    put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy))
-		return -EFAULT;
-
-	return err;
-}
-
-#ifdef CONFIG_X86_X32
-/* X32 ABI has 64bit timespec and 64bit alignment */
-struct snd_pcm_status_x32 {
-	s32 state;
-	u32 rsvd; /* alignment */
-	struct timespec trigger_tstamp;
-	struct timespec tstamp;
+	u8 rsvd[sizeof(time_t) - sizeof(s32)]; /* alignment */
+	s64 trigger_tstamp_sec;
+	s64 trigger_tstamp_nsec;
+	s64 tstamp_sec;
+	s64 tstamp_nsec;
 	u32 appl_ptr;
 	u32 hw_ptr;
 	s32 delay;
@@ -262,22 +202,26 @@ struct snd_pcm_status_x32 {
 	u32 overrange;
 	s32 suspended_state;
 	u32 audio_tstamp_data;
-	struct timespec audio_tstamp;
-	struct timespec driver_tstamp;
+	s64 audio_tstamp_sec;
+	s64 audio_tstamp_nsec;
+	s64 driver_tstamp_sec;
+	s64 driver_tstamp_nsec;
 	u32 audio_tstamp_accuracy;
-	unsigned char reserved[52-2*sizeof(struct timespec)];
+	unsigned char reserved[52-4*sizeof(s64)];
 } __packed;
 
 #define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst))
 
-static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream,
-				   struct snd_pcm_status_x32 __user *src,
-				   bool ext)
+static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream,
+					struct compat_snd_pcm_status64 __user *src,
+					bool ext)
 {
-	struct snd_pcm_status status;
+	struct snd_pcm_status64 status;
+	struct compat_snd_pcm_status64 compat_status64;
 	int err;
 
 	memset(&status, 0, sizeof(status));
+	memset(&compat_status64, 0, sizeof(compat_status64));
 	/*
 	 * with extension, parameters are read/write,
 	 * get audio_tstamp_data from user,
@@ -286,31 +230,39 @@ static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream,
 	if (ext && get_user(status.audio_tstamp_data,
 				(u32 __user *)(&src->audio_tstamp_data)))
 		return -EFAULT;
-	err = snd_pcm_status(substream, &status);
+	err = snd_pcm_status64(substream, &status);
 	if (err < 0)
 		return err;
 
 	if (clear_user(src, sizeof(*src)))
 		return -EFAULT;
-	if (put_user(status.state, &src->state) ||
-	    put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
-	    put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.appl_ptr, &src->appl_ptr) ||
-	    put_user(status.hw_ptr, &src->hw_ptr) ||
-	    put_user(status.delay, &src->delay) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.avail_max, &src->avail_max) ||
-	    put_user(status.overrange, &src->overrange) ||
-	    put_user(status.suspended_state, &src->suspended_state) ||
-	    put_user(status.audio_tstamp_data, &src->audio_tstamp_data) ||
-	    put_timespec(&status.audio_tstamp, &src->audio_tstamp) ||
-	    put_timespec(&status.driver_tstamp, &src->driver_tstamp) ||
-	    put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy))
+
+	compat_status64 = (struct compat_snd_pcm_status64) {
+		.state = status.state,
+		.trigger_tstamp_sec = status.trigger_tstamp_sec,
+		.trigger_tstamp_nsec = status.trigger_tstamp_nsec,
+		.tstamp_sec = status.tstamp_sec,
+		.tstamp_nsec = status.tstamp_nsec,
+		.appl_ptr = status.appl_ptr,
+		.hw_ptr = status.hw_ptr,
+		.delay = status.delay,
+		.avail = status.avail,
+		.avail_max = status.avail_max,
+		.overrange = status.overrange,
+		.suspended_state = status.suspended_state,
+		.audio_tstamp_data = status.audio_tstamp_data,
+		.audio_tstamp_sec = status.audio_tstamp_sec,
+		.audio_tstamp_nsec = status.audio_tstamp_nsec,
+		.driver_tstamp_sec = status.audio_tstamp_sec,
+		.driver_tstamp_nsec = status.audio_tstamp_nsec,
+		.audio_tstamp_accuracy = status.audio_tstamp_accuracy,
+	};
+
+	if (copy_to_user(src, &compat_status64, sizeof(compat_status64)))
 		return -EFAULT;
 
 	return err;
 }
-#endif /* CONFIG_X86_X32 */
 
 /* both for HW_PARAMS and HW_REFINE */
 static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,
@@ -633,8 +585,8 @@ enum {
 	SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct snd_pcm_hw_params32),
 	SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct snd_pcm_hw_params32),
 	SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct snd_pcm_sw_params32),
-	SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct snd_pcm_status32),
-	SNDRV_PCM_IOCTL_STATUS_EXT32 = _IOWR('A', 0x24, struct snd_pcm_status32),
+	SNDRV_PCM_IOCTL_STATUS_COMPAT32 = _IOR('A', 0x20, struct snd_pcm_status32),
+	SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32 = _IOWR('A', 0x24, struct snd_pcm_status32),
 	SNDRV_PCM_IOCTL_DELAY32 = _IOR('A', 0x21, s32),
 	SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct snd_pcm_channel_info32),
 	SNDRV_PCM_IOCTL_REWIND32 = _IOW('A', 0x46, u32),
@@ -644,10 +596,10 @@ enum {
 	SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32),
 	SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32),
 	SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
+	SNDRV_PCM_IOCTL_STATUS_COMPAT64 = _IOR('A', 0x20, struct compat_snd_pcm_status64),
+	SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64 = _IOWR('A', 0x24, struct compat_snd_pcm_status64),
 #ifdef CONFIG_X86_X32
 	SNDRV_PCM_IOCTL_CHANNEL_INFO_X32 = _IOR('A', 0x32, struct snd_pcm_channel_info),
-	SNDRV_PCM_IOCTL_STATUS_X32 = _IOR('A', 0x20, struct snd_pcm_status_x32),
-	SNDRV_PCM_IOCTL_STATUS_EXT_X32 = _IOWR('A', 0x24, struct snd_pcm_status_x32),
 	SNDRV_PCM_IOCTL_SYNC_PTR_X32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr_x32),
 #endif /* CONFIG_X86_X32 */
 };
@@ -697,10 +649,10 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
 		return snd_pcm_ioctl_hw_params_compat(substream, 0, argp);
 	case SNDRV_PCM_IOCTL_SW_PARAMS32:
 		return snd_pcm_ioctl_sw_params_compat(substream, argp);
-	case SNDRV_PCM_IOCTL_STATUS32:
-		return snd_pcm_status_user_compat(substream, argp, false);
-	case SNDRV_PCM_IOCTL_STATUS_EXT32:
-		return snd_pcm_status_user_compat(substream, argp, true);
+	case SNDRV_PCM_IOCTL_STATUS_COMPAT32:
+		return snd_pcm_status_user32(substream, argp, false);
+	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32:
+		return snd_pcm_status_user32(substream, argp, true);
 	case SNDRV_PCM_IOCTL_SYNC_PTR32:
 		return snd_pcm_ioctl_sync_ptr_compat(substream, argp);
 	case SNDRV_PCM_IOCTL_CHANNEL_INFO32:
@@ -719,11 +671,11 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
 		return snd_pcm_ioctl_rewind_compat(substream, argp);
 	case SNDRV_PCM_IOCTL_FORWARD32:
 		return snd_pcm_ioctl_forward_compat(substream, argp);
+	case SNDRV_PCM_IOCTL_STATUS_COMPAT64:
+		return snd_pcm_status_user_compat64(substream, argp, false);
+	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64:
+		return snd_pcm_status_user_compat64(substream, argp, true);
 #ifdef CONFIG_X86_X32
-	case SNDRV_PCM_IOCTL_STATUS_X32:
-		return snd_pcm_status_user_x32(substream, argp, false);
-	case SNDRV_PCM_IOCTL_STATUS_EXT_X32:
-		return snd_pcm_status_user_x32(substream, argp, true);
 	case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
 		return snd_pcm_ioctl_sync_ptr_x32(substream, argp);
 	case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32:
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c57dd4b..0c2ec6d 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -857,8 +857,8 @@ static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream,
 	return err;
 }
 
-int snd_pcm_status(struct snd_pcm_substream *substream,
-		   struct snd_pcm_status *status)
+int snd_pcm_status64(struct snd_pcm_substream *substream,
+		     struct snd_pcm_status64 *status)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
@@ -884,14 +884,22 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 	status->suspended_state = runtime->status->suspended_state;
 	if (status->state == SNDRV_PCM_STATE_OPEN)
 		goto _end;
-	status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp);
+	status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec;
+	status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec;
 	if (snd_pcm_running(substream)) {
 		snd_pcm_update_hw_ptr(substream);
 		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
-			status->tstamp = runtime->status->tstamp;
-			status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp);
-			status->audio_tstamp =
-				runtime->status->audio_tstamp;
+			status->tstamp_sec = runtime->status->tstamp.tv_sec;
+			status->tstamp_nsec =
+				runtime->status->tstamp.tv_nsec;
+			status->driver_tstamp_sec =
+				runtime->driver_tstamp.tv_sec;
+			status->driver_tstamp_nsec =
+				runtime->driver_tstamp.tv_nsec;
+			status->audio_tstamp_sec =
+				runtime->status->audio_tstamp.tv_sec;
+			status->audio_tstamp_nsec =
+				runtime->status->audio_tstamp.tv_nsec;
 			if (runtime->audio_tstamp_report.valid == 1)
 				/* backwards compatibility, no report provided in COMPAT mode */
 				snd_pcm_pack_audio_tstamp_report(&status->audio_tstamp_data,
@@ -906,7 +914,8 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 			struct timespec64 tstamp;
 
 			snd_pcm_gettime(runtime, &tstamp);
-			status->tstamp = timespec64_to_timespec(tstamp);
+			status->tstamp_sec = tstamp.tv_sec;
+			status->tstamp_nsec = tstamp.tv_nsec;
 		}
 	}
  _tstamp_end:
@@ -936,11 +945,11 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-static int snd_pcm_status_user(struct snd_pcm_substream *substream,
-			       struct snd_pcm_status __user * _status,
-			       bool ext)
+static int snd_pcm_status_user64(struct snd_pcm_substream *substream,
+				 struct snd_pcm_status64 __user * _status,
+				 bool ext)
 {
-	struct snd_pcm_status status;
+	struct snd_pcm_status64 status;
 	int res;
 
 	memset(&status, 0, sizeof(status));
@@ -952,7 +961,7 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream,
 	if (ext && get_user(status.audio_tstamp_data,
 				(u32 __user *)(&_status->audio_tstamp_data)))
 		return -EFAULT;
-	res = snd_pcm_status(substream, &status);
+	res = snd_pcm_status64(substream, &status);
 	if (res < 0)
 		return res;
 	if (copy_to_user(_status, &status, sizeof(status)))
@@ -960,6 +969,55 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
+				 struct snd_pcm_status32 __user * _status,
+				 bool ext)
+{
+	struct snd_pcm_status64 status64;
+	struct snd_pcm_status32 status32;
+	int res;
+
+	memset(&status64, 0, sizeof(status64));
+	memset(&status32, 0, sizeof(status32));
+	/*
+	 * with extension, parameters are read/write,
+	 * get audio_tstamp_data from user,
+	 * ignore rest of status structure
+	 */
+	if (ext && get_user(status64.audio_tstamp_data,
+			    (u32 __user *)(&_status->audio_tstamp_data)))
+		return -EFAULT;
+	res = snd_pcm_status64(substream, &status64);
+	if (res < 0)
+		return res;
+
+	status32 = (struct snd_pcm_status32) {
+		.state = status64.state,
+		.trigger_tstamp_sec = status64.trigger_tstamp_sec,
+		.trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
+		.tstamp_sec = status64.tstamp_sec,
+		.tstamp_nsec = status64.tstamp_nsec,
+		.appl_ptr = status64.appl_ptr,
+		.hw_ptr = status64.hw_ptr,
+		.delay = status64.delay,
+		.avail = status64.avail,
+		.avail_max = status64.avail_max,
+		.overrange = status64.overrange,
+		.suspended_state = status64.suspended_state,
+		.audio_tstamp_data = status64.audio_tstamp_data,
+		.audio_tstamp_sec = status64.audio_tstamp_sec,
+		.audio_tstamp_nsec = status64.audio_tstamp_nsec,
+		.driver_tstamp_sec = status64.audio_tstamp_sec,
+		.driver_tstamp_nsec = status64.audio_tstamp_nsec,
+		.audio_tstamp_accuracy = status64.audio_tstamp_accuracy,
+	};
+
+	if (copy_to_user(_status, &status32, sizeof(status32)))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int snd_pcm_channel_info(struct snd_pcm_substream *substream,
 				struct snd_pcm_channel_info * info)
 {
@@ -2896,10 +2954,14 @@ static int snd_pcm_common_ioctl(struct file *file,
 		return snd_pcm_hw_free(substream);
 	case SNDRV_PCM_IOCTL_SW_PARAMS:
 		return snd_pcm_sw_params_user(substream, arg);
-	case SNDRV_PCM_IOCTL_STATUS:
-		return snd_pcm_status_user(substream, arg, false);
-	case SNDRV_PCM_IOCTL_STATUS_EXT:
-		return snd_pcm_status_user(substream, arg, true);
+	case SNDRV_PCM_IOCTL_STATUS32:
+		return snd_pcm_status_user32(substream, arg, false);
+	case SNDRV_PCM_IOCTL_STATUS_EXT32:
+		return snd_pcm_status_user32(substream, arg, true);
+	case SNDRV_PCM_IOCTL_STATUS64:
+		return snd_pcm_status_user64(substream, arg, false);
+	case SNDRV_PCM_IOCTL_STATUS_EXT64:
+		return snd_pcm_status_user64(substream, arg, true);
 	case SNDRV_PCM_IOCTL_CHANNEL_INFO:
 		return snd_pcm_channel_info_user(substream, arg);
 	case SNDRV_PCM_IOCTL_PREPARE:
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 5/8] ALSA: Avoid using timespec for struct snd_rawmidi_status
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
@ 2018-04-24 12:06   ` Baolin Wang
  2018-04-24 12:06   ` Baolin Wang
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

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>
---
 include/uapi/sound/asound.h |    1 +
 sound/core/rawmidi.c        |  131 ++++++++++++++++++++++++++++++++++---------
 sound/core/rawmidi_compat.c |   87 ++++++++--------------------
 3 files changed, 126 insertions(+), 93 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index c9afde4..fad66ad 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -650,6 +650,7 @@ struct snd_rawmidi_params {
 
 struct snd_rawmidi_status {
 	int stream;
+	unsigned char pad1[sizeof(time_t) - sizeof(int)];
 	struct timespec tstamp;		/* Timestamp */
 	size_t avail;			/* available bytes */
 	size_t xruns;			/* count of overruns since last status (in bytes) */
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 69616d0..421b899 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -63,6 +63,29 @@
 #define rmidi_dbg(rmidi, fmt, args...) \
 	dev_dbg(&(rmidi)->dev, fmt, ##args)
 
+struct snd_rawmidi_status32 {
+	s32 stream;
+	s32 tstamp_sec;			/* Timestamp */
+	s32 tstamp_nsec;
+	u32 avail;			/* available bytes */
+	u32 xruns;			/* count of overruns since last status (in bytes) */
+	unsigned char reserved[16];	/* reserved for future use */
+};
+
+#define SNDRV_RAWMIDI_IOCTL_STATUS32	_IOWR('W', 0x20, struct snd_rawmidi_status32)
+
+struct snd_rawmidi_status64 {
+	int stream;
+	u8 rsvd[sizeof(time_t) - sizeof(int)]; /* alignment */
+	s64 tstamp_sec;			/* Timestamp */
+	s64 tstamp_nsec;
+	size_t avail;			/* available bytes */
+	size_t xruns;			/* count of overruns since last status (in bytes) */
+	unsigned char reserved[16];	/* reserved for future use */
+};
+
+#define SNDRV_RAWMIDI_IOCTL_STATUS64	_IOWR('W', 0x20, struct snd_rawmidi_status64)
+
 static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
 {
 	struct snd_rawmidi *rawmidi;
@@ -689,7 +712,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
 EXPORT_SYMBOL(snd_rawmidi_input_params);
 
 static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
-				     struct snd_rawmidi_status * status)
+				     struct snd_rawmidi_status64 * status)
 {
 	struct snd_rawmidi_runtime *runtime = substream->runtime;
 
@@ -702,7 +725,7 @@ static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
 }
 
 static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream,
-				    struct snd_rawmidi_status * status)
+				    struct snd_rawmidi_status64 * status)
 {
 	struct snd_rawmidi_runtime *runtime = substream->runtime;
 
@@ -716,6 +739,80 @@ static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream,
 	return 0;
 }
 
+static int snd_rawmidi_ioctl_status32(struct snd_rawmidi_file *rfile,
+				      struct snd_rawmidi_status32 __user *argp)
+{
+	int err = 0;
+	struct snd_rawmidi_status32 __user *status = argp;
+	struct snd_rawmidi_status32 status32;
+	struct snd_rawmidi_status64 status64;
+
+	if (copy_from_user(&status32, argp,
+			   sizeof(struct snd_rawmidi_status32)))
+		return -EFAULT;
+
+	switch (status32.stream) {
+	case SNDRV_RAWMIDI_STREAM_OUTPUT:
+		if (rfile->output == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_output_status(rfile->output, &status64);
+		break;
+	case SNDRV_RAWMIDI_STREAM_INPUT:
+		if (rfile->input == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_input_status(rfile->input, &status64);
+		break;
+	default:
+		return -EINVAL;
+	}
+	if (err < 0)
+		return err;
+
+	status32 = (struct snd_rawmidi_status32) {
+		.stream = status64.stream,
+		.tstamp_sec = status64.tstamp_sec,
+		.tstamp_nsec = status64.tstamp_nsec,
+		.avail = status64.avail,
+		.xruns = status64.xruns,
+	};
+
+	if (copy_to_user(status, &status32, sizeof(*status)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int snd_rawmidi_ioctl_status64(struct snd_rawmidi_file *rfile,
+				      struct snd_rawmidi_status64 __user *argp)
+{
+	int err = 0;
+	struct snd_rawmidi_status64 status;
+
+	if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status64)))
+		return -EFAULT;
+
+	switch (status.stream) {
+	case SNDRV_RAWMIDI_STREAM_OUTPUT:
+		if (rfile->output == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_output_status(rfile->output, &status);
+		break;
+	case SNDRV_RAWMIDI_STREAM_INPUT:
+		if (rfile->input == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_input_status(rfile->input, &status);
+		break;
+	default:
+		return -EINVAL;
+	}
+	if (err < 0)
+		return err;
+	if (copy_to_user(argp, &status,
+			 sizeof(struct snd_rawmidi_status64)))
+		return -EFAULT;
+	return 0;
+}
+
 static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct snd_rawmidi_file *rfile;
@@ -760,32 +857,10 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
 			return -EINVAL;
 		}
 	}
-	case SNDRV_RAWMIDI_IOCTL_STATUS:
-	{
-		int err = 0;
-		struct snd_rawmidi_status status;
-		if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status)))
-			return -EFAULT;
-		switch (status.stream) {
-		case SNDRV_RAWMIDI_STREAM_OUTPUT:
-			if (rfile->output == NULL)
-				return -EINVAL;
-			err = snd_rawmidi_output_status(rfile->output, &status);
-			break;
-		case SNDRV_RAWMIDI_STREAM_INPUT:
-			if (rfile->input == NULL)
-				return -EINVAL;
-			err = snd_rawmidi_input_status(rfile->input, &status);
-			break;
-		default:
-			return -EINVAL;
-		}
-		if (err < 0)
-			return err;
-		if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status)))
-			return -EFAULT;
-		return 0;
-	}
+	case SNDRV_RAWMIDI_IOCTL_STATUS32:
+		return snd_rawmidi_ioctl_status32(rfile, argp);
+	case SNDRV_RAWMIDI_IOCTL_STATUS64:
+		return snd_rawmidi_ioctl_status64(rfile, argp);
 	case SNDRV_RAWMIDI_IOCTL_DROP:
 	{
 		int val;
diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
index e30e30b..c817441 100644
--- a/sound/core/rawmidi_compat.c
+++ b/sound/core/rawmidi_compat.c
@@ -55,19 +55,22 @@ static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile,
 	return -EINVAL;
 }
 
-struct snd_rawmidi_status32 {
+struct compat_snd_rawmidi_status64 {
 	s32 stream;
-	struct compat_timespec tstamp;
+	u8 rsvd[sizeof(time_t) - sizeof(s32)]; /* alignment */
+	s64 tstamp_sec;
+	s64 tstamp_nsec;
 	u32 avail;
 	u32 xruns;
 	unsigned char reserved[16];
 } __attribute__((packed));
 
-static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
-					   struct snd_rawmidi_status32 __user *src)
+static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
+					     struct compat_snd_rawmidi_status64 __user *src)
 {
 	int err;
-	struct snd_rawmidi_status status;
+	struct snd_rawmidi_status64 status;
+	struct compat_snd_rawmidi_status64 compat_status;
 
 	if (get_user(status.stream, &src->stream))
 		return -EFAULT;
@@ -89,68 +92,24 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
 	if (err < 0)
 		return err;
 
-	if (compat_put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.xruns, &src->xruns))
-		return -EFAULT;
-
-	return 0;
-}
-
-#ifdef CONFIG_X86_X32
-/* X32 ABI has 64bit timespec and 64bit alignment */
-struct snd_rawmidi_status_x32 {
-	s32 stream;
-	u32 rsvd; /* alignment */
-	struct timespec tstamp;
-	u32 avail;
-	u32 xruns;
-	unsigned char reserved[16];
-} __attribute__((packed));
-
-#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst))
-
-static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile,
-					struct snd_rawmidi_status_x32 __user *src)
-{
-	int err;
-	struct snd_rawmidi_status status;
-
-	if (get_user(status.stream, &src->stream))
-		return -EFAULT;
-
-	switch (status.stream) {
-	case SNDRV_RAWMIDI_STREAM_OUTPUT:
-		if (!rfile->output)
-			return -EINVAL;
-		err = snd_rawmidi_output_status(rfile->output, &status);
-		break;
-	case SNDRV_RAWMIDI_STREAM_INPUT:
-		if (!rfile->input)
-			return -EINVAL;
-		err = snd_rawmidi_input_status(rfile->input, &status);
-		break;
-	default:
-		return -EINVAL;
-	}
-	if (err < 0)
-		return err;
+	compat_status = (struct compat_snd_rawmidi_status64) {
+		.stream = status.stream,
+		.tstamp_sec = status.tstamp_sec,
+		.tstamp_nsec = status.tstamp_nsec,
+		.avail = status.avail,
+		.xruns = status.xruns,
+	};
 
-	if (put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.xruns, &src->xruns))
+	if (copy_to_user(src, &compat_status, sizeof(*src)))
 		return -EFAULT;
 
 	return 0;
 }
-#endif /* CONFIG_X86_X32 */
 
 enum {
 	SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32),
-	SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
-#ifdef CONFIG_X86_X32
-	SNDRV_RAWMIDI_IOCTL_STATUS_X32 = _IOWR('W', 0x20, struct snd_rawmidi_status_x32),
-#endif /* CONFIG_X86_X32 */
+	SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
+	SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64 = _IOWR('W', 0x20, struct compat_snd_rawmidi_status64),
 };
 
 static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -167,12 +126,10 @@ static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsign
 		return snd_rawmidi_ioctl(file, cmd, (unsigned long)argp);
 	case SNDRV_RAWMIDI_IOCTL_PARAMS32:
 		return snd_rawmidi_ioctl_params_compat(rfile, argp);
-	case SNDRV_RAWMIDI_IOCTL_STATUS32:
-		return snd_rawmidi_ioctl_status_compat(rfile, argp);
-#ifdef CONFIG_X86_X32
-	case SNDRV_RAWMIDI_IOCTL_STATUS_X32:
-		return snd_rawmidi_ioctl_status_x32(rfile, argp);
-#endif /* CONFIG_X86_X32 */
+	case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32:
+		return snd_rawmidi_ioctl_status32(rfile, argp);
+	case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64:
+		return snd_rawmidi_ioctl_status_compat64(rfile, argp);
 	}
 	return -ENOIOCTLCMD;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 5/8] ALSA: Avoid using timespec for struct snd_rawmidi_status
@ 2018-04-24 12:06   ` Baolin Wang
  0 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: fabf, arvind.yadav.cs, linux-kernel, alsa-devel, baolin.wang,
	vinod.koul, hardik.t.shah, guneshwor.o.singh, lgirdwood, elfring,
	gudishax.kranthikumar, broonie, bhumirks, naveen.m, jeeja.kp,
	o-takashi, subhransu.s.prusty, mingo, dan.carpenter

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>
---
 include/uapi/sound/asound.h |    1 +
 sound/core/rawmidi.c        |  131 ++++++++++++++++++++++++++++++++++---------
 sound/core/rawmidi_compat.c |   87 ++++++++--------------------
 3 files changed, 126 insertions(+), 93 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index c9afde4..fad66ad 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -650,6 +650,7 @@ struct snd_rawmidi_params {
 
 struct snd_rawmidi_status {
 	int stream;
+	unsigned char pad1[sizeof(time_t) - sizeof(int)];
 	struct timespec tstamp;		/* Timestamp */
 	size_t avail;			/* available bytes */
 	size_t xruns;			/* count of overruns since last status (in bytes) */
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 69616d0..421b899 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -63,6 +63,29 @@
 #define rmidi_dbg(rmidi, fmt, args...) \
 	dev_dbg(&(rmidi)->dev, fmt, ##args)
 
+struct snd_rawmidi_status32 {
+	s32 stream;
+	s32 tstamp_sec;			/* Timestamp */
+	s32 tstamp_nsec;
+	u32 avail;			/* available bytes */
+	u32 xruns;			/* count of overruns since last status (in bytes) */
+	unsigned char reserved[16];	/* reserved for future use */
+};
+
+#define SNDRV_RAWMIDI_IOCTL_STATUS32	_IOWR('W', 0x20, struct snd_rawmidi_status32)
+
+struct snd_rawmidi_status64 {
+	int stream;
+	u8 rsvd[sizeof(time_t) - sizeof(int)]; /* alignment */
+	s64 tstamp_sec;			/* Timestamp */
+	s64 tstamp_nsec;
+	size_t avail;			/* available bytes */
+	size_t xruns;			/* count of overruns since last status (in bytes) */
+	unsigned char reserved[16];	/* reserved for future use */
+};
+
+#define SNDRV_RAWMIDI_IOCTL_STATUS64	_IOWR('W', 0x20, struct snd_rawmidi_status64)
+
 static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
 {
 	struct snd_rawmidi *rawmidi;
@@ -689,7 +712,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
 EXPORT_SYMBOL(snd_rawmidi_input_params);
 
 static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
-				     struct snd_rawmidi_status * status)
+				     struct snd_rawmidi_status64 * status)
 {
 	struct snd_rawmidi_runtime *runtime = substream->runtime;
 
@@ -702,7 +725,7 @@ static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
 }
 
 static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream,
-				    struct snd_rawmidi_status * status)
+				    struct snd_rawmidi_status64 * status)
 {
 	struct snd_rawmidi_runtime *runtime = substream->runtime;
 
@@ -716,6 +739,80 @@ static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream,
 	return 0;
 }
 
+static int snd_rawmidi_ioctl_status32(struct snd_rawmidi_file *rfile,
+				      struct snd_rawmidi_status32 __user *argp)
+{
+	int err = 0;
+	struct snd_rawmidi_status32 __user *status = argp;
+	struct snd_rawmidi_status32 status32;
+	struct snd_rawmidi_status64 status64;
+
+	if (copy_from_user(&status32, argp,
+			   sizeof(struct snd_rawmidi_status32)))
+		return -EFAULT;
+
+	switch (status32.stream) {
+	case SNDRV_RAWMIDI_STREAM_OUTPUT:
+		if (rfile->output == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_output_status(rfile->output, &status64);
+		break;
+	case SNDRV_RAWMIDI_STREAM_INPUT:
+		if (rfile->input == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_input_status(rfile->input, &status64);
+		break;
+	default:
+		return -EINVAL;
+	}
+	if (err < 0)
+		return err;
+
+	status32 = (struct snd_rawmidi_status32) {
+		.stream = status64.stream,
+		.tstamp_sec = status64.tstamp_sec,
+		.tstamp_nsec = status64.tstamp_nsec,
+		.avail = status64.avail,
+		.xruns = status64.xruns,
+	};
+
+	if (copy_to_user(status, &status32, sizeof(*status)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int snd_rawmidi_ioctl_status64(struct snd_rawmidi_file *rfile,
+				      struct snd_rawmidi_status64 __user *argp)
+{
+	int err = 0;
+	struct snd_rawmidi_status64 status;
+
+	if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status64)))
+		return -EFAULT;
+
+	switch (status.stream) {
+	case SNDRV_RAWMIDI_STREAM_OUTPUT:
+		if (rfile->output == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_output_status(rfile->output, &status);
+		break;
+	case SNDRV_RAWMIDI_STREAM_INPUT:
+		if (rfile->input == NULL)
+			return -EINVAL;
+		err = snd_rawmidi_input_status(rfile->input, &status);
+		break;
+	default:
+		return -EINVAL;
+	}
+	if (err < 0)
+		return err;
+	if (copy_to_user(argp, &status,
+			 sizeof(struct snd_rawmidi_status64)))
+		return -EFAULT;
+	return 0;
+}
+
 static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct snd_rawmidi_file *rfile;
@@ -760,32 +857,10 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
 			return -EINVAL;
 		}
 	}
-	case SNDRV_RAWMIDI_IOCTL_STATUS:
-	{
-		int err = 0;
-		struct snd_rawmidi_status status;
-		if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status)))
-			return -EFAULT;
-		switch (status.stream) {
-		case SNDRV_RAWMIDI_STREAM_OUTPUT:
-			if (rfile->output == NULL)
-				return -EINVAL;
-			err = snd_rawmidi_output_status(rfile->output, &status);
-			break;
-		case SNDRV_RAWMIDI_STREAM_INPUT:
-			if (rfile->input == NULL)
-				return -EINVAL;
-			err = snd_rawmidi_input_status(rfile->input, &status);
-			break;
-		default:
-			return -EINVAL;
-		}
-		if (err < 0)
-			return err;
-		if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status)))
-			return -EFAULT;
-		return 0;
-	}
+	case SNDRV_RAWMIDI_IOCTL_STATUS32:
+		return snd_rawmidi_ioctl_status32(rfile, argp);
+	case SNDRV_RAWMIDI_IOCTL_STATUS64:
+		return snd_rawmidi_ioctl_status64(rfile, argp);
 	case SNDRV_RAWMIDI_IOCTL_DROP:
 	{
 		int val;
diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
index e30e30b..c817441 100644
--- a/sound/core/rawmidi_compat.c
+++ b/sound/core/rawmidi_compat.c
@@ -55,19 +55,22 @@ static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile,
 	return -EINVAL;
 }
 
-struct snd_rawmidi_status32 {
+struct compat_snd_rawmidi_status64 {
 	s32 stream;
-	struct compat_timespec tstamp;
+	u8 rsvd[sizeof(time_t) - sizeof(s32)]; /* alignment */
+	s64 tstamp_sec;
+	s64 tstamp_nsec;
 	u32 avail;
 	u32 xruns;
 	unsigned char reserved[16];
 } __attribute__((packed));
 
-static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
-					   struct snd_rawmidi_status32 __user *src)
+static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
+					     struct compat_snd_rawmidi_status64 __user *src)
 {
 	int err;
-	struct snd_rawmidi_status status;
+	struct snd_rawmidi_status64 status;
+	struct compat_snd_rawmidi_status64 compat_status;
 
 	if (get_user(status.stream, &src->stream))
 		return -EFAULT;
@@ -89,68 +92,24 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
 	if (err < 0)
 		return err;
 
-	if (compat_put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.xruns, &src->xruns))
-		return -EFAULT;
-
-	return 0;
-}
-
-#ifdef CONFIG_X86_X32
-/* X32 ABI has 64bit timespec and 64bit alignment */
-struct snd_rawmidi_status_x32 {
-	s32 stream;
-	u32 rsvd; /* alignment */
-	struct timespec tstamp;
-	u32 avail;
-	u32 xruns;
-	unsigned char reserved[16];
-} __attribute__((packed));
-
-#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst))
-
-static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile,
-					struct snd_rawmidi_status_x32 __user *src)
-{
-	int err;
-	struct snd_rawmidi_status status;
-
-	if (get_user(status.stream, &src->stream))
-		return -EFAULT;
-
-	switch (status.stream) {
-	case SNDRV_RAWMIDI_STREAM_OUTPUT:
-		if (!rfile->output)
-			return -EINVAL;
-		err = snd_rawmidi_output_status(rfile->output, &status);
-		break;
-	case SNDRV_RAWMIDI_STREAM_INPUT:
-		if (!rfile->input)
-			return -EINVAL;
-		err = snd_rawmidi_input_status(rfile->input, &status);
-		break;
-	default:
-		return -EINVAL;
-	}
-	if (err < 0)
-		return err;
+	compat_status = (struct compat_snd_rawmidi_status64) {
+		.stream = status.stream,
+		.tstamp_sec = status.tstamp_sec,
+		.tstamp_nsec = status.tstamp_nsec,
+		.avail = status.avail,
+		.xruns = status.xruns,
+	};
 
-	if (put_timespec(&status.tstamp, &src->tstamp) ||
-	    put_user(status.avail, &src->avail) ||
-	    put_user(status.xruns, &src->xruns))
+	if (copy_to_user(src, &compat_status, sizeof(*src)))
 		return -EFAULT;
 
 	return 0;
 }
-#endif /* CONFIG_X86_X32 */
 
 enum {
 	SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32),
-	SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
-#ifdef CONFIG_X86_X32
-	SNDRV_RAWMIDI_IOCTL_STATUS_X32 = _IOWR('W', 0x20, struct snd_rawmidi_status_x32),
-#endif /* CONFIG_X86_X32 */
+	SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
+	SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64 = _IOWR('W', 0x20, struct compat_snd_rawmidi_status64),
 };
 
 static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -167,12 +126,10 @@ static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsign
 		return snd_rawmidi_ioctl(file, cmd, (unsigned long)argp);
 	case SNDRV_RAWMIDI_IOCTL_PARAMS32:
 		return snd_rawmidi_ioctl_params_compat(rfile, argp);
-	case SNDRV_RAWMIDI_IOCTL_STATUS32:
-		return snd_rawmidi_ioctl_status_compat(rfile, argp);
-#ifdef CONFIG_X86_X32
-	case SNDRV_RAWMIDI_IOCTL_STATUS_X32:
-		return snd_rawmidi_ioctl_status_x32(rfile, argp);
-#endif /* CONFIG_X86_X32 */
+	case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32:
+		return snd_rawmidi_ioctl_status32(rfile, argp);
+	case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64:
+		return snd_rawmidi_ioctl_status_compat64(rfile, argp);
 	}
 	return -ENOIOCTLCMD;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 6/8] ALSA: Avoid using timespec for struct snd_timer_tread
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
                   ` (4 preceding siblings ...)
  2018-04-24 12:06   ` Baolin Wang
@ 2018-04-24 12:06 ` Baolin Wang
  2018-04-24 12:06 ` [PATCH 7/8] ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c Baolin Wang
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

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>
---
 include/uapi/sound/asound.h |   13 +++-
 sound/core/timer.c          |  144 ++++++++++++++++++++++++++++++++-----------
 sound/core/timer_compat.c   |    2 +-
 3 files changed, 121 insertions(+), 38 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index fad66ad..f368e80 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -773,7 +773,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)
@@ -786,6 +786,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;
@@ -813,8 +822,10 @@ enum {
 
 struct snd_timer_tread {
 	int event;
+	__u8 pad1[sizeof(time_t) - sizeof(int)];
 	struct timespec tstamp;
 	unsigned int val;
+	__u8 pad2[sizeof(time_t) - sizeof(unsigned int)];
 };
 
 /****************************************************************************
diff --git a/sound/core/timer.c b/sound/core/timer.c
index c9d7ddb..729a643 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -58,6 +58,21 @@
 MODULE_ALIAS_CHARDEV(CONFIG_SND_MAJOR, SNDRV_MINOR_TIMER);
 MODULE_ALIAS("devname:snd/timer");
 
+enum timer_tread_format {
+	TREAD_FORMAT_NONE = 0,
+	TREAD_FORMAT_TIME64,
+	TREAD_FORMAT_TIME32,
+};
+
+struct snd_timer_tread64 {
+	int event;
+	u8 pad1[sizeof(time_t) - sizeof(int)];
+	s64 tstamp_sec;
+	s64 tstamp_nsec;
+	unsigned int val;
+	u32 pad2;
+};
+
 struct snd_timer_user {
 	struct snd_timer_instance *timeri;
 	int tread;		/* enhanced read with timestamps and events */
@@ -69,7 +84,7 @@ struct snd_timer_user {
 	int queue_size;
 	bool disconnected;
 	struct snd_timer_read *queue;
-	struct snd_timer_tread *tqueue;
+	struct snd_timer_tread64 *tqueue;
 	spinlock_t qlock;
 	unsigned long last_resolution;
 	unsigned int filter;
@@ -1306,7 +1321,7 @@ static void snd_timer_user_interrupt(struct snd_timer_instance *timeri,
 }
 
 static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu,
-					    struct snd_timer_tread *tread)
+					    struct snd_timer_tread64 *tread)
 {
 	if (tu->qused >= tu->queue_size) {
 		tu->overrun++;
@@ -1323,7 +1338,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 				     unsigned long resolution)
 {
 	struct snd_timer_user *tu = timeri->callback_data;
-	struct snd_timer_tread r1;
+	struct snd_timer_tread64 r1;
 	unsigned long flags;
 
 	if (event >= SNDRV_TIMER_EVENT_START &&
@@ -1333,7 +1348,8 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
 		return;
 	memset(&r1, 0, sizeof(r1));
 	r1.event = event;
-	r1.tstamp = timespec64_to_timespec(*tstamp);
+	r1.tstamp_sec = tstamp->tv_sec;
+	r1.tstamp_nsec = tstamp->tv_nsec;
 	r1.val = resolution;
 	spin_lock_irqsave(&tu->qlock, flags);
 	snd_timer_user_append_to_tqueue(tu, &r1);
@@ -1355,7 +1371,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 				      unsigned long ticks)
 {
 	struct snd_timer_user *tu = timeri->callback_data;
-	struct snd_timer_tread *r, r1;
+	struct snd_timer_tread64 *r, r1;
 	struct timespec64 tstamp;
 	int prev, append = 0;
 
@@ -1376,7 +1392,8 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 	if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) &&
 	    tu->last_resolution != resolution) {
 		r1.event = SNDRV_TIMER_EVENT_RESOLUTION;
-		r1.tstamp = timespec64_to_timespec(tstamp);
+		r1.tstamp_sec = tstamp.tv_sec;
+		r1.tstamp_nsec = tstamp.tv_nsec;
 		r1.val = resolution;
 		snd_timer_user_append_to_tqueue(tu, &r1);
 		tu->last_resolution = resolution;
@@ -1390,14 +1407,16 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 		prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1;
 		r = &tu->tqueue[prev];
 		if (r->event == SNDRV_TIMER_EVENT_TICK) {
-			r->tstamp = timespec64_to_timespec(tstamp);
+			r->tstamp_sec = tstamp.tv_sec;
+			r->tstamp_nsec = tstamp.tv_nsec;
 			r->val += ticks;
 			append++;
 			goto __wake;
 		}
 	}
 	r1.event = SNDRV_TIMER_EVENT_TICK;
-	r1.tstamp = timespec64_to_timespec(tstamp);
+	r1.tstamp_sec = tstamp.tv_sec;
+	r1.tstamp_nsec = tstamp.tv_nsec;
 	r1.val = ticks;
 	snd_timer_user_append_to_tqueue(tu, &r1);
 	append++;
@@ -1412,7 +1431,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
 static int realloc_user_queue(struct snd_timer_user *tu, int size)
 {
 	struct snd_timer_read *queue = NULL;
-	struct snd_timer_tread *tqueue = NULL;
+	struct snd_timer_tread64 *tqueue = NULL;
 
 	if (tu->tread) {
 		tqueue = kcalloc(size, sizeof(*tqueue), GFP_KERNEL);
@@ -1841,11 +1860,11 @@ static int snd_timer_user_params(struct file *file,
 	tu->qhead = tu->qtail = tu->qused = 0;
 	if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) {
 		if (tu->tread) {
-			struct snd_timer_tread tread;
+			struct snd_timer_tread64 tread;
 			memset(&tread, 0, sizeof(tread));
 			tread.event = SNDRV_TIMER_EVENT_EARLY;
-			tread.tstamp.tv_sec = 0;
-			tread.tstamp.tv_nsec = 0;
+			tread.tstamp_sec = 0;
+			tread.tstamp_nsec = 0;
 			tread.val = 0;
 			snd_timer_user_append_to_tqueue(tu, &tread);
 		} else {
@@ -1963,6 +1982,36 @@ static int snd_timer_user_pause(struct file *file)
 	return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0;
 }
 
+static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu,
+				unsigned int cmd, bool compat)
+{
+	int __user *p = argp;
+	int xarg, old_tread;
+
+	if (tu->timeri)	/* too late */
+		return -EBUSY;
+	if (get_user(xarg, p))
+		return -EFAULT;
+
+	old_tread = tu->tread;
+
+	if (!xarg)
+		tu->tread = TREAD_FORMAT_NONE;
+	else if (cmd == SNDRV_TIMER_IOCTL_TREAD64 ||
+		 (IS_ENABLED(CONFIG_64BITS) && !compat))
+		tu->tread = TREAD_FORMAT_TIME64;
+	else
+		tu->tread = TREAD_FORMAT_TIME32;
+
+	if (tu->tread != old_tread &&
+	    realloc_user_queue(tu, tu->queue_size) < 0) {
+		tu->tread = old_tread;
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 enum {
 	SNDRV_TIMER_IOCTL_START_OLD = _IO('T', 0x20),
 	SNDRV_TIMER_IOCTL_STOP_OLD = _IO('T', 0x21),
@@ -1971,7 +2020,7 @@ enum {
 };
 
 static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,
-				 unsigned long arg)
+				 unsigned long arg, bool compat)
 {
 	struct snd_timer_user *tu;
 	void __user *argp = (void __user *)arg;
@@ -1983,23 +2032,9 @@ static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,
 		return put_user(SNDRV_TIMER_VERSION, p) ? -EFAULT : 0;
 	case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
 		return snd_timer_user_next_device(argp);
-	case SNDRV_TIMER_IOCTL_TREAD:
-	{
-		int xarg, old_tread;
-
-		if (tu->timeri)	/* too late */
-			return -EBUSY;
-		if (get_user(xarg, p))
-			return -EFAULT;
-		old_tread = tu->tread;
-		tu->tread = xarg ? 1 : 0;
-		if (tu->tread != old_tread &&
-		    realloc_user_queue(tu, tu->queue_size) < 0) {
-			tu->tread = old_tread;
-			return -ENOMEM;
-		}
-		return 0;
-	}
+	case SNDRV_TIMER_IOCTL_TREAD_OLD:
+	case SNDRV_TIMER_IOCTL_TREAD64:
+		return snd_timer_user_tread(argp, tu, cmd, compat);
 	case SNDRV_TIMER_IOCTL_GINFO:
 		return snd_timer_user_ginfo(file, argp);
 	case SNDRV_TIMER_IOCTL_GPARAMS:
@@ -2039,7 +2074,7 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
 	long ret;
 
 	mutex_lock(&tu->ioctl_lock);
-	ret = __snd_timer_user_ioctl(file, cmd, arg);
+	ret = __snd_timer_user_ioctl(file, cmd, arg, false);
 	mutex_unlock(&tu->ioctl_lock);
 	return ret;
 }
@@ -2055,13 +2090,28 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on)
 static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 				   size_t count, loff_t *offset)
 {
+	struct snd_timer_tread64 *tread;
+	struct snd_timer_tread tread32;
 	struct snd_timer_user *tu;
 	long result = 0, unit;
 	int qhead;
 	int err = 0;
 
 	tu = file->private_data;
-	unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read);
+	switch (tu->tread) {
+	case TREAD_FORMAT_TIME64:
+		unit = sizeof(struct snd_timer_tread64);
+		break;
+	case TREAD_FORMAT_TIME32:
+		unit = sizeof(struct snd_timer_tread);
+		break;
+	case TREAD_FORMAT_NONE:
+		unit = sizeof(struct snd_timer_read);
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
 	mutex_lock(&tu->ioctl_lock);
 	spin_lock_irq(&tu->qlock);
 	while ((long)count - result >= unit) {
@@ -2100,14 +2150,36 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 		tu->qused--;
 		spin_unlock_irq(&tu->qlock);
 
-		if (tu->tread) {
-			if (copy_to_user(buffer, &tu->tqueue[qhead],
-					 sizeof(struct snd_timer_tread)))
+		tread = &tu->tqueue[qhead];
+
+		switch (tu->tread) {
+		case TREAD_FORMAT_TIME64:
+			if (copy_to_user(buffer, tread,
+					 sizeof(struct snd_timer_tread64)))
 				err = -EFAULT;
-		} else {
+			break;
+		case TREAD_FORMAT_TIME32:
+			memset(&tread32, 0, sizeof(tread32));
+			tread32 = (struct snd_timer_tread) {
+				.event = tread->event,
+				.tstamp = {
+					.tv_sec = tread->tstamp_sec,
+					.tv_nsec = tread->tstamp_nsec,
+				},
+				.val = tread->val,
+			};
+
+			if (copy_to_user(buffer, &tread32, sizeof(tread32)))
+				err = -EFAULT;
+			break;
+		case TREAD_FORMAT_NONE:
 			if (copy_to_user(buffer, &tu->queue[qhead],
 					 sizeof(struct snd_timer_read)))
 				err = -EFAULT;
+			break;
+		default:
+			err = -ENOTSUPP;
+			break;
 		}
 
 		spin_lock_irq(&tu->qlock);
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c
index 0495ede..bef7f87 100644
--- a/sound/core/timer_compat.c
+++ b/sound/core/timer_compat.c
@@ -111,7 +111,7 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
 	case SNDRV_TIMER_IOCTL_PAUSE:
 	case SNDRV_TIMER_IOCTL_PAUSE_OLD:
 	case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
-		return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
+		return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp, true);
 	case SNDRV_TIMER_IOCTL_GPARAMS32:
 		return snd_timer_user_gparams_compat(file, argp);
 	case SNDRV_TIMER_IOCTL_INFO32:
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 7/8] ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
                   ` (5 preceding siblings ...)
  2018-04-24 12:06 ` [PATCH 6/8] ALSA: Avoid using timespec for struct snd_timer_tread Baolin Wang
@ 2018-04-24 12:06 ` Baolin Wang
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

This is a preparation patch, moving the compat handler for
snd_pcm_ioctl_sync_ptr_compat from pcm_compat.c to pcm_native.c.
No other changes are indented.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 sound/core/pcm_compat.c |   98 ---------------------------------------------
 sound/core/pcm_native.c |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index a4ef13b..5ed30aa 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -102,19 +102,6 @@ struct snd_pcm_sw_params32 {
 	unsigned char reserved[56];
 };
 
-/* recalcuate the boundary within 32bit */
-static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime)
-{
-	snd_pcm_uframes_t boundary;
-
-	if (! runtime->buffer_size)
-		return 0;
-	boundary = runtime->buffer_size;
-	while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size)
-		boundary *= 2;
-	return boundary;
-}
-
 static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream,
 					  struct snd_pcm_sw_params32 __user *src)
 {
@@ -405,91 +392,6 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
 	return err;
 }
 
-
-struct snd_pcm_mmap_status32 {
-	s32 state;
-	s32 pad1;
-	u32 hw_ptr;
-	struct compat_timespec tstamp;
-	s32 suspended_state;
-	struct compat_timespec audio_tstamp;
-} __attribute__((packed));
-
-struct snd_pcm_mmap_control32 {
-	u32 appl_ptr;
-	u32 avail_min;
-};
-
-struct snd_pcm_sync_ptr32 {
-	u32 flags;
-	union {
-		struct snd_pcm_mmap_status32 status;
-		unsigned char reserved[64];
-	} s;
-	union {
-		struct snd_pcm_mmap_control32 control;
-		unsigned char reserved[64];
-	} c;
-} __attribute__((packed));
-
-static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
-					 struct snd_pcm_sync_ptr32 __user *src)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	volatile struct snd_pcm_mmap_status *status;
-	volatile struct snd_pcm_mmap_control *control;
-	u32 sflags;
-	struct snd_pcm_mmap_control scontrol;
-	struct snd_pcm_mmap_status sstatus;
-	snd_pcm_uframes_t boundary;
-	int err;
-
-	if (snd_BUG_ON(!runtime))
-		return -EINVAL;
-
-	if (get_user(sflags, &src->flags) ||
-	    get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
-	    get_user(scontrol.avail_min, &src->c.control.avail_min))
-		return -EFAULT;
-	if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) {
-		err = snd_pcm_hwsync(substream);
-		if (err < 0)
-			return err;
-	}
-	status = runtime->status;
-	control = runtime->control;
-	boundary = recalculate_boundary(runtime);
-	if (! boundary)
-		boundary = 0x7fffffff;
-	snd_pcm_stream_lock_irq(substream);
-	/* FIXME: we should consider the boundary for the sync from app */
-	if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
-		control->appl_ptr = scontrol.appl_ptr;
-	else
-		scontrol.appl_ptr = control->appl_ptr % boundary;
-	if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
-		control->avail_min = scontrol.avail_min;
-	else
-		scontrol.avail_min = control->avail_min;
-	sstatus.state = status->state;
-	sstatus.hw_ptr = status->hw_ptr % boundary;
-	sstatus.tstamp = status->tstamp;
-	sstatus.suspended_state = status->suspended_state;
-	sstatus.audio_tstamp = status->audio_tstamp;
-	snd_pcm_stream_unlock_irq(substream);
-	if (put_user(sstatus.state, &src->s.status.state) ||
-	    put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) ||
-	    compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) ||
-	    put_user(sstatus.suspended_state, &src->s.status.suspended_state) ||
-	    compat_put_timespec(&sstatus.audio_tstamp,
-		    &src->s.status.audio_tstamp) ||
-	    put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
-	    put_user(scontrol.avail_min, &src->c.control.avail_min))
-		return -EFAULT;
-
-	return 0;
-}
-
 #ifdef CONFIG_X86_X32
 /* X32 ABI has 64bit timespec and 64bit alignment */
 struct snd_pcm_mmap_status_x32 {
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 0c2ec6d..158e85d 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/compat.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/file.h>
@@ -2819,6 +2820,106 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+#ifdef CONFIG_COMPAT
+struct snd_pcm_mmap_status32 {
+	s32 state;
+	s32 pad1;
+	u32 hw_ptr;
+	struct compat_timespec tstamp;
+	s32 suspended_state;
+	struct compat_timespec audio_tstamp;
+} __attribute__((packed));
+
+struct snd_pcm_mmap_control32 {
+	u32 appl_ptr;
+	u32 avail_min;
+};
+
+struct snd_pcm_sync_ptr32 {
+	u32 flags;
+	union {
+		struct snd_pcm_mmap_status32 status;
+		unsigned char reserved[64];
+	} s;
+	union {
+		struct snd_pcm_mmap_control32 control;
+		unsigned char reserved[64];
+	} c;
+} __attribute__((packed));
+
+/* recalcuate the boundary within 32bit */
+static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime)
+{
+	snd_pcm_uframes_t boundary;
+
+	if (! runtime->buffer_size)
+		return 0;
+	boundary = runtime->buffer_size;
+	while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size)
+		boundary *= 2;
+	return boundary;
+}
+
+static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
+					 struct snd_pcm_sync_ptr32 __user *src)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	volatile struct snd_pcm_mmap_status *status;
+	volatile struct snd_pcm_mmap_control *control;
+	u32 sflags;
+	struct snd_pcm_mmap_control scontrol;
+	struct snd_pcm_mmap_status sstatus;
+	snd_pcm_uframes_t boundary;
+	int err;
+
+	if (snd_BUG_ON(!runtime))
+		return -EINVAL;
+
+	if (get_user(sflags, &src->flags) ||
+	    get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
+	    get_user(scontrol.avail_min, &src->c.control.avail_min))
+		return -EFAULT;
+	if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) {
+		err = snd_pcm_hwsync(substream);
+		if (err < 0)
+			return err;
+	}
+	status = runtime->status;
+	control = runtime->control;
+	boundary = recalculate_boundary(runtime);
+	if (! boundary)
+		boundary = 0x7fffffff;
+	snd_pcm_stream_lock_irq(substream);
+	/* FIXME: we should consider the boundary for the sync from app */
+	if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
+		control->appl_ptr = scontrol.appl_ptr;
+	else
+		scontrol.appl_ptr = control->appl_ptr % boundary;
+	if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
+		control->avail_min = scontrol.avail_min;
+	else
+		scontrol.avail_min = control->avail_min;
+	sstatus.state = status->state;
+	sstatus.hw_ptr = status->hw_ptr % boundary;
+	sstatus.tstamp = status->tstamp;
+	sstatus.suspended_state = status->suspended_state;
+	sstatus.audio_tstamp = status->audio_tstamp;
+	snd_pcm_stream_unlock_irq(substream);
+	if (put_user(sstatus.state, &src->s.status.state) ||
+	    put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) ||
+	    compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) ||
+	    put_user(sstatus.suspended_state, &src->s.status.suspended_state) ||
+	    compat_put_timespec(&sstatus.audio_tstamp,
+				&src->s.status.audio_tstamp) ||
+	    put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
+	    put_user(scontrol.avail_min, &src->c.control.avail_min))
+		return -EFAULT;
+
+	return 0;
+}
+#define __SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
+#endif
+
 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
                   ` (6 preceding siblings ...)
  2018-04-24 12:06 ` [PATCH 7/8] ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c Baolin Wang
@ 2018-04-24 12:06 ` Baolin Wang
  2018-04-24 13:27   ` Arnd Bergmann
                     ` (5 more replies)
  2018-04-24 13:29   ` Jaroslav Kysela
  2018-04-24 13:29   ` Arnd Bergmann
  9 siblings, 6 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-24 12:06 UTC (permalink / raw)
  To: perex, tiwai, arnd
  Cc: baolin.wang, lgirdwood, broonie, o-takashi, mingo, elfring,
	dan.carpenter, jeeja.kp, vinod.koul, guneshwor.o.singh,
	subhransu.s.prusty, bhumirks, gudishax.kranthikumar, naveen.m,
	hardik.t.shah, arvind.yadav.cs, fabf, alsa-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/uapi/sound/asound.h |   96 +++++++++++++++++++++++++++++++++++++++----
 sound/core/pcm_compat.c     |    9 ++--
 sound/core/pcm_lib.c        |   13 +++---
 sound/core/pcm_native.c     |   33 +++++++++------
 4 files changed, 120 insertions(+), 31 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index f368e80..18fbdcb 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -34,6 +34,8 @@
 #include <stdlib.h>
 #endif
 
+#include <asm/byteorder.h>
+
 /*
  *  protocol version
  */
@@ -300,7 +302,9 @@ enum {
 #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 */
@@ -316,8 +320,17 @@ enum {
 
 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 {
@@ -474,7 +487,22 @@ struct snd_pcm_status {
 	unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
 };
 
-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
+#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
+#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) */
@@ -483,7 +511,7 @@ struct snd_pcm_mmap_status {
 	struct 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 */
 };
@@ -492,14 +520,64 @@ 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;
+};
+
+struct __snd_timespec64 {
+	__s64 tv_sec;
+	__s64 tv_nsec;
+};
+
+#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;
 };
@@ -584,6 +662,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)
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 5ed30aa..51a9447 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -497,7 +497,6 @@ enum {
 	SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct snd_xferi32),
 	SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32),
 	SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32),
-	SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
 	SNDRV_PCM_IOCTL_STATUS_COMPAT64 = _IOR('A', 0x20, struct compat_snd_pcm_status64),
 	SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64 = _IOWR('A', 0x24, struct compat_snd_pcm_status64),
 #ifdef CONFIG_X86_X32
@@ -521,8 +520,8 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
 
 	/*
 	 * When PCM is used on 32bit mode, we need to disable
-	 * mmap of PCM status/control records because of the size
-	 * incompatibility.
+	 * mmap of the old PCM status/control records because
+	 * of the size incompatibility.
 	 */
 	pcm_file->no_compat_mmap = 1;
 
@@ -544,6 +543,8 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
 	case SNDRV_PCM_IOCTL_XRUN:
 	case SNDRV_PCM_IOCTL_LINK:
 	case SNDRV_PCM_IOCTL_UNLINK:
+	case __SNDRV_PCM_IOCTL_SYNC_PTR32:
+	case __SNDRV_PCM_IOCTL_SYNC_PTR64:
 		return snd_pcm_common_ioctl(file, substream, cmd, argp);
 	case SNDRV_PCM_IOCTL_HW_REFINE32:
 		return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
@@ -555,8 +556,6 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
 		return snd_pcm_status_user32(substream, argp, false);
 	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32:
 		return snd_pcm_status_user32(substream, argp, true);
-	case SNDRV_PCM_IOCTL_SYNC_PTR32:
-		return snd_pcm_ioctl_sync_ptr_compat(substream, argp);
 	case SNDRV_PCM_IOCTL_CHANNEL_INFO32:
 		return snd_pcm_ioctl_channel_info_compat(substream, argp);
 	case SNDRV_PCM_IOCTL_WRITEI_FRAMES32:
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 213f0e6..6d19e028 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -162,7 +162,8 @@ static void xrun(struct snd_pcm_substream *substream)
 		struct timespec64 tstamp;
 
 		snd_pcm_gettime(runtime, &tstamp);
-		runtime->status->tstamp = timespec64_to_timespec(tstamp);
+		runtime->status->tstamp.tv_sec = tstamp.tv_sec;
+		runtime->status->tstamp.tv_nsec = tstamp.tv_nsec;
 	}
 	snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
 	if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {
@@ -253,10 +254,12 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
 		*audio_tstamp = ns_to_timespec64(audio_nsecs);
 	}
 
-	if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
-		runtime->status->audio_tstamp =
-			timespec64_to_timespec(*audio_tstamp);
-		runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp);
+	if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec ||
+	    runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) {
+		runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec;
+		runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec;
+		runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec;
+		runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec;
 	}
 
 
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 158e85d..7bb14d5 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2820,7 +2820,6 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-#ifdef CONFIG_COMPAT
 struct snd_pcm_mmap_status32 {
 	s32 state;
 	s32 pad1;
@@ -2907,18 +2906,18 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
 	snd_pcm_stream_unlock_irq(substream);
 	if (put_user(sstatus.state, &src->s.status.state) ||
 	    put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) ||
-	    compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) ||
+	    put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp.tv_sec) ||
+	    put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp.tv_nsec) ||
 	    put_user(sstatus.suspended_state, &src->s.status.suspended_state) ||
-	    compat_put_timespec(&sstatus.audio_tstamp,
-				&src->s.status.audio_tstamp) ||
+	    put_user(sstatus.audio_tstamp.tv_sec, &src->s.status.audio_tstamp.tv_sec) ||
+	    put_user(sstatus.audio_tstamp.tv_nsec, &src->s.status.audio_tstamp.tv_nsec) ||
 	    put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
 	    put_user(scontrol.avail_min, &src->c.control.avail_min))
 		return -EFAULT;
 
 	return 0;
 }
-#define __SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
-#endif
+#define __SNDRV_PCM_IOCTL_SYNC_PTR32 _IOWR('A', 0x23, struct snd_pcm_sync_ptr32)
 
 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg)
 {
@@ -3092,7 +3091,9 @@ static int snd_pcm_common_ioctl(struct file *file,
 			return -EFAULT;
 		return 0;
 	}
-	case SNDRV_PCM_IOCTL_SYNC_PTR:
+	case __SNDRV_PCM_IOCTL_SYNC_PTR32:
+		return snd_pcm_ioctl_sync_ptr_compat(substream, arg);
+	case __SNDRV_PCM_IOCTL_SYNC_PTR64:
 		return snd_pcm_sync_ptr(substream, arg);
 #ifdef CONFIG_SND_SUPPORT_OLD_API
 	case SNDRV_PCM_IOCTL_HW_REFINE_OLD:
@@ -3472,8 +3473,6 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file
 
 static bool pcm_status_mmap_allowed(struct snd_pcm_file *pcm_file)
 {
-	if (pcm_file->no_compat_mmap)
-		return false;
 	/* See pcm_control_mmap_allowed() below.
 	 * Since older alsa-lib requires both status and control mmaps to be
 	 * coupled, we have to disable the status mmap for old alsa-lib, too.
@@ -3686,11 +3685,19 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area)
 
 	offset = area->vm_pgoff << PAGE_SHIFT;
 	switch (offset) {
-	case SNDRV_PCM_MMAP_OFFSET_STATUS:
+	case SNDRV_PCM_MMAP_OFFSET_STATUS_OLD:
+		if (pcm_file->no_compat_mmap || !IS_ENABLED(CONFIG_64BIT))
+			return -ENXIO;
+		/* fallthrough */
+	case SNDRV_PCM_MMAP_OFFSET_STATUS_NEW:
 		if (!pcm_status_mmap_allowed(pcm_file))
 			return -ENXIO;
 		return snd_pcm_mmap_status(substream, file, area);
-	case SNDRV_PCM_MMAP_OFFSET_CONTROL:
+	case SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD:
+		if (pcm_file->no_compat_mmap || !IS_ENABLED(CONFIG_64BIT))
+			return -ENXIO;
+		/* fallthrough */
+	case SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW:
 		if (!pcm_control_mmap_allowed(pcm_file))
 			return -ENXIO;
 		return snd_pcm_mmap_control(substream, file, area);
@@ -3850,9 +3857,9 @@ static unsigned long snd_pcm_get_unmapped_area(struct file *file,
 	unsigned long offset = pgoff << PAGE_SHIFT;
 
 	switch (offset) {
-	case SNDRV_PCM_MMAP_OFFSET_STATUS:
+	case SNDRV_PCM_MMAP_OFFSET_STATUS_NEW:
 		return (unsigned long)runtime->status;
-	case SNDRV_PCM_MMAP_OFFSET_CONTROL:
+	case SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW:
 		return (unsigned long)runtime->control;
 	default:
 		return (unsigned long)runtime->dma_area + offset;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
@ 2018-04-24 13:27   ` Arnd Bergmann
  2018-04-26  3:07     ` kbuild test robot
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-24 13:27 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

On Tue, Apr 24, 2018 at 2:06 PM, Baolin Wang <baolin.wang@linaro.org> wrote:

> @@ -544,6 +543,8 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
>         case SNDRV_PCM_IOCTL_XRUN:
>         case SNDRV_PCM_IOCTL_LINK:
>         case SNDRV_PCM_IOCTL_UNLINK:
> +       case __SNDRV_PCM_IOCTL_SYNC_PTR32:
> +       case __SNDRV_PCM_IOCTL_SYNC_PTR64:
>                 return snd_pcm_common_ioctl(file, substream, cmd, argp);
>         case SNDRV_PCM_IOCTL_HW_REFINE32:
>                 return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
> @@ -555,8 +556,6 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
>                 return snd_pcm_status_user32(substream, argp, false);
>         case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32:
>                 return snd_pcm_status_user32(substream, argp, true);
> -       case SNDRV_PCM_IOCTL_SYNC_PTR32:
> -               return snd_pcm_ioctl_sync_ptr_compat(substream, argp);
>         case SNDRV_PCM_IOCTL_CHANNEL_INFO32:
>                 return snd_pcm_ioctl_channel_info_compat(substream, argp);
>         case SNDRV_PCM_IOCTL_WRITEI_FRAMES32:

I found a bug here while doing some more testing on my own patch:
__SNDRV_PCM_IOCTL_SYNC_PTR64 has the same value as
SNDRV_PCM_IOCTL_SYNC_PTR_X32, so we get a duplicate case
error when CONFIG_X86_X32 is enabled. We still need both handlers,
so the fix I came up with is:

diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 51a9447442f3..dbeeae50fb8d 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -543,8 +543,13 @@ static long snd_pcm_ioctl_compat(struct file
*file, unsigned int cmd, unsigned l
        case SNDRV_PCM_IOCTL_XRUN:
        case SNDRV_PCM_IOCTL_LINK:
        case SNDRV_PCM_IOCTL_UNLINK:
-       case __SNDRV_PCM_IOCTL_SYNC_PTR32:
        case __SNDRV_PCM_IOCTL_SYNC_PTR64:
+#ifdef CONFIG_X86_X32
+               if (in_x32_syscall())
+                       return snd_pcm_ioctl_sync_ptr_x32(substream, argp);
+               /* fallthru */
+#endif /* CONFIG_X86_X32 */
+       case __SNDRV_PCM_IOCTL_SYNC_PTR32:
                return snd_pcm_common_ioctl(file, substream, cmd, argp);
        case SNDRV_PCM_IOCTL_HW_REFINE32:
                return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
@@ -577,8 +582,6 @@ static long snd_pcm_ioctl_compat(struct file
*file, unsigned int cmd, unsigned l
        case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64:
                return snd_pcm_status_user_compat64(substream, argp, true);
 #ifdef CONFIG_X86_X32
-       case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
-               return snd_pcm_ioctl_sync_ptr_x32(substream, argp);
        case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32:
                return snd_pcm_ioctl_channel_info_x32(substream, argp);
 #endif /* CONFIG_X86_X32 */

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
@ 2018-04-24 13:29   ` Jaroslav Kysela
  2018-04-24 12:06   ` Baolin Wang
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Jaroslav Kysela @ 2018-04-24 13:29 UTC (permalink / raw)
  To: Baolin Wang, tiwai, arnd
  Cc: lgirdwood, broonie, o-takashi, mingo, elfring, dan.carpenter,
	jeeja.kp, vinod.koul, guneshwor.o.singh, subhransu.s.prusty,
	bhumirks, gudishax.kranthikumar, naveen.m, hardik.t.shah,
	arvind.yadav.cs, fabf, alsa-devel, linux-kernel

Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
> Since many structures will use timespec type variables to record time stamp
> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
> tries to introduce new structures removing timespec type to compatible native
> mode and compat mode.
> 
> Moreover this patchset also converts the internal structrures to use timespec64
> type and related APIs.

Thanks for your patchset. A few comments:

It might be more nice to reuse the existing structures and put
timespec64 to the reserved field and duplicate information (with the
32-bit wrapping for the old fields). It means that we do not need new
ioctls and old libraries will be fine.

It may make sense to define private snd_timespec32 and snd_timespec64
with s32/s64 types instead separate sec/usec fields.

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
@ 2018-04-24 13:29   ` Jaroslav Kysela
  0 siblings, 0 replies; 48+ messages in thread
From: Jaroslav Kysela @ 2018-04-24 13:29 UTC (permalink / raw)
  To: Baolin Wang, tiwai, arnd
  Cc: fabf, arvind.yadav.cs, linux-kernel, alsa-devel, vinod.koul,
	hardik.t.shah, guneshwor.o.singh, lgirdwood, elfring,
	gudishax.kranthikumar, broonie, bhumirks, naveen.m, jeeja.kp,
	o-takashi, subhransu.s.prusty, mingo, dan.carpenter

Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
> Since many structures will use timespec type variables to record time stamp
> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
> tries to introduce new structures removing timespec type to compatible native
> mode and compat mode.
> 
> Moreover this patchset also converts the internal structrures to use timespec64
> type and related APIs.

Thanks for your patchset. A few comments:

It might be more nice to reuse the existing structures and put
timespec64 to the reserved field and duplicate information (with the
32-bit wrapping for the old fields). It means that we do not need new
ioctls and old libraries will be fine.

It may make sense to define private snd_timespec32 and snd_timespec64
with s32/s64 types instead separate sec/usec fields.

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
@ 2018-04-24 13:29   ` Arnd Bergmann
  2018-04-24 12:06   ` Baolin Wang
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-24 13:29 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

On Tue, Apr 24, 2018 at 2:06 PM, Baolin Wang <baolin.wang@linaro.org> wrote:
> Since many structures will use timespec type variables to record time stamp
> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
> tries to introduce new structures removing timespec type to compatible native
> mode and compat mode.
>
> Moreover this patchset also converts the internal structrures to use timespec64
> type and related APIs.
>
> Arnd Bergmann (2):
>   ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
>   ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
>
> Baolin Wang (6):
>   ALSA: Replace timespec with timespec64
>   ALSA: Avoid using timespec for struct snd_timer_status
>   ALSA: Avoid using timespec for struct snd_ctl_elem_value
>   ALSA: Avoid using timespec for struct snd_pcm_status
>   ALSA: Avoid using timespec for struct snd_rawmidi_status
>   ALSA: Avoid using timespec for struct snd_timer_tread

Thanks a lot for picking this up again and including my two patches!

I've done a private review yesterday, but will have another look either
today or tomorrow to see if I missed anything. I've also applied the
series to my randconfig build tree and will see if that finds any new
bugs. The builder has already found a bug in one of my two patches,
so there might be more.

      Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
@ 2018-04-24 13:29   ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-24 13:29 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Fabian Frederick, Arvind Yadav, Linux Kernel Mailing List,
	alsa-devel, Vinod Koul, hardik.t.shah, Takashi Iwai,
	Guneshwor Singh, Liam Girdwood, Takashi Sakamoto,
	gudishax.kranthikumar, Mark Brown, Bhumika Goyal, Naveen M,
	SF Markus Elfring, jeeja.kp, subhransu.s.prusty, Ingo Molnar,
	Dan Carpenter

On Tue, Apr 24, 2018 at 2:06 PM, Baolin Wang <baolin.wang@linaro.org> wrote:
> Since many structures will use timespec type variables to record time stamp
> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
> tries to introduce new structures removing timespec type to compatible native
> mode and compat mode.
>
> Moreover this patchset also converts the internal structrures to use timespec64
> type and related APIs.
>
> Arnd Bergmann (2):
>   ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
>   ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
>
> Baolin Wang (6):
>   ALSA: Replace timespec with timespec64
>   ALSA: Avoid using timespec for struct snd_timer_status
>   ALSA: Avoid using timespec for struct snd_ctl_elem_value
>   ALSA: Avoid using timespec for struct snd_pcm_status
>   ALSA: Avoid using timespec for struct snd_rawmidi_status
>   ALSA: Avoid using timespec for struct snd_timer_tread

Thanks a lot for picking this up again and including my two patches!

I've done a private review yesterday, but will have another look either
today or tomorrow to see if I missed anything. I've also applied the
series to my randconfig build tree and will see if that finds any new
bugs. The builder has already found a bug in one of my two patches,
so there might be more.

      Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-24 13:29   ` Jaroslav Kysela
@ 2018-04-24 13:37     ` Arnd Bergmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-24 13:37 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Baolin Wang, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

On Tue, Apr 24, 2018 at 3:29 PM, Jaroslav Kysela <perex@perex.cz> wrote:
> Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
>> Since many structures will use timespec type variables to record time stamp
>> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
>> tries to introduce new structures removing timespec type to compatible native
>> mode and compat mode.
>>
>> Moreover this patchset also converts the internal structrures to use timespec64
>> type and related APIs.
>
> Thanks for your patchset. A few comments:
>
> It might be more nice to reuse the existing structures and put
> timespec64 to the reserved field and duplicate information (with the
> 32-bit wrapping for the old fields). It means that we do not need new
> ioctls and old libraries will be fine.

The current approach is intended to make any user space work
without source-level changes, i.e. you can still build an old alsa-lib
package against a new glibc as long as you have the latest kernel
headers (which the glibc requires for using 64-bit time_t).

If we try to extend the structures in a different way, that requires
user space changes, and existing source code would silently
break on a future glibc.
IMHO changing the source-level interface should only be done
as a last resort for y2038.

Note that most of the work is not required to keep working beyond
2038, but actually is required just to keep working with an
updated glibc that redefines time_t to 64 bit. The audio timestamps
should be in CLOCK_MONOTONIC for new user space anyway,
and that doesn't overflow a 32-bit type.

> It may make sense to define private snd_timespec32 and snd_timespec64
> with s32/s64 types instead separate sec/usec fields.

Right, I have some ideas there as well as I saw one remaining issue
in my patch for the status mmap: when building a program with
64-bit time_t, we still see a copy of the old structure but with an\
impossible layout.

       ARnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
@ 2018-04-24 13:37     ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-24 13:37 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Fabian Frederick, Arvind Yadav, Linux Kernel Mailing List,
	alsa-devel, Baolin Wang, Vinod Koul, hardik.t.shah, Takashi Iwai,
	Guneshwor Singh, Liam Girdwood, Takashi Sakamoto,
	gudishax.kranthikumar, Mark Brown, Bhumika Goyal, Naveen M,
	SF Markus Elfring, jeeja.kp, subhransu.s.prusty, Ingo Molnar,
	Dan Carpenter

On Tue, Apr 24, 2018 at 3:29 PM, Jaroslav Kysela <perex@perex.cz> wrote:
> Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
>> Since many structures will use timespec type variables to record time stamp
>> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
>> tries to introduce new structures removing timespec type to compatible native
>> mode and compat mode.
>>
>> Moreover this patchset also converts the internal structrures to use timespec64
>> type and related APIs.
>
> Thanks for your patchset. A few comments:
>
> It might be more nice to reuse the existing structures and put
> timespec64 to the reserved field and duplicate information (with the
> 32-bit wrapping for the old fields). It means that we do not need new
> ioctls and old libraries will be fine.

The current approach is intended to make any user space work
without source-level changes, i.e. you can still build an old alsa-lib
package against a new glibc as long as you have the latest kernel
headers (which the glibc requires for using 64-bit time_t).

If we try to extend the structures in a different way, that requires
user space changes, and existing source code would silently
break on a future glibc.
IMHO changing the source-level interface should only be done
as a last resort for y2038.

Note that most of the work is not required to keep working beyond
2038, but actually is required just to keep working with an
updated glibc that redefines time_t to 64 bit. The audio timestamps
should be in CLOCK_MONOTONIC for new user space anyway,
and that doesn't overflow a 32-bit type.

> It may make sense to define private snd_timespec32 and snd_timespec64
> with s32/s64 types instead separate sec/usec fields.

Right, I have some ideas there as well as I saw one remaining issue
in my patch for the status mmap: when building a program with
64-bit time_t, we still see a copy of the old structure but with an\
impossible layout.

       ARnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-24 13:37     ` Arnd Bergmann
  (?)
@ 2018-04-25  7:23     ` Jaroslav Kysela
  2018-04-25 11:26       ` Arnd Bergmann
  -1 siblings, 1 reply; 48+ messages in thread
From: Jaroslav Kysela @ 2018-04-25  7:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Baolin Wang, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

Dne 24.4.2018 v 15:37 Arnd Bergmann napsal(a):
> On Tue, Apr 24, 2018 at 3:29 PM, Jaroslav Kysela <perex@perex.cz> wrote:
>> Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
>>> Since many structures will use timespec type variables to record time stamp
>>> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
>>> tries to introduce new structures removing timespec type to compatible native
>>> mode and compat mode.
>>>
>>> Moreover this patchset also converts the internal structrures to use timespec64
>>> type and related APIs.
>>
>> Thanks for your patchset. A few comments:
>>
>> It might be more nice to reuse the existing structures and put
>> timespec64 to the reserved field and duplicate information (with the
>> 32-bit wrapping for the old fields). It means that we do not need new
>> ioctls and old libraries will be fine.
> 
> The current approach is intended to make any user space work
> without source-level changes, i.e. you can still build an old alsa-lib
> package against a new glibc as long as you have the latest kernel
> headers (which the glibc requires for using 64-bit time_t).
> 
> If we try to extend the structures in a different way, that requires
> user space changes, and existing source code would silently
> break on a future glibc.
> IMHO changing the source-level interface should only be done
> as a last resort for y2038.

We have almost everything hidden in the alsa-lib code for the
applications and there is the protocol versioning, so we can detect the
changes easily and handle the new fields in the library. As you noted,
the current code will be fine until 2038 even with my proposed change
(which is more easy to be implemented in the kernel - less bloat) and
there are 20 years to update alsa-lib remaining for the 32-bit systems.

Only the binary compatibility for the older binaries should be taken
into account.

Also, you expect that tv_nsec will be changed to the 's64' type. Do you
have that confirmed from the glibc developers? From the current
specification, the tv_nsec type is 'long'. It may cause some binary
compatibility issues, too.

				Thanks,
					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-25  7:23     ` Jaroslav Kysela
@ 2018-04-25 11:26       ` Arnd Bergmann
  2018-04-25 11:56         ` Mark Brown
  0 siblings, 1 reply; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-25 11:26 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Baolin Wang, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

On Wed, Apr 25, 2018 at 9:23 AM, Jaroslav Kysela <perex@perex.cz> wrote:
> Dne 24.4.2018 v 15:37 Arnd Bergmann napsal(a):
>> On Tue, Apr 24, 2018 at 3:29 PM, Jaroslav Kysela <perex@perex.cz> wrote:
>>> Dne 24.4.2018 v 14:06 Baolin Wang napsal(a):
>>>> Since many structures will use timespec type variables to record time stamp
>>>> in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
>>>> tries to introduce new structures removing timespec type to compatible native
>>>> mode and compat mode.
>>>>
>>>> Moreover this patchset also converts the internal structrures to use timespec64
>>>> type and related APIs.
>>>
>>> Thanks for your patchset. A few comments:
>>>
>>> It might be more nice to reuse the existing structures and put
>>> timespec64 to the reserved field and duplicate information (with the
>>> 32-bit wrapping for the old fields). It means that we do not need new
>>> ioctls and old libraries will be fine.
>>
>> The current approach is intended to make any user space work
>> without source-level changes, i.e. you can still build an old alsa-lib
>> package against a new glibc as long as you have the latest kernel
>> headers (which the glibc requires for using 64-bit time_t).
>>
>> If we try to extend the structures in a different way, that requires
>> user space changes, and existing source code would silently
>> break on a future glibc.
>> IMHO changing the source-level interface should only be done
>> as a last resort for y2038.
>
> We have almost everything hidden in the alsa-lib code for the
> applications and there is the protocol versioning, so we can detect the
> changes easily and handle the new fields in the library.

I think we are both misunderstanding each other here, let's try
to work out what changes are required in alsa-lib. The idea of
Baolin's patches that you can simply rebuild alsa-lib (or any other
library using the alsa kernel interface, if any exist) against a new
C library and still have working audio.

Unfortunately I had not looked at the alsa-lib source code before,
so I missed the fact that it uses its own copy of the kernel headers,
and that it also defines an incompatible 'timespec' structure itself,
so it seems it's not as easy.

The earlier patches that Baolin posted last November tried to
work with unmodified kernel headers, which would have avoided
breaking alsa-lib, but after discussing with Takashi, Baolin simplified
them to remove the special cases for i386 structure alignment,
and I added back the support for mmap(), which did not work
in the original series, and is impossible without updating at least
the header file.

> As you noted,
> the current code will be fine until 2038 even with my proposed change
> (which is more easy to be implemented in the kernel - less bloat) and
> there are 20 years to update alsa-lib remaining for the 32-bit systems.

I did not claim that it works fine -- in fact the current state is
completely broken once you upgrade your glibc. What I meant is that
there is no *overflow* of time_t as long as user space enforces the
use of monotonic timestamps.

>From what I can tell, we have to fix these areas:

1. The kernel-internal interfaces in ALSA should be changed to avoid
     using 'struct timespec' and use something else (nanoseconds,
     ktime_t, timespec64, ...) so we can completely remove timespec
     from the kernel for everything other than compatibility with old
     user space.
2. alsa-lib must be changed to no longer define a 'struct timespec'
    that is incompatible with the C library, to avoid silently breaking
    ABIs between structures used inside alsa-lib and those in
    code using alsa-lib with a 64-bit time_t.
3. We must create a change to either alsa-lib (and every other
    implementation) or the kernel (including the uapi header) to
    avoid breaking SNDRV_TIMER_IOCTL_TREAD, which
    currently expects a 'timespec' to be read from a file descriptor
4. on 32-bit x86 and powerpc, we need to do something about
    about the mmap() for status and control structures to
    avoid breaking. My current patch implements a new binary
    layout to avoid most problems, including the issue of compat
    mode that never worked.
5. For all other ioctls we have the choice between fixing the
    kernel to provide an interface that is compatible with
    a future glibc, or to change the uapi header to move away
    from timespec to a structure with a different name but
    same binary layout and have alsa-lib convert between the
    two. I still see Baolin's series as preferred because it matches
    what we do for all other subsytems, implementing the
    native ioctls using the 64-bit version of timespec that
    match what the both kernel and future glibc use, and only
    providing the 32-bit interfaces for compatibility with existing
    binaries.
6. For completeness, it might be helpful to have alsa-lib
    use symbol versioning for each exported API so a
    single alsa-lib binary can work with both 32-bit time_t
    and 64-bit time_t using applications. Without this, everything
    will still keep working as long as you rebuild the entire
    distro with 64-bit time_t at once, but it won't allow a gradual
    migration of applications.

> Only the binary compatibility for the older binaries should be taken
> into account.
>
> Also, you expect that tv_nsec will be changed to the 's64' type. Do you
> have that confirmed from the glibc developers? From the current
> specification, the tv_nsec type is 'long'. It may cause some binary
> compatibility issues, too.

This is a complex sub-topic. Yes, we've had long discussions with the
glibc developers about it. glibc (and any other C99 compliant C
library) will use 'long' for tv_nsec, but they also have to use padding
after (or before, depending on endianess) tv_nsec to ensure that
the binary layout of timespec matches what we use in a 64-bit kernel.

For timestamps sent from the kernel to user space, we must initialize
the upper 32 bits of tv_nsec even on 32-bit kernels to avoid leaking
kernel stack data in the padding bits, so all interfaces are defined
in terms of __s64/__s64 rather than __s64/long timespec structures,
while both the kernel and user space use __s64/long internally.

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 0/8] Fix year 2038 issue for sound subsystem
  2018-04-25 11:26       ` Arnd Bergmann
@ 2018-04-25 11:56         ` Mark Brown
  0 siblings, 0 replies; 48+ messages in thread
From: Mark Brown @ 2018-04-25 11:56 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jaroslav Kysela, Baolin Wang, Takashi Iwai, Liam Girdwood,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

On Wed, Apr 25, 2018 at 01:26:23PM +0200, Arnd Bergmann wrote:
> On Wed, Apr 25, 2018 at 9:23 AM, Jaroslav Kysela <perex@perex.cz> wrote:

> > We have almost everything hidden in the alsa-lib code for the
> > applications and there is the protocol versioning, so we can detect the
> > changes easily and handle the new fields in the library.

> I think we are both misunderstanding each other here, let's try
> to work out what changes are required in alsa-lib. The idea of
> Baolin's patches that you can simply rebuild alsa-lib (or any other
> library using the alsa kernel interface, if any exist) against a new
> C library and still have working audio.

It's probably also worth mentioning that there are userspaces that don't
use alsa-lib at all, at least tinyalsa and salsa (if anyone still uses
salsa).

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
@ 2018-04-26  3:07     ` kbuild test robot
  2018-04-26  3:07     ` kbuild test robot
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  3:07 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2002 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: i386-randconfig-n0-201816 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

>> sound/core/pcm_native.c:2827:25: error: field 'tstamp' has incomplete type
     struct compat_timespec tstamp;
                            ^~~~~~
>> sound/core/pcm_native.c:2829:25: error: field 'audio_tstamp' has incomplete type
     struct compat_timespec audio_tstamp;
                            ^~~~~~~~~~~~

vim +/tstamp +2827 sound/core/pcm_native.c

^1da177e Linus Torvalds 2005-04-16  2822  
28282c58 Arnd Bergmann  2018-04-24  2823  struct snd_pcm_mmap_status32 {
28282c58 Arnd Bergmann  2018-04-24  2824  	s32 state;
28282c58 Arnd Bergmann  2018-04-24  2825  	s32 pad1;
28282c58 Arnd Bergmann  2018-04-24  2826  	u32 hw_ptr;
28282c58 Arnd Bergmann  2018-04-24 @2827  	struct compat_timespec tstamp;
28282c58 Arnd Bergmann  2018-04-24  2828  	s32 suspended_state;
28282c58 Arnd Bergmann  2018-04-24 @2829  	struct compat_timespec audio_tstamp;
28282c58 Arnd Bergmann  2018-04-24  2830  } __attribute__((packed));
28282c58 Arnd Bergmann  2018-04-24  2831  

:::::: The code at line 2827 was first introduced by commit
:::::: 28282c58cc57dade81f0f5c5a310647a10bd17c3 ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c

:::::: TO: Arnd Bergmann <arnd@arndb.de>
:::::: CC: 0day robot <fengguang.wu@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29340 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26  3:07     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  3:07 UTC (permalink / raw)
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2002 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: i386-randconfig-n0-201816 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

>> sound/core/pcm_native.c:2827:25: error: field 'tstamp' has incomplete type
     struct compat_timespec tstamp;
                            ^~~~~~
>> sound/core/pcm_native.c:2829:25: error: field 'audio_tstamp' has incomplete type
     struct compat_timespec audio_tstamp;
                            ^~~~~~~~~~~~

vim +/tstamp +2827 sound/core/pcm_native.c

^1da177e Linus Torvalds 2005-04-16  2822  
28282c58 Arnd Bergmann  2018-04-24  2823  struct snd_pcm_mmap_status32 {
28282c58 Arnd Bergmann  2018-04-24  2824  	s32 state;
28282c58 Arnd Bergmann  2018-04-24  2825  	s32 pad1;
28282c58 Arnd Bergmann  2018-04-24  2826  	u32 hw_ptr;
28282c58 Arnd Bergmann  2018-04-24 @2827  	struct compat_timespec tstamp;
28282c58 Arnd Bergmann  2018-04-24  2828  	s32 suspended_state;
28282c58 Arnd Bergmann  2018-04-24 @2829  	struct compat_timespec audio_tstamp;
28282c58 Arnd Bergmann  2018-04-24  2830  } __attribute__((packed));
28282c58 Arnd Bergmann  2018-04-24  2831  

:::::: The code at line 2827 was first introduced by commit
:::::: 28282c58cc57dade81f0f5c5a310647a10bd17c3 ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c

:::::: TO: Arnd Bergmann <arnd@arndb.de>
:::::: CC: 0day robot <fengguang.wu@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29340 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
@ 2018-04-26  6:20     ` kbuild test robot
  2018-04-26  3:07     ` kbuild test robot
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  6:20 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 7165 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: x86_64-acpi-redef (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
>> sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~

vim +580 sound/core/pcm_compat.c

^1da177e Linus Torvalds 2005-04-16  507  
^1da177e Linus Torvalds 2005-04-16  508  static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
^1da177e Linus Torvalds 2005-04-16  509  {
877211f5 Takashi Iwai   2005-11-17  510  	struct snd_pcm_file *pcm_file;
877211f5 Takashi Iwai   2005-11-17  511  	struct snd_pcm_substream *substream;
^1da177e Linus Torvalds 2005-04-16  512  	void __user *argp = compat_ptr(arg);
^1da177e Linus Torvalds 2005-04-16  513  
^1da177e Linus Torvalds 2005-04-16  514  	pcm_file = file->private_data;
^1da177e Linus Torvalds 2005-04-16  515  	if (! pcm_file)
^1da177e Linus Torvalds 2005-04-16  516  		return -ENOTTY;
^1da177e Linus Torvalds 2005-04-16  517  	substream = pcm_file->substream;
^1da177e Linus Torvalds 2005-04-16  518  	if (! substream)
^1da177e Linus Torvalds 2005-04-16  519  		return -ENOTTY;
^1da177e Linus Torvalds 2005-04-16  520  
^1da177e Linus Torvalds 2005-04-16  521  	/*
^1da177e Linus Torvalds 2005-04-16  522  	 * When PCM is used on 32bit mode, we need to disable
53cdcc38 Arnd Bergmann  2018-04-24  523  	 * mmap of the old PCM status/control records because
53cdcc38 Arnd Bergmann  2018-04-24  524  	 * of the size incompatibility.
^1da177e Linus Torvalds 2005-04-16  525  	 */
548a648b Takashi Iwai   2006-07-31  526  	pcm_file->no_compat_mmap = 1;
^1da177e Linus Torvalds 2005-04-16  527  
^1da177e Linus Torvalds 2005-04-16  528  	switch (cmd) {
^1da177e Linus Torvalds 2005-04-16  529  	case SNDRV_PCM_IOCTL_PVERSION:
^1da177e Linus Torvalds 2005-04-16  530  	case SNDRV_PCM_IOCTL_INFO:
5a7f2619 Takashi Iwai   2007-12-17  531  	case SNDRV_PCM_IOCTL_TSTAMP:
6b587ef9 Takashi Iwai   2007-12-14  532  	case SNDRV_PCM_IOCTL_TTSTAMP:
4b671f57 Takashi Iwai   2017-06-19  533  	case SNDRV_PCM_IOCTL_USER_PVERSION:
^1da177e Linus Torvalds 2005-04-16  534  	case SNDRV_PCM_IOCTL_HWSYNC:
^1da177e Linus Torvalds 2005-04-16  535  	case SNDRV_PCM_IOCTL_PREPARE:
^1da177e Linus Torvalds 2005-04-16  536  	case SNDRV_PCM_IOCTL_RESET:
^1da177e Linus Torvalds 2005-04-16  537  	case SNDRV_PCM_IOCTL_START:
^1da177e Linus Torvalds 2005-04-16  538  	case SNDRV_PCM_IOCTL_DROP:
^1da177e Linus Torvalds 2005-04-16  539  	case SNDRV_PCM_IOCTL_DRAIN:
^1da177e Linus Torvalds 2005-04-16  540  	case SNDRV_PCM_IOCTL_PAUSE:
^1da177e Linus Torvalds 2005-04-16  541  	case SNDRV_PCM_IOCTL_HW_FREE:
^1da177e Linus Torvalds 2005-04-16  542  	case SNDRV_PCM_IOCTL_RESUME:
^1da177e Linus Torvalds 2005-04-16  543  	case SNDRV_PCM_IOCTL_XRUN:
^1da177e Linus Torvalds 2005-04-16  544  	case SNDRV_PCM_IOCTL_LINK:
^1da177e Linus Torvalds 2005-04-16  545  	case SNDRV_PCM_IOCTL_UNLINK:
53cdcc38 Arnd Bergmann  2018-04-24  546  	case __SNDRV_PCM_IOCTL_SYNC_PTR32:
53cdcc38 Arnd Bergmann  2018-04-24  547  	case __SNDRV_PCM_IOCTL_SYNC_PTR64:
67616fed Takashi Iwai   2017-08-30  548  		return snd_pcm_common_ioctl(file, substream, cmd, argp);
^1da177e Linus Torvalds 2005-04-16  549  	case SNDRV_PCM_IOCTL_HW_REFINE32:
^1da177e Linus Torvalds 2005-04-16  550  		return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
^1da177e Linus Torvalds 2005-04-16  551  	case SNDRV_PCM_IOCTL_HW_PARAMS32:
^1da177e Linus Torvalds 2005-04-16  552  		return snd_pcm_ioctl_hw_params_compat(substream, 0, argp);
^1da177e Linus Torvalds 2005-04-16  553  	case SNDRV_PCM_IOCTL_SW_PARAMS32:
^1da177e Linus Torvalds 2005-04-16  554  		return snd_pcm_ioctl_sw_params_compat(substream, argp);
de41e437 Baolin Wang    2018-04-24  555  	case SNDRV_PCM_IOCTL_STATUS_COMPAT32:
de41e437 Baolin Wang    2018-04-24  556  		return snd_pcm_status_user32(substream, argp, false);
de41e437 Baolin Wang    2018-04-24  557  	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32:
de41e437 Baolin Wang    2018-04-24  558  		return snd_pcm_status_user32(substream, argp, true);
^1da177e Linus Torvalds 2005-04-16  559  	case SNDRV_PCM_IOCTL_CHANNEL_INFO32:
^1da177e Linus Torvalds 2005-04-16  560  		return snd_pcm_ioctl_channel_info_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  561  	case SNDRV_PCM_IOCTL_WRITEI_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  562  		return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp);
^1da177e Linus Torvalds 2005-04-16  563  	case SNDRV_PCM_IOCTL_READI_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  564  		return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp);
^1da177e Linus Torvalds 2005-04-16  565  	case SNDRV_PCM_IOCTL_WRITEN_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  566  		return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp);
^1da177e Linus Torvalds 2005-04-16  567  	case SNDRV_PCM_IOCTL_READN_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  568  		return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp);
^1da177e Linus Torvalds 2005-04-16  569  	case SNDRV_PCM_IOCTL_DELAY32:
^1da177e Linus Torvalds 2005-04-16  570  		return snd_pcm_ioctl_delay_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  571  	case SNDRV_PCM_IOCTL_REWIND32:
^1da177e Linus Torvalds 2005-04-16  572  		return snd_pcm_ioctl_rewind_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  573  	case SNDRV_PCM_IOCTL_FORWARD32:
^1da177e Linus Torvalds 2005-04-16  574  		return snd_pcm_ioctl_forward_compat(substream, argp);
de41e437 Baolin Wang    2018-04-24  575  	case SNDRV_PCM_IOCTL_STATUS_COMPAT64:
de41e437 Baolin Wang    2018-04-24  576  		return snd_pcm_status_user_compat64(substream, argp, false);
de41e437 Baolin Wang    2018-04-24  577  	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64:
de41e437 Baolin Wang    2018-04-24  578  		return snd_pcm_status_user_compat64(substream, argp, true);
513ace79 Takashi Iwai   2016-02-28  579  #ifdef CONFIG_X86_X32
513ace79 Takashi Iwai   2016-02-28 @580  	case SNDRV_PCM_IOCTL_SYNC_PTR_X32:

:::::: The code at line 580 was first introduced by commit
:::::: 513ace79b657e2022a592e77f24074e088681ecc ALSA: pcm: Fix ioctls for X32 ABI

:::::: TO: Takashi Iwai <tiwai@suse.de>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30366 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26  6:20     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  6:20 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, jeeja.kp, elfring, linux-kernel, vinod.koul,
	guneshwor.o.singh, mingo, gudishax.kranthikumar, arvind.yadav.cs,
	subhransu.s.prusty, dan.carpenter, arnd, hardik.t.shah, fabf,
	broonie, naveen.m, baolin.wang, lgirdwood, o-takashi, kbuild-all,
	bhumirks

[-- Attachment #1: Type: text/plain, Size: 7165 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: x86_64-acpi-redef (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
>> sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~

vim +580 sound/core/pcm_compat.c

^1da177e Linus Torvalds 2005-04-16  507  
^1da177e Linus Torvalds 2005-04-16  508  static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
^1da177e Linus Torvalds 2005-04-16  509  {
877211f5 Takashi Iwai   2005-11-17  510  	struct snd_pcm_file *pcm_file;
877211f5 Takashi Iwai   2005-11-17  511  	struct snd_pcm_substream *substream;
^1da177e Linus Torvalds 2005-04-16  512  	void __user *argp = compat_ptr(arg);
^1da177e Linus Torvalds 2005-04-16  513  
^1da177e Linus Torvalds 2005-04-16  514  	pcm_file = file->private_data;
^1da177e Linus Torvalds 2005-04-16  515  	if (! pcm_file)
^1da177e Linus Torvalds 2005-04-16  516  		return -ENOTTY;
^1da177e Linus Torvalds 2005-04-16  517  	substream = pcm_file->substream;
^1da177e Linus Torvalds 2005-04-16  518  	if (! substream)
^1da177e Linus Torvalds 2005-04-16  519  		return -ENOTTY;
^1da177e Linus Torvalds 2005-04-16  520  
^1da177e Linus Torvalds 2005-04-16  521  	/*
^1da177e Linus Torvalds 2005-04-16  522  	 * When PCM is used on 32bit mode, we need to disable
53cdcc38 Arnd Bergmann  2018-04-24  523  	 * mmap of the old PCM status/control records because
53cdcc38 Arnd Bergmann  2018-04-24  524  	 * of the size incompatibility.
^1da177e Linus Torvalds 2005-04-16  525  	 */
548a648b Takashi Iwai   2006-07-31  526  	pcm_file->no_compat_mmap = 1;
^1da177e Linus Torvalds 2005-04-16  527  
^1da177e Linus Torvalds 2005-04-16  528  	switch (cmd) {
^1da177e Linus Torvalds 2005-04-16  529  	case SNDRV_PCM_IOCTL_PVERSION:
^1da177e Linus Torvalds 2005-04-16  530  	case SNDRV_PCM_IOCTL_INFO:
5a7f2619 Takashi Iwai   2007-12-17  531  	case SNDRV_PCM_IOCTL_TSTAMP:
6b587ef9 Takashi Iwai   2007-12-14  532  	case SNDRV_PCM_IOCTL_TTSTAMP:
4b671f57 Takashi Iwai   2017-06-19  533  	case SNDRV_PCM_IOCTL_USER_PVERSION:
^1da177e Linus Torvalds 2005-04-16  534  	case SNDRV_PCM_IOCTL_HWSYNC:
^1da177e Linus Torvalds 2005-04-16  535  	case SNDRV_PCM_IOCTL_PREPARE:
^1da177e Linus Torvalds 2005-04-16  536  	case SNDRV_PCM_IOCTL_RESET:
^1da177e Linus Torvalds 2005-04-16  537  	case SNDRV_PCM_IOCTL_START:
^1da177e Linus Torvalds 2005-04-16  538  	case SNDRV_PCM_IOCTL_DROP:
^1da177e Linus Torvalds 2005-04-16  539  	case SNDRV_PCM_IOCTL_DRAIN:
^1da177e Linus Torvalds 2005-04-16  540  	case SNDRV_PCM_IOCTL_PAUSE:
^1da177e Linus Torvalds 2005-04-16  541  	case SNDRV_PCM_IOCTL_HW_FREE:
^1da177e Linus Torvalds 2005-04-16  542  	case SNDRV_PCM_IOCTL_RESUME:
^1da177e Linus Torvalds 2005-04-16  543  	case SNDRV_PCM_IOCTL_XRUN:
^1da177e Linus Torvalds 2005-04-16  544  	case SNDRV_PCM_IOCTL_LINK:
^1da177e Linus Torvalds 2005-04-16  545  	case SNDRV_PCM_IOCTL_UNLINK:
53cdcc38 Arnd Bergmann  2018-04-24  546  	case __SNDRV_PCM_IOCTL_SYNC_PTR32:
53cdcc38 Arnd Bergmann  2018-04-24  547  	case __SNDRV_PCM_IOCTL_SYNC_PTR64:
67616fed Takashi Iwai   2017-08-30  548  		return snd_pcm_common_ioctl(file, substream, cmd, argp);
^1da177e Linus Torvalds 2005-04-16  549  	case SNDRV_PCM_IOCTL_HW_REFINE32:
^1da177e Linus Torvalds 2005-04-16  550  		return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
^1da177e Linus Torvalds 2005-04-16  551  	case SNDRV_PCM_IOCTL_HW_PARAMS32:
^1da177e Linus Torvalds 2005-04-16  552  		return snd_pcm_ioctl_hw_params_compat(substream, 0, argp);
^1da177e Linus Torvalds 2005-04-16  553  	case SNDRV_PCM_IOCTL_SW_PARAMS32:
^1da177e Linus Torvalds 2005-04-16  554  		return snd_pcm_ioctl_sw_params_compat(substream, argp);
de41e437 Baolin Wang    2018-04-24  555  	case SNDRV_PCM_IOCTL_STATUS_COMPAT32:
de41e437 Baolin Wang    2018-04-24  556  		return snd_pcm_status_user32(substream, argp, false);
de41e437 Baolin Wang    2018-04-24  557  	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32:
de41e437 Baolin Wang    2018-04-24  558  		return snd_pcm_status_user32(substream, argp, true);
^1da177e Linus Torvalds 2005-04-16  559  	case SNDRV_PCM_IOCTL_CHANNEL_INFO32:
^1da177e Linus Torvalds 2005-04-16  560  		return snd_pcm_ioctl_channel_info_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  561  	case SNDRV_PCM_IOCTL_WRITEI_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  562  		return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp);
^1da177e Linus Torvalds 2005-04-16  563  	case SNDRV_PCM_IOCTL_READI_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  564  		return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp);
^1da177e Linus Torvalds 2005-04-16  565  	case SNDRV_PCM_IOCTL_WRITEN_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  566  		return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp);
^1da177e Linus Torvalds 2005-04-16  567  	case SNDRV_PCM_IOCTL_READN_FRAMES32:
^1da177e Linus Torvalds 2005-04-16  568  		return snd_pcm_ioctl_xfern_compat(substream, SNDRV_PCM_STREAM_CAPTURE, argp);
^1da177e Linus Torvalds 2005-04-16  569  	case SNDRV_PCM_IOCTL_DELAY32:
^1da177e Linus Torvalds 2005-04-16  570  		return snd_pcm_ioctl_delay_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  571  	case SNDRV_PCM_IOCTL_REWIND32:
^1da177e Linus Torvalds 2005-04-16  572  		return snd_pcm_ioctl_rewind_compat(substream, argp);
^1da177e Linus Torvalds 2005-04-16  573  	case SNDRV_PCM_IOCTL_FORWARD32:
^1da177e Linus Torvalds 2005-04-16  574  		return snd_pcm_ioctl_forward_compat(substream, argp);
de41e437 Baolin Wang    2018-04-24  575  	case SNDRV_PCM_IOCTL_STATUS_COMPAT64:
de41e437 Baolin Wang    2018-04-24  576  		return snd_pcm_status_user_compat64(substream, argp, false);
de41e437 Baolin Wang    2018-04-24  577  	case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64:
de41e437 Baolin Wang    2018-04-24  578  		return snd_pcm_status_user_compat64(substream, argp, true);
513ace79 Takashi Iwai   2016-02-28  579  #ifdef CONFIG_X86_X32
513ace79 Takashi Iwai   2016-02-28 @580  	case SNDRV_PCM_IOCTL_SYNC_PTR_X32:

:::::: The code at line 580 was first introduced by commit
:::::: 513ace79b657e2022a592e77f24074e088681ecc ALSA: pcm: Fix ioctls for X32 ABI

:::::: TO: Takashi Iwai <tiwai@suse.de>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30366 bytes --]

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
@ 2018-04-26  6:23     ` kbuild test robot
  2018-04-26  3:07     ` kbuild test robot
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  6:23 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Arnd,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/soc/sh/rcar/core.c:773:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:773:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:774:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:774:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:780:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:780:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:781:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:781:33: sparse: expression using sizeof(void)
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1169:67: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1169:67:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1169:67:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:401:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:438:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:499:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1032:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1032:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1032:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:1064:9: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
--
   sound/core/pcm_native.c:561:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:653:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:654:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:655:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:727:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:727:38:    expected int [signed] state
   sound/core/pcm_native.c:727:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:739:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:739:38:    expected int [signed] state
   sound/core/pcm_native.c:739:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:776:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:788:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:788:38:    expected int [signed] state
   sound/core/pcm_native.c:788:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:803:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:884:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/pcm_native.c:884:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:884:23:    got signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:885:33: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] suspended_state @@    got signed int [srestricted snd_pcm_state_t [usertype] suspended_state @@
   sound/core/pcm_native.c:885:33:    expected restricted snd_pcm_state_t [usertype] suspended_state
   sound/core/pcm_native.c:885:33:    got signed int [signed] [usertype] [explicitly-signed] suspended_state
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:927:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:928:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:935:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:996:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:996:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:996:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_native.c:1007:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1007:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1007:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1031:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1230:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1284:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1284:31:    expected int [signed] state
   sound/core/pcm_native.c:1284:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1291:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1291:40:    expected int [signed] state
   sound/core/pcm_native.c:1291:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1300:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1343:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1343:64:    expected int [signed] state
   sound/core/pcm_native.c:1343:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1359:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1359:38:    expected int [signed] state
   sound/core/pcm_native.c:1359:38:    got restricted snd_pcm_state_t [usertype] <noident>
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1393:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1395:46: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1432:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1432:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1432:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1437:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1437:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1437:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1463:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1485:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1485:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1485:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1569:49: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1570:50: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1627:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1644:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1645:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1646:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1647:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1696:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1697:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1718:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1718:38:    expected int [signed] state
   sound/core/pcm_native.c:1718:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1746:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1749:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1767:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1768:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1769:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1784:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:61:    expected int [signed] state
   sound/core/pcm_native.c:1784:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1785:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1785:63:    expected int [signed] state
   sound/core/pcm_native.c:1785:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1787:56: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1787:56:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1787:56:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1791:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1791:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1791:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1794:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1794:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1794:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1781:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1790:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1793:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1801:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1802:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1802:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1802:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1809:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1951:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1952:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1957:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1850:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1862:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1888:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1918:66: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2006:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2123:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2127:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2127:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2127:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2145:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2149:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2149:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2149:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2329:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2331:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2334:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2336:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2338:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2348:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   sound/core/pcm_native.c:2418:58: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2613:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2617:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2619:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2620:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2622:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2942:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:1093:47: sparse: too many warnings
   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
   sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~
--
   sound/core/pcm_lib.c:205:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1882:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1885:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1888:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1894:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1895:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1896:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1899:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2069:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2077:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2078:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2079:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2081:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2083:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2178:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2186:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2197:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2245:47: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/drivers/aloop.c:235:45: sparse: restricted snd_pcm_format_t degrades to integer
   sound/drivers/aloop.c:238:39: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/drivers/aloop.c:238:39:    expected unsigned int [unsigned] format
   sound/drivers/aloop.c:238:39:    got restricted snd_pcm_format_t [usertype] format
>> sound/drivers/aloop.c:411:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/drivers/aloop.c:914:34: sparse: incorrect type in assignment (different base types) @@    expected long [signed] max @@    got restricted snd_pcm_formatlong [signed] max @@
   sound/drivers/aloop.c:914:34:    expected long [signed] max
   sound/drivers/aloop.c:914:34:    got restricted snd_pcm_format_t [usertype] <noident>
   sound/drivers/aloop.c:1040:39: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/drivers/aloop.c:1040:39:    expected unsigned int [unsigned] format
   sound/drivers/aloop.c:1040:39:    got restricted snd_pcm_format_t [usertype] <noident>
--
>> sound/hda/hdmi_chmap.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/hda/hdmi_chmap.c:778:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/hda/hdmi_chmap.c:780:14: sparse: restricted snd_pcm_state_t degrades to integer
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
--
>> sound/core/oss/pcm_oss.c:1225:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1226:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1243:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1255:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1256:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1266:54: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1277:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1296:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1297:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1314:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1325:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1326:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1336:54: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/oss/pcm_oss.c:1618:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/oss/pcm_oss.c:1618:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/oss/pcm_oss.c:1618:23:    got signed int [signed] [usertype] [explicitly-signed] state
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   sound/core/oss/pcm_oss.c:1854:55: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got pcm_format_t [usertype] format @@
   sound/core/oss/pcm_oss.c:1854:55:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/oss/pcm_oss.c:1854:55:    got int [signed] [assigned] fmt
   sound/core/oss/pcm_oss.c:2821:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:2822:48: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/oss/pcm_oss.c:2832:29: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] ostate @@    got signed int [srestricted snd_pcm_state_t [usertype] ostate @@
   sound/core/oss/pcm_oss.c:2832:29:    expected restricted snd_pcm_state_t [usertype] ostate
   sound/core/oss/pcm_oss.c:2832:29:    got signed int [signed] [usertype] [explicitly-signed] state
>> sound/core/oss/pcm_oss.c:2833:46: sparse: call with no type!
--
   sound/firewire/bebob/bebob_pcm.c:32:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:32:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:33:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:33:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:61:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:61:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:62:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:62:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:86:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:86:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:87:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:87:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:90:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:90:32: sparse: expression using sizeof(void)
>> sound/firewire/bebob/bebob_pcm.c:200:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:220:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:234:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:249:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/dice/dice-pcm.c:82:17: sparse: expression using sizeof(void)
>> sound/firewire/dice/dice-pcm.c:136:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:155:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:170:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:186:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:335:31: sparse: expression using sizeof(void)
   sound/firewire/dice/dice-pcm.c:341:32: sparse: expression using sizeof(void)
--
   sound/firewire/digi00x/digi00x-pcm.c:28:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:28:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:29:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:29:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:51:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:51:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:52:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:52:25: sparse: expression using sizeof(void)
>> sound/firewire/digi00x/digi00x-pcm.c:169:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:189:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:220:50: sparse: restricted snd_pcm_state_t degrades to integer

vim +676 include/sound/pcm.h

30b771cf8 Takashi Iwai   2014-10-30  637  
30b771cf8 Takashi Iwai   2014-10-30  638  /**
30b771cf8 Takashi Iwai   2014-10-30  639   * snd_pcm_stream_lock_irqsave - Lock the PCM stream
30b771cf8 Takashi Iwai   2014-10-30  640   * @substream: PCM substream
30b771cf8 Takashi Iwai   2014-10-30  641   * @flags: irq flags
30b771cf8 Takashi Iwai   2014-10-30  642   *
30b771cf8 Takashi Iwai   2014-10-30  643   * This locks the PCM stream like snd_pcm_stream_lock() but with the local
30b771cf8 Takashi Iwai   2014-10-30  644   * IRQ (only when nonatomic is false).  In nonatomic case, this is identical
30b771cf8 Takashi Iwai   2014-10-30  645   * as snd_pcm_stream_lock().
30b771cf8 Takashi Iwai   2014-10-30  646   */
^1da177e4 Linus Torvalds 2005-04-16  647  #define snd_pcm_stream_lock_irqsave(substream, flags)		 \
^1da177e4 Linus Torvalds 2005-04-16  648  	do {							 \
7af142f75 Takashi Iwai   2014-09-01  649  		typecheck(unsigned long, flags);		 \
7af142f75 Takashi Iwai   2014-09-01  650  		flags = _snd_pcm_stream_lock_irqsave(substream); \
^1da177e4 Linus Torvalds 2005-04-16  651  	} while (0)
7af142f75 Takashi Iwai   2014-09-01  652  void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
7af142f75 Takashi Iwai   2014-09-01  653  				      unsigned long flags);
^1da177e4 Linus Torvalds 2005-04-16  654  
30b771cf8 Takashi Iwai   2014-10-30  655  /**
30b771cf8 Takashi Iwai   2014-10-30  656   * snd_pcm_group_for_each_entry - iterate over the linked substreams
30b771cf8 Takashi Iwai   2014-10-30  657   * @s: the iterator
30b771cf8 Takashi Iwai   2014-10-30  658   * @substream: the substream
30b771cf8 Takashi Iwai   2014-10-30  659   *
30b771cf8 Takashi Iwai   2014-10-30  660   * Iterate over the all linked substreams to the given @substream.
30b771cf8 Takashi Iwai   2014-10-30  661   * When @substream isn't linked with any others, this gives returns @substream
30b771cf8 Takashi Iwai   2014-10-30  662   * itself once.
30b771cf8 Takashi Iwai   2014-10-30  663   */
ef991b95a Takashi Iwai   2007-02-22  664  #define snd_pcm_group_for_each_entry(s, substream) \
ef991b95a Takashi Iwai   2007-02-22  665  	list_for_each_entry(s, &substream->group->substreams, link_list)
^1da177e4 Linus Torvalds 2005-04-16  666  
30b771cf8 Takashi Iwai   2014-10-30  667  /**
30b771cf8 Takashi Iwai   2014-10-30  668   * snd_pcm_running - Check whether the substream is in a running state
30b771cf8 Takashi Iwai   2014-10-30  669   * @substream: substream to check
30b771cf8 Takashi Iwai   2014-10-30  670   *
30b771cf8 Takashi Iwai   2014-10-30  671   * Returns true if the given substream is in the state RUNNING, or in the
30b771cf8 Takashi Iwai   2014-10-30  672   * state DRAINING for playback.
30b771cf8 Takashi Iwai   2014-10-30  673   */
877211f5e Takashi Iwai   2005-11-17  674  static inline int snd_pcm_running(struct snd_pcm_substream *substream)
^1da177e4 Linus Torvalds 2005-04-16  675  {
^1da177e4 Linus Torvalds 2005-04-16 @676  	return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
^1da177e4 Linus Torvalds 2005-04-16  677  		(substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
^1da177e4 Linus Torvalds 2005-04-16  678  		 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
^1da177e4 Linus Torvalds 2005-04-16  679  }
^1da177e4 Linus Torvalds 2005-04-16  680  

:::::: The code at line 676 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26  6:23     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  6:23 UTC (permalink / raw)
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Arnd,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/soc/sh/rcar/core.c:773:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:773:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:774:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:774:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:780:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:780:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:781:33: sparse: expression using sizeof(void)
   sound/soc/sh/rcar/core.c:781:33: sparse: expression using sizeof(void)
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1169:67: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1169:67:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1169:67:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:401:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:438:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:499:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1032:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1032:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1032:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:1064:9: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
--
   sound/core/pcm_native.c:561:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:653:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:654:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:655:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:727:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:727:38:    expected int [signed] state
   sound/core/pcm_native.c:727:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:739:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:739:38:    expected int [signed] state
   sound/core/pcm_native.c:739:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:776:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:788:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:788:38:    expected int [signed] state
   sound/core/pcm_native.c:788:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:803:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:884:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/pcm_native.c:884:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:884:23:    got signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:885:33: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] suspended_state @@    got signed int [srestricted snd_pcm_state_t [usertype] suspended_state @@
   sound/core/pcm_native.c:885:33:    expected restricted snd_pcm_state_t [usertype] suspended_state
   sound/core/pcm_native.c:885:33:    got signed int [signed] [usertype] [explicitly-signed] suspended_state
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:927:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:928:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:935:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:996:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:996:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:996:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_native.c:1007:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1007:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1007:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1031:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1230:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1284:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1284:31:    expected int [signed] state
   sound/core/pcm_native.c:1284:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1291:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1291:40:    expected int [signed] state
   sound/core/pcm_native.c:1291:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1300:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1343:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1343:64:    expected int [signed] state
   sound/core/pcm_native.c:1343:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1359:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1359:38:    expected int [signed] state
   sound/core/pcm_native.c:1359:38:    got restricted snd_pcm_state_t [usertype] <noident>
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1393:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1395:46: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1432:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1432:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1432:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1437:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1437:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1437:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1463:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1485:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1485:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1485:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1569:49: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1570:50: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1627:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1644:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1645:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1646:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1647:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1696:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1697:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1718:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1718:38:    expected int [signed] state
   sound/core/pcm_native.c:1718:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1746:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1749:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1767:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1768:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1769:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1784:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:61:    expected int [signed] state
   sound/core/pcm_native.c:1784:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1785:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1785:63:    expected int [signed] state
   sound/core/pcm_native.c:1785:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1787:56: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1787:56:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1787:56:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1791:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1791:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1791:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1794:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1794:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1794:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1781:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1790:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1793:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1801:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1802:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1802:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1802:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1809:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1951:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1952:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1957:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1850:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1862:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1888:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1918:66: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2006:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2123:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2127:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2127:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2127:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2145:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2149:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2149:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2149:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2329:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2331:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2334:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2336:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2338:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2348:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   sound/core/pcm_native.c:2418:58: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2613:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2617:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2619:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2620:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2622:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2942:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:1093:47: sparse: too many warnings
   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
   sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~
--
   sound/core/pcm_lib.c:205:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1882:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1885:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1888:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1894:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1895:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1896:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1899:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2069:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2077:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2078:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2079:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2081:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2083:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2178:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2186:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2197:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2245:47: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/drivers/aloop.c:235:45: sparse: restricted snd_pcm_format_t degrades to integer
   sound/drivers/aloop.c:238:39: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/drivers/aloop.c:238:39:    expected unsigned int [unsigned] format
   sound/drivers/aloop.c:238:39:    got restricted snd_pcm_format_t [usertype] format
>> sound/drivers/aloop.c:411:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/drivers/aloop.c:914:34: sparse: incorrect type in assignment (different base types) @@    expected long [signed] max @@    got restricted snd_pcm_formatlong [signed] max @@
   sound/drivers/aloop.c:914:34:    expected long [signed] max
   sound/drivers/aloop.c:914:34:    got restricted snd_pcm_format_t [usertype] <noident>
   sound/drivers/aloop.c:1040:39: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/drivers/aloop.c:1040:39:    expected unsigned int [unsigned] format
   sound/drivers/aloop.c:1040:39:    got restricted snd_pcm_format_t [usertype] <noident>
--
>> sound/hda/hdmi_chmap.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/hda/hdmi_chmap.c:778:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/hda/hdmi_chmap.c:780:14: sparse: restricted snd_pcm_state_t degrades to integer
--
>> include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
--
>> sound/core/oss/pcm_oss.c:1225:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1226:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1243:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1255:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1256:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1266:54: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1277:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1296:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1297:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1314:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1325:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1326:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:1336:54: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/oss/pcm_oss.c:1618:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/oss/pcm_oss.c:1618:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/oss/pcm_oss.c:1618:23:    got signed int [signed] [usertype] [explicitly-signed] state
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   sound/core/oss/pcm_oss.c:1854:55: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got pcm_format_t [usertype] format @@
   sound/core/oss/pcm_oss.c:1854:55:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/oss/pcm_oss.c:1854:55:    got int [signed] [assigned] fmt
   sound/core/oss/pcm_oss.c:2821:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/oss/pcm_oss.c:2822:48: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/oss/pcm_oss.c:2832:29: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] ostate @@    got signed int [srestricted snd_pcm_state_t [usertype] ostate @@
   sound/core/oss/pcm_oss.c:2832:29:    expected restricted snd_pcm_state_t [usertype] ostate
   sound/core/oss/pcm_oss.c:2832:29:    got signed int [signed] [usertype] [explicitly-signed] state
>> sound/core/oss/pcm_oss.c:2833:46: sparse: call with no type!
--
   sound/firewire/bebob/bebob_pcm.c:32:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:32:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:33:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:33:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:61:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:61:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:62:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:62:25: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:86:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:86:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:87:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:87:36: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:90:32: sparse: expression using sizeof(void)
   sound/firewire/bebob/bebob_pcm.c:90:32: sparse: expression using sizeof(void)
>> sound/firewire/bebob/bebob_pcm.c:200:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:220:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:234:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/bebob/bebob_pcm.c:249:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/dice/dice-pcm.c:82:17: sparse: expression using sizeof(void)
>> sound/firewire/dice/dice-pcm.c:136:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:155:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:170:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:186:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/dice/dice-pcm.c:335:31: sparse: expression using sizeof(void)
   sound/firewire/dice/dice-pcm.c:341:32: sparse: expression using sizeof(void)
--
   sound/firewire/digi00x/digi00x-pcm.c:28:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:28:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:29:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:29:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:51:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:51:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:52:25: sparse: expression using sizeof(void)
   sound/firewire/digi00x/digi00x-pcm.c:52:25: sparse: expression using sizeof(void)
>> sound/firewire/digi00x/digi00x-pcm.c:169:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:189:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/digi00x/digi00x-pcm.c:220:50: sparse: restricted snd_pcm_state_t degrades to integer

vim +676 include/sound/pcm.h

30b771cf8 Takashi Iwai   2014-10-30  637  
30b771cf8 Takashi Iwai   2014-10-30  638  /**
30b771cf8 Takashi Iwai   2014-10-30  639   * snd_pcm_stream_lock_irqsave - Lock the PCM stream
30b771cf8 Takashi Iwai   2014-10-30  640   * @substream: PCM substream
30b771cf8 Takashi Iwai   2014-10-30  641   * @flags: irq flags
30b771cf8 Takashi Iwai   2014-10-30  642   *
30b771cf8 Takashi Iwai   2014-10-30  643   * This locks the PCM stream like snd_pcm_stream_lock() but with the local
30b771cf8 Takashi Iwai   2014-10-30  644   * IRQ (only when nonatomic is false).  In nonatomic case, this is identical
30b771cf8 Takashi Iwai   2014-10-30  645   * as snd_pcm_stream_lock().
30b771cf8 Takashi Iwai   2014-10-30  646   */
^1da177e4 Linus Torvalds 2005-04-16  647  #define snd_pcm_stream_lock_irqsave(substream, flags)		 \
^1da177e4 Linus Torvalds 2005-04-16  648  	do {							 \
7af142f75 Takashi Iwai   2014-09-01  649  		typecheck(unsigned long, flags);		 \
7af142f75 Takashi Iwai   2014-09-01  650  		flags = _snd_pcm_stream_lock_irqsave(substream); \
^1da177e4 Linus Torvalds 2005-04-16  651  	} while (0)
7af142f75 Takashi Iwai   2014-09-01  652  void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
7af142f75 Takashi Iwai   2014-09-01  653  				      unsigned long flags);
^1da177e4 Linus Torvalds 2005-04-16  654  
30b771cf8 Takashi Iwai   2014-10-30  655  /**
30b771cf8 Takashi Iwai   2014-10-30  656   * snd_pcm_group_for_each_entry - iterate over the linked substreams
30b771cf8 Takashi Iwai   2014-10-30  657   * @s: the iterator
30b771cf8 Takashi Iwai   2014-10-30  658   * @substream: the substream
30b771cf8 Takashi Iwai   2014-10-30  659   *
30b771cf8 Takashi Iwai   2014-10-30  660   * Iterate over the all linked substreams to the given @substream.
30b771cf8 Takashi Iwai   2014-10-30  661   * When @substream isn't linked with any others, this gives returns @substream
30b771cf8 Takashi Iwai   2014-10-30  662   * itself once.
30b771cf8 Takashi Iwai   2014-10-30  663   */
ef991b95a Takashi Iwai   2007-02-22  664  #define snd_pcm_group_for_each_entry(s, substream) \
ef991b95a Takashi Iwai   2007-02-22  665  	list_for_each_entry(s, &substream->group->substreams, link_list)
^1da177e4 Linus Torvalds 2005-04-16  666  
30b771cf8 Takashi Iwai   2014-10-30  667  /**
30b771cf8 Takashi Iwai   2014-10-30  668   * snd_pcm_running - Check whether the substream is in a running state
30b771cf8 Takashi Iwai   2014-10-30  669   * @substream: substream to check
30b771cf8 Takashi Iwai   2014-10-30  670   *
30b771cf8 Takashi Iwai   2014-10-30  671   * Returns true if the given substream is in the state RUNNING, or in the
30b771cf8 Takashi Iwai   2014-10-30  672   * state DRAINING for playback.
30b771cf8 Takashi Iwai   2014-10-30  673   */
877211f5e Takashi Iwai   2005-11-17  674  static inline int snd_pcm_running(struct snd_pcm_substream *substream)
^1da177e4 Linus Torvalds 2005-04-16  675  {
^1da177e4 Linus Torvalds 2005-04-16 @676  	return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
^1da177e4 Linus Torvalds 2005-04-16  677  		(substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
^1da177e4 Linus Torvalds 2005-04-16  678  		 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
^1da177e4 Linus Torvalds 2005-04-16  679  }
^1da177e4 Linus Torvalds 2005-04-16  680  

:::::: The code at line 676 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
  2018-04-24 12:06   ` Baolin Wang
@ 2018-04-26  8:15     ` kbuild test robot
  -1 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  8:15 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 6346 bytes --]

Hi Baolin,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[also build test ERROR on next-20180424]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: sh-ecovec24_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
     if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
                                                         ^~~~~~~~~~~~
   In file included from include/linux/time.h:73:0,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/srcu.h:34,
                    from include/linux/notifier.h:16,
                    from include/linux/memory_hotplug.h:7,
                    from include/linux/mmzone.h:777,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from sound/core/pcm_lib.c:23:
   include/linux/time32.h:59:19: note: expected 'const struct timespec *' but argument is of type 'struct timespec64 *'
    static inline int timespec_equal(const struct timespec *a,
                      ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/timespec_equal +256 sound/core/pcm_lib.c

^1da177e Linus Torvalds       2005-04-16  222  
3179f620 Pierre-Louis Bossart 2015-02-13  223  static void update_audio_tstamp(struct snd_pcm_substream *substream,
ac8bbfea Baolin Wang          2018-04-24  224  				struct timespec64 *curr_tstamp,
ac8bbfea Baolin Wang          2018-04-24  225  				struct timespec64 *audio_tstamp)
3179f620 Pierre-Louis Bossart 2015-02-13  226  {
3179f620 Pierre-Louis Bossart 2015-02-13  227  	struct snd_pcm_runtime *runtime = substream->runtime;
3179f620 Pierre-Louis Bossart 2015-02-13  228  	u64 audio_frames, audio_nsecs;
ac8bbfea Baolin Wang          2018-04-24  229  	struct timespec64 driver_tstamp;
3179f620 Pierre-Louis Bossart 2015-02-13  230  
3179f620 Pierre-Louis Bossart 2015-02-13  231  	if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE)
3179f620 Pierre-Louis Bossart 2015-02-13  232  		return;
3179f620 Pierre-Louis Bossart 2015-02-13  233  
3179f620 Pierre-Louis Bossart 2015-02-13  234  	if (!(substream->ops->get_time_info) ||
3179f620 Pierre-Louis Bossart 2015-02-13  235  		(runtime->audio_tstamp_report.actual_type ==
3179f620 Pierre-Louis Bossart 2015-02-13  236  			SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) {
3179f620 Pierre-Louis Bossart 2015-02-13  237  
3179f620 Pierre-Louis Bossart 2015-02-13  238  		/*
3179f620 Pierre-Louis Bossart 2015-02-13  239  		 * provide audio timestamp derived from pointer position
3179f620 Pierre-Louis Bossart 2015-02-13  240  		 * add delay only if requested
3179f620 Pierre-Louis Bossart 2015-02-13  241  		 */
3179f620 Pierre-Louis Bossart 2015-02-13  242  
3179f620 Pierre-Louis Bossart 2015-02-13  243  		audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr;
3179f620 Pierre-Louis Bossart 2015-02-13  244  
3179f620 Pierre-Louis Bossart 2015-02-13  245  		if (runtime->audio_tstamp_config.report_delay) {
3179f620 Pierre-Louis Bossart 2015-02-13  246  			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
3179f620 Pierre-Louis Bossart 2015-02-13  247  				audio_frames -=  runtime->delay;
3179f620 Pierre-Louis Bossart 2015-02-13  248  			else
3179f620 Pierre-Louis Bossart 2015-02-13  249  				audio_frames +=  runtime->delay;
3179f620 Pierre-Louis Bossart 2015-02-13  250  		}
3179f620 Pierre-Louis Bossart 2015-02-13  251  		audio_nsecs = div_u64(audio_frames * 1000000000LL,
3179f620 Pierre-Louis Bossart 2015-02-13  252  				runtime->rate);
ac8bbfea Baolin Wang          2018-04-24  253  		*audio_tstamp = ns_to_timespec64(audio_nsecs);
3179f620 Pierre-Louis Bossart 2015-02-13  254  	}
ac8bbfea Baolin Wang          2018-04-24  255  
20e3f985 Henrik Eriksson      2017-11-21 @256  	if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
ac8bbfea Baolin Wang          2018-04-24  257  		runtime->status->audio_tstamp =
ac8bbfea Baolin Wang          2018-04-24  258  			timespec64_to_timespec(*audio_tstamp);
ac8bbfea Baolin Wang          2018-04-24  259  		runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp);
20e3f985 Henrik Eriksson      2017-11-21  260  	}
3179f620 Pierre-Louis Bossart 2015-02-13  261  
ac8bbfea Baolin Wang          2018-04-24  262  
3179f620 Pierre-Louis Bossart 2015-02-13  263  	/*
3179f620 Pierre-Louis Bossart 2015-02-13  264  	 * re-take a driver timestamp to let apps detect if the reference tstamp
3179f620 Pierre-Louis Bossart 2015-02-13  265  	 * read by low-level hardware was provided with a delay
3179f620 Pierre-Louis Bossart 2015-02-13  266  	 */
ac8bbfea Baolin Wang          2018-04-24  267  	snd_pcm_gettime(substream->runtime, &driver_tstamp);
3179f620 Pierre-Louis Bossart 2015-02-13  268  	runtime->driver_tstamp = driver_tstamp;
3179f620 Pierre-Louis Bossart 2015-02-13  269  }
3179f620 Pierre-Louis Bossart 2015-02-13  270  

:::::: The code at line 256 was first introduced by commit
:::::: 20e3f985bb875fea4f86b04eba4b6cc29bfd6b71 ALSA: pcm: update tstamp only if audio_tstamp changed

:::::: TO: Henrik Eriksson <henrik.eriksson@axis.com>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 15699 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
@ 2018-04-26  8:15     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  8:15 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, jeeja.kp, elfring, linux-kernel, vinod.koul,
	guneshwor.o.singh, mingo, gudishax.kranthikumar, arvind.yadav.cs,
	subhransu.s.prusty, dan.carpenter, arnd, hardik.t.shah, fabf,
	broonie, naveen.m, baolin.wang, lgirdwood, o-takashi, kbuild-all,
	bhumirks

[-- Attachment #1: Type: text/plain, Size: 6346 bytes --]

Hi Baolin,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[also build test ERROR on next-20180424]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
config: sh-ecovec24_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
     if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
                                                         ^~~~~~~~~~~~
   In file included from include/linux/time.h:73:0,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/srcu.h:34,
                    from include/linux/notifier.h:16,
                    from include/linux/memory_hotplug.h:7,
                    from include/linux/mmzone.h:777,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from sound/core/pcm_lib.c:23:
   include/linux/time32.h:59:19: note: expected 'const struct timespec *' but argument is of type 'struct timespec64 *'
    static inline int timespec_equal(const struct timespec *a,
                      ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/timespec_equal +256 sound/core/pcm_lib.c

^1da177e Linus Torvalds       2005-04-16  222  
3179f620 Pierre-Louis Bossart 2015-02-13  223  static void update_audio_tstamp(struct snd_pcm_substream *substream,
ac8bbfea Baolin Wang          2018-04-24  224  				struct timespec64 *curr_tstamp,
ac8bbfea Baolin Wang          2018-04-24  225  				struct timespec64 *audio_tstamp)
3179f620 Pierre-Louis Bossart 2015-02-13  226  {
3179f620 Pierre-Louis Bossart 2015-02-13  227  	struct snd_pcm_runtime *runtime = substream->runtime;
3179f620 Pierre-Louis Bossart 2015-02-13  228  	u64 audio_frames, audio_nsecs;
ac8bbfea Baolin Wang          2018-04-24  229  	struct timespec64 driver_tstamp;
3179f620 Pierre-Louis Bossart 2015-02-13  230  
3179f620 Pierre-Louis Bossart 2015-02-13  231  	if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE)
3179f620 Pierre-Louis Bossart 2015-02-13  232  		return;
3179f620 Pierre-Louis Bossart 2015-02-13  233  
3179f620 Pierre-Louis Bossart 2015-02-13  234  	if (!(substream->ops->get_time_info) ||
3179f620 Pierre-Louis Bossart 2015-02-13  235  		(runtime->audio_tstamp_report.actual_type ==
3179f620 Pierre-Louis Bossart 2015-02-13  236  			SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) {
3179f620 Pierre-Louis Bossart 2015-02-13  237  
3179f620 Pierre-Louis Bossart 2015-02-13  238  		/*
3179f620 Pierre-Louis Bossart 2015-02-13  239  		 * provide audio timestamp derived from pointer position
3179f620 Pierre-Louis Bossart 2015-02-13  240  		 * add delay only if requested
3179f620 Pierre-Louis Bossart 2015-02-13  241  		 */
3179f620 Pierre-Louis Bossart 2015-02-13  242  
3179f620 Pierre-Louis Bossart 2015-02-13  243  		audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr;
3179f620 Pierre-Louis Bossart 2015-02-13  244  
3179f620 Pierre-Louis Bossart 2015-02-13  245  		if (runtime->audio_tstamp_config.report_delay) {
3179f620 Pierre-Louis Bossart 2015-02-13  246  			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
3179f620 Pierre-Louis Bossart 2015-02-13  247  				audio_frames -=  runtime->delay;
3179f620 Pierre-Louis Bossart 2015-02-13  248  			else
3179f620 Pierre-Louis Bossart 2015-02-13  249  				audio_frames +=  runtime->delay;
3179f620 Pierre-Louis Bossart 2015-02-13  250  		}
3179f620 Pierre-Louis Bossart 2015-02-13  251  		audio_nsecs = div_u64(audio_frames * 1000000000LL,
3179f620 Pierre-Louis Bossart 2015-02-13  252  				runtime->rate);
ac8bbfea Baolin Wang          2018-04-24  253  		*audio_tstamp = ns_to_timespec64(audio_nsecs);
3179f620 Pierre-Louis Bossart 2015-02-13  254  	}
ac8bbfea Baolin Wang          2018-04-24  255  
20e3f985 Henrik Eriksson      2017-11-21 @256  	if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
ac8bbfea Baolin Wang          2018-04-24  257  		runtime->status->audio_tstamp =
ac8bbfea Baolin Wang          2018-04-24  258  			timespec64_to_timespec(*audio_tstamp);
ac8bbfea Baolin Wang          2018-04-24  259  		runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp);
20e3f985 Henrik Eriksson      2017-11-21  260  	}
3179f620 Pierre-Louis Bossart 2015-02-13  261  
ac8bbfea Baolin Wang          2018-04-24  262  
3179f620 Pierre-Louis Bossart 2015-02-13  263  	/*
3179f620 Pierre-Louis Bossart 2015-02-13  264  	 * re-take a driver timestamp to let apps detect if the reference tstamp
3179f620 Pierre-Louis Bossart 2015-02-13  265  	 * read by low-level hardware was provided with a delay
3179f620 Pierre-Louis Bossart 2015-02-13  266  	 */
ac8bbfea Baolin Wang          2018-04-24  267  	snd_pcm_gettime(substream->runtime, &driver_tstamp);
3179f620 Pierre-Louis Bossart 2015-02-13  268  	runtime->driver_tstamp = driver_tstamp;
3179f620 Pierre-Louis Bossart 2015-02-13  269  }
3179f620 Pierre-Louis Bossart 2015-02-13  270  

:::::: The code at line 256 was first introduced by commit
:::::: 20e3f985bb875fea4f86b04eba4b6cc29bfd6b71 ALSA: pcm: update tstamp only if audio_tstamp changed

:::::: TO: Henrik Eriksson <henrik.eriksson@axis.com>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 15699 bytes --]

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
  2018-04-26  8:15     ` kbuild test robot
@ 2018-04-26  8:30       ` Arnd Bergmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26  8:30 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Baolin Wang, kbuild-all, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, Linux Kernel Mailing List

On Thu, Apr 26, 2018 at 10:15 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Baolin,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on v4.17-rc2]
> [also build test ERROR on next-20180424]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> config: sh-ecovec24_defconfig (attached as .config)
> compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=sh
>
> Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
>       It only hurts bisectibility.
>
> All errors (new ones prefixed by >>):
>
>    sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
>      if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
>                                                          ^~~~~~~~~~~~


Probably a mistake during rebasing: patch 8/8 fixes this, but it should be done
right here by moving the open-coded comparison into the first patch:

-       if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
+       if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec ||
+           runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) {

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
@ 2018-04-26  8:30       ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26  8:30 UTC (permalink / raw)
  To: kbuild test robot
  Cc: alsa-devel, Liam Girdwood, jeeja.kp, SF Markus Elfring,
	Vinod Koul, Takashi Iwai, Guneshwor Singh, Ingo Molnar,
	gudishax.kranthikumar, Arvind Yadav, subhransu.s.prusty,
	Dan Carpenter, hardik.t.shah, Fabian Frederick, Mark Brown,
	Naveen M, Baolin Wang, Linux Kernel Mailing List,
	Takashi Sakamoto, kbuild-all, Bhumika Goyal

On Thu, Apr 26, 2018 at 10:15 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Baolin,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on v4.17-rc2]
> [also build test ERROR on next-20180424]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> config: sh-ecovec24_defconfig (attached as .config)
> compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=sh
>
> Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
>       It only hurts bisectibility.
>
> All errors (new ones prefixed by >>):
>
>    sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
>      if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
>                                                          ^~~~~~~~~~~~


Probably a mistake during rebasing: patch 8/8 fixes this, but it should be done
right here by moving the open-coded comparison into the first patch:

-       if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
+       if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec ||
+           runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) {

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
  2018-04-26  8:30       ` Arnd Bergmann
@ 2018-04-26  8:41         ` Baolin Wang
  -1 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-26  8:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild test robot, kbuild-all, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, Linux Kernel Mailing List

On 26 April 2018 at 16:30, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Apr 26, 2018 at 10:15 AM, kbuild test robot <lkp@intel.com> wrote:
>> Hi Baolin,
>>
>> I love your patch! Yet something to improve:
>>
>> [auto build test ERROR on v4.17-rc2]
>> [also build test ERROR on next-20180424]
>> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
>> config: sh-ecovec24_defconfig (attached as .config)
>> compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
>> reproduce:
>>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>         chmod +x ~/bin/make.cross
>>         # save the attached .config to linux build tree
>>         make.cross ARCH=sh
>>
>> Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
>>       It only hurts bisectibility.
>>
>> All errors (new ones prefixed by >>):
>>
>>    sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>>>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
>>      if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
>>                                                          ^~~~~~~~~~~~
>
>
> Probably a mistake during rebasing: patch 8/8 fixes this, but it should be done
> right here by moving the open-coded comparison into the first patch:
>
> -       if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
> +       if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec ||
> +           runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) {
>

Sorry, it's my mistake. Yes, I can fix this issue like what you showed.

-- 
Baolin.wang
Best Regards

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/8] ALSA: Replace timespec with timespec64
@ 2018-04-26  8:41         ` Baolin Wang
  0 siblings, 0 replies; 48+ messages in thread
From: Baolin Wang @ 2018-04-26  8:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: alsa-devel, Liam Girdwood, jeeja.kp, SF Markus Elfring,
	kbuild test robot, Vinod Koul, Takashi Iwai, Guneshwor Singh,
	Ingo Molnar, gudishax.kranthikumar, Arvind Yadav,
	subhransu.s.prusty, Dan Carpenter, hardik.t.shah,
	Fabian Frederick, Mark Brown, Naveen M,
	Linux Kernel Mailing List, Takashi Sakamoto, kbuild-all,
	Bhumika Goyal

On 26 April 2018 at 16:30, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Apr 26, 2018 at 10:15 AM, kbuild test robot <lkp@intel.com> wrote:
>> Hi Baolin,
>>
>> I love your patch! Yet something to improve:
>>
>> [auto build test ERROR on v4.17-rc2]
>> [also build test ERROR on next-20180424]
>> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
>> config: sh-ecovec24_defconfig (attached as .config)
>> compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
>> reproduce:
>>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>         chmod +x ~/bin/make.cross
>>         # save the attached .config to linux build tree
>>         make.cross ARCH=sh
>>
>> Note: the linux-review/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145 HEAD 53cdcc389f07bdd923be240cdb746a97de063301 builds fine.
>>       It only hurts bisectibility.
>>
>> All errors (new ones prefixed by >>):
>>
>>    sound/core/pcm_lib.c: In function 'update_audio_tstamp':
>>>> sound/core/pcm_lib.c:256:54: error: passing argument 2 of 'timespec_equal' from incompatible pointer type [-Werror=incompatible-pointer-types]
>>      if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
>>                                                          ^~~~~~~~~~~~
>
>
> Probably a mistake during rebasing: patch 8/8 fixes this, but it should be done
> right here by moving the open-coded comparison into the first patch:
>
> -       if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
> +       if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec ||
> +           runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) {
>

Sorry, it's my mistake. Yes, I can fix this issue like what you showed.

-- 
Baolin.wang
Best Regards

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
  2018-04-24 12:06 ` [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status Baolin Wang
@ 2018-04-26  9:20     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  9:20 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Baolin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   sound/core/pcm_native.c:561:51: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:561:51:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:561:51:    got int [signed] state
   sound/core/pcm_native.c:726:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:726:38:    expected int [signed] state
   sound/core/pcm_native.c:726:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:738:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:738:38:    expected int [signed] state
   sound/core/pcm_native.c:738:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:787:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:787:38:    expected int [signed] state
   sound/core/pcm_native.c:787:38:    got restricted snd_pcm_state_t [usertype] <noident>
>> sound/core/pcm_native.c:995:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:995:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:995:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
>> sound/core/pcm_native.c:1006:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1006:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1006:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1259:32: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:1259:32:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1259:32:    got int [signed] state
   sound/core/pcm_native.c:1283:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1283:31:    expected int [signed] state
   sound/core/pcm_native.c:1283:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1290:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1290:40:    expected int [signed] state
   sound/core/pcm_native.c:1290:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1316:28: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1318:40: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:1318:40:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1318:40:    got int [signed] state
   sound/core/pcm_native.c:1342:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1342:64:    expected int [signed] state
   sound/core/pcm_native.c:1342:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1358:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1358:38:    expected int [signed] state
   sound/core/pcm_native.c:1358:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1717:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1717:38:    expected int [signed] state
   sound/core/pcm_native.c:1717:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1783:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1783:61:    expected int [signed] state
   sound/core/pcm_native.c:1783:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1784:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:63:    expected int [signed] state
   sound/core/pcm_native.c:1784:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1801:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1801:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1801:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:2122:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2126:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2126:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2126:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2144:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2148:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2148:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2148:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2328:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2330:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2333:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2335:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2337:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2347:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   sound/core/pcm_compat.c:241:32: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_compat.c:241:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_compat.c:241:32:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_compat.c:252:42: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_compat.c:252:42:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_compat.c:252:42:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   sound/core/pcm_compat.c:480:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:480:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:480:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
   sound/core/pcm_compat.c:483:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:483:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:483:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
   sound/core/pcm_compat.c:569:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:569:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:569:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
   sound/core/pcm_compat.c:572:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:572:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:572:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:112:9: sparse: context imbalance in 'snd_pcm_stream_lock' - different lock contexts for basic block
   sound/core/pcm_native.c:134:28: sparse: context imbalance in 'snd_pcm_stream_unlock' - unexpected unlock
   sound/core/pcm_native.c:1130:52: sparse: context imbalance in 'snd_pcm_action_group' - unexpected unlock

vim +995 sound/core/pcm_native.c

   971	
   972	static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
   973					 struct snd_pcm_status32 __user * _status,
   974					 bool ext)
   975	{
   976		struct snd_pcm_status64 status64;
   977		struct snd_pcm_status32 status32;
   978		int res;
   979	
   980		memset(&status64, 0, sizeof(status64));
   981		memset(&status32, 0, sizeof(status32));
   982		/*
   983		 * with extension, parameters are read/write,
   984		 * get audio_tstamp_data from user,
   985		 * ignore rest of status structure
   986		 */
   987		if (ext && get_user(status64.audio_tstamp_data,
   988				    (u32 __user *)(&_status->audio_tstamp_data)))
   989			return -EFAULT;
   990		res = snd_pcm_status64(substream, &status64);
   991		if (res < 0)
   992			return res;
   993	
   994		status32 = (struct snd_pcm_status32) {
 > 995			.state = status64.state,
   996			.trigger_tstamp_sec = status64.trigger_tstamp_sec,
   997			.trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
   998			.tstamp_sec = status64.tstamp_sec,
   999			.tstamp_nsec = status64.tstamp_nsec,
  1000			.appl_ptr = status64.appl_ptr,
  1001			.hw_ptr = status64.hw_ptr,
  1002			.delay = status64.delay,
  1003			.avail = status64.avail,
  1004			.avail_max = status64.avail_max,
  1005			.overrange = status64.overrange,
> 1006			.suspended_state = status64.suspended_state,
  1007			.audio_tstamp_data = status64.audio_tstamp_data,
  1008			.audio_tstamp_sec = status64.audio_tstamp_sec,
  1009			.audio_tstamp_nsec = status64.audio_tstamp_nsec,
  1010			.driver_tstamp_sec = status64.audio_tstamp_sec,
  1011			.driver_tstamp_nsec = status64.audio_tstamp_nsec,
  1012			.audio_tstamp_accuracy = status64.audio_tstamp_accuracy,
  1013		};
  1014	
  1015		if (copy_to_user(_status, &status32, sizeof(status32)))
  1016			return -EFAULT;
  1017	
  1018		return 0;
  1019	}
  1020	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
@ 2018-04-26  9:20     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26  9:20 UTC (permalink / raw)
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Baolin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   sound/core/pcm_native.c:561:51: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:561:51:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:561:51:    got int [signed] state
   sound/core/pcm_native.c:726:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:726:38:    expected int [signed] state
   sound/core/pcm_native.c:726:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:738:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:738:38:    expected int [signed] state
   sound/core/pcm_native.c:738:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:787:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:787:38:    expected int [signed] state
   sound/core/pcm_native.c:787:38:    got restricted snd_pcm_state_t [usertype] <noident>
>> sound/core/pcm_native.c:995:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:995:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:995:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
>> sound/core/pcm_native.c:1006:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1006:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1006:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1259:32: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:1259:32:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1259:32:    got int [signed] state
   sound/core/pcm_native.c:1283:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1283:31:    expected int [signed] state
   sound/core/pcm_native.c:1283:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1290:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1290:40:    expected int [signed] state
   sound/core/pcm_native.c:1290:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1316:28: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1318:40: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
   sound/core/pcm_native.c:1318:40:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1318:40:    got int [signed] state
   sound/core/pcm_native.c:1342:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1342:64:    expected int [signed] state
   sound/core/pcm_native.c:1342:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1358:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1358:38:    expected int [signed] state
   sound/core/pcm_native.c:1358:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1717:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1717:38:    expected int [signed] state
   sound/core/pcm_native.c:1717:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1783:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1783:61:    expected int [signed] state
   sound/core/pcm_native.c:1783:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1784:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:63:    expected int [signed] state
   sound/core/pcm_native.c:1784:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1801:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1801:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1801:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:2122:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2126:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2126:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2126:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2144:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2148:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2148:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2148:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2328:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2330:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2333:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2335:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2337:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2347:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   sound/core/pcm_compat.c:241:32: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_compat.c:241:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_compat.c:241:32:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_compat.c:252:42: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_compat.c:252:42:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_compat.c:252:42:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
   include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
   sound/core/pcm_compat.c:480:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:480:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:480:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
   sound/core/pcm_compat.c:483:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:483:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:483:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
   sound/core/pcm_compat.c:569:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:569:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:569:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
   sound/core/pcm_compat.c:572:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
   sound/core/pcm_compat.c:572:13:    expected signed int [signed] [explicitly-signed] __pu_val
   sound/core/pcm_compat.c:572:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:112:9: sparse: context imbalance in 'snd_pcm_stream_lock' - different lock contexts for basic block
   sound/core/pcm_native.c:134:28: sparse: context imbalance in 'snd_pcm_stream_unlock' - unexpected unlock
   sound/core/pcm_native.c:1130:52: sparse: context imbalance in 'snd_pcm_action_group' - unexpected unlock

vim +995 sound/core/pcm_native.c

   971	
   972	static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
   973					 struct snd_pcm_status32 __user * _status,
   974					 bool ext)
   975	{
   976		struct snd_pcm_status64 status64;
   977		struct snd_pcm_status32 status32;
   978		int res;
   979	
   980		memset(&status64, 0, sizeof(status64));
   981		memset(&status32, 0, sizeof(status32));
   982		/*
   983		 * with extension, parameters are read/write,
   984		 * get audio_tstamp_data from user,
   985		 * ignore rest of status structure
   986		 */
   987		if (ext && get_user(status64.audio_tstamp_data,
   988				    (u32 __user *)(&_status->audio_tstamp_data)))
   989			return -EFAULT;
   990		res = snd_pcm_status64(substream, &status64);
   991		if (res < 0)
   992			return res;
   993	
   994		status32 = (struct snd_pcm_status32) {
 > 995			.state = status64.state,
   996			.trigger_tstamp_sec = status64.trigger_tstamp_sec,
   997			.trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
   998			.tstamp_sec = status64.tstamp_sec,
   999			.tstamp_nsec = status64.tstamp_nsec,
  1000			.appl_ptr = status64.appl_ptr,
  1001			.hw_ptr = status64.hw_ptr,
  1002			.delay = status64.delay,
  1003			.avail = status64.avail,
  1004			.avail_max = status64.avail_max,
  1005			.overrange = status64.overrange,
> 1006			.suspended_state = status64.suspended_state,
  1007			.audio_tstamp_data = status64.audio_tstamp_data,
  1008			.audio_tstamp_sec = status64.audio_tstamp_sec,
  1009			.audio_tstamp_nsec = status64.audio_tstamp_nsec,
  1010			.driver_tstamp_sec = status64.audio_tstamp_sec,
  1011			.driver_tstamp_nsec = status64.audio_tstamp_nsec,
  1012			.audio_tstamp_accuracy = status64.audio_tstamp_accuracy,
  1013		};
  1014	
  1015		if (copy_to_user(_status, &status32, sizeof(status32)))
  1016			return -EFAULT;
  1017	
  1018		return 0;
  1019	}
  1020	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
  2018-04-26  9:20     ` kbuild test robot
  (?)
@ 2018-04-26 10:53     ` Baolin Wang
  2018-04-26 12:50         ` Arnd Bergmann
  -1 siblings, 1 reply; 48+ messages in thread
From: Baolin Wang @ 2018-04-26 10:53 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, Jaroslav Kysela, Takashi Iwai, Arnd Bergmann,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, LKML

Hi Arnd,

On 26 April 2018 at 17:20, kbuild test robot <lkp@intel.com> wrote:
> Hi Baolin,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on v4.17-rc2]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> reproduce:
>         # apt-get install sparse
>         make ARCH=x86_64 allmodconfig
>         make C=1 CF=-D__CHECK_ENDIAN__
>
>
> sparse warnings: (new ones prefixed by >>)
>
>    sound/core/pcm_native.c:561:51: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
>    sound/core/pcm_native.c:561:51:    expected restricted snd_pcm_state_t [usertype] state
>    sound/core/pcm_native.c:561:51:    got int [signed] state
>    sound/core/pcm_native.c:726:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:726:38:    expected int [signed] state
>    sound/core/pcm_native.c:726:38:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:738:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:738:38:    expected int [signed] state
>    sound/core/pcm_native.c:738:38:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:787:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:787:38:    expected int [signed] state
>    sound/core/pcm_native.c:787:38:    got restricted snd_pcm_state_t [usertype] <noident>
>>> sound/core/pcm_native.c:995:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
>    sound/core/pcm_native.c:995:34:    expected signed int [signed] [usertype] [explicitly-signed] state
>    sound/core/pcm_native.c:995:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
>>> sound/core/pcm_native.c:1006:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
>    sound/core/pcm_native.c:1006:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
>    sound/core/pcm_native.c:1006:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
>    sound/core/pcm_native.c:1259:32: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
>    sound/core/pcm_native.c:1259:32:    expected restricted snd_pcm_state_t [usertype] state
>    sound/core/pcm_native.c:1259:32:    got int [signed] state
>    sound/core/pcm_native.c:1283:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1283:31:    expected int [signed] state
>    sound/core/pcm_native.c:1283:31:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1290:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1290:40:    expected int [signed] state
>    sound/core/pcm_native.c:1290:40:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1316:28: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/core/pcm_native.c:1318:40: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got t [usertype] state @@
>    sound/core/pcm_native.c:1318:40:    expected restricted snd_pcm_state_t [usertype] state
>    sound/core/pcm_native.c:1318:40:    got int [signed] state
>    sound/core/pcm_native.c:1342:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1342:64:    expected int [signed] state
>    sound/core/pcm_native.c:1342:64:    got restricted snd_pcm_state_t [usertype] state
>    sound/core/pcm_native.c:1358:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1358:38:    expected int [signed] state
>    sound/core/pcm_native.c:1358:38:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1717:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1717:38:    expected int [signed] state
>    sound/core/pcm_native.c:1717:38:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1783:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1783:61:    expected int [signed] state
>    sound/core/pcm_native.c:1783:61:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1784:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
>    sound/core/pcm_native.c:1784:63:    expected int [signed] state
>    sound/core/pcm_native.c:1784:63:    got restricted snd_pcm_state_t [usertype] <noident>
>    sound/core/pcm_native.c:1801:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
>    sound/core/pcm_native.c:1801:76:    expected int [signed] new_state
>    sound/core/pcm_native.c:1801:76:    got restricted snd_pcm_state_t
>    sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
>    sound/core/pcm_native.c:1904:40: sparse: expression using sizeof(void)
>    sound/core/pcm_native.c:2122:26: sparse: restricted snd_pcm_format_t degrades to integer
>    sound/core/pcm_native.c:2126:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
>    sound/core/pcm_native.c:2126:54:    expected restricted snd_pcm_format_t [usertype] format
>    sound/core/pcm_native.c:2126:54:    got unsigned int [unsigned] [assigned] k
>    sound/core/pcm_native.c:2144:26: sparse: restricted snd_pcm_format_t degrades to integer
>    sound/core/pcm_native.c:2148:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
>    sound/core/pcm_native.c:2148:54:    expected restricted snd_pcm_format_t [usertype] format
>    sound/core/pcm_native.c:2148:54:    got unsigned int [unsigned] [assigned] k
>    sound/core/pcm_native.c:2328:30: sparse: restricted snd_pcm_access_t degrades to integer
>    sound/core/pcm_native.c:2330:30: sparse: restricted snd_pcm_access_t degrades to integer
>    sound/core/pcm_native.c:2333:38: sparse: restricted snd_pcm_access_t degrades to integer
>    sound/core/pcm_native.c:2335:38: sparse: restricted snd_pcm_access_t degrades to integer
>    sound/core/pcm_native.c:2337:38: sparse: restricted snd_pcm_access_t degrades to integer
>    sound/core/pcm_native.c:2347:86: sparse: restricted snd_pcm_subformat_t degrades to integer
>    include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
>    include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
>    include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
>    include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
>    sound/core/pcm_compat.c:241:32: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
>    sound/core/pcm_compat.c:241:32:    expected signed int [signed] [usertype] [explicitly-signed] state
>    sound/core/pcm_compat.c:241:32:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
>    sound/core/pcm_compat.c:252:42: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
>    sound/core/pcm_compat.c:252:42:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
>    sound/core/pcm_compat.c:252:42:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
>    include/sound/pcm.h:1093:47: sparse: cast removes address space of expression
>    include/sound/pcm.h:1100:47: sparse: cast removes address space of expression
>    sound/core/pcm_compat.c:480:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
>    sound/core/pcm_compat.c:480:13:    expected signed int [signed] [explicitly-signed] __pu_val
>    sound/core/pcm_compat.c:480:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
>    sound/core/pcm_compat.c:483:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
>    sound/core/pcm_compat.c:483:13:    expected signed int [signed] [explicitly-signed] __pu_val
>    sound/core/pcm_compat.c:483:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
>    sound/core/pcm_compat.c:569:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
>    sound/core/pcm_compat.c:569:13:    expected signed int [signed] [explicitly-signed] __pu_val
>    sound/core/pcm_compat.c:569:13:    got restricted snd_pcm_state_t [assigned] [usertype] state
>    sound/core/pcm_compat.c:572:13: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [explicitly-signed] __pu_val @@    got restrictesigned int [signed] [explicitly-signed] __pu_val @@
>    sound/core/pcm_compat.c:572:13:    expected signed int [signed] [explicitly-signed] __pu_val
>    sound/core/pcm_compat.c:572:13:    got restricted snd_pcm_state_t [assigned] [usertype] suspended_state
>    sound/core/pcm_native.c:112:9: sparse: context imbalance in 'snd_pcm_stream_lock' - different lock contexts for basic block
>    sound/core/pcm_native.c:134:28: sparse: context imbalance in 'snd_pcm_stream_unlock' - unexpected unlock
>    sound/core/pcm_native.c:1130:52: sparse: context imbalance in 'snd_pcm_action_group' - unexpected unlock
>
> vim +995 sound/core/pcm_native.c
>
>    971
>    972  static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
>    973                                   struct snd_pcm_status32 __user * _status,
>    974                                   bool ext)
>    975  {
>    976          struct snd_pcm_status64 status64;
>    977          struct snd_pcm_status32 status32;
>    978          int res;
>    979
>    980          memset(&status64, 0, sizeof(status64));
>    981          memset(&status32, 0, sizeof(status32));
>    982          /*
>    983           * with extension, parameters are read/write,
>    984           * get audio_tstamp_data from user,
>    985           * ignore rest of status structure
>    986           */
>    987          if (ext && get_user(status64.audio_tstamp_data,
>    988                              (u32 __user *)(&_status->audio_tstamp_data)))
>    989                  return -EFAULT;
>    990          res = snd_pcm_status64(substream, &status64);
>    991          if (res < 0)
>    992                  return res;
>    993
>    994          status32 = (struct snd_pcm_status32) {
>  > 995                  .state = status64.state,
>    996                  .trigger_tstamp_sec = status64.trigger_tstamp_sec,
>    997                  .trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
>    998                  .tstamp_sec = status64.tstamp_sec,
>    999                  .tstamp_nsec = status64.tstamp_nsec,
>   1000                  .appl_ptr = status64.appl_ptr,
>   1001                  .hw_ptr = status64.hw_ptr,
>   1002                  .delay = status64.delay,
>   1003                  .avail = status64.avail,
>   1004                  .avail_max = status64.avail_max,
>   1005                  .overrange = status64.overrange,
>> 1006                  .suspended_state = status64.suspended_state,

I am not sure for the warning here, we should change 'snd_pcm_state_t'
to 's32' for struct snd_pcm_status64?

typedef int __bitwise snd_pcm_state_t;

-- 
Baolin.wang
Best Regards

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
@ 2018-04-26 11:25     ` kbuild test robot
  2018-04-26  3:07     ` kbuild test robot
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26 11:25 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Arnd,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm.c:1169:67: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1169:67:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1169:67:    got restricted snd_pcm_state_t [usertype] <noident>
>> sound/core/pcm.c:401:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:438:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:499:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1032:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1032:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1032:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:1064:9: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
--
   sound/core/pcm_native.c:561:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:653:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:654:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:655:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:727:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:727:38:    expected int [signed] state
   sound/core/pcm_native.c:727:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:739:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:739:38:    expected int [signed] state
   sound/core/pcm_native.c:739:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:776:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:788:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:788:38:    expected int [signed] state
   sound/core/pcm_native.c:788:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:803:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm_native.c:884:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/pcm_native.c:884:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:884:23:    got signed int [signed] [usertype] [explicitly-signed] state
>> sound/core/pcm_native.c:885:33: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] suspended_state @@    got signed int [srestricted snd_pcm_state_t [usertype] suspended_state @@
   sound/core/pcm_native.c:885:33:    expected restricted snd_pcm_state_t [usertype] suspended_state
   sound/core/pcm_native.c:885:33:    got signed int [signed] [usertype] [explicitly-signed] suspended_state
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:927:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:928:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:935:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:996:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:996:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:996:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_native.c:1007:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1007:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1007:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1031:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1230:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1284:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1284:31:    expected int [signed] state
   sound/core/pcm_native.c:1284:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1291:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1291:40:    expected int [signed] state
   sound/core/pcm_native.c:1291:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1300:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1343:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1343:64:    expected int [signed] state
   sound/core/pcm_native.c:1343:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1359:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1359:38:    expected int [signed] state
   sound/core/pcm_native.c:1359:38:    got restricted snd_pcm_state_t [usertype] <noident>
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1393:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1395:46: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm_native.c:1432:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1432:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1432:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1437:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1437:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1437:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1463:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1485:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1485:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1485:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1569:49: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1570:50: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1627:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1644:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1645:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1646:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1647:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1696:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1697:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1718:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1718:38:    expected int [signed] state
   sound/core/pcm_native.c:1718:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1746:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1749:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1767:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1768:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1769:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1784:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:61:    expected int [signed] state
   sound/core/pcm_native.c:1784:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1785:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1785:63:    expected int [signed] state
   sound/core/pcm_native.c:1785:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1787:56: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1787:56:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1787:56:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1791:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1791:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1791:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1794:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1794:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1794:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1781:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1790:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1793:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1801:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1802:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1802:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1802:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1809:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1951:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1952:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1957:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1850:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1862:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1888:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1918:66: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2006:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2123:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2127:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2127:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2127:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2145:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2149:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2149:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2149:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2329:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2331:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2334:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2336:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2338:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2348:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   sound/core/pcm_native.c:2418:58: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2613:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2617:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2619:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2620:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2622:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2942:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:1093:47: sparse: too many warnings
   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
   sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~
--
>> sound/core/pcm_lib.c:205:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1882:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1885:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1888:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1894:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1895:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1896:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1899:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2069:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2077:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2078:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2079:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2081:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2083:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2178:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2186:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2197:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2245:47: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/oxfw/oxfw-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:100:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:100:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:101:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:101:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:103:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:103:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:104:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:104:32: sparse: expression using sizeof(void)
>> sound/firewire/oxfw/oxfw-pcm.c:221:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:240:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:255:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:270:50: sparse: restricted snd_pcm_state_t degrades to integer
--
>> sound/firewire/tascam/tascam-pcm.c:98:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:118:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:133:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:149:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] access @@    got restricted snd_pcm_access_int [signed] access @@
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21:    expected int [signed] access
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21:    got restricted snd_pcm_access_t [usertype] <noident>
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] format @@    got restricted snd_pcm_format_int [signed] format @@
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21:    expected int [signed] format
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21:    got restricted snd_pcm_format_t [usertype] <noident>
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] access @@    got restricted sndint [signed] access @@
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21:    expected int [signed] access
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21:    got restricted snd_pcm_access_t
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] format @@    got restricted sndint [signed] format @@
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21:    expected int [signed] format
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21:    got restricted snd_pcm_format_t
>> drivers/usb/gadget/function/u_uac1_legacy.c:161:39: sparse: restricted snd_pcm_state_t degrades to integer
   drivers/usb/gadget/function/u_uac1_legacy.c:162:43: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/soc/intel/skylake/skl-pcm.c:159:43: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/soc/intel/skylake/skl-pcm.c:159:43:    expected unsigned int [unsigned] format
   sound/soc/intel/skylake/skl-pcm.c:159:43:    got restricted snd_pcm_format_t [usertype] format
   sound/soc/intel/skylake/skl-pcm.c:195:47: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/soc/intel/skylake/skl-pcm.c:195:47:    expected unsigned int [unsigned] format
   sound/soc/intel/skylake/skl-pcm.c:195:47:    got restricted snd_pcm_format_t [usertype] format
>> sound/soc/intel/skylake/skl-pcm.c:278:41: sparse: restricted snd_pcm_state_t degrades to integer
   sound/soc/intel/skylake/skl-pcm.c:574:55: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/pci/asihpi/asihpi.c:315:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:315:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:315:9:    got int
   sound/pci/asihpi/asihpi.c:318:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:318:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:318:9:    got int
   sound/pci/asihpi/asihpi.c:321:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:321:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:321:9:    got int
   sound/pci/asihpi/asihpi.c:322:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:322:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:322:9:    got int
   sound/pci/asihpi/asihpi.c:324:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:324:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:324:9:    got int
   sound/pci/asihpi/asihpi.c:325:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:325:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:325:9:    got int
   sound/pci/asihpi/asihpi.c:327:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:327:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:327:9:    got int
   sound/pci/asihpi/asihpi.c:328:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:328:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:328:9:    got int
   sound/pci/asihpi/asihpi.c:334:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:334:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:334:9:    got int
   sound/pci/asihpi/asihpi.c:397:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:397:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:398:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:398:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:542:18: sparse: expression using sizeof(void)
>> sound/pci/asihpi/asihpi.c:668:51: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/pci/asihpi/asihpi.c:668:51:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/pci/asihpi/asihpi.c:668:51:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/pci/asihpi/asihpi.c:822:35: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:822:35: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:857:24: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:887:41: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:887:41: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:1026:49: sparse: restricted snd_pcm_format_t degrades to integer
   sound/pci/asihpi/asihpi.c:1208:49: sparse: restricted snd_pcm_format_t degrades to integer
--
   sound/firewire/fireface/ff-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:59:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:59:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:60:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:60:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:84:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:84:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:85:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:85:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:90:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:90:32: sparse: expression using sizeof(void)
>> sound/firewire/fireface/ff-pcm.c:202:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:222:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:237:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:253:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/fireworks/fireworks_pcm.c:82:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:82:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:83:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:83:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:107:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:107:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:108:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:108:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:127:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:127:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:128:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:128:36: sparse: expression using sizeof(void)
>> sound/firewire/fireworks/fireworks_pcm.c:233:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:252:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:265:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:279:50: sparse: restricted snd_pcm_state_t degrades to integer

vim +884 sound/core/pcm_native.c

60f96aae Takashi Sakamoto     2017-06-09  639  
877211f5 Takashi Iwai         2005-11-17  640  static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  641  			     struct snd_pcm_hw_params *params)
^1da177e Linus Torvalds       2005-04-16  642  {
877211f5 Takashi Iwai         2005-11-17  643  	struct snd_pcm_runtime *runtime;
9442e691 Takashi Iwai         2006-09-30  644  	int err, usecs;
^1da177e Linus Torvalds       2005-04-16  645  	unsigned int bits;
^1da177e Linus Torvalds       2005-04-16  646  	snd_pcm_uframes_t frames;
^1da177e Linus Torvalds       2005-04-16  647  
7eaa943c Takashi Iwai         2008-08-08  648  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  649  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  650  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  651  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  652  	switch (runtime->status->state) {
^1da177e Linus Torvalds       2005-04-16  653  	case SNDRV_PCM_STATE_OPEN:
^1da177e Linus Torvalds       2005-04-16  654  	case SNDRV_PCM_STATE_SETUP:
^1da177e Linus Torvalds       2005-04-16  655  	case SNDRV_PCM_STATE_PREPARED:
^1da177e Linus Torvalds       2005-04-16  656  		break;
^1da177e Linus Torvalds       2005-04-16  657  	default:
^1da177e Linus Torvalds       2005-04-16  658  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  659  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  660  	}
^1da177e Linus Torvalds       2005-04-16  661  	snd_pcm_stream_unlock_irq(substream);
8eeaa2f9 Takashi Iwai         2014-02-10  662  #if IS_ENABLED(CONFIG_SND_PCM_OSS)
^1da177e Linus Torvalds       2005-04-16  663  	if (!substream->oss.oss)
^1da177e Linus Torvalds       2005-04-16  664  #endif
9c323fcb Takashi Iwai         2006-04-28  665  		if (atomic_read(&substream->mmap_count))
^1da177e Linus Torvalds       2005-04-16  666  			return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  667  
^1da177e Linus Torvalds       2005-04-16  668  	params->rmask = ~0U;
^1da177e Linus Torvalds       2005-04-16  669  	err = snd_pcm_hw_refine(substream, params);
^1da177e Linus Torvalds       2005-04-16  670  	if (err < 0)
^1da177e Linus Torvalds       2005-04-16  671  		goto _error;
^1da177e Linus Torvalds       2005-04-16  672  
^1da177e Linus Torvalds       2005-04-16  673  	err = snd_pcm_hw_params_choose(substream, params);
^1da177e Linus Torvalds       2005-04-16  674  	if (err < 0)
^1da177e Linus Torvalds       2005-04-16  675  		goto _error;
^1da177e Linus Torvalds       2005-04-16  676  
f9a076bf Takashi Sakamoto     2017-06-09  677  	err = fixup_unreferenced_params(substream, params);
f9a076bf Takashi Sakamoto     2017-06-09  678  	if (err < 0)
f9a076bf Takashi Sakamoto     2017-06-09  679  		goto _error;
f9a076bf Takashi Sakamoto     2017-06-09  680  
^1da177e Linus Torvalds       2005-04-16  681  	if (substream->ops->hw_params != NULL) {
^1da177e Linus Torvalds       2005-04-16  682  		err = substream->ops->hw_params(substream, params);
^1da177e Linus Torvalds       2005-04-16  683  		if (err < 0)
^1da177e Linus Torvalds       2005-04-16  684  			goto _error;
^1da177e Linus Torvalds       2005-04-16  685  	}
^1da177e Linus Torvalds       2005-04-16  686  
^1da177e Linus Torvalds       2005-04-16  687  	runtime->access = params_access(params);
^1da177e Linus Torvalds       2005-04-16  688  	runtime->format = params_format(params);
^1da177e Linus Torvalds       2005-04-16  689  	runtime->subformat = params_subformat(params);
^1da177e Linus Torvalds       2005-04-16  690  	runtime->channels = params_channels(params);
^1da177e Linus Torvalds       2005-04-16  691  	runtime->rate = params_rate(params);
^1da177e Linus Torvalds       2005-04-16  692  	runtime->period_size = params_period_size(params);
^1da177e Linus Torvalds       2005-04-16  693  	runtime->periods = params_periods(params);
^1da177e Linus Torvalds       2005-04-16  694  	runtime->buffer_size = params_buffer_size(params);
^1da177e Linus Torvalds       2005-04-16  695  	runtime->info = params->info;
^1da177e Linus Torvalds       2005-04-16  696  	runtime->rate_num = params->rate_num;
^1da177e Linus Torvalds       2005-04-16  697  	runtime->rate_den = params->rate_den;
ab69a490 Clemens Ladisch      2010-11-15  698  	runtime->no_period_wakeup =
ab69a490 Clemens Ladisch      2010-11-15  699  			(params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) &&
ab69a490 Clemens Ladisch      2010-11-15  700  			(params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP);
^1da177e Linus Torvalds       2005-04-16  701  
^1da177e Linus Torvalds       2005-04-16  702  	bits = snd_pcm_format_physical_width(runtime->format);
^1da177e Linus Torvalds       2005-04-16  703  	runtime->sample_bits = bits;
^1da177e Linus Torvalds       2005-04-16  704  	bits *= runtime->channels;
^1da177e Linus Torvalds       2005-04-16  705  	runtime->frame_bits = bits;
^1da177e Linus Torvalds       2005-04-16  706  	frames = 1;
^1da177e Linus Torvalds       2005-04-16  707  	while (bits % 8 != 0) {
^1da177e Linus Torvalds       2005-04-16  708  		bits *= 2;
^1da177e Linus Torvalds       2005-04-16  709  		frames *= 2;
^1da177e Linus Torvalds       2005-04-16  710  	}
^1da177e Linus Torvalds       2005-04-16  711  	runtime->byte_align = bits / 8;
^1da177e Linus Torvalds       2005-04-16  712  	runtime->min_align = frames;
^1da177e Linus Torvalds       2005-04-16  713  
^1da177e Linus Torvalds       2005-04-16  714  	/* Default sw params */
^1da177e Linus Torvalds       2005-04-16  715  	runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
^1da177e Linus Torvalds       2005-04-16  716  	runtime->period_step = 1;
^1da177e Linus Torvalds       2005-04-16  717  	runtime->control->avail_min = runtime->period_size;
^1da177e Linus Torvalds       2005-04-16  718  	runtime->start_threshold = 1;
^1da177e Linus Torvalds       2005-04-16  719  	runtime->stop_threshold = runtime->buffer_size;
^1da177e Linus Torvalds       2005-04-16  720  	runtime->silence_threshold = 0;
^1da177e Linus Torvalds       2005-04-16  721  	runtime->silence_size = 0;
ead4046b Clemens Ladisch      2010-05-21  722  	runtime->boundary = runtime->buffer_size;
ead4046b Clemens Ladisch      2010-05-21  723  	while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size)
ead4046b Clemens Ladisch      2010-05-21  724  		runtime->boundary *= 2;
^1da177e Linus Torvalds       2005-04-16  725  
^1da177e Linus Torvalds       2005-04-16  726  	snd_pcm_timer_resolution_change(substream);
9b0573c0 Takashi Iwai         2012-10-12  727  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);
9442e691 Takashi Iwai         2006-09-30  728  
82f68251 James Bottomley      2010-07-05  729  	if (pm_qos_request_active(&substream->latency_pm_qos_req))
82f68251 James Bottomley      2010-07-05  730  		pm_qos_remove_request(&substream->latency_pm_qos_req);
9442e691 Takashi Iwai         2006-09-30  731  	if ((usecs = period_to_usecs(runtime)) >= 0)
82f68251 James Bottomley      2010-07-05  732  		pm_qos_add_request(&substream->latency_pm_qos_req,
ed77134b Mark Gross           2010-05-06  733  				   PM_QOS_CPU_DMA_LATENCY, usecs);
^1da177e Linus Torvalds       2005-04-16  734  	return 0;
^1da177e Linus Torvalds       2005-04-16  735   _error:
25985edc Lucas De Marchi      2011-03-30  736  	/* hardware might be unusable from this time,
^1da177e Linus Torvalds       2005-04-16  737  	   so we force application to retry to set
^1da177e Linus Torvalds       2005-04-16  738  	   the correct hardware parameter settings */
9b0573c0 Takashi Iwai         2012-10-12 @739  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
^1da177e Linus Torvalds       2005-04-16  740  	if (substream->ops->hw_free != NULL)
^1da177e Linus Torvalds       2005-04-16  741  		substream->ops->hw_free(substream);
^1da177e Linus Torvalds       2005-04-16  742  	return err;
^1da177e Linus Torvalds       2005-04-16  743  }
^1da177e Linus Torvalds       2005-04-16  744  
877211f5 Takashi Iwai         2005-11-17  745  static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  746  				  struct snd_pcm_hw_params __user * _params)
^1da177e Linus Torvalds       2005-04-16  747  {
877211f5 Takashi Iwai         2005-11-17  748  	struct snd_pcm_hw_params *params;
^1da177e Linus Torvalds       2005-04-16  749  	int err;
^1da177e Linus Torvalds       2005-04-16  750  
ef44a1ec Li Zefan             2009-04-10  751  	params = memdup_user(_params, sizeof(*params));
ef44a1ec Li Zefan             2009-04-10  752  	if (IS_ERR(params))
ef44a1ec Li Zefan             2009-04-10  753  		return PTR_ERR(params);
ef44a1ec Li Zefan             2009-04-10  754  
^1da177e Linus Torvalds       2005-04-16  755  	err = snd_pcm_hw_params(substream, params);
f74ae15f Takashi Sakamoto     2017-06-11  756  	if (err < 0)
f74ae15f Takashi Sakamoto     2017-06-11  757  		goto end;
ef44a1ec Li Zefan             2009-04-10  758  
f74ae15f Takashi Sakamoto     2017-06-11  759  	if (copy_to_user(_params, params, sizeof(*params)))
f74ae15f Takashi Sakamoto     2017-06-11  760  		err = -EFAULT;
f74ae15f Takashi Sakamoto     2017-06-11  761  end:
^1da177e Linus Torvalds       2005-04-16  762  	kfree(params);
^1da177e Linus Torvalds       2005-04-16  763  	return err;
^1da177e Linus Torvalds       2005-04-16  764  }
^1da177e Linus Torvalds       2005-04-16  765  
877211f5 Takashi Iwai         2005-11-17  766  static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
^1da177e Linus Torvalds       2005-04-16  767  {
877211f5 Takashi Iwai         2005-11-17  768  	struct snd_pcm_runtime *runtime;
^1da177e Linus Torvalds       2005-04-16  769  	int result = 0;
^1da177e Linus Torvalds       2005-04-16  770  
7eaa943c Takashi Iwai         2008-08-08  771  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  772  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  773  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  774  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  775  	switch (runtime->status->state) {
^1da177e Linus Torvalds       2005-04-16  776  	case SNDRV_PCM_STATE_SETUP:
^1da177e Linus Torvalds       2005-04-16  777  	case SNDRV_PCM_STATE_PREPARED:
^1da177e Linus Torvalds       2005-04-16  778  		break;
^1da177e Linus Torvalds       2005-04-16  779  	default:
^1da177e Linus Torvalds       2005-04-16  780  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  781  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  782  	}
^1da177e Linus Torvalds       2005-04-16  783  	snd_pcm_stream_unlock_irq(substream);
9c323fcb Takashi Iwai         2006-04-28  784  	if (atomic_read(&substream->mmap_count))
^1da177e Linus Torvalds       2005-04-16  785  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  786  	if (substream->ops->hw_free)
^1da177e Linus Torvalds       2005-04-16  787  		result = substream->ops->hw_free(substream);
9b0573c0 Takashi Iwai         2012-10-12 @788  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
82f68251 James Bottomley      2010-07-05  789  	pm_qos_remove_request(&substream->latency_pm_qos_req);
^1da177e Linus Torvalds       2005-04-16  790  	return result;
^1da177e Linus Torvalds       2005-04-16  791  }
^1da177e Linus Torvalds       2005-04-16  792  
877211f5 Takashi Iwai         2005-11-17  793  static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  794  			     struct snd_pcm_sw_params *params)
^1da177e Linus Torvalds       2005-04-16  795  {
877211f5 Takashi Iwai         2005-11-17  796  	struct snd_pcm_runtime *runtime;
1250932e Jaroslav Kysela      2010-01-07  797  	int err;
^1da177e Linus Torvalds       2005-04-16  798  
7eaa943c Takashi Iwai         2008-08-08  799  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  800  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  801  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  802  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  803  	if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
^1da177e Linus Torvalds       2005-04-16  804  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  805  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  806  	}
^1da177e Linus Torvalds       2005-04-16  807  	snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  808  
145d92e7 Dan Carpenter        2015-09-23  809  	if (params->tstamp_mode < 0 ||
145d92e7 Dan Carpenter        2015-09-23  810  	    params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
^1da177e Linus Torvalds       2005-04-16  811  		return -EINVAL;
58900810 Takashi Iwai         2014-07-16  812  	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12) &&
58900810 Takashi Iwai         2014-07-16  813  	    params->tstamp_type > SNDRV_PCM_TSTAMP_TYPE_LAST)
5646eda5 Takashi Iwai         2014-07-10  814  		return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  815  	if (params->avail_min == 0)
^1da177e Linus Torvalds       2005-04-16  816  		return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  817  	if (params->silence_size >= runtime->boundary) {
^1da177e Linus Torvalds       2005-04-16  818  		if (params->silence_threshold != 0)
^1da177e Linus Torvalds       2005-04-16  819  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  820  	} else {
^1da177e Linus Torvalds       2005-04-16  821  		if (params->silence_size > params->silence_threshold)
^1da177e Linus Torvalds       2005-04-16  822  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  823  		if (params->silence_threshold > runtime->buffer_size)
^1da177e Linus Torvalds       2005-04-16  824  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  825  	}
1250932e Jaroslav Kysela      2010-01-07  826  	err = 0;
^1da177e Linus Torvalds       2005-04-16  827  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  828  	runtime->tstamp_mode = params->tstamp_mode;
58900810 Takashi Iwai         2014-07-16  829  	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12))
5646eda5 Takashi Iwai         2014-07-10  830  		runtime->tstamp_type = params->tstamp_type;
^1da177e Linus Torvalds       2005-04-16  831  	runtime->period_step = params->period_step;
^1da177e Linus Torvalds       2005-04-16  832  	runtime->control->avail_min = params->avail_min;
^1da177e Linus Torvalds       2005-04-16  833  	runtime->start_threshold = params->start_threshold;
^1da177e Linus Torvalds       2005-04-16  834  	runtime->stop_threshold = params->stop_threshold;
^1da177e Linus Torvalds       2005-04-16  835  	runtime->silence_threshold = params->silence_threshold;
^1da177e Linus Torvalds       2005-04-16  836  	runtime->silence_size = params->silence_size;
^1da177e Linus Torvalds       2005-04-16  837          params->boundary = runtime->boundary;
^1da177e Linus Torvalds       2005-04-16  838  	if (snd_pcm_running(substream)) {
^1da177e Linus Torvalds       2005-04-16  839  		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
^1da177e Linus Torvalds       2005-04-16  840  		    runtime->silence_size > 0)
^1da177e Linus Torvalds       2005-04-16  841  			snd_pcm_playback_silence(substream, ULONG_MAX);
1250932e Jaroslav Kysela      2010-01-07  842  		err = snd_pcm_update_state(substream, runtime);
^1da177e Linus Torvalds       2005-04-16  843  	}
^1da177e Linus Torvalds       2005-04-16  844  	snd_pcm_stream_unlock_irq(substream);
1250932e Jaroslav Kysela      2010-01-07  845  	return err;
^1da177e Linus Torvalds       2005-04-16  846  }
^1da177e Linus Torvalds       2005-04-16  847  
877211f5 Takashi Iwai         2005-11-17  848  static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  849  				  struct snd_pcm_sw_params __user * _params)
^1da177e Linus Torvalds       2005-04-16  850  {
877211f5 Takashi Iwai         2005-11-17  851  	struct snd_pcm_sw_params params;
^1da177e Linus Torvalds       2005-04-16  852  	int err;
^1da177e Linus Torvalds       2005-04-16  853  	if (copy_from_user(&params, _params, sizeof(params)))
^1da177e Linus Torvalds       2005-04-16  854  		return -EFAULT;
^1da177e Linus Torvalds       2005-04-16  855  	err = snd_pcm_sw_params(substream, &params);
^1da177e Linus Torvalds       2005-04-16  856  	if (copy_to_user(_params, &params, sizeof(params)))
^1da177e Linus Torvalds       2005-04-16  857  		return -EFAULT;
^1da177e Linus Torvalds       2005-04-16  858  	return err;
^1da177e Linus Torvalds       2005-04-16  859  }
^1da177e Linus Torvalds       2005-04-16  860  
de41e437 Baolin Wang          2018-04-24  861  int snd_pcm_status64(struct snd_pcm_substream *substream,
de41e437 Baolin Wang          2018-04-24  862  		     struct snd_pcm_status64 *status)
^1da177e Linus Torvalds       2005-04-16  863  {
877211f5 Takashi Iwai         2005-11-17  864  	struct snd_pcm_runtime *runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  865  
^1da177e Linus Torvalds       2005-04-16  866  	snd_pcm_stream_lock_irq(substream);
3179f620 Pierre-Louis Bossart 2015-02-13  867  
3179f620 Pierre-Louis Bossart 2015-02-13  868  	snd_pcm_unpack_audio_tstamp_config(status->audio_tstamp_data,
3179f620 Pierre-Louis Bossart 2015-02-13  869  					&runtime->audio_tstamp_config);
3179f620 Pierre-Louis Bossart 2015-02-13  870  
3179f620 Pierre-Louis Bossart 2015-02-13  871  	/* backwards compatible behavior */
3179f620 Pierre-Louis Bossart 2015-02-13  872  	if (runtime->audio_tstamp_config.type_requested ==
3179f620 Pierre-Louis Bossart 2015-02-13  873  		SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT) {
3179f620 Pierre-Louis Bossart 2015-02-13  874  		if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK)
3179f620 Pierre-Louis Bossart 2015-02-13  875  			runtime->audio_tstamp_config.type_requested =
3179f620 Pierre-Louis Bossart 2015-02-13  876  				SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
3179f620 Pierre-Louis Bossart 2015-02-13  877  		else
3179f620 Pierre-Louis Bossart 2015-02-13  878  			runtime->audio_tstamp_config.type_requested =
3179f620 Pierre-Louis Bossart 2015-02-13  879  				SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
3179f620 Pierre-Louis Bossart 2015-02-13  880  		runtime->audio_tstamp_report.valid = 0;
3179f620 Pierre-Louis Bossart 2015-02-13  881  	} else
3179f620 Pierre-Louis Bossart 2015-02-13  882  		runtime->audio_tstamp_report.valid = 1;
3179f620 Pierre-Louis Bossart 2015-02-13  883  
^1da177e Linus Torvalds       2005-04-16 @884  	status->state = runtime->status->state;
^1da177e Linus Torvalds       2005-04-16 @885  	status->suspended_state = runtime->status->suspended_state;
^1da177e Linus Torvalds       2005-04-16  886  	if (status->state == SNDRV_PCM_STATE_OPEN)
^1da177e Linus Torvalds       2005-04-16  887  		goto _end;
de41e437 Baolin Wang          2018-04-24  888  	status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  889  	status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec;
8c121586 Jaroslav Kysela      2008-01-11  890  	if (snd_pcm_running(substream)) {
^1da177e Linus Torvalds       2005-04-16  891  		snd_pcm_update_hw_ptr(substream);
8c121586 Jaroslav Kysela      2008-01-11  892  		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
de41e437 Baolin Wang          2018-04-24  893  			status->tstamp_sec = runtime->status->tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  894  			status->tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  895  				runtime->status->tstamp.tv_nsec;
de41e437 Baolin Wang          2018-04-24  896  			status->driver_tstamp_sec =
de41e437 Baolin Wang          2018-04-24  897  				runtime->driver_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  898  			status->driver_tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  899  				runtime->driver_tstamp.tv_nsec;
de41e437 Baolin Wang          2018-04-24  900  			status->audio_tstamp_sec =
de41e437 Baolin Wang          2018-04-24  901  				runtime->status->audio_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  902  			status->audio_tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  903  				runtime->status->audio_tstamp.tv_nsec;
3179f620 Pierre-Louis Bossart 2015-02-13  904  			if (runtime->audio_tstamp_report.valid == 1)
3179f620 Pierre-Louis Bossart 2015-02-13  905  				/* backwards compatibility, no report provided in COMPAT mode */
3179f620 Pierre-Louis Bossart 2015-02-13  906  				snd_pcm_pack_audio_tstamp_report(&status->audio_tstamp_data,
3179f620 Pierre-Louis Bossart 2015-02-13  907  								&status->audio_tstamp_accuracy,
3179f620 Pierre-Louis Bossart 2015-02-13  908  								&runtime->audio_tstamp_report);
3179f620 Pierre-Louis Bossart 2015-02-13  909  
8c121586 Jaroslav Kysela      2008-01-11  910  			goto _tstamp_end;
8c121586 Jaroslav Kysela      2008-01-11  911  		}
0d59b814 Pierre-Louis Bossart 2015-02-06  912  	} else {
0d59b814 Pierre-Louis Bossart 2015-02-06  913  		/* get tstamp only in fallback mode and only if enabled */
ac8bbfea Baolin Wang          2018-04-24  914  		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
ac8bbfea Baolin Wang          2018-04-24  915  			struct timespec64 tstamp;
ac8bbfea Baolin Wang          2018-04-24  916  
ac8bbfea Baolin Wang          2018-04-24  917  			snd_pcm_gettime(runtime, &tstamp);
de41e437 Baolin Wang          2018-04-24  918  			status->tstamp_sec = tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  919  			status->tstamp_nsec = tstamp.tv_nsec;
ac8bbfea Baolin Wang          2018-04-24  920  		}
0d59b814 Pierre-Louis Bossart 2015-02-06  921  	}
8c121586 Jaroslav Kysela      2008-01-11  922   _tstamp_end:
^1da177e Linus Torvalds       2005-04-16  923  	status->appl_ptr = runtime->control->appl_ptr;
^1da177e Linus Torvalds       2005-04-16  924  	status->hw_ptr = runtime->status->hw_ptr;
^1da177e Linus Torvalds       2005-04-16  925  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
^1da177e Linus Torvalds       2005-04-16  926  		status->avail = snd_pcm_playback_avail(runtime);
^1da177e Linus Torvalds       2005-04-16  927  		if (runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
4bbe1ddf Takashi Iwai         2008-10-13  928  		    runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
^1da177e Linus Torvalds       2005-04-16  929  			status->delay = runtime->buffer_size - status->avail;
4bbe1ddf Takashi Iwai         2008-10-13  930  			status->delay += runtime->delay;
4bbe1ddf Takashi Iwai         2008-10-13  931  		} else
^1da177e Linus Torvalds       2005-04-16  932  			status->delay = 0;
^1da177e Linus Torvalds       2005-04-16  933  	} else {
^1da177e Linus Torvalds       2005-04-16  934  		status->avail = snd_pcm_capture_avail(runtime);
^1da177e Linus Torvalds       2005-04-16  935  		if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
4bbe1ddf Takashi Iwai         2008-10-13  936  			status->delay = status->avail + runtime->delay;
^1da177e Linus Torvalds       2005-04-16  937  		else
^1da177e Linus Torvalds       2005-04-16  938  			status->delay = 0;
^1da177e Linus Torvalds       2005-04-16  939  	}
^1da177e Linus Torvalds       2005-04-16  940  	status->avail_max = runtime->avail_max;
^1da177e Linus Torvalds       2005-04-16  941  	status->overrange = runtime->overrange;
^1da177e Linus Torvalds       2005-04-16  942  	runtime->avail_max = 0;
^1da177e Linus Torvalds       2005-04-16  943  	runtime->overrange = 0;
^1da177e Linus Torvalds       2005-04-16  944   _end:
^1da177e Linus Torvalds       2005-04-16  945   	snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  946  	return 0;
^1da177e Linus Torvalds       2005-04-16  947  }
^1da177e Linus Torvalds       2005-04-16  948  

:::::: The code at line 884 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26 11:25     ` kbuild test robot
  0 siblings, 0 replies; 48+ messages in thread
From: kbuild test robot @ 2018-04-26 11:25 UTC (permalink / raw)
  Cc: kbuild-all, perex, tiwai, arnd, baolin.wang, lgirdwood, broonie,
	o-takashi, mingo, elfring, dan.carpenter, jeeja.kp, vinod.koul,
	guneshwor.o.singh, subhransu.s.prusty, bhumirks,
	gudishax.kranthikumar, naveen.m, hardik.t.shah, arvind.yadav.cs,
	fabf, alsa-devel, linux-kernel

Hi Arnd,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
   sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm.c:1169:67: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1169:67:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1169:67:    got restricted snd_pcm_state_t [usertype] <noident>
>> sound/core/pcm.c:401:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:438:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:499:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm.c:1032:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm.c:1032:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm.c:1032:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm.c:1064:9: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
--
   sound/core/pcm_native.c:561:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:653:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:654:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:655:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:727:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:727:38:    expected int [signed] state
   sound/core/pcm_native.c:727:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:739:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:739:38:    expected int [signed] state
   sound/core/pcm_native.c:739:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:776:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:777:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:788:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:788:38:    expected int [signed] state
   sound/core/pcm_native.c:788:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:803:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm_native.c:884:23: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] state @@    got signed int [srestricted snd_pcm_state_t [usertype] state @@
   sound/core/pcm_native.c:884:23:    expected restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:884:23:    got signed int [signed] [usertype] [explicitly-signed] state
>> sound/core/pcm_native.c:885:33: sparse: incorrect type in assignment (different base types) @@    expected restricted snd_pcm_state_t [usertype] suspended_state @@    got signed int [srestricted snd_pcm_state_t [usertype] suspended_state @@
   sound/core/pcm_native.c:885:33:    expected restricted snd_pcm_state_t [usertype] suspended_state
   sound/core/pcm_native.c:885:33:    got signed int [signed] [usertype] [explicitly-signed] suspended_state
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:927:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:928:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:935:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:996:34: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:996:34:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:996:34:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] state
   sound/core/pcm_native.c:1007:44: sparse: incorrect type in initializer (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] suspended_state @@    got restricted ssigned int [signed] [usertype] [explicitly-signed] suspended_state @@
   sound/core/pcm_native.c:1007:44:    expected signed int [signed] [usertype] [explicitly-signed] suspended_state
   sound/core/pcm_native.c:1007:44:    got restricted snd_pcm_state_t [addressable] [assigned] [usertype] suspended_state
   sound/core/pcm_native.c:1031:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1230:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1284:31: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1284:31:    expected int [signed] state
   sound/core/pcm_native.c:1284:31:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1291:40: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1291:40:    expected int [signed] state
   sound/core/pcm_native.c:1291:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1300:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1343:64: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1343:64:    expected int [signed] state
   sound/core/pcm_native.c:1343:64:    got restricted snd_pcm_state_t [usertype] state
   sound/core/pcm_native.c:1359:38: sparse: incorrect type in argument 3 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1359:38:    expected int [signed] state
   sound/core/pcm_native.c:1359:38:    got restricted snd_pcm_state_t [usertype] <noident>
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1393:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1395:46: sparse: restricted snd_pcm_state_t degrades to integer
>> sound/core/pcm_native.c:1432:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1432:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1432:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1437:40: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1437:40:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1437:40:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1463:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1485:32: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1485:32:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1485:32:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1569:49: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1570:50: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1627:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1644:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1645:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1646:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1647:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1696:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1697:39: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1718:38: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1718:38:    expected int [signed] state
   sound/core/pcm_native.c:1718:38:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1746:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1749:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1767:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1768:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1769:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1784:61: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1784:61:    expected int [signed] state
   sound/core/pcm_native.c:1784:61:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1785:63: sparse: incorrect type in argument 2 (different base types) @@    expected int [signed] state @@    got restricted snd_pcm_state_int [signed] state @@
   sound/core/pcm_native.c:1785:63:    expected int [signed] state
   sound/core/pcm_native.c:1785:63:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1787:56: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1787:56:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1787:56:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1791:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1791:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1791:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1794:48: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/core/pcm_native.c:1794:48:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/core/pcm_native.c:1794:48:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/core/pcm_native.c:1781:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1790:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1793:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1801:47: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1802:76: sparse: incorrect type in initializer (different base types) @@    expected int [signed] new_state @@    got restricted snint [signed] new_state @@
   sound/core/pcm_native.c:1802:76:    expected int [signed] new_state
   sound/core/pcm_native.c:1802:76:    got restricted snd_pcm_state_t
   sound/core/pcm_native.c:1809:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1951:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1952:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1957:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1850:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1862:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1888:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1905:40: sparse: expression using sizeof(void)
   sound/core/pcm_native.c:1918:66: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2006:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2123:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2127:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2127:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2127:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2145:26: sparse: restricted snd_pcm_format_t degrades to integer
   sound/core/pcm_native.c:2149:54: sparse: incorrect type in argument 1 (different base types) @@    expected restricted snd_pcm_format_t [usertype] format @@    got ricted snd_pcm_format_t [usertype] format @@
   sound/core/pcm_native.c:2149:54:    expected restricted snd_pcm_format_t [usertype] format
   sound/core/pcm_native.c:2149:54:    got unsigned int [unsigned] [assigned] k
   sound/core/pcm_native.c:2329:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2331:30: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2334:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2336:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2338:38: sparse: restricted snd_pcm_access_t degrades to integer
   sound/core/pcm_native.c:2348:86: sparse: restricted snd_pcm_subformat_t degrades to integer
   sound/core/pcm_native.c:2418:58: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2613:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2617:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2619:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2620:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2622:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2624:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_native.c:2942:39: sparse: restricted snd_pcm_state_t degrades to integer
>> include/sound/pcm.h:1093:47: sparse: too many warnings
   In file included from sound/core/pcm_native.c:3728:0:
   sound/core/pcm_compat.c: In function 'snd_pcm_ioctl_compat':
   sound/core/pcm_compat.c:580:2: error: duplicate case value
     case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
     ^~~~
   sound/core/pcm_compat.c:547:2: note: previously used here
     case __SNDRV_PCM_IOCTL_SYNC_PTR64:
     ^~~~
--
>> sound/core/pcm_lib.c:205:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1032:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1033:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1405:34: sparse: expression using sizeof(void)
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:676:54: sparse: restricted snd_pcm_state_t degrades to integer
   include/sound/pcm.h:677:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1851:37: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:1882:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1885:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1888:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1894:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1895:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1896:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:1899:22: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2069:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2077:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2078:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2079:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2081:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2083:14: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2178:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2186:39: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2197:55: sparse: restricted snd_pcm_state_t degrades to integer
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2205:42: sparse: expression using sizeof(void)
   sound/core/pcm_lib.c:2245:47: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/oxfw/oxfw-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:100:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:100:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:101:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:101:36: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:103:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:103:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:104:32: sparse: expression using sizeof(void)
   sound/firewire/oxfw/oxfw-pcm.c:104:32: sparse: expression using sizeof(void)
>> sound/firewire/oxfw/oxfw-pcm.c:221:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:240:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:255:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/oxfw/oxfw-pcm.c:270:50: sparse: restricted snd_pcm_state_t degrades to integer
--
>> sound/firewire/tascam/tascam-pcm.c:98:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:118:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:133:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/tascam/tascam-pcm.c:149:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] access @@    got restricted snd_pcm_access_int [signed] access @@
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21:    expected int [signed] access
   drivers/usb/gadget/function/u_uac1_legacy.c:104:21:    got restricted snd_pcm_access_t [usertype] <noident>
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] format @@    got restricted snd_pcm_format_int [signed] format @@
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21:    expected int [signed] format
   drivers/usb/gadget/function/u_uac1_legacy.c:105:21:    got restricted snd_pcm_format_t [usertype] <noident>
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] access @@    got restricted sndint [signed] access @@
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21:    expected int [signed] access
   drivers/usb/gadget/function/u_uac1_legacy.c:135:21:    got restricted snd_pcm_access_t
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21: sparse: incorrect type in assignment (different base types) @@    expected int [signed] format @@    got restricted sndint [signed] format @@
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21:    expected int [signed] format
   drivers/usb/gadget/function/u_uac1_legacy.c:136:21:    got restricted snd_pcm_format_t
>> drivers/usb/gadget/function/u_uac1_legacy.c:161:39: sparse: restricted snd_pcm_state_t degrades to integer
   drivers/usb/gadget/function/u_uac1_legacy.c:162:43: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/soc/intel/skylake/skl-pcm.c:159:43: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/soc/intel/skylake/skl-pcm.c:159:43:    expected unsigned int [unsigned] format
   sound/soc/intel/skylake/skl-pcm.c:159:43:    got restricted snd_pcm_format_t [usertype] format
   sound/soc/intel/skylake/skl-pcm.c:195:47: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned int [unsigned] format @@    got restricted snd_unsigned int [unsigned] format @@
   sound/soc/intel/skylake/skl-pcm.c:195:47:    expected unsigned int [unsigned] format
   sound/soc/intel/skylake/skl-pcm.c:195:47:    got restricted snd_pcm_format_t [usertype] format
>> sound/soc/intel/skylake/skl-pcm.c:278:41: sparse: restricted snd_pcm_state_t degrades to integer
   sound/soc/intel/skylake/skl-pcm.c:574:55: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/pci/asihpi/asihpi.c:315:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:315:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:315:9:    got int
   sound/pci/asihpi/asihpi.c:318:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:318:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:318:9:    got int
   sound/pci/asihpi/asihpi.c:321:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:321:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:321:9:    got int
   sound/pci/asihpi/asihpi.c:322:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:322:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:322:9:    got int
   sound/pci/asihpi/asihpi.c:324:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:324:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:324:9:    got int
   sound/pci/asihpi/asihpi.c:325:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:325:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:325:9:    got int
   sound/pci/asihpi/asihpi.c:327:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:327:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:327:9:    got int
   sound/pci/asihpi/asihpi.c:328:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:328:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:328:9:    got int
   sound/pci/asihpi/asihpi.c:334:9: sparse: incorrect type in initializer (different base types) @@    expected restricted snd_pcm_format_t @@    got t_t @@
   sound/pci/asihpi/asihpi.c:334:9:    expected restricted snd_pcm_format_t
   sound/pci/asihpi/asihpi.c:334:9:    got int
   sound/pci/asihpi/asihpi.c:397:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:397:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:398:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:398:36: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:542:18: sparse: expression using sizeof(void)
>> sound/pci/asihpi/asihpi.c:668:51: sparse: incorrect type in assignment (different base types) @@    expected signed int [signed] [usertype] [explicitly-signed] state @@    got igned] [usertype] [explicitly-signed] state @@
   sound/pci/asihpi/asihpi.c:668:51:    expected signed int [signed] [usertype] [explicitly-signed] state
   sound/pci/asihpi/asihpi.c:668:51:    got restricted snd_pcm_state_t [usertype] <noident>
   sound/pci/asihpi/asihpi.c:822:35: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:822:35: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:857:24: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:887:41: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:887:41: sparse: expression using sizeof(void)
   sound/pci/asihpi/asihpi.c:1026:49: sparse: restricted snd_pcm_format_t degrades to integer
   sound/pci/asihpi/asihpi.c:1208:49: sparse: restricted snd_pcm_format_t degrades to integer
--
   sound/firewire/fireface/ff-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:34:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:35:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:59:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:59:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:60:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:60:25: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:84:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:84:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:85:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:85:36: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:89:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:90:32: sparse: expression using sizeof(void)
   sound/firewire/fireface/ff-pcm.c:90:32: sparse: expression using sizeof(void)
>> sound/firewire/fireface/ff-pcm.c:202:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:222:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:237:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireface/ff-pcm.c:253:50: sparse: restricted snd_pcm_state_t degrades to integer
--
   sound/firewire/fireworks/fireworks_pcm.c:82:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:82:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:83:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:83:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:107:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:107:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:108:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:108:25: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:127:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:127:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:128:36: sparse: expression using sizeof(void)
   sound/firewire/fireworks/fireworks_pcm.c:128:36: sparse: expression using sizeof(void)
>> sound/firewire/fireworks/fireworks_pcm.c:233:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:252:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:265:50: sparse: restricted snd_pcm_state_t degrades to integer
   sound/firewire/fireworks/fireworks_pcm.c:279:50: sparse: restricted snd_pcm_state_t degrades to integer

vim +884 sound/core/pcm_native.c

60f96aae Takashi Sakamoto     2017-06-09  639  
877211f5 Takashi Iwai         2005-11-17  640  static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  641  			     struct snd_pcm_hw_params *params)
^1da177e Linus Torvalds       2005-04-16  642  {
877211f5 Takashi Iwai         2005-11-17  643  	struct snd_pcm_runtime *runtime;
9442e691 Takashi Iwai         2006-09-30  644  	int err, usecs;
^1da177e Linus Torvalds       2005-04-16  645  	unsigned int bits;
^1da177e Linus Torvalds       2005-04-16  646  	snd_pcm_uframes_t frames;
^1da177e Linus Torvalds       2005-04-16  647  
7eaa943c Takashi Iwai         2008-08-08  648  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  649  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  650  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  651  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  652  	switch (runtime->status->state) {
^1da177e Linus Torvalds       2005-04-16  653  	case SNDRV_PCM_STATE_OPEN:
^1da177e Linus Torvalds       2005-04-16  654  	case SNDRV_PCM_STATE_SETUP:
^1da177e Linus Torvalds       2005-04-16  655  	case SNDRV_PCM_STATE_PREPARED:
^1da177e Linus Torvalds       2005-04-16  656  		break;
^1da177e Linus Torvalds       2005-04-16  657  	default:
^1da177e Linus Torvalds       2005-04-16  658  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  659  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  660  	}
^1da177e Linus Torvalds       2005-04-16  661  	snd_pcm_stream_unlock_irq(substream);
8eeaa2f9 Takashi Iwai         2014-02-10  662  #if IS_ENABLED(CONFIG_SND_PCM_OSS)
^1da177e Linus Torvalds       2005-04-16  663  	if (!substream->oss.oss)
^1da177e Linus Torvalds       2005-04-16  664  #endif
9c323fcb Takashi Iwai         2006-04-28  665  		if (atomic_read(&substream->mmap_count))
^1da177e Linus Torvalds       2005-04-16  666  			return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  667  
^1da177e Linus Torvalds       2005-04-16  668  	params->rmask = ~0U;
^1da177e Linus Torvalds       2005-04-16  669  	err = snd_pcm_hw_refine(substream, params);
^1da177e Linus Torvalds       2005-04-16  670  	if (err < 0)
^1da177e Linus Torvalds       2005-04-16  671  		goto _error;
^1da177e Linus Torvalds       2005-04-16  672  
^1da177e Linus Torvalds       2005-04-16  673  	err = snd_pcm_hw_params_choose(substream, params);
^1da177e Linus Torvalds       2005-04-16  674  	if (err < 0)
^1da177e Linus Torvalds       2005-04-16  675  		goto _error;
^1da177e Linus Torvalds       2005-04-16  676  
f9a076bf Takashi Sakamoto     2017-06-09  677  	err = fixup_unreferenced_params(substream, params);
f9a076bf Takashi Sakamoto     2017-06-09  678  	if (err < 0)
f9a076bf Takashi Sakamoto     2017-06-09  679  		goto _error;
f9a076bf Takashi Sakamoto     2017-06-09  680  
^1da177e Linus Torvalds       2005-04-16  681  	if (substream->ops->hw_params != NULL) {
^1da177e Linus Torvalds       2005-04-16  682  		err = substream->ops->hw_params(substream, params);
^1da177e Linus Torvalds       2005-04-16  683  		if (err < 0)
^1da177e Linus Torvalds       2005-04-16  684  			goto _error;
^1da177e Linus Torvalds       2005-04-16  685  	}
^1da177e Linus Torvalds       2005-04-16  686  
^1da177e Linus Torvalds       2005-04-16  687  	runtime->access = params_access(params);
^1da177e Linus Torvalds       2005-04-16  688  	runtime->format = params_format(params);
^1da177e Linus Torvalds       2005-04-16  689  	runtime->subformat = params_subformat(params);
^1da177e Linus Torvalds       2005-04-16  690  	runtime->channels = params_channels(params);
^1da177e Linus Torvalds       2005-04-16  691  	runtime->rate = params_rate(params);
^1da177e Linus Torvalds       2005-04-16  692  	runtime->period_size = params_period_size(params);
^1da177e Linus Torvalds       2005-04-16  693  	runtime->periods = params_periods(params);
^1da177e Linus Torvalds       2005-04-16  694  	runtime->buffer_size = params_buffer_size(params);
^1da177e Linus Torvalds       2005-04-16  695  	runtime->info = params->info;
^1da177e Linus Torvalds       2005-04-16  696  	runtime->rate_num = params->rate_num;
^1da177e Linus Torvalds       2005-04-16  697  	runtime->rate_den = params->rate_den;
ab69a490 Clemens Ladisch      2010-11-15  698  	runtime->no_period_wakeup =
ab69a490 Clemens Ladisch      2010-11-15  699  			(params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) &&
ab69a490 Clemens Ladisch      2010-11-15  700  			(params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP);
^1da177e Linus Torvalds       2005-04-16  701  
^1da177e Linus Torvalds       2005-04-16  702  	bits = snd_pcm_format_physical_width(runtime->format);
^1da177e Linus Torvalds       2005-04-16  703  	runtime->sample_bits = bits;
^1da177e Linus Torvalds       2005-04-16  704  	bits *= runtime->channels;
^1da177e Linus Torvalds       2005-04-16  705  	runtime->frame_bits = bits;
^1da177e Linus Torvalds       2005-04-16  706  	frames = 1;
^1da177e Linus Torvalds       2005-04-16  707  	while (bits % 8 != 0) {
^1da177e Linus Torvalds       2005-04-16  708  		bits *= 2;
^1da177e Linus Torvalds       2005-04-16  709  		frames *= 2;
^1da177e Linus Torvalds       2005-04-16  710  	}
^1da177e Linus Torvalds       2005-04-16  711  	runtime->byte_align = bits / 8;
^1da177e Linus Torvalds       2005-04-16  712  	runtime->min_align = frames;
^1da177e Linus Torvalds       2005-04-16  713  
^1da177e Linus Torvalds       2005-04-16  714  	/* Default sw params */
^1da177e Linus Torvalds       2005-04-16  715  	runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
^1da177e Linus Torvalds       2005-04-16  716  	runtime->period_step = 1;
^1da177e Linus Torvalds       2005-04-16  717  	runtime->control->avail_min = runtime->period_size;
^1da177e Linus Torvalds       2005-04-16  718  	runtime->start_threshold = 1;
^1da177e Linus Torvalds       2005-04-16  719  	runtime->stop_threshold = runtime->buffer_size;
^1da177e Linus Torvalds       2005-04-16  720  	runtime->silence_threshold = 0;
^1da177e Linus Torvalds       2005-04-16  721  	runtime->silence_size = 0;
ead4046b Clemens Ladisch      2010-05-21  722  	runtime->boundary = runtime->buffer_size;
ead4046b Clemens Ladisch      2010-05-21  723  	while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size)
ead4046b Clemens Ladisch      2010-05-21  724  		runtime->boundary *= 2;
^1da177e Linus Torvalds       2005-04-16  725  
^1da177e Linus Torvalds       2005-04-16  726  	snd_pcm_timer_resolution_change(substream);
9b0573c0 Takashi Iwai         2012-10-12  727  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);
9442e691 Takashi Iwai         2006-09-30  728  
82f68251 James Bottomley      2010-07-05  729  	if (pm_qos_request_active(&substream->latency_pm_qos_req))
82f68251 James Bottomley      2010-07-05  730  		pm_qos_remove_request(&substream->latency_pm_qos_req);
9442e691 Takashi Iwai         2006-09-30  731  	if ((usecs = period_to_usecs(runtime)) >= 0)
82f68251 James Bottomley      2010-07-05  732  		pm_qos_add_request(&substream->latency_pm_qos_req,
ed77134b Mark Gross           2010-05-06  733  				   PM_QOS_CPU_DMA_LATENCY, usecs);
^1da177e Linus Torvalds       2005-04-16  734  	return 0;
^1da177e Linus Torvalds       2005-04-16  735   _error:
25985edc Lucas De Marchi      2011-03-30  736  	/* hardware might be unusable from this time,
^1da177e Linus Torvalds       2005-04-16  737  	   so we force application to retry to set
^1da177e Linus Torvalds       2005-04-16  738  	   the correct hardware parameter settings */
9b0573c0 Takashi Iwai         2012-10-12 @739  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
^1da177e Linus Torvalds       2005-04-16  740  	if (substream->ops->hw_free != NULL)
^1da177e Linus Torvalds       2005-04-16  741  		substream->ops->hw_free(substream);
^1da177e Linus Torvalds       2005-04-16  742  	return err;
^1da177e Linus Torvalds       2005-04-16  743  }
^1da177e Linus Torvalds       2005-04-16  744  
877211f5 Takashi Iwai         2005-11-17  745  static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  746  				  struct snd_pcm_hw_params __user * _params)
^1da177e Linus Torvalds       2005-04-16  747  {
877211f5 Takashi Iwai         2005-11-17  748  	struct snd_pcm_hw_params *params;
^1da177e Linus Torvalds       2005-04-16  749  	int err;
^1da177e Linus Torvalds       2005-04-16  750  
ef44a1ec Li Zefan             2009-04-10  751  	params = memdup_user(_params, sizeof(*params));
ef44a1ec Li Zefan             2009-04-10  752  	if (IS_ERR(params))
ef44a1ec Li Zefan             2009-04-10  753  		return PTR_ERR(params);
ef44a1ec Li Zefan             2009-04-10  754  
^1da177e Linus Torvalds       2005-04-16  755  	err = snd_pcm_hw_params(substream, params);
f74ae15f Takashi Sakamoto     2017-06-11  756  	if (err < 0)
f74ae15f Takashi Sakamoto     2017-06-11  757  		goto end;
ef44a1ec Li Zefan             2009-04-10  758  
f74ae15f Takashi Sakamoto     2017-06-11  759  	if (copy_to_user(_params, params, sizeof(*params)))
f74ae15f Takashi Sakamoto     2017-06-11  760  		err = -EFAULT;
f74ae15f Takashi Sakamoto     2017-06-11  761  end:
^1da177e Linus Torvalds       2005-04-16  762  	kfree(params);
^1da177e Linus Torvalds       2005-04-16  763  	return err;
^1da177e Linus Torvalds       2005-04-16  764  }
^1da177e Linus Torvalds       2005-04-16  765  
877211f5 Takashi Iwai         2005-11-17  766  static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
^1da177e Linus Torvalds       2005-04-16  767  {
877211f5 Takashi Iwai         2005-11-17  768  	struct snd_pcm_runtime *runtime;
^1da177e Linus Torvalds       2005-04-16  769  	int result = 0;
^1da177e Linus Torvalds       2005-04-16  770  
7eaa943c Takashi Iwai         2008-08-08  771  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  772  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  773  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  774  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  775  	switch (runtime->status->state) {
^1da177e Linus Torvalds       2005-04-16  776  	case SNDRV_PCM_STATE_SETUP:
^1da177e Linus Torvalds       2005-04-16  777  	case SNDRV_PCM_STATE_PREPARED:
^1da177e Linus Torvalds       2005-04-16  778  		break;
^1da177e Linus Torvalds       2005-04-16  779  	default:
^1da177e Linus Torvalds       2005-04-16  780  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  781  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  782  	}
^1da177e Linus Torvalds       2005-04-16  783  	snd_pcm_stream_unlock_irq(substream);
9c323fcb Takashi Iwai         2006-04-28  784  	if (atomic_read(&substream->mmap_count))
^1da177e Linus Torvalds       2005-04-16  785  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  786  	if (substream->ops->hw_free)
^1da177e Linus Torvalds       2005-04-16  787  		result = substream->ops->hw_free(substream);
9b0573c0 Takashi Iwai         2012-10-12 @788  	snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
82f68251 James Bottomley      2010-07-05  789  	pm_qos_remove_request(&substream->latency_pm_qos_req);
^1da177e Linus Torvalds       2005-04-16  790  	return result;
^1da177e Linus Torvalds       2005-04-16  791  }
^1da177e Linus Torvalds       2005-04-16  792  
877211f5 Takashi Iwai         2005-11-17  793  static int snd_pcm_sw_params(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  794  			     struct snd_pcm_sw_params *params)
^1da177e Linus Torvalds       2005-04-16  795  {
877211f5 Takashi Iwai         2005-11-17  796  	struct snd_pcm_runtime *runtime;
1250932e Jaroslav Kysela      2010-01-07  797  	int err;
^1da177e Linus Torvalds       2005-04-16  798  
7eaa943c Takashi Iwai         2008-08-08  799  	if (PCM_RUNTIME_CHECK(substream))
7eaa943c Takashi Iwai         2008-08-08  800  		return -ENXIO;
^1da177e Linus Torvalds       2005-04-16  801  	runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  802  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  803  	if (runtime->status->state == SNDRV_PCM_STATE_OPEN) {
^1da177e Linus Torvalds       2005-04-16  804  		snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  805  		return -EBADFD;
^1da177e Linus Torvalds       2005-04-16  806  	}
^1da177e Linus Torvalds       2005-04-16  807  	snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  808  
145d92e7 Dan Carpenter        2015-09-23  809  	if (params->tstamp_mode < 0 ||
145d92e7 Dan Carpenter        2015-09-23  810  	    params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST)
^1da177e Linus Torvalds       2005-04-16  811  		return -EINVAL;
58900810 Takashi Iwai         2014-07-16  812  	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12) &&
58900810 Takashi Iwai         2014-07-16  813  	    params->tstamp_type > SNDRV_PCM_TSTAMP_TYPE_LAST)
5646eda5 Takashi Iwai         2014-07-10  814  		return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  815  	if (params->avail_min == 0)
^1da177e Linus Torvalds       2005-04-16  816  		return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  817  	if (params->silence_size >= runtime->boundary) {
^1da177e Linus Torvalds       2005-04-16  818  		if (params->silence_threshold != 0)
^1da177e Linus Torvalds       2005-04-16  819  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  820  	} else {
^1da177e Linus Torvalds       2005-04-16  821  		if (params->silence_size > params->silence_threshold)
^1da177e Linus Torvalds       2005-04-16  822  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  823  		if (params->silence_threshold > runtime->buffer_size)
^1da177e Linus Torvalds       2005-04-16  824  			return -EINVAL;
^1da177e Linus Torvalds       2005-04-16  825  	}
1250932e Jaroslav Kysela      2010-01-07  826  	err = 0;
^1da177e Linus Torvalds       2005-04-16  827  	snd_pcm_stream_lock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  828  	runtime->tstamp_mode = params->tstamp_mode;
58900810 Takashi Iwai         2014-07-16  829  	if (params->proto >= SNDRV_PROTOCOL_VERSION(2, 0, 12))
5646eda5 Takashi Iwai         2014-07-10  830  		runtime->tstamp_type = params->tstamp_type;
^1da177e Linus Torvalds       2005-04-16  831  	runtime->period_step = params->period_step;
^1da177e Linus Torvalds       2005-04-16  832  	runtime->control->avail_min = params->avail_min;
^1da177e Linus Torvalds       2005-04-16  833  	runtime->start_threshold = params->start_threshold;
^1da177e Linus Torvalds       2005-04-16  834  	runtime->stop_threshold = params->stop_threshold;
^1da177e Linus Torvalds       2005-04-16  835  	runtime->silence_threshold = params->silence_threshold;
^1da177e Linus Torvalds       2005-04-16  836  	runtime->silence_size = params->silence_size;
^1da177e Linus Torvalds       2005-04-16  837          params->boundary = runtime->boundary;
^1da177e Linus Torvalds       2005-04-16  838  	if (snd_pcm_running(substream)) {
^1da177e Linus Torvalds       2005-04-16  839  		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
^1da177e Linus Torvalds       2005-04-16  840  		    runtime->silence_size > 0)
^1da177e Linus Torvalds       2005-04-16  841  			snd_pcm_playback_silence(substream, ULONG_MAX);
1250932e Jaroslav Kysela      2010-01-07  842  		err = snd_pcm_update_state(substream, runtime);
^1da177e Linus Torvalds       2005-04-16  843  	}
^1da177e Linus Torvalds       2005-04-16  844  	snd_pcm_stream_unlock_irq(substream);
1250932e Jaroslav Kysela      2010-01-07  845  	return err;
^1da177e Linus Torvalds       2005-04-16  846  }
^1da177e Linus Torvalds       2005-04-16  847  
877211f5 Takashi Iwai         2005-11-17  848  static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream,
877211f5 Takashi Iwai         2005-11-17  849  				  struct snd_pcm_sw_params __user * _params)
^1da177e Linus Torvalds       2005-04-16  850  {
877211f5 Takashi Iwai         2005-11-17  851  	struct snd_pcm_sw_params params;
^1da177e Linus Torvalds       2005-04-16  852  	int err;
^1da177e Linus Torvalds       2005-04-16  853  	if (copy_from_user(&params, _params, sizeof(params)))
^1da177e Linus Torvalds       2005-04-16  854  		return -EFAULT;
^1da177e Linus Torvalds       2005-04-16  855  	err = snd_pcm_sw_params(substream, &params);
^1da177e Linus Torvalds       2005-04-16  856  	if (copy_to_user(_params, &params, sizeof(params)))
^1da177e Linus Torvalds       2005-04-16  857  		return -EFAULT;
^1da177e Linus Torvalds       2005-04-16  858  	return err;
^1da177e Linus Torvalds       2005-04-16  859  }
^1da177e Linus Torvalds       2005-04-16  860  
de41e437 Baolin Wang          2018-04-24  861  int snd_pcm_status64(struct snd_pcm_substream *substream,
de41e437 Baolin Wang          2018-04-24  862  		     struct snd_pcm_status64 *status)
^1da177e Linus Torvalds       2005-04-16  863  {
877211f5 Takashi Iwai         2005-11-17  864  	struct snd_pcm_runtime *runtime = substream->runtime;
^1da177e Linus Torvalds       2005-04-16  865  
^1da177e Linus Torvalds       2005-04-16  866  	snd_pcm_stream_lock_irq(substream);
3179f620 Pierre-Louis Bossart 2015-02-13  867  
3179f620 Pierre-Louis Bossart 2015-02-13  868  	snd_pcm_unpack_audio_tstamp_config(status->audio_tstamp_data,
3179f620 Pierre-Louis Bossart 2015-02-13  869  					&runtime->audio_tstamp_config);
3179f620 Pierre-Louis Bossart 2015-02-13  870  
3179f620 Pierre-Louis Bossart 2015-02-13  871  	/* backwards compatible behavior */
3179f620 Pierre-Louis Bossart 2015-02-13  872  	if (runtime->audio_tstamp_config.type_requested ==
3179f620 Pierre-Louis Bossart 2015-02-13  873  		SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT) {
3179f620 Pierre-Louis Bossart 2015-02-13  874  		if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK)
3179f620 Pierre-Louis Bossart 2015-02-13  875  			runtime->audio_tstamp_config.type_requested =
3179f620 Pierre-Louis Bossart 2015-02-13  876  				SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
3179f620 Pierre-Louis Bossart 2015-02-13  877  		else
3179f620 Pierre-Louis Bossart 2015-02-13  878  			runtime->audio_tstamp_config.type_requested =
3179f620 Pierre-Louis Bossart 2015-02-13  879  				SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
3179f620 Pierre-Louis Bossart 2015-02-13  880  		runtime->audio_tstamp_report.valid = 0;
3179f620 Pierre-Louis Bossart 2015-02-13  881  	} else
3179f620 Pierre-Louis Bossart 2015-02-13  882  		runtime->audio_tstamp_report.valid = 1;
3179f620 Pierre-Louis Bossart 2015-02-13  883  
^1da177e Linus Torvalds       2005-04-16 @884  	status->state = runtime->status->state;
^1da177e Linus Torvalds       2005-04-16 @885  	status->suspended_state = runtime->status->suspended_state;
^1da177e Linus Torvalds       2005-04-16  886  	if (status->state == SNDRV_PCM_STATE_OPEN)
^1da177e Linus Torvalds       2005-04-16  887  		goto _end;
de41e437 Baolin Wang          2018-04-24  888  	status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  889  	status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec;
8c121586 Jaroslav Kysela      2008-01-11  890  	if (snd_pcm_running(substream)) {
^1da177e Linus Torvalds       2005-04-16  891  		snd_pcm_update_hw_ptr(substream);
8c121586 Jaroslav Kysela      2008-01-11  892  		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
de41e437 Baolin Wang          2018-04-24  893  			status->tstamp_sec = runtime->status->tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  894  			status->tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  895  				runtime->status->tstamp.tv_nsec;
de41e437 Baolin Wang          2018-04-24  896  			status->driver_tstamp_sec =
de41e437 Baolin Wang          2018-04-24  897  				runtime->driver_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  898  			status->driver_tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  899  				runtime->driver_tstamp.tv_nsec;
de41e437 Baolin Wang          2018-04-24  900  			status->audio_tstamp_sec =
de41e437 Baolin Wang          2018-04-24  901  				runtime->status->audio_tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  902  			status->audio_tstamp_nsec =
de41e437 Baolin Wang          2018-04-24  903  				runtime->status->audio_tstamp.tv_nsec;
3179f620 Pierre-Louis Bossart 2015-02-13  904  			if (runtime->audio_tstamp_report.valid == 1)
3179f620 Pierre-Louis Bossart 2015-02-13  905  				/* backwards compatibility, no report provided in COMPAT mode */
3179f620 Pierre-Louis Bossart 2015-02-13  906  				snd_pcm_pack_audio_tstamp_report(&status->audio_tstamp_data,
3179f620 Pierre-Louis Bossart 2015-02-13  907  								&status->audio_tstamp_accuracy,
3179f620 Pierre-Louis Bossart 2015-02-13  908  								&runtime->audio_tstamp_report);
3179f620 Pierre-Louis Bossart 2015-02-13  909  
8c121586 Jaroslav Kysela      2008-01-11  910  			goto _tstamp_end;
8c121586 Jaroslav Kysela      2008-01-11  911  		}
0d59b814 Pierre-Louis Bossart 2015-02-06  912  	} else {
0d59b814 Pierre-Louis Bossart 2015-02-06  913  		/* get tstamp only in fallback mode and only if enabled */
ac8bbfea Baolin Wang          2018-04-24  914  		if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
ac8bbfea Baolin Wang          2018-04-24  915  			struct timespec64 tstamp;
ac8bbfea Baolin Wang          2018-04-24  916  
ac8bbfea Baolin Wang          2018-04-24  917  			snd_pcm_gettime(runtime, &tstamp);
de41e437 Baolin Wang          2018-04-24  918  			status->tstamp_sec = tstamp.tv_sec;
de41e437 Baolin Wang          2018-04-24  919  			status->tstamp_nsec = tstamp.tv_nsec;
ac8bbfea Baolin Wang          2018-04-24  920  		}
0d59b814 Pierre-Louis Bossart 2015-02-06  921  	}
8c121586 Jaroslav Kysela      2008-01-11  922   _tstamp_end:
^1da177e Linus Torvalds       2005-04-16  923  	status->appl_ptr = runtime->control->appl_ptr;
^1da177e Linus Torvalds       2005-04-16  924  	status->hw_ptr = runtime->status->hw_ptr;
^1da177e Linus Torvalds       2005-04-16  925  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
^1da177e Linus Torvalds       2005-04-16  926  		status->avail = snd_pcm_playback_avail(runtime);
^1da177e Linus Torvalds       2005-04-16  927  		if (runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
4bbe1ddf Takashi Iwai         2008-10-13  928  		    runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
^1da177e Linus Torvalds       2005-04-16  929  			status->delay = runtime->buffer_size - status->avail;
4bbe1ddf Takashi Iwai         2008-10-13  930  			status->delay += runtime->delay;
4bbe1ddf Takashi Iwai         2008-10-13  931  		} else
^1da177e Linus Torvalds       2005-04-16  932  			status->delay = 0;
^1da177e Linus Torvalds       2005-04-16  933  	} else {
^1da177e Linus Torvalds       2005-04-16  934  		status->avail = snd_pcm_capture_avail(runtime);
^1da177e Linus Torvalds       2005-04-16  935  		if (runtime->status->state == SNDRV_PCM_STATE_RUNNING)
4bbe1ddf Takashi Iwai         2008-10-13  936  			status->delay = status->avail + runtime->delay;
^1da177e Linus Torvalds       2005-04-16  937  		else
^1da177e Linus Torvalds       2005-04-16  938  			status->delay = 0;
^1da177e Linus Torvalds       2005-04-16  939  	}
^1da177e Linus Torvalds       2005-04-16  940  	status->avail_max = runtime->avail_max;
^1da177e Linus Torvalds       2005-04-16  941  	status->overrange = runtime->overrange;
^1da177e Linus Torvalds       2005-04-16  942  	runtime->avail_max = 0;
^1da177e Linus Torvalds       2005-04-16  943  	runtime->overrange = 0;
^1da177e Linus Torvalds       2005-04-16  944   _end:
^1da177e Linus Torvalds       2005-04-16  945   	snd_pcm_stream_unlock_irq(substream);
^1da177e Linus Torvalds       2005-04-16  946  	return 0;
^1da177e Linus Torvalds       2005-04-16  947  }
^1da177e Linus Torvalds       2005-04-16  948  

:::::: The code at line 884 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-26 11:25     ` kbuild test robot
@ 2018-04-26 11:31       ` Arnd Bergmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 11:31 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Baolin Wang, kbuild-all, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, Linux Kernel Mailing List

On Thu, Apr 26, 2018 at 1:25 PM, kbuild test robot <lkp@intel.com> wrote:
> Hi Arnd,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on v4.17-rc2]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> reproduce:
>         # apt-get install sparse
>         make ARCH=x86_64 allmodconfig
>         make C=1 CF=-D__CHECK_ENDIAN__
>
>
> sparse warnings: (new ones prefixed by >>)
>
>    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer

>From what I can tell, these are all existing driver problems, no idea why we now
have one more warning than before.

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26 11:31       ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 11:31 UTC (permalink / raw)
  To: kbuild test robot
  Cc: alsa-devel, Liam Girdwood, jeeja.kp, SF Markus Elfring,
	Vinod Koul, Takashi Iwai, Guneshwor Singh, Ingo Molnar,
	gudishax.kranthikumar, Arvind Yadav, subhransu.s.prusty,
	Dan Carpenter, hardik.t.shah, Fabian Frederick, Mark Brown,
	Naveen M, Baolin Wang, Linux Kernel Mailing List,
	Takashi Sakamoto, kbuild-all, Bhumika Goyal

On Thu, Apr 26, 2018 at 1:25 PM, kbuild test robot <lkp@intel.com> wrote:
> Hi Arnd,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on v4.17-rc2]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> reproduce:
>         # apt-get install sparse
>         make ARCH=x86_64 allmodconfig
>         make C=1 CF=-D__CHECK_ENDIAN__
>
>
> sparse warnings: (new ones prefixed by >>)
>
>    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
>>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
>    sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer

>From what I can tell, these are all existing driver problems, no idea why we now
have one more warning than before.

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-26  3:07     ` kbuild test robot
@ 2018-04-26 11:34       ` Arnd Bergmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 11:34 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Baolin Wang, kbuild-all, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, Linux Kernel Mailing List

On Thu, Apr 26, 2018 at 5:07 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Arnd,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on v4.17-rc2]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> config: i386-randconfig-n0-201816 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
>>> sound/core/pcm_native.c:2827:25: error: field 'tstamp' has incomplete type
>      struct compat_timespec tstamp;
>                             ^~~~~~
>>> sound/core/pcm_native.c:2829:25: error: field 'audio_tstamp' has incomplete type
>      struct compat_timespec audio_tstamp;
>                             ^~~~~~~~~~~~

This is due to a dependency on one of Deepa's patches that is
currently in linux-next,
scheduled for 4.18-rc1, but that won't be in 4.17.

It seems likely that we won't come to a conclusion in time for 4.18
anyway, so that's
probably fine. If we want the patches in 4.18, I can come up with a
different way of
doing this.

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26 11:34       ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 11:34 UTC (permalink / raw)
  To: kbuild test robot
  Cc: alsa-devel, Liam Girdwood, jeeja.kp, SF Markus Elfring,
	Vinod Koul, Takashi Iwai, Guneshwor Singh, Ingo Molnar,
	gudishax.kranthikumar, Arvind Yadav, subhransu.s.prusty,
	Dan Carpenter, hardik.t.shah, Fabian Frederick, Mark Brown,
	Naveen M, Baolin Wang, Linux Kernel Mailing List,
	Takashi Sakamoto, kbuild-all, Bhumika Goyal

On Thu, Apr 26, 2018 at 5:07 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Arnd,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on v4.17-rc2]
> [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180424]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> config: i386-randconfig-n0-201816 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
>>> sound/core/pcm_native.c:2827:25: error: field 'tstamp' has incomplete type
>      struct compat_timespec tstamp;
>                             ^~~~~~
>>> sound/core/pcm_native.c:2829:25: error: field 'audio_tstamp' has incomplete type
>      struct compat_timespec audio_tstamp;
>                             ^~~~~~~~~~~~

This is due to a dependency on one of Deepa's patches that is
currently in linux-next,
scheduled for 4.18-rc1, but that won't be in 4.17.

It seems likely that we won't come to a conclusion in time for 4.18
anyway, so that's
probably fine. If we want the patches in 4.18, I can come up with a
different way of
doing this.

       Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-26 11:31       ` Arnd Bergmann
@ 2018-04-26 12:11         ` Takashi Iwai
  -1 siblings, 0 replies; 48+ messages in thread
From: Takashi Iwai @ 2018-04-26 12:11 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild test robot, kbuild-all, alsa-devel, Arvind Yadav,
	Bhumika Goyal, Liam Girdwood, gudishax.kranthikumar,
	Guneshwor Singh, hardik.t.shah, jeeja.kp, Naveen M,
	subhransu.s.prusty, Vinod Koul, Mark Brown, Ingo Molnar,
	Baolin Wang, Dan Carpenter, Jaroslav Kysela, Takashi Sakamoto,
	Fabian Frederick, SF Markus Elfring, Linux Kernel Mailing List

On Thu, 26 Apr 2018 13:31:17 +0200,
Arnd Bergmann wrote:
> 
> On Thu, Apr 26, 2018 at 1:25 PM, kbuild test robot <lkp@intel.com> wrote:
> > Hi Arnd,
> >
> > I love your patch! Perhaps something to improve:
> >
> > [auto build test WARNING on v4.17-rc2]
> > [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> >
> > url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> > reproduce:
> >         # apt-get install sparse
> >         make ARCH=x86_64 allmodconfig
> >         make C=1 CF=-D__CHECK_ENDIAN__
> >
> >
> > sparse warnings: (new ones prefixed by >>)
> >
> >    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
> >>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer
> 
> From what I can tell, these are all existing driver problems, no idea why we now
> have one more warning than before.

The only marked one is new, and others are already present in the
current code.  You can ignore these sparse warnings.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
@ 2018-04-26 12:11         ` Takashi Iwai
  0 siblings, 0 replies; 48+ messages in thread
From: Takashi Iwai @ 2018-04-26 12:11 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild test robot, kbuild-all, alsa-devel, Arvind Yadav,
	Bhumika Goyal, Liam Girdwood, gudishax.kranthikumar,
	Guneshwor Singh, hardik.t.shah, jeeja.kp, Naveen M,
	subhransu.s.prusty, Vinod Koul, Mark Brown, Ingo Molnar,
	Baolin Wang, Dan Carpenter, Jaroslav Kysela, Takashi Sakamoto,
	Fabian Frederick, SF Markus Elfring

On Thu, 26 Apr 2018 13:31:17 +0200,
Arnd Bergmann wrote:
> 
> On Thu, Apr 26, 2018 at 1:25 PM, kbuild test robot <lkp@intel.com> wrote:
> > Hi Arnd,
> >
> > I love your patch! Perhaps something to improve:
> >
> > [auto build test WARNING on v4.17-rc2]
> > [cannot apply to sound/for-next asoc/for-next arm-soc/for-next next-20180426]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> >
> > url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Fix-year-2038-issue-for-sound-subsystem/20180426-010145
> > reproduce:
> >         # apt-get install sparse
> >         make ARCH=x86_64 allmodconfig
> >         make C=1 CF=-D__CHECK_ENDIAN__
> >
> >
> > sparse warnings: (new ones prefixed by >>)
> >
> >    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:35:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:36:29: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:65:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:66:32: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:92:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
> >    sound/firewire/motu/motu-pcm.c:93:36: sparse: expression using sizeof(void)
> >>> sound/firewire/motu/motu-pcm.c:204:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:223:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:238:50: sparse: restricted snd_pcm_state_t degrades to integer
> >    sound/firewire/motu/motu-pcm.c:254:50: sparse: restricted snd_pcm_state_t degrades to integer
> 
> From what I can tell, these are all existing driver problems, no idea why we now
> have one more warning than before.

The only marked one is new, and others are already present in the
current code.  You can ignore these sparse warnings.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
  2018-04-26 10:53     ` Baolin Wang
@ 2018-04-26 12:50         ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 12:50 UTC (permalink / raw)
  To: Baolin Wang
  Cc: kbuild test robot, kbuild-all, Jaroslav Kysela, Takashi Iwai,
	Liam Girdwood, Mark Brown, Takashi Sakamoto, Ingo Molnar,
	SF Markus Elfring, Dan Carpenter, jeeja.kp, Vinod Koul,
	Guneshwor Singh, subhransu.s.prusty, Bhumika Goyal,
	gudishax.kranthikumar, Naveen M, hardik.t.shah, Arvind Yadav,
	Fabian Frederick, alsa-devel, LKML

On Thu, Apr 26, 2018 at 12:53 PM, Baolin Wang <baolin.wang@linaro.org> wrote:

>>
>>    971
>>    972  static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
>>    973                                   struct snd_pcm_status32 __user * _status,
>>    974                                   bool ext)
>>    975  {
>>    976          struct snd_pcm_status64 status64;
>>    977          struct snd_pcm_status32 status32;
>>    978          int res;
>>    979
>>    980          memset(&status64, 0, sizeof(status64));
>>    981          memset(&status32, 0, sizeof(status32));
>>    982          /*
>>    983           * with extension, parameters are read/write,
>>    984           * get audio_tstamp_data from user,
>>    985           * ignore rest of status structure
>>    986           */
>>    987          if (ext && get_user(status64.audio_tstamp_data,
>>    988                              (u32 __user *)(&_status->audio_tstamp_data)))
>>    989                  return -EFAULT;
>>    990          res = snd_pcm_status64(substream, &status64);
>>    991          if (res < 0)
>>    992                  return res;
>>    993
>>    994          status32 = (struct snd_pcm_status32) {
>>  > 995                  .state = status64.state,
>>    996                  .trigger_tstamp_sec = status64.trigger_tstamp_sec,
>>    997                  .trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
>>    998                  .tstamp_sec = status64.tstamp_sec,
>>    999                  .tstamp_nsec = status64.tstamp_nsec,
>>   1000                  .appl_ptr = status64.appl_ptr,
>>   1001                  .hw_ptr = status64.hw_ptr,
>>   1002                  .delay = status64.delay,
>>   1003                  .avail = status64.avail,
>>   1004                  .avail_max = status64.avail_max,
>>   1005                  .overrange = status64.overrange,
>>> 1006                  .suspended_state = status64.suspended_state,
>
> I am not sure for the warning here, we should change 'snd_pcm_state_t'
> to 's32' for struct snd_pcm_status64?
>
> typedef int __bitwise snd_pcm_state_t;

The problem is that snd_pcm_status32 uses 'u32' here instead of snd_pcm_state_t,
and the __bitwise annotation makes the two types incompatible. This is a
preexisting problem, the warning mail just appeared because you moved that
code to a different file.

If you want to avoid that warning, either use a type case with '__force',
or change the snd_pcm_status32 structure to also use snd_pcm_state_t.

That would be a useful change, but it should be separate from your
other changes since it's an unrelated problem.

      Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status
@ 2018-04-26 12:50         ` Arnd Bergmann
  0 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 12:50 UTC (permalink / raw)
  To: Baolin Wang
  Cc: alsa-devel, Liam Girdwood, jeeja.kp, SF Markus Elfring,
	kbuild test robot, Vinod Koul, Takashi Iwai, Guneshwor Singh,
	Ingo Molnar, gudishax.kranthikumar, Arvind Yadav,
	subhransu.s.prusty, Dan Carpenter, hardik.t.shah,
	Fabian Frederick, Mark Brown, Naveen M, LKML, Takashi Sakamoto,
	kbuild-all, Bhumika Goyal

On Thu, Apr 26, 2018 at 12:53 PM, Baolin Wang <baolin.wang@linaro.org> wrote:

>>
>>    971
>>    972  static int snd_pcm_status_user32(struct snd_pcm_substream *substream,
>>    973                                   struct snd_pcm_status32 __user * _status,
>>    974                                   bool ext)
>>    975  {
>>    976          struct snd_pcm_status64 status64;
>>    977          struct snd_pcm_status32 status32;
>>    978          int res;
>>    979
>>    980          memset(&status64, 0, sizeof(status64));
>>    981          memset(&status32, 0, sizeof(status32));
>>    982          /*
>>    983           * with extension, parameters are read/write,
>>    984           * get audio_tstamp_data from user,
>>    985           * ignore rest of status structure
>>    986           */
>>    987          if (ext && get_user(status64.audio_tstamp_data,
>>    988                              (u32 __user *)(&_status->audio_tstamp_data)))
>>    989                  return -EFAULT;
>>    990          res = snd_pcm_status64(substream, &status64);
>>    991          if (res < 0)
>>    992                  return res;
>>    993
>>    994          status32 = (struct snd_pcm_status32) {
>>  > 995                  .state = status64.state,
>>    996                  .trigger_tstamp_sec = status64.trigger_tstamp_sec,
>>    997                  .trigger_tstamp_nsec = status64.trigger_tstamp_nsec,
>>    998                  .tstamp_sec = status64.tstamp_sec,
>>    999                  .tstamp_nsec = status64.tstamp_nsec,
>>   1000                  .appl_ptr = status64.appl_ptr,
>>   1001                  .hw_ptr = status64.hw_ptr,
>>   1002                  .delay = status64.delay,
>>   1003                  .avail = status64.avail,
>>   1004                  .avail_max = status64.avail_max,
>>   1005                  .overrange = status64.overrange,
>>> 1006                  .suspended_state = status64.suspended_state,
>
> I am not sure for the warning here, we should change 'snd_pcm_state_t'
> to 's32' for struct snd_pcm_status64?
>
> typedef int __bitwise snd_pcm_state_t;

The problem is that snd_pcm_status32 uses 'u32' here instead of snd_pcm_state_t,
and the __bitwise annotation makes the two types incompatible. This is a
preexisting problem, the warning mail just appeared because you moved that
code to a different file.

If you want to avoid that warning, either use a type case with '__force',
or change the snd_pcm_status32 structure to also use snd_pcm_state_t.

That would be a useful change, but it should be separate from your
other changes since it's an unrelated problem.

      Arnd

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
  2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
                     ` (4 preceding siblings ...)
  2018-04-26 11:25     ` kbuild test robot
@ 2018-04-26 15:14   ` Arnd Bergmann
  5 siblings, 0 replies; 48+ messages in thread
From: Arnd Bergmann @ 2018-04-26 15:14 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
	Takashi Sakamoto, Ingo Molnar, SF Markus Elfring, Dan Carpenter,
	jeeja.kp, Vinod Koul, Guneshwor Singh, subhransu.s.prusty,
	Bhumika Goyal, gudishax.kranthikumar, Naveen M, hardik.t.shah,
	Arvind Yadav, Fabian Frederick, alsa-devel,
	Linux Kernel Mailing List

On Tue, Apr 24, 2018 at 2:06 PM, Baolin Wang <baolin.wang@linaro.org> wrote:

> -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
> +#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
> +#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) */

One more thing here: this definition is slightly suboptimal because in
an alsa-lib that gets built with 64-bit time_t, we end up with an unusable
__snd_pcm_mmap_status structure (__snd_pcm_mmap_status64 works
fine, and that would be the normal thing to use). Just in case we want
to be able to build an alsa-lib that is capable of running both on
new kernels with 64-bit time_t interfaces exposed to applications and
also on old kernels that don't have the new ioctls, we probably want
another fixup merged in:

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 18fbdcb2c7b6..638c717d3eb9 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -496,19 +496,30 @@ struct snd_pcm_status {
 #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
+#define __snd_timespec64               timespec
+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 {
@@ -532,11 +543,6 @@ struct __snd_pcm_sync_ptr {
        } c;
 };

-struct __snd_timespec64 {
-       __s64 tv_sec;
-       __s64 tv_nsec;
-};
-
 #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];

With this change, alsa-lib can either access whichever structure
matches the glibc 'timespec' definition, or it can ask for
__struct __snd_pcm_mmap_status and struct __snd_pcm_mmap_status64
explicitly, regardless of the time_t definition.

         Arnd

^ permalink raw reply related	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2018-04-26 15:15 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-24 12:06 [PATCH 0/8] Fix year 2038 issue for sound subsystem Baolin Wang
2018-04-24 12:06 ` [PATCH 1/8] ALSA: Replace timespec with timespec64 Baolin Wang
2018-04-24 12:06   ` Baolin Wang
2018-04-26  8:15   ` kbuild test robot
2018-04-26  8:15     ` kbuild test robot
2018-04-26  8:30     ` Arnd Bergmann
2018-04-26  8:30       ` Arnd Bergmann
2018-04-26  8:41       ` Baolin Wang
2018-04-26  8:41         ` Baolin Wang
2018-04-24 12:06 ` [PATCH 2/8] ALSA: Avoid using timespec for struct snd_timer_status Baolin Wang
2018-04-24 12:06   ` Baolin Wang
2018-04-24 12:06 ` [PATCH 3/8] ALSA: Avoid using timespec for struct snd_ctl_elem_value Baolin Wang
2018-04-24 12:06 ` [PATCH 4/8] ALSA: Avoid using timespec for struct snd_pcm_status Baolin Wang
2018-04-26  9:20   ` kbuild test robot
2018-04-26  9:20     ` kbuild test robot
2018-04-26 10:53     ` Baolin Wang
2018-04-26 12:50       ` Arnd Bergmann
2018-04-26 12:50         ` Arnd Bergmann
2018-04-24 12:06 ` [PATCH 5/8] ALSA: Avoid using timespec for struct snd_rawmidi_status Baolin Wang
2018-04-24 12:06   ` Baolin Wang
2018-04-24 12:06 ` [PATCH 6/8] ALSA: Avoid using timespec for struct snd_timer_tread Baolin Wang
2018-04-24 12:06 ` [PATCH 7/8] ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c Baolin Wang
2018-04-24 12:06 ` [PATCH 8/8] ALSA: add new 32-bit layout for snd_pcm_mmap_status/control Baolin Wang
2018-04-24 13:27   ` Arnd Bergmann
2018-04-26  3:07   ` kbuild test robot
2018-04-26  3:07     ` kbuild test robot
2018-04-26 11:34     ` Arnd Bergmann
2018-04-26 11:34       ` Arnd Bergmann
2018-04-26  6:20   ` kbuild test robot
2018-04-26  6:20     ` kbuild test robot
2018-04-26  6:23   ` kbuild test robot
2018-04-26  6:23     ` kbuild test robot
2018-04-26 11:25   ` kbuild test robot
2018-04-26 11:25     ` kbuild test robot
2018-04-26 11:31     ` Arnd Bergmann
2018-04-26 11:31       ` Arnd Bergmann
2018-04-26 12:11       ` Takashi Iwai
2018-04-26 12:11         ` Takashi Iwai
2018-04-26 15:14   ` Arnd Bergmann
2018-04-24 13:29 ` [PATCH 0/8] Fix year 2038 issue for sound subsystem Jaroslav Kysela
2018-04-24 13:29   ` Jaroslav Kysela
2018-04-24 13:37   ` Arnd Bergmann
2018-04-24 13:37     ` Arnd Bergmann
2018-04-25  7:23     ` Jaroslav Kysela
2018-04-25 11:26       ` Arnd Bergmann
2018-04-25 11:56         ` Mark Brown
2018-04-24 13:29 ` Arnd Bergmann
2018-04-24 13:29   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.