Lines Matching +full:mem +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0 or MIT
9 #include <linux/dma-mapping.h>
12 #include <linux/iosys-map.h>
36 * struct panthor_fw_binary_hdr - Firmware binary header.
64 * enum panthor_fw_binary_entry_type - Firmware binary entry type
67 /** @CSF_FW_BINARY_ENTRY_TYPE_IFACE: Host <-> FW interface. */
73 /** @CSF_FW_BINARY_ENTRY_TYPE_FUTF_TEST: Unit-tests. */
110 * struct panthor_fw_binary_section_entry_hdr - Describes a section of FW binary
136 * struct panthor_fw_binary_iter - Firmware binary iterator
152 * struct panthor_fw_section - FW section
161 /** @mem: Section memory. */
162 struct panthor_kernel_bo *mem; member
203 * struct panthor_fw_iface - FW interfaces
217 * struct panthor_fw - Firmware management
269 return ptdev->fw->vm; in panthor_fw_vm()
273 * panthor_fw_get_glb_iface() - Get the global interface
281 return &ptdev->fw->iface.global; in panthor_fw_get_glb_iface()
285 * panthor_fw_get_csg_iface() - Get a command stream group slot interface
294 if (drm_WARN_ON(&ptdev->base, csg_slot >= MAX_CSGS)) in panthor_fw_get_csg_iface()
297 return &ptdev->fw->iface.groups[csg_slot]; in panthor_fw_get_csg_iface()
301 * panthor_fw_get_cs_iface() - Get a command stream slot interface
311 if (drm_WARN_ON(&ptdev->base, csg_slot >= MAX_CSGS || cs_slot >= MAX_CS_PER_CSG)) in panthor_fw_get_cs_iface()
314 return &ptdev->fw->iface.streams[csg_slot][cs_slot]; in panthor_fw_get_cs_iface()
318 * panthor_fw_conv_timeout() - Convert a timeout into a cycle-count
320 * @timeout_us: Timeout expressed in micro-seconds.
322 * The FW has two timer sources: the GPU counter or arch-timer. We need
340 timer_rate = clk_get_rate(ptdev->clks.core); in panthor_fw_conv_timeout()
343 if (drm_WARN_ON(&ptdev->base, !timer_rate)) { in panthor_fw_conv_timeout()
354 if (drm_WARN_ON(&ptdev->base, mod_cycles > GLB_TIMER_VAL(~0))) in panthor_fw_conv_timeout()
365 size_t new_offset = iter->offset + size; in panthor_fw_binary_iter_read()
367 if (new_offset > iter->size || new_offset < iter->offset) { in panthor_fw_binary_iter_read()
368 drm_err(&ptdev->base, "Firmware too small\n"); in panthor_fw_binary_iter_read()
369 return -EINVAL; in panthor_fw_binary_iter_read()
372 memcpy(out, iter->data + iter->offset, size); in panthor_fw_binary_iter_read()
373 iter->offset = new_offset; in panthor_fw_binary_iter_read()
382 size_t new_offset = iter->offset + size; in panthor_fw_binary_sub_iter_init()
384 if (new_offset > iter->size || new_offset < iter->offset) { in panthor_fw_binary_sub_iter_init()
385 drm_err(&ptdev->base, "Firmware entry too long\n"); in panthor_fw_binary_sub_iter_init()
386 return -EINVAL; in panthor_fw_binary_sub_iter_init()
389 sub_iter->offset = 0; in panthor_fw_binary_sub_iter_init()
390 sub_iter->data = iter->data + iter->offset; in panthor_fw_binary_sub_iter_init()
391 sub_iter->size = size; in panthor_fw_binary_sub_iter_init()
392 iter->offset = new_offset; in panthor_fw_binary_sub_iter_init()
399 bool was_mapped = !!section->mem->kmap; in panthor_fw_init_section_mem()
402 if (!section->data.size && in panthor_fw_init_section_mem()
403 !(section->flags & CSF_FW_BINARY_IFACE_ENTRY_RD_ZERO)) in panthor_fw_init_section_mem()
406 ret = panthor_kernel_bo_vmap(section->mem); in panthor_fw_init_section_mem()
407 if (drm_WARN_ON(&ptdev->base, ret)) in panthor_fw_init_section_mem()
410 memcpy(section->mem->kmap, section->data.buf, section->data.size); in panthor_fw_init_section_mem()
411 if (section->flags & CSF_FW_BINARY_IFACE_ENTRY_RD_ZERO) { in panthor_fw_init_section_mem()
412 memset(section->mem->kmap + section->data.size, 0, in panthor_fw_init_section_mem()
413 panthor_kernel_bo_size(section->mem) - section->data.size); in panthor_fw_init_section_mem()
417 panthor_kernel_bo_vunmap(section->mem); in panthor_fw_init_section_mem()
421 * panthor_fw_alloc_queue_iface_mem() - Allocate a ring-buffer interfaces.
443 struct panthor_kernel_bo *mem; in panthor_fw_alloc_queue_iface_mem() local
446 mem = panthor_kernel_bo_create(ptdev, ptdev->fw->vm, SZ_8K, in panthor_fw_alloc_queue_iface_mem()
451 if (IS_ERR(mem)) in panthor_fw_alloc_queue_iface_mem()
452 return mem; in panthor_fw_alloc_queue_iface_mem()
454 ret = panthor_kernel_bo_vmap(mem); in panthor_fw_alloc_queue_iface_mem()
456 panthor_kernel_bo_destroy(mem); in panthor_fw_alloc_queue_iface_mem()
460 memset(mem->kmap, 0, panthor_kernel_bo_size(mem)); in panthor_fw_alloc_queue_iface_mem()
461 *input = mem->kmap; in panthor_fw_alloc_queue_iface_mem()
462 *output = mem->kmap + SZ_4K; in panthor_fw_alloc_queue_iface_mem()
463 *input_fw_va = panthor_kernel_bo_gpuva(mem); in panthor_fw_alloc_queue_iface_mem()
466 return mem; in panthor_fw_alloc_queue_iface_mem()
470 * panthor_fw_alloc_suspend_buf_mem() - Allocate a suspend buffer for a command stream group.
490 ssize_t vm_pgsz = panthor_vm_page_size(ptdev->fw->vm); in panthor_fw_load_section_entry()
502 drm_err(&ptdev->base, "Firmware corrupted, data.end < data.start (0x%x < 0x%x)\n", in panthor_fw_load_section_entry()
504 return -EINVAL; in panthor_fw_load_section_entry()
508 drm_err(&ptdev->base, "Firmware corrupted, hdr.va.end < hdr.va.start (0x%x < 0x%x)\n", in panthor_fw_load_section_entry()
510 return -EINVAL; in panthor_fw_load_section_entry()
513 if (hdr.data.end > fw->size) { in panthor_fw_load_section_entry()
514 drm_err(&ptdev->base, "Firmware corrupted, file truncated? data_end=0x%x > fw size=0x%zx\n", in panthor_fw_load_section_entry()
515 hdr.data.end, fw->size); in panthor_fw_load_section_entry()
516 return -EINVAL; in panthor_fw_load_section_entry()
520 drm_err(&ptdev->base, "Firmware corrupted, virtual addresses not page aligned: 0x%x-0x%x\n", in panthor_fw_load_section_entry()
522 return -EINVAL; in panthor_fw_load_section_entry()
526 drm_err(&ptdev->base, "Firmware contains interface with unsupported flags (0x%x)\n", in panthor_fw_load_section_entry()
528 return -EINVAL; in panthor_fw_load_section_entry()
532 drm_warn(&ptdev->base, in panthor_fw_load_section_entry()
539 drm_err(&ptdev->base, in panthor_fw_load_section_entry()
541 return -EINVAL; in panthor_fw_load_section_entry()
544 name_len = iter->size - iter->offset; in panthor_fw_load_section_entry()
546 section = drmm_kzalloc(&ptdev->base, sizeof(*section), GFP_KERNEL); in panthor_fw_load_section_entry()
548 return -ENOMEM; in panthor_fw_load_section_entry()
550 list_add_tail(§ion->node, &ptdev->fw->sections); in panthor_fw_load_section_entry()
551 section->flags = hdr.flags; in panthor_fw_load_section_entry()
552 section->data.size = hdr.data.end - hdr.data.start; in panthor_fw_load_section_entry()
554 if (section->data.size > 0) { in panthor_fw_load_section_entry()
555 void *data = drmm_kmalloc(&ptdev->base, section->data.size, GFP_KERNEL); in panthor_fw_load_section_entry()
558 return -ENOMEM; in panthor_fw_load_section_entry()
560 memcpy(data, fw->data + hdr.data.start, section->data.size); in panthor_fw_load_section_entry()
561 section->data.buf = data; in panthor_fw_load_section_entry()
565 char *name = drmm_kmalloc(&ptdev->base, name_len + 1, GFP_KERNEL); in panthor_fw_load_section_entry()
568 return -ENOMEM; in panthor_fw_load_section_entry()
570 memcpy(name, iter->data + iter->offset, name_len); in panthor_fw_load_section_entry()
572 section->name = name; in panthor_fw_load_section_entry()
575 section_size = hdr.va.end - hdr.va.start; in panthor_fw_load_section_entry()
590 * non-cacheable for now. We might want to introduce a new in panthor_fw_load_section_entry()
594 * of IO-coherent systems. in panthor_fw_load_section_entry()
599 section->mem = panthor_kernel_bo_create(ptdev, panthor_fw_vm(ptdev), in panthor_fw_load_section_entry()
603 if (IS_ERR(section->mem)) in panthor_fw_load_section_entry()
604 return PTR_ERR(section->mem); in panthor_fw_load_section_entry()
606 if (drm_WARN_ON(&ptdev->base, section->mem->va_node.start != hdr.va.start)) in panthor_fw_load_section_entry()
607 return -EINVAL; in panthor_fw_load_section_entry()
609 if (section->flags & CSF_FW_BINARY_IFACE_ENTRY_RD_SHARED) { in panthor_fw_load_section_entry()
610 ret = panthor_kernel_bo_vmap(section->mem); in panthor_fw_load_section_entry()
617 bo = to_panthor_bo(section->mem->obj); in panthor_fw_load_section_entry()
618 sgt = drm_gem_shmem_get_pages_sgt(&bo->base); in panthor_fw_load_section_entry()
622 dma_sync_sgtable_for_device(ptdev->base.dev, sgt, DMA_TO_DEVICE); in panthor_fw_load_section_entry()
626 ptdev->fw->shared_section = section; in panthor_fw_load_section_entry()
636 list_for_each_entry(section, &ptdev->fw->sections, node) { in panthor_reload_fw_sections()
639 if (!full_reload && !(section->flags & CSF_FW_BINARY_IFACE_ENTRY_RD_WR)) in panthor_reload_fw_sections()
643 sgt = drm_gem_shmem_get_pages_sgt(&to_panthor_bo(section->mem->obj)->base); in panthor_reload_fw_sections()
644 if (!drm_WARN_ON(&ptdev->base, IS_ERR_OR_NULL(sgt))) in panthor_reload_fw_sections()
645 dma_sync_sgtable_for_device(ptdev->base.dev, sgt, DMA_TO_DEVICE); in panthor_reload_fw_sections()
661 if ((iter->offset % sizeof(u32)) || in panthor_fw_load_entry()
663 drm_err(&ptdev->base, "Firmware entry isn't 32 bit aligned, offset=0x%x size=0x%x\n", in panthor_fw_load_entry()
664 (u32)(iter->offset - sizeof(u32)), CSF_FW_BINARY_ENTRY_SIZE(ehdr)); in panthor_fw_load_entry()
665 return -EINVAL; in panthor_fw_load_entry()
669 CSF_FW_BINARY_ENTRY_SIZE(ehdr) - sizeof(ehdr))) in panthor_fw_load_entry()
670 return -EINVAL; in panthor_fw_load_entry()
689 drm_err(&ptdev->base, in panthor_fw_load_entry()
690 "Unsupported non-optional entry type %u in firmware\n", in panthor_fw_load_entry()
692 return -EINVAL; in panthor_fw_load_entry()
704 (u32)GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id), in panthor_fw_load()
705 (u32)GPU_ARCH_MINOR(ptdev->gpu_info.gpu_id), in panthor_fw_load()
708 ret = request_firmware(&fw, fw_path, ptdev->base.dev); in panthor_fw_load()
710 drm_err(&ptdev->base, "Failed to load firmware image '%s'\n", in panthor_fw_load()
715 iter.data = fw->data; in panthor_fw_load()
716 iter.size = fw->size; in panthor_fw_load()
722 ret = -EINVAL; in panthor_fw_load()
723 drm_err(&ptdev->base, "Invalid firmware magic\n"); in panthor_fw_load()
728 ret = -EINVAL; in panthor_fw_load()
729 drm_err(&ptdev->base, "Unsupported firmware binary header version %d.%d (expected %d.x)\n", in panthor_fw_load()
735 drm_err(&ptdev->base, "Firmware image is truncated\n"); in panthor_fw_load()
747 if (!ptdev->fw->shared_section) { in panthor_fw_load()
748 drm_err(&ptdev->base, "Shared interface region not found\n"); in panthor_fw_load()
749 ret = -EINVAL; in panthor_fw_load()
759 * iface_fw_to_cpu_addr() - Turn an MCU address into a CPU address
763 * Return: NULL if the address is not part of the shared section, non-NULL otherwise.
767 u64 shared_mem_start = panthor_kernel_bo_gpuva(ptdev->fw->shared_section->mem); in iface_fw_to_cpu_addr()
769 panthor_kernel_bo_size(ptdev->fw->shared_section->mem); in iface_fw_to_cpu_addr()
773 return ptdev->fw->shared_section->mem->kmap + (mcu_va - shared_mem_start); in iface_fw_to_cpu_addr()
781 struct panthor_fw_cs_iface *cs_iface = &ptdev->fw->iface.streams[csg_idx][cs_idx]; in panthor_init_cs_iface()
782 u64 shared_section_sz = panthor_kernel_bo_size(ptdev->fw->shared_section->mem); in panthor_init_cs_iface()
784 (csg_idx * glb_iface->control->group_stride) + in panthor_init_cs_iface()
786 (cs_idx * csg_iface->control->stream_stride); in panthor_init_cs_iface()
791 return -EINVAL; in panthor_init_cs_iface()
793 spin_lock_init(&cs_iface->lock); in panthor_init_cs_iface()
794 cs_iface->control = ptdev->fw->shared_section->mem->kmap + iface_offset; in panthor_init_cs_iface()
795 cs_iface->input = iface_fw_to_cpu_addr(ptdev, cs_iface->control->input_va); in panthor_init_cs_iface()
796 cs_iface->output = iface_fw_to_cpu_addr(ptdev, cs_iface->control->output_va); in panthor_init_cs_iface()
798 if (!cs_iface->input || !cs_iface->output) { in panthor_init_cs_iface()
799 drm_err(&ptdev->base, "Invalid stream control interface input/output VA"); in panthor_init_cs_iface()
800 return -EINVAL; in panthor_init_cs_iface()
804 if (cs_iface->control->features != first_cs_iface->control->features) { in panthor_init_cs_iface()
805 drm_err(&ptdev->base, "Expecting identical CS slots"); in panthor_init_cs_iface()
806 return -EINVAL; in panthor_init_cs_iface()
809 u32 reg_count = CS_FEATURES_WORK_REGS(cs_iface->control->features); in panthor_init_cs_iface()
811 ptdev->csif_info.cs_reg_count = reg_count; in panthor_init_cs_iface()
812 ptdev->csif_info.unpreserved_cs_reg_count = CSF_UNPRESERVED_REG_COUNT; in panthor_init_cs_iface()
821 if (a->features != b->features) in compare_csg()
823 if (a->suspend_size != b->suspend_size) in compare_csg()
825 if (a->protm_suspend_size != b->protm_suspend_size) in compare_csg()
827 if (a->stream_num != b->stream_num) in compare_csg()
836 struct panthor_fw_csg_iface *csg_iface = &ptdev->fw->iface.groups[csg_idx]; in panthor_init_csg_iface()
837 u64 shared_section_sz = panthor_kernel_bo_size(ptdev->fw->shared_section->mem); in panthor_init_csg_iface()
838 u32 iface_offset = CSF_GROUP_CONTROL_OFFSET + (csg_idx * glb_iface->control->group_stride); in panthor_init_csg_iface()
842 return -EINVAL; in panthor_init_csg_iface()
844 spin_lock_init(&csg_iface->lock); in panthor_init_csg_iface()
845 csg_iface->control = ptdev->fw->shared_section->mem->kmap + iface_offset; in panthor_init_csg_iface()
846 csg_iface->input = iface_fw_to_cpu_addr(ptdev, csg_iface->control->input_va); in panthor_init_csg_iface()
847 csg_iface->output = iface_fw_to_cpu_addr(ptdev, csg_iface->control->output_va); in panthor_init_csg_iface()
849 if (csg_iface->control->stream_num < MIN_CS_PER_CSG || in panthor_init_csg_iface()
850 csg_iface->control->stream_num > MAX_CS_PER_CSG) in panthor_init_csg_iface()
851 return -EINVAL; in panthor_init_csg_iface()
853 if (!csg_iface->input || !csg_iface->output) { in panthor_init_csg_iface()
854 drm_err(&ptdev->base, "Invalid group control interface input/output VA"); in panthor_init_csg_iface()
855 return -EINVAL; in panthor_init_csg_iface()
862 if (!compare_csg(first_csg_iface->control, csg_iface->control)) { in panthor_init_csg_iface()
863 drm_err(&ptdev->base, "Expecting identical CSG slots"); in panthor_init_csg_iface()
864 return -EINVAL; in panthor_init_csg_iface()
868 for (i = 0; i < csg_iface->control->stream_num; i++) { in panthor_init_csg_iface()
882 if (glb_iface->control->version < CSF_IFACE_VERSION(1, 1, 0)) in panthor_get_instr_features()
885 return glb_iface->control->instr_features; in panthor_get_instr_features()
890 struct panthor_fw_global_iface *glb_iface = &ptdev->fw->iface.global; in panthor_fw_init_ifaces()
893 if (!ptdev->fw->shared_section->mem->kmap) in panthor_fw_init_ifaces()
894 return -EINVAL; in panthor_fw_init_ifaces()
896 spin_lock_init(&glb_iface->lock); in panthor_fw_init_ifaces()
897 glb_iface->control = ptdev->fw->shared_section->mem->kmap; in panthor_fw_init_ifaces()
899 if (!glb_iface->control->version) { in panthor_fw_init_ifaces()
900 drm_err(&ptdev->base, "Firmware version is 0. Firmware may have failed to boot"); in panthor_fw_init_ifaces()
901 return -EINVAL; in panthor_fw_init_ifaces()
904 glb_iface->input = iface_fw_to_cpu_addr(ptdev, glb_iface->control->input_va); in panthor_fw_init_ifaces()
905 glb_iface->output = iface_fw_to_cpu_addr(ptdev, glb_iface->control->output_va); in panthor_fw_init_ifaces()
906 if (!glb_iface->input || !glb_iface->output) { in panthor_fw_init_ifaces()
907 drm_err(&ptdev->base, "Invalid global control interface input/output VA"); in panthor_fw_init_ifaces()
908 return -EINVAL; in panthor_fw_init_ifaces()
911 if (glb_iface->control->group_num > MAX_CSGS || in panthor_fw_init_ifaces()
912 glb_iface->control->group_num < MIN_CSGS) { in panthor_fw_init_ifaces()
913 drm_err(&ptdev->base, "Invalid number of control groups"); in panthor_fw_init_ifaces()
914 return -EINVAL; in panthor_fw_init_ifaces()
917 for (i = 0; i < glb_iface->control->group_num; i++) { in panthor_fw_init_ifaces()
924 drm_info(&ptdev->base, "CSF FW v%d.%d.%d, Features %#x Instrumentation features %#x", in panthor_fw_init_ifaces()
925 CSF_IFACE_VERSION_MAJOR(glb_iface->control->version), in panthor_fw_init_ifaces()
926 CSF_IFACE_VERSION_MINOR(glb_iface->control->version), in panthor_fw_init_ifaces()
927 CSF_IFACE_VERSION_PATCH(glb_iface->control->version), in panthor_fw_init_ifaces()
928 glb_iface->control->features, in panthor_fw_init_ifaces()
938 glb_iface->input->core_en_mask = ptdev->gpu_info.shader_present; in panthor_fw_init_global_iface()
941 glb_iface->input->poweroff_timer = panthor_fw_conv_timeout(ptdev, PWROFF_HYSTERESIS_US); in panthor_fw_init_global_iface()
942 glb_iface->input->progress_timer = PROGRESS_TIMEOUT_CYCLES >> PROGRESS_TIMEOUT_SCALE_SHIFT; in panthor_fw_init_global_iface()
943 glb_iface->input->idle_timer = panthor_fw_conv_timeout(ptdev, IDLE_HYSTERESIS_US); in panthor_fw_init_global_iface()
946 glb_iface->input->ack_irq_mask = GLB_CFG_ALLOC_EN | in panthor_fw_init_global_iface()
962 mod_delayed_work(ptdev->reset.wq, &ptdev->fw->watchdog.ping_work, in panthor_fw_init_global_iface()
968 if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF)) in panthor_job_irq_handler()
969 ptdev->fw->booted = true; in panthor_job_irq_handler()
971 wake_up_all(&ptdev->fw->req_waitqueue); in panthor_job_irq_handler()
974 if (!ptdev->fw->booted) in panthor_job_irq_handler()
985 ptdev->fw->booted = false; in panthor_fw_start()
986 panthor_job_irq_resume(&ptdev->fw->irq, ~0); in panthor_fw_start()
989 if (!wait_event_timeout(ptdev->fw->req_waitqueue, in panthor_fw_start()
990 ptdev->fw->booted, in panthor_fw_start()
992 if (!ptdev->fw->booted && in panthor_fw_start()
1006 drm_err(&ptdev->base, "Failed to boot MCU (status=%s)", in panthor_fw_start()
1008 return -ETIMEDOUT; in panthor_fw_start()
1019 if (readl_poll_timeout(ptdev->iomem + MCU_STATUS, status, in panthor_fw_stop()
1021 drm_err(&ptdev->base, "Failed to stop MCU"); in panthor_fw_stop()
1025 * panthor_fw_pre_reset() - Call before a reset.
1030 * MCU, so we can do a fast-reset when panthor_fw_post_reset() is called.
1035 cancel_delayed_work_sync(&ptdev->fw->watchdog.ping_work); in panthor_fw_pre_reset()
1037 ptdev->fw->fast_reset = false; in panthor_fw_pre_reset()
1045 if (!readl_poll_timeout(ptdev->iomem + MCU_STATUS, status, in panthor_fw_pre_reset()
1047 glb_iface->output->halt_status == PANTHOR_FW_HALT_OK) { in panthor_fw_pre_reset()
1048 ptdev->fw->fast_reset = true; in panthor_fw_pre_reset()
1050 drm_warn(&ptdev->base, "Failed to cleanly suspend MCU"); in panthor_fw_pre_reset()
1053 /* The FW detects 0 -> 1 transitions. Make sure we reset in panthor_fw_pre_reset()
1059 panthor_job_irq_suspend(&ptdev->fw->irq); in panthor_fw_pre_reset()
1063 * panthor_fw_post_reset() - Call after a reset.
1074 ret = panthor_vm_active(ptdev->fw->vm); in panthor_fw_post_reset()
1081 if (ptdev->fw->fast_reset) { in panthor_fw_post_reset()
1090 ptdev->fw->fast_reset = false; in panthor_fw_post_reset()
1091 drm_err(&ptdev->base, "FW fast reset failed, trying a slow reset"); in panthor_fw_post_reset()
1093 ret = panthor_vm_flush_all(ptdev->fw->vm); in panthor_fw_post_reset()
1095 drm_err(&ptdev->base, "FW slow reset failed (couldn't flush FW's AS l2cache)"); in panthor_fw_post_reset()
1108 drm_err(&ptdev->base, "FW slow reset failed (couldn't start the FW )"); in panthor_fw_post_reset()
1113 /* We must re-initialize the global interface even on fast-reset. */ in panthor_fw_post_reset()
1119 * panthor_fw_unplug() - Called when the device is unplugged.
1126 * If there is still FW-related work running after this function returns,
1134 cancel_delayed_work_sync(&ptdev->fw->watchdog.ping_work); in panthor_fw_unplug()
1137 if (ptdev->fw->irq.irq) in panthor_fw_unplug()
1138 panthor_job_irq_suspend(&ptdev->fw->irq); in panthor_fw_unplug()
1142 list_for_each_entry(section, &ptdev->fw->sections, node) in panthor_fw_unplug()
1143 panthor_kernel_bo_destroy(section->mem); in panthor_fw_unplug()
1150 panthor_vm_put(ptdev->fw->vm); in panthor_fw_unplug()
1151 ptdev->fw->vm = NULL; in panthor_fw_unplug()
1153 panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000); in panthor_fw_unplug()
1157 * panthor_fw_wait_acks() - Wait for requests to be acknowledged by the FW.
1166 * Return: 0 on success, -ETIMEDOUT otherwise.
1195 return -ETIMEDOUT; in panthor_fw_wait_acks()
1199 * panthor_fw_glb_wait_acks() - Wait for global requests to be acknowledged.
1206 * Return: 0 on success, -ETIMEDOUT otherwise.
1215 if (drm_WARN_ON(&ptdev->base, req_mask & (~GLB_REQ_MASK | GLB_HALT))) in panthor_fw_glb_wait_acks()
1216 return -EINVAL; in panthor_fw_glb_wait_acks()
1218 return panthor_fw_wait_acks(&glb_iface->input->req, in panthor_fw_glb_wait_acks()
1219 &glb_iface->output->ack, in panthor_fw_glb_wait_acks()
1220 &ptdev->fw->req_waitqueue, in panthor_fw_glb_wait_acks()
1225 * panthor_fw_csg_wait_acks() - Wait for command stream group requests to be acknowledged.
1233 * Return: 0 on success, -ETIMEDOUT otherwise.
1241 if (drm_WARN_ON(&ptdev->base, req_mask & ~CSG_REQ_MASK)) in panthor_fw_csg_wait_acks()
1242 return -EINVAL; in panthor_fw_csg_wait_acks()
1244 ret = panthor_fw_wait_acks(&csg_iface->input->req, in panthor_fw_csg_wait_acks()
1245 &csg_iface->output->ack, in panthor_fw_csg_wait_acks()
1246 &ptdev->fw->req_waitqueue, in panthor_fw_csg_wait_acks()
1262 * panthor_fw_ring_csg_doorbells() - Ring command stream group doorbells.
1281 struct panthor_device *ptdev = fw->irq.ptdev; in panthor_fw_ping_work()
1295 drm_err(&ptdev->base, "FW ping timeout, scheduling a reset"); in panthor_fw_ping_work()
1297 mod_delayed_work(ptdev->reset.wq, &fw->watchdog.ping_work, in panthor_fw_ping_work()
1303 * panthor_fw_init() - Initialize FW related data.
1313 fw = drmm_kzalloc(&ptdev->base, sizeof(*fw), GFP_KERNEL); in panthor_fw_init()
1315 return -ENOMEM; in panthor_fw_init()
1317 ptdev->fw = fw; in panthor_fw_init()
1318 init_waitqueue_head(&fw->req_waitqueue); in panthor_fw_init()
1319 INIT_LIST_HEAD(&fw->sections); in panthor_fw_init()
1320 INIT_DELAYED_WORK(&fw->watchdog.ping_work, panthor_fw_ping_work); in panthor_fw_init()
1322 irq = platform_get_irq_byname(to_platform_device(ptdev->base.dev), "job"); in panthor_fw_init()
1324 return -ENODEV; in panthor_fw_init()
1326 ret = panthor_request_job_irq(ptdev, &fw->irq, irq, 0); in panthor_fw_init()
1328 drm_err(&ptdev->base, "failed to request job irq"); in panthor_fw_init()
1336 fw->vm = panthor_vm_create(ptdev, true, in panthor_fw_init()
1340 if (IS_ERR(fw->vm)) { in panthor_fw_init()
1341 ret = PTR_ERR(fw->vm); in panthor_fw_init()
1342 fw->vm = NULL; in panthor_fw_init()
1350 ret = panthor_vm_active(fw->vm); in panthor_fw_init()