aboutsummaryrefslogtreecommitdiff
path: root/drivers/accel
AgeCommit message (Collapse)AuthorFilesLines
2023-03-20accel/habanalabs: regenerate gaudi2 ids_map_extendedOhad Sharabi1-38/+38
Some names of events has been modified/added. Signed-off-by: Ohad Sharabi <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: expose dram reserved size by kmdOfir Bitton1-0/+1
We expose this in order for user applications to know how much dram is reserved for internal use. Signed-off-by: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: remove '\n' when passing strings to gaudi2_print_event()Tomer Tayar1-11/+11
Remove all '\n' from strings which are passed as arguments to gaudi2_print_event(), because the newline character is added internally in this function. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: return tlb inv error code upon failureKoby Elbaz2-18/+43
Now that CQ-completion based jobs do not trigger a reset upon failure, failure of such jobs (e.g., MMU cache invalidation) should be handled by the caller itself depending on the error code returned to it. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: in {e/p}dma_core events read the err cause regDafna Hirschfeld1-7/+33
Since the err_cause register is unprivileged, we should read it from the driver instead of using the param that came from the FW. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: fix use of var reset_sleep_msDafna Hirschfeld1-18/+16
- remove reset_sleep_ms arg from functions that don't use it. - move the call msleep(reset_sleep_ms) from btm poll to gaudi2_hw_fini as it is called from there already for other flow. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: in hw_fini return error code if polling timed-outDafna Hirschfeld3-12/+14
In hw_fini callback, we use either the cpucp packet method or polling a register. Currently we return error only in the case of cpucp packet failure. In this patch we also return error if polling timed out. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: increase reset poll timeoutOfir Bitton1-1/+2
Due to a firmware bug we need to increase reset poll timeout or else we will timeout in secured environments. Signed-off-by: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: do not verify engine modes after being changedKoby Elbaz1-34/+1
Engines idle state can't always be verified between changes of engine modes (e.g., stall/halt). For example, if a CS is inflight when altering engine's mode, idle state will return NOT idle, always. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: align to latest firmware specsOded Gabbay5-40/+27
Copy the most up-to-date interface files to the firmware. Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Ofir Bitton <[email protected]>
2023-03-20accel/habanalabs: Fix spelling mistake "maped" -> "mapped"Colin Ian King1-1/+1
There is a spelling mistake in a dev_err message. Fix it. Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-20accel/habanalabs: make gaudi2_is_device_idle() staticOded Gabbay1-1/+1
This function is only called inside gaudi2.c file. Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Ofir Bitton <[email protected]>
2023-03-17driver core: class: remove module * from class_create()Greg Kroah-Hartman2-2/+2
The module pointer in class_create() never actually did anything, and it shouldn't have been requred to be set as a parameter even if it did something. So just remove it and fix up all callers of the function in the kernel tree at the same time. Cc: "Rafael J. Wysocki" <[email protected]> Acked-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2023-03-15accel/habanalabs: Drop redundant pci_enable_pcie_error_reporting()Bjorn Helgaas1-5/+0
pci_enable_pcie_error_reporting() enables the device to send ERR_* Messages. Since commit f26e58bf6f54 ("PCI/AER: Enable error reporting when AER is native"), the PCI core does this for all devices during enumeration, so the driver doesn't need to do it itself. Remove the redundant pci_enable_pcie_error_reporting() call from the driver. Also remove the corresponding pci_disable_pcie_error_reporting() from the driver .remove() path. Note that this only controls ERR_* Messages from the device. An ERR_* Message may cause the Root Port to generate an interrupt, depending on the AER Root Error Command register managed by the AER service driver. Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: postpone mem_mgr IDR destruction to hpriv_release()Tomer Tayar4-1/+23
The memory manager IDR is currently destroyed when user releases the file descriptor. However, at this point the user context might be still held, and memory buffers might be still in use. Later on, calls to release those buffers will fail due to not finding their handles in the IDR, leading to a memory leak. To avoid this leak, split the IDR destruction from the memory manager fini, and postpone it to hpriv_release() when there is no user context and no buffers are used. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: move soft-reset wait to soft-reset executeDafna Hirschfeld1-24/+26
We plan to do soft-reset either by mmio or by using cpucp packet depending on the FW version. We don't want to check FW version in two different places for that (execute soft-reset and wait to soft-reset) so move the waiting to gaudi2_execute_soft_reset. This also makes sense because the cpucp also does the waiting. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: add uapi to stall/resume engineKoby Elbaz6-5/+325
The user might want to stall/resume engines to perform power testing for various scenarios. Because our current HL_CS_FLAGS_ENGINE_CORE_COMMAND command only handles the engines' cores, we need to add another opcode for handling entire engine and not just its core. The user supplies an array, where each entry holds the engine's ID and the command to send to the engine. The size of the array is limited by the number of engines in the ASIC (only Gaudi2 is currently supported). Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: use scnprintf() in print_device_in_use_info()Tomer Tayar1-26/+10
compose_device_in_use_info() was added to handle the snprintf() return value in a single place. However, the buffer size in print_device_in_use_info() is set such that it would be enough for the max possible print, so compose_device_in_use_info() is not really needed. Moreover, scnprintf() can be used instead of snprintf(), to save the check if the return value larger than the given size. Cc: Stanislaw Gruszka <[email protected]> Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: unify err log of hw-fini failure in dirty stateDafna Hirschfeld1-1/+1
print more informative message when failing in dirty state Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: use a mutex rather than a spinlockKoby Elbaz2-9/+10
There are two reasons why mutex is better here: 1. There's a critical section relatively long, where in certain scenarios (e.g., multiple VM allocations) taking a spinlock might cause noticeable performance degradation. 2. It will remove the incorrect usage of mutex under spin_lock (where preemption is disabled). Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: allow getting HL_INFO_DRAM_USAGE during soft-resetDafna Hirschfeld1-4/+2
We can allow userspace to query the dram usage during soft-reset. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: fix register address on PDMA/EDMA idle checkKoby Elbaz1-22/+22
The PDMA/EDMA is_idle routines didn't check the correct CORE register in order to get the accurate idle state. Moreover, it's better to make the is_idle routine more robust by adding additional checks (IS_HALTED) before announcing that the core is idle. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: remove a useless is_idle TPC flagKoby Elbaz1-1/+0
Is appears that the flag - DCORE0_TPC0_CFG_STATUS_VECTOR_PIPE_EMPTY_MASK, has no actual use when it comes to querying TPC idleness, since this flag's corresponding bit turns-off after stalling the engine, and turns back on after resuming it. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: fix few misspelled words in the codefarah kassabri6-10/+10
Run spell checker on the code and fix accordingly. Signed-off-by: farah kassabri <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: verify return code after scrubbing ARCs DCCMsKoby Elbaz1-4/+22
In case the KDMA fails scrubbing the DCCMs (following a soft-reset upon device release), the driver will only print failure until reset flow ends, rather than escalating it into a hard-reset. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: use notifications and graceful reset for decoderTomer Tayar1-6/+16
Add notifications to user in case of decoder abnormal interrupts, and use the graceful reset mechanism if reset is required. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: assert return value of hw_finiDafna Hirschfeld4-6/+27
Since hw_fini return error code for failure indication, we should check its return value. Currently it might only fail upon soft-reset from hl_device_reset. Later patch will add hw_fini failure in case of polling timeout in hard-reset. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: break is_idle function into per-engine sub-routinesKoby Elbaz1-66/+146
is_idle() was too long, so break it up for readability. In addition, we can now use the new sub-routines from other places. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: add device id to all threads namesSagiv Ozeri1-8/+12
Compute driver threads names will start with hlX-*, when X is the device id. This will help distinguish them from the NIC thread names. Signed-off-by: Sagiv Ozeri <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: add helper function to get vm hash nodeTomer Tayar1-12/+16
Add a helper function to search the vm hash for a node with a given virtual address. As opposed to the current code, this function explicitly returns NULL when no node is found, instead of basing on the loop cursor object's value. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: remove unneeded irq_handler variableTomer Tayar1-5/+3
'irq_handler' in gaudi2_enable_msix(), is just assigned with a function name and then used when calling request_threaded_irq(). Remove the variable and use the function name directly as an argument. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: change hw_fini to return int to indicate errorDafna Hirschfeld4-7/+10
We later use cpucp packet for soft reset which might fail so we should be able propagate the failure case. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: improve readability of engines idle mask printTomer Tayar1-12/+11
Remove leading zeroes when printing the idle mask to make it clearer. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: organize hl_device structure commentSagiv Ozeri1-3/+3
Make the comments align with the order of the fields in the structure Signed-off-by: Sagiv Ozeri <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: set hl_capture_*_err storage-class-specifier to staticTom Rix1-2/+2
smatch reports drivers/accel/habanalabs/common/device.c:2619:6: warning: symbol 'hl_capture_hw_err' was not declared. Should it be static? drivers/accel/habanalabs/common/device.c:2641:6: warning: symbol 'hl_capture_fw_err' was not declared. Should it be static? both are only used in device.c, so they should be static Signed-off-by: Tom Rix <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: change unused extern decl of hdev to forward decl of hl_deviceTom Rix1-1/+1
Building with clang W=2 has several similar warnings drivers/accel/habanalabs/common/decoder.c:46:51: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static void dec_error_intr_work(struct hl_device *hdev, u32 base_addr, u32 core_id) ^ drivers/accel/habanalabs/common/security.h:13:26: note: previous declaration is here extern struct hl_device *hdev; ^ There is no global definition of hdev, so the extern is not needed. Searched with grep -r '^struct' . | grep hl_dev Change to an forward decl to resolve these issues drivers/accel/habanalabs/common/mmu/../security.h:133:40: error: ‘struct hl_device’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror] 133 | bool (*skip_block_hook)(struct hl_device *hdev, | ^~~~~~~~~ Signed-off-by: Tom Rix <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
2023-03-15accel/habanalabs: don't trace cpu accessible dma alloc/freeDafna Hirschfeld2-29/+12
The cpu accessible dma allocations use the gen_pool api which actually does not allocate new memory from the system but manages memory already allocated before. When tracing this together with real dma allocation/free it cause confusing logs like a '0' dma address and a cpu address appearing twice etc. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: in hl_device_reset small refactor for readabiltyDafna Hirschfeld1-9/+8
in the out_err flow, combine the two cases of soft-reset since they have mostly common code. In addition unlock reset_info.lock after touching reset count. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: in hl_device_reset remove 'hard_instead_of_soft'Dafna Hirschfeld1-8/+5
Because this field is only used for debug print, we can do more precise debug directly instead. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: rename security function parametersKoby Elbaz1-3/+3
To match their description above the function Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: tiny refactor of hl_device_reset for readabilityDafna Hirschfeld1-4/+3
Align assignment of reset_upon_device_release to the convention used in this function. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: remove hl_irq_handler_default()Tomer Tayar2-19/+0
hl_irq_handler_default() is not used and can be removed. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: fix print in hl_irq_handler_eq()Tomer Tayar1-4/+3
"eq_base[eq->ci].hdr.ctl" is used directly in a print without a le32_to_cpu() conversion. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: add support for TPC assertOfir Bitton7-3/+50
In order to allow TPC engines to raise an assert, we must expose the relevant MSIX interrupt to the user so he will configure the engine correctly. In addition, we implement the corresponding interrupt handler that will notify the user upon such an event. Signed-off-by: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: capture interrupt timestamp in handlerOfir Bitton2-3/+8
In order for interrupt timestamp to be more accurate we should capture it during the interrupt handling rather than in threaded irq context. Signed-off-by: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: change user interrupt to threaded IRQTal Cohen4-35/+53
We prefer not to handle the user interrupt job inside the interrupt context. Instead, use threaded IRQ to handle the user interrupts. This will allow to avoid disabling interrupts when the user process registers for a new event and to avoid long handling inside an interrupt. Signed-off-by: Tal Cohen <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: modify events reset policyOhad Sharabi1-244/+244
The policy file of the events reset has been modified. This change is reflected in the autogenerated file. Signed-off-by: Ohad Sharabi <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: get reset type indication from irq_mapOhad Sharabi2-2649/+2661
When getting an event, add the ability to deduce the reset type from the IRQ map table instead of using hard reset regardless. Signed-off-by: Ohad Sharabi <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: enable graceful reset mechanism for compute-resetTomer Tayar1-14/+12
The graceful reset mechanism is currently enabled only for reset requests that will end up with hard-reset. In future, reset requests due to errors in some device engines, are going to be modified to request compute-reset, as the much longer hard-reset is not really needed there. To allow it, enable graceful reset also for compute-reset, and reset after user releases the device won't be escalated to hard-reset in those cases. If watchdog expires and user didn't release the device, hard-reset will be initiated in any case. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>
2023-03-15accel/habanalabs: disable PCI when escalating compute to hard-resetKoby Elbaz1-8/+8
In case a compute reset has failed or a request for a hard reset has just arrived, then we escalate current reset procedure from compute to hard-reset. In such a case, the FW should be aware of the updated error cause, and if LKD is the one who performs the reset (rather than the FW), then we ask the FW to disable PCI access. We would also like to have relevant debug info and therefore we print the currently escalating reset type. Signed-off-by: Koby Elbaz <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]>