All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: guido@kiener-muenchen.de
Cc: dpenkler@gmail.com, steve_bayless@keysight.com,
	gregkh@linuxfoundation.org, pankaj.adhikari@ni.com,
	guido.kiener@rohde-schwarz.com, linux-usb@vger.kernel.org
Subject: [07/12] usb: usbtmc: Add ioctl USBTMC488_IOCTL_WAIT_SRQ
Date: Fri, 25 May 2018 13:17:29 +0200	[thread overview]
Message-ID: <1527247049.10047.2.camel@suse.com> (raw)

Am Donnerstag, den 24.05.2018, 12:59 +0000 schrieb guido@kiener-
muenchen.de:
> Zitat von Oliver Neukum <oneukum@suse.com>:
> 
> > Am Donnerstag, den 17.05.2018, 19:03 +0200 schrieb Guido Kiener:
> > > +static int usbtmc488_ioctl_wait_srq(struct usbtmc_file_data *file_data,
> > > +                                   unsigned int __user *arg)
> > > +{
> > > +       struct usbtmc_device_data *data = file_data->data;
> > > +       struct device *dev = &data->intf->dev;
> > > +       int rv;
> > > +       unsigned int timeout;
> > > +       unsigned long expire;
> > > +
> > > +       if (!data->iin_ep_present) {
> > > +               dev_dbg(dev, "no interrupt endpoint present\n");
> > > +               return -EFAULT;
> > > +       }
> > > +
> > > +       if (get_user(timeout, arg))
> > > +               return -EFAULT;
> > > +
> > > +       expire = msecs_to_jiffies(timeout);
> > > +
> > > +       mutex_unlock(&data->io_mutex);
> > 
> > There is such a thing as threads sharing file descriptors.
> > That leads to the question what happens to the mutex if this
> > ioctl() is called multiple times.
> > 
> > 	Regards
> > 		Oliver
> 
> Multiple threads can wait with the same or different file descriptors.
> When an SRQ interrupt occurs, all threads and file descriptors are
> informed concurrently with wake_up_interruptible_all(&data->waitq);
> The "_all" is already fixed in 02/12.

No, the problem is that you will underflow io->mutex

	Regards
		Oliver
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-05-25 11:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 11:17 Oliver Neukum [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-28 12:36 [07/12] usb: usbtmc: Add ioctl USBTMC488_IOCTL_WAIT_SRQ Oliver Neukum
2018-05-28 10:59 Guido Kiener
2018-05-24 12:59 Guido Kiener
2018-05-23 16:33 Greg Kroah-Hartman
2018-05-23 12:08 Oliver Neukum
2018-05-18 15:17 Guido Kiener
2018-05-18 15:07 Greg Kroah-Hartman
2018-05-18 15:02 Guido Kiener
2018-05-18 13:38 Greg Kroah-Hartman
2018-05-17 17:03 Guido Kiener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1527247049.10047.2.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guido.kiener@rohde-schwarz.com \
    --cc=guido@kiener-muenchen.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=pankaj.adhikari@ni.com \
    --cc=steve_bayless@keysight.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.