Re: [PATCH v3 2/2] tpm: add support for nonblocking operation
From: Tadeusz Struk
Date: Wed Jun 13 2018 - 14:05:36 EST
On 06/13/2018 10:55 AM, J Freyensee wrote:
>> +ÂÂÂ /*
>> +ÂÂÂÂ * If in nonblocking mode schedule an async job to send
>> +ÂÂÂÂ * the command return the size.
>> +ÂÂÂÂ * In case of error the err code will be returned in
>> +ÂÂÂÂ * the subsequent read call.
>> +ÂÂÂÂ */
>> +ÂÂÂ if (file->f_flags & O_NONBLOCK) {
>> +ÂÂÂÂÂÂÂ queue_work(tpm_dev_wq, &priv->async_work);
>> +ÂÂÂÂÂÂÂ return size;
>
> Apologies for the question, but should there be a mutex_unlock() here? It's about the only return statement I am seeing where I cannot tell if a mutex_unlock() will be called before return or is needed before return. The rest of the code is pretty obvious the return statements are being re-factored to an out: block where the mutex_unlock() will always be called before returning.
Hi Jay,
We need to hold the lock until the whole command is sent and the device is ready for next one.
In case of the async job the mutex in unlocked in tpm_async_work() just after the tpm_transmit() returns.
Thanks for reviewing.
--
Tadeusz