diff options
Diffstat (limited to 'drivers/net/wireless/iwlegacy/common.c')
-rw-r--r-- | drivers/net/wireless/iwlegacy/common.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d0d408e1b367..872302a3f869 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c | |||
@@ -2887,20 +2887,22 @@ EXPORT_SYMBOL(il_queue_space); | |||
2887 | * il_queue_init - Initialize queue's high/low-water and read/write idxes | 2887 | * il_queue_init - Initialize queue's high/low-water and read/write idxes |
2888 | */ | 2888 | */ |
2889 | static int | 2889 | static int |
2890 | il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, | 2890 | il_queue_init(struct il_priv *il, struct il_queue *q, int slots, u32 id) |
2891 | u32 id) | ||
2892 | { | 2891 | { |
2893 | q->n_bd = count; | 2892 | /* |
2894 | q->n_win = slots_num; | 2893 | * TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise |
2895 | q->id = id; | 2894 | * il_queue_inc_wrap and il_queue_dec_wrap are broken. |
2895 | */ | ||
2896 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | ||
2897 | /* FIXME: remove q->n_bd */ | ||
2898 | q->n_bd = TFD_QUEUE_SIZE_MAX; | ||
2896 | 2899 | ||
2897 | /* count must be power-of-two size, otherwise il_queue_inc_wrap | 2900 | q->n_win = slots; |
2898 | * and il_queue_dec_wrap are broken. */ | 2901 | q->id = id; |
2899 | BUG_ON(!is_power_of_2(count)); | ||
2900 | 2902 | ||
2901 | /* slots_num must be power-of-two size, otherwise | 2903 | /* slots_must be power-of-two size, otherwise |
2902 | * il_get_cmd_idx is broken. */ | 2904 | * il_get_cmd_idx is broken. */ |
2903 | BUG_ON(!is_power_of_2(slots_num)); | 2905 | BUG_ON(!is_power_of_2(slots)); |
2904 | 2906 | ||
2905 | q->low_mark = q->n_win / 4; | 2907 | q->low_mark = q->n_win / 4; |
2906 | if (q->low_mark < 4) | 2908 | if (q->low_mark < 4) |
@@ -2959,12 +2961,11 @@ error: | |||
2959 | * il_tx_queue_init - Allocate and initialize one tx/cmd queue | 2961 | * il_tx_queue_init - Allocate and initialize one tx/cmd queue |
2960 | */ | 2962 | */ |
2961 | int | 2963 | int |
2962 | il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | 2964 | il_tx_queue_init(struct il_priv *il, u32 txq_id) |
2963 | u32 txq_id) | ||
2964 | { | 2965 | { |
2965 | int i, len; | 2966 | int i, len, ret; |
2966 | int ret; | 2967 | int slots, actual_slots; |
2967 | int actual_slots = slots_num; | 2968 | struct il_tx_queue *txq = &il->txq[txq_id]; |
2968 | 2969 | ||
2969 | /* | 2970 | /* |
2970 | * Alloc buffer array for commands (Tx or other types of commands). | 2971 | * Alloc buffer array for commands (Tx or other types of commands). |
@@ -2974,8 +2975,13 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | |||
2974 | * For normal Tx queues (all other queues), no super-size command | 2975 | * For normal Tx queues (all other queues), no super-size command |
2975 | * space is needed. | 2976 | * space is needed. |
2976 | */ | 2977 | */ |
2977 | if (txq_id == il->cmd_queue) | 2978 | if (txq_id == il->cmd_queue) { |
2978 | actual_slots++; | 2979 | slots = TFD_CMD_SLOTS; |
2980 | actual_slots = slots + 1; | ||
2981 | } else { | ||
2982 | slots = TFD_TX_CMD_SLOTS; | ||
2983 | actual_slots = slots; | ||
2984 | } | ||
2979 | 2985 | ||
2980 | txq->meta = | 2986 | txq->meta = |
2981 | kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); | 2987 | kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); |
@@ -2988,7 +2994,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | |||
2988 | len = sizeof(struct il_device_cmd); | 2994 | len = sizeof(struct il_device_cmd); |
2989 | for (i = 0; i < actual_slots; i++) { | 2995 | for (i = 0; i < actual_slots; i++) { |
2990 | /* only happens for cmd queue */ | 2996 | /* only happens for cmd queue */ |
2991 | if (i == slots_num) | 2997 | if (i == slots) |
2992 | len = IL_MAX_CMD_SIZE; | 2998 | len = IL_MAX_CMD_SIZE; |
2993 | 2999 | ||
2994 | txq->cmd[i] = kmalloc(len, GFP_KERNEL); | 3000 | txq->cmd[i] = kmalloc(len, GFP_KERNEL); |
@@ -3011,12 +3017,8 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | |||
3011 | if (txq_id < 4) | 3017 | if (txq_id < 4) |
3012 | il_set_swq_id(txq, txq_id, txq_id); | 3018 | il_set_swq_id(txq, txq_id, txq_id); |
3013 | 3019 | ||
3014 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | ||
3015 | * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ | ||
3016 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | ||
3017 | |||
3018 | /* Initialize queue's high/low-water marks, and head/tail idxes */ | 3020 | /* Initialize queue's high/low-water marks, and head/tail idxes */ |
3019 | il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | 3021 | il_queue_init(il, &txq->q, slots, txq_id); |
3020 | 3022 | ||
3021 | /* Tell device where to find queue */ | 3023 | /* Tell device where to find queue */ |
3022 | il->ops->txq_init(il, txq); | 3024 | il->ops->txq_init(il, txq); |
@@ -3034,20 +3036,24 @@ out_free_arrays: | |||
3034 | EXPORT_SYMBOL(il_tx_queue_init); | 3036 | EXPORT_SYMBOL(il_tx_queue_init); |
3035 | 3037 | ||
3036 | void | 3038 | void |
3037 | il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, | 3039 | il_tx_queue_reset(struct il_priv *il, u32 txq_id) |
3038 | u32 txq_id) | ||
3039 | { | 3040 | { |
3040 | int actual_slots = slots_num; | 3041 | int slots, actual_slots; |
3042 | struct il_tx_queue *txq = &il->txq[txq_id]; | ||
3041 | 3043 | ||
3042 | if (txq_id == il->cmd_queue) | 3044 | if (txq_id == il->cmd_queue) { |
3043 | actual_slots++; | 3045 | slots = TFD_CMD_SLOTS; |
3046 | actual_slots = TFD_CMD_SLOTS + 1; | ||
3047 | } else { | ||
3048 | slots = TFD_TX_CMD_SLOTS; | ||
3049 | actual_slots = TFD_TX_CMD_SLOTS; | ||
3050 | } | ||
3044 | 3051 | ||
3045 | memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); | 3052 | memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); |
3046 | |||
3047 | txq->need_update = 0; | 3053 | txq->need_update = 0; |
3048 | 3054 | ||
3049 | /* Initialize queue's high/low-water marks, and head/tail idxes */ | 3055 | /* Initialize queue's high/low-water marks, and head/tail idxes */ |
3050 | il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | 3056 | il_queue_init(il, &txq->q, slots, txq_id); |
3051 | 3057 | ||
3052 | /* Tell device where to find queue */ | 3058 | /* Tell device where to find queue */ |
3053 | il->ops->txq_init(il, txq); | 3059 | il->ops->txq_init(il, txq); |