All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12][RESEND] iio: core,buffer: add support for multiple IIO buffers per IIO device
@ 2021-01-22 16:25 Alexandru Ardelean
  2021-01-22 16:25 ` [PATCH v2 01/12][RESEND] iio: core: register chardev only if needed Alexandru Ardelean
                   ` (11 more replies)
  0 siblings, 12 replies; 25+ messages in thread
From: Alexandru Ardelean @ 2021-01-22 16:25 UTC (permalink / raw)
  To: linux-kernel, linux-iio
  Cc: lars, Michael.Hennerich, jic23, nuno.sa, dragos.bogdan,
	Alexandru Ardelean

Continuing from:
 https://lore.kernel.org/linux-iio/20201117162340.43924-1-alexandru.ardelean@analog.com/

Changelog v1 -> v2:
* 'iio: buffer: rework buffer & scan_elements dir creation'
  add more doc-strings detailing the reasoning for this change
* 'iio: buffer: re-route scan_elements via it's kobj_type'
  move list_del() before the kfree()'s in the list destruction
* 'iio: buffer: introduce support for attaching more IIO buffers'
  - changed to 'cnt' variable vs re-using the 'i' for unwinding in
    iio_buffer_alloc_sysfs_and_mask()
  - removed kfree(old) in iio_device_attach_buffer()
  - made iio_device_attach_buffer() an int return; this means that some
    follow up patches are needed to make this return value be used;
* 'iio: buffer: add ioctl() to support opening extra buffers for IIO device'
  - tested ioctl() with a simple C program; attached to comment;
  - changed 'i' variable usage to 'sz' for alloc
  - changed logic for buffer0; returning FD 0; userspace should know
    that the IIO_BUFFER_GET_FD_IOCTL call returns 0 for buffer0;
    this is because I can't find a way to determine the FD of the
    ioctl() in the kernel; duplicating an ioctl() for buffer0 is also bad;

Alexandru Ardelean (12):
  iio: core: register chardev only if needed
  iio: buffer: add back-ref from iio_buffer to iio_dev
  iio: buffer: rework buffer & scan_elements dir creation
  iio: buffer: add index to the first IIO buffer dir and symlink it back
  iio: core: split __iio_device_attr_init() to init only the attr object
  iio: buffer: re-route scan_elements via it's kobj_type
  iio: buffer: re-route core buffer attributes via it's new kobj_type
  iio: buffer: add helper to get the IIO device to which a buffer
    belongs
  iio: re-route all buffer attributes through new buffer kobj_type
  iio: core: wrap iio device & buffer into struct for character devices
  iio: buffer: introduce support for attaching more IIO buffers
  iio: buffer: add ioctl() to support opening extra buffers for IIO
    device

 drivers/iio/accel/adxl372.c                   |  36 +-
 drivers/iio/accel/bmc150-accel-core.c         |  34 +-
 drivers/iio/adc/at91-sama5d2_adc.c            |  30 +-
 .../buffer/industrialio-buffer-dmaengine.c    |  13 +-
 .../cros_ec_sensors/cros_ec_sensors_core.c    |  30 +-
 .../common/hid-sensors/hid-sensor-trigger.c   |  32 +-
 drivers/iio/iio_core.h                        |  11 +
 drivers/iio/industrialio-buffer.c             | 647 ++++++++++++++----
 drivers/iio/industrialio-core.c               | 117 ++--
 include/linux/iio/buffer.h                    |   6 +-
 include/linux/iio/buffer_impl.h               |  25 +-
 include/linux/iio/iio-opaque.h                |   6 +
 include/linux/iio/iio.h                       |   2 +-
 include/linux/iio/sysfs.h                     |  50 ++
 include/uapi/linux/iio/buffer.h               |  10 +
 15 files changed, 790 insertions(+), 259 deletions(-)
 create mode 100644 include/uapi/linux/iio/buffer.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [PATCH v2 12/12][RESEND] iio: buffer: add ioctl() to support opening extra buffers for IIO device
@ 2021-01-25  8:22 kernel test robot
  0 siblings, 0 replies; 25+ messages in thread
From: kernel test robot @ 2021-01-25  8:22 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210122162529.84978-13-alexandru.ardelean@analog.com>
References: <20210122162529.84978-13-alexandru.ardelean@analog.com>
TO: Alexandru Ardelean <alexandru.ardelean@analog.com>
TO: linux-kernel(a)vger.kernel.org
TO: linux-iio(a)vger.kernel.org
CC: lars(a)metafoo.de
CC: Michael.Hennerich(a)analog.com
CC: jic23(a)kernel.org
CC: nuno.sa(a)analog.com
CC: dragos.bogdan(a)analog.com
CC: Alexandru Ardelean <alexandru.ardelean@analog.com>

Hi Alexandru,

I love your patch! Perhaps something to improve:

