18 #include <linux/kernel.h>
19 #include <linux/slab.h>
26 int col, mas, safe_mas, unsafe_mas;
27 unsigned char *bm = ai->
bm;
31 for (col = ci->
csi.start_col; col < UWB_NUM_ZONES; col += ci->
csi.interval) {
33 safe_mas = ci->
csi.safe_mas_per_col;
34 unsafe_mas = ci->
csi.unsafe_mas_per_col;
37 if (bm[col * UWB_MAS_PER_ZONE + mas] == 0) {
42 }
else if (unsafe_mas > 0) {
48 bm[col * UWB_MAS_PER_ZONE + mas] =
c;
57 unsigned char *bm = ai->
bm;
63 for (mas = UWB_MAS_PER_ZONE - 1; mas >= 0; mas--) {
64 if (ri->
avail[mas] == 1) {
68 }
else if (rows > 7) {
74 bm[col * UWB_NUM_ZONES + mas] =
c;
138 int num_safe_mas,
int num_unsafe_mas)
143 int deep,
set, col, start_col_deep, col_start_set;
144 int start_col, max_mas_in_set, lowest_max_mas_in_deep;
148 tmp_csi.start_col = 0;
150 n_mas = num_unsafe_mas + num_safe_mas;
152 for (deep = 0; ((interval >> deep) & 0x1) == 0; deep++) {
157 for (
set = 1;
set <= (1 << deep);
set++) {
159 start_col = start_col_deep + col_start_set;
162 if (ci[col].max_avail_safe >= num_safe_mas &&
163 ci[col].max_avail_unsafe >= n_mas) {
164 if (ci[col].highest_mas[n_mas] > max_mas_in_set)
171 if ((lowest_max_mas_in_deep > max_mas_in_set) && max_mas_in_set) {
172 lowest_max_mas_in_deep = max_mas_in_set;
176 col_start_set += (interval >> deep);
179 if (lowest_max_mas_in_deep < 8) {
183 }
else if ((lowest_max_mas_in_deep > 8) &&
206 unsigned char *bm = ai->
bm;
223 static void uwb_rsv_fill_column_info(
unsigned char *bm,
int column,
struct uwb_rsv_col_info *rci)
227 int previous_avail = 0;
230 8, 7, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1,
236 if (!bm[column * UWB_NUM_ZONES + mas]) {
242 if (previous_avail) {
244 if ((block_count > safe_mas_in_row[
start_block]) &&
262 unsigned char *bm = ai->
bm;
267 uwb_rsv_fill_column_info(bm, col, &ci[col]);
278 for (n_rows = max_rows; n_rows >= min_rows; n_rows--) {
280 ai->
ri.used_rows = n_rows;
282 uwb_rsv_fill_row_alloc(ai);
291 int n_safe, n_unsafe, n_mas;
292 int n_column = UWB_NUM_ZONES /
interval;
293 int max_per_zone = ai->
max_mas / n_column;
294 int min_per_zone = ai->
min_mas / n_column;
299 if (min_per_zone > UWB_MAS_PER_ZONE) {
303 if (max_per_zone > UWB_MAS_PER_ZONE) {
307 for (n_mas = max_per_zone; n_mas >= min_per_zone; n_mas--) {
310 for (n_safe = n_mas; n_safe >= 0; n_safe--) {
311 n_unsafe = n_mas - n_safe;
313 uwb_rsv_fill_column_alloc(ai);
341 get_row_descriptors(ai);
345 goto alloc_not_found;
348 get_column_descriptors(ai);
350 for (interval = 16; interval >= 2; interval>>=1) {
358 get_row_descriptors(ai);
362 goto alloc_not_found;
368 for (bit_index = 0; bit_index <
UWB_NUM_MAS; bit_index++) {
370 set_bit(bit_index, result->bm);
372 set_bit(bit_index, result->unsafe_bm);
374 bitmap_or(result->bm, result->bm, result->unsafe_bm, UWB_NUM_MAS);