]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fixes for 4.4
authorSasha Levin <sashal@kernel.org>
Wed, 15 Jan 2020 02:49:08 +0000 (21:49 -0500)
committerSasha Levin <sashal@kernel.org>
Wed, 15 Jan 2020 02:49:08 +0000 (21:49 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.4/hid-hidraw-fix-returning-epollout-from-hidraw_poll.patch [new file with mode: 0644]
queue-4.4/hid-hidraw-uhid-always-report-epollout.patch [new file with mode: 0644]
queue-4.4/hidraw-return-epollout-from-hidraw_poll.patch [new file with mode: 0644]
queue-4.4/series [new file with mode: 0644]

diff --git a/queue-4.4/hid-hidraw-fix-returning-epollout-from-hidraw_poll.patch b/queue-4.4/hid-hidraw-fix-returning-epollout-from-hidraw_poll.patch
new file mode 100644 (file)
index 0000000..283434a
--- /dev/null
@@ -0,0 +1,48 @@
+From e4a11775a38399cb7869eb1e531feedba4ca80d0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Dec 2019 03:37:13 +0100
+Subject: HID: hidraw: Fix returning EPOLLOUT from hidraw_poll
+
+From: Marcel Holtmann <marcel@holtmann.org>
+
+[ Upstream commit 9f3b61dc1dd7b81e99e7ed23776bb64a35f39e1a ]
+
+When polling a connected /dev/hidrawX device, it is useful to get the
+EPOLLOUT when writing is possible. Since writing is possible as soon as
+the device is connected, always return it.
+
+Right now EPOLLOUT is only returned when there are also input reports
+are available. This works if devices start sending reports when
+connected, but some HID devices might need an output report first before
+sending any input reports. This change will allow using EPOLLOUT here as
+well.
+
+Fixes: 378b80370aa1 ("hidraw: Return EPOLLOUT from hidraw_poll")
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Cc: stable@vger.kernel.org
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hidraw.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
+index 27d2f5a48a11..e60d9c88bd35 100644
+--- a/drivers/hid/hidraw.c
++++ b/drivers/hid/hidraw.c
+@@ -265,10 +265,10 @@ static unsigned int hidraw_poll(struct file *file, poll_table *wait)
+       poll_wait(file, &list->hidraw->wait, wait);
+       if (list->head != list->tail)
+-              return POLLIN | POLLRDNORM | POLLOUT;
++              return POLLIN | POLLRDNORM;
+       if (!list->hidraw->exist)
+               return POLLERR | POLLHUP;
+-      return 0;
++      return POLLOUT | POLLWRNORM;
+ }
+ static int hidraw_open(struct inode *inode, struct file *file)
+-- 
+2.20.1
+
diff --git a/queue-4.4/hid-hidraw-uhid-always-report-epollout.patch b/queue-4.4/hid-hidraw-uhid-always-report-epollout.patch
new file mode 100644 (file)
index 0000000..5b85b85
--- /dev/null
@@ -0,0 +1,69 @@
+From 26ff3058f5f38b21ab570dd9a6cfd7054f9d073b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Jan 2020 15:32:51 +0100
+Subject: HID: hidraw, uhid: Always report EPOLLOUT
+
+From: Jiri Kosina <jkosina@suse.cz>
+
+[ Upstream commit 9e635c2851df6caee651e589fbf937b637973c91 ]
+
+hidraw and uhid device nodes are always available for writing so we should
+always report EPOLLOUT and EPOLLWRNORM bits, not only in the cases when
+there is nothing to read.
+
+Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
+Fixes: be54e7461ffdc ("HID: uhid: Fix returning EPOLLOUT from uhid_char_poll")
+Fixes: 9f3b61dc1dd7b ("HID: hidraw: Fix returning EPOLLOUT from hidraw_poll")
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hidraw.c | 7 ++++---
+ drivers/hid/uhid.c   | 5 +++--
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
+index e60d9c88bd35..ef9e196b54a5 100644
+--- a/drivers/hid/hidraw.c
++++ b/drivers/hid/hidraw.c
+@@ -262,13 +262,14 @@ out:
+ static unsigned int hidraw_poll(struct file *file, poll_table *wait)
+ {
+       struct hidraw_list *list = file->private_data;
++      unsigned int mask = POLLOUT | POLLWRNORM; /* hidraw is always writable */
+       poll_wait(file, &list->hidraw->wait, wait);
+       if (list->head != list->tail)
+-              return POLLIN | POLLRDNORM;
++              mask |= POLLIN | POLLRDNORM;
+       if (!list->hidraw->exist)
+-              return POLLERR | POLLHUP;
+-      return POLLOUT | POLLWRNORM;
++              mask |= POLLERR | POLLHUP;
++      return mask;
+ }
+ static int hidraw_open(struct inode *inode, struct file *file)
+diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
+index ea0c860ee842..a7ba4db8cff7 100644
+--- a/drivers/hid/uhid.c
++++ b/drivers/hid/uhid.c
+@@ -769,13 +769,14 @@ unlock:
+ static unsigned int uhid_char_poll(struct file *file, poll_table *wait)
+ {
+       struct uhid_device *uhid = file->private_data;
++      unsigned int mask = POLLOUT | POLLWRNORM; /* uhid is always writable */
+       poll_wait(file, &uhid->waitq, wait);
+       if (uhid->head != uhid->tail)
+-              return POLLIN | POLLRDNORM;
++              mask |= POLLIN | POLLRDNORM;
+-      return EPOLLOUT | EPOLLWRNORM;
++      return mask;
+ }
+ static const struct file_operations uhid_fops = {
+-- 
+2.20.1
+
diff --git a/queue-4.4/hidraw-return-epollout-from-hidraw_poll.patch b/queue-4.4/hidraw-return-epollout-from-hidraw_poll.patch
new file mode 100644 (file)
index 0000000..f9e8cf1
--- /dev/null
@@ -0,0 +1,40 @@
+From 883f93b3162a8500ff47c62bff39ac68f3ef48ce Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 9 Jul 2019 13:03:37 +0200
+Subject: hidraw: Return EPOLLOUT from hidraw_poll
+
+From: Fabian Henneke <fabian.henneke@gmail.com>
+
+[ Upstream commit 378b80370aa1fe50f9c48a3ac8af3e416e73b89f ]
+
+Always return EPOLLOUT from hidraw_poll when a device is connected.
+This is safe since writes are always possible (but will always block).
+
+hidraw does not support non-blocking writes and instead always calls
+blocking backend functions on write requests. Hence, so far, a call to
+poll never returned EPOLLOUT, which confuses tools like socat.
+
+Signed-off-by: Fabian Henneke <fabian.henneke@gmail.com>
+In-reply-to: <CA+hv5qkyis03CgYTWeWX9cr0my-d2Oe+aZo+mjmWRXgjrGqyrw@mail.gmail.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hidraw.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
+index 627a24d3ea7c..27d2f5a48a11 100644
+--- a/drivers/hid/hidraw.c
++++ b/drivers/hid/hidraw.c
+@@ -265,7 +265,7 @@ static unsigned int hidraw_poll(struct file *file, poll_table *wait)
+       poll_wait(file, &list->hidraw->wait, wait);
+       if (list->head != list->tail)
+-              return POLLIN | POLLRDNORM;
++              return POLLIN | POLLRDNORM | POLLOUT;
+       if (!list->hidraw->exist)
+               return POLLERR | POLLHUP;
+       return 0;
+-- 
+2.20.1
+
diff --git a/queue-4.4/series b/queue-4.4/series
new file mode 100644 (file)
index 0000000..4d1cfae
--- /dev/null
@@ -0,0 +1,3 @@
+hidraw-return-epollout-from-hidraw_poll.patch
+hid-hidraw-fix-returning-epollout-from-hidraw_poll.patch
+hid-hidraw-uhid-always-report-epollout.patch