[auto build test WARNING on iio/togreg]
[also build test WARNING on linux/master linus/master v5.11-rc5 next-20210122]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/iio-core-buffer-add-support-for-multiple-IIO-buffers-per-IIO-device/20210125-053419
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: i386-randconfig-m021-20210125 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-20) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/iio/industrialio-buffer.c:1451 iio_device_buffer_getfd() warn: potential spectre issue 'iio_dev_opaque->attached_buffers' [r] (local cap)
drivers/iio/industrialio-buffer.c:1453 iio_device_buffer_getfd() warn: possible spectre second half.  'buffer'

Old smatch warnings:
drivers/iio/industrialio-buffer.c:1721 iio_buffer_alloc_sysfs_and_mask() error: uninitialized symbol 'cnt'.

vim +1451 drivers/iio/industrialio-buffer.c

2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1424  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1425  static long iio_device_buffer_getfd(struct iio_dev *indio_dev, unsigned long arg)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1426  {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1427  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1428  	int __user *ival = (int __user *)arg;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1429  	char buf_name[sizeof("iio:buffer:xxx")];
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1430  	struct iio_dev_buffer_pair *ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1431  	struct iio_buffer *buffer;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1432  	int fd, idx;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1433  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1434  	if (copy_from_user(&idx, ival, sizeof(idx)))
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1435  		return -EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1436  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1437  	if (idx == 0) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1438  		fd = 0;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1439  		if (copy_to_user(ival, &fd, sizeof(fd)))
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1440  			return -EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1441  		return 0;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1442  	}
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1443  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1444  	if (idx >= iio_dev_opaque->attached_buffers_cnt)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1445  		return -ENOENT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1446  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1447  	fd = mutex_lock_interruptible(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1448  	if (fd)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1449  		return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1450  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22 @1451  	buffer = iio_dev_opaque->attached_buffers[idx];
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1452  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22 @1453  	if (test_and_set_bit(IIO_BUSY_BIT_POS, &buffer->flags)) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1454  		fd = -EBUSY;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1455  		goto error_unlock;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1456  	}
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1457  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1458  	iio_device_get(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1459  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1460  	ib = kzalloc(sizeof(*ib), GFP_KERNEL);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1461  	if (!ib) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1462  		fd = -ENOMEM;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1463  		goto error_iio_dev_put;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1464  	}
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1465  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1466  	ib->indio_dev = indio_dev;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1467  	ib->buffer = buffer;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1468  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1469  	fd = anon_inode_getfd(buf_name, &iio_buffer_chrdev_fileops,
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1470  			      ib, O_RDWR | O_CLOEXEC);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1471  	if (fd < 0)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1472  		goto error_free_ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1473  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1474  	if (copy_to_user(ival, &fd, sizeof(fd))) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1475  		fd = -EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1476  		goto error_free_ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1477  	}
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1478  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1479  	mutex_unlock(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1480  	return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1481  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1482  error_free_ib:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1483  	kfree(ib);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1484  error_iio_dev_put:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1485  	iio_device_put(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1486  	clear_bit(IIO_BUSY_BIT_POS, &buffer->flags);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1487  error_unlock:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1488  	mutex_unlock(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1489  	return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1490  }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1491  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

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

end of thread, other threads:[~2021-01-27 14:51 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-22 16:25 [PATCH v2 00/12][RESEND] iio: core,buffer: add support for multiple IIO buffers per IIO device Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 01/12][RESEND] iio: core: register chardev only if needed Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 02/12][RESEND] iio: buffer: add back-ref from iio_buffer to iio_dev Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 03/12][RESEND] iio: buffer: rework buffer & scan_elements dir creation Alexandru Ardelean
2021-01-24 18:11   ` Jonathan Cameron
2021-01-24 19:07     ` Alexandru Ardelean
2021-01-25 19:29       ` Greg Kroah-Hartman
2021-01-25 19:28     ` Greg Kroah-Hartman
2021-01-26  9:45       ` Alexandru Ardelean
2021-01-27 14:48         ` Jonathan Cameron
2021-01-22 16:25 ` [PATCH v2 04/12][RESEND] iio: buffer: add index to the first IIO buffer dir and symlink it back Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 05/12][RESEND] iio: core: split __iio_device_attr_init() to init only the attr object Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 06/12][RESEND] iio: buffer: re-route scan_elements via it's kobj_type Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 07/12][RESEND] iio: buffer: re-route core buffer attributes via it's new kobj_type Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 08/12][RESEND] iio: buffer: add helper to get the IIO device to which a buffer belongs Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 09/12][RESEND] iio: re-route all buffer attributes through new buffer kobj_type Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 10/12][RESEND] iio: core: wrap iio device & buffer into struct for character devices Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 11/12][RESEND] iio: buffer: introduce support for attaching more IIO buffers Alexandru Ardelean
2021-01-25 11:06   ` [kbuild] " Dan Carpenter
2021-01-25 11:06     ` Dan Carpenter
2021-01-25 11:06     ` Dan Carpenter
2021-01-22 16:25 ` [PATCH v2 12/12][RESEND] iio: buffer: add ioctl() to support opening extra buffers for IIO device Alexandru Ardelean
2021-01-24 18:38   ` Jonathan Cameron
2021-01-24 19:32     ` Alexandru Ardelean
  -- strict thread matches above, loose matches on Subject: below --
2021-01-25  8:22 kernel test robot

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.