* Re: [PATCH v13 15/17] counter: Implement events_queue_size sysfs attribute
@ 2021-07-13 16:32 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-07-13 16:32 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4398 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <7ec39add7db353b4e8d1c53f52b356007364ad14.1626165765.git.vilhelm.gray@gmail.com>
References: <7ec39add7db353b4e8d1c53f52b356007364ad14.1626165765.git.vilhelm.gray@gmail.com>
TO: William Breathitt Gray <vilhelm.gray@gmail.com>
TO: jic23(a)kernel.org
CC: linux-stm32(a)st-md-mailman.stormreply.com
CC: kernel(a)pengutronix.de
CC: a.fatoum(a)pengutronix.de
CC: kamel.bouhara(a)bootlin.com
CC: gwendal(a)chromium.org
CC: alexandre.belloni(a)bootlin.com
CC: david(a)lechnology.com
CC: linux-iio(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
Hi William,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 50be9417e23af5a8ac860d998e1e3f06b8fd79d7]
url: https://github.com/0day-ci/linux/commits/William-Breathitt-Gray/Introduce-the-Counter-character-device-interface/20210713-175710
base: 50be9417e23af5a8ac860d998e1e3f06b8fd79d7
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: x86_64-randconfig-b001-20210713 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# apt-get install iwyu # include-what-you-use
# https://github.com/0day-ci/linux/commit/a16ea08b1f0cdcc3856ae990be2597731c9673b7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review William-Breathitt-Gray/Introduce-the-Counter-character-device-interface/20210713-175710
git checkout a16ea08b1f0cdcc3856ae990be2597731c9673b7
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross C=1 CHECK=iwyu O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/counter/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
iwyu warnings: (new ones prefixed by >>)
>> drivers/counter/counter-chrdev.c:6:1: iwyu: warning: superfluous #include <linux/bitops.h>
drivers/counter/counter-chrdev.c:9:1: iwyu: warning: superfluous #include <linux/err.h>
drivers/counter/counter-chrdev.c:20:1: iwyu: warning: superfluous #include <linux/timekeeping.h>
--
>> drivers/counter/counter-sysfs.c:6:1: iwyu: warning: superfluous #include <linux/bitops.h>
drivers/counter/counter-sysfs.c:9:1: iwyu: warning: superfluous #include <linux/err.h>
vim +6 drivers/counter/counter-chrdev.c
a16ea08b1f0cdc William Breathitt Gray 2021-07-13 @6 #include <linux/bitops.h>
bcec37b307240f William Breathitt Gray 2021-07-13 7 #include <linux/cdev.h>
bcec37b307240f William Breathitt Gray 2021-07-13 8 #include <linux/counter.h>
bcec37b307240f William Breathitt Gray 2021-07-13 9 #include <linux/err.h>
bcec37b307240f William Breathitt Gray 2021-07-13 10 #include <linux/errno.h>
bcec37b307240f William Breathitt Gray 2021-07-13 11 #include <linux/export.h>
bcec37b307240f William Breathitt Gray 2021-07-13 12 #include <linux/fs.h>
bcec37b307240f William Breathitt Gray 2021-07-13 13 #include <linux/kfifo.h>
bcec37b307240f William Breathitt Gray 2021-07-13 14 #include <linux/list.h>
bcec37b307240f William Breathitt Gray 2021-07-13 15 #include <linux/mutex.h>
bcec37b307240f William Breathitt Gray 2021-07-13 16 #include <linux/nospec.h>
bcec37b307240f William Breathitt Gray 2021-07-13 17 #include <linux/poll.h>
bcec37b307240f William Breathitt Gray 2021-07-13 18 #include <linux/slab.h>
bcec37b307240f William Breathitt Gray 2021-07-13 19 #include <linux/spinlock.h>
bcec37b307240f William Breathitt Gray 2021-07-13 20 #include <linux/timekeeping.h>
bcec37b307240f William Breathitt Gray 2021-07-13 21 #include <linux/types.h>
bcec37b307240f William Breathitt Gray 2021-07-13 22 #include <linux/uaccess.h>
bcec37b307240f William Breathitt Gray 2021-07-13 23 #include <linux/wait.h>
bcec37b307240f William Breathitt Gray 2021-07-13 24
---
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: 36273 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v13 15/17] counter: Implement events_queue_size sysfs attribute
2021-07-13 9:53 [PATCH v13 00/17] Introduce the Counter character device interface William Breathitt Gray
@ 2021-07-13 9:53 ` William Breathitt Gray
0 siblings, 0 replies; 3+ messages in thread
From: William Breathitt Gray @ 2021-07-13 9:53 UTC (permalink / raw)
To: jic23
Cc: linux-stm32, kernel, a.fatoum, kamel.bouhara, gwendal,
alexandre.belloni, david, linux-iio, linux-kernel,
linux-arm-kernel, syednwaris, patrick.havelange, fabrice.gasnier,
mcoquelin.stm32, alexandre.torgue, o.rempel, jarkko.nikula,
William Breathitt Gray
The events_queue_size sysfs attribute provides a way for users to
dynamically configure the Counter events queue size for the Counter
character device interface. The size is in number of struct
counter_event data structures. The number of elements will be rounded-up
to a power of 2 due to a requirement of the kfifo_alloc function called
during reallocation of the queue.
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
Documentation/ABI/testing/sysfs-bus-counter | 8 ++++
drivers/counter/counter-chrdev.c | 6 +++
drivers/counter/counter-sysfs.c | 45 +++++++++++++++++++++
include/linux/counter.h | 2 +
4 files changed, 61 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter
index e0e99adb0ecc..84ebb1ed28ed 100644
--- a/Documentation/ABI/testing/sysfs-bus-counter
+++ b/Documentation/ABI/testing/sysfs-bus-counter
@@ -233,6 +233,14 @@ Description:
shorter or equal to configured value are ignored. Value 0 means
filter is disabled.
+What: /sys/bus/counter/devices/counterX/events_queue_size
+KernelVersion: 5.15
+Contact: linux-iio@vger.kernel.org
+Description:
+ Size of the Counter events queue in number of struct
+ counter_event data structures. The number of elements will be
+ rounded-up to a power of 2.
+
What: /sys/bus/counter/devices/counterX/name
KernelVersion: 5.2
Contact: linux-iio@vger.kernel.org
diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index d5af82d3c04b..cf94e8f1c4ea 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -3,6 +3,7 @@
* Generic Counter character device interface
* Copyright (C) 2020 William Breathitt Gray
*/
+#include <linux/bitops.h>
#include <linux/cdev.h>
#include <linux/counter.h>
#include <linux/err.h>
@@ -336,6 +337,9 @@ static int counter_chrdev_open(struct inode *inode, struct file *filp)
typeof(*counter),
chrdev);
+ if (test_and_set_bit_lock(0, counter->chrdev_lock))
+ return -EBUSY;
+
get_device(&counter->dev);
filp->private_data = counter;
@@ -352,6 +356,7 @@ static int counter_chrdev_release(struct inode *inode, struct file *filp)
return err;
put_device(&counter->dev);
+ clear_bit_unlock(0, counter->chrdev_lock);
return 0;
}
@@ -376,6 +381,7 @@ int counter_chrdev_add(struct counter_device *const counter)
mutex_init(&counter->events_lock);
/* Initialize character device */
+ clear_bit(0, counter->chrdev_lock);
cdev_init(&counter->chrdev, &counter_fops);
/* Allocate Counter events queue */
diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index df1d75e0d7b8..d2d6495f73c5 100644
--- a/drivers/counter/counter-sysfs.c
+++ b/drivers/counter/counter-sysfs.c
@@ -3,11 +3,13 @@
* Generic Counter sysfs interface
* Copyright (C) 2020 William Breathitt Gray
*/
+#include <linux/bitops.h>
#include <linux/counter.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
+#include <linux/kfifo.h>
#include <linux/kstrtox.h>
#include <linux/list.h>
#include <linux/string.h>
@@ -785,12 +787,49 @@ static int counter_num_counts_read(struct counter_device *counter, u8 *val)
return 0;
}
+static int counter_events_queue_size_read(struct counter_device *counter,
+ u64 *val)
+{
+ *val = kfifo_size(&counter->events);
+ return 0;
+}
+
+static int counter_events_queue_size_write(struct counter_device *counter,
+ u64 val)
+{
+ DECLARE_KFIFO_PTR(events, struct counter_event);
+ int err = 0;
+
+ /* Verify chrdev is not currently being used */
+ if (test_and_set_bit_lock(0, counter->chrdev_lock))
+ return -EBUSY;
+
+ /* Allocate new events queue */
+ err = kfifo_alloc(&events, val, GFP_KERNEL);
+ if (err)
+ goto exit_early;
+
+ /* Swap in new events queue */
+ kfifo_free(&counter->events);
+ counter->events.kfifo = events.kfifo;
+
+exit_early:
+ clear_bit_unlock(0, counter->chrdev_lock);
+
+ return err;
+}
+
static struct counter_comp counter_num_signals_comp =
COUNTER_COMP_DEVICE_U8("num_signals", counter_num_signals_read, NULL);
static struct counter_comp counter_num_counts_comp =
COUNTER_COMP_DEVICE_U8("num_counts", counter_num_counts_read, NULL);
+static struct counter_comp counter_events_queue_size_comp =
+ COUNTER_COMP_DEVICE_U64("events_queue_size",
+ counter_events_queue_size_read,
+ counter_events_queue_size_write);
+
static int counter_sysfs_attr_add(struct counter_device *const counter,
struct counter_attribute_group *cattr_group)
{
@@ -829,6 +868,12 @@ static int counter_sysfs_attr_add(struct counter_device *const counter,
if (err < 0)
return err;
+ /* Create events_queue_size attribute */
+ err = counter_attr_create(dev, cattr_group,
+ &counter_events_queue_size_comp, scope, NULL);
+ if (err < 0)
+ return err;
+
/* Create an attribute for each extension */
for (i = 0; i < counter->num_ext; i++) {
ext = &counter->ext[i];
diff --git a/include/linux/counter.h b/include/linux/counter.h
index 895d60a238a9..bfd96fa1f7fe 100644
--- a/include/linux/counter.h
+++ b/include/linux/counter.h
@@ -297,6 +297,7 @@ struct counter_ops {
* @events: queue of detected Counter events
* @events_wait: wait queue to allow blocking reads of Counter events
* @events_lock: lock to protect Counter events queue read operations
+ * @chrdev_lock: lock to limit chrdev to a single open at a time
*/
struct counter_device {
const char *name;
@@ -323,6 +324,7 @@ struct counter_device {
DECLARE_KFIFO_PTR(events, struct counter_event);
wait_queue_head_t events_wait;
struct mutex events_lock;
+ DECLARE_BITMAP(chrdev_lock, 1);
};
int counter_register(struct counter_device *const counter);
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v13 15/17] counter: Implement events_queue_size sysfs attribute
@ 2021-07-13 9:53 ` William Breathitt Gray
0 siblings, 0 replies; 3+ messages in thread
From: William Breathitt Gray @ 2021-07-13 9:53 UTC (permalink / raw)
To: jic23
Cc: linux-stm32, kernel, a.fatoum, kamel.bouhara, gwendal,
alexandre.belloni, david, linux-iio, linux-kernel,
linux-arm-kernel, syednwaris, patrick.havelange, fabrice.gasnier,
mcoquelin.stm32, alexandre.torgue, o.rempel, jarkko.nikula,
William Breathitt Gray
The events_queue_size sysfs attribute provides a way for users to
dynamically configure the Counter events queue size for the Counter
character device interface. The size is in number of struct
counter_event data structures. The number of elements will be rounded-up
to a power of 2 due to a requirement of the kfifo_alloc function called
during reallocation of the queue.
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
Documentation/ABI/testing/sysfs-bus-counter | 8 ++++
drivers/counter/counter-chrdev.c | 6 +++
drivers/counter/counter-sysfs.c | 45 +++++++++++++++++++++
include/linux/counter.h | 2 +
4 files changed, 61 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter
index e0e99adb0ecc..84ebb1ed28ed 100644
--- a/Documentation/ABI/testing/sysfs-bus-counter
+++ b/Documentation/ABI/testing/sysfs-bus-counter
@@ -233,6 +233,14 @@ Description:
shorter or equal to configured value are ignored. Value 0 means
filter is disabled.
+What: /sys/bus/counter/devices/counterX/events_queue_size
+KernelVersion: 5.15
+Contact: linux-iio@vger.kernel.org
+Description:
+ Size of the Counter events queue in number of struct
+ counter_event data structures. The number of elements will be
+ rounded-up to a power of 2.
+
What: /sys/bus/counter/devices/counterX/name
KernelVersion: 5.2
Contact: linux-iio@vger.kernel.org
diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index d5af82d3c04b..cf94e8f1c4ea 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -3,6 +3,7 @@
* Generic Counter character device interface
* Copyright (C) 2020 William Breathitt Gray
*/
+#include <linux/bitops.h>
#include <linux/cdev.h>
#include <linux/counter.h>
#include <linux/err.h>
@@ -336,6 +337,9 @@ static int counter_chrdev_open(struct inode *inode, struct file *filp)
typeof(*counter),
chrdev);
+ if (test_and_set_bit_lock(0, counter->chrdev_lock))
+ return -EBUSY;
+
get_device(&counter->dev);
filp->private_data = counter;
@@ -352,6 +356,7 @@ static int counter_chrdev_release(struct inode *inode, struct file *filp)
return err;
put_device(&counter->dev);
+ clear_bit_unlock(0, counter->chrdev_lock);
return 0;
}
@@ -376,6 +381,7 @@ int counter_chrdev_add(struct counter_device *const counter)
mutex_init(&counter->events_lock);
/* Initialize character device */
+ clear_bit(0, counter->chrdev_lock);
cdev_init(&counter->chrdev, &counter_fops);
/* Allocate Counter events queue */
diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index df1d75e0d7b8..d2d6495f73c5 100644
--- a/drivers/counter/counter-sysfs.c
+++ b/drivers/counter/counter-sysfs.c
@@ -3,11 +3,13 @@
* Generic Counter sysfs interface
* Copyright (C) 2020 William Breathitt Gray
*/
+#include <linux/bitops.h>
#include <linux/counter.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
+#include <linux/kfifo.h>
#include <linux/kstrtox.h>
#include <linux/list.h>
#include <linux/string.h>
@@ -785,12 +787,49 @@ static int counter_num_counts_read(struct counter_device *counter, u8 *val)
return 0;
}
+static int counter_events_queue_size_read(struct counter_device *counter,
+ u64 *val)
+{
+ *val = kfifo_size(&counter->events);
+ return 0;
+}
+
+static int counter_events_queue_size_write(struct counter_device *counter,
+ u64 val)
+{
+ DECLARE_KFIFO_PTR(events, struct counter_event);
+ int err = 0;
+
+ /* Verify chrdev is not currently being used */
+ if (test_and_set_bit_lock(0, counter->chrdev_lock))
+ return -EBUSY;
+
+ /* Allocate new events queue */
+ err = kfifo_alloc(&events, val, GFP_KERNEL);
+ if (err)
+ goto exit_early;
+
+ /* Swap in new events queue */
+ kfifo_free(&counter->events);
+ counter->events.kfifo = events.kfifo;
+
+exit_early:
+ clear_bit_unlock(0, counter->chrdev_lock);
+
+ return err;
+}
+
static struct counter_comp counter_num_signals_comp =
COUNTER_COMP_DEVICE_U8("num_signals", counter_num_signals_read, NULL);
static struct counter_comp counter_num_counts_comp =
COUNTER_COMP_DEVICE_U8("num_counts", counter_num_counts_read, NULL);
+static struct counter_comp counter_events_queue_size_comp =
+ COUNTER_COMP_DEVICE_U64("events_queue_size",
+ counter_events_queue_size_read,
+ counter_events_queue_size_write);
+
static int counter_sysfs_attr_add(struct counter_device *const counter,
struct counter_attribute_group *cattr_group)
{
@@ -829,6 +868,12 @@ static int counter_sysfs_attr_add(struct counter_device *const counter,
if (err < 0)
return err;
+ /* Create events_queue_size attribute */
+ err = counter_attr_create(dev, cattr_group,
+ &counter_events_queue_size_comp, scope, NULL);
+ if (err < 0)
+ return err;
+
/* Create an attribute for each extension */
for (i = 0; i < counter->num_ext; i++) {
ext = &counter->ext[i];
diff --git a/include/linux/counter.h b/include/linux/counter.h
index 895d60a238a9..bfd96fa1f7fe 100644
--- a/include/linux/counter.h
+++ b/include/linux/counter.h
@@ -297,6 +297,7 @@ struct counter_ops {
* @events: queue of detected Counter events
* @events_wait: wait queue to allow blocking reads of Counter events
* @events_lock: lock to protect Counter events queue read operations
+ * @chrdev_lock: lock to limit chrdev to a single open at a time
*/
struct counter_device {
const char *name;
@@ -323,6 +324,7 @@ struct counter_device {
DECLARE_KFIFO_PTR(events, struct counter_event);
wait_queue_head_t events_wait;
struct mutex events_lock;
+ DECLARE_BITMAP(chrdev_lock, 1);
};
int counter_register(struct counter_device *const counter);
--
2.32.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-13 16:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 16:32 [PATCH v13 15/17] counter: Implement events_queue_size sysfs attribute kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2021-07-13 9:53 [PATCH v13 00/17] Introduce the Counter character device interface William Breathitt Gray
2021-07-13 9:53 ` [PATCH v13 15/17] counter: Implement events_queue_size sysfs attribute William Breathitt Gray
2021-07-13 9:53 ` William Breathitt Gray
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.