Skip to contentSkip to conversation

kernel panic on gpio-keys

DISCUSSION Paul Cercueil 2 participants 6 messages Dec 11, 2013 – Dec 30, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};

(tested on kernel 3.12).

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

Regards.

maintainer
#1 lore raw
Quoted 17 lines · Paul Cercueil

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};
Quoted 4 lines

(tested on kernel 3.12).

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

It woudl be helpful if you poster the stack trace from panic so we'd have an idea where the fault happens.

Thanks.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 20 lines · Dmitry Torokhov
Quoted 19 lines · Paul Cercueil

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};

(tested on kernel 3.12).

Quoted 8 lines
Quoted 2 lines

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

It woudl be helpful if you poster the stack trace from panic so we'd have an idea where the fault happens.

Thanks.

Here is the crash log I get: http://pastebin.com/FzTTGxsR
(I did put it on pastebin because it's huge, 200+ lines).

The first OOPS happen as soon as the GPIO button is pressed; the other ones seem to happen recursively. I included only a part of the log I get, as the OOPSes continue to flow until the watchdog kicks in.

maintainer
#3 lore raw
Quoted 30 lines · Paul Cercueil
Quoted 20 lines · Dmitry Torokhov
Quoted 19 lines · Paul Cercueil

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};

(tested on kernel 3.12).

Quoted 8 lines
Quoted 2 lines

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

It woudl be helpful if you poster the stack trace from panic so we'd have an idea where the fault happens.

Thanks.

Quoted 7 lines

Here is the crash log I get: http://pastebin.com/FzTTGxsR
(I did put it on pastebin because it's huge, 200+ lines).

The first OOPS happen as soon as the GPIO button is pressed; the other ones seem to happen recursively. I included only a part of the log I get, as the OOPSes continue to flow until the watchdog kicks in.

Hmm, I have an idea: this driver is one of few that does not use input_set_abs_info() and this does not allocate memory for absinfo data that input core uses to handle absolute events.

Does the patch below work for you?

Thanks.

Signature · 14 lines
Dmitry

Input: allocate absinfo data when setting ABS capability

From: Dmitry Torokhov <[email protected]>

We need to make sure we allocate absinfo data when we are setting one of
EV_ABS/ABS_XXX capabilities, otherwise we may bomb when we try to emit this
event.

Signed-off-by: Dmitry Torokhov <[email protected]>
---
 drivers/input/input.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/input/input.c +4 -0
index 692435a..1c4c0db 100644
@@ -1909,6 +1909,10 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
 		break;
 
 	case EV_ABS:
+		input_alloc_absinfo(dev);
+		if (!dev->absinfo)
+			return;
+
 		__set_bit(code, dev->absbit);
 		break;
 
#4 lore raw
Quoted 39 lines · Dmitry Torokhov
Quoted 30 lines · Paul Cercueil
Quoted 20 lines · Dmitry Torokhov
Quoted 19 lines · Paul Cercueil

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};

(tested on kernel 3.12).

Quoted 8 lines
Quoted 2 lines

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

It woudl be helpful if you poster the stack trace from panic so we'd have an idea where the fault happens.

Thanks.

Quoted 7 lines

Here is the crash log I get: http://pastebin.com/FzTTGxsR
(I did put it on pastebin because it's huge, 200+ lines).

The first OOPS happen as soon as the GPIO button is pressed; the other ones seem to happen recursively. I included only a part of the log I get, as the OOPSes continue to flow until the watchdog kicks in.

Quoted 8 lines

Hmm, I have an idea: this driver is one of few that does not use input_set_abs_info() and this does not allocate memory for absinfo data that input core uses to handle absolute events.

Does the patch below work for you?

Thanks.

Hi,

The patch works just fine, thank you!

maintainer
#5 lore raw
Quoted 44 lines · Paul Cercueil
Quoted 43 lines · Dmitry Torokhov
Quoted 30 lines · Paul Cercueil
Quoted 20 lines · Dmitry Torokhov
Quoted 19 lines · Paul Cercueil

Hi there,

I am trying to use the gpio-keys driver to inject joystick events. There seems to be some basic support of it, looking at <linux/gpio_keys.h>.

However, registering the following will trigger a kernel panic in the kernel:

static struct gpio_keys_button my_buttons[] {
	{
		.gpio = GPIO_FOO,
		.type = EV_ABS,
		.code = ABS_HAT0X,
		.value = 1,
	},
};

(tested on kernel 3.12).

Quoted 8 lines
Quoted 2 lines

I don't know well the input subsystem, so I have no idea of what is going wrong. Could anybody try to at least reproduce the issue?

It woudl be helpful if you poster the stack trace from panic so we'd have an idea where the fault happens.

Thanks.

Quoted 7 lines

Here is the crash log I get: http://pastebin.com/FzTTGxsR
(I did put it on pastebin because it's huge, 200+ lines).

The first OOPS happen as soon as the GPIO button is pressed; the other ones seem to happen recursively. I included only a part of the log I get, as the OOPSes continue to flow until the watchdog kicks in.

Hmm, I have an idea: this driver is one of few that does not use input_set_abs_info() and this does not allocate memory for absinfo data that input core uses to handle absolute events.

Quoted 8 lines
Quoted 4 lines

Does the patch below work for you?

Thanks.

Hi,

The patch works just fine, thank you!

Thanks Paul.

Signature · 1 line
Dmitry