* Re: [PATCH] staging: axis-fifo: fix sleep while holding mutex [not found] <20260203112029.27894-1-baran9arda@gmail.com> @ 2026-04-26 19:05 ` Greg KH 0 siblings, 0 replies; 3+ messages in thread From: Greg KH @ 2026-04-26 19:05 UTC (permalink / raw) To: Baran Arda; +Cc: ovidiu.panait.oss, gshahrouzi, linux-staging, linux-kernel On Tue, Feb 03, 2026 at 02:20:29PM +0300, Baran Arda wrote: > Signed-off-by: Baran Arda <baran9arda@gmail.com> > --- > drivers/staging/axis-fifo/axis-fifo.c | 30 ++++++++++++++------------- > 1 file changed, 16 insertions(+), 14 deletions(-) > > diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c > index 509d620d6ce7..21dc9521afab 100644 > --- a/drivers/staging/axis-fifo/axis-fifo.c > +++ b/drivers/staging/axis-fifo/axis-fifo.c > @@ -197,11 +197,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, > goto end_unlock; > } > } else { > - /* opened in blocking mode > - * wait for a packet available interrupt (or timeout) > - * if nothing is currently available > + /* > + * Opened in blocking mode. Wait for a packet available > + * interrupt (or timeout) before acquiring the lock. > */ > - mutex_lock(&fifo->read_lock); > ret = wait_event_interruptible_timeout(fifo->read_queue, > ioread32(fifo->base_addr + XLLF_RDFO_OFFSET), > read_timeout); > @@ -214,8 +213,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, > ret); > } > > - goto end_unlock; > + return ret; > } > + > + mutex_lock(&fifo->read_lock); > } > > bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET); > @@ -342,25 +343,26 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf, > } else { > /* opened in blocking mode */ > > - /* wait for an interrupt (or timeout) if there isn't > - * currently enough room in the fifo > + /* > + * Wait for a packet available > + * interrupt (or timeout) before acquiring the lock. > */ > - mutex_lock(&fifo->write_lock); > - ret = wait_event_interruptible_timeout(fifo->write_queue, > - ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > - >= words_to_write, > - write_timeout); > + ret = wait_event_interruptible_timeout(fifo->read_queue, > + ioread32(fifo->base_addr + XLLF_RDFO_OFFSET), > + read_timeout); > > if (ret <= 0) { > if (ret == 0) { > ret = -EAGAIN; > } else if (ret != -ERESTARTSYS) { > - dev_err(fifo->dt_device, "wait_event_interruptible_timeout() error in write (ret=%i)\n", > + dev_err(fifo->dt_device, "wait_event_interruptible_timeout() error in read (ret=%i)\n", > ret); > } > > - goto end_unlock; > + return ret; > } > + > + mutex_lock(&fifo->read_lock); > } > > txbuf = vmemdup_user(buf, len); > -- > 2.39.5 (Apple Git-154) > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what a proper Subject: line should look like. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] staging: axis-fifo: fix sleep while holding mutex @ 2026-02-03 11:36 Baran Arda 2026-02-03 11:43 ` Greg KH 0 siblings, 1 reply; 3+ messages in thread From: Baran Arda @ 2026-02-03 11:36 UTC (permalink / raw) To: gregkh Cc: ovidiu.panait.oss, gshahrouzi, linux-staging, linux-kernel, baran9arda The driver calls wait_event_interruptible_timeout() while holding a mutex. This can lead to a deadlock or poor performance as the mutex is held while the process is sleeping, preventing other processes from accessing the device. This patch moves the wait_event call outside of the mutex lock in both read and write operations. --- drivers/staging/axis-fifo/axis-fifo.c | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 509d620d6ce7..a651c59a80ea 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -197,11 +197,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, goto end_unlock; } } else { - /* opened in blocking mode - * wait for a packet available interrupt (or timeout) - * if nothing is currently available + /* + * Opened in blocking mode. Wait for a packet available + * interrupt (or timeout) before acquiring the lock. */ - mutex_lock(&fifo->read_lock); ret = wait_event_interruptible_timeout(fifo->read_queue, ioread32(fifo->base_addr + XLLF_RDFO_OFFSET), read_timeout); @@ -214,8 +213,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, ret); } - goto end_unlock; + return ret; } + + mutex_lock(&fifo->read_lock); } bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET); @@ -340,27 +341,26 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf, goto end_unlock; } } else { - /* opened in blocking mode */ - - /* wait for an interrupt (or timeout) if there isn't - * currently enough room in the fifo + /* + * Opened in blocking mode. Wait for enough room in the FIFO + * (or timeout) before acquiring the lock. */ - mutex_lock(&fifo->write_lock); ret = wait_event_interruptible_timeout(fifo->write_queue, ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) - >= words_to_write, + >= words_to_write, write_timeout); if (ret <= 0) { - if (ret == 0) { + if (ret == 0) ret = -EAGAIN; - } else if (ret != -ERESTARTSYS) { + else if (ret != -ERESTARTSYS) dev_err(fifo->dt_device, "wait_event_interruptible_timeout() error in write (ret=%i)\n", ret); - } - goto end_unlock; + return ret; } + + mutex_lock(&fifo->write_lock); } txbuf = vmemdup_user(buf, len); -- 2.39.5 (Apple Git-154) ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: axis-fifo: fix sleep while holding mutex 2026-02-03 11:36 Baran Arda @ 2026-02-03 11:43 ` Greg KH 0 siblings, 0 replies; 3+ messages in thread From: Greg KH @ 2026-02-03 11:43 UTC (permalink / raw) To: Baran Arda; +Cc: ovidiu.panait.oss, gshahrouzi, linux-staging, linux-kernel On Tue, Feb 03, 2026 at 02:36:51PM +0300, Baran Arda wrote: > The driver calls wait_event_interruptible_timeout() while holding a mutex. This can lead to a deadlock or poor performance as the mutex is held while the process is sleeping, preventing other processes from accessing the device. This patch moves the wait_event call outside of the mutex lock in both read and write operations. > --- > drivers/staging/axis-fifo/axis-fifo.c | 30 +++++++++++++-------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c > index 509d620d6ce7..a651c59a80ea 100644 > --- a/drivers/staging/axis-fifo/axis-fifo.c > +++ b/drivers/staging/axis-fifo/axis-fifo.c > @@ -197,11 +197,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, > goto end_unlock; > } > } else { > - /* opened in blocking mode > - * wait for a packet available interrupt (or timeout) > - * if nothing is currently available > + /* > + * Opened in blocking mode. Wait for a packet available > + * interrupt (or timeout) before acquiring the lock. > */ > - mutex_lock(&fifo->read_lock); > ret = wait_event_interruptible_timeout(fifo->read_queue, > ioread32(fifo->base_addr + XLLF_RDFO_OFFSET), > read_timeout); > @@ -214,8 +213,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, > ret); > } > > - goto end_unlock; > + return ret; > } > + > + mutex_lock(&fifo->read_lock); > } > > bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET); > @@ -340,27 +341,26 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf, > goto end_unlock; > } > } else { > - /* opened in blocking mode */ > - > - /* wait for an interrupt (or timeout) if there isn't > - * currently enough room in the fifo > + /* > + * Opened in blocking mode. Wait for enough room in the FIFO > + * (or timeout) before acquiring the lock. > */ > - mutex_lock(&fifo->write_lock); > ret = wait_event_interruptible_timeout(fifo->write_queue, > ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) > - >= words_to_write, > + >= words_to_write, > write_timeout); > > if (ret <= 0) { > - if (ret == 0) { > + if (ret == 0) > ret = -EAGAIN; > - } else if (ret != -ERESTARTSYS) { > + else if (ret != -ERESTARTSYS) > dev_err(fifo->dt_device, "wait_event_interruptible_timeout() error in write (ret=%i)\n", > ret); > - } > > - goto end_unlock; > + return ret; > } > + > + mutex_lock(&fifo->write_lock); > } > > txbuf = vmemdup_user(buf, len); > -- > 2.39.5 (Apple Git-154) > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - Your patch does not have a Signed-off-by: line. Please read the kernel file, Documentation/process/submitting-patches.rst and resend it after adding that line. Note, the line needs to be in the body of the email, before the patch, not at the bottom of the patch or in the email signature. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-27 3:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260203112029.27894-1-baran9arda@gmail.com>
2026-04-26 19:05 ` [PATCH] staging: axis-fifo: fix sleep while holding mutex Greg KH
2026-02-03 11:36 Baran Arda
2026-02-03 11:43 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox