Fixes to v5.11
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
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.
--- drivers/infiniband/core/user_mad.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/core/user_mad.c +6 -1
@@ -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
PATCH 2/2 IB/umad: Return EPOLLERR in case of when device disassociated
In reply to Leon RomanovskyFrom: 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.
--- drivers/infiniband/core/user_mad.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/infiniband/core/user_mad.c +10 -0
@@ -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