mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] char: xillybus: use stream_open for stream semantics
@ 2026-10-31  8:36 mdshahid03
  2026-11-02 11:23 ` Eli Billauer
  0 siblings, 1 reply; 4+ messages in thread
From: mdshahid03 @ 2026-10-31  8:36 UTC (permalink / raw)
  To: eli.billauer; +Cc: arnd, gregkh, linux-kernel, Mohammad Shahid

From: Mohammad Shahid <mdshahid03@gmail.com>

The Xillybus uses nonseekable_open() in xillybus_open()
for non-seekable channels. However,its read and write
callbacks maintain their own buffer positions and do not
use the file position passed by VFS.

Use stream_open() to mark these channels as streams and
disable unnecessary file position handling,allowing read
and write operations to run concurrently.

This issue is reported by stream_open.cocci script as a
potential deadlock between read and write operations.

Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
 drivers/char/xillybus/xillybus_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c
index 7189c6d97e7d..92c526e84572 100644
--- a/drivers/char/xillybus/xillybus_core.c
+++ b/drivers/char/xillybus/xillybus_core.c
@@ -1607,7 +1607,7 @@ static int xillybus_open(struct inode *inode, struct file *filp)
 		mutex_unlock(&channel->wr_mutex);
 
 	if (!rc && (!channel->seekable))
-		return nonseekable_open(inode, filp);
+		return stream_open(inode, filp);
 
 	return rc;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] char: xillybus: use stream_open for stream semantics
  2026-10-31  8:36 [PATCH] char: xillybus: use stream_open for stream semantics mdshahid03
@ 2026-11-02 11:23 ` Eli Billauer
  2026-11-10 17:44   ` mdshahid03
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Billauer @ 2026-11-02 11:23 UTC (permalink / raw)
  To: mdshahid03; +Cc: arnd, gregkh, linux-kernel

Hello Mohammad,

On 31/10/2026 9:36, mdshahid03@gmail.com wrote:
> Use stream_open() to mark these channels as streams and
> disable unnecessary file position handling,

The difference between stream_open() and nonseekable_open() is that the 
former sets FMODE_STREAM and clears FMODE_ATOMIC_POS. I made a quick 
test run, and FMODE_ATOMIC_POS isn't set in either case. As 
FMODE_ATOMIC_POS is clear, no lock is taken while updating fpos either way.

So in effect, the only difference is that FMODE_STREAM is set. Frankly 
speaking, I'm not sure in what way this matters, if at all.

> allowing read
> and write operations to run concurrently.

I checked that with hardware. There's no problem running read() and 
write() concurrently even before this patch. And I don't see why there 
would be a problem.

It seems like FMODE_STREAM was supposed to replace FMODE_ATOMIC_POS 
somewhere back in 2019 with Linus' commit 0be0ee71816b ("vfs: properly 
and reliably lock f_pos in fdget_pos()"). That is where he urged the 
move towards stream_open(). But then he reverted it with commit 
2be7d348fe92 soon afterwards.

All in all, I don't know what to say about this. Calling stream_open() 
does sound more correct, and nothing broke with this patch. But I'm 
generally unhappy fiddling with code unless it fixes something.

Regards,
    Eli

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] char: xillybus: use stream_open for stream semantics
  2026-11-02 11:23 ` Eli Billauer
@ 2026-11-10 17:44   ` mdshahid03
  2026-12-06 14:36     ` mdshahid03
  0 siblings, 1 reply; 4+ messages in thread
From: mdshahid03 @ 2026-11-10 17:44 UTC (permalink / raw)
  To: Eli Billauer; +Cc: mdshahid03, arnd, gregkh, linux-kernel

Hi Eli,

Thanks for the detailed explanation and testing in HW.

I think, if this doesn not break anything and using stream_open()
for these channels more logical ,then ,it make sense to use it.

Thanks
Shahid.

