Skip to contentSkip to conversation

omap3isp: support 64-bit version of omap3isp_stat_data

PATCH Superseded Arnd Bergmann 2 participants 2 messages Jun 17, 2016 – Jun 18, 2016 Media (V4L/DVB)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 omap3isp: support 64-bit version of omap3isp_stat_data

C libraries with 64-bit time_t use an incompatible format for struct omap3isp_stat_data. This changes the kernel code to support either version, by moving over the normal handling to the 64-bit variant, and adding compatiblity code to handle the old binary format with the existing ioctl command code.

Fortunately, the command code includes the size of the structure, so the difference gets handled automatically.

---
This patch was originally part of a longer series, along with other patches that we still have to rewrite for the generic ioctl interface, but the OMAP specific ioctl commands are completely independent of that, so I think we can just merge this version for 4.8.

Compared to the previous version, I am no longer using 'struct v4l2_timeval' now, but just define the kernel-internal type as part of omap3isp_stat_data.

drivers/media/platform/omap3isp/isph3a_aewb.c +2 -0
index ccaf92f39236..2d567725608f 100644
@@ -250,6 +250,8 @@ static long h3a_aewb_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 		return omap3isp_stat_config(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_REQ:
 		return omap3isp_stat_request_statistics(stat, arg);
+	case VIDIOC_OMAP3ISP_STAT_REQ_TIME32:
+		return omap3isp_stat_request_statistics_time32(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_EN: {
 		unsigned long *en = arg;
 		return omap3isp_stat_enable(stat, !!*en);
drivers/media/platform/omap3isp/isph3a_af.c +2 -0
index 92937f7eecef..2ac02371318b 100644
@@ -314,6 +314,8 @@ static long h3a_af_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 		return omap3isp_stat_config(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_REQ:
 		return omap3isp_stat_request_statistics(stat, arg);
+	case VIDIOC_OMAP3ISP_STAT_REQ_TIME32:
+		return omap3isp_stat_request_statistics_time32(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_EN: {
 		int *en = arg;
 		return omap3isp_stat_enable(stat, !!*en);
drivers/media/platform/omap3isp/isphist.c +2 -0
index 7138b043a4aa..669b97b079ee 100644
@@ -436,6 +436,8 @@ static long hist_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 		return omap3isp_stat_config(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_REQ:
 		return omap3isp_stat_request_statistics(stat, arg);
+	case VIDIOC_OMAP3ISP_STAT_REQ_TIME32:
+		return omap3isp_stat_request_statistics_time32(stat, arg);
 	case VIDIOC_OMAP3ISP_STAT_EN: {
 		int *en = arg;
 		return omap3isp_stat_enable(stat, !!*en);
drivers/media/platform/omap3isp/ispstat.c +15 -0
index 1b9217d3b1b6..3025a9170e0c 100644
@@ -508,6 +508,21 @@ int omap3isp_stat_request_statistics(struct ispstat *stat,
 	return 0;
 }
 
+int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
+					struct omap3isp_stat_data_time32 *data)
+{
+	struct omap3isp_stat_data data64;
+	int ret;
+
+	ret = omap3isp_stat_request_statistics(stat, &data64);
+
+	data->ts.tv_sec = data64.ts.tv_sec;
+	data->ts.tv_usec = data64.ts.tv_usec;
+	memcpy(&data->buf, &data64.buf, sizeof(*data) - sizeof(data->ts));
+
+	return ret;
+}
+
 /*
  * omap3isp_stat_config - Receives new statistic engine configuration.
  * @new_conf: Pointer to config structure.
drivers/media/platform/omap3isp/ispstat.h +2 -0
index 6d9b0244f320..0afa89de09de 100644
@@ -130,6 +130,8 @@ struct ispstat_generic_config {
 int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
 int omap3isp_stat_request_statistics(struct ispstat *stat,
 				     struct omap3isp_stat_data *data);
+int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
+				     struct omap3isp_stat_data_time32 *data);
 int omap3isp_stat_init(struct ispstat *stat, const char *name,
 		       const struct v4l2_subdev_ops *sd_ops);
 void omap3isp_stat_cleanup(struct ispstat *stat);
include/uapi/linux/omap3isp.h +22 -0
index c090cf9249bb..076d3f3a79d9 100644
@@ -54,6 +54,8 @@
 	_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct omap3isp_h3a_af_config)
 #define VIDIOC_OMAP3ISP_STAT_REQ \
 	_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct omap3isp_stat_data)
+#define VIDIOC_OMAP3ISP_STAT_REQ_TIME32 \
+	_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct omap3isp_stat_data_time32)
 #define VIDIOC_OMAP3ISP_STAT_EN \
 	_IOWR('V', BASE_VIDIOC_PRIVATE + 7, unsigned long)
 
@@ -164,7 +166,14 @@ struct omap3isp_h3a_aewb_config {
  * @config_counter: Number of the configuration associated with the data.
  */
 struct omap3isp_stat_data {
+#ifdef __KERNEL__
+	struct {
+		__s64	tv_sec;
+		__s64	tv_usec;
+	};
+#else
 	struct timeval ts;
+#endif
 	void __user *buf;
 	__u32 buf_size;
 	__u16 frame_number;
@@ -172,6 +181,19 @@ struct omap3isp_stat_data {
 	__u16 config_counter;
 };
 
+#ifdef __KERNEL__
+struct omap3isp_stat_data_time32 {
+	struct {
+		__s32	tv_sec;
+		__s32	tv_usec;
+	} ts;
+	__u32 buf;
+	__u32 buf_size;
+	__u16 frame_number;
+	__u16 cur_frame;
+	__u16 config_counter;
+};
+#endif
 
 /* Histogram related structs */
 
#1 lore raw
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.7-rc3 next-20160617]
[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/Arnd-Bergmann/omap3isp-support-64-bit-version-of-omap3isp_stat_data/20160618-045121
base:   git://linuxtv.org/media_tree.git master
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

drivers/media/platform/omap3isp/ispstat.c: In function 'omap3isp_stat_request_statistics':

>> drivers/media/platform/omap3isp/ispstat.c:499:6: error: 'struct omap3isp_stat_data' has no member named 'ts'
     data->ts = buf->ts;
         ^
   drivers/media/platform/omap3isp/ispstat.c: In function 'omap3isp_stat_request_statistics_time32':
   drivers/media/platform/omap3isp/ispstat.c:519:26: error: 'struct omap3isp_stat_data' has no member named 'ts'
     data->ts.tv_sec = data64.ts.tv_sec;
                             ^
   drivers/media/platform/omap3isp/ispstat.c:520:27: error: 'struct omap3isp_stat_data' has no member named 'ts'
     data->ts.tv_usec = data64.ts.tv_usec;
                              ^

vim +499 drivers/media/platform/omap3isp/ispstat.c

68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  493  	buf = isp_stat_buf_get(stat, data);
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  494  	if (IS_ERR(buf)) {
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  495  		mutex_unlock(&stat->ioctl_lock);
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  496  		return PTR_ERR(buf);
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  497  	}
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  498  
5ba0e2c3a drivers/media/platform/omap3isp/ispstat.c Arnd Bergmann 2015-09-17 @499  	data->ts = buf->ts;
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  500  	data->config_counter = buf->config_counter;
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  501  	data->frame_number = buf->frame_number;
68e342b30 drivers/media/video/omap3isp/ispstat.c    David Cohen   2011-02-12  502  	data->buf_size = buf->buf_size;

:::::: The code at line 499 was first introduced by commit
:::::: 5ba0e2c3ad4c049b19f6cad7ec62e59424a55183 [media] use v4l2_get_timestamp where possible

:::::: TO: Arnd Bergmann <[email protected]>
:::::: CC: Mauro Carvalho Chehab <[email protected]>

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