msm: mhi_dev: Checking the out channel status directly

If the net dev init process is scheduled out in between registering
a callback for in-channel and out-channel and start command for these
channels gets processed at this time (after registering the callback
for out channel but before registeringthe callback for in-channel)
then with existing logic, we never register with the network interface.

Checking the out channel status directly rather than using local bool
variable out_channel_started before calling
mhi_dev_net_open_chan_create_netif API. If out channel status is
connected the mhi_dev_net_open_chan_create_netif API is called.

Change-Id: I69af6c49ee565ffd04c4d0ac22b686ff986b7bc7
Signed-off-by: Sai Chaitanya Kaveti <quic_skaveti@quicinc.com>
Signed-off-by: Lakshmi Prasanna Meka <quic_lmeka@quicinc.com>
This commit is contained in:
Sai Chaitanya Kaveti 2021-11-09 13:31:54 +05:30 committed by Lakshmi Prasanna Meka
parent 9ffbd50cbf
commit c994af004d

View File

@ -698,7 +698,7 @@ static void mhi_dev_net_state_cb(struct mhi_dev_client_cb_data *cb_data)
int mhi_dev_net_interface_init(struct mhi_dev_ops *dev_ops)
{
int ret_val = 0, index = 0;
bool out_channel_started = false;
uint32_t info_out_ch = 0;
struct mhi_dev_net_client *mhi_net_client = NULL;
if (mhi_net_ctxt.client_handle) {
@ -753,10 +753,7 @@ int mhi_dev_net_interface_init(struct mhi_dev_ops *dev_ops)
}
ret_val = dev_ops->register_state_cb(mhi_dev_net_state_cb,
mhi_net_client, MHI_CLIENT_IP_SW_4_OUT);
/* -EEXIST indicates success and channel is already open */
if (ret_val == -EEXIST)
out_channel_started = true;
else if (ret_val < 0)
if (ret_val < 0 && ret_val != -EEXIST)
goto register_state_cb_fail;
ret_val = dev_ops->register_state_cb(mhi_dev_net_state_cb,
@ -773,13 +770,16 @@ int mhi_dev_net_interface_init(struct mhi_dev_ops *dev_ops)
* with mhi_dev_net_open_chan_create_netif().
*/
ret_val = 0;
if (out_channel_started) {
ret_val = mhi_dev_net_open_chan_create_netif
(mhi_net_client);
if (ret_val < 0) {
mhi_dev_net_log(MHI_ERROR,
"Failed to open channels\n");
goto channel_open_fail;
if (!mhi_net_ctxt.dev_ops->ctrl_state_info(mhi_net_client->out_chan,
&info_out_ch)) {
if (info_out_ch == MHI_STATE_CONNECTED) {
ret_val = mhi_dev_net_open_chan_create_netif
(mhi_net_client);
if (ret_val < 0) {
mhi_dev_net_log(MHI_ERROR,
"Failed to open channels\n");
goto channel_open_fail;
}
}
}
} else if (ret_val < 0) {