* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2014-08-12 3:30 [PATCH] Input: serio: make HYPERV_KEYBOARD depend on SERIO_I8042=y Dexuan Cui
@ 2016-04-18 15:23 ` Mark Laws
2016-04-18 15:23 ` Mark Laws
1 sibling, 0 replies; 18+ messages in thread
From: Mark Laws @ 2016-04-18 15:23 UTC (permalink / raw)
To: kys, haiyangz; +Cc: Mark Laws, devel, linux-input
Hi,
Please keep me Cc:ed in any replies as I'm not on these lists.
Description of the fix is in the commit message for the patch.
Discussion:
Given that most distributions were already statically linking i8042.c,
having it not unload even if there is no i8042 device seems a better fix
than the alternatives:
a) requiring users build a kernel with CONFIG_SERIO_I8042=y;
b) duplicating the needed bits from atkbd.c in hyperv-keyboard, or;
c) this patch, but with a "stay_resident=1" option to enable the
workaround. Detecting presence of Hyper-V could be handled by udev,
which would pass this option, but every distribution would need to
fix their rules (certainly we don't want to check for Hyper-V in
i8042.c)
Mark Laws (1):
Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
drivers/input/serio/i8042.c | 43 +++++++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
--
2.8.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2014-08-12 3:30 [PATCH] Input: serio: make HYPERV_KEYBOARD depend on SERIO_I8042=y Dexuan Cui
2016-04-18 15:23 ` [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs Mark Laws
@ 2016-04-18 15:23 ` Mark Laws
2016-04-18 16:54 ` Dan Carpenter
1 sibling, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-18 15:23 UTC (permalink / raw)
To: kys, haiyangz; +Cc: Mark Laws, devel, linux-input
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
The transitive dependency on i8042.c is non-trivial--there appears to be
no obvious way to untangle it other than by duplicating much of atkbd.c
within hyperv-keyboard--so we employ a simple workaround: keep i8042.ko
loaded even if no i8042 device is detected, but set a flag so that any
calls into the module simply return (since we don't want to try to
interact with the non-existent i8042). This allows atkbd.c and libps2.c
to load, solving the problem.
Signed-off-by: Mark Laws <mdl@60hz.org>
---
drivers/input/serio/i8042.c | 41 ++++++++++++++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..4d49496 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -132,6 +132,7 @@ struct i8042_port {
static struct i8042_port i8042_ports[I8042_NUM_PORTS];
+static bool i8042_present;
static unsigned char i8042_initial_ctr;
static unsigned char i8042_ctr;
static bool i8042_mux_present;
@@ -163,6 +164,9 @@ int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
unsigned long flags;
int ret = 0;
+ if (!i8042_present)
+ return ret;
+
spin_lock_irqsave(&i8042_lock, flags);
if (i8042_platform_filter) {
@@ -184,6 +188,9 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
unsigned long flags;
int ret = 0;
+ if (!i8042_present)
+ return ret;
+
spin_lock_irqsave(&i8042_lock, flags);
if (i8042_platform_filter != filter) {
@@ -311,7 +318,10 @@ static int __i8042_command(unsigned char *param, int command)
int i8042_command(unsigned char *param, int command)
{
unsigned long flags;
- int retval;
+ int retval = 0;
+
+ if (!i8042_present)
+ return retval;
spin_lock_irqsave(&i8042_lock, flags);
retval = __i8042_command(param, command);
@@ -1380,6 +1390,9 @@ bool i8042_check_port_owner(const struct serio *port)
{
int i;
+ if (!i8042_present)
+ return false;
+
for (i = 0; i < I8042_NUM_PORTS; i++)
if (i8042_ports[i].serio == port)
return true;
@@ -1569,13 +1582,17 @@ static int __init i8042_init(void)
dbg_init();
+ i8042_present = false;
+
err = i8042_platform_init();
if (err)
return err;
err = i8042_controller_check();
- if (err)
- goto err_platform_exit;
+ if (err) {
+ pr_info("Staying resident in case of module dependencies\n");
+ goto out;
+ }
pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
if (IS_ERR(pdev)) {
@@ -1585,7 +1602,9 @@ static int __init i8042_init(void)
bus_register_notifier(&serio_bus, &i8042_kbd_bind_notifier_block);
panic_blink = i8042_panic_blink;
+ i8042_present = true;
+out:
return 0;
err_platform_exit:
@@ -1595,12 +1614,20 @@ static int __init i8042_init(void)
static void __exit i8042_exit(void)
{
- platform_device_unregister(i8042_platform_device);
- platform_driver_unregister(&i8042_driver);
+ if (i8042_present) {
+ platform_device_unregister(i8042_platform_device);
+ platform_driver_unregister(&i8042_driver);
+ }
+
i8042_platform_exit();
- bus_unregister_notifier(&serio_bus, &i8042_kbd_bind_notifier_block);
- panic_blink = NULL;
+ if (i8042_present) {
+ bus_unregister_notifier(&serio_bus,
+ &i8042_kbd_bind_notifier_block);
+ panic_blink = NULL;
+ }
+
+ i8042_present = false;
}
module_init(i8042_init);
--
2.8.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-18 15:23 ` Mark Laws
@ 2016-04-18 16:54 ` Dan Carpenter
2016-04-18 17:24 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Dan Carpenter @ 2016-04-18 16:54 UTC (permalink / raw)
To: Mark Laws; +Cc: kys, haiyangz, devel, linux-input
So if the user inserts the module without a keyboard then in the
original code they would just put a keyboard in and try again. Now they
have to do an extra rmmod. What about if we just removed the test for
if the keyboard is present?
On Tue, Apr 19, 2016 at 12:23:36AM +0900, Mark Laws wrote:
> As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
>
> > hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> > driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> > ps2_command(). libps2.c depends on i8042.c because it invokes
> > i8042_check_port_owner(). As a result, hyperv_keyboard actually
> > depends on i8042.c.
> >
> > For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> > Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> > rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> > no i8042 device emulated) and finally hyperv_keyboard can't work and
> > the user can't input: https://bugs.archlinux.org/task/39820
> > (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
>
> The transitive dependency on i8042.c is non-trivial--there appears to be
> no obvious way to untangle it other than by duplicating much of atkbd.c
> within hyperv-keyboard--so we employ a simple workaround: keep i8042.ko
> loaded even if no i8042 device is detected, but set a flag so that any
> calls into the module simply return (since we don't want to try to
> interact with the non-existent i8042). This allows atkbd.c and libps2.c
> to load, solving the problem.
>
> Signed-off-by: Mark Laws <mdl@60hz.org>
> ---
> drivers/input/serio/i8042.c | 41 ++++++++++++++++++++++++++++++++++-------
> 1 file changed, 34 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
> index 4541957..4d49496 100644
> --- a/drivers/input/serio/i8042.c
> +++ b/drivers/input/serio/i8042.c
> @@ -132,6 +132,7 @@ struct i8042_port {
>
> static struct i8042_port i8042_ports[I8042_NUM_PORTS];
>
> +static bool i8042_present;
> static unsigned char i8042_initial_ctr;
> static unsigned char i8042_ctr;
> static bool i8042_mux_present;
> @@ -163,6 +164,9 @@ int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
> unsigned long flags;
> int ret = 0;
>
> + if (!i8042_present)
> + return ret;
Don't obfuscate the literal. Just "return 0;". Also if it's goto out
just change that to "return 0;" because it's simpler for the reader.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-18 16:54 ` Dan Carpenter
@ 2016-04-18 17:24 ` Mark Laws
2016-04-18 20:36 ` Dan Carpenter
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-18 17:24 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kys, haiyangz, devel, linux-input
On Tue, Apr 19, 2016 at 1:54 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> So if the user inserts the module without a keyboard then in the
> original code they would just put a keyboard in and try again. Now they
> have to do an extra rmmod. What about if we just removed the test for
> if the keyboard is present?
Sorry, I don't understand--which part are you suggesting we remove?
> Don't obfuscate the literal. Just "return 0;". Also if it's goto out
> just change that to "return 0;" because it's simpler for the reader.
Will fix.
Regards,
Mark Laws
--
|v\ /\ |\ |< |_ /\ \^| //
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-18 17:24 ` Mark Laws
@ 2016-04-18 20:36 ` Dan Carpenter
2016-04-18 22:00 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Dan Carpenter @ 2016-04-18 20:36 UTC (permalink / raw)
To: Mark Laws; +Cc: devel, haiyangz, linux-input
On Tue, Apr 19, 2016 at 02:24:47AM +0900, Mark Laws wrote:
> On Tue, Apr 19, 2016 at 1:54 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > So if the user inserts the module without a keyboard then in the
> > original code they would just put a keyboard in and try again. Now they
> > have to do an extra rmmod. What about if we just removed the test for
> > if the keyboard is present?
>
> Sorry, I don't understand--which part are you suggesting we remove?
>
The call to i8042_controller_check() or move it to the probe function or
something. Why must we have the hardware to load the module?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-18 20:36 ` Dan Carpenter
@ 2016-04-18 22:00 ` Mark Laws
2016-04-19 8:22 ` Dan Carpenter
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-18 22:00 UTC (permalink / raw)
To: Dan Carpenter; +Cc: devel, haiyangz, linux-input
On Tue, Apr 19, 2016 at 5:36 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Apr 19, 2016 at 02:24:47AM +0900, Mark Laws wrote:
>> Sorry, I don't understand--which part are you suggesting we remove?
>
> The call to i8042_controller_check() or move it to the probe function or
> something. Why must we have the hardware to load the module?
We don't. That's the point of the patch. Do you mean that since our
intent is to load the module regardless of whether or not the hardware
is there, the check should be (re)moved simply to clarify the code?
Sorry for the stupid questions--I'm just trying to make sure I
understand you correctly!
Regards,
Mark Laws
--
|v\ /\ |\ |< |_ /\ \^| //
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-18 22:00 ` Mark Laws
@ 2016-04-19 8:22 ` Dan Carpenter
2016-04-19 10:46 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Dan Carpenter @ 2016-04-19 8:22 UTC (permalink / raw)
To: Mark Laws; +Cc: devel, haiyangz, linux-input
On Tue, Apr 19, 2016 at 07:00:42AM +0900, Mark Laws wrote:
> On Tue, Apr 19, 2016 at 5:36 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Tue, Apr 19, 2016 at 02:24:47AM +0900, Mark Laws wrote:
> >> Sorry, I don't understand--which part are you suggesting we remove?
> >
> > The call to i8042_controller_check() or move it to the probe function or
> > something. Why must we have the hardware to load the module?
>
> We don't. That's the point of the patch. Do you mean that since our
> intent is to load the module regardless of whether or not the hardware
> is there, the check should be (re)moved simply to clarify the code?
Yeah. Just remove the call to i8042_controller_check(). Wouldn't
everyone be happy with that situation?
Your patch makes life slightly more complicated for people who want to
use the original hardware if the load the module but the hardware isn't
detected.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-19 8:22 ` Dan Carpenter
@ 2016-04-19 10:46 ` Mark Laws
2016-04-22 13:00 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-19 10:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: devel, haiyangz, linux-input
On Tue, Apr 19, 2016 at 5:22 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Yeah. Just remove the call to i8042_controller_check(). Wouldn't
> everyone be happy with that situation?
No problem, I agree this is better--just wasn't sure what you meant initially.
> Your patch makes life slightly more complicated for people who want to
> use the original hardware if the load the module but the hardware isn't
> detected.
That is true, but apparently nobody can think of a better solution
(including me :)) and this bug has been open for two years. Having to
rmmod in the corner case where the module gets loaded but no i8042 is
present seems a small price to pay for having the keyboard work
regardless of CONFIG_I8042=y or m. Right now, any distribution with
CONFIG_I8042=m has a non-functional keyboard on Hyper-V Gen2 VMs,
which is probably frustrating for (e.g.) Arch Linux users who find
themselves unable to type and thus can't install their distribution.
Regards,
Mark Laws
--
|v\ /\ |\ |< |_ /\ \^| //
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-19 10:46 ` Mark Laws
@ 2016-04-22 13:00 ` Mark Laws
2016-04-22 13:01 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-22 13:00 UTC (permalink / raw)
To: haiyangz; +Cc: Mark Laws, devel, linux-input
This is an updated version of the original patch from this thread. It
fixes the style issues Dan Carpenter brought up.
Mark Laws (1):
Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
drivers/input/serio/i8042.c | 50 ++++++++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 16 deletions(-)
--
2.8.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-22 13:00 ` Mark Laws
@ 2016-04-22 13:01 ` Mark Laws
2016-04-22 13:17 ` Dan Carpenter
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-22 13:01 UTC (permalink / raw)
To: haiyangz; +Cc: devel, linux-input, Mark Laws
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
The transitive dependency on i8042.c is non-trivial--there appears to be
no obvious way to untangle it other than by duplicating much of atkbd.c
within hyperv-keyboard--so we employ a simple workaround: keep i8042.ko
loaded even if no i8042 device is detected, but set a flag so that any
calls into the module simply return (since we don't want to try to
interact with the non-existent i8042). This allows atkbd.c and libps2.c
to load, solving the problem.
Signed-off-by: Mark Laws <mdl@60hz.org>
---
drivers/input/serio/i8042.c | 50 ++++++++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..00f73d3 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -132,6 +132,7 @@ struct i8042_port {
static struct i8042_port i8042_ports[I8042_NUM_PORTS];
+static bool i8042_present;
static unsigned char i8042_initial_ctr;
static unsigned char i8042_ctr;
static bool i8042_mux_present;
@@ -163,6 +164,9 @@ int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
unsigned long flags;
int ret = 0;
+ if (!i8042_present)
+ return 0;
+
spin_lock_irqsave(&i8042_lock, flags);
if (i8042_platform_filter) {
@@ -184,6 +188,9 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
unsigned long flags;
int ret = 0;
+ if (!i8042_present)
+ return 0;
+
spin_lock_irqsave(&i8042_lock, flags);
if (i8042_platform_filter != filter) {
@@ -313,6 +320,9 @@ int i8042_command(unsigned char *param, int command)
unsigned long flags;
int retval;
+ if (!i8042_present)
+ return 0;
+
spin_lock_irqsave(&i8042_lock, flags);
retval = __i8042_command(param, command);
spin_unlock_irqrestore(&i8042_lock, flags);
@@ -1380,6 +1390,9 @@ bool i8042_check_port_owner(const struct serio *port)
{
int i;
+ if (!i8042_present)
+ return false;
+
for (i = 0; i < I8042_NUM_PORTS; i++)
if (i8042_ports[i].serio == port)
return true;
@@ -1493,6 +1506,10 @@ static int __init i8042_probe(struct platform_device *dev)
{
int error;
+ error = i8042_controller_check();
+ if (error)
+ return error;
+
i8042_platform_device = dev;
if (i8042_reset) {
@@ -1569,38 +1586,39 @@ static int __init i8042_init(void)
dbg_init();
+ i8042_present = false;
+
err = i8042_platform_init();
if (err)
return err;
- err = i8042_controller_check();
- if (err)
- goto err_platform_exit;
-
pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
- if (IS_ERR(pdev)) {
- err = PTR_ERR(pdev);
- goto err_platform_exit;
- }
+ if (IS_ERR(pdev))
+ return 0; /* load anyway since some modules depend on our symbols */
bus_register_notifier(&serio_bus, &i8042_kbd_bind_notifier_block);
panic_blink = i8042_panic_blink;
+ i8042_present = true;
return 0;
-
- err_platform_exit:
- i8042_platform_exit();
- return err;
}
static void __exit i8042_exit(void)
{
- platform_device_unregister(i8042_platform_device);
- platform_driver_unregister(&i8042_driver);
+ if (i8042_present) {
+ platform_device_unregister(i8042_platform_device);
+ platform_driver_unregister(&i8042_driver);
+ }
+
i8042_platform_exit();
- bus_unregister_notifier(&serio_bus, &i8042_kbd_bind_notifier_block);
- panic_blink = NULL;
+ if (i8042_present) {
+ bus_unregister_notifier(&serio_bus,
+ &i8042_kbd_bind_notifier_block);
+ panic_blink = NULL;
+ }
+
+ i8042_present = false;
}
module_init(i8042_init);
--
2.8.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-22 13:01 ` Mark Laws
@ 2016-04-22 13:17 ` Dan Carpenter
2016-04-22 17:30 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Dan Carpenter @ 2016-04-22 13:17 UTC (permalink / raw)
To: Mark Laws; +Cc: haiyangz, devel, linux-input
Why is platform_create_bundle() failing? It didn't fail in the first
version of the patch.
Btw, I'm not asking rhetorical questions, if I ask a question it means I
legitimately don't know the answer.
But I don't like this patch. Could you describe how you have tested it
with real hardware? What I want to know is that you loaded the module
without the hardware installed and then installed the hardware and got
it to work. You have made that more complicated and you've said that
you're willing to complicate life for those users slightly because it's
a trade off for fixing your bug... But that's sort of annoying and no
one has even tested how it works.
What I was really wondering last time was why can we not just do this?
Testing to see if the hardware is present is normally done in the
probe() function and not the init() function. I have not tested this
and I don't know what happens when we do this. Apparently, it causes
platform_create_bundle() to fail but I'm not sure why... Maybe the
create bundle call probe() and that fails?
How hard would it be to separate these things out into two modules
really? You say that you'd have to duplicate everything but maybe we
could instead just make the common functions into a library type thing..
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..4f0bc7c 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1573,10 +1573,6 @@ static int __init i8042_init(void)
if (err)
return err;
- err = i8042_controller_check();
- if (err)
- goto err_platform_exit;
-
pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
if (IS_ERR(pdev)) {
err = PTR_ERR(pdev);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-22 13:17 ` Dan Carpenter
@ 2016-04-22 17:30 ` Mark Laws
2016-04-22 17:30 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-04-22 17:30 UTC (permalink / raw)
To: haiyangz, dan.carpenter; +Cc: Mark Laws, devel, linux-input
A few tripels later and the patch has been completely rewritten.
The problem symbols have been moved to a new module, libi8042.c, which
both libps2.c and i8042.c use. libps2.c no longer depends on i8042.c,
and i8042.c no longer needs the gross hack of the previous patch.
Since I didn't write anything new, just shuffled things around, I
haven't changed any copyrights. I have no idea what the right procedure
is here, so please let me know, since I'm probably screwing up somehow.
Mark Laws (1):
Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
drivers/input/serio/Kconfig | 7 ++++-
drivers/input/serio/Makefile | 1 +
drivers/input/serio/i8042.c | 48 ---------------------------------
drivers/input/serio/i8042.h | 7 -----
drivers/input/serio/libi8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/serio/libps2.c | 2 +-
include/linux/i8042.h | 17 +-----------
include/linux/libi8042.h | 55 ++++++++++++++++++++++++++++++++++++++
8 files changed, 124 insertions(+), 73 deletions(-)
create mode 100644 drivers/input/serio/libi8042.c
create mode 100644 include/linux/libi8042.h
--
2.8.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-04-22 17:30 ` Mark Laws
@ 2016-04-22 17:30 ` Mark Laws
0 siblings, 0 replies; 18+ messages in thread
From: Mark Laws @ 2016-04-22 17:30 UTC (permalink / raw)
To: haiyangz, dan.carpenter; +Cc: Mark Laws, devel, linux-input
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
This eliminates the transitive dependency on i8042.c by moving the
symbols libps2.c depends on to a new module, libi8042.c.
Signed-off-by: Mark Laws <mdl@60hz.org>
---
drivers/input/serio/Kconfig | 7 ++++-
drivers/input/serio/Makefile | 1 +
drivers/input/serio/i8042.c | 48 ---------------------------------
drivers/input/serio/i8042.h | 7 -----
drivers/input/serio/libi8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/serio/libps2.c | 2 +-
include/linux/i8042.h | 17 +-----------
include/linux/libi8042.h | 55 ++++++++++++++++++++++++++++++++++++++
8 files changed, 124 insertions(+), 73 deletions(-)
create mode 100644 drivers/input/serio/libi8042.c
create mode 100644 include/linux/libi8042.h
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index c3d05b4..a8ca89c 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -25,10 +25,15 @@ config ARCH_MIGHT_HAVE_PC_SERIO
if SERIO
+config SERIO_LIBI8042
+ tristate "i8042 driver library"
+ default y
+
config SERIO_I8042
tristate "i8042 PC Keyboard controller"
default y
depends on ARCH_MIGHT_HAVE_PC_SERIO
+ select SERIO_LIBI8042
help
i8042 is the chip over which the standard AT keyboard and PS/2
mouse are connected to the computer. If you use these devices,
@@ -176,7 +181,7 @@ config SERIO_MACEPS2
config SERIO_LIBPS2
tristate "PS/2 driver library"
- depends on SERIO_I8042 || SERIO_I8042=n
+ depends on SERIO_LIBI8042 || SERIO_LIBI8042=n
help
Say Y here if you are using a driver for device connected
to a PS/2 port, such as PS/2 mouse or standard AT keyboard.
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
index 2374ef9..b3a806f 100644
--- a/drivers/input/serio/Makefile
+++ b/drivers/input/serio/Makefile
@@ -5,6 +5,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_SERIO) += serio.o
+obj-$(CONFIG_SERIO_LIBI8042) += libi8042.o
obj-$(CONFIG_SERIO_I8042) += i8042.o
obj-$(CONFIG_SERIO_PARKBD) += parkbd.o
obj-$(CONFIG_SERIO_SERPORT) += serport.o
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..707bb19 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -107,30 +107,9 @@ static char i8042_aux_firmware_id[128];
*/
static DEFINE_SPINLOCK(i8042_lock);
-/*
- * Writers to AUX and KBD ports as well as users issuing i8042_command
- * directly should acquire i8042_mutex (by means of calling
- * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
- * they do not disturb each other (unfortunately in many i8042
- * implementations write to one of the ports will immediately abort
- * command that is being processed by another port).
- */
-static DEFINE_MUTEX(i8042_mutex);
-
-struct i8042_port {
- struct serio *serio;
- int irq;
- bool exists;
- bool driver_bound;
- signed char mux;
-};
-
#define I8042_KBD_PORT_NO 0
#define I8042_AUX_PORT_NO 1
#define I8042_MUX_PORT_NO 2
-#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
-
-static struct i8042_port i8042_ports[I8042_NUM_PORTS];
static unsigned char i8042_initial_ctr;
static unsigned char i8042_ctr;
@@ -145,18 +124,6 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id);
static bool (*i8042_platform_filter)(unsigned char data, unsigned char str,
struct serio *serio);
-void i8042_lock_chip(void)
-{
- mutex_lock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_lock_chip);
-
-void i8042_unlock_chip(void)
-{
- mutex_unlock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_unlock_chip);
-
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
@@ -1373,21 +1340,6 @@ static void i8042_unregister_ports(void)
}
}
-/*
- * Checks whether port belongs to i8042 controller.
- */
-bool i8042_check_port_owner(const struct serio *port)
-{
- int i;
-
- for (i = 0; i < I8042_NUM_PORTS; i++)
- if (i8042_ports[i].serio == port)
- return true;
-
- return false;
-}
-EXPORT_SYMBOL(i8042_check_port_owner);
-
static void i8042_free_irqs(void)
{
if (i8042_aux_irq_registered)
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
index 1db0a40..7de98ac 100644
--- a/drivers/input/serio/i8042.h
+++ b/drivers/input/serio/i8042.h
@@ -54,13 +54,6 @@
#define I8042_BUFFER_SIZE 16
/*
- * Number of AUX ports on controllers supporting active multiplexing
- * specification
- */
-
-#define I8042_NUM_MUX_PORTS 4
-
-/*
* Debug.
*/
diff --git a/drivers/input/serio/libi8042.c b/drivers/input/serio/libi8042.c
new file mode 100644
index 0000000..4505bac
--- /dev/null
+++ b/drivers/input/serio/libi8042.c
@@ -0,0 +1,60 @@
+/*
+ * i8042 driver shared dependencies
+ *
+ * Copyright (c) 1999-2004 Vojtech Pavlik
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/libi8042.h>
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_DESCRIPTION("i8042 driver shared dependencies");
+MODULE_LICENSE("GPL");
+
+/*
+ * Writers to AUX and KBD ports as well as users issuing i8042_command
+ * directly should acquire i8042_mutex (by means of calling
+ * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
+ * they do not disturb each other (unfortunately in many i8042
+ * implementations write to one of the ports will immediately abort
+ * command that is being processed by another port).
+ */
+static DEFINE_MUTEX(i8042_mutex);
+
+struct i8042_port i8042_ports[I8042_NUM_PORTS];
+EXPORT_SYMBOL(i8042_ports);
+
+void i8042_lock_chip(void)
+{
+ mutex_lock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_lock_chip);
+
+void i8042_unlock_chip(void)
+{
+ mutex_unlock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_unlock_chip);
+
+/*
+ * Checks whether port belongs to i8042 controller.
+ */
+bool i8042_check_port_owner(const struct serio *port)
+{
+ int i;
+
+ for (i = 0; i < I8042_NUM_PORTS; i++)
+ if (i8042_ports[i].serio == port)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(i8042_check_port_owner);
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 316f2c8..62c0059 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -17,7 +17,7 @@
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/serio.h>
-#include <linux/i8042.h>
+#include <linux/libi8042.h>
#include <linux/libps2.h>
#define DRIVER_DESC "PS/2 driver library"
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 0f9bafa..77aed40 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -8,6 +8,7 @@
*/
#include <linux/types.h>
+#include <linux/libi8042.h>
/*
* Standard commands.
@@ -59,10 +60,7 @@ struct serio;
#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
-void i8042_lock_chip(void);
-void i8042_unlock_chip(void);
int i8042_command(unsigned char *param, int command);
-bool i8042_check_port_owner(const struct serio *);
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio));
int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
@@ -70,24 +68,11 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
#else
-static inline void i8042_lock_chip(void)
-{
-}
-
-static inline void i8042_unlock_chip(void)
-{
-}
-
static inline int i8042_command(unsigned char *param, int command)
{
return -ENODEV;
}
-static inline bool i8042_check_port_owner(const struct serio *serio)
-{
- return false;
-}
-
static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
diff --git a/include/linux/libi8042.h b/include/linux/libi8042.h
new file mode 100644
index 0000000..5a730f0
--- /dev/null
+++ b/include/linux/libi8042.h
@@ -0,0 +1,55 @@
+#ifndef _LINUX_LIBI8042_H
+#define _LINUX_LIBI8042_H
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+
+/*
+ * Number of AUX ports on controllers supporting active multiplexing
+ * specification
+ */
+
+#define I8042_NUM_MUX_PORTS 4
+#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
+
+struct serio;
+
+struct i8042_port {
+ struct serio *serio;
+ int irq;
+ bool exists;
+ bool driver_bound;
+ signed char mux;
+};
+
+#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
+
+extern struct i8042_port i8042_ports[I8042_NUM_PORTS];
+
+void i8042_lock_chip(void);
+void i8042_unlock_chip(void);
+bool i8042_check_port_owner(const struct serio *);
+
+#else
+
+static inline void i8042_lock_chip(void)
+{
+}
+
+static inline void i8042_unlock_chip(void)
+{
+}
+
+static inline bool i8042_check_port_owner(const struct serio *serio)
+{
+ return false;
+}
+
+#endif
+
+#endif
--
2.8.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
@ 2016-06-13 14:38 Mark Laws
2016-06-13 14:38 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-06-13 14:38 UTC (permalink / raw)
To: linux-input; +Cc: Mark Laws, kys, haiyangz, dmitry.torokhov
Some minor reorganizations to i8042.c in order to fix a bug that could prevent
the keyboard from working at the Hyper-V virtual console (see patch for a more
detailed explanation).
Thanks for looking this over, KY--sorry for the delay in resending it!
Mark Laws (1):
Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
drivers/input/serio/Kconfig | 7 ++++-
drivers/input/serio/Makefile | 1 +
drivers/input/serio/i8042.c | 48 ---------------------------------
drivers/input/serio/i8042.h | 7 -----
drivers/input/serio/libi8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/serio/libps2.c | 2 +-
include/linux/i8042.h | 17 +-----------
include/linux/libi8042.h | 55 ++++++++++++++++++++++++++++++++++++++
8 files changed, 124 insertions(+), 73 deletions(-)
create mode 100644 drivers/input/serio/libi8042.c
create mode 100644 include/linux/libi8042.h
--
2.8.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-06-13 14:38 Mark Laws
@ 2016-06-13 14:38 ` Mark Laws
2016-06-13 20:45 ` [PATCH] [PATCH] Input: i8042 - Fix console keyboard support on Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Mark Laws @ 2016-06-13 14:38 UTC (permalink / raw)
To: linux-input; +Cc: Mark Laws, kys, haiyangz, dmitry.torokhov
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
This eliminates the transitive dependency on i8042.c by moving the
symbols libps2.c depends on to a new module, libi8042.c.
Signed-off-by: Mark Laws <mdl@60hz.org>
---
drivers/input/serio/Kconfig | 7 ++++-
drivers/input/serio/Makefile | 1 +
drivers/input/serio/i8042.c | 48 ---------------------------------
drivers/input/serio/i8042.h | 7 -----
drivers/input/serio/libi8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/serio/libps2.c | 2 +-
include/linux/i8042.h | 17 +-----------
include/linux/libi8042.h | 55 ++++++++++++++++++++++++++++++++++++++
8 files changed, 124 insertions(+), 73 deletions(-)
create mode 100644 drivers/input/serio/libi8042.c
create mode 100644 include/linux/libi8042.h
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index c3d05b4..a8ca89c 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -25,10 +25,15 @@ config ARCH_MIGHT_HAVE_PC_SERIO
if SERIO
+config SERIO_LIBI8042
+ tristate "i8042 driver library"
+ default y
+
config SERIO_I8042
tristate "i8042 PC Keyboard controller"
default y
depends on ARCH_MIGHT_HAVE_PC_SERIO
+ select SERIO_LIBI8042
help
i8042 is the chip over which the standard AT keyboard and PS/2
mouse are connected to the computer. If you use these devices,
@@ -176,7 +181,7 @@ config SERIO_MACEPS2
config SERIO_LIBPS2
tristate "PS/2 driver library"
- depends on SERIO_I8042 || SERIO_I8042=n
+ depends on SERIO_LIBI8042 || SERIO_LIBI8042=n
help
Say Y here if you are using a driver for device connected
to a PS/2 port, such as PS/2 mouse or standard AT keyboard.
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
index 2374ef9..b3a806f 100644
--- a/drivers/input/serio/Makefile
+++ b/drivers/input/serio/Makefile
@@ -5,6 +5,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_SERIO) += serio.o
+obj-$(CONFIG_SERIO_LIBI8042) += libi8042.o
obj-$(CONFIG_SERIO_I8042) += i8042.o
obj-$(CONFIG_SERIO_PARKBD) += parkbd.o
obj-$(CONFIG_SERIO_SERPORT) += serport.o
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..707bb19 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -107,30 +107,9 @@ static char i8042_aux_firmware_id[128];
*/
static DEFINE_SPINLOCK(i8042_lock);
-/*
- * Writers to AUX and KBD ports as well as users issuing i8042_command
- * directly should acquire i8042_mutex (by means of calling
- * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
- * they do not disturb each other (unfortunately in many i8042
- * implementations write to one of the ports will immediately abort
- * command that is being processed by another port).
- */
-static DEFINE_MUTEX(i8042_mutex);
-
-struct i8042_port {
- struct serio *serio;
- int irq;
- bool exists;
- bool driver_bound;
- signed char mux;
-};
-
#define I8042_KBD_PORT_NO 0
#define I8042_AUX_PORT_NO 1
#define I8042_MUX_PORT_NO 2
-#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
-
-static struct i8042_port i8042_ports[I8042_NUM_PORTS];
static unsigned char i8042_initial_ctr;
static unsigned char i8042_ctr;
@@ -145,18 +124,6 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id);
static bool (*i8042_platform_filter)(unsigned char data, unsigned char str,
struct serio *serio);
-void i8042_lock_chip(void)
-{
- mutex_lock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_lock_chip);
-
-void i8042_unlock_chip(void)
-{
- mutex_unlock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_unlock_chip);
-
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
@@ -1373,21 +1340,6 @@ static void i8042_unregister_ports(void)
}
}
-/*
- * Checks whether port belongs to i8042 controller.
- */
-bool i8042_check_port_owner(const struct serio *port)
-{
- int i;
-
- for (i = 0; i < I8042_NUM_PORTS; i++)
- if (i8042_ports[i].serio == port)
- return true;
-
- return false;
-}
-EXPORT_SYMBOL(i8042_check_port_owner);
-
static void i8042_free_irqs(void)
{
if (i8042_aux_irq_registered)
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
index 1db0a40..7de98ac 100644
--- a/drivers/input/serio/i8042.h
+++ b/drivers/input/serio/i8042.h
@@ -54,13 +54,6 @@
#define I8042_BUFFER_SIZE 16
/*
- * Number of AUX ports on controllers supporting active multiplexing
- * specification
- */
-
-#define I8042_NUM_MUX_PORTS 4
-
-/*
* Debug.
*/
diff --git a/drivers/input/serio/libi8042.c b/drivers/input/serio/libi8042.c
new file mode 100644
index 0000000..4505bac
--- /dev/null
+++ b/drivers/input/serio/libi8042.c
@@ -0,0 +1,60 @@
+/*
+ * i8042 driver shared dependencies
+ *
+ * Copyright (c) 1999-2004 Vojtech Pavlik
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/libi8042.h>
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_DESCRIPTION("i8042 driver shared dependencies");
+MODULE_LICENSE("GPL");
+
+/*
+ * Writers to AUX and KBD ports as well as users issuing i8042_command
+ * directly should acquire i8042_mutex (by means of calling
+ * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
+ * they do not disturb each other (unfortunately in many i8042
+ * implementations write to one of the ports will immediately abort
+ * command that is being processed by another port).
+ */
+static DEFINE_MUTEX(i8042_mutex);
+
+struct i8042_port i8042_ports[I8042_NUM_PORTS];
+EXPORT_SYMBOL(i8042_ports);
+
+void i8042_lock_chip(void)
+{
+ mutex_lock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_lock_chip);
+
+void i8042_unlock_chip(void)
+{
+ mutex_unlock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_unlock_chip);
+
+/*
+ * Checks whether port belongs to i8042 controller.
+ */
+bool i8042_check_port_owner(const struct serio *port)
+{
+ int i;
+
+ for (i = 0; i < I8042_NUM_PORTS; i++)
+ if (i8042_ports[i].serio == port)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(i8042_check_port_owner);
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 316f2c8..62c0059 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -17,7 +17,7 @@
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/serio.h>
-#include <linux/i8042.h>
+#include <linux/libi8042.h>
#include <linux/libps2.h>
#define DRIVER_DESC "PS/2 driver library"
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 0f9bafa..77aed40 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -8,6 +8,7 @@
*/
#include <linux/types.h>
+#include <linux/libi8042.h>
/*
* Standard commands.
@@ -59,10 +60,7 @@ struct serio;
#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
-void i8042_lock_chip(void);
-void i8042_unlock_chip(void);
int i8042_command(unsigned char *param, int command);
-bool i8042_check_port_owner(const struct serio *);
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio));
int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
@@ -70,24 +68,11 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
#else
-static inline void i8042_lock_chip(void)
-{
-}
-
-static inline void i8042_unlock_chip(void)
-{
-}
-
static inline int i8042_command(unsigned char *param, int command)
{
return -ENODEV;
}
-static inline bool i8042_check_port_owner(const struct serio *serio)
-{
- return false;
-}
-
static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
diff --git a/include/linux/libi8042.h b/include/linux/libi8042.h
new file mode 100644
index 0000000..5a730f0
--- /dev/null
+++ b/include/linux/libi8042.h
@@ -0,0 +1,55 @@
+#ifndef _LINUX_LIBI8042_H
+#define _LINUX_LIBI8042_H
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+
+/*
+ * Number of AUX ports on controllers supporting active multiplexing
+ * specification
+ */
+
+#define I8042_NUM_MUX_PORTS 4
+#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
+
+struct serio;
+
+struct i8042_port {
+ struct serio *serio;
+ int irq;
+ bool exists;
+ bool driver_bound;
+ signed char mux;
+};
+
+#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
+
+extern struct i8042_port i8042_ports[I8042_NUM_PORTS];
+
+void i8042_lock_chip(void);
+void i8042_unlock_chip(void);
+bool i8042_check_port_owner(const struct serio *);
+
+#else
+
+static inline void i8042_lock_chip(void)
+{
+}
+
+static inline void i8042_unlock_chip(void)
+{
+}
+
+static inline bool i8042_check_port_owner(const struct serio *serio)
+{
+ return false;
+}
+
+#endif
+
+#endif
--
2.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-06-13 20:45 ` [PATCH] [PATCH] Input: i8042 - Fix console keyboard support on Mark Laws
@ 2016-06-13 20:45 ` Mark Laws
0 siblings, 0 replies; 18+ messages in thread
From: Mark Laws @ 2016-06-13 20:45 UTC (permalink / raw)
To: linux-input; +Cc: Mark Laws, kys, dmitry.torokhov, arjan.van.de.ven
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
This eliminates the transitive dependency on i8042.c by moving the
symbols libps2.c depends on to a new module, libi8042.c.
Signed-off-by: Mark Laws <mdl@60hz.org>
---
drivers/input/keyboard/Kconfig | 2 +-
drivers/input/serio/Kconfig | 7 ++++-
drivers/input/serio/Makefile | 1 +
drivers/input/serio/i8042.c | 48 ---------------------------------
drivers/input/serio/i8042.h | 7 -----
drivers/input/serio/libi8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/serio/libps2.c | 2 +-
include/linux/i8042.h | 17 +-----------
include/linux/libi8042.h | 55 ++++++++++++++++++++++++++++++++++++++
9 files changed, 125 insertions(+), 74 deletions(-)
create mode 100644 drivers/input/serio/libi8042.c
create mode 100644 include/linux/libi8042.h
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 509608c..98c5425 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -71,7 +71,7 @@ config KEYBOARD_ATKBD
default y
select SERIO
select SERIO_LIBPS2
- select SERIO_I8042 if ARCH_MIGHT_HAVE_PC_SERIO
+ select SERIO_LIBI8042 if ARCH_MIGHT_HAVE_PC_SERIO
select SERIO_GSCPS2 if GSC
help
Say Y here if you want to use a standard AT or PS/2 keyboard. Usually
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index c3d05b4..a8ca89c 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -25,10 +25,15 @@ config ARCH_MIGHT_HAVE_PC_SERIO
if SERIO
+config SERIO_LIBI8042
+ tristate "i8042 driver library"
+ default y
+
config SERIO_I8042
tristate "i8042 PC Keyboard controller"
default y
depends on ARCH_MIGHT_HAVE_PC_SERIO
+ select SERIO_LIBI8042
help
i8042 is the chip over which the standard AT keyboard and PS/2
mouse are connected to the computer. If you use these devices,
@@ -176,7 +181,7 @@ config SERIO_MACEPS2
config SERIO_LIBPS2
tristate "PS/2 driver library"
- depends on SERIO_I8042 || SERIO_I8042=n
+ depends on SERIO_LIBI8042 || SERIO_LIBI8042=n
help
Say Y here if you are using a driver for device connected
to a PS/2 port, such as PS/2 mouse or standard AT keyboard.
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
index 2374ef9..b3a806f 100644
--- a/drivers/input/serio/Makefile
+++ b/drivers/input/serio/Makefile
@@ -5,6 +5,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_SERIO) += serio.o
+obj-$(CONFIG_SERIO_LIBI8042) += libi8042.o
obj-$(CONFIG_SERIO_I8042) += i8042.o
obj-$(CONFIG_SERIO_PARKBD) += parkbd.o
obj-$(CONFIG_SERIO_SERPORT) += serport.o
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..707bb19 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -107,30 +107,9 @@ static char i8042_aux_firmware_id[128];
*/
static DEFINE_SPINLOCK(i8042_lock);
-/*
- * Writers to AUX and KBD ports as well as users issuing i8042_command
- * directly should acquire i8042_mutex (by means of calling
- * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
- * they do not disturb each other (unfortunately in many i8042
- * implementations write to one of the ports will immediately abort
- * command that is being processed by another port).
- */
-static DEFINE_MUTEX(i8042_mutex);
-
-struct i8042_port {
- struct serio *serio;
- int irq;
- bool exists;
- bool driver_bound;
- signed char mux;
-};
-
#define I8042_KBD_PORT_NO 0
#define I8042_AUX_PORT_NO 1
#define I8042_MUX_PORT_NO 2
-#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
-
-static struct i8042_port i8042_ports[I8042_NUM_PORTS];
static unsigned char i8042_initial_ctr;
static unsigned char i8042_ctr;
@@ -145,18 +124,6 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id);
static bool (*i8042_platform_filter)(unsigned char data, unsigned char str,
struct serio *serio);
-void i8042_lock_chip(void)
-{
- mutex_lock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_lock_chip);
-
-void i8042_unlock_chip(void)
-{
- mutex_unlock(&i8042_mutex);
-}
-EXPORT_SYMBOL(i8042_unlock_chip);
-
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
@@ -1373,21 +1340,6 @@ static void i8042_unregister_ports(void)
}
}
-/*
- * Checks whether port belongs to i8042 controller.
- */
-bool i8042_check_port_owner(const struct serio *port)
-{
- int i;
-
- for (i = 0; i < I8042_NUM_PORTS; i++)
- if (i8042_ports[i].serio == port)
- return true;
-
- return false;
-}
-EXPORT_SYMBOL(i8042_check_port_owner);
-
static void i8042_free_irqs(void)
{
if (i8042_aux_irq_registered)
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
index 1db0a40..7de98ac 100644
--- a/drivers/input/serio/i8042.h
+++ b/drivers/input/serio/i8042.h
@@ -54,13 +54,6 @@
#define I8042_BUFFER_SIZE 16
/*
- * Number of AUX ports on controllers supporting active multiplexing
- * specification
- */
-
-#define I8042_NUM_MUX_PORTS 4
-
-/*
* Debug.
*/
diff --git a/drivers/input/serio/libi8042.c b/drivers/input/serio/libi8042.c
new file mode 100644
index 0000000..4505bac
--- /dev/null
+++ b/drivers/input/serio/libi8042.c
@@ -0,0 +1,60 @@
+/*
+ * i8042 driver shared dependencies
+ *
+ * Copyright (c) 1999-2004 Vojtech Pavlik
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/libi8042.h>
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_DESCRIPTION("i8042 driver shared dependencies");
+MODULE_LICENSE("GPL");
+
+/*
+ * Writers to AUX and KBD ports as well as users issuing i8042_command
+ * directly should acquire i8042_mutex (by means of calling
+ * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that
+ * they do not disturb each other (unfortunately in many i8042
+ * implementations write to one of the ports will immediately abort
+ * command that is being processed by another port).
+ */
+static DEFINE_MUTEX(i8042_mutex);
+
+struct i8042_port i8042_ports[I8042_NUM_PORTS];
+EXPORT_SYMBOL(i8042_ports);
+
+void i8042_lock_chip(void)
+{
+ mutex_lock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_lock_chip);
+
+void i8042_unlock_chip(void)
+{
+ mutex_unlock(&i8042_mutex);
+}
+EXPORT_SYMBOL(i8042_unlock_chip);
+
+/*
+ * Checks whether port belongs to i8042 controller.
+ */
+bool i8042_check_port_owner(const struct serio *port)
+{
+ int i;
+
+ for (i = 0; i < I8042_NUM_PORTS; i++)
+ if (i8042_ports[i].serio == port)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(i8042_check_port_owner);
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 316f2c8..62c0059 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -17,7 +17,7 @@
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/serio.h>
-#include <linux/i8042.h>
+#include <linux/libi8042.h>
#include <linux/libps2.h>
#define DRIVER_DESC "PS/2 driver library"
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 0f9bafa..77aed40 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -8,6 +8,7 @@
*/
#include <linux/types.h>
+#include <linux/libi8042.h>
/*
* Standard commands.
@@ -59,10 +60,7 @@ struct serio;
#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
-void i8042_lock_chip(void);
-void i8042_unlock_chip(void);
int i8042_command(unsigned char *param, int command);
-bool i8042_check_port_owner(const struct serio *);
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio));
int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
@@ -70,24 +68,11 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
#else
-static inline void i8042_lock_chip(void)
-{
-}
-
-static inline void i8042_unlock_chip(void)
-{
-}
-
static inline int i8042_command(unsigned char *param, int command)
{
return -ENODEV;
}
-static inline bool i8042_check_port_owner(const struct serio *serio)
-{
- return false;
-}
-
static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
diff --git a/include/linux/libi8042.h b/include/linux/libi8042.h
new file mode 100644
index 0000000..5a730f0
--- /dev/null
+++ b/include/linux/libi8042.h
@@ -0,0 +1,55 @@
+#ifndef _LINUX_LIBI8042_H
+#define _LINUX_LIBI8042_H
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+
+/*
+ * Number of AUX ports on controllers supporting active multiplexing
+ * specification
+ */
+
+#define I8042_NUM_MUX_PORTS 4
+#define I8042_NUM_PORTS (I8042_NUM_MUX_PORTS + 2)
+
+struct serio;
+
+struct i8042_port {
+ struct serio *serio;
+ int irq;
+ bool exists;
+ bool driver_bound;
+ signed char mux;
+};
+
+#if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
+
+extern struct i8042_port i8042_ports[I8042_NUM_PORTS];
+
+void i8042_lock_chip(void);
+void i8042_unlock_chip(void);
+bool i8042_check_port_owner(const struct serio *);
+
+#else
+
+static inline void i8042_lock_chip(void)
+{
+}
+
+static inline void i8042_unlock_chip(void)
+{
+}
+
+static inline bool i8042_check_port_owner(const struct serio *serio)
+{
+ return false;
+}
+
+#endif
+
+#endif
--
2.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
[not found] <CADemMPNEv+kq21rXQMmB_BjgTsnEjscOCS5A02VAapOOM-ryMA@mail.gmail.com>
@ 2016-07-25 21:01 ` Dmitry Torokhov
2016-07-25 22:15 ` Mark Laws
0 siblings, 1 reply; 18+ messages in thread
From: Dmitry Torokhov @ 2016-07-25 21:01 UTC (permalink / raw)
To: Mark Laws; +Cc: KY Srinivasan, Van De Ven, Arjan, Linux Input
[ resending to inlude the list ]
Hi Mark,
On Tue, Jul 19, 2016 at 06:22:57PM -0700, Mark Laws wrote:
> On Tue, Jul 19, 2016 at 4:34 PM, KY Srinivasan <kys@microsoft.com> wrote:
> >> -----Original Message-----
> >> From: Mark Laws [mailto:mdl@60hz.org]
> >> Sent: Tuesday, July 19, 2016 1:29 AM
> >> To: Van De Ven, Arjan <arjan.van.de.ven@intel.com>
> >> Cc: KY Srinivasan <kys@microsoft.com>
> >> Subject: Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2
> >> Hyper-V VMs
> >>
> >> On Tue, Jun 21, 2016 at 7:41 PM, Mark Laws <mdl@60hz.org> wrote:
> >> > On Wed, Jun 22, 2016 at 11:36 AM, Van De Ven, Arjan
> >> > <arjan.van.de.ven@intel.com> wrote:
> >> >>> Hi KY and Arjan,
> >> >>>
> >> >>> Does anything remain to be fixed in this patch?
> >> >>
> >> >> it works great for me.... 8042 is no longer on my radar of trouble makers...
> >> >
> >> > Glad to hear it. I hope it can get merged soon, as it's surely been a
> >> > nuisance for at least a few other folks.
> >>
> >> Hi,
> >>
> >> Is there anyone I should ping about getting this merged? Should I CC
> >> Dmitry again?
> >
> > Please do.
> >
> > K. Y
>
> Hi Dmitry,
>
> Could you please take a look at the patch earlier in this thread and
> merge it if it's OK? K.Y. and Arjan have said it's good. I can provide
> a rebased version if needed, though I think the one from this thread
> should apply cleanly.
Sorry for the delay, the reason is that I absolutely hated exporting the
ports array from i8042 and into yet another module. Even though I was
the author of i8042_check_port_owner() I do not like this mechanism at
all and I think it is worse than doing a small layer violation and
having a shared PS/2 mutex directly in serio port structure.
Can you please tell me if the patch below solves the issue for you?
Thanks!
--
Dmitry
Input: i8042 - break load dependency between atkbd/psmouse and i8042
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com we
have a hard load dependency between i8042 and atkbd which prevents
keyboard from working on Gen2 Hyper-V VMs:
> hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
> driver like atkbd.c. atkbd.c depends on libps2.c because it invokes
> ps2_command(). libps2.c depends on i8042.c because it invokes
> i8042_check_port_owner(). As a result, hyperv_keyboard actually
> depends on i8042.c.
>
> For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
> Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
> rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
> no i8042 device emulated) and finally hyperv_keyboard can't work and
> the user can't input: https://bugs.archlinux.org/task/39820
> (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
To break the dependency we move away from using i8042_check_port_owner()
and instead allow serio port owner specify a mutex that clients should use
to serialize PS/2 command stream.
Reported-by: Mark Laws <mdl@60hz.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/serio/i8042.c | 16 +---------------
drivers/input/serio/libps2.c | 10 ++++------
include/linux/i8042.h | 6 ------
include/linux/serio.h | 24 +++++++++++++++++++-----
4 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 4541957..b4d3408 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1277,6 +1277,7 @@ static int __init i8042_create_kbd_port(void)
serio->start = i8042_start;
serio->stop = i8042_stop;
serio->close = i8042_port_close;
+ serio->ps2_cmd_mutex = &i8042_mutex;
serio->port_data = port;
serio->dev.parent = &i8042_platform_device->dev;
strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name));
@@ -1373,21 +1374,6 @@ static void i8042_unregister_ports(void)
}
}
-/*
- * Checks whether port belongs to i8042 controller.
- */
-bool i8042_check_port_owner(const struct serio *port)
-{
- int i;
-
- for (i = 0; i < I8042_NUM_PORTS; i++)
- if (i8042_ports[i].serio == port)
- return true;
-
- return false;
-}
-EXPORT_SYMBOL(i8042_check_port_owner);
-
static void i8042_free_irqs(void)
{
if (i8042_aux_irq_registered)
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 316f2c8..83e9c66 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -56,19 +56,17 @@ EXPORT_SYMBOL(ps2_sendbyte);
void ps2_begin_command(struct ps2dev *ps2dev)
{
- mutex_lock(&ps2dev->cmd_mutex);
+ struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
- if (i8042_check_port_owner(ps2dev->serio))
- i8042_lock_chip();
+ mutex_lock(m);
}
EXPORT_SYMBOL(ps2_begin_command);
void ps2_end_command(struct ps2dev *ps2dev)
{
- if (i8042_check_port_owner(ps2dev->serio))
- i8042_unlock_chip();
+ struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
- mutex_unlock(&ps2dev->cmd_mutex);
+ mutex_unlock(m);
}
EXPORT_SYMBOL(ps2_end_command);
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 0f9bafa..d98780c 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -62,7 +62,6 @@ struct serio;
void i8042_lock_chip(void);
void i8042_unlock_chip(void);
int i8042_command(unsigned char *param, int command);
-bool i8042_check_port_owner(const struct serio *);
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio));
int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
@@ -83,11 +82,6 @@ static inline int i8042_command(unsigned char *param, int command)
return -ENODEV;
}
-static inline bool i8042_check_port_owner(const struct serio *serio)
-{
- return false;
-}
-
static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
diff --git a/include/linux/serio.h b/include/linux/serio.h
index df4ab5d..c733cff 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -31,7 +31,8 @@ struct serio {
struct serio_device_id id;
- spinlock_t lock; /* protects critical sections from port's interrupt handler */
+ /* Protects critical sections from port's interrupt handler */
+ spinlock_t lock;
int (*write)(struct serio *, unsigned char);
int (*open)(struct serio *);
@@ -40,16 +41,29 @@ struct serio {
void (*stop)(struct serio *);
struct serio *parent;
- struct list_head child_node; /* Entry in parent->children list */
+ /* Entry in parent->children list */
+ struct list_head child_node;
struct list_head children;
- unsigned int depth; /* level of nesting in serio hierarchy */
+ /* Level of nesting in serio hierarchy */
+ unsigned int depth;
- struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
- struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
+ /*
+ * serio->drv is accessed from interrupt handlers; when modifying
+ * caller should acquire serio->drv_mutex and serio->lock.
+ */
+ struct serio_driver *drv;
+ /* Protects serio->drv so attributes can pin current driver */
+ struct mutex drv_mutex;
struct device dev;
struct list_head node;
+
+ /*
+ * For use by PS/2 layer when several ports share hardware and
+ * may get indigestion when exposed to concurrent access (i8042).
+ */
+ struct mutex *ps2_cmd_mutex;
};
#define to_serio_port(d) container_of(d, struct serio, dev)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs
2016-07-25 21:01 ` [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs Dmitry Torokhov
@ 2016-07-25 22:15 ` Mark Laws
0 siblings, 0 replies; 18+ messages in thread
From: Mark Laws @ 2016-07-25 22:15 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: KY Srinivasan, Van De Ven, Arjan, Linux Input
On Tue, Jul 26, 2016 at 6:01 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> [ resending to inlude the list ]
>
> Hi Mark,
>
> (snip)
>
> Can you please tell me if the patch below solves the issue for you?
>
> Thanks!
Hi Dmitry,
No worries about the delay! I tested your patch just now and I can
confirm it solves the issue.
Regards,
Mark Laws
--
|v\ /\ |\ |< |_ /\ \^| //
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-07-25 22:16 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CADemMPNEv+kq21rXQMmB_BjgTsnEjscOCS5A02VAapOOM-ryMA@mail.gmail.com>
2016-07-25 21:01 ` [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs Dmitry Torokhov
2016-07-25 22:15 ` Mark Laws
2016-06-13 14:38 Mark Laws
2016-06-13 14:38 ` Mark Laws
2016-06-13 20:45 ` [PATCH] [PATCH] Input: i8042 - Fix console keyboard support on Mark Laws
2016-06-13 20:45 ` [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs Mark Laws
-- strict thread matches above, loose matches on Subject: below --
2014-08-12 3:30 [PATCH] Input: serio: make HYPERV_KEYBOARD depend on SERIO_I8042=y Dexuan Cui
2016-04-18 15:23 ` [PATCH] Input: i8042 - Fix console keyboard support on Gen2 Hyper-V VMs Mark Laws
2016-04-18 15:23 ` Mark Laws
2016-04-18 16:54 ` Dan Carpenter
2016-04-18 17:24 ` Mark Laws
2016-04-18 20:36 ` Dan Carpenter
2016-04-18 22:00 ` Mark Laws
2016-04-19 8:22 ` Dan Carpenter
2016-04-19 10:46 ` Mark Laws
2016-04-22 13:00 ` Mark Laws
2016-04-22 13:01 ` Mark Laws
2016-04-22 13:17 ` Dan Carpenter
2016-04-22 17:30 ` Mark Laws
2016-04-22 17:30 ` Mark Laws
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).