* Re: [PATCH v2] Input: xen-kbdfront - allow better run-time configuration
From: Juergen Gross @ 2018-04-23 8:23 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-input, linux-kernel,
dmitry.torokhov, lyan, boris.ostrovsky
Cc: andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <998533bb-8042-b07e-cb79-661750e035d9@gmail.com>
On 23/04/18 10:02, Oleksandr Andrushchenko wrote:
> Juergen, Jason, Dmitry
> any comment on this?
Oleksandr, please give us some time. I can't speak for others, but I am
not sitting here idling and hoping that some work (e.g. patches to
review) might appear.
I have a lot of other stuff to do and will respond when I find some time
to look at your patches.
Pinging others on Monday when having sent out the patch only on Thursday
is rather unfriendly.
Juergen
^ permalink raw reply
* Re: [PATCH v2] Input: xen-kbdfront - allow better run-time configuration
From: Oleksandr Andrushchenko @ 2018-04-23 8:02 UTC (permalink / raw)
To: xen-devel, linux-input, linux-kernel, dmitry.torokhov, jgross,
lyan, boris.ostrovsky
Cc: andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <20180419133934.31306-1-andr2000@gmail.com>
Juergen, Jason, Dmitry
any comment on this?
Thank you,
Oleksandr
On 04/19/2018 04:39 PM, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> It is now only possible to control if multi-touch virtual device
> is created or not (via the corresponding XenStore entries),
> but keyboard and pointer devices are always created.
> In some cases this is not desirable. For example, if virtual
> keyboard device is exposed to Android then the latter won't
> automatically show on-screen keyboard as it expects that a
> physical keyboard device can be used for typing.
>
> Make it possible to configure which virtual devices are created
> with module parameters:
> - provide no_ptr_dev if no pointer device needs to be created
> - provide no_kbd_dev if no keyboard device needs to be created
> Keep old behavior by default.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> Suggested-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
> Tested-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
> ---
> Changes since v1:
> - changed module parameters from uint to bool
>
> drivers/input/misc/xen-kbdfront.c | 159 +++++++++++++++++-------------
> 1 file changed, 92 insertions(+), 67 deletions(-)
>
> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
> index d91f3b1c5375..d8cca212f737 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -51,6 +51,16 @@ module_param_array(ptr_size, int, NULL, 0444);
> MODULE_PARM_DESC(ptr_size,
> "Pointing device width, height in pixels (default 800,600)");
>
> +static bool no_ptr_dev;
> +module_param(no_ptr_dev, bool, 0);
> +MODULE_PARM_DESC(no_ptr_dev,
> + "If set then no virtual pointing device exposed to the guest");
> +
> +static bool no_kbd_dev;
> +module_param(no_kbd_dev, bool, 0);
> +MODULE_PARM_DESC(no_kbd_dev,
> + "If set then no virtual keyboard device exposed to the guest");
> +
> static int xenkbd_remove(struct xenbus_device *);
> static int xenkbd_connect_backend(struct xenbus_device *, struct xenkbd_info *);
> static void xenkbd_disconnect_backend(struct xenkbd_info *);
> @@ -63,6 +73,9 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *);
> static void xenkbd_handle_motion_event(struct xenkbd_info *info,
> struct xenkbd_motion *motion)
> {
> + if (unlikely(!info->ptr))
> + return;
> +
> input_report_rel(info->ptr, REL_X, motion->rel_x);
> input_report_rel(info->ptr, REL_Y, motion->rel_y);
> if (motion->rel_z)
> @@ -73,6 +86,9 @@ static void xenkbd_handle_motion_event(struct xenkbd_info *info,
> static void xenkbd_handle_position_event(struct xenkbd_info *info,
> struct xenkbd_position *pos)
> {
> + if (unlikely(!info->ptr))
> + return;
> +
> input_report_abs(info->ptr, ABS_X, pos->abs_x);
> input_report_abs(info->ptr, ABS_Y, pos->abs_y);
> if (pos->rel_z)
> @@ -97,6 +113,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
> return;
> }
>
> + if (unlikely(!dev))
> + return;
> +
> input_event(dev, EV_KEY, key->keycode, value);
> input_sync(dev);
> }
> @@ -192,7 +211,7 @@ static int xenkbd_probe(struct xenbus_device *dev,
> const struct xenbus_device_id *id)
> {
> int ret, i;
> - unsigned int abs, touch;
> + unsigned int touch;
> struct xenkbd_info *info;
> struct input_dev *kbd, *ptr, *mtouch;
>
> @@ -211,24 +230,6 @@ static int xenkbd_probe(struct xenbus_device *dev,
> if (!info->page)
> goto error_nomem;
>
> - /* Set input abs params to match backend screen res */
> - abs = xenbus_read_unsigned(dev->otherend,
> - XENKBD_FIELD_FEAT_ABS_POINTER, 0);
> - ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend,
> - XENKBD_FIELD_WIDTH,
> - ptr_size[KPARAM_X]);
> - ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend,
> - XENKBD_FIELD_HEIGHT,
> - ptr_size[KPARAM_Y]);
> - if (abs) {
> - ret = xenbus_write(XBT_NIL, dev->nodename,
> - XENKBD_FIELD_REQ_ABS_POINTER, "1");
> - if (ret) {
> - pr_warn("xenkbd: can't request abs-pointer\n");
> - abs = 0;
> - }
> - }
> -
> touch = xenbus_read_unsigned(dev->nodename,
> XENKBD_FIELD_FEAT_MTOUCH, 0);
> if (touch) {
> @@ -241,60 +242,84 @@ static int xenkbd_probe(struct xenbus_device *dev,
> }
>
> /* keyboard */
> - kbd = input_allocate_device();
> - if (!kbd)
> - goto error_nomem;
> - kbd->name = "Xen Virtual Keyboard";
> - kbd->phys = info->phys;
> - kbd->id.bustype = BUS_PCI;
> - kbd->id.vendor = 0x5853;
> - kbd->id.product = 0xffff;
> -
> - __set_bit(EV_KEY, kbd->evbit);
> - for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
> - __set_bit(i, kbd->keybit);
> - for (i = KEY_OK; i < KEY_MAX; i++)
> - __set_bit(i, kbd->keybit);
> -
> - ret = input_register_device(kbd);
> - if (ret) {
> - input_free_device(kbd);
> - xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
> - goto error;
> + if (!no_kbd_dev) {
> + kbd = input_allocate_device();
> + if (!kbd)
> + goto error_nomem;
> + kbd->name = "Xen Virtual Keyboard";
> + kbd->phys = info->phys;
> + kbd->id.bustype = BUS_PCI;
> + kbd->id.vendor = 0x5853;
> + kbd->id.product = 0xffff;
> +
> + __set_bit(EV_KEY, kbd->evbit);
> + for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
> + __set_bit(i, kbd->keybit);
> + for (i = KEY_OK; i < KEY_MAX; i++)
> + __set_bit(i, kbd->keybit);
> +
> + ret = input_register_device(kbd);
> + if (ret) {
> + input_free_device(kbd);
> + xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
> + goto error;
> + }
> + info->kbd = kbd;
> }
> - info->kbd = kbd;
>
> /* pointing device */
> - ptr = input_allocate_device();
> - if (!ptr)
> - goto error_nomem;
> - ptr->name = "Xen Virtual Pointer";
> - ptr->phys = info->phys;
> - ptr->id.bustype = BUS_PCI;
> - ptr->id.vendor = 0x5853;
> - ptr->id.product = 0xfffe;
> -
> - if (abs) {
> - __set_bit(EV_ABS, ptr->evbit);
> - input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0);
> - input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0);
> - } else {
> - input_set_capability(ptr, EV_REL, REL_X);
> - input_set_capability(ptr, EV_REL, REL_Y);
> - }
> - input_set_capability(ptr, EV_REL, REL_WHEEL);
> + if (!no_ptr_dev) {
> + unsigned int abs;
> +
> + /* Set input abs params to match backend screen res */
> + abs = xenbus_read_unsigned(dev->otherend,
> + XENKBD_FIELD_FEAT_ABS_POINTER, 0);
> + ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend,
> + XENKBD_FIELD_WIDTH,
> + ptr_size[KPARAM_X]);
> + ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend,
> + XENKBD_FIELD_HEIGHT,
> + ptr_size[KPARAM_Y]);
> + if (abs) {
> + ret = xenbus_write(XBT_NIL, dev->nodename,
> + XENKBD_FIELD_REQ_ABS_POINTER, "1");
> + if (ret) {
> + pr_warn("xenkbd: can't request abs-pointer\n");
> + abs = 0;
> + }
> + }
>
> - __set_bit(EV_KEY, ptr->evbit);
> - for (i = BTN_LEFT; i <= BTN_TASK; i++)
> - __set_bit(i, ptr->keybit);
> + ptr = input_allocate_device();
> + if (!ptr)
> + goto error_nomem;
> + ptr->name = "Xen Virtual Pointer";
> + ptr->phys = info->phys;
> + ptr->id.bustype = BUS_PCI;
> + ptr->id.vendor = 0x5853;
> + ptr->id.product = 0xfffe;
> +
> + if (abs) {
> + __set_bit(EV_ABS, ptr->evbit);
> + input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0);
> + input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0);
> + } else {
> + input_set_capability(ptr, EV_REL, REL_X);
> + input_set_capability(ptr, EV_REL, REL_Y);
> + }
> + input_set_capability(ptr, EV_REL, REL_WHEEL);
>
> - ret = input_register_device(ptr);
> - if (ret) {
> - input_free_device(ptr);
> - xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
> - goto error;
> + __set_bit(EV_KEY, ptr->evbit);
> + for (i = BTN_LEFT; i <= BTN_TASK; i++)
> + __set_bit(i, ptr->keybit);
> +
> + ret = input_register_device(ptr);
> + if (ret) {
> + input_free_device(ptr);
> + xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
> + goto error;
> + }
> + info->ptr = ptr;
> }
> - info->ptr = ptr;
>
> /* multi-touch device */
> if (touch) {
^ permalink raw reply
* [PATCH v2 2/2] input: misc: Add Spreadtrum vibrator driver
From: Baolin Wang @ 2018-04-23 2:33 UTC (permalink / raw)
To: dmitry.torokhov, robh+dt, mark.rutland, orsonzhai, zhang.lyra
Cc: linux-input, devicetree, linux-kernel, baolin.wang, xiaotong.lu
In-Reply-To: <e2f85ec0b1fb66baa41dd85bb31e8113e23c704b.1524450536.git.baolin.wang@linaro.org>
From: Xiaotong Lu <xiaotong.lu@spreadtrum.com>
This patch adds the Spreadtrum vibrator driver, which embedded in the
Spreadtrum SC27xx series PMICs.
Signed-off-by: Xiaotong Lu <xiaotong.lu@spreadtrum.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
Changes since v1:
- Remove input_ff_destroy() and input_unregister_device()
---
drivers/input/misc/Kconfig | 10 +++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/sc27xx-vibra.c | 156 +++++++++++++++++++++++++++++++++++++
3 files changed, 167 insertions(+)
create mode 100644 drivers/input/misc/sc27xx-vibra.c
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 572b15f..c761c0c 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -841,4 +841,14 @@ config INPUT_RAVE_SP_PWRBUTTON
To compile this driver as a module, choose M here: the
module will be called rave-sp-pwrbutton.
+config INPUT_SC27XX_VIBRA
+ tristate "Spreadtrum sc27xx vibrator support"
+ depends on MFD_SC27XX_PMIC || COMPILE_TEST
+ select INPUT_FF_MEMLESS
+ help
+ This option enables support for Spreadtrum sc27xx vibrator driver.
+
+ To compile this driver as a module, choose M here. The module will
+ be called sc27xx_vibra.
+
endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 72cde28..9d0f9d1 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o
+obj-$(CONFIG_INPUT_SC27XX_VIBRA) += sc27xx-vibra.o
obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o
obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o
diff --git a/drivers/input/misc/sc27xx-vibra.c b/drivers/input/misc/sc27xx-vibra.c
new file mode 100644
index 0000000..f78e70f
--- /dev/null
+++ b/drivers/input/misc/sc27xx-vibra.c
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Spreadtrum Communications Inc.
+ */
+
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+
+#define CUR_DRV_CAL_SEL GENMASK(13, 12)
+#define SLP_LDOVIBR_PD_EN BIT(9)
+#define LDO_VIBR_PD BIT(8)
+
+struct vibra_info {
+ struct input_dev *input_dev;
+ struct work_struct play_work;
+ struct regmap *regmap;
+ u32 base;
+ u32 strength;
+ bool enabled;
+};
+
+static void sc27xx_vibra_set(struct vibra_info *info, bool on)
+{
+ if (on) {
+ regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0);
+ regmap_update_bits(info->regmap, info->base,
+ SLP_LDOVIBR_PD_EN, 0);
+ info->enabled = true;
+ } else {
+ regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD,
+ LDO_VIBR_PD);
+ regmap_update_bits(info->regmap, info->base,
+ SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN);
+ info->enabled = false;
+ }
+}
+
+static int sc27xx_vibra_hw_init(struct vibra_info *info)
+{
+ return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0);
+}
+
+static void sc27xx_vibra_play_work(struct work_struct *work)
+{
+ struct vibra_info *info = container_of(work, struct vibra_info,
+ play_work);
+
+ if (info->strength && !info->enabled)
+ sc27xx_vibra_set(info, true);
+ else if (info->enabled)
+ sc27xx_vibra_set(info, false);
+}
+
+static int sc27xx_vibra_play(struct input_dev *input, void *data,
+ struct ff_effect *effect)
+{
+ struct vibra_info *info = input_get_drvdata(input);
+
+ info->strength = effect->u.rumble.weak_magnitude;
+ schedule_work(&info->play_work);
+
+ return 0;
+}
+
+static void sc27xx_vibra_close(struct input_dev *input)
+{
+ struct vibra_info *info = input_get_drvdata(input);
+
+ cancel_work_sync(&info->play_work);
+ if (info->enabled)
+ sc27xx_vibra_set(info, false);
+}
+
+static int sc27xx_vibra_probe(struct platform_device *pdev)
+{
+ struct device_node *node = pdev->dev.of_node;
+ struct vibra_info *info;
+ int ret;
+
+ info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!info->regmap) {
+ dev_err(&pdev->dev, "failed to get vibrator regmap.\n");
+ return -ENODEV;
+ }
+
+ ret = of_property_read_u32(node, "reg", &info->base);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to get vibrator base address.\n");
+ return ret;
+ }
+
+ info->input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!info->input_dev) {
+ dev_err(&pdev->dev, "failed to allocate input device.\n");
+ return -ENOMEM;
+ }
+
+ info->input_dev->name = "sc27xx:vibrator";
+ info->input_dev->id.version = 0;
+ info->input_dev->dev.parent = pdev->dev.parent;
+ info->input_dev->close = sc27xx_vibra_close;
+
+ input_set_drvdata(info->input_dev, info);
+ input_set_capability(info->input_dev, EV_FF, FF_RUMBLE);
+ INIT_WORK(&info->play_work, sc27xx_vibra_play_work);
+ info->enabled = false;
+
+ ret = input_ff_create_memless(info->input_dev, NULL, sc27xx_vibra_play);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register vibrator to FF.\n");
+ return ret;
+ }
+
+ ret = input_register_device(info->input_dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register input device.\n");
+ return ret;
+ }
+
+ ret = sc27xx_vibra_hw_init(info);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize the vibrator.\n");
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, info);
+ return 0;
+}
+
+static const struct of_device_id sc27xx_vibra_of_match[] = {
+ { .compatible = "sprd,sc27xx-vibrator", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match);
+
+static struct platform_driver sc27xx_vibra_driver = {
+ .driver = {
+ .name = "sc27xx-vibrator",
+ .of_match_table = sc27xx_vibra_of_match,
+ },
+ .probe = sc27xx_vibra_probe,
+};
+
+module_platform_driver(sc27xx_vibra_driver);
+
+MODULE_DESCRIPTION("Spreadtrum SC27xx Vibrator Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Xiaotong Lu <xiaotong.lu@spreadtrum.com>");
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/2] dt-bindings: input: Add Add Spreadtrum SC27xx vibrator documentation
From: Baolin Wang @ 2018-04-23 2:33 UTC (permalink / raw)
To: dmitry.torokhov, robh+dt, mark.rutland, orsonzhai, zhang.lyra
Cc: linux-input, devicetree, linux-kernel, baolin.wang, xiaotong.lu
From: Xiaotong Lu <xiaotong.lu@spreadtrum.com>
This patch adds the binding documentation for Spreadtrum SC27xx series
vibrator device.
Signed-off-by: Xiaotong Lu <xiaotong.lu@spreadtrum.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
Changes since v1:
- No updates.
---
.../bindings/input/sprd,sc27xx-vibra.txt | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
new file mode 100644
index 0000000..92ead29
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
@@ -0,0 +1,12 @@
+Spreadtrum SC27xx PMIC Vibrator
+
+Required properties:
+- compatible: should be "sprd,sc27xx-vibrator".
+- reg: address of vibrator control register.
+
+Example :
+
+vibrator@eb4 {
+ compatible = "sprd,sc27xx-vibrator";
+ reg = <0xeb4>;
+};
--
1.7.9.5
^ permalink raw reply related
* WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
From: syzbot @ 2018-04-23 2:02 UTC (permalink / raw)
To: dmitry.torokhov, linux-input, linux-kernel, rydberg,
syzkaller-bugs
Hello,
syzbot hit the following crash on upstream commit
285848b0f4074f04ab606f1e5dca296482033d54 (Sun Apr 22 04:20:48 2018 +0000)
Merge tag 'random_for_linus_stable' of
git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
syzbot dashboard link:
https://syzkaller.appspot.com/bug?extid=e1670f554caa60fb147b
So far this crash happened 398 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6457007586410496
syzkaller reproducer:
https://syzkaller.appspot.com/x/repro.syz?id=5576436211515392
Raw console output:
https://syzkaller.appspot.com/x/log.txt?id=6327380104708096
Kernel config:
https://syzkaller.appspot.com/x/.config?id=1808800213120130118
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+e1670f554caa60fb147b@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.
=====================================================
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
4.17.0-rc1+ #12 Not tainted
-----------------------------------------------------
syzkaller880831/4534 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
(ptrval) (fs_reclaim){+.+.}, at:
fs_reclaim_acquire.part.82+0x0/0x30 mm/page_alloc.c:463
and this task is already holding:
(ptrval) (&(&dev->event_lock)->rlock){-.-.}, at:
input_inject_event+0xe0/0x3ed drivers/input/input.c:461
which would create a new lock dependency:
(&(&dev->event_lock)->rlock){-.-.} -> (fs_reclaim){+.+.}
but this new dependency connects a HARDIRQ-irq-safe lock:
(&(&dev->event_lock)->rlock){-.-.}
... which became HARDIRQ-irq-safe at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
input_event+0x67/0xa0 drivers/input/input.c:435
input_report_key include/linux/input.h:393 [inline]
psmouse_report_standard_buttons+0x31/0x90
drivers/input/mouse/psmouse-base.c:127
psmouse_report_standard_packet drivers/input/mouse/psmouse-base.c:145
[inline]
psmouse_process_byte+0x1ef/0x710 drivers/input/mouse/psmouse-base.c:236
psmouse_handle_byte+0x4a/0x570 drivers/input/mouse/psmouse-base.c:278
psmouse_interrupt+0x38a/0x1420 drivers/input/mouse/psmouse-base.c:428
serio_interrupt+0x98/0x160 drivers/input/serio/serio.c:1018
i8042_interrupt+0x385/0x5e0 drivers/input/serio/i8042.c:586
__handle_irq_event_percpu+0x1c0/0xad0 kernel/irq/handle.c:149
handle_irq_event_percpu+0x98/0x1c0 kernel/irq/handle.c:189
handle_irq_event+0xa7/0x135 kernel/irq/handle.c:206
handle_edge_irq+0x20f/0x870 kernel/irq/chip.c:791
generic_handle_irq_desc include/linux/irqdesc.h:159 [inline]
handle_irq+0x18c/0x2e7 arch/x86/kernel/irq_64.c:77
do_IRQ+0x78/0x190 arch/x86/kernel/irq.c:245
ret_from_intr+0x0/0x1e
arch_local_irq_enable arch/x86/include/asm/paravirt.h:793 [inline]
__do_softirq+0x298/0xaf5 kernel/softirq.c:269
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1d1/0x200 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:525 [inline]
smp_apic_timer_interrupt+0x17e/0x710 arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:863
arch_local_irq_restore arch/x86/include/asm/paravirt.h:783 [inline]
lock_release+0x4d4/0xa10 kernel/locking/lockdep.c:3942
fs_reclaim_release.part.83+0x1c/0x20 mm/page_alloc.c:3746
fs_reclaim_release+0x14/0x20 mm/page_alloc.c:3747
slab_pre_alloc_hook mm/slab.h:419 [inline]
slab_alloc mm/slab.c:3378 [inline]
kmem_cache_alloc+0x30/0x760 mm/slab.c:3552
kmem_cache_zalloc include/linux/slab.h:691 [inline]
__kernfs_new_node+0xe7/0x580 fs/kernfs/dir.c:633
kernfs_new_node+0x80/0xf0 fs/kernfs/dir.c:679
__kernfs_create_file+0x4d/0x330 fs/kernfs/file.c:989
sysfs_add_file_mode_ns+0x21a/0x560 fs/sysfs/file.c:305
create_files fs/sysfs/group.c:62 [inline]
internal_create_group+0x282/0x970 fs/sysfs/group.c:132
sysfs_create_group fs/sysfs/group.c:154 [inline]
sysfs_create_groups+0x9b/0x150 fs/sysfs/group.c:181
device_add_groups drivers/base/core.c:1033 [inline]
device_add_attrs drivers/base/core.c:1181 [inline]
device_add+0x84d/0x16d0 drivers/base/core.c:1813
netdev_register_kobject+0x180/0x380 net/core/net-sysfs.c:1604
register_netdevice+0x997/0x11c0 net/core/dev.c:7961
register_netdev+0x30/0x50 net/core/dev.c:8076
sit_init_net+0x445/0xc50 net/ipv6/sit.c:1857
ops_init+0xff/0x550 net/core/net_namespace.c:128
__register_pernet_operations net/core/net_namespace.c:912 [inline]
register_pernet_operations+0x49a/0x9f0 net/core/net_namespace.c:987
register_pernet_device+0x2a/0x80 net/core/net_namespace.c:1074
sit_init+0x22/0x175 net/ipv6/sit.c:1914
do_one_initcall+0x127/0x913 init/main.c:883
do_initcall_level init/main.c:951 [inline]
do_initcalls init/main.c:959 [inline]
do_basic_setup init/main.c:977 [inline]
kernel_init_freeable+0x49b/0x58e init/main.c:1127
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
to a HARDIRQ-irq-unsafe lock:
(fs_reclaim){+.+.}
... which became HARDIRQ-irq-unsafe at:
...
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30 mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc_node mm/slab.c:3299 [inline]
kmem_cache_alloc_node_trace+0x39/0x770 mm/slab.c:3661
kmalloc_node include/linux/slab.h:550 [inline]
kzalloc_node include/linux/slab.h:712 [inline]
alloc_worker+0xbd/0x2e0 kernel/workqueue.c:1704
init_rescuer.part.25+0x1f/0x190 kernel/workqueue.c:4000
init_rescuer kernel/workqueue.c:3997 [inline]
workqueue_init+0x51f/0x7d0 kernel/workqueue.c:5732
kernel_init_freeable+0x2ad/0x58e init/main.c:1115
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
other info that might help us debug this:
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(fs_reclaim);
local_irq_disable();
lock(&(&dev->event_lock)->rlock);
lock(fs_reclaim);
<Interrupt>
lock(&(&dev->event_lock)->rlock);
*** DEADLOCK ***
3 locks held by syzkaller880831/4534:
#0: (ptrval) (&evdev->mutex){+.+.}, at: evdev_write+0x1cc/0x860
drivers/input/evdev.c:543
#1: (ptrval) (&(&dev->event_lock)->rlock){-.-.}, at:
input_inject_event+0xe0/0x3ed drivers/input/input.c:461
#2: (ptrval) (rcu_read_lock){....}, at: is_event_supported
drivers/input/input.c:56 [inline]
#2: (ptrval) (rcu_read_lock){....}, at:
input_inject_event+0xc5/0x3ed drivers/input/input.c:460
the dependencies between HARDIRQ-irq-safe lock and the holding lock:
-> (&(&dev->event_lock)->rlock){-.-.} ops: 1797 {
IN-HARDIRQ-W at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
__raw_spin_lock_irqsave
include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x96/0xc0
kernel/locking/spinlock.c:152
input_event+0x67/0xa0 drivers/input/input.c:435
input_report_key include/linux/input.h:393 [inline]
psmouse_report_standard_buttons+0x31/0x90
drivers/input/mouse/psmouse-base.c:127
psmouse_report_standard_packet
drivers/input/mouse/psmouse-base.c:145 [inline]
psmouse_process_byte+0x1ef/0x710
drivers/input/mouse/psmouse-base.c:236
psmouse_handle_byte+0x4a/0x570
drivers/input/mouse/psmouse-base.c:278
psmouse_interrupt+0x38a/0x1420
drivers/input/mouse/psmouse-base.c:428
serio_interrupt+0x98/0x160
drivers/input/serio/serio.c:1018
i8042_interrupt+0x385/0x5e0
drivers/input/serio/i8042.c:586
__handle_irq_event_percpu+0x1c0/0xad0
kernel/irq/handle.c:149
handle_irq_event_percpu+0x98/0x1c0
kernel/irq/handle.c:189
handle_irq_event+0xa7/0x135 kernel/irq/handle.c:206
handle_edge_irq+0x20f/0x870 kernel/irq/chip.c:791
generic_handle_irq_desc include/linux/irqdesc.h:159
[inline]
handle_irq+0x18c/0x2e7 arch/x86/kernel/irq_64.c:77
do_IRQ+0x78/0x190 arch/x86/kernel/irq.c:245
ret_from_intr+0x0/0x1e
arch_local_irq_enable
arch/x86/include/asm/paravirt.h:793 [inline]
__do_softirq+0x298/0xaf5 kernel/softirq.c:269
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1d1/0x200 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:525 [inline]
smp_apic_timer_interrupt+0x17e/0x710
arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0xf/0x20
arch/x86/entry/entry_64.S:863
arch_local_irq_restore
arch/x86/include/asm/paravirt.h:783 [inline]
lock_release+0x4d4/0xa10 kernel/locking/lockdep.c:3942
fs_reclaim_release.part.83+0x1c/0x20
mm/page_alloc.c:3746
fs_reclaim_release+0x14/0x20 mm/page_alloc.c:3747
slab_pre_alloc_hook mm/slab.h:419 [inline]
slab_alloc mm/slab.c:3378 [inline]
kmem_cache_alloc+0x30/0x760 mm/slab.c:3552
kmem_cache_zalloc include/linux/slab.h:691 [inline]
__kernfs_new_node+0xe7/0x580 fs/kernfs/dir.c:633
kernfs_new_node+0x80/0xf0 fs/kernfs/dir.c:679
__kernfs_create_file+0x4d/0x330 fs/kernfs/file.c:989
sysfs_add_file_mode_ns+0x21a/0x560 fs/sysfs/file.c:305
create_files fs/sysfs/group.c:62 [inline]
internal_create_group+0x282/0x970 fs/sysfs/group.c:132
sysfs_create_group fs/sysfs/group.c:154 [inline]
sysfs_create_groups+0x9b/0x150 fs/sysfs/group.c:181
device_add_groups drivers/base/core.c:1033 [inline]
device_add_attrs drivers/base/core.c:1181 [inline]
device_add+0x84d/0x16d0 drivers/base/core.c:1813
netdev_register_kobject+0x180/0x380
net/core/net-sysfs.c:1604
register_netdevice+0x997/0x11c0 net/core/dev.c:7961
register_netdev+0x30/0x50 net/core/dev.c:8076
sit_init_net+0x445/0xc50 net/ipv6/sit.c:1857
ops_init+0xff/0x550 net/core/net_namespace.c:128
__register_pernet_operations
net/core/net_namespace.c:912 [inline]
register_pernet_operations+0x49a/0x9f0
net/core/net_namespace.c:987
register_pernet_device+0x2a/0x80
net/core/net_namespace.c:1074
sit_init+0x22/0x175 net/ipv6/sit.c:1914
do_one_initcall+0x127/0x913 init/main.c:883
do_initcall_level init/main.c:951 [inline]
do_initcalls init/main.c:959 [inline]
do_basic_setup init/main.c:977 [inline]
kernel_init_freeable+0x49b/0x58e init/main.c:1127
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
IN-SOFTIRQ-W at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
__raw_spin_lock_irqsave
include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x96/0xc0
kernel/locking/spinlock.c:152
input_event+0x67/0xa0 drivers/input/input.c:435
input_report_key include/linux/input.h:393 [inline]
psmouse_report_standard_buttons+0x31/0x90
drivers/input/mouse/psmouse-base.c:127
psmouse_report_standard_packet
drivers/input/mouse/psmouse-base.c:145 [inline]
psmouse_process_byte+0x1ef/0x710
drivers/input/mouse/psmouse-base.c:236
psmouse_handle_byte+0x4a/0x570
drivers/input/mouse/psmouse-base.c:278
psmouse_interrupt+0x38a/0x1420
drivers/input/mouse/psmouse-base.c:428
serio_interrupt+0x98/0x160
drivers/input/serio/serio.c:1018
i8042_interrupt+0x385/0x5e0
drivers/input/serio/i8042.c:586
__handle_irq_event_percpu+0x1c0/0xad0
kernel/irq/handle.c:149
handle_irq_event_percpu+0x98/0x1c0
kernel/irq/handle.c:189
handle_irq_event+0xa7/0x135 kernel/irq/handle.c:206
handle_edge_irq+0x20f/0x870 kernel/irq/chip.c:791
generic_handle_irq_desc include/linux/irqdesc.h:159
[inline]
handle_irq+0x18c/0x2e7 arch/x86/kernel/irq_64.c:77
do_IRQ+0x78/0x190 arch/x86/kernel/irq.c:245
ret_from_intr+0x0/0x1e
arch_local_irq_enable
arch/x86/include/asm/paravirt.h:793 [inline]
__do_softirq+0x298/0xaf5 kernel/softirq.c:269
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1d1/0x200 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:525 [inline]
smp_apic_timer_interrupt+0x17e/0x710
arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0xf/0x20
arch/x86/entry/entry_64.S:863
arch_local_irq_restore
arch/x86/include/asm/paravirt.h:783 [inline]
lock_release+0x4d4/0xa10 kernel/locking/lockdep.c:3942
fs_reclaim_release.part.83+0x1c/0x20
mm/page_alloc.c:3746
fs_reclaim_release+0x14/0x20 mm/page_alloc.c:3747
slab_pre_alloc_hook mm/slab.h:419 [inline]
slab_alloc mm/slab.c:3378 [inline]
kmem_cache_alloc+0x30/0x760 mm/slab.c:3552
kmem_cache_zalloc include/linux/slab.h:691 [inline]
__kernfs_new_node+0xe7/0x580 fs/kernfs/dir.c:633
kernfs_new_node+0x80/0xf0 fs/kernfs/dir.c:679
__kernfs_create_file+0x4d/0x330 fs/kernfs/file.c:989
sysfs_add_file_mode_ns+0x21a/0x560 fs/sysfs/file.c:305
create_files fs/sysfs/group.c:62 [inline]
internal_create_group+0x282/0x970 fs/sysfs/group.c:132
sysfs_create_group fs/sysfs/group.c:154 [inline]
sysfs_create_groups+0x9b/0x150 fs/sysfs/group.c:181
device_add_groups drivers/base/core.c:1033 [inline]
device_add_attrs drivers/base/core.c:1181 [inline]
device_add+0x84d/0x16d0 drivers/base/core.c:1813
netdev_register_kobject+0x180/0x380
net/core/net-sysfs.c:1604
register_netdevice+0x997/0x11c0 net/core/dev.c:7961
register_netdev+0x30/0x50 net/core/dev.c:8076
sit_init_net+0x445/0xc50 net/ipv6/sit.c:1857
ops_init+0xff/0x550 net/core/net_namespace.c:128
__register_pernet_operations
net/core/net_namespace.c:912 [inline]
register_pernet_operations+0x49a/0x9f0
net/core/net_namespace.c:987
register_pernet_device+0x2a/0x80
net/core/net_namespace.c:1074
sit_init+0x22/0x175 net/ipv6/sit.c:1914
do_one_initcall+0x127/0x913 init/main.c:883
do_initcall_level init/main.c:951 [inline]
do_initcalls init/main.c:959 [inline]
do_basic_setup init/main.c:977 [inline]
kernel_init_freeable+0x49b/0x58e init/main.c:1127
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
INITIAL USE at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
__raw_spin_lock_irqsave
include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x96/0xc0
kernel/locking/spinlock.c:152
input_inject_event+0xe0/0x3ed drivers/input/input.c:461
input_leds_brightness_set+0x81/0xb0
drivers/input/input-leds.c:66
__led_set_brightness drivers/leds/led-core.c:34 [inline]
led_set_brightness_nopm+0x4c/0xe0
drivers/leds/led-core.c:261
led_set_brightness_nosleep drivers/leds/led-core.c:278
[inline]
led_set_brightness+0x113/0x220
drivers/leds/led-core.c:253
led_trigger_event+0x77/0xd0
drivers/leds/led-triggers.c:292
kbd_led_trigger_activate+0xed/0x120
drivers/tty/vt/keyboard.c:969
led_trigger_set+0x668/0x930
drivers/leds/led-triggers.c:138
led_trigger_set_default+0x10a/0x180
drivers/leds/led-triggers.c:171
of_led_classdev_register+0x485/0x640
drivers/leds/led-class.c:302
input_leds_connect+0x410/0x7c0
drivers/input/input-leds.c:143
input_attach_handler+0x1b1/0x210
drivers/input/input.c:996
input_register_device.cold.22+0xe8/0x297
drivers/input/input.c:2152
atkbd_connect+0x6fe/0x930
drivers/input/keyboard/atkbd.c:1200
serio_connect_driver+0x4f/0x70
drivers/input/serio/serio.c:63
serio_driver_probe+0x47/0x60
drivers/input/serio/serio.c:794
really_probe drivers/base/dd.c:448 [inline]
driver_probe_device+0x69b/0x960 drivers/base/dd.c:590
__driver_attach+0x1b2/0x1f0 drivers/base/dd.c:824
bus_for_each_dev+0x151/0x1d0 drivers/base/bus.c:311
driver_attach+0x3d/0x50 drivers/base/dd.c:843
serio_attach_driver drivers/input/serio/serio.c:824
[inline]
serio_handle_event+0x70a/0xb20
drivers/input/serio/serio.c:243
process_one_work+0xc1e/0x1b50 kernel/workqueue.c:2145
worker_thread+0x1cc/0x1440 kernel/workqueue.c:2279
kthread+0x345/0x410 kernel/kthread.c:238
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
}
... key at: [<ffffffff8b147da0>] __key.33448+0x0/0x40
... acquired at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30 mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc mm/slab.c:3378 [inline]
__do_kmalloc mm/slab.c:3716 [inline]
__kmalloc+0x45/0x760 mm/slab.c:3727
kmalloc_array include/linux/slab.h:631 [inline]
kcalloc include/linux/slab.h:642 [inline]
numa_crng_init drivers/char/random.c:798 [inline]
crng_reseed+0x427/0x920 drivers/char/random.c:923
credit_entropy_bits+0x98d/0xa30 drivers/char/random.c:708
add_timer_randomness+0x26b/0x320 drivers/char/random.c:1133
add_input_randomness+0xce/0x3e0 drivers/char/random.c:1148
input_handle_event+0xb3/0x1210 drivers/input/input.c:375
input_inject_event+0x367/0x3ed drivers/input/input.c:466
evdev_write+0x4d1/0x860 drivers/input/evdev.c:560
__vfs_write+0x10b/0x960 fs/read_write.c:485
vfs_write+0x1f8/0x560 fs/read_write.c:549
ksys_write+0xf9/0x250 fs/read_write.c:598
__do_sys_write fs/read_write.c:610 [inline]
__se_sys_write fs/read_write.c:607 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:607
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
the dependencies between the lock to be acquired
and HARDIRQ-irq-unsafe lock:
-> (fs_reclaim){+.+.} ops: 1058989 {
HARDIRQ-ON-W at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30
mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc_node mm/slab.c:3299 [inline]
kmem_cache_alloc_node_trace+0x39/0x770 mm/slab.c:3661
kmalloc_node include/linux/slab.h:550 [inline]
kzalloc_node include/linux/slab.h:712 [inline]
alloc_worker+0xbd/0x2e0 kernel/workqueue.c:1704
init_rescuer.part.25+0x1f/0x190 kernel/workqueue.c:4000
init_rescuer kernel/workqueue.c:3997 [inline]
workqueue_init+0x51f/0x7d0 kernel/workqueue.c:5732
kernel_init_freeable+0x2ad/0x58e init/main.c:1115
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
SOFTIRQ-ON-W at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30
mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc_node mm/slab.c:3299 [inline]
kmem_cache_alloc_node_trace+0x39/0x770 mm/slab.c:3661
kmalloc_node include/linux/slab.h:550 [inline]
kzalloc_node include/linux/slab.h:712 [inline]
alloc_worker+0xbd/0x2e0 kernel/workqueue.c:1704
init_rescuer.part.25+0x1f/0x190 kernel/workqueue.c:4000
init_rescuer kernel/workqueue.c:3997 [inline]
workqueue_init+0x51f/0x7d0 kernel/workqueue.c:5732
kernel_init_freeable+0x2ad/0x58e init/main.c:1115
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
INITIAL USE at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30 mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc_node mm/slab.c:3299 [inline]
kmem_cache_alloc_node_trace+0x39/0x770 mm/slab.c:3661
kmalloc_node include/linux/slab.h:550 [inline]
kzalloc_node include/linux/slab.h:712 [inline]
alloc_worker+0xbd/0x2e0 kernel/workqueue.c:1704
init_rescuer.part.25+0x1f/0x190 kernel/workqueue.c:4000
init_rescuer kernel/workqueue.c:3997 [inline]
workqueue_init+0x51f/0x7d0 kernel/workqueue.c:5732
kernel_init_freeable+0x2ad/0x58e init/main.c:1115
kernel_init+0x11/0x1b3 init/main.c:1053
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
}
... key at: [<ffffffff88df4620>] __fs_reclaim_map+0x0/0x40
... acquired at:
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30 mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc mm/slab.c:3378 [inline]
__do_kmalloc mm/slab.c:3716 [inline]
__kmalloc+0x45/0x760 mm/slab.c:3727
kmalloc_array include/linux/slab.h:631 [inline]
kcalloc include/linux/slab.h:642 [inline]
numa_crng_init drivers/char/random.c:798 [inline]
crng_reseed+0x427/0x920 drivers/char/random.c:923
credit_entropy_bits+0x98d/0xa30 drivers/char/random.c:708
add_timer_randomness+0x26b/0x320 drivers/char/random.c:1133
add_input_randomness+0xce/0x3e0 drivers/char/random.c:1148
input_handle_event+0xb3/0x1210 drivers/input/input.c:375
input_inject_event+0x367/0x3ed drivers/input/input.c:466
evdev_write+0x4d1/0x860 drivers/input/evdev.c:560
__vfs_write+0x10b/0x960 fs/read_write.c:485
vfs_write+0x1f8/0x560 fs/read_write.c:549
ksys_write+0xf9/0x250 fs/read_write.c:598
__do_sys_write fs/read_write.c:610 [inline]
__se_sys_write fs/read_write.c:607 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:607
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
stack backtrace:
CPU: 0 PID: 4534 Comm: syzkaller880831 Not tainted 4.17.0-rc1+ #12
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1b9/0x294 lib/dump_stack.c:113
print_bad_irq_dependency kernel/locking/lockdep.c:1570 [inline]
check_usage.cold.58+0x6d5/0xac7 kernel/locking/lockdep.c:1602
check_irq_usage kernel/locking/lockdep.c:1658 [inline]
check_prev_add_irq kernel/locking/lockdep_states.h:7 [inline]
check_prev_add kernel/locking/lockdep.c:1868 [inline]
check_prevs_add kernel/locking/lockdep.c:1976 [inline]
validate_chain kernel/locking/lockdep.c:2417 [inline]
__lock_acquire+0x2417/0x5140 kernel/locking/lockdep.c:3431
lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
fs_reclaim_acquire.part.82+0x24/0x30 mm/page_alloc.c:3739
fs_reclaim_acquire+0x14/0x20 mm/page_alloc.c:3740
slab_pre_alloc_hook mm/slab.h:418 [inline]
slab_alloc mm/slab.c:3378 [inline]
__do_kmalloc mm/slab.c:3716 [inline]
__kmalloc+0x45/0x760 mm/slab.c:3727
kmalloc_array include/linux/slab.h:631 [inline]
kcalloc include/linux/slab.h:642 [inline]
numa_crng_init drivers/char/random.c:798 [inline]
crng_reseed+0x427/0x920 drivers/char/random.c:923
credit_entropy_bits+0x98d/0xa30 drivers/char/random.c:708
add_timer_randomness+0x26b/0x320 drivers/char/random.c:1133
add_input_randomness+0xce/0x3e0 drivers/char/random.c:1148
input_handle_event+0xb3/0x1210 drivers/input/input.c:375
input_inject_event+0x367/0x3ed drivers/input/input.c:466
evdev_write+0x4d1/0x860 drivers/input/evdev.c:560
__vfs_write+0x10b/0x960 fs/read_write.c:485
vfs_write+0x1f8/0x560 fs/read_write.c:549
ksys_write+0xf9/0x250 fs/read_write.c:598
__do_sys_write fs/read_write.c:610 [inline]
__se_sys_write fs/read_write.c:607 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:607
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x443db9
RSP: 002b:00007ffd62c88e88 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0008000040000002 RCX: 0000000000443db9
RDX: 0000000000000030 RSI: 00000000200000c0 RDI: 00000000000003ff
RBP: 746e6576652f7475 R08: 00000000004002e0 R09: 00000000004002e0
R10: 0000000000000000 R11: 0000000000000246 R12: 706e692f7665642f
R13: 0000000000401af0 R14: 0000000000000000 R15: 0000000000000000
BUG: sleeping function called from invalid context at mm/slab.h:421
in_atomic(): 1, irqs_disabled(): 1, pid: 4534, name: syzkaller880831
INFO: lockdep is turned off.
irq event stamp: 74430
hardirqs last enabled at (74429): [<ffffffff8100c172>]
do_syscall_64+0x92/0x800 arch/x86/entry/common.c:274
hardirqs last disabled at (74430): [<ffffffff876eada4>]
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
hardirqs last disabled at (74430): [<ffffffff876eada4>]
_raw_spin_lock_irqsave+0x74/0xc0 kernel/locking/spinlock.c:152
softirqs last enabled at (74408): [<ffffffff87a00778>]
__do_softirq+0x778/0xaf5 kernel/softirq.c:311
softirqs last disabled at (74401): [<ffffffff81475041>] invoke_softirq
kernel/softirq.c:365 [inline]
softirqs last disabled at (74401): [<ffffffff81475041>]
irq_exit+0x1d1/0x200 kernel/softirq.c:405
CPU: 0 PID: 4534 Comm: syzkaller880831 Not tainted 4.17.0-rc1+ #12
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1b9/0x294 lib/dump_stack.c:113
___might_sleep.cold.87+0x11f/0x13a kernel/sched/core.c:6188
__might_sleep+0x95/0x190 kernel/sched/core.c:6141
slab_pre_alloc_hook mm/slab.h:421 [inline]
slab_alloc mm/slab.c:3378 [inline]
__do_kmalloc mm/slab.c:3716 [inline]
__kmalloc+0x2b9/0x760 mm/slab.c:3727
kmalloc_array include/linux/slab.h:631 [inline]
kcalloc include/linux/slab.h:642 [inline]
numa_crng_init drivers/char/random.c:798 [inline]
crng_reseed+0x427/0x920 drivers/char/random.c:923
credit_entropy_bits+0x98d/0xa30 drivers/char/random.c:708
add_timer_randomness+0x26b/0x320 drivers/char/random.c:1133
add_input_randomness+0xce/0x3e0 drivers/char/random.c:1148
input_handle_event+0xb3/0x1210 drivers/input/input.c:375
input_inject_event+0x367/0x3ed drivers/input/input.c:466
evdev_write+0x4d1/0x860 drivers/input/evdev.c:560
__vfs_write+0x10b/0x960 fs/read_write.c:485
vfs_write+0x1f8/0x560 fs/read_write.c:549
ksys_write+0xf9/0x250 fs/read_write.c:598
__do_sys_write fs/read_write.c:610 [inline]
__se_sys_write fs/read_write.c:607 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:607
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x443db9
RSP: 002b:00007ffd62c88e88 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0008000040000002 RCX: 0000000000443db9
RDX: 0000000000000030 RSI: 00000000200000c0 RDI: 00000000000003ff
RBP: 746e6576652f7475 R08: 00000000004002e0 R09: 00000000004002e0
R10: 0000000000000000 R11: 0000000000000246 R12: 706e692f7665642f
R13: 0000000000401af0 R14: 0000000000000000 R15: 0000000000000000
random: crng init done
---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzkaller@googlegroups.com.
syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts - fix reset-gpio for level based irqs
From: Nick Dyer @ 2018-04-21 20:11 UTC (permalink / raw)
To: Sebastian Reichel, Ezequiel Garcia
Cc: Dmitry Torokhov, linux-input, linux-kernel, kernel
In-Reply-To: <20180420194207.i2zo235duknjsjjd@earth.universe>
On Fri, Apr 20, 2018 at 09:42:07PM +0200, Sebastian Reichel wrote:
> On Fri, Apr 20, 2018 at 02:44:02PM -0300, Ezequiel Garcia wrote:
> > Hi Sebastian,
> >
> > On Fri, 2018-04-20 at 19:24 +0200, Sebastian Reichel wrote:
> > > The current reset-gpio support triggers an interrupt storm on platforms
> > > using the maxtouch with level based interrupt. The Motorola Droid 4,
> > > which I used for some of the tests is not affected, since it uses a level
> > > based interrupt.
> > >
> >
> > I found this confusing. Interrupt storm happen with level-based interrupts,
> > but the Droid4 is not affected?
Can I ask what happens during the interrupt storm. Are you getting lots
of the "failed to read T44 and T5" message, or something else?
> > > This change avoids the interrupt storm by enabling the device while
> > > its interrupt is disabled. The following mxt_initialize() requires,
> > > that the device is responsive (at least mxt224E is unresponsive for
> > > ~22ms), so we wait some time. We don't wait for leaving bootloader
> > > mode anymore, since mxt_initialize() checks for it anyways.
> > >
> >
> > IMHO, having some more or less arbritrary sleeps is almost
> > always a problem. This value might be enough for some platform,
> > might be too short for some other, and then it might get too large
> > for someone else.
>
> The 22ms chip-being-unresponsive are not newly introduced. The
> same 22ms are also required for soft-reset. I did introduce a
> new time (MXT_RESET_GPIO_TIME) for the "chip being reset" state,
> since my randomly chosen 200ms from before were exaggerated
> considering all mxt datasheets I checked stated only a few nano
> seconds.
According to the data sheets there is a period after a reset where the
CHG line is temporarily set as an input, during which the host should
ignore it. If you don't, you might get a stray interrupt and try and
communicate with the device, which might leave it in a bad state. I
think you mentioned that later in your email.
The reset time varies per chip, but the 100ms in mxt_soft_reset() was
based on discussions with app support at Atmel, so should be correct in
most cases.
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts - fix reset-gpio for level based irqs
From: Sebastian Reichel @ 2018-04-20 19:42 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: Nick Dyer, Dmitry Torokhov, linux-input, linux-kernel, kernel
In-Reply-To: <7b4976b0a8a642767bd4e0a5e9d7fb6c9dc86ec9.camel@collabora.com>
[-- Attachment #1: Type: text/plain, Size: 3719 bytes --]
On Fri, Apr 20, 2018 at 02:44:02PM -0300, Ezequiel Garcia wrote:
> Hi Sebastian,
>
> On Fri, 2018-04-20 at 19:24 +0200, Sebastian Reichel wrote:
> > The current reset-gpio support triggers an interrupt storm on platforms
> > using the maxtouch with level based interrupt. The Motorola Droid 4,
> > which I used for some of the tests is not affected, since it uses a level
> > based interrupt.
> >
>
> I found this confusing. Interrupt storm happen with level-based interrupts,
> but the Droid4 is not affected?
This is a typo. Droid 4 has an edge based interrupt defined, PPD has
an level based interrupt defined. PPD got an interrupt storm, Droid 4
did not.
> > This change avoids the interrupt storm by enabling the device while
> > its interrupt is disabled. The following mxt_initialize() requires,
> > that the device is responsive (at least mxt224E is unresponsive for
> > ~22ms), so we wait some time. We don't wait for leaving bootloader
> > mode anymore, since mxt_initialize() checks for it anyways.
> >
>
> IMHO, having some more or less arbritrary sleeps is almost
> always a problem. This value might be enough for some platform,
> might be too short for some other, and then it might get too large
> for someone else.
The 22ms chip-being-unresponsive are not newly introduced. The
same 22ms are also required for soft-reset. I did introduce a
new time (MXT_RESET_GPIO_TIME) for the "chip being reset" state,
since my randomly chosen 200ms from before were exaggerated
considering all mxt datasheets I checked stated only a few nano
seconds.
> > This fixes a boot problem on GE PPD (watchdog kills device) and also
> > has been tested on the Droid 4.
> >
> > Fixes: f657b00df22e ("Input: atmel_mxt_ts - add support for reset line")
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> > ---
> > drivers/input/touchscreen/atmel_mxt_ts.c | 15 +++++----------
> > 1 file changed, 5 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> > index 5d9699fe1b55..f8a9f2a47e78 100644
> > --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> > @@ -194,6 +194,7 @@ enum t100_type {
> >
> > /* Delay times */
> > #define MXT_BACKUP_TIME 50 /* msec */
> > +#define MXT_RESET_GPIO_TIME 20 /* msec */
> > #define MXT_RESET_TIME 200 /* msec */
> > #define MXT_RESET_TIMEOUT 3000 /* msec */
> > #define MXT_CRC_TIMEOUT 1000 /* msec */
> > @@ -3167,20 +3168,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
> > return error;
> > }
> >
> > + disable_irq(client->irq);
> > +
> > if (data->reset_gpio) {
> > - data->in_bootloader = true;
> > - msleep(MXT_RESET_TIME);
> > - reinit_completion(&data->bl_completion);
> > + msleep(MXT_RESET_GPIO_TIME);
> > gpiod_set_value(data->reset_gpio, 1);
>
> Can't we enable the IRQ here, just before the wait...
>
> > - error = mxt_wait_for_completion(data, &data->bl_completion,
> > - MXT_RESET_TIMEOUT);
>
> ... and then disable it back afterwards?
Yes and no. We need the wait, since the interrupt pin does random
stuff for 100ms after reset. We can do the wait-for-completion
after that time (see mxt_soft_reset function). I kept it simple,
since the following init does another soft reset anyways.
> > - if (error)
> > - return error;
> > - data->in_bootloader = false;
> > + msleep(MXT_RESET_TIME);
>
> > }
> >
> > - disable_irq(client->irq);
> > -
> > error = mxt_initialize(data);
> > if (error)
> > return error;
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH] Input: atmel_mxt_ts - fix reset-gpio for level based irqs
From: Ezequiel Garcia @ 2018-04-20 17:44 UTC (permalink / raw)
To: Sebastian Reichel, Nick Dyer, Dmitry Torokhov, linux-input
Cc: linux-kernel, kernel
In-Reply-To: <20180420172408.26164-1-sebastian.reichel@collabora.co.uk>
Hi Sebastian,
On Fri, 2018-04-20 at 19:24 +0200, Sebastian Reichel wrote:
> The current reset-gpio support triggers an interrupt storm on platforms
> using the maxtouch with level based interrupt. The Motorola Droid 4,
> which I used for some of the tests is not affected, since it uses a level
> based interrupt.
>
I found this confusing. Interrupt storm happen with level-based interrupts,
but the Droid4 is not affected?
> This change avoids the interrupt storm by enabling the device while
> its interrupt is disabled. The following mxt_initialize() requires,
> that the device is responsive (at least mxt224E is unresponsive for
> ~22ms), so we wait some time. We don't wait for leaving bootloader
> mode anymore, since mxt_initialize() checks for it anyways.
>
IMHO, having some more or less arbritrary sleeps is almost
always a problem. This value might be enough for some platform,
might be too short for some other, and then it might get too large
for someone else.
> This fixes a boot problem on GE PPD (watchdog kills device) and also
> has been tested on the Droid 4.
>
> Fixes: f657b00df22e ("Input: atmel_mxt_ts - add support for reset line")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> ---
> drivers/input/touchscreen/atmel_mxt_ts.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 5d9699fe1b55..f8a9f2a47e78 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -194,6 +194,7 @@ enum t100_type {
>
> /* Delay times */
> #define MXT_BACKUP_TIME 50 /* msec */
> +#define MXT_RESET_GPIO_TIME 20 /* msec */
> #define MXT_RESET_TIME 200 /* msec */
> #define MXT_RESET_TIMEOUT 3000 /* msec */
> #define MXT_CRC_TIMEOUT 1000 /* msec */
> @@ -3167,20 +3168,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
> return error;
> }
>
> + disable_irq(client->irq);
> +
> if (data->reset_gpio) {
> - data->in_bootloader = true;
> - msleep(MXT_RESET_TIME);
> - reinit_completion(&data->bl_completion);
> + msleep(MXT_RESET_GPIO_TIME);
> gpiod_set_value(data->reset_gpio, 1);
Can't we enable the IRQ here, just before the wait...
> - error = mxt_wait_for_completion(data, &data->bl_completion,
> - MXT_RESET_TIMEOUT);
... and then disable it back afterwards?
> - if (error)
> - return error;
> - data->in_bootloader = false;
> + msleep(MXT_RESET_TIME);
> }
>
> - disable_irq(client->irq);
> -
> error = mxt_initialize(data);
> if (error)
> return error;
> --
> 2.17.0
>
>
^ permalink raw reply
* [PATCH] Input: atmel_mxt_ts - fix reset-gpio for level based irqs
From: Sebastian Reichel @ 2018-04-20 17:24 UTC (permalink / raw)
To: Nick Dyer, Dmitry Torokhov, linux-input
Cc: linux-kernel, kernel, Sebastian Reichel
The current reset-gpio support triggers an interrupt storm on platforms
using the maxtouch with level based interrupt. The Motorola Droid 4,
which I used for some of the tests is not affected, since it uses a level
based interrupt.
This change avoids the interrupt storm by enabling the device while
its interrupt is disabled. The following mxt_initialize() requires,
that the device is responsive (at least mxt224E is unresponsive for
~22ms), so we wait some time. We don't wait for leaving bootloader
mode anymore, since mxt_initialize() checks for it anyways.
This fixes a boot problem on GE PPD (watchdog kills device) and also
has been tested on the Droid 4.
Fixes: f657b00df22e ("Input: atmel_mxt_ts - add support for reset line")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 5d9699fe1b55..f8a9f2a47e78 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -194,6 +194,7 @@ enum t100_type {
/* Delay times */
#define MXT_BACKUP_TIME 50 /* msec */
+#define MXT_RESET_GPIO_TIME 20 /* msec */
#define MXT_RESET_TIME 200 /* msec */
#define MXT_RESET_TIMEOUT 3000 /* msec */
#define MXT_CRC_TIMEOUT 1000 /* msec */
@@ -3167,20 +3168,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
return error;
}
+ disable_irq(client->irq);
+
if (data->reset_gpio) {
- data->in_bootloader = true;
- msleep(MXT_RESET_TIME);
- reinit_completion(&data->bl_completion);
+ msleep(MXT_RESET_GPIO_TIME);
gpiod_set_value(data->reset_gpio, 1);
- error = mxt_wait_for_completion(data, &data->bl_completion,
- MXT_RESET_TIMEOUT);
- if (error)
- return error;
- data->in_bootloader = false;
+ msleep(MXT_RESET_TIME);
}
- disable_irq(client->irq);
-
error = mxt_initialize(data);
if (error)
return error;
--
2.17.0
^ permalink raw reply related
* Re: [PATCH v6 24/30] drm/rockchip: Disable PSR on input events
From: Enric Balletbo i Serra @ 2018-04-20 13:51 UTC (permalink / raw)
To: Andrzej Hajda, architt, inki.dae, thierry.reding, hjc, seanpaul,
airlied, tfiga, heiko
Cc: dri-devel, dianders, ykk, kernel, m.szyprowski, linux-samsung-soc,
jy0922.shim, rydberg, krzk, linux-rockchip, kgene, linux-input,
orjan.eide, wxt, jeffy.chen, linux-arm-kernel, mark.yao, wzz, hl,
jingoohan1, sw0312.kim, linux-kernel, kyungmin.park,
Laurent.pinchart, kuankuan.y, hshi, Kristian H. Kristensen
In-Reply-To: <9de97922-da64-d914-8b8c-ed064056edbd@samsung.com>
Hi Andrzej,
On 20/04/18 15:47, Andrzej Hajda wrote:
> Hi Enric,
>
>
> On 05.04.2018 11:49, Enric Balletbo i Serra wrote:
>> From: "Kristian H. Kristensen" <hoegsberg@google.com>
>>
>> To improve PSR exit latency, we speculatively start exiting when we
>> receive input events. Occasionally, this may lead to false positives,
>> but most of the time we get a head start on coming out of PSR. Depending
>> on how userspace takes to produce a new frame in response to the event,
>> this can completely hide the exit latency. In case of Chrome OS, we
>> typically get the input notifier 50ms or more before the dirty_fb
>> triggered exit.
>
> This patch is quite controversial and require more attention/discussion
> and probably changes.
Agree.
> The rest of the patches is OK, and all have r-b/t-b tags.
> If you prefer I can merge all other patches, if you rebase patches 25-30
> on top of patch 23, or I can only merge patches 01-23.
> What do you prefer?
>
If the patches 25-30 are also fine let me rebase those, and lets start a
discussion regarding patches 23-25 on another patchset. I'll send another
version without 23-25.
Regards,
Enric
> Regards
> Andrzej
>
>>
>> Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
>> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
>> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
>> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>>
>> drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 134 ++++++++++++++++++++++++++++
>> 1 file changed, 134 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
>> index 9376f4396b6b..a107845ba97c 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
>> @@ -12,6 +12,8 @@
>> * GNU General Public License for more details.
>> */
>>
>> +#include <linux/input.h>
>> +
>> #include <drm/drmP.h>
>> #include <drm/drm_crtc_helper.h>
>>
>> @@ -35,6 +37,9 @@ struct psr_drv {
>> enum psr_state state;
>>
>> struct delayed_work flush_work;
>> + struct work_struct disable_work;
>> +
>> + struct input_handler input_handler;
>>
>> int (*set)(struct drm_encoder *encoder, bool enable);
>> };
>> @@ -133,6 +138,18 @@ static void psr_flush_handler(struct work_struct *work)
>> mutex_unlock(&psr->lock);
>> }
>>
>> +static void psr_disable_handler(struct work_struct *work)
>> +{
>> + struct psr_drv *psr = container_of(work, struct psr_drv, disable_work);
>> +
>> + /* If the state has changed since we initiated the flush, do nothing */
>> + mutex_lock(&psr->lock);
>> + if (psr->state == PSR_ENABLE)
>> + psr_set_state_locked(psr, PSR_FLUSH);
>> + mutex_unlock(&psr->lock);
>> + mod_delayed_work(system_wq, &psr->flush_work, PSR_FLUSH_TIMEOUT_MS);
>> +}
>> +
>> /**
>> * rockchip_drm_psr_activate - activate PSR on the given pipe
>> * @encoder: encoder to obtain the PSR encoder
>> @@ -173,6 +190,7 @@ int rockchip_drm_psr_deactivate(struct drm_encoder *encoder)
>> psr->active = false;
>> mutex_unlock(&psr->lock);
>> cancel_delayed_work_sync(&psr->flush_work);
>> + cancel_work_sync(&psr->disable_work);
>>
>> return 0;
>> }
>> @@ -226,6 +244,95 @@ void rockchip_drm_psr_flush_all(struct drm_device *dev)
>> }
>> EXPORT_SYMBOL(rockchip_drm_psr_flush_all);
>>
>> +static void psr_input_event(struct input_handle *handle,
>> + unsigned int type, unsigned int code,
>> + int value)
>> +{
>> + struct psr_drv *psr = handle->handler->private;
>> +
>> + schedule_work(&psr->disable_work);
>> +}
>> +
>> +static int psr_input_connect(struct input_handler *handler,
>> + struct input_dev *dev,
>> + const struct input_device_id *id)
>> +{
>> + struct input_handle *handle;
>> + int error;
>> +
>> + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
>> + if (!handle)
>> + return -ENOMEM;
>> +
>> + handle->dev = dev;
>> + handle->handler = handler;
>> + handle->name = "rockchip-psr";
>> +
>> + error = input_register_handle(handle);
>> + if (error)
>> + goto err2;
>> +
>> + error = input_open_device(handle);
>> + if (error)
>> + goto err1;
>> +
>> + return 0;
>> +
>> +err1:
>> + input_unregister_handle(handle);
>> +err2:
>> + kfree(handle);
>> + return error;
>> +}
>> +
>> +static void psr_input_disconnect(struct input_handle *handle)
>> +{
>> + input_close_device(handle);
>> + input_unregister_handle(handle);
>> + kfree(handle);
>> +}
>> +
>> +/* Same device ids as cpu-boost */
>> +static const struct input_device_id psr_ids[] = {
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
>> + INPUT_DEVICE_ID_MATCH_ABSBIT,
>> + .evbit = { BIT_MASK(EV_ABS) },
>> + .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
>> + BIT_MASK(ABS_MT_POSITION_X) |
>> + BIT_MASK(ABS_MT_POSITION_Y) },
>> + }, /* multi-touch touchscreen */
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
>> + .evbit = { BIT_MASK(EV_ABS) },
>> + .absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) }
>> +
>> + }, /* stylus or joystick device */
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
>> + .evbit = { BIT_MASK(EV_KEY) },
>> + .keybit = { [BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) },
>> + }, /* pointer (e.g. trackpad, mouse) */
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
>> + .evbit = { BIT_MASK(EV_KEY) },
>> + .keybit = { [BIT_WORD(KEY_ESC)] = BIT_MASK(KEY_ESC) },
>> + }, /* keyboard */
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
>> + INPUT_DEVICE_ID_MATCH_KEYBIT,
>> + .evbit = { BIT_MASK(EV_KEY) },
>> + .keybit = {[BIT_WORD(BTN_JOYSTICK)] = BIT_MASK(BTN_JOYSTICK) },
>> + }, /* joysticks not caught by ABS_X above */
>> + {
>> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
>> + INPUT_DEVICE_ID_MATCH_KEYBIT,
>> + .evbit = { BIT_MASK(EV_KEY) },
>> + .keybit = { [BIT_WORD(BTN_GAMEPAD)] = BIT_MASK(BTN_GAMEPAD) },
>> + }, /* gamepad */
>> + { },
>> +};
>> +
>> /**
>> * rockchip_drm_psr_register - register encoder to psr driver
>> * @encoder: encoder that obtain the PSR function
>> @@ -239,6 +346,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
>> {
>> struct rockchip_drm_private *drm_drv = encoder->dev->dev_private;
>> struct psr_drv *psr;
>> + int error;
>>
>> if (!encoder || !psr_set)
>> return -EINVAL;
>> @@ -248,6 +356,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
>> return -ENOMEM;
>>
>> INIT_DELAYED_WORK(&psr->flush_work, psr_flush_handler);
>> + INIT_WORK(&psr->disable_work, psr_disable_handler);
>> mutex_init(&psr->lock);
>>
>> psr->active = true;
>> @@ -255,11 +364,33 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
>> psr->encoder = encoder;
>> psr->set = psr_set;
>>
>> + psr->input_handler.event = psr_input_event;
>> + psr->input_handler.connect = psr_input_connect;
>> + psr->input_handler.disconnect = psr_input_disconnect;
>> + psr->input_handler.name =
>> + kasprintf(GFP_KERNEL, "rockchip-psr-%s", encoder->name);
>> + if (!psr->input_handler.name) {
>> + error = -ENOMEM;
>> + goto err2;
>> + }
>> + psr->input_handler.id_table = psr_ids;
>> + psr->input_handler.private = psr;
>> +
>> + error = input_register_handler(&psr->input_handler);
>> + if (error)
>> + goto err1;
>> +
>> mutex_lock(&drm_drv->psr_list_lock);
>> list_add_tail(&psr->list, &drm_drv->psr_list);
>> mutex_unlock(&drm_drv->psr_list_lock);
>>
>> return 0;
>> +
>> + err1:
>> + kfree(psr->input_handler.name);
>> + err2:
>> + kfree(psr);
>> + return error;
>> }
>> EXPORT_SYMBOL(rockchip_drm_psr_register);
>>
>> @@ -279,8 +410,11 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder)
>> mutex_lock(&drm_drv->psr_list_lock);
>> list_for_each_entry_safe(psr, n, &drm_drv->psr_list, list) {
>> if (psr->encoder == encoder) {
>> + input_unregister_handler(&psr->input_handler);
>> cancel_delayed_work_sync(&psr->flush_work);
>> + cancel_work_sync(&psr->disable_work);
>> list_del(&psr->list);
>> + kfree(psr->input_handler.name);
>> kfree(psr);
>> }
>> }
>
>
^ permalink raw reply
* Re: [PATCH v6 24/30] drm/rockchip: Disable PSR on input events
From: Andrzej Hajda @ 2018-04-20 13:47 UTC (permalink / raw)
To: Enric Balletbo i Serra, architt, inki.dae, thierry.reding, hjc,
seanpaul, airlied, tfiga, heiko
Cc: dri-devel, dianders, ykk, kernel, m.szyprowski, linux-samsung-soc,
jy0922.shim, rydberg, krzk, linux-rockchip, kgene, linux-input,
orjan.eide, wxt, jeffy.chen, linux-arm-kernel, mark.yao, wzz, hl,
jingoohan1, sw0312.kim, linux-kernel, kyungmin.park,
Laurent.pinchart, kuankuan.y, hshi, Kristian H. Kristensen
In-Reply-To: <20180405095000.9756-25-enric.balletbo@collabora.com>
Hi Enric,
On 05.04.2018 11:49, Enric Balletbo i Serra wrote:
> From: "Kristian H. Kristensen" <hoegsberg@google.com>
>
> To improve PSR exit latency, we speculatively start exiting when we
> receive input events. Occasionally, this may lead to false positives,
> but most of the time we get a head start on coming out of PSR. Depending
> on how userspace takes to produce a new frame in response to the event,
> this can completely hide the exit latency. In case of Chrome OS, we
> typically get the input notifier 50ms or more before the dirty_fb
> triggered exit.
This patch is quite controversial and require more attention/discussion
and probably changes.
The rest of the patches is OK, and all have r-b/t-b tags.
If you prefer I can merge all other patches, if you rebase patches 25-30
on top of patch 23, or I can only merge patches 01-23.
What do you prefer?
Regards
Andrzej
>
> Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>
> drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 134 ++++++++++++++++++++++++++++
> 1 file changed, 134 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
> index 9376f4396b6b..a107845ba97c 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
> @@ -12,6 +12,8 @@
> * GNU General Public License for more details.
> */
>
> +#include <linux/input.h>
> +
> #include <drm/drmP.h>
> #include <drm/drm_crtc_helper.h>
>
> @@ -35,6 +37,9 @@ struct psr_drv {
> enum psr_state state;
>
> struct delayed_work flush_work;
> + struct work_struct disable_work;
> +
> + struct input_handler input_handler;
>
> int (*set)(struct drm_encoder *encoder, bool enable);
> };
> @@ -133,6 +138,18 @@ static void psr_flush_handler(struct work_struct *work)
> mutex_unlock(&psr->lock);
> }
>
> +static void psr_disable_handler(struct work_struct *work)
> +{
> + struct psr_drv *psr = container_of(work, struct psr_drv, disable_work);
> +
> + /* If the state has changed since we initiated the flush, do nothing */
> + mutex_lock(&psr->lock);
> + if (psr->state == PSR_ENABLE)
> + psr_set_state_locked(psr, PSR_FLUSH);
> + mutex_unlock(&psr->lock);
> + mod_delayed_work(system_wq, &psr->flush_work, PSR_FLUSH_TIMEOUT_MS);
> +}
> +
> /**
> * rockchip_drm_psr_activate - activate PSR on the given pipe
> * @encoder: encoder to obtain the PSR encoder
> @@ -173,6 +190,7 @@ int rockchip_drm_psr_deactivate(struct drm_encoder *encoder)
> psr->active = false;
> mutex_unlock(&psr->lock);
> cancel_delayed_work_sync(&psr->flush_work);
> + cancel_work_sync(&psr->disable_work);
>
> return 0;
> }
> @@ -226,6 +244,95 @@ void rockchip_drm_psr_flush_all(struct drm_device *dev)
> }
> EXPORT_SYMBOL(rockchip_drm_psr_flush_all);
>
> +static void psr_input_event(struct input_handle *handle,
> + unsigned int type, unsigned int code,
> + int value)
> +{
> + struct psr_drv *psr = handle->handler->private;
> +
> + schedule_work(&psr->disable_work);
> +}
> +
> +static int psr_input_connect(struct input_handler *handler,
> + struct input_dev *dev,
> + const struct input_device_id *id)
> +{
> + struct input_handle *handle;
> + int error;
> +
> + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
> + if (!handle)
> + return -ENOMEM;
> +
> + handle->dev = dev;
> + handle->handler = handler;
> + handle->name = "rockchip-psr";
> +
> + error = input_register_handle(handle);
> + if (error)
> + goto err2;
> +
> + error = input_open_device(handle);
> + if (error)
> + goto err1;
> +
> + return 0;
> +
> +err1:
> + input_unregister_handle(handle);
> +err2:
> + kfree(handle);
> + return error;
> +}
> +
> +static void psr_input_disconnect(struct input_handle *handle)
> +{
> + input_close_device(handle);
> + input_unregister_handle(handle);
> + kfree(handle);
> +}
> +
> +/* Same device ids as cpu-boost */
> +static const struct input_device_id psr_ids[] = {
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
> + INPUT_DEVICE_ID_MATCH_ABSBIT,
> + .evbit = { BIT_MASK(EV_ABS) },
> + .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
> + BIT_MASK(ABS_MT_POSITION_X) |
> + BIT_MASK(ABS_MT_POSITION_Y) },
> + }, /* multi-touch touchscreen */
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
> + .evbit = { BIT_MASK(EV_ABS) },
> + .absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) }
> +
> + }, /* stylus or joystick device */
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
> + .evbit = { BIT_MASK(EV_KEY) },
> + .keybit = { [BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) },
> + }, /* pointer (e.g. trackpad, mouse) */
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
> + .evbit = { BIT_MASK(EV_KEY) },
> + .keybit = { [BIT_WORD(KEY_ESC)] = BIT_MASK(KEY_ESC) },
> + }, /* keyboard */
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
> + INPUT_DEVICE_ID_MATCH_KEYBIT,
> + .evbit = { BIT_MASK(EV_KEY) },
> + .keybit = {[BIT_WORD(BTN_JOYSTICK)] = BIT_MASK(BTN_JOYSTICK) },
> + }, /* joysticks not caught by ABS_X above */
> + {
> + .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
> + INPUT_DEVICE_ID_MATCH_KEYBIT,
> + .evbit = { BIT_MASK(EV_KEY) },
> + .keybit = { [BIT_WORD(BTN_GAMEPAD)] = BIT_MASK(BTN_GAMEPAD) },
> + }, /* gamepad */
> + { },
> +};
> +
> /**
> * rockchip_drm_psr_register - register encoder to psr driver
> * @encoder: encoder that obtain the PSR function
> @@ -239,6 +346,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
> {
> struct rockchip_drm_private *drm_drv = encoder->dev->dev_private;
> struct psr_drv *psr;
> + int error;
>
> if (!encoder || !psr_set)
> return -EINVAL;
> @@ -248,6 +356,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
> return -ENOMEM;
>
> INIT_DELAYED_WORK(&psr->flush_work, psr_flush_handler);
> + INIT_WORK(&psr->disable_work, psr_disable_handler);
> mutex_init(&psr->lock);
>
> psr->active = true;
> @@ -255,11 +364,33 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder,
> psr->encoder = encoder;
> psr->set = psr_set;
>
> + psr->input_handler.event = psr_input_event;
> + psr->input_handler.connect = psr_input_connect;
> + psr->input_handler.disconnect = psr_input_disconnect;
> + psr->input_handler.name =
> + kasprintf(GFP_KERNEL, "rockchip-psr-%s", encoder->name);
> + if (!psr->input_handler.name) {
> + error = -ENOMEM;
> + goto err2;
> + }
> + psr->input_handler.id_table = psr_ids;
> + psr->input_handler.private = psr;
> +
> + error = input_register_handler(&psr->input_handler);
> + if (error)
> + goto err1;
> +
> mutex_lock(&drm_drv->psr_list_lock);
> list_add_tail(&psr->list, &drm_drv->psr_list);
> mutex_unlock(&drm_drv->psr_list_lock);
>
> return 0;
> +
> + err1:
> + kfree(psr->input_handler.name);
> + err2:
> + kfree(psr);
> + return error;
> }
> EXPORT_SYMBOL(rockchip_drm_psr_register);
>
> @@ -279,8 +410,11 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder)
> mutex_lock(&drm_drv->psr_list_lock);
> list_for_each_entry_safe(psr, n, &drm_drv->psr_list, list) {
> if (psr->encoder == encoder) {
> + input_unregister_handler(&psr->input_handler);
> cancel_delayed_work_sync(&psr->flush_work);
> + cancel_work_sync(&psr->disable_work);
> list_del(&psr->list);
> + kfree(psr->input_handler.name);
> kfree(psr);
> }
> }
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Rakesh Iyer can't be reached anymore
From: Jon Hunter @ 2018-04-20 7:03 UTC (permalink / raw)
To: Wolfram Sang, linux-kernel
Cc: Laxman Dewangan, Dmitry Torokhov, Thierry Reding, linux-input,
linux-tegra
In-Reply-To: <20180419174211.2532-1-wsa@the-dreams.de>
On 19/04/18 18:42, Wolfram Sang wrote:
> The current mail address is rejected, last activity (with a different
> address) in git-history is from 2012. Remove this.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>
> If somebody knows a recent address, then we can simply update, of course.
>
> MAINTAINERS | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index c4b6d379423e..0307426c2564 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13833,7 +13833,6 @@ S: Supported
> F: drivers/iommu/tegra*
>
> TEGRA KBC DRIVER
> -M: Rakesh Iyer <riyer@nvidia.com>
> M: Laxman Dewangan <ldewangan@nvidia.com>
> S: Supported
> F: drivers/input/keyboard/tegra-kbc.c
>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Cheers!
Jon
^ permalink raw reply
* [PATCH] Input: touchscreen: Fix a typo in Kconfig
From: Masanari Iida @ 2018-04-19 18:45 UTC (permalink / raw)
To: linux-kernel, dmitry.torokhov, trivial, linux-input; +Cc: Masanari Iida
This patch fix a spelling typo found in Kconfig.
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
---
drivers/input/touchscreen/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 4f15496fec8b..3e613afa10b4 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -362,7 +362,7 @@ config TOUCHSCREEN_HIDEEP
If unsure, say N.
- To compile this driver as a moudle, choose M here : the
+ To compile this driver as a module, choose M here : the
module will be called hideep_ts.
config TOUCHSCREEN_ILI210X
--
2.17.0.140.g0b0cc9f86731
^ permalink raw reply related
* [PATCH] MAINTAINERS: Rakesh Iyer can't be reached anymore
From: Wolfram Sang @ 2018-04-19 17:42 UTC (permalink / raw)
To: linux-kernel
Cc: Wolfram Sang, Laxman Dewangan, Dmitry Torokhov, Thierry Reding,
Jonathan Hunter, linux-input, linux-tegra
The current mail address is rejected, last activity (with a different
address) in git-history is from 2012. Remove this.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
If somebody knows a recent address, then we can simply update, of course.
MAINTAINERS | 1 -
1 file changed, 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index c4b6d379423e..0307426c2564 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13833,7 +13833,6 @@ S: Supported
F: drivers/iommu/tegra*
TEGRA KBC DRIVER
-M: Rakesh Iyer <riyer@nvidia.com>
M: Laxman Dewangan <ldewangan@nvidia.com>
S: Supported
F: drivers/input/keyboard/tegra-kbc.c
--
2.11.0
^ permalink raw reply related
* [PATCH 23/61] input: touchscreen: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Dmitry Torokhov,
linux-input
In-Reply-To: <20180419140641.27926-1-wsa+renesas@sang-engineering.com>
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. buildbot is happy. Please apply individually.
drivers/input/touchscreen/imx6ul_tsc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index ee82a975bfd2..da9e0a774e4b 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -515,8 +515,7 @@ static int imx6ul_tsc_probe(struct platform_device *pdev)
static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
+ struct imx6ul_tsc *tsc = dev_get_drvdata(dev);
struct input_dev *input_dev = tsc->input;
mutex_lock(&input_dev->mutex);
@@ -535,8 +534,7 @@ static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
+ struct imx6ul_tsc *tsc = dev_get_drvdata(dev);
struct input_dev *input_dev = tsc->input;
int retval = 0;
--
2.11.0
^ permalink raw reply related
* [PATCH 22/61] input: mouse: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Dmitry Torokhov,
linux-input
In-Reply-To: <20180419140641.27926-1-wsa+renesas@sang-engineering.com>
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. buildbot is happy. Please apply individually.
drivers/input/mouse/navpoint.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/input/mouse/navpoint.c b/drivers/input/mouse/navpoint.c
index d6e8f58a1de3..3d83a79e14d9 100644
--- a/drivers/input/mouse/navpoint.c
+++ b/drivers/input/mouse/navpoint.c
@@ -320,8 +320,7 @@ static int navpoint_remove(struct platform_device *pdev)
static int __maybe_unused navpoint_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct navpoint *navpoint = platform_get_drvdata(pdev);
+ struct navpoint *navpoint = dev_get_drvdata(dev);
struct input_dev *input = navpoint->input;
mutex_lock(&input->mutex);
@@ -334,8 +333,7 @@ static int __maybe_unused navpoint_suspend(struct device *dev)
static int __maybe_unused navpoint_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct navpoint *navpoint = platform_get_drvdata(pdev);
+ struct navpoint *navpoint = dev_get_drvdata(dev);
struct input_dev *input = navpoint->input;
mutex_lock(&input->mutex);
--
2.11.0
^ permalink raw reply related
* [PATCH 21/61] input: misc: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Dmitry Torokhov,
linux-input
In-Reply-To: <20180419140641.27926-1-wsa+renesas@sang-engineering.com>
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. buildbot is happy. Please apply individually.
drivers/input/misc/max77693-haptic.c | 6 ++----
drivers/input/misc/max8997_haptic.c | 3 +--
drivers/input/misc/palmas-pwrbutton.c | 6 ++----
drivers/input/misc/regulator-haptic.c | 6 ++----
drivers/input/misc/twl4030-vibra.c | 3 +--
drivers/input/misc/twl6040-vibra.c | 3 +--
6 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 46b0f48fbf49..8968fd48e95c 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -381,8 +381,7 @@ static int max77693_haptic_probe(struct platform_device *pdev)
static int __maybe_unused max77693_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max77693_haptic *haptic = platform_get_drvdata(pdev);
+ struct max77693_haptic *haptic = dev_get_drvdata(dev);
if (haptic->enabled) {
max77693_haptic_disable(haptic);
@@ -394,8 +393,7 @@ static int __maybe_unused max77693_haptic_suspend(struct device *dev)
static int __maybe_unused max77693_haptic_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max77693_haptic *haptic = platform_get_drvdata(pdev);
+ struct max77693_haptic *haptic = dev_get_drvdata(dev);
if (haptic->suspend_state) {
max77693_haptic_enable(haptic);
diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index 99bc762881d5..5ffb0ac68d50 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -388,8 +388,7 @@ static int max8997_haptic_remove(struct platform_device *pdev)
static int __maybe_unused max8997_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max8997_haptic *chip = platform_get_drvdata(pdev);
+ struct max8997_haptic *chip = dev_get_drvdata(dev);
max8997_haptic_disable(chip);
diff --git a/drivers/input/misc/palmas-pwrbutton.c b/drivers/input/misc/palmas-pwrbutton.c
index 1e1baed63929..27617868b292 100644
--- a/drivers/input/misc/palmas-pwrbutton.c
+++ b/drivers/input/misc/palmas-pwrbutton.c
@@ -270,8 +270,7 @@ static int palmas_pwron_remove(struct platform_device *pdev)
*/
static int __maybe_unused palmas_pwron_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+ struct palmas_pwron *pwron = dev_get_drvdata(dev);
cancel_delayed_work_sync(&pwron->input_work);
@@ -291,8 +290,7 @@ static int __maybe_unused palmas_pwron_suspend(struct device *dev)
*/
static int __maybe_unused palmas_pwron_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+ struct palmas_pwron *pwron = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
disable_irq_wake(pwron->irq);
diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c
index a1db1e5040dc..0b78a87f3192 100644
--- a/drivers/input/misc/regulator-haptic.c
+++ b/drivers/input/misc/regulator-haptic.c
@@ -206,8 +206,7 @@ static int regulator_haptic_probe(struct platform_device *pdev)
static int __maybe_unused regulator_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct regulator_haptic *haptic = platform_get_drvdata(pdev);
+ struct regulator_haptic *haptic = dev_get_drvdata(dev);
int error;
error = mutex_lock_interruptible(&haptic->mutex);
@@ -225,8 +224,7 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev)
static int __maybe_unused regulator_haptic_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct regulator_haptic *haptic = platform_get_drvdata(pdev);
+ struct regulator_haptic *haptic = dev_get_drvdata(dev);
unsigned int magnitude;
mutex_lock(&haptic->mutex);
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index c37aea9ac272..7b9104c058ca 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -159,8 +159,7 @@ static void twl4030_vibra_close(struct input_dev *input)
/*** Module ***/
static int __maybe_unused twl4030_vibra_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct vibra_info *info = platform_get_drvdata(pdev);
+ struct vibra_info *info = dev_get_drvdata(dev);
if (info->enabled)
vibra_disable(info);
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 15e0d352c4cc..c8539a4a98c6 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -226,8 +226,7 @@ static void twl6040_vibra_close(struct input_dev *input)
static int __maybe_unused twl6040_vibra_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct vibra_info *info = platform_get_drvdata(pdev);
+ struct vibra_info *info = dev_get_drvdata(dev);
cancel_work_sync(&info->play_work);
--
2.11.0
^ permalink raw reply related
* [PATCH 20/61] input: keyboard: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Dmitry Torokhov,
Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
linux-tegra
In-Reply-To: <20180419140641.27926-1-wsa+renesas@sang-engineering.com>
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. buildbot is happy. Please apply individually.
drivers/input/keyboard/ep93xx_keypad.c | 10 ++++------
drivers/input/keyboard/imx_keypad.c | 10 ++++------
drivers/input/keyboard/lpc32xx-keys.c | 6 ++----
drivers/input/keyboard/matrix_keypad.c | 10 ++++------
drivers/input/keyboard/omap4-keypad.c | 10 ++++------
drivers/input/keyboard/pmic8xxx-keypad.c | 6 ++----
drivers/input/keyboard/pxa27x_keypad.c | 10 ++++------
drivers/input/keyboard/samsung-keypad.c | 12 ++++--------
drivers/input/keyboard/snvs_pwrkey.c | 10 ++++------
drivers/input/keyboard/spear-keyboard.c | 10 ++++------
drivers/input/keyboard/st-keyscan.c | 6 ++----
drivers/input/keyboard/tegra-kbc.c | 10 ++++------
12 files changed, 42 insertions(+), 68 deletions(-)
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index f77b295e0123..7584a03db4b3 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -185,8 +185,7 @@ static void ep93xx_keypad_close(struct input_dev *pdev)
#ifdef CONFIG_PM_SLEEP
static int ep93xx_keypad_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
struct input_dev *input_dev = keypad->input_dev;
mutex_lock(&input_dev->mutex);
@@ -198,7 +197,7 @@ static int ep93xx_keypad_suspend(struct device *dev)
mutex_unlock(&input_dev->mutex);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
enable_irq_wake(keypad->irq);
return 0;
@@ -206,11 +205,10 @@ static int ep93xx_keypad_suspend(struct device *dev)
static int ep93xx_keypad_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
struct input_dev *input_dev = keypad->input_dev;
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
disable_irq_wake(keypad->irq);
mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 25d61d8d4fc4..56328ced81e2 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -532,8 +532,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
static int __maybe_unused imx_kbd_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx_keypad *kbd = platform_get_drvdata(pdev);
+ struct imx_keypad *kbd = dev_get_drvdata(dev);
struct input_dev *input_dev = kbd->input_dev;
/* imx kbd can wake up system even clock is disabled */
@@ -544,7 +543,7 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
mutex_unlock(&input_dev->mutex);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
enable_irq_wake(kbd->irq);
return 0;
@@ -552,12 +551,11 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
static int __maybe_unused imx_kbd_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx_keypad *kbd = platform_get_drvdata(pdev);
+ struct imx_keypad *kbd = dev_get_drvdata(dev);
struct input_dev *input_dev = kbd->input_dev;
int ret = 0;
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
disable_irq_wake(kbd->irq);
mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
index 1dd57ac0e7a2..0831a6f2a9d4 100644
--- a/drivers/input/keyboard/lpc32xx-keys.c
+++ b/drivers/input/keyboard/lpc32xx-keys.c
@@ -279,8 +279,7 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP
static int lpc32xx_kscan_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
+ struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
struct input_dev *input = kscandat->input;
mutex_lock(&input->mutex);
@@ -297,8 +296,7 @@ static int lpc32xx_kscan_suspend(struct device *dev)
static int lpc32xx_kscan_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
+ struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
struct input_dev *input = kscandat->input;
int retval = 0;
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 41614c185918..73ca55e4babe 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -276,12 +276,11 @@ static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad)
static int matrix_keypad_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct matrix_keypad *keypad = platform_get_drvdata(pdev);
+ struct matrix_keypad *keypad = dev_get_drvdata(dev);
matrix_keypad_stop(keypad->input_dev);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
matrix_keypad_enable_wakeup(keypad);
return 0;
@@ -289,10 +288,9 @@ static int matrix_keypad_suspend(struct device *dev)
static int matrix_keypad_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct matrix_keypad *keypad = platform_get_drvdata(pdev);
+ struct matrix_keypad *keypad = dev_get_drvdata(dev);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
matrix_keypad_disable_wakeup(keypad);
matrix_keypad_start(keypad->input_dev);
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 940d38b08e6b..13578b884ace 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -422,11 +422,10 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
#ifdef CONFIG_PM_SLEEP
static int omap4_keypad_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+ struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
int error;
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
error = enable_irq_wake(keypad_data->irq);
if (!error)
keypad_data->irq_wake_enabled = true;
@@ -437,10 +436,9 @@ static int omap4_keypad_suspend(struct device *dev)
static int omap4_keypad_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+ struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
- if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
+ if (device_may_wakeup(dev) && keypad_data->irq_wake_enabled) {
disable_irq_wake(keypad_data->irq);
keypad_data->irq_wake_enabled = false;
}
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 98b24ed18752..048a39321298 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -636,8 +636,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP
static int pmic8xxx_kp_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
+ struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
struct input_dev *input_dev = kp->input;
if (device_may_wakeup(dev)) {
@@ -656,8 +655,7 @@ static int pmic8xxx_kp_suspend(struct device *dev)
static int pmic8xxx_kp_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
+ struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
struct input_dev *input_dev = kp->input;
if (device_may_wakeup(dev)) {
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index d0bdaeadf86d..1f54a3162124 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -666,14 +666,13 @@ static void pxa27x_keypad_close(struct input_dev *dev)
#ifdef CONFIG_PM_SLEEP
static int pxa27x_keypad_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
+ struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
/*
* If the keypad is used a wake up source, clock can not be disabled.
* Or it can not detect the key pressing.
*/
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
enable_irq_wake(keypad->irq);
else
clk_disable_unprepare(keypad->clk);
@@ -683,8 +682,7 @@ static int pxa27x_keypad_suspend(struct device *dev)
static int pxa27x_keypad_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
+ struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
struct input_dev *input_dev = keypad->input_dev;
int ret = 0;
@@ -692,7 +690,7 @@ static int pxa27x_keypad_resume(struct device *dev)
* If the keypad is used as wake up source, the clock is not turned
* off. So do not need configure it again.
*/
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
disable_irq_wake(keypad->irq);
} else {
mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 316414465c77..27790a8a44f5 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -466,8 +466,7 @@ static int samsung_keypad_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
static int samsung_keypad_runtime_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+ struct samsung_keypad *keypad = dev_get_drvdata(dev);
unsigned int val;
int error;
@@ -490,8 +489,7 @@ static int samsung_keypad_runtime_suspend(struct device *dev)
static int samsung_keypad_runtime_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+ struct samsung_keypad *keypad = dev_get_drvdata(dev);
unsigned int val;
if (keypad->stopped)
@@ -535,8 +533,7 @@ static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
static int samsung_keypad_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+ struct samsung_keypad *keypad = dev_get_drvdata(dev);
struct input_dev *input_dev = keypad->input_dev;
mutex_lock(&input_dev->mutex);
@@ -553,8 +550,7 @@ static int samsung_keypad_suspend(struct device *dev)
static int samsung_keypad_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+ struct samsung_keypad *keypad = dev_get_drvdata(dev);
struct input_dev *input_dev = keypad->input_dev;
mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 53c768b95939..f439f7bd2f5f 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -180,10 +180,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+ struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
enable_irq_wake(pdata->irq);
return 0;
@@ -191,10 +190,9 @@ static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+ struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
- if (device_may_wakeup(&pdev->dev))
+ if (device_may_wakeup(dev))
disable_irq_wake(pdata->irq);
return 0;
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 7d25fa338ab4..a0276a3376d2 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -288,8 +288,7 @@ static int spear_kbd_remove(struct platform_device *pdev)
static int __maybe_unused spear_kbd_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct spear_kbd *kbd = platform_get_drvdata(pdev);
+ struct spear_kbd *kbd = dev_get_drvdata(dev);
struct input_dev *input_dev = kbd->input;
unsigned int rate = 0, mode_ctl_reg, val;
@@ -300,7 +299,7 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG);
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
if (!enable_irq_wake(kbd->irq))
kbd->irq_wake_enabled = true;
@@ -341,13 +340,12 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
static int __maybe_unused spear_kbd_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct spear_kbd *kbd = platform_get_drvdata(pdev);
+ struct spear_kbd *kbd = dev_get_drvdata(dev);
struct input_dev *input_dev = kbd->input;
mutex_lock(&input_dev->mutex);
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
if (kbd->irq_wake_enabled) {
kbd->irq_wake_enabled = false;
disable_irq_wake(kbd->irq);
diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c
index babcfb165e4f..3b4727e4b411 100644
--- a/drivers/input/keyboard/st-keyscan.c
+++ b/drivers/input/keyboard/st-keyscan.c
@@ -218,8 +218,7 @@ static int keyscan_probe(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP
static int keyscan_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct st_keyscan *keypad = platform_get_drvdata(pdev);
+ struct st_keyscan *keypad = dev_get_drvdata(dev);
struct input_dev *input = keypad->input_dev;
mutex_lock(&input->mutex);
@@ -235,8 +234,7 @@ static int keyscan_suspend(struct device *dev)
static int keyscan_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct st_keyscan *keypad = platform_get_drvdata(pdev);
+ struct st_keyscan *keypad = dev_get_drvdata(dev);
struct input_dev *input = keypad->input_dev;
int retval = 0;
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 875205f445b5..861bfcbd817d 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -744,11 +744,10 @@ static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable)
static int tegra_kbc_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct tegra_kbc *kbc = platform_get_drvdata(pdev);
+ struct tegra_kbc *kbc = dev_get_drvdata(dev);
mutex_lock(&kbc->idev->mutex);
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
disable_irq(kbc->irq);
del_timer_sync(&kbc->timer);
tegra_kbc_set_fifo_interrupt(kbc, false);
@@ -781,12 +780,11 @@ static int tegra_kbc_suspend(struct device *dev)
static int tegra_kbc_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct tegra_kbc *kbc = platform_get_drvdata(pdev);
+ struct tegra_kbc *kbc = dev_get_drvdata(dev);
int err = 0;
mutex_lock(&kbc->idev->mutex);
- if (device_may_wakeup(&pdev->dev)) {
+ if (device_may_wakeup(dev)) {
disable_irq_wake(kbc->irq);
tegra_kbc_setup_wakekeys(kbc, false);
/* We will use fifo interrupts for key detection. */
--
2.11.0
^ permalink raw reply related
* [PATCH 17/61] hid: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Jiri Kosina,
Jonathan Cameron, Srinivas Pandruvada, Benjamin Tissoires,
linux-input, linux-iio
In-Reply-To: <20180419140641.27926-1-wsa+renesas@sang-engineering.com>
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Build tested only. buildbot is happy. Please apply individually.
drivers/hid/hid-sensor-custom.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index e8a114157f87..cd0c2a7c8003 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -157,8 +157,7 @@ static int usage_id_cmp(const void *p1, const void *p2)
static ssize_t enable_sensor_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", sensor_inst->enable);
}
@@ -237,8 +236,7 @@ static ssize_t enable_sensor_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
int value;
int ret = -EINVAL;
@@ -283,8 +281,7 @@ static const struct attribute_group enable_sensor_attr_group = {
static ssize_t show_value(struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
struct hid_sensor_hub_attribute_info *attribute;
int index, usage, field_index;
char name[HID_CUSTOM_NAME_LENGTH];
@@ -392,8 +389,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
static ssize_t store_value(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
int index, field_index, usage;
char name[HID_CUSTOM_NAME_LENGTH];
int value;
--
2.11.0
^ permalink raw reply related
* [PATCH 00/61] tree-wide: simplify getting .drvdata
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
To: linux-kernel
Cc: linux-ide, alsa-devel, linux-iio, kernel-janitors, linux-fbdev,
dri-devel, platform-driver-x86, Wolfram Sang, linux-mtd,
linux-clk, ac100, devel, linux-samsung-soc, linux-rockchip,
linux-serial, linux-input, linux-media, linux-pwm, linux-watchdog,
linux-pm, linux-arm-msm, acpi4asus-user, greybus-dev,
linux-mediatek, linux-tegra, linux-omap, linux-soc,
linux-arm-kernel
I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:
- struct platform_device *pdev = to_platform_device(dev);
- struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.
A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata
Open for other comments, suggestions, too, of course.
Here is the cocci-script I created (after <n> iterations by manually checking
samples):
@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
- struct platform_device *pdev = to_platform_device(d);
|
- struct platform_device *pdev;
...
- pdev = to_platform_device(d);
)
<... when != pdev
- &pdev->dev
+ d
...>
ptr =
- platform_get_drvdata(pdev)
+ dev_get_drvdata(d)
<... when != pdev
- &pdev->dev
+ d
...>
Kind regards,
Wolfram
Wolfram Sang (61):
ARM: plat-samsung: simplify getting .drvdata
ata: simplify getting .drvdata
auxdisplay: simplify getting .drvdata
bus: simplify getting .drvdata
clk: samsung: simplify getting .drvdata
crypto: simplify getting .drvdata
dma: simplify getting .drvdata
dmaengine: dw: simplify getting .drvdata
dmaengine: qcom: simplify getting .drvdata
gpio: simplify getting .drvdata
gpu: drm: msm: simplify getting .drvdata
gpu: drm: msm: adreno: simplify getting .drvdata
gpu: drm: msm: disp: mdp5: simplify getting .drvdata
gpu: drm: msm: dsi: simplify getting .drvdata
gpu: drm: omapdrm: displays: simplify getting .drvdata
gpu: drm: vc4: simplify getting .drvdata
hid: simplify getting .drvdata
iio: common: cros_ec_sensors: simplify getting .drvdata
iio: common: hid-sensors: simplify getting .drvdata
input: keyboard: simplify getting .drvdata
input: misc: simplify getting .drvdata
input: mouse: simplify getting .drvdata
input: touchscreen: simplify getting .drvdata
iommu: simplify getting .drvdata
media: platform: am437x: simplify getting .drvdata
media: platform: exynos4-is: simplify getting .drvdata
media: platform: s5p-mfc: simplify getting .drvdata
mmc: host: simplify getting .drvdata
mtd: devices: simplify getting .drvdata
mtd: nand: onenand: simplify getting .drvdata
net: dsa: simplify getting .drvdata
net: ethernet: cadence: simplify getting .drvdata
net: ethernet: davicom: simplify getting .drvdata
net: ethernet: smsc: simplify getting .drvdata
net: ethernet: ti: simplify getting .drvdata
net: ethernet: wiznet: simplify getting .drvdata
perf: simplify getting .drvdata
pinctrl: simplify getting .drvdata
pinctrl: intel: simplify getting .drvdata
platform: x86: simplify getting .drvdata
power: supply: simplify getting .drvdata
ptp: simplify getting .drvdata
pwm: simplify getting .drvdata
rtc: simplify getting .drvdata
slimbus: simplify getting .drvdata
spi: simplify getting .drvdata
staging: greybus: simplify getting .drvdata
staging: iio: adc: simplify getting .drvdata
staging: nvec: simplify getting .drvdata
thermal: simplify getting .drvdata
thermal: int340x_thermal: simplify getting .drvdata
thermal: st: simplify getting .drvdata
tty: serial: simplify getting .drvdata
uio: simplify getting .drvdata
usb: mtu3: simplify getting .drvdata
usb: phy: simplify getting .drvdata
video: fbdev: simplify getting .drvdata
video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
watchdog: simplify getting .drvdata
net: dsa: simplify getting .drvdata
ASoC: atmel: simplify getting .drvdata
arch/arm/plat-samsung/adc.c | 3 +-
drivers/ata/pata_samsung_cf.c | 8 ++---
drivers/auxdisplay/arm-charlcd.c | 6 ++--
drivers/bus/brcmstb_gisb.c | 12 +++----
drivers/clk/samsung/clk-s3c2410-dclk.c | 6 ++--
drivers/crypto/exynos-rng.c | 6 ++--
drivers/crypto/picoxcell_crypto.c | 6 ++--
drivers/dma/at_hdmac.c | 9 ++---
drivers/dma/at_xdmac.c | 9 ++---
drivers/dma/dw/platform.c | 6 ++--
drivers/dma/fsldma.c | 6 ++--
drivers/dma/idma64.c | 6 ++--
drivers/dma/qcom/hidma.c | 3 +-
drivers/dma/qcom/hidma_mgmt_sys.c | 6 ++--
drivers/dma/ste_dma40.c | 12 +++----
drivers/dma/txx9dmac.c | 8 ++---
drivers/gpio/gpio-dwapb.c | 6 ++--
drivers/gpio/gpio-lynxpoint.c | 3 +-
drivers/gpio/gpio-omap.c | 12 +++----
drivers/gpio/gpio-tegra.c | 6 ++--
drivers/gpio/gpio-zynq.c | 6 ++--
drivers/gpu/drm/msm/adreno/adreno_device.c | 6 ++--
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 6 ++--
drivers/gpu/drm/msm/dsi/dsi_host.c | 6 ++--
drivers/gpu/drm/msm/msm_drv.c | 3 +-
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 18 ++++------
drivers/gpu/drm/vc4/vc4_drv.c | 3 +-
drivers/hid/hid-sensor-custom.c | 12 +++----
.../common/cros_ec_sensors/cros_ec_sensors_core.c | 6 ++--
.../iio/common/hid-sensors/hid-sensor-trigger.c | 9 ++---
drivers/input/keyboard/ep93xx_keypad.c | 10 +++---
drivers/input/keyboard/imx_keypad.c | 10 +++---
drivers/input/keyboard/lpc32xx-keys.c | 6 ++--
drivers/input/keyboard/matrix_keypad.c | 10 +++---
drivers/input/keyboard/omap4-keypad.c | 10 +++---
drivers/input/keyboard/pmic8xxx-keypad.c | 6 ++--
drivers/input/keyboard/pxa27x_keypad.c | 10 +++---
drivers/input/keyboard/samsung-keypad.c | 12 +++----
drivers/input/keyboard/snvs_pwrkey.c | 10 +++---
drivers/input/keyboard/spear-keyboard.c | 10 +++---
drivers/input/keyboard/st-keyscan.c | 6 ++--
drivers/input/keyboard/tegra-kbc.c | 10 +++---
drivers/input/misc/max77693-haptic.c | 6 ++--
drivers/input/misc/max8997_haptic.c | 3 +-
drivers/input/misc/palmas-pwrbutton.c | 6 ++--
drivers/input/misc/regulator-haptic.c | 6 ++--
drivers/input/misc/twl4030-vibra.c | 3 +-
drivers/input/misc/twl6040-vibra.c | 3 +-
drivers/input/mouse/navpoint.c | 6 ++--
drivers/input/touchscreen/imx6ul_tsc.c | 6 ++--
drivers/iommu/qcom_iommu.c | 6 ++--
drivers/media/platform/am437x/am437x-vpfe.c | 6 ++--
drivers/media/platform/exynos4-is/media-dev.c | 6 ++--
drivers/media/platform/exynos4-is/mipi-csis.c | 6 ++--
drivers/media/platform/s5p-mfc/s5p_mfc.c | 6 ++--
drivers/mmc/host/davinci_mmc.c | 6 ++--
drivers/mmc/host/sdhci-of-arasan.c | 6 ++--
drivers/mmc/host/wmt-sdmmc.c | 6 ++--
drivers/mtd/devices/docg3.c | 3 +-
drivers/mtd/nand/onenand/samsung.c | 6 ++--
drivers/net/dsa/bcm_sf2.c | 6 ++--
drivers/net/dsa/qca8k.c | 6 ++--
drivers/net/ethernet/cadence/macb_main.c | 6 ++--
drivers/net/ethernet/davicom/dm9000.c | 6 ++--
drivers/net/ethernet/smsc/smc91x.c | 3 +-
drivers/net/ethernet/ti/cpsw.c | 6 ++--
drivers/net/ethernet/ti/davinci_emac.c | 6 ++--
drivers/net/ethernet/wiznet/w5300.c | 6 ++--
drivers/perf/arm_spe_pmu.c | 6 ++--
drivers/pinctrl/intel/pinctrl-baytrail.c | 6 ++--
drivers/pinctrl/intel/pinctrl-cherryview.c | 6 ++--
drivers/pinctrl/intel/pinctrl-intel.c | 6 ++--
drivers/pinctrl/pinctrl-amd.c | 6 ++--
drivers/pinctrl/pinctrl-at91-pio4.c | 6 ++--
drivers/platform/x86/asus-laptop.c | 3 +-
drivers/platform/x86/asus-wmi.c | 3 +-
drivers/platform/x86/samsung-laptop.c | 3 +-
drivers/power/supply/gpio-charger.c | 3 +-
drivers/ptp/ptp_dte.c | 6 ++--
drivers/pwm/pwm-atmel-tcb.c | 6 ++--
drivers/pwm/pwm-rcar.c | 3 +-
drivers/rtc/rtc-bq4802.c | 6 ++--
drivers/rtc/rtc-ds1216.c | 6 ++--
drivers/rtc/rtc-ds1511.c | 9 ++---
drivers/rtc/rtc-ds1553.c | 15 +++-----
drivers/rtc/rtc-ds1685.c | 21 ++++-------
drivers/rtc/rtc-ds1742.c | 6 ++--
drivers/rtc/rtc-lpc32xx.c | 16 ++++-----
drivers/rtc/rtc-m48t59.c | 41 +++++++++-------------
drivers/rtc/rtc-mv.c | 3 +-
drivers/rtc/rtc-mxc.c | 21 ++++-------
drivers/rtc/rtc-pcap.c | 15 +++-----
drivers/rtc/rtc-sh.c | 15 +++-----
drivers/rtc/rtc-stk17ta8.c | 15 +++-----
drivers/rtc/rtc-test.c | 3 +-
drivers/rtc/rtc-zynqmp.c | 10 +++---
drivers/slimbus/qcom-ctrl.c | 6 ++--
drivers/spi/spi-cadence.c | 6 ++--
drivers/spi/spi-zynqmp-gqspi.c | 6 ++--
drivers/staging/greybus/arche-platform.c | 3 +-
drivers/staging/iio/adc/ad7606_par.c | 6 ++--
drivers/staging/nvec/nvec.c | 6 ++--
drivers/thermal/int340x_thermal/int3400_thermal.c | 9 ++---
drivers/thermal/rockchip_thermal.c | 8 ++---
drivers/thermal/spear_thermal.c | 8 ++---
drivers/thermal/st/st_thermal.c | 6 ++--
drivers/thermal/zx2967_thermal.c | 6 ++--
drivers/tty/serial/imx.c | 18 ++++------
drivers/tty/serial/qcom_geni_serial.c | 6 ++--
drivers/tty/serial/st-asc.c | 6 ++--
drivers/tty/serial/xilinx_uartps.c | 6 ++--
drivers/uio/uio_fsl_elbc_gpcm.c | 6 ++--
drivers/usb/mtu3/mtu3_plat.c | 6 ++--
drivers/usb/phy/phy-am335x.c | 6 ++--
drivers/video/fbdev/auo_k190x.c | 12 +++----
.../fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 18 ++++------
drivers/video/fbdev/sh_mobile_lcdcfb.c | 6 ++--
drivers/video/fbdev/sh_mobile_meram.c | 6 ++--
drivers/watchdog/cadence_wdt.c | 6 ++--
drivers/watchdog/of_xilinx_wdt.c | 6 ++--
drivers/watchdog/wdat_wdt.c | 6 ++--
net/dsa/legacy.c | 6 ++--
sound/soc/atmel/atmel_ssc_dai.c | 6 ++--
123 files changed, 319 insertions(+), 607 deletions(-)
--
2.11.0
^ permalink raw reply
* [PATCH v2] Input: xen-kbdfront - allow better run-time configuration
From: Oleksandr Andrushchenko @ 2018-04-19 13:39 UTC (permalink / raw)
To: xen-devel, linux-input, linux-kernel, dmitry.torokhov, jgross,
lyan, boris.ostrovsky
Cc: andr2000, andrii_chepurnyi, Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
It is now only possible to control if multi-touch virtual device
is created or not (via the corresponding XenStore entries),
but keyboard and pointer devices are always created.
In some cases this is not desirable. For example, if virtual
keyboard device is exposed to Android then the latter won't
automatically show on-screen keyboard as it expects that a
physical keyboard device can be used for typing.
Make it possible to configure which virtual devices are created
with module parameters:
- provide no_ptr_dev if no pointer device needs to be created
- provide no_kbd_dev if no keyboard device needs to be created
Keep old behavior by default.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Suggested-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Tested-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
---
Changes since v1:
- changed module parameters from uint to bool
drivers/input/misc/xen-kbdfront.c | 159 +++++++++++++++++-------------
1 file changed, 92 insertions(+), 67 deletions(-)
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index d91f3b1c5375..d8cca212f737 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -51,6 +51,16 @@ module_param_array(ptr_size, int, NULL, 0444);
MODULE_PARM_DESC(ptr_size,
"Pointing device width, height in pixels (default 800,600)");
+static bool no_ptr_dev;
+module_param(no_ptr_dev, bool, 0);
+MODULE_PARM_DESC(no_ptr_dev,
+ "If set then no virtual pointing device exposed to the guest");
+
+static bool no_kbd_dev;
+module_param(no_kbd_dev, bool, 0);
+MODULE_PARM_DESC(no_kbd_dev,
+ "If set then no virtual keyboard device exposed to the guest");
+
static int xenkbd_remove(struct xenbus_device *);
static int xenkbd_connect_backend(struct xenbus_device *, struct xenkbd_info *);
static void xenkbd_disconnect_backend(struct xenkbd_info *);
@@ -63,6 +73,9 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *);
static void xenkbd_handle_motion_event(struct xenkbd_info *info,
struct xenkbd_motion *motion)
{
+ if (unlikely(!info->ptr))
+ return;
+
input_report_rel(info->ptr, REL_X, motion->rel_x);
input_report_rel(info->ptr, REL_Y, motion->rel_y);
if (motion->rel_z)
@@ -73,6 +86,9 @@ static void xenkbd_handle_motion_event(struct xenkbd_info *info,
static void xenkbd_handle_position_event(struct xenkbd_info *info,
struct xenkbd_position *pos)
{
+ if (unlikely(!info->ptr))
+ return;
+
input_report_abs(info->ptr, ABS_X, pos->abs_x);
input_report_abs(info->ptr, ABS_Y, pos->abs_y);
if (pos->rel_z)
@@ -97,6 +113,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
return;
}
+ if (unlikely(!dev))
+ return;
+
input_event(dev, EV_KEY, key->keycode, value);
input_sync(dev);
}
@@ -192,7 +211,7 @@ static int xenkbd_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
int ret, i;
- unsigned int abs, touch;
+ unsigned int touch;
struct xenkbd_info *info;
struct input_dev *kbd, *ptr, *mtouch;
@@ -211,24 +230,6 @@ static int xenkbd_probe(struct xenbus_device *dev,
if (!info->page)
goto error_nomem;
- /* Set input abs params to match backend screen res */
- abs = xenbus_read_unsigned(dev->otherend,
- XENKBD_FIELD_FEAT_ABS_POINTER, 0);
- ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend,
- XENKBD_FIELD_WIDTH,
- ptr_size[KPARAM_X]);
- ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend,
- XENKBD_FIELD_HEIGHT,
- ptr_size[KPARAM_Y]);
- if (abs) {
- ret = xenbus_write(XBT_NIL, dev->nodename,
- XENKBD_FIELD_REQ_ABS_POINTER, "1");
- if (ret) {
- pr_warn("xenkbd: can't request abs-pointer\n");
- abs = 0;
- }
- }
-
touch = xenbus_read_unsigned(dev->nodename,
XENKBD_FIELD_FEAT_MTOUCH, 0);
if (touch) {
@@ -241,60 +242,84 @@ static int xenkbd_probe(struct xenbus_device *dev,
}
/* keyboard */
- kbd = input_allocate_device();
- if (!kbd)
- goto error_nomem;
- kbd->name = "Xen Virtual Keyboard";
- kbd->phys = info->phys;
- kbd->id.bustype = BUS_PCI;
- kbd->id.vendor = 0x5853;
- kbd->id.product = 0xffff;
-
- __set_bit(EV_KEY, kbd->evbit);
- for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
- __set_bit(i, kbd->keybit);
- for (i = KEY_OK; i < KEY_MAX; i++)
- __set_bit(i, kbd->keybit);
-
- ret = input_register_device(kbd);
- if (ret) {
- input_free_device(kbd);
- xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
- goto error;
+ if (!no_kbd_dev) {
+ kbd = input_allocate_device();
+ if (!kbd)
+ goto error_nomem;
+ kbd->name = "Xen Virtual Keyboard";
+ kbd->phys = info->phys;
+ kbd->id.bustype = BUS_PCI;
+ kbd->id.vendor = 0x5853;
+ kbd->id.product = 0xffff;
+
+ __set_bit(EV_KEY, kbd->evbit);
+ for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
+ __set_bit(i, kbd->keybit);
+ for (i = KEY_OK; i < KEY_MAX; i++)
+ __set_bit(i, kbd->keybit);
+
+ ret = input_register_device(kbd);
+ if (ret) {
+ input_free_device(kbd);
+ xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
+ goto error;
+ }
+ info->kbd = kbd;
}
- info->kbd = kbd;
/* pointing device */
- ptr = input_allocate_device();
- if (!ptr)
- goto error_nomem;
- ptr->name = "Xen Virtual Pointer";
- ptr->phys = info->phys;
- ptr->id.bustype = BUS_PCI;
- ptr->id.vendor = 0x5853;
- ptr->id.product = 0xfffe;
-
- if (abs) {
- __set_bit(EV_ABS, ptr->evbit);
- input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0);
- input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0);
- } else {
- input_set_capability(ptr, EV_REL, REL_X);
- input_set_capability(ptr, EV_REL, REL_Y);
- }
- input_set_capability(ptr, EV_REL, REL_WHEEL);
+ if (!no_ptr_dev) {
+ unsigned int abs;
+
+ /* Set input abs params to match backend screen res */
+ abs = xenbus_read_unsigned(dev->otherend,
+ XENKBD_FIELD_FEAT_ABS_POINTER, 0);
+ ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend,
+ XENKBD_FIELD_WIDTH,
+ ptr_size[KPARAM_X]);
+ ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend,
+ XENKBD_FIELD_HEIGHT,
+ ptr_size[KPARAM_Y]);
+ if (abs) {
+ ret = xenbus_write(XBT_NIL, dev->nodename,
+ XENKBD_FIELD_REQ_ABS_POINTER, "1");
+ if (ret) {
+ pr_warn("xenkbd: can't request abs-pointer\n");
+ abs = 0;
+ }
+ }
- __set_bit(EV_KEY, ptr->evbit);
- for (i = BTN_LEFT; i <= BTN_TASK; i++)
- __set_bit(i, ptr->keybit);
+ ptr = input_allocate_device();
+ if (!ptr)
+ goto error_nomem;
+ ptr->name = "Xen Virtual Pointer";
+ ptr->phys = info->phys;
+ ptr->id.bustype = BUS_PCI;
+ ptr->id.vendor = 0x5853;
+ ptr->id.product = 0xfffe;
+
+ if (abs) {
+ __set_bit(EV_ABS, ptr->evbit);
+ input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0);
+ input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0);
+ } else {
+ input_set_capability(ptr, EV_REL, REL_X);
+ input_set_capability(ptr, EV_REL, REL_Y);
+ }
+ input_set_capability(ptr, EV_REL, REL_WHEEL);
- ret = input_register_device(ptr);
- if (ret) {
- input_free_device(ptr);
- xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
- goto error;
+ __set_bit(EV_KEY, ptr->evbit);
+ for (i = BTN_LEFT; i <= BTN_TASK; i++)
+ __set_bit(i, ptr->keybit);
+
+ ret = input_register_device(ptr);
+ if (ret) {
+ input_free_device(ptr);
+ xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+ goto error;
+ }
+ info->ptr = ptr;
}
- info->ptr = ptr;
/* multi-touch device */
if (touch) {
--
2.17.0
^ permalink raw reply related
* Re: [Xen-devel] [PATCH] Input: xen-kbdfront - allow better run-time configuration
From: Oleksandr Andrushchenko @ 2018-04-19 13:22 UTC (permalink / raw)
To: Juergen Gross, Jason Andryuk
Cc: xen-devel, linux-input, open list, dmitry.torokhov, lyan,
Boris Ostrovsky, andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <d4075815-2b41-781d-3541-6a17a181512d@suse.com>
On 04/19/2018 04:19 PM, Juergen Gross wrote:
> On 19/04/18 15:12, Oleksandr Andrushchenko wrote:
>> On 04/19/2018 04:10 PM, Jason Andryuk wrote:
>>> On Thu, Apr 19, 2018 at 9:01 AM, Oleksandr Andrushchenko
>>> <andr2000@gmail.com> wrote:
>>>> Ok, so I'll send v2 with the following changes:
>>>>
>>>> diff --git a/drivers/input/misc/xen-kbdfront.c
>>>> b/drivers/input/misc/xen-kbdfront.c
>>>> index a3306aad40b0..d8cca212f737 100644
>>>> --- a/drivers/input/misc/xen-kbdfront.c
>>>> +++ b/drivers/input/misc/xen-kbdfront.c
>>>> @@ -51,13 +51,13 @@ module_param_array(ptr_size, int, NULL, 0444);
>>>> MODULE_PARM_DESC(ptr_size,
>>>> "Pointing device width, height in pixels (default 800,600)");
>>>>
>>>> -static unsigned int no_ptr_dev;
>>>> -module_param(no_ptr_dev, uint, 0);
>>>> +static bool no_ptr_dev;
>>>> +module_param(no_ptr_dev, bool, 0);
>>>> MODULE_PARM_DESC(no_ptr_dev,
>>>> "If set then no virtual pointing device exposed to the guest");
>>>>
>>>> -static unsigned int no_kbd_dev;
>>>> -module_param(no_kbd_dev, uint, 0);
>>>> +static bool no_kbd_dev;
>>>> +module_param(no_kbd_dev, bool, 0);
>>>> MODULE_PARM_DESC(no_kbd_dev,
>>>> "If set then no virtual keyboard device exposed to the guest");
>>> I prefer direct logic over inverse logic. Maybe just use kbd_dev,
>>> default to true, but allow it to be set off?
>>>
>>> static bool kbd_dev = true;
>>> module_param(kbd_dev, bool, 0);
>> I have no preference here, either way works for me
>> Juergen, what do you think about the above?
> I really have no preference here. What should be taken into account is
> that boolean parameters don't need a value, meaning "true" in that case.
> This would make no sense for "kbd_dev" as it wouldn't change the
> default.
Then I'll go with the diff above, e.g. boolean no_{kbd|ptr})dev
> Juergen
^ permalink raw reply
* Re: [Xen-devel] [PATCH] Input: xen-kbdfront - allow better run-time configuration
From: Juergen Gross @ 2018-04-19 13:19 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Jason Andryuk
Cc: xen-devel, linux-input, open list, dmitry.torokhov, lyan,
Boris Ostrovsky, andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <5ed20b99-263d-d906-9349-d064eead36ad@gmail.com>
On 19/04/18 15:12, Oleksandr Andrushchenko wrote:
> On 04/19/2018 04:10 PM, Jason Andryuk wrote:
>> On Thu, Apr 19, 2018 at 9:01 AM, Oleksandr Andrushchenko
>> <andr2000@gmail.com> wrote:
>>> Ok, so I'll send v2 with the following changes:
>>>
>>> diff --git a/drivers/input/misc/xen-kbdfront.c
>>> b/drivers/input/misc/xen-kbdfront.c
>>> index a3306aad40b0..d8cca212f737 100644
>>> --- a/drivers/input/misc/xen-kbdfront.c
>>> +++ b/drivers/input/misc/xen-kbdfront.c
>>> @@ -51,13 +51,13 @@ module_param_array(ptr_size, int, NULL, 0444);
>>> MODULE_PARM_DESC(ptr_size,
>>> "Pointing device width, height in pixels (default 800,600)");
>>>
>>> -static unsigned int no_ptr_dev;
>>> -module_param(no_ptr_dev, uint, 0);
>>> +static bool no_ptr_dev;
>>> +module_param(no_ptr_dev, bool, 0);
>>> MODULE_PARM_DESC(no_ptr_dev,
>>> "If set then no virtual pointing device exposed to the guest");
>>>
>>> -static unsigned int no_kbd_dev;
>>> -module_param(no_kbd_dev, uint, 0);
>>> +static bool no_kbd_dev;
>>> +module_param(no_kbd_dev, bool, 0);
>>> MODULE_PARM_DESC(no_kbd_dev,
>>> "If set then no virtual keyboard device exposed to the guest");
>> I prefer direct logic over inverse logic. Maybe just use kbd_dev,
>> default to true, but allow it to be set off?
>>
>> static bool kbd_dev = true;
>> module_param(kbd_dev, bool, 0);
> I have no preference here, either way works for me
> Juergen, what do you think about the above?
I really have no preference here. What should be taken into account is
that boolean parameters don't need a value, meaning "true" in that case.
This would make no sense for "kbd_dev" as it wouldn't change the
default.
Juergen
^ permalink raw reply
* Re: [Xen-devel] [PATCH] Input: xen-kbdfront - allow better run-time configuration
From: Oleksandr Andrushchenko @ 2018-04-19 13:12 UTC (permalink / raw)
To: Jason Andryuk
Cc: Juergen Gross, xen-devel, linux-input, open list, dmitry.torokhov,
lyan, Boris Ostrovsky, andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <CAKf6xpsM03AB-mHaYdpVfipRdtx9uO1rS=bHZdEi3fkfTo6b4g@mail.gmail.com>
On 04/19/2018 04:10 PM, Jason Andryuk wrote:
> On Thu, Apr 19, 2018 at 9:01 AM, Oleksandr Andrushchenko
> <andr2000@gmail.com> wrote:
>> Ok, so I'll send v2 with the following changes:
>>
>> diff --git a/drivers/input/misc/xen-kbdfront.c
>> b/drivers/input/misc/xen-kbdfront.c
>> index a3306aad40b0..d8cca212f737 100644
>> --- a/drivers/input/misc/xen-kbdfront.c
>> +++ b/drivers/input/misc/xen-kbdfront.c
>> @@ -51,13 +51,13 @@ module_param_array(ptr_size, int, NULL, 0444);
>> MODULE_PARM_DESC(ptr_size,
>> "Pointing device width, height in pixels (default 800,600)");
>>
>> -static unsigned int no_ptr_dev;
>> -module_param(no_ptr_dev, uint, 0);
>> +static bool no_ptr_dev;
>> +module_param(no_ptr_dev, bool, 0);
>> MODULE_PARM_DESC(no_ptr_dev,
>> "If set then no virtual pointing device exposed to the guest");
>>
>> -static unsigned int no_kbd_dev;
>> -module_param(no_kbd_dev, uint, 0);
>> +static bool no_kbd_dev;
>> +module_param(no_kbd_dev, bool, 0);
>> MODULE_PARM_DESC(no_kbd_dev,
>> "If set then no virtual keyboard device exposed to the guest");
> I prefer direct logic over inverse logic. Maybe just use kbd_dev,
> default to true, but allow it to be set off?
>
> static bool kbd_dev = true;
> module_param(kbd_dev, bool, 0);
I have no preference here, either way works for me
Juergen, what do you think about the above?
> Regards,
> Jason
^ permalink raw reply
* Re: [Xen-devel] [PATCH] Input: xen-kbdfront - allow better run-time configuration
From: Jason Andryuk @ 2018-04-19 13:10 UTC (permalink / raw)
To: Oleksandr Andrushchenko
Cc: Juergen Gross, xen-devel, linux-input, open list, dmitry.torokhov,
lyan, Boris Ostrovsky, andrii_chepurnyi, Oleksandr Andrushchenko
In-Reply-To: <d935e7d9-090f-a8b1-7f12-5e0a7f0adf1b@gmail.com>
On Thu, Apr 19, 2018 at 9:01 AM, Oleksandr Andrushchenko
<andr2000@gmail.com> wrote:
>
> Ok, so I'll send v2 with the following changes:
>
> diff --git a/drivers/input/misc/xen-kbdfront.c
> b/drivers/input/misc/xen-kbdfront.c
> index a3306aad40b0..d8cca212f737 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -51,13 +51,13 @@ module_param_array(ptr_size, int, NULL, 0444);
> MODULE_PARM_DESC(ptr_size,
> "Pointing device width, height in pixels (default 800,600)");
>
> -static unsigned int no_ptr_dev;
> -module_param(no_ptr_dev, uint, 0);
> +static bool no_ptr_dev;
> +module_param(no_ptr_dev, bool, 0);
> MODULE_PARM_DESC(no_ptr_dev,
> "If set then no virtual pointing device exposed to the guest");
>
> -static unsigned int no_kbd_dev;
> -module_param(no_kbd_dev, uint, 0);
> +static bool no_kbd_dev;
> +module_param(no_kbd_dev, bool, 0);
> MODULE_PARM_DESC(no_kbd_dev,
> "If set then no virtual keyboard device exposed to the guest");
I prefer direct logic over inverse logic. Maybe just use kbd_dev,
default to true, but allow it to be set off?
static bool kbd_dev = true;
module_param(kbd_dev, bool, 0);
Regards,
Jason
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox