2017-11-14 10:37:23

by Oleksandr Shamray

[permalink] [raw]
Subject: RE: [v11,1/4] drivers: jtag: Add JTAG core driver

> -----Original Message-----
> From: Chip Bilbrey [mailto:[email protected]]
> Sent: Monday, November 6, 2017 12:33 AM
> To: Oleksandr Shamray <[email protected]>
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; Vadim Pasternak <[email protected]>; system-sw-low-
> level <[email protected]>; [email protected]; openocd-
> [email protected]; [email protected];
> [email protected]; [email protected]; Jiri Pirko <[email protected]>
> 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 <[email protected]>.

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

From 1583329461455998157@xxx Mon Nov 06 15:04:01 +0000 2017
X-GM-THRID: 1583060999217857805
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread