On 06/09/2024 13:50, Bryan O'Donoghue wrote:
+
+ ret = core->hfi_ops->session_open(inst);
+ if (ret) {
+ ret = -EINVAL;
+ dev_err(core->dev, "session open failed\n");
+ goto unlock;
+ }
I don't understand the lifetime of the core->lock mutex here.
It has verified the state as !ISIR_CORE_ERROR and then _released_ the
lock so by the time you get to core->hfi_ops->session_open() you've not
guaranteed the state at all.
Shouldn't you continue to hold the core mutex for the duration of the
core->does_stuff() operation ?
i.e. the state was not !IRIS_CORE_ERROR at an indeterminate time prior
to the next use of core-> ...
Perhaps this is all very obvious but, I'm not immediately understanding
what the mutex gurantees nor for how long it does that.
You'd probably be better off
- taking the mutex at the external facing API
- validating state if you must
- doing all of your core ops
- dropping
If I'm interpreting your code right, there's alot of checking state in
function a -> lock/check/unlock with function a then calling function b
- which again verifies core->state and then optionally modifies say the
linked list.
But since function b is called by function a, and function b requires
the core->lock - you may as well have held that lock from a through b.
Moreover - what's the use case of the very granular core->stat lock
checking ?
When is it valid for example for iris_vb2_queue_setup() to have
core->state change state during the lifetime of iris_vb2_queue_setup() ?
iris_vb2_queue_setup() checks core->state
-> locks - checks - release
-> calls iris_hfi_gen1_session_open or
iris_hfi_gen2_session_open
-> what is the assumed core->state @ that point?
So that's what I mean, I'm not immediately understanding why this
granular locking scheme is in use, seems way, way, way too granular ?
---
bod