Lines Matching +full:pages +full:- +full:count

4  * SPDX-License-Identifier: Apache-2.0
22 * Implementation is designed for the PCIe MSI/MSI-X use-case in mind.
63 unsigned int cmp = 1 << (bits - 1); in fls_z()
70 bits--; in fls_z()
81 unsigned int count = WAIT_QUIESCENT; in its_force_quiescent() local
82 uint32_t reg = sys_read32(data->base + GITS_CTLR); in its_force_quiescent()
87 sys_write32(reg, data->base + GITS_CTLR); in its_force_quiescent()
95 count--; in its_force_quiescent()
96 if (!count) { in its_force_quiescent()
97 return -EBUSY; in its_force_quiescent()
101 reg = sys_read32(data->base + GITS_CTLR); in its_force_quiescent()
118 uint64_t reg = sys_read64(data->base + GITS_BASER(i)); in its_probe_baser_page_size()
123 sys_write64(reg, data->base + GITS_BASER(i)); in its_probe_baser_page_size()
125 reg = sys_read64(data->base + GITS_BASER(i)); in its_probe_baser_page_size()
152 unsigned int device_ids = GITS_TYPER_DEVBITS_GET(sys_read64(data->base + GITS_TYPER)) + 1; in its_alloc_tables()
156 uint64_t reg = sys_read64(data->base + GITS_BASER(i)); in its_alloc_tables()
190 lvl2_width = fls_z(page_size / entry_size) - 1; in its_alloc_tables()
191 device_ids -= lvl2_width + 1; in its_alloc_tables()
209 LOG_INF("Allocating %s table of %ldx%ldK pages (%ld bytes entry)", in its_alloc_tables()
214 return -ENOMEM; in its_alloc_tables()
231 reg |= MASK_SET(page_cnt - 1, GITS_BASER_SIZE); in its_alloc_tables()
239 sys_write64(reg, data->base + GITS_BASER(i)); in its_alloc_tables()
244 data->dev_table_is_indirect = indirect; in its_alloc_tables()
245 data->indirect_dev_lvl1_table = alloc_addr; in its_alloc_tables()
246 data->indirect_dev_lvl1_width = device_ids; in its_alloc_tables()
247 data->indirect_dev_lvl2_width = lvl2_width; in its_alloc_tables()
248 data->indirect_dev_page_size = page_size; in its_alloc_tables()
261 widx = data->cmd_write - data->cmd_base; in its_queue_full()
262 ridx = sys_read32(data->base + GITS_CREADR) / sizeof(struct its_cmd_block); in its_queue_full()
271 unsigned int count = 1000000; /* 1s! */ in its_allocate_entry() local
274 count--; in its_allocate_entry()
275 if (!count) { in its_allocate_entry()
282 cmd = data->cmd_write++; in its_allocate_entry()
285 if (data->cmd_write == (data->cmd_base + ITS_CMD_QUEUE_NR_ENTRIES)) { in its_allocate_entry()
286 data->cmd_write = data->cmd_base; in its_allocate_entry()
290 cmd->raw_cmd[0] = 0; in its_allocate_entry()
291 cmd->raw_cmd[1] = 0; in its_allocate_entry()
292 cmd->raw_cmd[2] = 0; in its_allocate_entry()
293 cmd->raw_cmd[3] = 0; in its_allocate_entry()
301 unsigned int count = 1000000; /* 1s! */ in its_post_command() local
303 wr_idx = (data->cmd_write - data->cmd_base) * sizeof(*cmd); in its_post_command()
304 rd_idx = sys_read32(data->base + GITS_CREADR); in its_post_command()
308 sys_write32(wr_idx, data->base + GITS_CWRITER); in its_post_command()
311 idx = sys_read32(data->base + GITS_CREADR); in its_post_command()
317 count--; in its_post_command()
318 if (!count) { in its_post_command()
321 return -ETIMEDOUT; in its_post_command()
334 return -EBUSY; in its_send_sync_cmd()
337 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_SYNC, GITS_CMD_ID); in its_send_sync_cmd()
338 cmd->raw_cmd[2] = MASK_SET(rd_addr >> GITS_CMD_RDBASE_ALIGN, GITS_CMD_RDBASE); in its_send_sync_cmd()
349 return -EBUSY; in its_send_mapc_cmd()
352 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_MAPC, GITS_CMD_ID); in its_send_mapc_cmd()
353 cmd->raw_cmd[2] = MASK_SET(icid, GITS_CMD_ICID) | in its_send_mapc_cmd()
366 return -EBUSY; in its_send_mapd_cmd()
369 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_MAPD, GITS_CMD_ID) | in its_send_mapd_cmd()
371 cmd->raw_cmd[1] = MASK_SET(size, GITS_CMD_SIZE); in its_send_mapd_cmd()
372 cmd->raw_cmd[2] = MASK_SET(itt_addr >> GITS_CMD_ITTADDR_ALIGN, GITS_CMD_ITTADDR) | in its_send_mapd_cmd()
384 return -EBUSY; in its_send_mapti_cmd()
387 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_MAPTI, GITS_CMD_ID) | in its_send_mapti_cmd()
389 cmd->raw_cmd[1] = MASK_SET(event_id, GITS_CMD_EVENTID) | in its_send_mapti_cmd()
391 cmd->raw_cmd[2] = MASK_SET(icid, GITS_CMD_ICID); in its_send_mapti_cmd()
402 return -EBUSY; in its_send_int_cmd()
405 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_INT, GITS_CMD_ID) | in its_send_int_cmd()
407 cmd->raw_cmd[1] = MASK_SET(event_id, GITS_CMD_EVENTID); in its_send_int_cmd()
417 return -EBUSY; in its_send_invall_cmd()
420 cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_INVALL, GITS_CMD_ID); in its_send_invall_cmd()
421 cmd->raw_cmd[2] = MASK_SET(icid, GITS_CMD_ICID); in its_send_invall_cmd()
428 struct gicv3_its_data *data = dev->data; in gicv3_its_send_int()
437 const struct gicv3_its_config *cfg = dev->config; in its_setup_cmd_queue()
438 struct gicv3_its_data *data = dev->data; in its_setup_cmd_queue()
442 memset(cfg->cmd_queue, 0, cfg->cmd_queue_size); in its_setup_cmd_queue()
444 reg |= MASK_SET(cfg->cmd_queue_size / SIZE_4K, GITS_CBASER_SIZE); in its_setup_cmd_queue()
446 reg |= MASK_SET((uintptr_t)cfg->cmd_queue >> GITS_CBASER_ADDR_SHIFT, GITS_CBASER_ADDR); in its_setup_cmd_queue()
451 sys_write64(reg, data->base + GITS_CBASER); in its_setup_cmd_queue()
453 data->cmd_base = (struct its_cmd_block *)cfg->cmd_queue; in its_setup_cmd_queue()
454 data->cmd_write = data->cmd_base; in its_setup_cmd_queue()
458 sys_write64(0, data->base + GITS_CWRITER); in its_setup_cmd_queue()
463 struct gicv3_its_data *data = dev->data; in gicv3_rdist_get_rdbase()
464 uint64_t typer = sys_read64(data->base + GITS_TYPER); in gicv3_rdist_get_rdbase()
476 struct gicv3_its_data *data = dev->data; in gicv3_its_map_intid()
482 return -EINVAL; in gicv3_its_map_intid()
486 ret = its_send_mapti_cmd(data, device_id, event_id, intid, arch_curr_cpu()->id); in gicv3_its_map_intid()
493 return its_send_sync_cmd(data, gicv3_rdist_get_rdbase(dev, arch_curr_cpu()->id)); in gicv3_its_map_intid()
499 struct gicv3_its_data *data = dev->data; in gicv3_its_init_device_id()
507 entry_size = GITS_TYPER_ITT_ENTRY_SIZE_GET(sys_read64(data->base + GITS_TYPER)) + 1; in gicv3_its_init_device_id()
509 if (data->dev_table_is_indirect) { in gicv3_its_init_device_id()
510 size_t offset = device_id >> data->indirect_dev_lvl2_width; in gicv3_its_init_device_id()
513 if (offset > (1 << data->indirect_dev_lvl1_width)) { in gicv3_its_init_device_id()
514 return -EINVAL; in gicv3_its_init_device_id()
518 if (!data->indirect_dev_lvl1_table[offset]) { in gicv3_its_init_device_id()
522 data->indirect_dev_page_size / 1024); in gicv3_its_init_device_id()
524 alloc_addr = k_aligned_alloc(data->indirect_dev_page_size, in gicv3_its_init_device_id()
525 data->indirect_dev_page_size); in gicv3_its_init_device_id()
527 return -ENOMEM; in gicv3_its_init_device_id()
530 memset(alloc_addr, 0, data->indirect_dev_page_size); in gicv3_its_init_device_id()
532 data->indirect_dev_lvl1_table[offset] = (uintptr_t)alloc_addr | in gicv3_its_init_device_id()
548 return -ENOMEM; in gicv3_its_init_device_id()
551 /* size is log2(ites) - 1, equivalent to (fls(ites) - 1) - 1 */ in gicv3_its_init_device_id()
552 ret = its_send_mapd_cmd(data, device_id, fls_z(nr_ites) - 2, (uintptr_t)itt, true); in gicv3_its_init_device_id()
568 const struct gicv3_its_config *cfg = (const struct gicv3_its_config *)dev->config; in gicv3_its_get_msi_addr()
570 return cfg->base_addr + GITS_TRANSLATER; in gicv3_its_get_msi_addr()
580 data = (struct gicv3_its_data *) dev->data; \
581 ret = its_send_mapc_cmd(data, arch_curr_cpu()->id, \
582 gicv3_rdist_get_rdbase(dev, arch_curr_cpu()->id), \
586 arch_curr_cpu()->id); \
603 data = (struct gicv3_its_data *) dev->data; \
604 ret = its_send_invall_cmd(data, arch_curr_cpu()->id); \
607 arch_curr_cpu()->id); \
611 gicv3_rdist_get_rdbase(dev, arch_curr_cpu()->id)); \
622 const struct gicv3_its_config *cfg = dev->config; in gicv3_its_init()
623 struct gicv3_its_data *data = dev->data; in gicv3_its_init()
627 device_map(&data->base, cfg->base_addr, cfg->base_size, K_MEM_CACHE_NONE); in gicv3_its_init()
643 reg = sys_read32(data->base + GITS_CTLR); in gicv3_its_init()
645 sys_write32(reg, data->base + GITS_CTLR); in gicv3_its_init()
648 ret = its_send_mapc_cmd(data, arch_curr_cpu()->id, in gicv3_its_init()
649 gicv3_rdist_get_rdbase(dev, arch_curr_cpu()->id), true); in gicv3_its_init()