Lines Matching refs:rbnode
45 struct regcache_rbtree_node *rbnode, in regcache_rbtree_get_base_top_reg() argument
48 *base = rbnode->base_reg; in regcache_rbtree_get_base_top_reg()
49 *top = rbnode->base_reg + ((rbnode->blklen - 1) * map->reg_stride); in regcache_rbtree_get_base_top_reg()
53 struct regcache_rbtree_node *rbnode, unsigned int idx) in regcache_rbtree_get_register() argument
55 return regcache_get_val(map, rbnode->block, idx); in regcache_rbtree_get_register()
59 struct regcache_rbtree_node *rbnode, in regcache_rbtree_set_register() argument
62 set_bit(idx, rbnode->cache_present); in regcache_rbtree_set_register()
63 regcache_set_val(map, rbnode->block, idx, val); in regcache_rbtree_set_register()
71 struct regcache_rbtree_node *rbnode; in regcache_rbtree_lookup() local
74 rbnode = rbtree_ctx->cached_rbnode; in regcache_rbtree_lookup()
75 if (rbnode) { in regcache_rbtree_lookup()
76 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_lookup()
79 return rbnode; in regcache_rbtree_lookup()
84 rbnode = container_of(node, struct regcache_rbtree_node, node); in regcache_rbtree_lookup()
85 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_lookup()
88 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_lookup()
89 return rbnode; in regcache_rbtree_lookup()
101 struct regcache_rbtree_node *rbnode) in regcache_rbtree_insert() argument
117 base_reg = rbnode->base_reg; in regcache_rbtree_insert()
130 rb_link_node(&rbnode->node, parent, new); in regcache_rbtree_insert()
131 rb_insert_color(&rbnode->node, root); in regcache_rbtree_insert()
260 struct regcache_rbtree_node *rbnode; in regcache_rbtree_read() local
263 rbnode = regcache_rbtree_lookup(map, reg); in regcache_rbtree_read()
264 if (rbnode) { in regcache_rbtree_read()
265 reg_tmp = (reg - rbnode->base_reg) / map->reg_stride; in regcache_rbtree_read()
266 if (!test_bit(reg_tmp, rbnode->cache_present)) in regcache_rbtree_read()
268 *value = regcache_rbtree_get_register(map, rbnode, reg_tmp); in regcache_rbtree_read()
278 struct regcache_rbtree_node *rbnode, in regcache_rbtree_insert_to_block() argument
291 offset = (rbnode->base_reg - base_reg) / map->reg_stride; in regcache_rbtree_insert_to_block()
293 blk = krealloc(rbnode->block, in regcache_rbtree_insert_to_block()
299 if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) { in regcache_rbtree_insert_to_block()
300 present = krealloc(rbnode->cache_present, in regcache_rbtree_insert_to_block()
308 memset(present + BITS_TO_LONGS(rbnode->blklen), 0, in regcache_rbtree_insert_to_block()
309 (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen)) in regcache_rbtree_insert_to_block()
312 present = rbnode->cache_present; in regcache_rbtree_insert_to_block()
318 blk, rbnode->blklen * map->cache_word_size); in regcache_rbtree_insert_to_block()
323 rbnode->block = blk; in regcache_rbtree_insert_to_block()
324 rbnode->blklen = blklen; in regcache_rbtree_insert_to_block()
325 rbnode->base_reg = base_reg; in regcache_rbtree_insert_to_block()
326 rbnode->cache_present = present; in regcache_rbtree_insert_to_block()
328 regcache_rbtree_set_register(map, rbnode, pos, value); in regcache_rbtree_insert_to_block()
335 struct regcache_rbtree_node *rbnode; in regcache_rbtree_node_alloc() local
339 rbnode = kzalloc(sizeof(*rbnode), GFP_KERNEL); in regcache_rbtree_node_alloc()
340 if (!rbnode) in regcache_rbtree_node_alloc()
353 rbnode->blklen = (range->range_max - range->range_min) / in regcache_rbtree_node_alloc()
355 rbnode->base_reg = range->range_min; in regcache_rbtree_node_alloc()
359 if (!rbnode->blklen) { in regcache_rbtree_node_alloc()
360 rbnode->blklen = 1; in regcache_rbtree_node_alloc()
361 rbnode->base_reg = reg; in regcache_rbtree_node_alloc()
364 rbnode->block = kmalloc_array(rbnode->blklen, map->cache_word_size, in regcache_rbtree_node_alloc()
366 if (!rbnode->block) in regcache_rbtree_node_alloc()
369 rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen), in regcache_rbtree_node_alloc()
370 sizeof(*rbnode->cache_present), in regcache_rbtree_node_alloc()
372 if (!rbnode->cache_present) in regcache_rbtree_node_alloc()
375 return rbnode; in regcache_rbtree_node_alloc()
378 kfree(rbnode->block); in regcache_rbtree_node_alloc()
380 kfree(rbnode); in regcache_rbtree_node_alloc()
388 struct regcache_rbtree_node *rbnode, *rbnode_tmp; in regcache_rbtree_write() local
398 rbnode = regcache_rbtree_lookup(map, reg); in regcache_rbtree_write()
399 if (rbnode) { in regcache_rbtree_write()
400 reg_tmp = (reg - rbnode->base_reg) / map->reg_stride; in regcache_rbtree_write()
401 regcache_rbtree_set_register(map, rbnode, reg_tmp, value); in regcache_rbtree_write()
434 rbnode = rbnode_tmp; in regcache_rbtree_write()
454 if (rbnode) { in regcache_rbtree_write()
455 ret = regcache_rbtree_insert_to_block(map, rbnode, in regcache_rbtree_write()
461 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_write()
468 rbnode = regcache_rbtree_node_alloc(map, reg); in regcache_rbtree_write()
469 if (!rbnode) in regcache_rbtree_write()
471 regcache_rbtree_set_register(map, rbnode, in regcache_rbtree_write()
472 reg - rbnode->base_reg, value); in regcache_rbtree_write()
473 regcache_rbtree_insert(map, &rbtree_ctx->root, rbnode); in regcache_rbtree_write()
474 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_write()
485 struct regcache_rbtree_node *rbnode; in regcache_rbtree_sync() local
492 rbnode = rb_entry(node, struct regcache_rbtree_node, node); in regcache_rbtree_sync()
494 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_sync()
509 end = rbnode->blklen; in regcache_rbtree_sync()
511 ret = regcache_sync_block(map, rbnode->block, in regcache_rbtree_sync()
512 rbnode->cache_present, in regcache_rbtree_sync()
513 rbnode->base_reg, start, end); in regcache_rbtree_sync()
525 struct regcache_rbtree_node *rbnode; in regcache_rbtree_drop() local
532 rbnode = rb_entry(node, struct regcache_rbtree_node, node); in regcache_rbtree_drop()
534 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_drop()
549 end = rbnode->blklen; in regcache_rbtree_drop()
551 bitmap_clear(rbnode->cache_present, start, end - start); in regcache_rbtree_drop()