Skip to contentSkip to conversation

Fixes to v5.11

PATCH New Leon Romanovsky 1 participant 3 messages Jan 25, 2021 – Jan 26, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

cover Fixes to v5.11

From: Leon Romanovsky <[email protected]>

v1:
* Improved grammar and add wake call to ib_umad_kill_port()
v0: https://lore.kernel.org/linux-rdma/[email protected]/

Shay Drory (2):
IB/umad: Return EIO in case of when device disassociated IB/umad: Return EPOLLERR in case of when device disassociated

 drivers/infiniband/core/user_mad.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

--
2.29.2

#1 lore raw

PATCH 1/2 IB/umad: Return EIO in case of when device disassociated

From: Shay Drory <[email protected]>

MAD message received by the user has EINVAL error in all flows including when the device is disassociated. That makes it impossible for the applications to treat such flow differently.

Change it to return EIO, so the applications will be able to perform disassociation recovery.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/infiniband/core/user_mad.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/core/user_mad.c +6 -1
index 19104a675691..7ec1918431f7 100644
@@ -379,6 +379,11 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf,
 
 	mutex_lock(&file->mutex);
 
+	if (file->agents_dead) {
+		mutex_unlock(&file->mutex);
+		return -EIO;
+	}
+
 	while (list_empty(&file->recv_list)) {
 		mutex_unlock(&file->mutex);
 
@@ -524,7 +529,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 
 	agent = __get_agent(file, packet->mad.hdr.id);
 	if (!agent) {
-		ret = -EINVAL;
+		ret = -EIO;
 		goto err_up;
 	}
 
Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/2 IB/umad: Return EPOLLERR in case of when device disassociated

In reply to Leon Romanovsky

From: Shay Drory <[email protected]>

Currently, polling a umad device will always works, even if the device was disassociated. A disassociated device should immediately return EPOLLERR from poll(). Otherwise userspace is endlessly hung on poll() with no idea that the device has been removed from the system.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/infiniband/core/user_mad.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/infiniband/core/user_mad.c +10 -0
index 7ec1918431f7..dd7f3b437c6b 100644
@@ -397,6 +397,11 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf,
 		mutex_lock(&file->mutex);
 	}
 
+	if (file->agents_dead) {
+		mutex_unlock(&file->mutex);
+		return -EIO;
+	}
+
 	packet = list_entry(file->recv_list.next, struct ib_umad_packet, list);
 	list_del(&packet->list);
 
@@ -658,10 +663,14 @@ static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
 	/* we will always be able to post a MAD send */
 	__poll_t mask = EPOLLOUT | EPOLLWRNORM;
 
+	mutex_lock(&file->mutex);
 	poll_wait(filp, &file->recv_wait, wait);
 
 	if (!list_empty(&file->recv_list))
 		mask |= EPOLLIN | EPOLLRDNORM;
+	if (file->agents_dead)
+		mask = EPOLLERR;
+	mutex_unlock(&file->mutex);
 
 	return mask;
 }
@@ -1341,6 +1350,7 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
 	list_for_each_entry(file, &port->file_list, port_list) {
 		mutex_lock(&file->mutex);
 		file->agents_dead = 1;
+		wake_up_interruptible(&file->recv_wait);
 		mutex_unlock(&file->mutex);
 
 		for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id)
Signature · 1 line
2.29.2