lkml.org 
[lkml]   [2008]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [PATCH][v5] HP iLO driver
Andrew Morton wrote:
> On Wed, 2 Jul 2008 09:38:53 -0600 David Altobelli
> <david.altobelli@hp.com> wrote:
>
>>
>> +static ssize_t ilo_write(struct file *fp, const char __user *buf,
>> + size_t len, loff_t *off)
>> +{
>> + int err, pkt_id, pkt_len;
>> + struct ccb_data *data;
>> + struct ccb *driver_ccb;
>> + struct ilo_hwinfo *hw;
>> + void *pkt;
>> +
>> + data = fp->private_data;
>> + driver_ccb = &data->driver_ccb;
>> + hw = data->ilo_hw;
>> +
>> + if (is_device_reset(hw) || is_channel_reset(driver_ccb)) { +
>> /* + * If the device has been reset, applications
>> + * need to close and reopen all ccbs. + */
>> + ilo_reset(hw);
>> + return -ENODEV;
>> + }
>
> Can multiple processes open and write to this "device"? If so, the
> above looks awfully racy. Perhaps vfs-level i_mutex coverage will
> save us on the write-versus-write side, but not on write-versus-read.

Yes, the channels can be shared.

I'm probably missing the race you are seeing, but is_device_reset()
checks a hardware bit, and this hw bit is only cleared after the flag
checked in is_channel_reset() is set. Multiple processes could get into
ilo_reset(), but that function rechecks the hardware bit after taking a
lock (and I don't believe it could happen, but there is no real downside
to multiple setters of the reset flag). Also, this bit of code is only
there to tell the applications that they need to close and reopen channels,
by returning -ENODEV. Reading/writing from a reset channel will not cause
problems, the read or write will simply not succeed.


\
 
 \ /
  Last update: 2008-07-10 17:49    [W:0.105 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site