On 2026-11-02 12:23 +0100, Eli Billauer wrote:
> Hello Mohammad,
> 
> On 31/10/2026 9:36, mdshahid03@gmail.com wrote:
> > Use stream_open() to mark these channels as streams and
> > disable unnecessary file position handling,
> 
> The difference between stream_open() and nonseekable_open() is that the 
> former sets FMODE_STREAM and clears FMODE_ATOMIC_POS. I made a quick 
> test run, and FMODE_ATOMIC_POS isn't set in either case. As 
> FMODE_ATOMIC_POS is clear, no lock is taken while updating fpos either way.
> 
> So in effect, the only difference is that FMODE_STREAM is set. Frankly 
> speaking, I'm not sure in what way this matters, if at all.
> 
> > allowing read
> > and write operations to run concurrently.
> 
> I checked that with hardware. There's no problem running read() and 
> write() concurrently even before this patch. And I don't see why there 
> would be a problem.
> 
> It seems like FMODE_STREAM was supposed to replace FMODE_ATOMIC_POS 
> somewhere back in 2019 with Linus' commit 0be0ee71816b ("vfs: properly 
> and reliably lock f_pos in fdget_pos()"). That is where he urged the 
> move towards stream_open(). But then he reverted it with commit 
> 2be7d348fe92 soon afterwards.
> 
> All in all, I don't know what to say about this. Calling stream_open() 
> does sound more correct, and nothing broke with this patch. But I'm 
> generally unhappy fiddling with code unless it fixes something.
> 
> Regards,
>     Eli
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] char: xillybus: use stream_open for stream semantics
  2026-11-10 17:44   ` mdshahid03
@ 2026-12-06 14:36     ` mdshahid03
  0 siblings, 0 replies; 4+ messages in thread
From: mdshahid03 @ 2026-12-06 14:36 UTC (permalink / raw)
  To: mdshahid03; +Cc: Eli Billauer, arnd, gregkh, linux-kernel

Hi Eli,

Hope you are doing well.

I also have a similar patch in the USB subsystem, which has been picked up by Greg KH:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=8e4f387616d40f0bde7b9c80e76fcc536f02a240

Do you think also this patch is suitable for merging as well?

Thanks
Shahid.

On 2026-11-10 23:14 +0530, mdshahid03@gmail.com wrote:
> Hi Eli,
> 
> Thanks for the detailed explanation and testing in HW.
> 
> I think, if this doesn not break anything and using stream_open()
> for these channels more logical ,then ,it make sense to use it.
> 
> Thanks
> Shahid.
> 
> On 2026-11-02 12:23 +0100, Eli Billauer wrote:
> > Hello Mohammad,
> > 
> > On 31/10/2026 9:36, mdshahid03@gmail.com wrote:
> > > Use stream_open() to mark these channels as streams and
> > > disable unnecessary file position handling,
> > 
> > The difference between stream_open() and nonseekable_open() is that the 
> > former sets FMODE_STREAM and clears FMODE_ATOMIC_POS. I made a quick 
> > test run, and FMODE_ATOMIC_POS isn't set in either case. As 
> > FMODE_ATOMIC_POS is clear, no lock is taken while updating fpos either way.
> > 
> > So in effect, the only difference is that FMODE_STREAM is set. Frankly 
> > speaking, I'm not sure in what way this matters, if at all.
> > 
> > > allowing read
> > > and write operations to run concurrently.
> > 
> > I checked that with hardware. There's no problem running read() and 
> > write() concurrently even before this patch. And I don't see why there 
> > would be a problem.
> > 
> > It seems like FMODE_STREAM was supposed to replace FMODE_ATOMIC_POS 
> > somewhere back in 2019 with Linus' commit 0be0ee71816b ("vfs: properly 
> > and reliably lock f_pos in fdget_pos()"). That is where he urged the 
> > move towards stream_open(). But then he reverted it with commit 
> > 2be7d348fe92 soon afterwards.
> > 
> > All in all, I don't know what to say about this. Calling stream_open() 
> > does sound more correct, and nothing broke with this patch. But I'm 
> > generally unhappy fiddling with code unless it fixes something.
> > 
> > Regards,
> >     Eli
> > 
> > 
> 
> 
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-06 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31  8:36 [PATCH] char: xillybus: use stream_open for stream semantics mdshahid03
2026-11-02 11:23 ` Eli Billauer
2026-11-10 17:44   ` mdshahid03
2026-12-06 14:36     ` mdshahid03

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®