> -----Original Message----- > From: Chip Bilbrey [mailto:c...@bilbrey.org] > Sent: Monday, November 6, 2017 12:33 AM > To: Oleksandr Shamray <oleksan...@mellanox.com> > Cc: gre...@linuxfoundation.org; a...@arndb.de; linux- > ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > devicet...@vger.kernel.org; open...@lists.ozlabs.org; j...@jms.id.au; > j...@resnulli.us; tklau...@distanz.ch; linux-ser...@vger.kernel.org; > m...@shout.net; Vadim Pasternak <vad...@mellanox.com>; system-sw-low- > level <system-sw-low-le...@mellanox.com>; robh...@kernel.org; openocd- > devel-ow...@lists.sourceforge.net; linux-...@vger.kernel.org; > da...@davemloft.net; mche...@kernel.org; Jiri Pirko <j...@mellanox.com> > Subject: Re: [v11,1/4] drivers: jtag: Add JTAG core driver > > > Oleksandr Shamray writes:
[..] > I notice the single-open()-per-device lock was dropped by request in an > earlier > revision of your patches, but multiple processes trying to drive a single JTAG > master could wreak serious havoc if transactions get interleaved. Would > something like an added JTAG_LOCKCHAIN/UNLOCKCHAIN > ioctl() for exclusive client access be reasonable to prevent this? > Yes, it dropped by recommendation of Greg KH <gre...@linuxfoundation.org>. Greg, what you can suggest about it. May be better to add again single-open()-per-device lock with right locking way like: >if (mutex_lock_interruptible(&jtag->open_lock)) { > return -ERESTARTSYS; >} > >if (jtag->opened) { > mutex_unlock(&jtag->open_lock); > return -EINVAL; >} > >nonseekable_open(inode, file); >file->private_data = jtag; >jtag->opened++; >mutex_unlock(&jtag->open_lock); > Thaks. > -Chip