mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2026-04-27 22:29:35 +02:00
commit 4097461897 upstream.
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>
Tested-by: Mark Laws <mdl@60hz.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
221 lines
5.3 KiB
C
221 lines
5.3 KiB
C
#ifndef _SERIO_H
|
|
#define _SERIO_H
|
|
|
|
/*
|
|
* Copyright (C) 1999-2002 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/ioctl.h>
|
|
|
|
#define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/list.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/device.h>
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
struct serio {
|
|
void *port_data;
|
|
|
|
char name[32];
|
|
char phys[32];
|
|
|
|
bool manual_bind;
|
|
|
|
struct serio_device_id id;
|
|
|
|
/* Protects critical sections from port's interrupt handler */
|
|
spinlock_t lock;
|
|
|
|
int (*write)(struct serio *, unsigned char);
|
|
int (*open)(struct serio *);
|
|
void (*close)(struct serio *);
|
|
int (*start)(struct serio *);
|
|
void (*stop)(struct serio *);
|
|
|
|
struct serio *parent;
|
|
/* Entry in parent->children list */
|
|
struct list_head child_node;
|
|
struct list_head children;
|
|
/* Level of nesting in serio hierarchy */
|
|
unsigned int depth;
|
|
|
|
/*
|
|
* 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)
|
|
|
|
struct serio_driver {
|
|
const char *description;
|
|
|
|
const struct serio_device_id *id_table;
|
|
bool manual_bind;
|
|
|
|
void (*write_wakeup)(struct serio *);
|
|
irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
|
|
int (*connect)(struct serio *, struct serio_driver *drv);
|
|
int (*reconnect)(struct serio *);
|
|
void (*disconnect)(struct serio *);
|
|
void (*cleanup)(struct serio *);
|
|
|
|
struct device_driver driver;
|
|
};
|
|
#define to_serio_driver(d) container_of(d, struct serio_driver, driver)
|
|
|
|
int serio_open(struct serio *serio, struct serio_driver *drv);
|
|
void serio_close(struct serio *serio);
|
|
void serio_rescan(struct serio *serio);
|
|
void serio_reconnect(struct serio *serio);
|
|
irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
|
|
|
|
void __serio_register_port(struct serio *serio, struct module *owner);
|
|
|
|
/* use a define to avoid include chaining to get THIS_MODULE */
|
|
#define serio_register_port(serio) \
|
|
__serio_register_port(serio, THIS_MODULE)
|
|
|
|
void serio_unregister_port(struct serio *serio);
|
|
void serio_unregister_child_port(struct serio *serio);
|
|
|
|
int __must_check __serio_register_driver(struct serio_driver *drv,
|
|
struct module *owner, const char *mod_name);
|
|
|
|
/* use a define to avoid include chaining to get THIS_MODULE & friends */
|
|
#define serio_register_driver(drv) \
|
|
__serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
|
|
|
|
void serio_unregister_driver(struct serio_driver *drv);
|
|
|
|
static inline int serio_write(struct serio *serio, unsigned char data)
|
|
{
|
|
if (serio->write)
|
|
return serio->write(serio, data);
|
|
else
|
|
return -1;
|
|
}
|
|
|
|
static inline void serio_drv_write_wakeup(struct serio *serio)
|
|
{
|
|
if (serio->drv && serio->drv->write_wakeup)
|
|
serio->drv->write_wakeup(serio);
|
|
}
|
|
|
|
/*
|
|
* Use the following functions to manipulate serio's per-port
|
|
* driver-specific data.
|
|
*/
|
|
static inline void *serio_get_drvdata(struct serio *serio)
|
|
{
|
|
return dev_get_drvdata(&serio->dev);
|
|
}
|
|
|
|
static inline void serio_set_drvdata(struct serio *serio, void *data)
|
|
{
|
|
dev_set_drvdata(&serio->dev, data);
|
|
}
|
|
|
|
/*
|
|
* Use the following functions to protect critical sections in
|
|
* driver code from port's interrupt handler
|
|
*/
|
|
static inline void serio_pause_rx(struct serio *serio)
|
|
{
|
|
spin_lock_irq(&serio->lock);
|
|
}
|
|
|
|
static inline void serio_continue_rx(struct serio *serio)
|
|
{
|
|
spin_unlock_irq(&serio->lock);
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
* bit masks for use in "interrupt" flags (3rd argument)
|
|
*/
|
|
#define SERIO_TIMEOUT 1
|
|
#define SERIO_PARITY 2
|
|
#define SERIO_FRAME 4
|
|
|
|
/*
|
|
* Serio types
|
|
*/
|
|
#define SERIO_XT 0x00
|
|
#define SERIO_8042 0x01
|
|
#define SERIO_RS232 0x02
|
|
#define SERIO_HIL_MLC 0x03
|
|
#define SERIO_PS_PSTHRU 0x05
|
|
#define SERIO_8042_XL 0x06
|
|
|
|
/*
|
|
* Serio protocols
|
|
*/
|
|
#define SERIO_UNKNOWN 0x00
|
|
#define SERIO_MSC 0x01
|
|
#define SERIO_SUN 0x02
|
|
#define SERIO_MS 0x03
|
|
#define SERIO_MP 0x04
|
|
#define SERIO_MZ 0x05
|
|
#define SERIO_MZP 0x06
|
|
#define SERIO_MZPP 0x07
|
|
#define SERIO_VSXXXAA 0x08
|
|
#define SERIO_SUNKBD 0x10
|
|
#define SERIO_WARRIOR 0x18
|
|
#define SERIO_SPACEORB 0x19
|
|
#define SERIO_MAGELLAN 0x1a
|
|
#define SERIO_SPACEBALL 0x1b
|
|
#define SERIO_GUNZE 0x1c
|
|
#define SERIO_IFORCE 0x1d
|
|
#define SERIO_STINGER 0x1e
|
|
#define SERIO_NEWTON 0x1f
|
|
#define SERIO_STOWAWAY 0x20
|
|
#define SERIO_H3600 0x21
|
|
#define SERIO_PS2SER 0x22
|
|
#define SERIO_TWIDKBD 0x23
|
|
#define SERIO_TWIDJOY 0x24
|
|
#define SERIO_HIL 0x25
|
|
#define SERIO_SNES232 0x26
|
|
#define SERIO_SEMTECH 0x27
|
|
#define SERIO_LKKBD 0x28
|
|
#define SERIO_ELO 0x29
|
|
#define SERIO_MICROTOUCH 0x30
|
|
#define SERIO_PENMOUNT 0x31
|
|
#define SERIO_TOUCHRIGHT 0x32
|
|
#define SERIO_TOUCHWIN 0x33
|
|
#define SERIO_TAOSEVM 0x34
|
|
#define SERIO_FUJITSU 0x35
|
|
#define SERIO_ZHENHUA 0x36
|
|
#define SERIO_INEXIO 0x37
|
|
#define SERIO_TOUCHIT213 0x38
|
|
#define SERIO_W8001 0x39
|
|
#define SERIO_DYNAPRO 0x3a
|
|
#define SERIO_HAMPSHIRE 0x3b
|
|
#define SERIO_PS2MULT 0x3c
|
|
#define SERIO_TSC40 0x3d
|
|
|
|
#endif
|