Re: [PATCH v3] usb: cdc-wdm: cannot wait forever for blocking read/write on reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Donnerstag, 2. Februar 2012, 13:26:56 schrieb Bjørn Mork:
> > No, you are misusing the flags here. We need a way to have mutual exclusion.
> > The flags may be set after we have passed that point of execution.
> 
> OK, forget the flag and take the global wdm_mutex during reset?  Or do
> you need another device specific mutex for this purpose to avoid locking
> all opens of any cdc-wdm device while one is being reset?
> 
> Or assume that any write blocking will be short, and use the wlock both
> for reset and open?

No, we cannot assume that. A device may be reset because it is broken.

The correct algorithm is

a) on the system code path (pre/post ...

set a flag
wake_up_all
mutex_lock

b) on the read/write code path

mutex_lock
wait_event //checking for the flag

if (flag)
	return error

mutex_unlock

Taking a mutex is not wrong. We just need to make sure everybody holding
a mutex makes progress when the system needs to do something. So we
need to do wake_up_all() before we take a mutex and set a flag to avoid
the race.

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux