stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Mark Laws <mdl@60hz.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: [PATCH 4.4 089/113] Input: i8042 - break load dependency between atkbd/psmouse and i8042
Date: Mon,  5 Sep 2016 18:44:52 +0200	[thread overview]
Message-ID: <20160905164352.979688538@linuxfoundation.org> (raw)
In-Reply-To: <20160905164349.217621339@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

commit 4097461897df91041382ff6fcd2bfa7ee6b2448c 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 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(-)

--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1277,6 +1277,7 @@ static int __init i8042_create_kbd_port(
 	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)
--- 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);
 
--- 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
 	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))
 {
--- 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)
 



  parent reply	other threads:[~2016-09-05 16:55 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160905164958uscas1p289eb6febd0bd03618ab344d7b8bdeac3@uscas1p2.samsung.com>
2016-09-05 16:43 ` [PATCH 4.4 000/113] 4.4.20-stable review Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 001/113] hugetlb: fix nr_pmds accounting with shared page tables Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 002/113] x86/mm: Disable preemption during CR3 read+write Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 003/113] uprobes/x86: Fix RIP-relative handling of EVEX-encoded instructions Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 004/113] tools/testing/nvdimm: fix SIGTERM vs hotplug crash Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 005/113] SUNRPC: Handle EADDRNOTAVAIL on connection failures Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 007/113] powerpc/eeh: eeh_pci_enable(): fix checking of post-request state Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 008/113] ALSA: usb-audio: Add a sample rate quirk for Creative Live! Cam Socialize HD (VF0610) Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 009/113] ALSA: usb-audio: Add quirk for ELP HD USB Camera Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 010/113] arm64: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 011/113] parisc: Fix order of EREFUSED define in errno.h Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 012/113] virtio: fix memory leak in virtqueue_add() Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 013/113] vfio/pci: Fix NULL pointer oops in error interrupt setup handling Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 014/113] perf intel-pt: Fix occasional decoding errors when tracing system-wide Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 015/113] libnvdimm, nd_blk: mask off reserved status bits Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 016/113] ALSA: hda - Manage power well properly for resume Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 017/113] NVMe: Dont unmap controller registers on reset Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 018/113] PCI: Support PCIe devices with short cfg_size Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 019/113] PCI: Add Netronome vendor and device IDs Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 020/113] PCI: Limit config space size for Netronome NFP6000 family Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 021/113] PCI: Add Netronome NFP4000 PF device ID Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 022/113] PCI: Limit config space size for Netronome NFP4000 Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 024/113] ACPI: CPPC: Return error if _CPC is invalid on a CPU Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 025/113] ACPI / CPPC: Prevent cpc_desc_ptr points to the invalid data Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 026/113] um: Dont discard .text.exit section Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 027/113] genirq/msi: Remove unused MSI_FLAG_IDENTITY_MAP Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 028/113] genirq/msi: Make sure PCI MSIs are activated early Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 029/113] crypto: caam - fix non-hmac hashes Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 032/113] usb: ehci: change order of register cleanup during shutdown Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 033/113] usb: misc: usbtest: add fix for driver hang Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 034/113] usb: dwc3: pci: add Intel Kabylake PCI ID Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 035/113] usb: dwc3: gadget: increment request->actual once Greg Kroah-Hartman
2016-09-05 16:43   ` [PATCH 4.4 036/113] usb: define USB_SPEED_SUPER_PLUS speed for SuperSpeedPlus USB3.1 devices Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 037/113] usb: hub: Fix unbalanced reference count/memory leak/deadlocks Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 038/113] USB: hub: fix up early-exit pathway in hub_activate Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 039/113] USB: hub: change the locking " Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 040/113] usb: renesas_usbhs: clear the BRDYSTS in usbhsg_ep_enable() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 041/113] usb: renesas_usbhs: Use dmac only if the pipe type is bulk Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 042/113] USB: validate wMaxPacketValue entries in endpoint descriptors Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 043/113] usb: gadget: fsl_qe_udc: off by one in setup_received_handle() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 044/113] usb/gadget: fix gadgetfs aio support Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 045/113] xhci: always handle "Command Ring Stopped" events Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 046/113] usb: xhci: Fix panic if disconnect Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 047/113] xhci: dont dereference a xhci member after removing xhci Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 048/113] USB: serial: fix memleak in driver-registration error path Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 049/113] USB: serial: option: add D-Link DWM-156/A3 Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 050/113] USB: serial: option: add support for Telit LE920A4 Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 051/113] USB: serial: ftdi_sio: add device ID for WICED USB UART dev board Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 053/113] xhci: Make sure xhci handles USB_SPEED_SUPER_PLUS devices Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 054/113] iommu/dma: Dont put uninitialised IOVA domains Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 055/113] iommu/arm-smmu: Fix CMDQ error handling Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 056/113] iommu/arm-smmu: Dont BUG() if we find aborting STEs with disable_bypass Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 058/113] EDAC: Increment correct counter in edac_inc_ue_error() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 059/113] s390/dasd: fix hanging device after clear subchannel Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 060/113] mac80211: fix purging multicast PS buffer queue Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 061/113] arm64: dts: rockchip: add reset saradc node for rk3368 SoCs Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 062/113] of: fix reference counting in of_graph_get_endpoint_by_regs Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 063/113] sched/cputime: Fix NO_HZ_FULL getrusage() monotonicity regression Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 064/113] sched/nohz: Fix affine unpinned timers mess Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 065/113] iio: fix sched WARNING "do not call blocking ops when !TASK_RUNNING" Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 070/113] drm/amd/amdgpu: sdma resume fail during S4 on CI Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 072/113] drm/i915: fix aliasing_ppgtt leak Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 073/113] ARC: build: Better way to detect ISA compatible toolchain Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 074/113] ARC: use correct offset in pt_regs for saving/restoring user mode r25 Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 075/113] ARC: Call trace_hardirqs_on() before enabling irqs Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 076/113] ARC: Elide redundant setup of DMA callbacks Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 077/113] aacraid: Check size values after double-fetch from user Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 078/113] mfd: cros_ec: Add cros_ec_cmd_xfer_status() helper Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 079/113] i2c: cros-ec-tunnel: Fix usage of cros_ec_cmd_xfer() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 080/113] cdc-acm: fix wrong pipe type on rx interrupt xfers Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 081/113] mpt3sas: Fix resume on WarpDrive flash cards Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 082/113] megaraid_sas: Fix probing cards without io port Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 083/113] usb: renesas_usbhs: gadget: fix return value check in usbhs_mod_gadget_probe() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 084/113] gpio: Fix OF build problem on UM Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 085/113] fs/seq_file: fix out-of-bounds read Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 086/113] btrfs: waiting on qgroup rescan should not always be interruptible Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 087/113] btrfs: properly track when rescan worker is running Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 088/113] Input: tegra-kbc - fix inverted reset logic Greg Kroah-Hartman
2016-09-05 16:44   ` Greg Kroah-Hartman [this message]
2016-09-05 16:44   ` [PATCH 4.4 090/113] Input: i8042 - set up shared ps2_cmd_mutex for AUX ports Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 091/113] crypto: nx - off by one bug in nx_of_update_msc() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 092/113] crypto: qat - fix aes-xts key sizes Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 093/113] dmaengine: usb-dmac: check CHCR.DE bit in usb_dmac_isr_channel() Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 095/113] usb: chipidea: udc: dont touch DP when controller is in host mode Greg Kroah-Hartman
2016-09-05 16:44   ` [PATCH 4.4 096/113] USB: fix typo in wMaxPacketSize validation Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 097/113] USB: serial: mos7720: fix non-atomic allocation in write path Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 098/113] USB: serial: mos7840: " Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 099/113] USB: serial: option: add WeTelecom WM-D200 Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 100/113] USB: serial: option: add WeTelecom 0x6802 and 0x6803 products Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 101/113] staging: comedi: daqboard2000: bug fix board type matching code Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 103/113] staging: comedi: ni_mio_common: fix AO inttrig backwards compatibility Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 105/113] ACPI / drivers: fix typo in ACPI_DECLARE_PROBE_ENTRY macro Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 106/113] ACPI / drivers: replace acpi_probe_lock spinlock with mutex Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 107/113] ACPI / sysfs: fix error code in get_status() Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 108/113] ACPI / SRAT: fix SRAT parsing order with both LAPIC and X2APIC present Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 109/113] ALSA: line6: Remove double line6_pcm_release() after failed acquire Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 110/113] ALSA: line6: Give up on the lock while URBs are released Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 111/113] ALSA: line6: Fix POD sysfs attributes segfault Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 112/113] hwmon: (iio_hwmon) fix memory leak in name attribute Greg Kroah-Hartman
2016-09-05 16:45   ` [PATCH 4.4 113/113] sysfs: correctly handle read offset on PREALLOC attrs Greg Kroah-Hartman
2016-09-06 17:03   ` [PATCH 4.4 000/113] 4.4.20-stable review Guenter Roeck
2016-09-06 18:03   ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160905164352.979688538@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdl@60hz.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).