-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
d4xx: Locking on open dfu device #226
Conversation
@@ -4967,26 +4967,29 @@ static int ds5_dfu_device_open(struct inode *inode, struct file *file) | |||
state->client->adapter); | |||
#endif | |||
#endif | |||
mutex_lock(&state->lock); | |||
if (state->dfu_dev.device_open_count) | |||
return -EBUSY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need mutex_unlock(&state->lock);
here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this was another adjustment of where mutex should be hold and we missed that.
@@ -4997,6 +5000,7 @@ static int ds5_dfu_device_open(struct inode *inode, struct file *file) | |||
i2c_set_adapter_bus_clk_rate(parent, DFU_I2C_BUS_CLK_RATE); | |||
#endif | |||
#endif | |||
mutex_unlock(&state->lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who reads state->dfu_dev.bus_clk_rate
?
We set using the i2c API right?
Why do we need to keep the last value? can't we hard coded set 400 on entrance and set 100 on exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can hard code values
Nice catch Dima. |
@mengyui On your PR you also added lock and said it caused some crash. |
Another interesting question is how do we see 2 opens w/o a close in between. |
The issue which i'm trying to fix is related to "device_open_count" BTW, should the lock be unlocked before returning from the function? |
It was tested with unit-tests on single camera. |
Thanks. |
This is not "enters" dfu mode, it's open dfu device and close dfu device. For Jetson we switch I2C bus speed clock.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Fix bus clock restore on dfu open/close.
sometimes we have race condition while running tests