diff options
author | Aurora pro automerger <aurora-pro-automerger@google.com> | 2023-01-06 06:59:41 +0000 |
---|---|---|
committer | davidchiang <davidchiang@google.com> | 2023-01-06 08:08:49 +0000 |
commit | 8a4b0d93e1f8b9ae23fb476eef4d43f18bc3cc1d (patch) | |
tree | 77a55bc81515aae0827a3cdb0f2ef0d68a46f677 /gxp-firmware.c | |
parent | 9cc533bf4e533f90504fe355b5fcc726c1c549e0 (diff) | |
download | gs201-8a4b0d93e1f8b9ae23fb476eef4d43f18bc3cc1d.tar.gz |
gxp: [Copybara Auto Merge] Merge branch 'gs201-u' into 'android13-gs-pixel-5.10-udc'
gxp: amalthea uses different edgetpu path
Bug: 263918299
gxp: fix uninit warn of gxp_debugfs_mailbox
gcip: style fix up
gcip: implement noncontiguous alloc
Bug: 262684159
gcip: Change hard-coded magic numbers to MACROs
Bug: 257300340
gcip: Update the size encoding of image config
Bug: 257300340 (repeat)
gcip: unittests: implement timeout race trigger
Bug: 261822585
gcip: implement reference count to the awaiter
Bug: 261822585 (repeat)
gcip: implement gcip_mailbox_cancel_awaiter
Bug: 261822585 (repeat)
gcip: fix log style in gcip domain pool
gcip: Add domain pool
Bug: 228907682
gcip: init ignore_seq_order of KCI
gcip: Use term awaiter instead of async_resp
Bug: 249642792
gcip: constantize gcip_kci_args
gcip: use rate limiting for reverse KCI failure warning
gcip: remote unnecessary pointer cast
gcip: Check telemetry buffer size
gcip: Remove redundant error
gcip: support arbitrary seq order commands
Bug: 247414706
gcip: Add gcip-telemetry
Bug: 239374826
gcip: use pad/pap instead of llx for logging
gcip: implement gcip image config utilities
Bug: 243500340
gcip: Don't pass mailbox param when calling the release_async_resp_data callback
Bug: 239804137
gcip: Call release_data callback instead of ops->release_async_resp_data
Bug: 239804137 (repeat)
gcip: fix typo 'timedout'
gcip: Implement gcip-firmware.c
Bug: 239637765
gcip: Free arrived or timedout, but not handled async_resp
Bug: 239010918
gcip: Set base_paddr of gcip_mem_pool
Bug: 236673496
gcip: Adopt gcip-mailbox to gcip-kci
Bug: 236679300
gcip: Implement the generalized mailbox (gcip-mailbox.c)
Bug: 236679300 (repeat)
gcip: Make gcip_kci_push_cmd static
Bug: 223764481
gcip: implement gcip-mem-pool
Bug: 236673496 (repeat)
gcip: Add KCI support
Bug: 223764481 (repeat)
gcip: unittests: Add initial Kconfig and Makefile
Bug: 222416109
gcip: Add initial Kconfig and Makefile
Bug: 222416109 (repeat)
GCIP_MAIN_REV_ID: a1895a61a873d1f52896f955e09d2e263b22a0e8
gxp: bump GXP version to 1.7
gxp: remove debugfs earlier than before_remove
Bug: 263830035
gxp: adopt updated gxp_client_allocate_virtual_device
gxp: debugfs utilizes UCI in the MCU mode
Bug: 263830035 (repeat)
gxp: call gxp_client_* funcs from firmware_run debugfs
Bug: 263830035 (repeat)
gxp: apply clang-format to gxp-debugfs.c
gxp: update the interface of execute_cmd callback
Bug: 263830035 (repeat)
gxp: power off core on mbox allocation failure
Bug: 264184974
gxp: Set special client ID to secure VD
Bug: 263685745
gxp: Allocate secure VD
Bug: 263836991
gxp: Add a secure VD field to struct gxp_dev
Bug: 263685535
gxp: Add 'flags' to struct gxp_virtual_device_ioctl
Bug: 263836981
gxp: Remove warnings during compilation
Bug: 264010198
gxp: cleanup common platform probe
Bug: 263844135
gxp: amalthea use GCIP
Bug: 263918299 (repeat)
gxp: update Makefile for kleaf support
gxp: use PMU register
Bug: 263830026
gxp: map private firmware data region
Bug: 261797596
gxp: introduce gxp_dma_map_iova_sgt
Bug: 262825536
gxp: allocate per VD firmware data
Bug: 261797596 (repeat)
gxp: Correct the lpm offsets calculations
Bug: 263239197
gxp: Move shareability config with block power configuration
Bug: 263310466
gxp: Enable new telemetry
Bug: 247955426
gxp: enable dynamic slice index
Bug: 255706432
gxp: Add support for core_boot insmod parameter
Bug: 251612313
gxp: Add first_open support to VMBox
Bug: 263296400
gxp: new UCI ioctl interfaces
Bug: 261667704
gxp: remove unused virt_core in vd_suspend
gxp: move system memory rates to config files
Bug: 262964769
gxp: increase shared buffer size from 192K to 512K
Bug: 262686729
gxp: introduce wait_queue for waiting responses
Bug: 261822585 (repeat)
gxp: rename queue to dest_queue
Bug: 261822585 (repeat)
gxp: adopt gxp-mcu-platform
Bug: 249918544
gxp: revert tpu mapped checking logic
gxp: Add telemetry buffer size fields to specs ioctl
Bug: 259404526
gxp: fix error handling of gxp_map_tpu_mbx_queue
gxp: fix logic of checking tpu_file when destroying clients
gxp: europa: add mailbox array csrs
Bug: 261150717
gxp: Implement mmap for new telemetry flow.
Bug: 259404466
gxp: add 'features' field to specs
Bug: 256073820
gxp: fix up reserved fields in gxp_specs_ioctl
gxp: Add missing include
Bug: 261550238
gxp: Apply gcip domain pool
Bug: 228907682 (repeat)
gxp: Move mailbox CSR based calls to chip specific file
Bug: 261150717 (repeat)
gxp: Make mailbox csr offset chip specific
Bug: 261150717 (repeat)
gxp: Allocate telemetry buffers during init
Bug: 247955426 (repeat)
gxp: introduce gxp-mcu-fs
Bug: 249918544 (repeat)
gxp: move client_has_vd check to client.c
Bug: 249918544 (repeat)
gxp: use entry point in elf header instead of fixed IOVA
Bug: 260647260
gxp: Add _legacy postfix to telemetry function
Bug: 247955426 (repeat)
gxp: Refactor LPM to accommodate new chips
Bug: 254168276
gxp: introduce gxp_pm_update_pm_qos
Bug: 239638427
gxp: map tpu mbx queue even in MCU mode
Bug: 237624453
gxp: fetch segment boundaries from ELF header
Bug: 259197130
gxp: add ifdef guard for edgetpu_ext interface
Bug: 259357745
gxp: set VD credit to 256
Bug: 257137038
gxp: Indroduce config-pwr-state.h
Bug: 258154981
gxp: add cmd credit to virtual device
Bug: 257137038 (repeat)
gxp: fix the default domain cache
gxp: revert ignore_seq_order settings
gxp: Map TPU mbx only in the direct mode
Bug: 249440369
gxp: Forward the thermal request to MCU when possible
Bug: 255613035
gxp: Introduce gxp_wakelock_acquire_if_powered
Bug: 255613035 (repeat)
gxp: Add GXP_HAS_MCU config
gxp: Roll back aur_power_state2rate changes in thermal
gxp: Use aur_power_state2rate for thermal
gxp: Fix reader/writer lock for vd allocation
Bug: 257049139
gxp: Add a static debug pointer to driver state
Bug: 255451381
gxp: fixup headers in platform.c
gxp: remove obsolete ACPI support
Bug: b/230701592
gxp: Add namespace import for DMA_BUF for 5.16
Bug: 232003048
gxp: Handle Core TelemetryRead rcki
Bug: 249096610
gxp: Add GXP_HAS_LAP to config
Bug: 249227451
gxp: remove explicit values of LPM PSM enum
gxp: temporarily set slice_index to 0
Bug: 255706432 (repeat)
Bug: 242011394
gxp: do power votes in VD wakelock acquisition
Bug: 253990922, 253555787
gxp: Remove redundant state settings
Bug: 189396709
gxp: LPM interfaces accepts enum psm
Bug: 254168276 (repeat)
gxp: Reduce mailbox timeout to 1s
Bug: 250265514
gxp: Adopt awaiter of GCIP
Bug: 249642792 (repeat)
gxp: disable core interrupts before core releasing
Bug: 252915360
gxp: remove response consuming callbacks
Bug: 245455607
gxp: abstract GCIP send/put funcs from gxp-mailbox
Bug: 245455607 (repeat)
gxp: re-purpose GXP_LEGACY_MAILBOX
Bug: 245455607 (repeat)
gxp: use const args for mailbox init
gxp: bump uapi version to 1.5
gxp: remove unnecessary coherent buf cast
gxp: fix typo an core
gxp: Call MCU telemetry irq handler when KCI irq is fired
BUg: 237099103
gxp: move DVFS macro out from lpm.h
gxp: use BIT() for shifting operations
gxp: introduce coherent buffer data structure
Bug: 248436918
gxp: add europa platform driver
Bug: 235918085
gxp: address review comments on gdomain alloc
gxp: store client IDs in gxp_virtual_device
Bug: 246520556
gxp: clang-format gxp.h
gxp: introduce {after,before}_{map,unmap}_tpu_mbx_queue callbacks
Bug: 246520556 (repeat)
gxp: call GCIP consume funcs from gxp-mailbox
Bug: 245455607 (repeat)
gxp: manage gcip_{mailbox,kci} from gxp_mailbox
Bug: 245455607 (repeat)
gxp: pass data size and wrap bit to gxp_mailbox_args
Bug: 245455607 (repeat)
gxp: pass GCIP operators to gxp_mailbox
Bug: 245455607 (repeat)
gxp: introduce enum gxp_mailbox_type
Bug: 245455607 (repeat)
gxp: call exposed response consuming funcs of gxp-mailbox-impl.h
Bug: 245455607 (repeat)
gxp: expose response consuming functions to gxp-mailbox-impl.h
Bug: 245455607 (repeat)
gxp: Add MCU telemetry support
Bug: 237099103 (repeat)
gxp: Add chip specific mmap handler
Bug: 237099103 (repeat)
gxp: Prefix the telemetry with core
Bug: 237099103 (repeat)
gxp: Rename gxp-telemetry to gxp-core-telemetry
Bug: 237099103 (repeat)
gxp: add wrappers around iommu domain
Bug: 248436918 (repeat)
gxp: introduce gxp-mailbox-impl.[c|h]
Bug: 237908534
gxp: Hide Amalthea only things of gxp-mailbox from Callisto
Bug: 237908534 (repeat)
gxp: introduce GXP_LEGACY_MAILBOX
Bug: 245455607 (repeat)
gxp: return error when gxp_fw_data_create_app fails
Bug: 249402363
gxp: fix memory leak on VD allocate resp queues
Bug: 247662695
gxp: Wait for PS0 before powering down BLK_AUR
Bug: 247273478
gxp: Enable best-fit IOVA allocator
Bug: 241190719
gxp: remove compat ioctl interfaces
gxp: remove cache invalidate of telemetry buffers
Bug: 247772036
Bug: 245238253
gxp: cache invalidate on signal telemetry eventfd
Bug: 247772036 (repeat)
gxp: fix passing a NULL pointer to the gxp_vd_block_ready
Bug: 247660434
gxp: Sort the GXP_IOCTL defines
gxp: accept finalizing non-initalized modules
Bug: 245690393
gxp: introduce IS_GXP_TEST
Bug: 245690393 (repeat)
gxp: define chip_rev module param
gxp: sync with the fake core firmware
Bug: 245270826
gxp: invalidate cache before fetching responses
Bug: 242326098
gxp: make load_dsp_firmware return error properly
Bug: 245270826 (repeat)
gxp: support VD suspend/resume in Zuma direct mode
Bug: 244699959
gxp: bump version to 1.4
Revert "gxp: Update gxp.h to reflect OFF being allowed in mbox IOCTL"
Revert "gxp: remove GXP_POWER_STATE_OFF check in mbox cmd"
gxp: Removing printing the log buff
Bug: 244270315
gxp: support both coherent/non-coherent mappings
Bug: 205831251
gxp: fix the unused warning on gem5 platform
gxp: Update gxp.h to reflect OFF being allowed in mbox IOCTL
Bug: 243737206
gxp: add wakelock_{after,before}_blk_{on,off}
Bug: 241044848
gxp: Attach device after iommu domain allocated
Bug: 243328707
gxp: Introduce {after,before}_vd_block_{ready,unready} callbacks
Bug: 241057541
gxp: Rollback {after,before}_{allocate,release}_vd callbacks
Bug: 241057541 (repeat)
gxp: Introduce the `gxp_vd_block_unready` function.
Bug: 241057541 (repeat)
gxp: Make the `gxp_vd_stop` can work with READY state
Bug: 241057541 (repeat)
gxp: wrap power states into a struct
Bug: 242155424
gxp: fix various typos
gxp: Protect telemetry status in vd alloc/release
Bug: 242145264
gxp: Fail to allocate VD if initial mapping fails
Bug: 242145264 (repeat)
gxp: Use one gxp_mailbox_create_manager
Bug: 242939166
gxp: Extract mailbox manager from gxp-mailbox.h
Bug: 242939166 (repeat)
gxp: Implement the mailbox manager operator setting function of UCI
Bug: 242178774
gxp: Add init functions for the legacy mailbox and DCI
Bug: 242178774 (repeat)
gxp: Introduce `GXP_HAS_DCI` definition
Bug: 242964051
gxp: fix error handling on probing
gxp: append internal headers after EXTRA_CFLAGS
Bug: 242960640
gxp: remove GXP_POWER_STATE_OFF check in mbox cmd
gxp: Add power states requests callback
Bug: 241782481
gxp: Allocate resources on VD creation
Bug: 241206240
gxp: handle VD allocation in gxp-client.c
Bug: 241206240 (repeat)
gxp: handle wakelock request in gxp-client.c
Bug: 241206240 (repeat)
gxp: gxp_mapping_create accepts domain
Bug: 240415495
gxp: split out gxp_vd & gxp_fw module init/destroy
Bug: 193180931
gxp: fixup DVFS requests
Bug: 242785262
gxp: Only (un)map telem if enabled on vd start/stop
Bug: 241090227
gxp: release TPU file after VD stop
Bug: 241085004
gxp: increase the ref to TPU FD on TPU buffer map
Bug: 241085004 (repeat)
gxp: misc_register as the last step of probe
Bug: 241718472
gxp: remove unneeded devm_kfree
Bug: 241517691
gxp: Cancel last worker when power req queue is full
Bug: 240533763
gxp: Map slice of shared buffer to IOMMU domain instead of whole of it
Bug: 240128962
gxp: Allocate slice_index when allocating virtual device
Bug: 240128962 (repeat)
gxp: Add ID allocator for the slice index of shared buffer
Bug: 240128962 (repeat)
gxp: Introduce slice_index of the virtual device
Bug: 240128962 (repeat)
gxp: unittests: Introduce gxp-debug-dump-test.c and enable debug dump test
Bug: 241086197
Bug: 234892966
gxp: remove domain attach on VD creation
Bug: 241057799
gxp: Add `num_cores` in command ioctls for UCI
Bug: 232310140, 237660465
gxp: Disallow /d/gxp/firmware_run if VDs are running
Bug: 240764261
gxp: remove unneeded warnings from in PM
gxp: Review feedback from 7/21 release
Bug: 240315433
gxp: work around thermal_cdev_update
Bug: 235433985
gxp: remove virt_core_list from gxp_dmabuf_map
Bug: 240661491
gxp: remove virt_core_list from gxp_mapping
Bug: 240661491 (repeat)
gxp: add gxp_vd_phys_core_list
gxp: remove ZEBU_SYSMMU_WORKAROUND
gxp: Replace (resp_queue, eventfd) params with (client, virt_core) of async ops
gxp: remove virt_core_list from tpu_mbx_desc
gxp: check VD is non-null in gxp_client_destroy
gxp: remove core_domains from vd
Bug: 240415495 (repeat)
gxp: remove gxp_vd_phys_core_to_virt_core
gxp: clean up gxp-dma.h descriptions
Bug: 240415495 (repeat)
gxp: dma_map_tpu_buffer accepts domain
Bug: 240415495 (repeat)
gxp: gxp_dma_alloc_coherent takes domain
Bug: 240415495 (repeat)
gxp: map_allocated_coherent_buffer takes domain
Bug: 240415495 (repeat)
gxp: dma_map_dmabuf accepts domain as the arg
Bug: 240415495 (repeat)
gxp: dma_map_sg accepts domain as arg
Bug: 240415495 (repeat)
gxp: dma_map_core_resources accepts domain
Bug: 240415495 (repeat)
gxp: dma_domain_attach_device accepts domain
Bug: 240415495 (repeat)
gxp: Add callbacks for after allocating / before releasing the vd
Bug: 237955391
gxp: program SSMT to the first domain
Bug: 240415495 (repeat)
gxp: deprecate virtual_core_list
Bug: 240514360
gxp: map telemetry buffers to all domains
Bug: 240415495 (repeat)
gxp: map all core resources to all domains in VD
Bug: 240415495 (repeat)
gxp: remove the core parameter from dbg dump buf
gxp: Map telemetry buffs before writing descriptor
Bug: 239640408
gxp: Decide generating interrupt after allocating mailbox according to interface
gxp: Add common operators of gcip-mailbox-ops to the gxp-mailbox-driver
gxp: Merge resp_queue wait macro into the gxp-mailbox.h
gxp: fix typos in comments
Bug: 240315433 (repeat)
gxp: rename callisto.ko to gxp.ko
Bug: 240212593
gxp: Cleanup FW data on VD creation failure
Bug: 240192343
gxp: remove the core number patch on gem5 platform
Bug: 239908693
gxp: edgetpu symbol path according to target chip
Bug: 239766974
gxp: warn deprecate pwr states only once
Bug: 237337595
gxp: don't modify clkmux state during core booting
Bug: 238960149
gxp: Map mailboxes for IOVA of KCI/UCI
Bug: 228401855
gxp: Introduce gxp-usage-stats.c and complete update_usage KCI command
Bug: 237967242
gxp: Introduce gxp-kci.c
Bug: 228401855 (repeat)
gxp: Introduce gxp-dci.c
Bug: 236332988
gxp: Remove the dependency of gcip-mailbox from Amalthea
Bug: 237908672
gxp: Introduce gxp_mailbox_args
Bug: 236332988 (repeat)
gxp: Introduce gxp_mailbox_ops
Bug: 236332988 (repeat)
gxp: Apply gcip-mailbox to gxp-mailbox
Bug: 236679300 (repeat)
gxp: Apply abstracted mailbox functions
Bug: 237908672 (repeat)
gxp: Abstracts mailbox related functions into the mailbox manager
Bug: 237908672 (repeat)
gxp: temporarily attach a domain while VD creating
Bug: 232310140
gxp: add interface to override ioctl handlers
gxp: implement UCI
Bug: 232310140 (repeat)
gxp: fix OOT build for amalthea
gxp: increase the waiting time for cores booting
Bug: 237378056
gxp: fix deadlock on power states queue full
Bug: 236087752
gxp: parallelize the firmware startup process
Bug: 207036666
gxp: Fix bug when clearing FW buffers on auth fail
Bug: 237789581
gxp: firmware load should use configured name
gxp: add gcip include for GKI kernel
gxp: deprecate NON_AGGRESSOR / add LOW_FREQ_CLKMUX
Bug: 237337595 (repeat)
Bug: 237378056 (repeat)
gxp: Disable telemetry before free
Bug: 235771175
gxp: hold mmap lock around call to find_extend_vma
Bug: 237404338
gxp: Don't change doorbell mask for running cores
Bug: 235447772
gxp: compile gcip as an object
Bug: 234674944
gxp: map shared buffer region
Bug: 237262124
gxp: add gcip support to Makefile
Bug: 234674944 (repeat)
gxp: move firmware default name to chip config
Bug: 234261504
gxp: Rename gxp-hw-mailbox-driver.c to gxp-mailbox-driver.c
Bug: 236431904
gxp: Move increasing queue head / tail functions to gxp-hw-mailbox-driver.c
Bug: 236431904 (repeat)
gxp: Move setting queue head / tail functions to gxp-hw-mailbox-driver.c
Bug: 236431904 (repeat)
gxp: Move circ queue cnt / inc functions to gxp-hw-mailbox-driver.c
Bug: 236431904 (repeat)
gxp: Apply clang-format on the mailbox sources
Bug: 236431904 (repeat)
gxp: propagate GXP_PLATFORM option to Kbuild
gxp: optional chip scratchpad region
gxp: gxp-platform adopt common-platform.c
Bug: 232894415
gxp: correct MAILBOX_DEVICE_INTERFACE_OFFSET for gem5
gxp: define ZEBU_SYSMMU_WORKAROUND in GEM5 and ZEBU_IP platform
gxp: adjust Makefile for gem5 & kernel 5.13
gxp: add a parameter to specify callisto mode
Bug: 235193368
gxp: introduce GXP_NUM_MAILBOXES config
Bug: 235173180
gxp: remove redundant checks for mailbox mgr
gxp: remove unused DMA functions
Bug: 235212179
gxp: avoid holding semaphore during mmap
Bug: 232183143
gxp: move iova.h to config files
Bug: 235173809
gxp: Remove CONFIG_GXP_TEST from the SSMT related codes
Bug: 201505925
gxp: lpm enable PS1 only for core CSRs
gxp: add an MCU structure
Bug: 229587136
gxp: define core CSR addresses as macros
Bug: 234705757
gxp: Add option to disable DSP FW auth
Bug: 235135800
gxp: Fix hangs and OOB writes when auth fails
Bug: 234947988
gxp: Adjust the per-core FW size from 16MB to 1MB
Bug: 228277106
gxp: Add enable_debug_dump argument for insmod
Bug: 234529356
gxp: Dynamically allocate memory for debug dump buffer
Bug: 234529355
gxp: Trigger debug dump only when firmware is up and running
Bug: 233660431
Bug: 233607168
gxp: remove support for unsigned firmware
Bug: 220246540
gxp: Expose additional DVFS states in power APIs
Bug: 233929549
gxp: introduce a gxp_firmware_manager
Bug: 230682809
gxp: remove CONFIG_GXP_CLOUDRIPPER
gitignore: ignore .repo and gcip-kernel-driver
Bug: 234674944 (repeat)
gxp: set VID for both SSMTs and possible SIDs
gxp: move LPM_TOP_PSM to config files
Bug: 232471681
gxp: move SID of core macros to config files
Bug: 233989804
gxp: different mailbox offset for platforms
Bug: 233887617
gxp: authenticate firmware after requesting it
Bug: 232715929
gxp: dma-iommu adopts gxp-ssmt interface
Bug: 233989804 (repeat)
gxp: add standalone ssmt driver
Bug: 233989804 (repeat)
gxp: add ifdef guard to disable suspend
Bug: 234096867
gxp: set VD state in vd_stop
Bug: 234096867 (repeat)
gxp: Add lockdep checks to gxp-telemetry.c
gxp: add log on probe success
Bug: 233887617 (repeat)
gxp: add tgid to client tracking and suspend block reporting
Bug: 230656700
Revert "gxp: send UUD request before shutting down AUR_BLK"
gxp: send UUD request before shutting down AUR_BLK
Bug: 233584605
gxp: add parse_dt callback for device probe
Bug: 232894415 (repeat)
gxp: remove unrequired CORE_SCRATCHPAD_BASE offset
Bug: 233381187
gxp: Switch the boot mode storage from CSRs into the scratchpad space
Bug: 233381187 (repeat)
gxp: Refactor FW boot mode into its own functions
Bug: 233381187 (repeat)
gxp: Fix locking in gxp_telemetry_disable()
Bug: 232876605
gxp: initial gxp mcu firmware support
Bug: 229587136 (repeat)
gxp: add callbacks for common probing / removal
Bug: 232894415 (repeat)
gxp: introduce gxp-common-platform.c
Bug: 232894415 (repeat)
gxp: remove mm-backport.h
gxp: Add NULL check of doorbells and barriers allocation
Bug: 232612591
gxp: enhance Makefile for future chip support
Bug: 230702544
gxp: debugfs use cmu.vaddr for accessing CMU CSRs
gcip: add gcip-alloc-helper.h
Bug: 262684159 (repeat)
gcip: Update the comments in gcip-image-config for new encoding
Bug: 257300340 (repeat)
gcip: add reference count to the awaiter
Bug: 261822585 (repeat)
gcip: introduce gcip_mailbox_cancel_awaiter
Bug: 261822585 (repeat)
gcip: introduce gcip_kci_offload_chip_type
Bug: 260690355
gcip: add {link,unlink}_offload_vmbox KCI codes
Bug: 260690355 (repeat)
gcip: Add domain pool
Bug: 228907682 (repeat)
gcip: Add remapped_data_{start,size} to image config
Bug: 257212385
gcip: image header use unsigned fields
gcip: add common authenticated image format header
gcip: Use term awaiter instead of async_resp
Bug: 249642792 (repeat)
gcip: constantize gcip_kci_args
gcip: support arbitrary seq order commands
Bug: 247414706 (repeat)
gcip: Add gcip-telemetry
Bug: 239374826 (repeat)
gcip: add gcip-image-config.h
Bug: 243500340 (repeat)
gcip: Add linux/workqueue.h as header
gcip: Remove mailbox param from the release_async_resp_data callback
Bug: 239804137 (repeat)
gcip: Add release_data callback to the gcip_mailbox_async_response
Bug: 239804137 (repeat)
gcip: fix typo in gcip-mailbox.h
gcip: fix various typos
gcip: Fix reverse KCI codes
Bug: 223764481 (repeat)
gcip: Introduce gcip-firmware.h
Bug: 239637765 (repeat)
gcip: add gcip_mem_pool_offset
gcip: Add KCI codes
Bug: 223764481 (repeat)
gcip: Remove the variables of gcip-kci.h which are moved to gcip-mailbox.h
Bug: 236679300 (repeat)
gcip: Add mailbox related structures and functions (gcip-mailbox.h)
Bug: 236679300 (repeat)
gcip: Add getters for gcip_kci
Bug: 237785687
gcip: Make gcip_kci_push_cmd static
Bug: 223764481 (repeat)
gcip: add gcip memory pool
Bug: 236673496 (repeat)
gcip: Add KCI related structures and functions
Bug: 223764481 (repeat)
gcip: Add mailbox macro and enum
Bug: 223764481 (repeat)
gcip: Add circular queue mailbox helper functions
Bug: 223764481 (repeat)
GCIP_HEADERS_REV_ID: 37a282fd7aad536dc4521a908468bc9557911a19
gxp: Add a static debug pointer to driver state
To assist with debugging of ramdumps where the GXP driver is not in the
backstack, add a static symbol containing a pointer to the driver state
so it can be located quickly in memory.
Bug: 255451381 (repeat)
gxp: Reduce mailbox timeout to 1s
Reduce GXP timeout to allow for faster notification of failure since the
longest any workloads are expected to run is ~500ms.
Bug: 250265514 (repeat)
GitOrigin-RevId: d7c38381aeae2ecc8b3b3f84abf45f1fe26edc4b
Change-Id: Id0718e8bff32a18aff796dfd7779e2d61a6c4a64
Diffstat (limited to 'gxp-firmware.c')
-rw-r--r-- | gxp-firmware.c | 432 |
1 files changed, 304 insertions, 128 deletions
diff --git a/gxp-firmware.c b/gxp-firmware.c index eb31f23..fcf6a6f 100644 --- a/gxp-firmware.c +++ b/gxp-firmware.c @@ -17,6 +17,8 @@ #include <linux/types.h> #include "gxp-bpm.h" +#include "gxp-config.h" +#include "gxp-core-telemetry.h" #include "gxp-debug-dump.h" #include "gxp-doorbell.h" #include "gxp-firmware.h" @@ -26,11 +28,11 @@ #include "gxp-mailbox.h" #include "gxp-notification.h" #include "gxp-pm.h" -#include "gxp-telemetry.h" #include "gxp-vd.h" -/* Files need to be copied to /lib/firmware */ -#define DSP_FIRMWARE_DEFAULT_PREFIX "gxp_fw_core" +#if IS_ENABLED(CONFIG_GXP_TEST) +#include "unittests/factory/fake-gxp-firmware.h" +#endif #define FW_HEADER_SIZE (0x1000) #define FW_IMAGE_TYPE_OFFSET (0x400) @@ -38,6 +40,9 @@ static int gxp_dsp_fw_auth_disable; module_param_named(dsp_fw_auth_disable, gxp_dsp_fw_auth_disable, int, 0660); +static bool gxp_core_boot = true; +module_param_named(core_boot, gxp_core_boot, bool, 0660); + static int request_dsp_firmware(struct gxp_dev *gxp, char *name_prefix, const struct firmware *out_firmwares[GXP_NUM_CORES]) @@ -92,59 +97,19 @@ static int elf_load_segments(struct gxp_dev *gxp, const u8 *elf_data, ehdr = (struct elf32_hdr *)elf_data; phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff); - if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) || - (ehdr->e_ident[EI_MAG1] != ELFMAG1) || - (ehdr->e_ident[EI_MAG2] != ELFMAG2) || - (ehdr->e_ident[EI_MAG3] != ELFMAG3)) { - dev_err(gxp->dev, "Cannot load FW! Invalid ELF format.\n"); - return -EINVAL; - } - /* go through the available ELF segments */ for (i = 0; i < ehdr->e_phnum; i++, phdr++) { - u64 da = phdr->p_paddr; - u32 memsz = phdr->p_memsz; - u32 filesz = phdr->p_filesz; - u32 offset = phdr->p_offset; + const u64 da = phdr->p_paddr; + const u32 memsz = phdr->p_memsz; + const u32 filesz = phdr->p_filesz; void *ptr; - if (phdr->p_type != PT_LOAD) - continue; - - if (!phdr->p_flags) - continue; - - if (!memsz) + if (phdr->p_type != PT_LOAD || !phdr->p_flags || !memsz) continue; - if (!((da >= (u32)buffer->daddr) && - ((da + memsz) <= ((u32)buffer->daddr + - (u32)buffer->size)))) { - /* - * Some BSS data may be referenced from TCM, and can be - * skipped while loading - */ - dev_err(gxp->dev, "Segment out of bounds: da 0x%llx mem 0x%x. Skipping...\n", - da, memsz); + if (!(da >= buffer->daddr && + da + memsz <= buffer->daddr + buffer->size)) continue; - } - - dev_notice(gxp->dev, "phdr: type %d da 0x%llx memsz 0x%x filesz 0x%x\n", - phdr->p_type, da, memsz, filesz); - - if (filesz > memsz) { - dev_err(gxp->dev, "Bad phdr filesz 0x%x memsz 0x%x\n", - filesz, memsz); - ret = -EINVAL; - break; - } - - if (offset + filesz > size) { - dev_err(gxp->dev, "Truncated fw: need 0x%x avail 0x%zx\n", - offset + filesz, size); - ret = -EINVAL; - break; - } /* grab the kernel address for this device address */ ptr = buffer->vaddr + (da - buffer->daddr); @@ -169,6 +134,15 @@ static int elf_load_segments(struct gxp_dev *gxp, const u8 *elf_data, return ret; } +static void elf_fetch_entry_point(struct gxp_dev *gxp, const u8 *elf_data, + uint core) +{ + struct elf32_hdr *ehdr; + + ehdr = (struct elf32_hdr *)elf_data; + gxp->firmware_mgr->entry_points[core] = ehdr->e_entry; +} + static int gxp_firmware_authenticate(struct gxp_dev *gxp, const struct firmware *firmwares[GXP_NUM_CORES]) @@ -258,6 +232,112 @@ error: return ret; } +static int gxp_firmware_fetch_boundary(struct gxp_dev *gxp, const u8 *elf_data, + size_t size, + const struct gxp_mapped_resource *buffer, + dma_addr_t *boundary_ptr) +{ + struct elf32_hdr *ehdr = (struct elf32_hdr *)elf_data; + struct elf32_phdr *phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff); + int i, ret = 0; + dma_addr_t boundary = 0; + + if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) || + (ehdr->e_ident[EI_MAG1] != ELFMAG1) || + (ehdr->e_ident[EI_MAG2] != ELFMAG2) || + (ehdr->e_ident[EI_MAG3] != ELFMAG3)) { + dev_err(gxp->dev, "Invalid ELF format."); + return -EINVAL; + } + + /* go through the available ELF segments */ + for (i = 0; i < ehdr->e_phnum; i++, phdr++) { + const u64 da = phdr->p_paddr; + const u32 memsz = phdr->p_memsz; + const u32 filesz = phdr->p_filesz; + const u32 offset = phdr->p_offset; + const u32 p_flags = phdr->p_flags; + + if (phdr->p_type != PT_LOAD || !p_flags || !memsz) + continue; + + if (!(da >= buffer->daddr && + da + memsz <= buffer->daddr + buffer->size)) { + /* + * Some BSS data may be referenced from TCM, and can be + * skipped while loading + */ + dev_err(gxp->dev, "Segment out of bounds: da 0x%llx mem 0x%x. Skipping...", + da, memsz); + continue; + } + + dev_info(gxp->dev, + "phdr: da %#llx memsz %#x filesz %#x perm %d", da, + memsz, filesz, p_flags); + + if (filesz > memsz) { + dev_err(gxp->dev, "Bad phdr filesz %#x memsz %#x", + filesz, memsz); + ret = -EINVAL; + break; + } + + if (offset + filesz > size) { + dev_err(gxp->dev, "Truncated fw: need %#x avail %#zx", + offset + filesz, size); + ret = -EINVAL; + break; + } + if (p_flags & PF_W) { + if (!boundary) + boundary = da; + } else if (boundary) { + dev_err(gxp->dev, + "Found RO region after a writable segment"); + ret = -EINVAL; + break; + } + } + /* no boundary has been found - assume the whole image is RO */ + if (!boundary) + boundary = buffer->daddr + buffer->size; + if (!ret) + *boundary_ptr = boundary; + + return ret; +} + +/* + * Sets @rw_boundaries by analyzing LOAD segments in ELF headers. + * + * Assumes the LOAD segments are arranged with RO first then RW. Returns -EINVAL + * if this is not true. + */ +static int gxp_firmware_fetch_boundaries(struct gxp_dev *gxp, + struct gxp_firmware_manager *mgr) +{ + int core, ret; + + for (core = 0; core < GXP_NUM_CORES; core++) { + ret = gxp_firmware_fetch_boundary( + gxp, mgr->firmwares[core]->data + FW_HEADER_SIZE, + mgr->firmwares[core]->size - FW_HEADER_SIZE, + &gxp->fwbufs[core], &mgr->rw_boundaries[core]); + if (ret) { + dev_err(gxp->dev, + "failed to fetch boundary of core %d: %d", core, + ret); + goto error; + } + } + return 0; + +error: + memset(mgr->rw_boundaries, 0, sizeof(mgr->rw_boundaries)); + return ret; +} + /* Forward declaration for usage inside gxp_firmware_load(..). */ static void gxp_firmware_unload(struct gxp_dev *gxp, uint core); @@ -265,39 +345,43 @@ static void gxp_program_reset_vector(struct gxp_dev *gxp, uint core, bool verbos { u32 reset_vec; - reset_vec = gxp_read_32_core(gxp, core, - GXP_REG_ALT_RESET_VECTOR); + reset_vec = gxp_read_32(gxp, GXP_CORE_REG_ALT_RESET_VECTOR(core)); if (verbose) dev_notice(gxp->dev, "Current Aurora reset vector for core %u: 0x%x\n", core, reset_vec); - gxp_write_32_core(gxp, core, GXP_REG_ALT_RESET_VECTOR, - gxp->fwbufs[core].daddr); + gxp_write_32(gxp, GXP_CORE_REG_ALT_RESET_VECTOR(core), + gxp->firmware_mgr->entry_points[core]); if (verbose) dev_notice(gxp->dev, - "New Aurora reset vector for core %u: 0x%llx\n", - core, gxp->fwbufs[core].daddr); + "New Aurora reset vector for core %u: 0x%x\n", + core, gxp->firmware_mgr->entry_points[core]); } static int gxp_firmware_load(struct gxp_dev *gxp, uint core) { + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; u32 offset; void __iomem *core_scratchpad_base; int ret; - if (!gxp->firmwares[core]) + if (!mgr->firmwares[core]) return -ENODEV; /* Load firmware to System RAM */ ret = elf_load_segments(gxp, - gxp->firmwares[core]->data + FW_HEADER_SIZE, - gxp->firmwares[core]->size - FW_HEADER_SIZE, + mgr->firmwares[core]->data + FW_HEADER_SIZE, + mgr->firmwares[core]->size - FW_HEADER_SIZE, &gxp->fwbufs[core]); if (ret) { dev_err(gxp->dev, "Unable to load elf file\n"); goto out_firmware_unload; } + elf_fetch_entry_point(gxp, + mgr->firmwares[core]->data + FW_HEADER_SIZE, + core); + memset(gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF, 0, AURORA_SCRATCHPAD_LEN); @@ -326,7 +410,7 @@ out_firmware_unload: static int gxp_firmware_handshake(struct gxp_dev *gxp, uint core) { u32 offset; - u32 expected_top_value; + u32 __maybe_unused expected_top_value; void __iomem *core_scratchpad_base; int ctr; @@ -334,7 +418,7 @@ static int gxp_firmware_handshake(struct gxp_dev *gxp, uint core) dev_notice(gxp->dev, "Waiting for core %u to power up...\n", core); ctr = 1000; while (ctr) { - if (gxp_lpm_is_powered(gxp, core)) + if (gxp_lpm_is_powered(gxp, CORE_TO_PSM(core))) break; udelay(1 * GXP_TIME_DELAY_FACTOR); ctr--; @@ -359,6 +443,15 @@ static int gxp_firmware_handshake(struct gxp_dev *gxp, uint core) */ ctr = 5000; offset = SCRATCHPAD_MSG_OFFSET(MSG_CORE_ALIVE); +#if IS_ENABLED(CONFIG_GXP_TEST) + fake_gxp_firmware_flush_work_all(); + /* + * As the fake firmware works are flushed, we don't have to busy-wait the response of + * the firmware. By setting @ctr to 1, just run the while loop below once for the code + * coverage. + */ + ctr = 1; +#endif usleep_range(50 * GXP_TIME_DELAY_FACTOR, 60 * GXP_TIME_DELAY_FACTOR); while (ctr--) { if (readl(core_scratchpad_base + offset) == Q7_ALIVE_MAGIC) @@ -437,15 +530,16 @@ static ssize_t load_dsp_firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gxp_dev *gxp = dev_get_drvdata(dev); + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; ssize_t ret; - mutex_lock(&gxp->dsp_firmware_lock); + mutex_lock(&mgr->dsp_firmware_lock); ret = scnprintf(buf, PAGE_SIZE, "%s\n", - gxp->firmware_name ? gxp->firmware_name : + mgr->firmware_name ? mgr->firmware_name : DSP_FIRMWARE_DEFAULT_PREFIX); - mutex_unlock(&gxp->dsp_firmware_lock); + mutex_unlock(&mgr->dsp_firmware_lock); return ret; } @@ -455,6 +549,7 @@ static ssize_t load_dsp_firmware_store(struct device *dev, const char *buf, size_t count) { struct gxp_dev *gxp = dev_get_drvdata(dev); + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; const struct firmware *firmwares[GXP_NUM_CORES]; char *name_buf = NULL; int ret; @@ -466,10 +561,10 @@ static ssize_t load_dsp_firmware_store(struct device *dev, */ down_read(&gxp->vd_semaphore); - if (gxp->firmware_running) { + if (mgr->firmware_running) { dev_warn(dev, "Cannot update firmware when any core is running\n"); ret = -EBUSY; - goto out; + goto err_out; } name_buf = fw_name_from_attr_buf(buf); @@ -477,10 +572,10 @@ static ssize_t load_dsp_firmware_store(struct device *dev, dev_err(gxp->dev, "Invalid firmware prefix requested: %s\n", buf); ret = PTR_ERR(name_buf); - goto out; + goto err_out; } - mutex_lock(&gxp->dsp_firmware_lock); + mutex_lock(&mgr->dsp_firmware_lock); dev_notice(gxp->dev, "Requesting firmware be reloaded: %s\n", name_buf); @@ -497,25 +592,32 @@ static ssize_t load_dsp_firmware_store(struct device *dev, goto err_authenticate_firmware; for (core = 0; core < GXP_NUM_CORES; core++) { - if (gxp->firmwares[core]) - release_firmware(gxp->firmwares[core]); - gxp->firmwares[core] = firmwares[core]; + if (mgr->firmwares[core]) + release_firmware(mgr->firmwares[core]); + mgr->firmwares[core] = firmwares[core]; } - kfree(gxp->firmware_name); - gxp->firmware_name = name_buf; + ret = gxp_firmware_fetch_boundaries(gxp, mgr); + if (ret) + goto err_fetch_boundaries; - mutex_unlock(&gxp->dsp_firmware_lock); -out: + kfree(mgr->firmware_name); + mgr->firmware_name = name_buf; + + mutex_unlock(&mgr->dsp_firmware_lock); up_read(&gxp->vd_semaphore); return count; +err_fetch_boundaries: + for (core = 0; core < GXP_NUM_CORES; core++) + mgr->firmwares[core] = NULL; err_authenticate_firmware: for (core = 0; core < GXP_NUM_CORES; core++) release_firmware(firmwares[core]); err_request_firmware: kfree(name_buf); - mutex_unlock(&gxp->dsp_firmware_lock); + mutex_unlock(&mgr->dsp_firmware_lock); +err_out: up_read(&gxp->vd_semaphore); return ret; } @@ -537,6 +639,13 @@ int gxp_fw_init(struct gxp_dev *gxp) uint core; struct resource r; int ret; + struct gxp_firmware_manager *mgr; + + mgr = devm_kzalloc(gxp->dev, sizeof(*mgr), GFP_KERNEL); + if (!mgr) + return -ENOMEM; + gxp->firmware_mgr = mgr; + mutex_init(&mgr->dsp_firmware_lock); /* Power on BLK_AUR to read the revision and processor ID registers */ gxp_pm_blk_on(gxp); @@ -545,7 +654,7 @@ int gxp_fw_init(struct gxp_dev *gxp) dev_notice(gxp->dev, "Aurora version: 0x%x\n", ver); for (core = 0; core < GXP_NUM_CORES; core++) { - proc_id = gxp_read_32_core(gxp, core, GXP_REG_PROCESSOR_ID); + proc_id = gxp_read_32(gxp, GXP_CORE_REG_PROCESSOR_ID(core)); dev_notice(gxp->dev, "Aurora core %u processor ID: 0x%x\n", core, proc_id); } @@ -609,7 +718,7 @@ int gxp_fw_init(struct gxp_dev *gxp) if (ret) goto out_fw_destroy; - gxp->firmware_running = 0; + mgr->firmware_running = 0; return 0; out_fw_destroy: @@ -620,6 +729,10 @@ out_fw_destroy: void gxp_fw_destroy(struct gxp_dev *gxp) { uint core; + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; + + if (IS_GXP_TEST && !mgr) + return; device_remove_group(gxp->dev, &gxp_firmware_attr_group); @@ -629,54 +742,83 @@ void gxp_fw_destroy(struct gxp_dev *gxp) gxp->fwbufs[core].vaddr = NULL; } - if (gxp->firmwares[core]) { - release_firmware(gxp->firmwares[core]); - gxp->firmwares[core] = NULL; + if (mgr->firmwares[core]) { + release_firmware(mgr->firmwares[core]); + mgr->firmwares[core] = NULL; } } - kfree(gxp->firmware_name); + kfree(mgr->firmware_name); } int gxp_firmware_request_if_needed(struct gxp_dev *gxp) { int ret = 0; uint core; + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; + char *name = NULL; - mutex_lock(&gxp->dsp_firmware_lock); + mutex_lock(&mgr->dsp_firmware_lock); - if (gxp->is_firmware_requested) + if (mgr->is_firmware_requested) goto out; - ret = request_dsp_firmware(gxp, DSP_FIRMWARE_DEFAULT_PREFIX, - gxp->firmwares); + if (mgr->firmware_name == NULL) + name = DSP_FIRMWARE_DEFAULT_PREFIX; + else + name = mgr->firmware_name; + + ret = request_dsp_firmware(gxp, name, mgr->firmwares); if (ret) goto out; - ret = gxp_firmware_authenticate(gxp, gxp->firmwares); + ret = gxp_firmware_authenticate(gxp, mgr->firmwares); if (ret) goto err_authenticate_firmware; - gxp->is_firmware_requested = true; + ret = gxp_firmware_fetch_boundaries(gxp, mgr); + if (ret) + goto err_authenticate_firmware; + + mgr->is_firmware_requested = true; out: - mutex_unlock(&gxp->dsp_firmware_lock); + mutex_unlock(&mgr->dsp_firmware_lock); return ret; err_authenticate_firmware: for (core = 0; core < GXP_NUM_CORES; core++) { - release_firmware(gxp->firmwares[core]); - gxp->firmwares[core] = NULL; + release_firmware(mgr->firmwares[core]); + mgr->firmwares[core] = NULL; } - mutex_unlock(&gxp->dsp_firmware_lock); + mutex_unlock(&mgr->dsp_firmware_lock); return ret; } +/* TODO(b/253464747): Refactor these interrupts handlers and gxp-doorbell.c. */ +static void enable_core_interrupts(struct gxp_dev *gxp, uint core) +{ + /* + * GXP_CORE_REG_COMMON_INT_MASK_0 is handled in doorbell module, so we + * don't need to enable it here. + */ + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_1(core), 0xffffffff); + gxp_write_32(gxp, GXP_CORE_REG_DEDICATED_INT_MASK(core), 0xffffffff); +} + +static void disable_core_interrupts(struct gxp_dev *gxp, uint core) +{ + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_0(core), 0); + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_1(core), 0); + gxp_write_32(gxp, GXP_CORE_REG_DEDICATED_INT_MASK(core), 0); +} + static int gxp_firmware_setup(struct gxp_dev *gxp, uint core) { int ret = 0; + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; - if (gxp->firmware_running & BIT(core)) { + if (mgr->firmware_running & BIT(core)) { dev_err(gxp->dev, "Firmware is already running on core %u\n", core); return -EBUSY; @@ -689,15 +831,19 @@ static int gxp_firmware_setup(struct gxp_dev *gxp, uint core) } /* Mark this as a cold boot */ - gxp_firmware_set_boot_mode(gxp, core, GXP_BOOT_MODE_REQUEST_COLD_BOOT); + if (gxp_core_boot) + gxp_firmware_set_boot_mode(gxp, core, + GXP_BOOT_MODE_REQUEST_COLD_BOOT); ret = gxp_firmware_setup_hw_after_block_off(gxp, core, /*verbose=*/true); if (ret) { dev_err(gxp->dev, "Failed to power up core %u\n", core); gxp_firmware_unload(gxp, core); + return ret; } + enable_core_interrupts(gxp, core); return ret; } @@ -721,27 +867,35 @@ static int gxp_firmware_finish_startup(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint virt_core, uint core) { - int ret; struct work_struct *work; + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; + int ret = 0; - ret = gxp_firmware_handshake(gxp, core); - if (ret) { - dev_err(gxp->dev, "Firmware handshake failed on core %u\n", - core); - gxp_pm_core_off(gxp, core); - goto out_firmware_unload; - } + if (gxp_core_boot) { + ret = gxp_firmware_handshake(gxp, core); + if (ret) { + dev_err(gxp->dev, + "Firmware handshake failed on core %u\n", core); + goto err_firmware_off; + } - /* Initialize mailbox */ - gxp->mailbox_mgr->mailboxes[core] = - gxp_mailbox_alloc(gxp->mailbox_mgr, vd, virt_core, core); - if (IS_ERR(gxp->mailbox_mgr->mailboxes[core])) { - dev_err(gxp->dev, - "Unable to allocate mailbox (core=%u, ret=%ld)\n", core, - PTR_ERR(gxp->mailbox_mgr->mailboxes[core])); - ret = PTR_ERR(gxp->mailbox_mgr->mailboxes[core]); - gxp->mailbox_mgr->mailboxes[core] = NULL; - goto out_firmware_unload; + /* Initialize mailbox */ + if (gxp->mailbox_mgr->allocate_mailbox) { + gxp->mailbox_mgr->mailboxes[core] = + gxp->mailbox_mgr->allocate_mailbox( + gxp->mailbox_mgr, vd, virt_core, core); + if (IS_ERR(gxp->mailbox_mgr->mailboxes[core])) { + dev_err(gxp->dev, + "Unable to allocate mailbox (core=%u, ret=%ld)\n", + core, + PTR_ERR(gxp->mailbox_mgr + ->mailboxes[core])); + ret = PTR_ERR( + gxp->mailbox_mgr->mailboxes[core]); + gxp->mailbox_mgr->mailboxes[core] = NULL; + goto err_firmware_off; + } + } } work = gxp_debug_dump_get_notification_handler(gxp, core); @@ -749,16 +903,18 @@ static int gxp_firmware_finish_startup(struct gxp_dev *gxp, gxp_notification_register_handler( gxp, core, HOST_NOTIF_DEBUG_DUMP_READY, work); - work = gxp_telemetry_get_notification_handler(gxp, core); + work = gxp_core_telemetry_get_notification_handler(gxp, core); if (work) gxp_notification_register_handler( - gxp, core, HOST_NOTIF_TELEMETRY_STATUS, work); + gxp, core, HOST_NOTIF_CORE_TELEMETRY_STATUS, work); - gxp->firmware_running |= BIT(core); + mgr->firmware_running |= BIT(core); return ret; -out_firmware_unload: +err_firmware_off: + if (gxp_core_boot) + gxp_pm_core_off(gxp, core); gxp_firmware_unload(gxp, core); return ret; } @@ -767,22 +923,36 @@ static void gxp_firmware_stop_core(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint virt_core, uint core) { - if (!(gxp->firmware_running & BIT(core))) + struct gxp_firmware_manager *mgr = gxp->firmware_mgr; + + if (!(mgr->firmware_running & BIT(core))) dev_err(gxp->dev, "Firmware is not running on core %u\n", core); - gxp->firmware_running &= ~BIT(core); + mgr->firmware_running &= ~BIT(core); gxp_notification_unregister_handler(gxp, core, HOST_NOTIF_DEBUG_DUMP_READY); gxp_notification_unregister_handler(gxp, core, - HOST_NOTIF_TELEMETRY_STATUS); + HOST_NOTIF_CORE_TELEMETRY_STATUS); + + if (gxp_core_boot) { + if (gxp->mailbox_mgr->release_mailbox) { + gxp->mailbox_mgr->release_mailbox( + gxp->mailbox_mgr, vd, virt_core, + gxp->mailbox_mgr->mailboxes[core]); + dev_notice(gxp->dev, "Mailbox %u released\n", core); + } - gxp_mailbox_release(gxp->mailbox_mgr, vd, virt_core, - gxp->mailbox_mgr->mailboxes[core]); - dev_notice(gxp->dev, "Mailbox %u released\n", core); + if (vd->state == GXP_VD_RUNNING) { + /* + * Disable interrupts to prevent cores from being woken up + * unexpectedly. + */ + disable_core_interrupts(gxp, core); + gxp_pm_core_off(gxp, core); + } + } - if (vd->state == GXP_VD_RUNNING) - gxp_pm_core_off(gxp, core); gxp_firmware_unload(gxp, core); } @@ -813,7 +983,8 @@ int gxp_firmware_run(struct gxp_dev *gxp, struct gxp_virtual_device *vd, for (core = 0; core < GXP_NUM_CORES; core++) { if (core_list & BIT(core)) { if (!(failed_cores & BIT(core))) { - gxp_pm_core_off(gxp, core); + if (gxp_core_boot) + gxp_pm_core_off(gxp, core); gxp_firmware_unload(gxp, core); } } @@ -834,8 +1005,11 @@ int gxp_firmware_run(struct gxp_dev *gxp, struct gxp_virtual_device *vd, } #endif /* Switch clock mux to the normal state to guarantee LPM works */ - gxp_pm_force_clkmux_normal(gxp); - gxp_firmware_wakeup_cores(gxp, core_list); + if (gxp_core_boot) { + gxp_pm_force_clkmux_normal(gxp); + gxp_firmware_wakeup_cores(gxp, core_list); + } + virt_core = 0; for (core = 0; core < GXP_NUM_CORES; core++) { if (core_list & BIT(core)) { @@ -864,7 +1038,8 @@ int gxp_firmware_run(struct gxp_dev *gxp, struct gxp_virtual_device *vd, } } /* Check if we need to set clock mux to low state as requested */ - gxp_pm_resume_clkmux(gxp); + if (gxp_core_boot) + gxp_pm_resume_clkmux(gxp); return ret; } @@ -873,7 +1048,8 @@ int gxp_firmware_setup_hw_after_block_off(struct gxp_dev *gxp, uint core, bool verbose) { gxp_program_reset_vector(gxp, core, verbose); - return gxp_pm_core_on(gxp, core, verbose); + + return gxp_core_boot ? gxp_pm_core_on(gxp, core, verbose) : 0; } |