habanalabs: use smallest possible alignment for virtual addresses
PATCH 1/11 habanalabs: use smallest possible alignment for virtual addresses
From: Omer Shpigelman <[email protected]>
Change the acquiring of a device virtual address for mapping by using the smallest possible alignment, rather than the biggest, depending on the page size used by the user for allocating the memory. This will lower the virtual space memory consumption.
--- drivers/misc/habanalabs/common/memory.c | 86 ++++++++++++++----------- 1 file changed, 48 insertions(+), 38 deletions(-)
drivers/misc/habanalabs/common/memory.c +48 -38
@@ -505,41 +505,32 @@ static inline int add_va_block(struct hl_device *hdev, }/* -* get_va_block - get a virtual block with the requested size -* -* @hdev : pointer to the habanalabs device structure -* @va_range : pointer to the virtual addresses range -* @size : requested block size -* @hint_addr : hint for request address by the user -* @is_userptr : is host or DRAM memory +* get_va_block() - get a virtual block for the given size and alignment. +* @hdev: pointer to the habanalabs device structure. +* @va_range: pointer to the virtual addresses range. +* @size: requested block size. +* @hint_addr: hint for requested address by the user. +* @va_block_align: required alignment of the virtual block start address. * * This function does the following: * - Iterate on the virtual block list to find a suitable virtual block for the -* requested size -* - Reserve the requested block and update the list -* - Return the start address of the virtual block +* given size and alignment. +* - Reserve the requested block and update the list. +* - Return the start address of the virtual block. */ -static u64 get_va_block (struct hl_device *hdev, -struct hl_va_range *va_range,u64 size,u64 hint_addr, -bool is_userptr) +static u64 get_va_block (struct hl_device *hdev,struct hl_va_range *va_range, +u64 size,u64 hint_addr,u32 va_block_align) {struct hl_vm_va_block *va_block, *new_va_block =NULL ; -u64 valid_start, valid_size, prev_start, prev_end, page_mask, +u64 valid_start, valid_size, prev_start, prev_end, align_mask, res_valid_start =0 , res_valid_size =0 ; -u32 page_size;bool add_prev = false; -if (is_userptr) -/* -* We cannot know if the user allocated memory with huge pages -* or not, hence we continue with the biggest possible -* granularity. -*/ - page_size = hdev->asic_prop.pmmu_huge.page_size; -else - page_size = hdev->asic_prop.dmmu.page_size; + align_mask = ~((u64 )va_block_align -1 ); - page_mask = ~((u64 )page_size -1 ); +/* check if hint_addr is aligned */ +if (hint_addr & (va_block_align -1 )) + hint_addr =0 ;mutex_lock (&va_range->lock);
@@ -549,9 +540,9 @@ static u64 get_va_block(struct hl_device *hdev,/* calc the first possible aligned addr */ valid_start = va_block->start; -if (valid_start & (page_size -1 )) { - valid_start &= page_mask; - valid_start += page_size; +if (valid_start & (va_block_align -1 )) { + valid_start &= align_mask; + valid_start += va_block_align;if (valid_start > va_block->end)continue ; }
@@ -863,7 +854,7 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,struct hl_va_range *va_range;enum vm_type_t *vm_type;u64 ret_vaddr, hint_addr; -u32 handle =0 ; +u32 handle =0 , va_block_align;int rc;bool is_userptr = args->flags &HL_MEM_USERPTR ;
@@ -873,6 +864,8 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,if (is_userptr) {u64 addr = args->map_host.host_virt_addr, size = args->map_host.mem_size; +u32 page_size = hdev->asic_prop.pmmu.page_size, + huge_page_size = hdev->asic_prop.pmmu_huge.page_size; rc =dma_map_host_va (hdev, addr, size, &userptr);if (rc) {
@@ -892,6 +885,27 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, vm_type = (enum vm_type_t *) userptr; hint_addr = args->map_host.hint_addr; handle = phys_pg_pack->handle; + +/* get required alignment */ +if (phys_pg_pack->page_size == page_size) { + va_range = ctx->host_va_range; + +/* +* huge page alignment may be needed in case of regular +* page mapping, depending on the host VA alignment +*/ +if (addr & (huge_page_size -1 )) + va_block_align = page_size; +else + va_block_align = huge_page_size; + }else { +/* +* huge page alignment is needed in case of huge page +* mapping +*/ + va_range = ctx->host_huge_va_range; + va_block_align = huge_page_size; + } }else { handle =lower_32_bits (args->map_device.handle);
@@ -912,6 +926,10 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, vm_type = (enum vm_type_t *) phys_pg_pack; hint_addr = args->map_device.hint_addr; + +/* DRAM VA alignment is the same as the DRAM page size */ + va_range = ctx->dram_va_range; + va_block_align = hdev->asic_prop.dmmu.page_size; }/*
@@ -933,16 +951,8 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, goto hnode_err; } -if (is_userptr) -if (phys_pg_pack->page_size == hdev->asic_prop.pmmu.page_size) - va_range = ctx->host_va_range; -else - va_range = ctx->host_huge_va_range; -else - va_range = ctx->dram_va_range; - ret_vaddr =get_va_block (hdev, va_range, phys_pg_pack->total_size, - hint_addr, is_userptr); + hint_addr, va_block_align);if (!ret_vaddr) {dev_err (hdev->dev,"no available va block for handle %u\n" , handle);
Signature · 1 line
2.17.1
PATCH 2/11 habanalabs: rename mmu.c to mmu_v1.c
From: Moti Haimovski <[email protected]>
In the future we will have MMU v2 code, so we need to prepare the driver for it. The first step is to rename the current MMU file to mmu_v1.c.
---
drivers/misc/habanalabs/common/Makefile | 4 ++--
drivers/misc/habanalabs/common/{mmu.c => mmu_v1.c} | 0
2 files changed, 2 insertions(+), 2 deletions(-)
rename drivers/misc/habanalabs/common/{mmu.c => mmu_v1.c} (100%)drivers/misc/habanalabs/common/Makefile +2 -2
@@ -3,5 +3,5 @@ HL_COMMON_FILES := common/habanalabs_drv.o common/device.o common/context.o \ common/asid.o common/habanalabs_ioctl.o \ common/command_buffer.o common/hw_queue.o common/irq.o \ common/sysfs.o common/hwmon.o common/memory.o \ - common/command_submission.o common/mmu.o common/firmware_if.o \ - common/pci.o + common/command_submission.o common/mmu_v1.o \ + common/firmware_if.o common/pci.o
drivers/misc/habanalabs/common/mmu_v1.c renamed from drivers/misc/habanalabs/common/mmu.c +0 -0
Signature · 1 line
2.17.1
PATCH 3/11 habanalabs: refactor MMU as device-oriented
In reply to Oded GabbayFrom: Moti Haimovski <[email protected]>
As preparation to MMU v2, rework MMU to be device oriented instantiated according to the device in hand.
--- drivers/misc/habanalabs/common/Makefile | 2 +- drivers/misc/habanalabs/common/device.c | 6 + drivers/misc/habanalabs/common/habanalabs.h | 49 +++- drivers/misc/habanalabs/common/mmu.c | 309 ++++++++++++++++++++ drivers/misc/habanalabs/common/mmu_v1.c | 260 +++------------- 5 files changed, 404 insertions(+), 222 deletions(-) create mode 100644 drivers/misc/habanalabs/common/mmu.c
drivers/misc/habanalabs/common/Makefile +1 -1
@@ -3,5 +3,5 @@ HL_COMMON_FILES := common/habanalabs_drv.o common/device.o common/context.o \ common/asid.o common/habanalabs_ioctl.o \ common/command_buffer.o common/hw_queue.o common/irq.o \ common/sysfs.o common/hwmon.o common/memory.o \ - common/command_submission.o common/mmu_v1.o \ + common/command_submission.o common/mmu.o common/mmu_v1.o \ common/firmware_if.o common/pci.o
drivers/misc/habanalabs/common/device.c +6 -0
@@ -321,6 +321,10 @@ static int device_early_init(struct hl_device *hdev) goto free_chip_info; } + rc =hl_mmu_if_set_funcs (hdev); +if (rc) + goto free_idle_busy_ts_arr; +hl_cb_mgr_init (&hdev->kernel_cb_mgr);mutex_init (&hdev->send_cpu_message_lock);
@@ -334,6 +338,8 @@ static int device_early_init(struct hl_device *hdev)return 0 ; +free_idle_busy_ts_arr: +kfree (hdev->idle_busy_ts_arr); free_chip_info:kfree (hdev->hl_chip_info); free_eq_wq:
drivers/misc/habanalabs/common/habanalabs.h +45 -4
89 lines not on this page · raw message
drivers/misc/habanalabs/common/mmu.c new file +309 -0
309 lines not on this page · raw message
drivers/misc/habanalabs/common/mmu_v1.c +43 -217
391 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 4/11 habanalabs: add num_hops to hl_mmu_properties
In reply to Oded GabbayFrom: Moti Haimovski <[email protected]>
This commit adds the number of HOPs supported by the device to the device MMU properties.
--- drivers/misc/habanalabs/common/habanalabs.h | 6 ++++++ drivers/misc/habanalabs/gaudi/gaudi.c | 1 + drivers/misc/habanalabs/goya/goya.c | 2 ++ drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h | 2 ++ 4 files changed, 11 insertions(+)
drivers/misc/habanalabs/common/habanalabs.h +6 -0
@@ -236,12 +236,15 @@ enum hl_device_hw_state {* @hop2_shift: shift of hop 2 mask. * @hop3_shift: shift of hop 3 mask. * @hop4_shift: shift of hop 4 mask. +* @hop5_shift: shift of hop 5 mask. * @hop0_mask: mask to get the PTE address in hop 0. * @hop1_mask: mask to get the PTE address in hop 1. * @hop2_mask: mask to get the PTE address in hop 2. * @hop3_mask: mask to get the PTE address in hop 3. * @hop4_mask: mask to get the PTE address in hop 4. +* @hop5_mask: mask to get the PTE address in hop 5. * @page_size: default page size used to allocate memory. +* @num_hops: The amount of hops supported by the translation table. */ struct hl_mmu_properties {u64 start_addr;
@@ -251,12 +254,15 @@ struct hl_mmu_properties {u64 hop2_shift;u64 hop3_shift;u64 hop4_shift; +u64 hop5_shift;u64 hop0_mask;u64 hop1_mask;u64 hop2_mask;u64 hop3_mask;u64 hop4_mask; +u64 hop5_mask;u32 page_size; +u32 num_hops; };/**
drivers/misc/habanalabs/gaudi/gaudi.c +1 -0
@@ -441,6 +441,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev) prop->pmmu.end_addr = (VA_HOST_SPACE_START +VA_HOST_SPACE_SIZE /2 ) -1 ; prop->pmmu.page_size =PAGE_SIZE_4KB ; + prop->pmmu.num_hops =MMU_ARCH_5_HOPS ;/* PMMU and HPMMU are the same except of page size */ memcpy (&prop->pmmu_huge, &prop->pmmu,sizeof (prop->pmmu));
drivers/misc/habanalabs/goya/goya.c +2 -0
@@ -426,12 +426,14 @@ int goya_get_fixed_properties(struct hl_device *hdev) prop->dmmu.start_addr =VA_DDR_SPACE_START ; prop->dmmu.end_addr =VA_DDR_SPACE_END ; prop->dmmu.page_size =PAGE_SIZE_2MB ; + prop->dmmu.num_hops =MMU_ARCH_5_HOPS ;/* shifts and masks are the same in PMMU and DMMU */ memcpy (&prop->pmmu, &prop->dmmu,sizeof (prop->dmmu)); prop->pmmu.start_addr =VA_HOST_SPACE_START ; prop->pmmu.end_addr =VA_HOST_SPACE_END ; prop->pmmu.page_size =PAGE_SIZE_4KB ; + prop->pmmu.num_hops =MMU_ARCH_5_HOPS ;/* PMMU and HPMMU are the same except of page size */ memcpy (&prop->pmmu_huge, &prop->pmmu,sizeof (prop->pmmu));
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h +2 -0
@@ -29,6 +29,8 @@#define HOP3_SHIFT 21#define HOP4_SHIFT 12 +#define MMU_ARCH_5_HOPS 5 +#define HOP_PHYS_ADDR_MASK (~FLAGS_MASK)#define HL_PTE_SIZE sizeof(u64)
Signature · 1 line
2.17.1
PATCH 5/11 habanalabs: add debugfs support for MMU with 6 HOPs
In reply to Oded GabbayFrom: Moti Haimovski <[email protected]>
This commit modify the existing debugfs code to support future devices that have a 6 HOPs MMU implementation instead of 5 HOPs implementation.
--- drivers/misc/habanalabs/common/debugfs.c | 70 ++++++++++++++++++++---- 1 file changed, 60 insertions(+), 10 deletions(-)
drivers/misc/habanalabs/common/debugfs.c +60 -10
@@ -354,6 +354,14 @@ static inline u64 get_hop4_pte_addr(struct hl_ctx *ctx, mmu_specs->hop4_shift); } +static inline u64 get_hop5_pte_addr (struct hl_ctx *ctx, +struct hl_mmu_properties *mmu_specs, +u64 hop_addr,u64 vaddr) +{ +return get_hopN_pte_addr (ctx, hop_addr, vaddr, mmu_specs->hop5_mask, + mmu_specs->hop5_shift); +} +static inline u64 get_next_hop_addr (u64 curr_pte) {if (curr_pte &PAGE_PRESENT_MASK )
@@ -377,6 +385,7 @@ static int mmu_show(struct seq_file *s, void *data) hop2_addr =0 , hop2_pte_addr =0 , hop2_pte =0 , hop3_addr =0 , hop3_pte_addr =0 , hop3_pte =0 , hop4_addr =0 , hop4_pte_addr =0 , hop4_pte =0 , + hop5_addr =0 , hop5_pte_addr =0 , hop5_pte =0 , virt_addr = dev_entry->mmu_addr;if (!hdev->mmu_enable)
@@ -428,20 +437,49 @@ static int mmu_show(struct seq_file *s, void *data) hop3_pte_addr =get_hop3_pte_addr (ctx, mmu_prop, hop3_addr, virt_addr); hop3_pte = hdev->asic_funcs->read_pte (hdev, hop3_pte_addr); -if (!(hop3_pte &LAST_MASK )) { +if (mmu_prop->num_hops ==MMU_ARCH_5_HOPS ) { +if (!(hop3_pte &LAST_MASK )) { + hop4_addr =get_next_hop_addr (hop3_pte); + +if (hop4_addr ==ULLONG_MAX ) + goto not_mapped; + + hop4_pte_addr =get_hop4_pte_addr (ctx, mmu_prop, + hop4_addr, virt_addr); + hop4_pte = hdev->asic_funcs->read_pte (hdev, + hop4_pte_addr); +if (!(hop4_pte &PAGE_PRESENT_MASK )) + goto not_mapped; + }else { +if (!(hop3_pte &PAGE_PRESENT_MASK )) + goto not_mapped; + } + }else { hop4_addr =get_next_hop_addr (hop3_pte);if (hop4_addr ==ULLONG_MAX ) goto not_mapped; - hop4_pte_addr =get_hop4_pte_addr (ctx, mmu_prop, hop4_addr, - virt_addr); - hop4_pte = hdev->asic_funcs->read_pte (hdev, hop4_pte_addr); -if (!(hop4_pte &PAGE_PRESENT_MASK )) - goto not_mapped; - }else { -if (!(hop3_pte &PAGE_PRESENT_MASK )) - goto not_mapped; + hop4_pte_addr =get_hop4_pte_addr (ctx, mmu_prop, + hop4_addr, virt_addr); + hop4_pte = hdev->asic_funcs->read_pte (hdev, + hop4_pte_addr); +if (!(hop4_pte &LAST_MASK )) { + hop5_addr =get_next_hop_addr (hop4_pte); + +if (hop5_addr ==ULLONG_MAX ) + goto not_mapped; + + hop5_pte_addr =get_hop5_pte_addr (ctx, mmu_prop, + hop5_addr, virt_addr); + hop5_pte = hdev->asic_funcs->read_pte (hdev, + hop5_pte_addr); +if (!(hop5_pte &PAGE_PRESENT_MASK )) + goto not_mapped; + }else { +if (!(hop4_pte &PAGE_PRESENT_MASK )) + goto not_mapped; + } } seq_printf(s, "asid: %u, virt_addr: 0x%llx\n",
@@ -463,10 +501,22 @@ static int mmu_show(struct seq_file *s, void *data)seq_printf (s,"hop3_pte_addr: 0x%llx\n" , hop3_pte_addr);seq_printf (s,"hop3_pte: 0x%llx\n" , hop3_pte); -if (!(hop3_pte &LAST_MASK )) { +if (mmu_prop->num_hops ==MMU_ARCH_5_HOPS ) { +if (!(hop3_pte &LAST_MASK )) { +seq_printf (s,"hop4_addr: 0x%llx\n" , hop4_addr); +seq_printf (s,"hop4_pte_addr: 0x%llx\n" , hop4_pte_addr); +seq_printf (s,"hop4_pte: 0x%llx\n" , hop4_pte); + } + }else {seq_printf (s,"hop4_addr: 0x%llx\n" , hop4_addr);seq_printf (s,"hop4_pte_addr: 0x%llx\n" , hop4_pte_addr);seq_printf (s,"hop4_pte: 0x%llx\n" , hop4_pte); + +if (!(hop4_pte &LAST_MASK )) { +seq_printf (s,"hop5_addr: 0x%llx\n" , hop5_addr); +seq_printf (s,"hop5_pte_addr: 0x%llx\n" , hop5_pte_addr); +seq_printf (s,"hop5_pte: 0x%llx\n" , hop5_pte); + } } goto out;
Signature · 1 line
2.17.1
PATCH 6/11 habanalabs/gaudi: increase timeout for boot fit load
In reply to Oded GabbayThe firmware running in the boot stage takes more time to execute due to increased security mechanisms. Therefore, we need to increase the timeout we wait for the boot fit to finish loading.
--- drivers/misc/habanalabs/gaudi/gaudiP.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/gaudi/gaudiP.h +1 -1
@@ -42,7 +42,7 @@#define MAX_POWER_DEFAULT_PCI 200000/* 200W */ #define MAX_POWER_DEFAULT_PMC 350000/* 350W */ -#define GAUDI_CPU_TIMEOUT_USEC 15000000/* 15s */ +#define GAUDI_CPU_TIMEOUT_USEC 30000000/* 30s */ #define TPC_ENABLED_MASK 0xFF
Signature · 1 line
2.17.1
PATCH 7/11 habanalabs: allow to wait on CS without sleep
In reply to Oded GabbayThe user sometimes wants to check if a CS has completed to clean resources. In that case, the user doesn't want to sleep but just to check if the CS has finished and continue with his code.
Add a new definition to the API of the wait on CS. The new definition says that if the timeout is 0, the driver won't sleep at all but return immediately after checking if the CS has finished.
--- drivers/misc/habanalabs/common/command_submission.c | 7 +++++-- include/uapi/misc/habanalabs.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/common/command_submission.c +5 -2
@@ -1180,8 +1180,11 @@ static long _hl_cs_wait_ioctl(struct hl_device *hdev,"Can't wait on CS %llu because current CS is at seq %llu\n" , seq, ctx->cs_sequence); }else if (fence) { - rc =wait_for_completion_interruptible_timeout ( - &fence->completion, timeout); +if (!timeout_us) + rc =completion_done (&fence->completion); +else + rc =wait_for_completion_interruptible_timeout ( + &fence->completion, timeout);if (fence->error == -ETIMEDOUT ) rc = -ETIMEDOUT ;
include/uapi/misc/habanalabs.h +3 -0
@@ -914,6 +914,9 @@ struct hl_debug_args {* inside the kernel until the CS has finished or until the user-requested * timeout has expired. * +* If the timeout value is 0, the driver won't sleep at all. It will check +* the status of the CS and return immediately +* * The return value of the IOCTL is a standard Linux error code. The possible * values are: *
Signature · 1 line
2.17.1
PATCH 8/11 habanalabs: no need for DMA_SHARED_BUFFER
In reply to Oded GabbayNow that the driver no longer uses dma_buf, we can remove the select of DMA_SHARED_BUFFER from kconfig.
--- drivers/misc/habanalabs/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/misc/habanalabs/Kconfig +0 -1
@@ -7,7 +7,6 @@ config HABANA_AI tristate "HabanaAI accelerators (habanalabs)" depends on PCI && HAS_IOMEM select FRAME_VECTOR - select DMA_SHARED_BUFFER select GENERIC_ALLOCATOR select HWMON help
Signature · 1 line
2.17.1
PATCH 9/11 habanalabs: Save context in a command buffer object
In reply to Oded GabbayFrom: Tomer Tayar <[email protected]>
Future changes require using a context while handling a command buffer, and thus need to save the context in the command buffer object.
--- .../misc/habanalabs/common/command_buffer.c | 22 +++++++++++-------- drivers/misc/habanalabs/common/debugfs.c | 2 +- drivers/misc/habanalabs/common/habanalabs.h | 9 ++++---- drivers/misc/habanalabs/gaudi/gaudi.c | 10 +++++---- drivers/misc/habanalabs/goya/goya.c | 10 +++++---- 5 files changed, 31 insertions(+), 22 deletions(-)
drivers/misc/habanalabs/common/command_buffer.c +13 -9
@@ -47,6 +47,8 @@ static void cb_release(struct kref *ref)hl_debugfs_remove_cb (cb); +hl_ctx_put (cb->ctx); +cb_do_release (hdev, cb); }
@@ -107,11 +109,12 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size, }int hl_cb_create (struct hl_device *hdev,struct hl_cb_mgr *mgr, -u32 cb_size,u64 *handle,int ctx_id,bool internal_cb) +struct hl_ctx *ctx,u32 cb_size,bool internal_cb, +u64 *handle) {struct hl_cb *cb;bool alloc_new_cb = true; -int rc; +int rc, ctx_id = ctx->asid;/* * Can't use generic function to check this because of special case
@@ -163,7 +166,8 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr, } cb->hdev = hdev; - cb->ctx_id = ctx_id; + cb->ctx = ctx; +hl_ctx_get (hdev, cb->ctx);spin_lock (&mgr->cb_lock); rc =idr_alloc (&mgr->cb_handles, cb,1 ,0 ,GFP_ATOMIC );
@@ -191,6 +195,7 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,return 0 ; release_cb: +hl_ctx_put (cb->ctx);cb_do_release (hdev, cb); out_err: *handle =0 ;
@@ -250,9 +255,8 @@ int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data) args->in.cb_size, HL_MAX_CB_SIZE); rc = -EINVAL ; }else { - rc =hl_cb_create (hdev, &hpriv->cb_mgr, - args->in.cb_size, &handle, - hpriv->ctx->asid, false); + rc =hl_cb_create (hdev, &hpriv->cb_mgr, hpriv->ctx, + args->in.cb_size, false, &handle); }memset (args,0 ,sizeof (*args));
@@ -424,7 +428,7 @@ void hl_cb_mgr_fini(struct hl_device *hdev, struct hl_cb_mgr *mgr)if (kref_put (&cb->refcount, cb_release) !=1 )dev_err (hdev->dev,"CB %d for CTX ID %d is still alive\n" , - id, cb->ctx_id); + id, cb->ctx->asid); }idr_destroy (&mgr->cb_handles);
@@ -437,8 +441,8 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size,struct hl_cb *cb;int rc; - rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, cb_size, &cb_handle, -HL_KERNEL_ASID_ID , internal_cb); + rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, cb_size, + internal_cb, &cb_handle);if (rc) {dev_err (hdev->dev,"Failed to allocate CB for the kernel driver %d\n" , rc);
drivers/misc/habanalabs/common/debugfs.c +1 -1
@@ -111,7 +111,7 @@ static int command_buffers_show(struct seq_file *s, void *data) }seq_printf (s," %03llu %d 0x%08x %d %d %d\n" , - cb->id, cb->ctx_id, cb->size, + cb->id, cb->ctx->asid, cb->size,kref_read (&cb->refcount), cb->mmap, cb->cs_cnt); }
drivers/misc/habanalabs/common/habanalabs.h +5 -4
@@ -417,6 +417,7 @@ struct hl_cb_mgr {* struct hl_cb - describes a Command Buffer. * @refcount: reference counter for usage of the CB. * @hdev: pointer to device this CB belongs to. +* @ctx: pointer to the CB owner's context. * @lock: spinlock to protect mmap/cs flows. * @debugfs_list: node in debugfs list of command buffers. * @pool_list: node in pool list of command buffers.
@@ -426,7 +427,6 @@ struct hl_cb_mgr {* @mmap_size: Holds the CB's size that was mmaped. * @size: holds the CB's size. * @cs_cnt: holds number of CS that this CB participates in. -* @ctx_id: holds the ID of the owner's context. * @mmap: true if the CB is currently mmaped to user. * @is_pool: true if CB was acquired from the pool, false otherwise. * @is_internal: internaly allocated
@@ -434,6 +434,7 @@ struct hl_cb_mgr {struct hl_cb {struct kref refcount;struct hl_device *hdev; +struct hl_ctx *ctx;spinlock_t lock;struct list_head debugfs_list;struct list_head pool_list;
@@ -443,7 +444,6 @@ struct hl_cb {u32 mmap_size;u32 size;u32 cs_cnt; -u32 ctx_id;u8 mmap;u8 is_pool;u8 is_internal;
@@ -1838,8 +1838,9 @@ void hl_sysfs_fini(struct hl_device *hdev);int hl_hwmon_init (struct hl_device *hdev);void hl_hwmon_fini (struct hl_device *hdev); -int hl_cb_create (struct hl_device *hdev,struct hl_cb_mgr *mgr,u32 cb_size, -u64 *handle,int ctx_id,bool internal_cb); +int hl_cb_create (struct hl_device *hdev,struct hl_cb_mgr *mgr, +struct hl_ctx *ctx,u32 cb_size,bool internal_cb, +u64 *handle);int hl_cb_destroy (struct hl_device *hdev,struct hl_cb_mgr *mgr,u64 cb_handle);int hl_cb_mmap (struct hl_fpriv *hpriv,struct vm_area_struct *vma); struct hl_cb *hl_cb_get(struct hl_device *hdev, struct hl_cb_mgr *mgr,
drivers/misc/habanalabs/gaudi/gaudi.c +6 -4
@@ -4114,8 +4114,9 @@ static int gaudi_parse_cb_mmu(struct hl_device *hdev, parser->patched_cb_size = parser->user_cb_size +sizeof (struct packet_msg_prot ) *2 ; - rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size, - &patched_cb_handle,HL_KERNEL_ASID_ID , false); + rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, + parser->patched_cb_size, false, + &patched_cb_handle);if (rc) { dev_err(hdev->dev,
@@ -4187,8 +4188,9 @@ static int gaudi_parse_cb_no_mmu(struct hl_device *hdev,if (rc) goto free_userptr; - rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size, - &patched_cb_handle,HL_KERNEL_ASID_ID , false); + rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, + parser->patched_cb_size, false, + &patched_cb_handle);if (rc) {dev_err (hdev->dev,"Failed to allocate patched CB for DMA CS %d\n" , rc);
drivers/misc/habanalabs/goya/goya.c +6 -4
@@ -3810,8 +3810,9 @@ static int goya_parse_cb_mmu(struct hl_device *hdev, parser->patched_cb_size = parser->user_cb_size +sizeof (struct packet_msg_prot ) *2 ; - rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size, - &patched_cb_handle,HL_KERNEL_ASID_ID , false); + rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, + parser->patched_cb_size, false, + &patched_cb_handle);if (rc) { dev_err(hdev->dev,
@@ -3883,8 +3884,9 @@ static int goya_parse_cb_no_mmu(struct hl_device *hdev,if (rc) goto free_userptr; - rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size, - &patched_cb_handle,HL_KERNEL_ASID_ID , false); + rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, + parser->patched_cb_size, false, + &patched_cb_handle);if (rc) {dev_err (hdev->dev,"Failed to allocate patched CB for DMA CS %d\n" , rc);
Signature · 1 line
2.17.1
PATCH 10/11 habanalabs: Add an option to map CB to device MMU
In reply to Oded GabbayFrom: Tomer Tayar <[email protected]>
There are cases in which the device should access the host memory of a CB through the device MMU, and thus this memory should be mapped. The patch adds a flag to the CB IOCTL, in which a user can ask the driver to perform the mapping when creating a CB.
The mapping is allowed only if a dedicated VA range was allocated for the specific ASIC.
--- .../misc/habanalabs/common/command_buffer.c | 197 +++++++++++++++++- drivers/misc/habanalabs/common/context.c | 12 +- drivers/misc/habanalabs/common/habanalabs.h | 20 +- drivers/misc/habanalabs/gaudi/gaudi.c | 4 +- drivers/misc/habanalabs/goya/goya.c | 4 +- include/uapi/misc/habanalabs.h | 12 +- 6 files changed, 238 insertions(+), 11 deletions(-)
drivers/misc/habanalabs/common/command_buffer.c +193 -4
@@ -13,6 +13,132 @@#include <linux/uaccess.h> #include <linux/genalloc.h> +static int cb_map_mem (struct hl_ctx *ctx,struct hl_cb *cb) +{ +struct hl_device *hdev = ctx->hdev; +struct asic_fixed_properties *prop = &hdev->asic_prop; +struct hl_vm_va_block *va_block, *tmp; +dma_addr_t bus_addr; +u64 virt_addr; +u32 page_size = prop->pmmu.page_size; +s32 offset; +int rc; + +if (!hdev->supports_cb_mapping) { +dev_err_ratelimited (hdev->dev, +"Cannot map CB because no VA range is allocated for CB mapping\n" ); +return -EINVAL ; + } + +if (!hdev->mmu_enable) { +dev_err_ratelimited (hdev->dev, +"Cannot map CB because MMU is disabled\n" ); +return -EINVAL ; + } + +INIT_LIST_HEAD (&cb->va_block_list); + +for (bus_addr = cb->bus_address; + bus_addr < cb->bus_address + cb->size; + bus_addr += page_size) { + + virt_addr = (u64 )gen_pool_alloc (ctx->cb_va_pool, page_size); +if (!virt_addr) { +dev_err (hdev->dev, +"Failed to allocate device virtual address for CB\n" ); + rc = -ENOMEM ; + goto err_va_pool_free; + } + + va_block =kzalloc (sizeof (*va_block),GFP_KERNEL ); +if (!va_block) { + rc = -ENOMEM ; +gen_pool_free (ctx->cb_va_pool, virt_addr, page_size); + goto err_va_pool_free; + } + + va_block->start = virt_addr; + va_block->end = virt_addr + page_size; + va_block->size = page_size; +list_add_tail (&va_block->node, &cb->va_block_list); + } + +mutex_lock (&ctx->mmu_lock); + + bus_addr = cb->bus_address; + offset =0 ; +list_for_each_entry (va_block, &cb->va_block_list, node) { + rc =hl_mmu_map (ctx, va_block->start, bus_addr, va_block->size, +list_is_last (&va_block->node, + &cb->va_block_list)); +if (rc) { +dev_err (hdev->dev, +"Failed to map va %#llx to CB's pa %#llx\n" , + va_block->start, bus_addr); + goto err_va_umap; + } + + bus_addr += va_block->size; + offset += va_block->size; + } + + hdev->asic_funcs->mmu_invalidate_cache (hdev, false,VM_TYPE_USERPTR ); + +mutex_unlock (&ctx->mmu_lock); + + cb->is_mmu_mapped = true; + +return 0 ; + +err_va_umap: +list_for_each_entry (va_block, &cb->va_block_list, node) { +if (offset <=0 ) +break ; +hl_mmu_unmap (ctx, va_block->start, va_block->size, + offset <= va_block->size); + offset -= va_block->size; + } + + hdev->asic_funcs->mmu_invalidate_cache (hdev, true,VM_TYPE_USERPTR ); + +mutex_unlock (&ctx->mmu_lock); + +err_va_pool_free: +list_for_each_entry_safe (va_block, tmp, &cb->va_block_list, node) { +gen_pool_free (ctx->cb_va_pool, va_block->start, va_block->size); +list_del (&va_block->node); +kfree (va_block); + } + +return rc; +} + +static void cb_unmap_mem (struct hl_ctx *ctx,struct hl_cb *cb) +{ +struct hl_device *hdev = ctx->hdev; +struct hl_vm_va_block *va_block, *tmp; + +mutex_lock (&ctx->mmu_lock); + +list_for_each_entry (va_block, &cb->va_block_list, node) +if (hl_mmu_unmap (ctx, va_block->start, va_block->size, +list_is_last (&va_block->node, + &cb->va_block_list))) +dev_warn_ratelimited (hdev->dev, +"Failed to unmap CB's va 0x%llx\n" , + va_block->start); + + hdev->asic_funcs->mmu_invalidate_cache (hdev, true,VM_TYPE_USERPTR ); + +mutex_unlock (&ctx->mmu_lock); + +list_for_each_entry_safe (va_block, tmp, &cb->va_block_list, node) { +gen_pool_free (ctx->cb_va_pool, va_block->start, va_block->size); +list_del (&va_block->node); +kfree (va_block); + } +} +static void cb_fini (struct hl_device *hdev,struct hl_cb *cb) {if (cb->is_internal)
@@ -47,6 +173,9 @@ static void cb_release(struct kref *ref)hl_debugfs_remove_cb (cb); +if (cb->is_mmu_mapped) +cb_unmap_mem (cb->ctx, cb); +hl_ctx_put (cb->ctx);cb_do_release (hdev, cb);
@@ -110,7 +239,7 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size,int hl_cb_create (struct hl_device *hdev,struct hl_cb_mgr *mgr,struct hl_ctx *ctx,u32 cb_size,bool internal_cb, -u64 *handle) +bool map_cb,u64 *handle) {struct hl_cb *cb;bool alloc_new_cb = true;
@@ -169,13 +298,26 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr, cb->ctx = ctx;hl_ctx_get (hdev, cb->ctx); +if (map_cb) { +if (ctx_id ==HL_KERNEL_ASID_ID ) { +dev_err (hdev->dev, +"CB mapping is not supported for kernel context\n" ); + rc = -EINVAL ; + goto release_cb; + } + + rc =cb_map_mem (ctx, cb); +if (rc) + goto release_cb; + } +spin_lock (&mgr->cb_lock); rc =idr_alloc (&mgr->cb_handles, cb,1 ,0 ,GFP_ATOMIC );spin_unlock (&mgr->cb_lock);if (rc <0 ) {dev_err (hdev->dev,"Failed to allocate IDR for a new CB\n" ); - goto release_cb; + goto unmap_mem; } cb->id = (u64 ) rc;
@@ -194,6 +336,9 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,return 0 ; +unmap_mem: +if (cb->is_mmu_mapped) +cb_unmap_mem (cb->ctx, cb); release_cb:hl_ctx_put (cb->ctx);cb_do_release (hdev, cb);
@@ -256,7 +401,9 @@ int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data) rc = -EINVAL ; }else { rc =hl_cb_create (hdev, &hpriv->cb_mgr, hpriv->ctx, - args->in.cb_size, false, &handle); + args->in.cb_size, false, + !!(args->in.flags &HL_CB_FLAGS_MAP ), + &handle); }memset (args,0 ,sizeof (*args));
@@ -442,7 +589,7 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size,int rc; rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, cb_size, - internal_cb, &cb_handle); + internal_cb, false, &cb_handle);if (rc) {dev_err (hdev->dev,"Failed to allocate CB for the kernel driver %d\n" , rc);
@@ -498,3 +645,45 @@ int hl_cb_pool_fini(struct hl_device *hdev)return 0 ; } + +int hl_cb_va_pool_init (struct hl_ctx *ctx) +{ +struct hl_device *hdev = ctx->hdev; +struct asic_fixed_properties *prop = &hdev->asic_prop; +int rc; + +if (!hdev->supports_cb_mapping) +return 0 ; + + ctx->cb_va_pool =gen_pool_create (__ffs (prop->pmmu.page_size),-1 ); +if (!ctx->cb_va_pool) { +dev_err (hdev->dev, +"Failed to create VA gen pool for CB mapping\n" ); +return -ENOMEM ; + } + + rc =gen_pool_add (ctx->cb_va_pool, prop->cb_va_start_addr, + prop->cb_va_end_addr - prop->cb_va_start_addr,-1 ); +if (rc) { +dev_err (hdev->dev, +"Failed to add memory to VA gen pool for CB mapping\n" ); + goto err_pool_destroy; + } + +return 0 ; + +err_pool_destroy: +gen_pool_destroy (ctx->cb_va_pool); + +return rc; +} + +void hl_cb_va_pool_fini (struct hl_ctx *ctx) +{ +struct hl_device *hdev = ctx->hdev; + +if (!hdev->supports_cb_mapping) +return ; + +gen_pool_destroy (ctx->cb_va_pool); +}
drivers/misc/habanalabs/common/context.c +11 -1
@@ -37,6 +37,7 @@ static void hl_ctx_fini(struct hl_ctx *ctx)if ((hdev->in_debug) && (hdev->compute_ctx == ctx))hl_device_set_debug_mode (hdev, false); +hl_cb_va_pool_fini (ctx);hl_vm_ctx_fini (ctx);hl_asid_free (hdev, ctx->asid); }else {
@@ -155,15 +156,24 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) goto err_asid_free; } + rc =hl_cb_va_pool_init (ctx); +if (rc) { +dev_err (hdev->dev, +"Failed to init VA pool for mapped CB\n" ); + goto err_vm_ctx_fini; + } + rc = hdev->asic_funcs->ctx_init (ctx);if (rc) {dev_err (hdev->dev,"ctx_init failed\n" ); - goto err_vm_ctx_fini; + goto err_cb_va_pool_fini; } }return 0 ; +err_cb_va_pool_fini: +hl_cb_va_pool_fini (ctx); err_vm_ctx_fini:hl_vm_ctx_fini (ctx); err_asid_free:
drivers/misc/habanalabs/common/habanalabs.h +19 -1
@@ -291,6 +291,10 @@ struct hl_mmu_properties {* @pcie_aux_dbi_reg_addr: Address of the PCIE_AUX DBI register. * @mmu_pgt_addr: base physical address in DRAM of MMU page tables. * @mmu_dram_default_page_addr: DRAM default page physical address. +* @cb_va_start_addr: virtual start address of command buffers which are mapped +* to the device's MMU. +* @cb_va_end_addr: virtual end address of command buffers which are mapped to +* the device's MMU. * @mmu_pgt_size: MMU page tables total size. * @mmu_pte_size: PTE size in MMU page tables. * @mmu_hop_table_size: MMU hop table size.
@@ -339,6 +343,8 @@ struct asic_fixed_properties {u64 pcie_aux_dbi_reg_addr;u64 mmu_pgt_addr;u64 mmu_dram_default_page_addr; +u64 cb_va_start_addr; +u64 cb_va_end_addr;u32 mmu_pgt_size;u32 mmu_pte_size;u32 mmu_hop_table_size;
@@ -421,6 +427,8 @@ struct hl_cb_mgr {* @lock: spinlock to protect mmap/cs flows. * @debugfs_list: node in debugfs list of command buffers. * @pool_list: node in pool list of command buffers. +* @va_block_list: list of virtual addresses blocks of the CB if it is mapped to +* the device's MMU. * @id: the CB's ID. * @kernel_address: Holds the CB's kernel virtual address. * @bus_address: Holds the CB's DMA address.
@@ -430,6 +438,7 @@ struct hl_cb_mgr {* @mmap: true if the CB is currently mmaped to user. * @is_pool: true if CB was acquired from the pool, false otherwise. * @is_internal: internaly allocated +* @is_mmu_mapped: true if the CB is mapped to the device's MMU. */ struct hl_cb {struct kref refcount;
@@ -438,6 +447,7 @@ struct hl_cb {spinlock_t lock;struct list_head debugfs_list;struct list_head pool_list; +struct list_head va_block_list;u64 id;u64 kernel_address;dma_addr_t bus_address;
@@ -447,6 +457,7 @@ struct hl_cb {u8 mmap;u8 is_pool;u8 is_internal; +u8 is_mmu_mapped; };
@@ -843,6 +854,8 @@ struct hl_va_range {* @mmu_lock: protects the MMU page tables. Any change to the PGT, modifying the * MMU hash or walking the PGT requires talking this lock. * @debugfs_list: node in debugfs list of contexts. +* @cb_va_pool: device VA pool for command buffers which are mapped to the +* device's MMU. * @cs_sequence: sequence number for CS. Value is assigned to a CS and passed * to user so user could inquire about CS. It is used as * index to cs_pending array.
@@ -874,6 +887,7 @@ struct hl_ctx {struct mutex mmu_lock;struct list_head debugfs_list;struct hl_cs_counters cs_counters; +struct gen_pool *cb_va_pool;u64 cs_sequence;u64 *dram_default_hops;spinlock_t cs_lock;
@@ -1574,6 +1588,7 @@ struct hl_mmu_funcs {* @sync_stream_queue_idx: helper index for sync stream queues initialization. * @supports_coresight: is CoreSight supported. * @supports_soft_reset: is soft reset supported. +* @supports_cb_mapping: is mapping a CB to the device's MMU supported. */ struct hl_device {struct pci_dev *pdev;
@@ -1673,6 +1688,7 @@ struct hl_device {u8 sync_stream_queue_idx;u8 supports_coresight;u8 supports_soft_reset; +u8 supports_cb_mapping;/* Parameters for bring-up */ u8 mmu_enable;
@@ -1840,7 +1856,7 @@ void hl_hwmon_fini(struct hl_device *hdev);int hl_cb_create (struct hl_device *hdev,struct hl_cb_mgr *mgr,struct hl_ctx *ctx,u32 cb_size,bool internal_cb, -u64 *handle); +bool map_cb,u64 *handle);int hl_cb_destroy (struct hl_device *hdev,struct hl_cb_mgr *mgr,u64 cb_handle);int hl_cb_mmap (struct hl_fpriv *hpriv,struct vm_area_struct *vma); struct hl_cb *hl_cb_get(struct hl_device *hdev, struct hl_cb_mgr *mgr,
@@ -1852,6 +1868,8 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size, bool internal_cb);int hl_cb_pool_init (struct hl_device *hdev);int hl_cb_pool_fini (struct hl_device *hdev); +int hl_cb_va_pool_init (struct hl_ctx *ctx); +void hl_cb_va_pool_fini (struct hl_ctx *ctx);void hl_cs_rollback_all (struct hl_device *hdev); struct hl_cs_job *hl_cs_allocate_job(struct hl_device *hdev,
drivers/misc/habanalabs/gaudi/gaudi.c +2 -2
@@ -4115,7 +4115,7 @@ static int gaudi_parse_cb_mmu(struct hl_device *hdev,sizeof (struct packet_msg_prot ) *2 ; rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, - parser->patched_cb_size, false, + parser->patched_cb_size, false, false, &patched_cb_handle);if (rc) {
@@ -4189,7 +4189,7 @@ static int gaudi_parse_cb_no_mmu(struct hl_device *hdev, goto free_userptr; rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, - parser->patched_cb_size, false, + parser->patched_cb_size, false, false, &patched_cb_handle);if (rc) { dev_err(hdev->dev,
drivers/misc/habanalabs/goya/goya.c +2 -2
@@ -3811,7 +3811,7 @@ static int goya_parse_cb_mmu(struct hl_device *hdev,sizeof (struct packet_msg_prot ) *2 ; rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, - parser->patched_cb_size, false, + parser->patched_cb_size, false, false, &patched_cb_handle);if (rc) {
@@ -3885,7 +3885,7 @@ static int goya_parse_cb_no_mmu(struct hl_device *hdev, goto free_userptr; rc =hl_cb_create (hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, - parser->patched_cb_size, false, + parser->patched_cb_size, false, false, &patched_cb_handle);if (rc) { dev_err(hdev->dev,
include/uapi/misc/habanalabs.h +11 -1
@@ -462,6 +462,9 @@ struct hl_info_args {/* 2MB minus 32 bytes for 2xMSG_PROT */ #define HL_MAX_CB_SIZE (0x200000 - 32) +/* Indicates whether the command buffer should be mapped to the device's MMU */ +#define HL_CB_FLAGS_MAP 0x1 +struct hl_cb_in {/* Handle of CB or 0 if we want to create one */ __u64 cb_handle;
@@ -473,7 +476,8 @@ struct hl_cb_in {__u32 cb_size;/* Context ID - Currently not in use */ __u32 ctx_id; -__u32 pad; +/* HL_CB_FLAGS_* */ +__u32 flags; };struct hl_cb_out {
@@ -856,6 +860,12 @@ struct hl_debug_args {* When creating a new CB, the IOCTL returns a handle of it, and the user-space * process needs to use that handle to mmap the buffer so it can access them. * +* In some instances, the device must access the command buffer through the +* device's MMU, and thus its memory should be mapped. In these cases, user can +* indicate the driver that such a mapping is required. +* The resulting device virtual address will be used internally by the driver, +* and won't be returned to user. +* */ #define HL_IOCTL_CB \ _IOWR('H', 0x02, union hl_cb_args)
Signature · 1 line
2.17.1
PATCH 11/11 habanalabs: update firmware interface file
In reply to Oded GabbayAdd new packet to fetch PLL information from firmware. This will be needed in the future when the driver won't be able to access the PLL registers directly
--- .../misc/habanalabs/include/common/cpucp_if.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/misc/habanalabs/include/common/cpucp_if.h +25 -0
@@ -213,6 +213,12 @@ enum pq_init_status {* Trigger the reset_history property of a specified current sensor. * The packet's arguments specify the desired sensor and the field to * set. +* +* CPUCP_PACKET_PLL_REG_GET +* Fetch register of PLL from the required PLL IP. +* The packet's arguments specify the PLL IP and the register to get. +* Each register is 32-bit value which is returned in result field. +* */ enum cpucp_packet_id {
@@ -245,6 +251,7 @@ enum cpucp_packet_id {CPUCP_PACKET_PCIE_THROUGHPUT_GET ,/* internal */ CPUCP_PACKET_PCIE_REPLAY_CNT_GET ,/* internal */ CPUCP_PACKET_TOTAL_ENERGY_GET ,/* internal */ + CPUCP_PACKET_PLL_REG_GET, /* internal */ };#define CPUCP_PACKET_FENCE_VAL 0xFE8CE7A5
@@ -279,6 +286,11 @@ struct cpucp_packet {__u8 pad;/* unused */ }; +struct {/* For PLL register fetch */ +__le16 pll_type; +__le16 pll_reg; + }; +/* For any general request */ __le32 index;
@@ -354,6 +366,19 @@ enum cpucp_pcie_throughput_attributes {cpucp_pcie_throughput_rx }; +enum cpucp_pll_reg_attributes { + cpucp_pll_nr_reg, + cpucp_pll_nf_reg, + cpucp_pll_od_reg, + cpucp_pll_div_factor_reg, + cpucp_pll_div_sel_reg +}; + +enum cpucp_pll_type_attributes { + cpucp_pll_cpu, + cpucp_pll_pci, +}; +/* Event Queue Packets */ struct eq_generic_event {
Signature · 1 line
2.17.1