--- zzzz-none-000/linux-3.10.107/drivers/uwb/rsv.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/uwb/rsv.c 2021-02-04 17:41:59.000000000 +0000 @@ -163,8 +163,10 @@ } stream = find_first_zero_bit(streams_bm, UWB_NUM_STREAMS); - if (stream >= UWB_NUM_STREAMS) + if (stream >= UWB_NUM_STREAMS) { + dev_err(dev, "%s: no available stream found\n", __func__); return -EBUSY; + } rsv->stream = stream; set_bit(stream, streams_bm); @@ -211,7 +213,7 @@ bow->total_expired = 0; bow->window = UWB_DRP_BACKOFF_WIN_MIN >> 1; } - dev_dbg(dev, "backoff_win_timer total_expired=%d, n=%d\n: ", bow->total_expired, bow->n); + dev_dbg(dev, "backoff_win_timer total_expired=%d, n=%d\n", bow->total_expired, bow->n); /* try to relocate all the "to be moved" relocations */ uwb_rsv_handle_drp_avail_change(rc); @@ -232,12 +234,12 @@ bow->window <<= 1; bow->n = prandom_u32() & (bow->window - 1); - dev_dbg(dev, "new_window=%d, n=%d\n: ", bow->window, bow->n); + dev_dbg(dev, "new_window=%d, n=%d\n", bow->window, bow->n); /* reset the timer associated variables */ timeout_us = bow->n * UWB_SUPERFRAME_LENGTH_US; bow->total_expired = 0; - mod_timer(&bow->timer, jiffies + usecs_to_jiffies(timeout_us)); + mod_timer(&bow->timer, jiffies + usecs_to_jiffies(timeout_us)); } static void uwb_rsv_stroke_timer(struct uwb_rsv *rsv) @@ -249,7 +251,9 @@ * super frame and should not be terminated if no response is * received. */ - if (rsv->is_multicast) { + if (rsv->state == UWB_RSV_STATE_NONE) { + sframes = 0; + } else if (rsv->is_multicast) { if (rsv->state == UWB_RSV_STATE_O_INITIATED || rsv->state == UWB_RSV_STATE_O_MOVE_EXPANDING || rsv->state == UWB_RSV_STATE_O_MOVE_COMBINING @@ -257,7 +261,7 @@ sframes = 1; if (rsv->state == UWB_RSV_STATE_O_ESTABLISHED) sframes = 0; - + } if (sframes > 0) { @@ -322,6 +326,7 @@ switch (new_state) { case UWB_RSV_STATE_NONE: uwb_rsv_state_update(rsv, UWB_RSV_STATE_NONE); + uwb_rsv_remove(rsv); uwb_rsv_callback(rsv); break; case UWB_RSV_STATE_O_INITIATED: @@ -442,6 +447,8 @@ uwb_rsv_set_state(rsv, UWB_RSV_STATE_T_ACCEPTED); uwb_drp_avail_release(rsv->rc, &rsv->mv.companion_mas); goto unlock; + case UWB_RSV_STATE_NONE: + goto unlock; default: break; } @@ -463,9 +470,7 @@ INIT_LIST_HEAD(&rsv->rc_node); INIT_LIST_HEAD(&rsv->pal_node); kref_init(&rsv->kref); - init_timer(&rsv->timer); - rsv->timer.function = uwb_rsv_timer; - rsv->timer.data = (unsigned long)rsv; + setup_timer(&rsv->timer, uwb_rsv_timer, (unsigned long)rsv); rsv->rc = rc; INIT_WORK(&rsv->handle_timeout_work, uwb_rsv_handle_timeout_work); @@ -550,12 +555,16 @@ { struct uwb_rc *rc = rsv->rc; struct uwb_mas_bm available; + struct device *dev = &rc->uwb_dev.dev; int ret; mutex_lock(&rc->rsvs_mutex); ret = uwb_rsv_get_stream(rsv); - if (ret) + if (ret) { + dev_err(dev, "%s: uwb_rsv_get_stream failed: %d\n", + __func__, ret); goto out; + } rsv->tiebreaker = prandom_u32() & 1; /* get available mas bitmap */ @@ -565,12 +574,16 @@ if (ret == UWB_RSV_ALLOC_NOT_FOUND) { ret = -EBUSY; uwb_rsv_put_stream(rsv); + dev_err(dev, "%s: uwb_rsv_find_best_allocation failed: %d\n", + __func__, ret); goto out; } ret = uwb_drp_avail_reserve_pending(rc, &rsv->mas); if (ret != 0) { uwb_rsv_put_stream(rsv); + dev_err(dev, "%s: uwb_drp_avail_reserve_pending failed: %d\n", + __func__, ret); goto out; } @@ -611,7 +624,7 @@ struct device *dev = &rc->uwb_dev.dev; struct uwb_rsv_move *mv; int ret = 0; - + if (bow->can_reserve_extra_mases == false) return -EBUSY; @@ -628,7 +641,7 @@ } else { dev_dbg(dev, "new allocation not found\n"); } - + return ret; } @@ -640,7 +653,7 @@ struct uwb_drp_backoff_win *bow = &rc->bow; struct uwb_rsv *rsv; struct uwb_mas_bm mas; - + if (bow->can_reserve_extra_mases == false) return; @@ -652,7 +665,7 @@ uwb_rsv_try_move(rsv, &mas); } } - + } /** @@ -872,7 +885,7 @@ */ void uwb_rsv_sched_update(struct uwb_rc *rc) { - spin_lock_bh(&rc->rsvs_lock); + spin_lock_irq(&rc->rsvs_lock); if (!delayed_work_pending(&rc->rsv_update_work)) { if (rc->set_drp_ie_pending > 0) { rc->set_drp_ie_pending++; @@ -881,7 +894,7 @@ uwb_rsv_queue_update(rc); } unlock: - spin_unlock_bh(&rc->rsvs_lock); + spin_unlock_irq(&rc->rsvs_lock); } /* @@ -916,10 +929,10 @@ struct uwb_rsv *rsv; mutex_lock(&rc->rsvs_mutex); - + list_for_each_entry(rsv, &rc->reservations, rc_node) { if (rsv->type != UWB_DRP_TYPE_ALIEN_BP) { - rsv->callback(rsv); + uwb_rsv_callback(rsv); } } @@ -974,9 +987,8 @@ rc->bow.can_reserve_extra_mases = true; rc->bow.total_expired = 0; rc->bow.window = UWB_DRP_BACKOFF_WIN_MIN >> 1; - init_timer(&rc->bow.timer); - rc->bow.timer.function = uwb_rsv_backoff_win_timer; - rc->bow.timer.data = (unsigned long)&rc->bow; + setup_timer(&rc->bow.timer, uwb_rsv_backoff_win_timer, + (unsigned long)&rc->bow); bitmap_complement(rc->uwb_dev.streams, rc->uwb_dev.streams, UWB_NUM_STREAMS); }