lkml.org 
[lkml]   [2007]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] Use mutex instead of semaphore in the Host AP driver
Whoops ...


On Mon, 30 Jul 2007, Satyam Sharma wrote:

> On Mon, 30 Jul 2007, Michael Buesch wrote:
>
> > On Sunday 29 July 2007 23:34, Matthias Kaehlcke wrote:
> > > The Host AP driver uses a semaphore as mutex. Use the mutex API
> > > instead of the (binary) semaphore.
> > >
> > > Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
>
> [ Something seems to have gone wrong with your diff / patch / script.
> There was no diff header here, which should have been. ]
>
> > > - res = down_interruptible(&local->rid_bap_sem);
> > > + res = mutex_lock_interruptible(&local->rid_bap_mtx);
> > > if (res)
> > > return res;
> > >
> > > @@ -902,7 +902,7 @@ static int hfa384x_set_rid(struct net_device *dev, u16 rid, void *buf, int len)
> > > /* RID len in words and +1 for rec.rid */
> > > rec.len = cpu_to_le16(len / 2 + len % 2 + 1);
> > >
> > > - res = down_interruptible(&local->rid_bap_sem);
> > > + res = mutex_lock_interruptible(&local->rid_bap_mtx);
> > > if (res)
> > > return res;
> > >
> >
> > Is res returned to userspace? If yes, that's not right.
>
> Yup, that's not right.
>
> > On a interrupted mutex allocation you should return
> > -ERESTARTSYS to userspace.
>
> Nope, userspace must not see ERESTARTSYS (I /think/ this is the third
> time I'm participating in this exact same discussion :-)
>
> If the return would be caught by a previous in-kernel caller in the
> call chain, ERESTARTSYS is okay and it could try to restart the
> operation. However, if the return goes unfiltered directly to
> userspace, EINTR is the correct choice.

Eek, and because mutex_lock_interruptible() *does* return -EINTR when
interrupted by a signal, and I noticed that hfa384x_set_rid() could be
called from an ioctl(2) codepath with no intermediate caller trying to
restart it, so the code is perfectly alright, actually.

But the patch doesn't have the diff header anyway, so Matthias would
probably have to resend in any case :-)


Satyam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-07-30 05:37    [W:0.065 / U:12.240 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site