diff options
author | Aurora zuma automerger <aurora-zuma-automerger@google.com> | 2023-05-10 09:35:41 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-05-11 22:03:34 -0700 |
commit | 845dc991e47ae307e1b8eb8bf76a743812df9417 (patch) | |
tree | 549acfdf628190ba35055eb0b4fb6dd8fed67813 | |
parent | 9e67071e743d6e2e48c6584a827d0d4cc42750b8 (diff) | |
download | zuma-845dc991e47ae307e1b8eb8bf76a743812df9417.tar.gz |
gxp: [Copybara Auto Merge] Merge branch 'zuma' into 'android14-gs-pixel-5.15'
gxp: remove legacy TODOs
gxp: remove vd config version
Bug: 281609488
gxp: remove unreferenced macros and functions
Bug: 281609488 (repeat)
gxp: remove gxp_fw_data_use_per_vd_config
Bug: 281609488 (repeat)
gxp: reject loading legacy firmware
Bug: 281609488 (repeat)
gxp: fix max num of debug dump segments
Bug: 281636081
gxp: remove unneeded log on memory alloc failure
gxp: unittests: test MCU FW sending FW_CRASH while stopping
Bug: 281088523
gxp: make MCU crash handler scheduled work
Bug: 281088523 (repeat)
gxp: reorder locks in the MCU crash handler
Bug: 281088523 (repeat)
gxp: refine vd_semaphore usage to prevent deadlock
Bug: 281007294
gxp: turn on slow clock on idle
Bug: 279201155
gxp: decouple PM from client->semaphore
Bug: 280724971
gxp: fix UAF on awaiter releasing
Bug: 280737201
gxp: cancel KCI workers before CSR reset
Bug: 280548609
gxp: make MCU crash handler scheduled work
Bug: 281088523 (repeat)
Test: Passed the unittests
gxp: reorder locks in the MCU crash handler
Bug: 281088523 (repeat)
gxp: refine vd_semaphore usage to prevent deadlock
Bug: 281007294 (repeat)
gxp: turn on slow clock on idle
Bug: 279201155 (repeat)
gxp: decouple PM from client->semaphore
Bug: 280724971 (repeat)
(cherry picked from commit 8e46531e8a3898b6689c3a192bb42e10bb4bf633)
GitOrigin-RevId: ce20da14dbffd8d462bc8903dae72b615ae203e4
Change-Id: I23f032ddb88acc92669b77a7d7e6f8f52f414dfd
-rw-r--r-- | .clang-format | 688 | ||||
-rw-r--r-- | .gitignore | 11 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | callisto/csrs.h | 2 | ||||
-rw-r--r-- | callisto/iova.h | 1 | ||||
-rw-r--r-- | gxp-client.c | 15 | ||||
-rw-r--r-- | gxp-client.h | 8 | ||||
-rw-r--r-- | gxp-common-platform.c | 67 | ||||
-rw-r--r-- | gxp-debug-dump.c | 6 | ||||
-rw-r--r-- | gxp-debug-dump.h | 8 | ||||
-rw-r--r-- | gxp-dma-iommu.c | 10 | ||||
-rw-r--r-- | gxp-firmware-data.c | 3 | ||||
-rw-r--r-- | gxp-firmware-data.h | 5 | ||||
-rw-r--r-- | gxp-firmware.c | 100 | ||||
-rw-r--r-- | gxp-firmware.h | 33 | ||||
-rw-r--r-- | gxp-host-device-structs.h | 44 | ||||
-rw-r--r-- | gxp-kci.c | 8 | ||||
-rw-r--r-- | gxp-mcu-firmware.c | 98 | ||||
-rw-r--r-- | gxp-mcu-firmware.h | 4 | ||||
-rw-r--r-- | gxp-pm.c | 3 | ||||
-rw-r--r-- | gxp-usage-stats.c | 4 | ||||
-rw-r--r-- | gxp-vd.c | 96 | ||||
-rw-r--r-- | gxp-vd.h | 2 |
23 files changed, 213 insertions, 1005 deletions
diff --git a/.clang-format b/.clang-format deleted file mode 100644 index d116625..0000000 --- a/.clang-format +++ /dev/null @@ -1,688 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# clang-format configuration file. Intended for clang-format >= 11. -# -# For more information, see: -# -# Documentation/process/clang-format.rst -# https://clang.llvm.org/docs/ClangFormat.html -# https://clang.llvm.org/docs/ClangFormatStyleOptions.html -# ---- -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: false -ColumnLimit: 100 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false - -# Taken from: -# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \ -# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ -# | LC_ALL=C sort -u -ForEachMacros: - - '__ata_qc_for_each' - - '__bio_for_each_bvec' - - '__bio_for_each_segment' - - '__evlist__for_each_entry' - - '__evlist__for_each_entry_continue' - - '__evlist__for_each_entry_from' - - '__evlist__for_each_entry_reverse' - - '__evlist__for_each_entry_safe' - - '__for_each_mem_range' - - '__for_each_mem_range_rev' - - '__for_each_thread' - - '__hlist_for_each_rcu' - - '__map__for_each_symbol_by_name' - - '__perf_evlist__for_each_entry' - - '__perf_evlist__for_each_entry_reverse' - - '__perf_evlist__for_each_entry_safe' - - '__rq_for_each_bio' - - '__shost_for_each_device' - - 'apei_estatus_for_each_section' - - 'ata_for_each_dev' - - 'ata_for_each_link' - - 'ata_qc_for_each' - - 'ata_qc_for_each_raw' - - 'ata_qc_for_each_with_internal' - - 'ax25_for_each' - - 'ax25_uid_for_each' - - 'bio_for_each_bvec' - - 'bio_for_each_bvec_all' - - 'bio_for_each_folio_all' - - 'bio_for_each_integrity_vec' - - 'bio_for_each_segment' - - 'bio_for_each_segment_all' - - 'bio_list_for_each' - - 'bip_for_each_vec' - - 'bond_for_each_slave' - - 'bond_for_each_slave_rcu' - - 'bpf__perf_for_each_map' - - 'bpf__perf_for_each_map_named' - - 'bpf_for_each_spilled_reg' - - 'bpf_object__for_each_map' - - 'bpf_object__for_each_program' - - 'bpf_object__for_each_safe' - - 'bpf_perf_object__for_each' - - 'btree_for_each_safe128' - - 'btree_for_each_safe32' - - 'btree_for_each_safe64' - - 'btree_for_each_safel' - - 'card_for_each_dev' - - 'cgroup_taskset_for_each' - - 'cgroup_taskset_for_each_leader' - - 'cpufreq_for_each_efficient_entry_idx' - - 'cpufreq_for_each_entry' - - 'cpufreq_for_each_entry_idx' - - 'cpufreq_for_each_valid_entry' - - 'cpufreq_for_each_valid_entry_idx' - - 'css_for_each_child' - - 'css_for_each_descendant_post' - - 'css_for_each_descendant_pre' - - 'damon_for_each_region' - - 'damon_for_each_region_safe' - - 'damon_for_each_scheme' - - 'damon_for_each_scheme_safe' - - 'damon_for_each_target' - - 'damon_for_each_target_safe' - - 'data__for_each_file' - - 'data__for_each_file_new' - - 'data__for_each_file_start' - - 'device_for_each_child_node' - - 'displayid_iter_for_each' - - 'dma_fence_array_for_each' - - 'dma_fence_chain_for_each' - - 'dma_fence_unwrap_for_each' - - 'dma_resv_for_each_fence' - - 'dma_resv_for_each_fence_unlocked' - - 'do_for_each_ftrace_op' - - 'drm_atomic_crtc_for_each_plane' - - 'drm_atomic_crtc_state_for_each_plane' - - 'drm_atomic_crtc_state_for_each_plane_state' - - 'drm_atomic_for_each_plane_damage' - - 'drm_client_for_each_connector_iter' - - 'drm_client_for_each_modeset' - - 'drm_connector_for_each_possible_encoder' - - 'drm_for_each_bridge_in_chain' - - 'drm_for_each_connector_iter' - - 'drm_for_each_crtc' - - 'drm_for_each_crtc_reverse' - - 'drm_for_each_encoder' - - 'drm_for_each_encoder_mask' - - 'drm_for_each_fb' - - 'drm_for_each_legacy_plane' - - 'drm_for_each_plane' - - 'drm_for_each_plane_mask' - - 'drm_for_each_privobj' - - 'drm_mm_for_each_hole' - - 'drm_mm_for_each_node' - - 'drm_mm_for_each_node_in_range' - - 'drm_mm_for_each_node_safe' - - 'dsa_switch_for_each_available_port' - - 'dsa_switch_for_each_cpu_port' - - 'dsa_switch_for_each_port' - - 'dsa_switch_for_each_port_continue_reverse' - - 'dsa_switch_for_each_port_safe' - - 'dsa_switch_for_each_user_port' - - 'dsa_tree_for_each_user_port' - - 'dso__for_each_symbol' - - 'dsos__for_each_with_build_id' - - 'elf_hash_for_each_possible' - - 'elf_section__for_each_rel' - - 'elf_section__for_each_rela' - - 'elf_symtab__for_each_symbol' - - 'evlist__for_each_cpu' - - 'evlist__for_each_entry' - - 'evlist__for_each_entry_continue' - - 'evlist__for_each_entry_from' - - 'evlist__for_each_entry_reverse' - - 'evlist__for_each_entry_safe' - - 'flow_action_for_each' - - 'for_each_acpi_dev_match' - - 'for_each_active_dev_scope' - - 'for_each_active_drhd_unit' - - 'for_each_active_iommu' - - 'for_each_aggr_pgid' - - 'for_each_available_child_of_node' - - 'for_each_bench' - - 'for_each_bio' - - 'for_each_board_func_rsrc' - - 'for_each_btf_ext_rec' - - 'for_each_btf_ext_sec' - - 'for_each_bvec' - - 'for_each_card_auxs' - - 'for_each_card_auxs_safe' - - 'for_each_card_components' - - 'for_each_card_dapms' - - 'for_each_card_pre_auxs' - - 'for_each_card_prelinks' - - 'for_each_card_rtds' - - 'for_each_card_rtds_safe' - - 'for_each_card_widgets' - - 'for_each_card_widgets_safe' - - 'for_each_cgroup_storage_type' - - 'for_each_child_of_node' - - 'for_each_clear_bit' - - 'for_each_clear_bit_from' - - 'for_each_clear_bitrange' - - 'for_each_clear_bitrange_from' - - 'for_each_cmd' - - 'for_each_cmsghdr' - - 'for_each_collection' - - 'for_each_comp_order' - - 'for_each_compatible_node' - - 'for_each_component_dais' - - 'for_each_component_dais_safe' - - 'for_each_console' - - 'for_each_console_srcu' - - 'for_each_cpu' - - 'for_each_cpu_and' - - 'for_each_cpu_not' - - 'for_each_cpu_wrap' - - 'for_each_dapm_widgets' - - 'for_each_dedup_cand' - - 'for_each_dev_addr' - - 'for_each_dev_scope' - - 'for_each_dma_cap_mask' - - 'for_each_dpcm_be' - - 'for_each_dpcm_be_rollback' - - 'for_each_dpcm_be_safe' - - 'for_each_dpcm_fe' - - 'for_each_drhd_unit' - - 'for_each_dss_dev' - - 'for_each_efi_memory_desc' - - 'for_each_efi_memory_desc_in_map' - - 'for_each_element' - - 'for_each_element_extid' - - 'for_each_element_id' - - 'for_each_endpoint_of_node' - - 'for_each_event' - - 'for_each_event_tps' - - 'for_each_evictable_lru' - - 'for_each_fib6_node_rt_rcu' - - 'for_each_fib6_walker_rt' - - 'for_each_free_mem_pfn_range_in_zone' - - 'for_each_free_mem_pfn_range_in_zone_from' - - 'for_each_free_mem_range' - - 'for_each_free_mem_range_reverse' - - 'for_each_func_rsrc' - - 'for_each_group_evsel' - - 'for_each_group_member' - - 'for_each_hstate' - - 'for_each_if' - - 'for_each_inject_fn' - - 'for_each_insn' - - 'for_each_insn_prefix' - - 'for_each_intid' - - 'for_each_iommu' - - 'for_each_ip_tunnel_rcu' - - 'for_each_irq_nr' - - 'for_each_lang' - - 'for_each_link_codecs' - - 'for_each_link_cpus' - - 'for_each_link_platforms' - - 'for_each_lru' - - 'for_each_matching_node' - - 'for_each_matching_node_and_match' - - 'for_each_mem_pfn_range' - - 'for_each_mem_range' - - 'for_each_mem_range_rev' - - 'for_each_mem_region' - - 'for_each_member' - - 'for_each_memory' - - 'for_each_migratetype_order' - - 'for_each_missing_reg' - - 'for_each_net' - - 'for_each_net_continue_reverse' - - 'for_each_net_rcu' - - 'for_each_netdev' - - 'for_each_netdev_continue' - - 'for_each_netdev_continue_rcu' - - 'for_each_netdev_continue_reverse' - - 'for_each_netdev_feature' - - 'for_each_netdev_in_bond_rcu' - - 'for_each_netdev_rcu' - - 'for_each_netdev_reverse' - - 'for_each_netdev_safe' - - 'for_each_new_connector_in_state' - - 'for_each_new_crtc_in_state' - - 'for_each_new_mst_mgr_in_state' - - 'for_each_new_plane_in_state' - - 'for_each_new_plane_in_state_reverse' - - 'for_each_new_private_obj_in_state' - - 'for_each_new_reg' - - 'for_each_node' - - 'for_each_node_by_name' - - 'for_each_node_by_type' - - 'for_each_node_mask' - - 'for_each_node_state' - - 'for_each_node_with_cpus' - - 'for_each_node_with_property' - - 'for_each_nonreserved_multicast_dest_pgid' - - 'for_each_of_allnodes' - - 'for_each_of_allnodes_from' - - 'for_each_of_cpu_node' - - 'for_each_of_pci_range' - - 'for_each_old_connector_in_state' - - 'for_each_old_crtc_in_state' - - 'for_each_old_mst_mgr_in_state' - - 'for_each_old_plane_in_state' - - 'for_each_old_private_obj_in_state' - - 'for_each_oldnew_connector_in_state' - - 'for_each_oldnew_crtc_in_state' - - 'for_each_oldnew_mst_mgr_in_state' - - 'for_each_oldnew_plane_in_state' - - 'for_each_oldnew_plane_in_state_reverse' - - 'for_each_oldnew_private_obj_in_state' - - 'for_each_online_cpu' - - 'for_each_online_node' - - 'for_each_online_pgdat' - - 'for_each_path' - - 'for_each_pci_bridge' - - 'for_each_pci_dev' - - 'for_each_pcm_streams' - - 'for_each_physmem_range' - - 'for_each_populated_zone' - - 'for_each_possible_cpu' - - 'for_each_present_cpu' - - 'for_each_prime_number' - - 'for_each_prime_number_from' - - 'for_each_probe_cache_entry' - - 'for_each_process' - - 'for_each_process_thread' - - 'for_each_prop_codec_conf' - - 'for_each_prop_dai_codec' - - 'for_each_prop_dai_cpu' - - 'for_each_prop_dlc_codecs' - - 'for_each_prop_dlc_cpus' - - 'for_each_prop_dlc_platforms' - - 'for_each_property_of_node' - - 'for_each_reg' - - 'for_each_reg_filtered' - - 'for_each_registered_fb' - - 'for_each_requested_gpio' - - 'for_each_requested_gpio_in_range' - - 'for_each_reserved_mem_range' - - 'for_each_reserved_mem_region' - - 'for_each_rtd_codec_dais' - - 'for_each_rtd_components' - - 'for_each_rtd_cpu_dais' - - 'for_each_rtd_dais' - - 'for_each_script' - - 'for_each_sec' - - 'for_each_set_bit' - - 'for_each_set_bit_from' - - 'for_each_set_bitrange' - - 'for_each_set_bitrange_from' - - 'for_each_set_clump8' - - 'for_each_sg' - - 'for_each_sg_dma_page' - - 'for_each_sg_page' - - 'for_each_sgtable_dma_page' - - 'for_each_sgtable_dma_sg' - - 'for_each_sgtable_page' - - 'for_each_sgtable_sg' - - 'for_each_shell_test' - - 'for_each_sibling_event' - - 'for_each_subelement' - - 'for_each_subelement_extid' - - 'for_each_subelement_id' - - 'for_each_sublist' - - 'for_each_subsystem' - - 'for_each_supported_activate_fn' - - 'for_each_supported_inject_fn' - - 'for_each_test' - - 'for_each_thread' - - 'for_each_token' - - 'for_each_unicast_dest_pgid' - - 'for_each_vsi' - - 'for_each_wakeup_source' - - 'for_each_zone' - - 'for_each_zone_zonelist' - - 'for_each_zone_zonelist_nodemask' - - 'func_for_each_insn' - - 'fwnode_for_each_available_child_node' - - 'fwnode_for_each_child_node' - - 'fwnode_graph_for_each_endpoint' - - 'gadget_for_each_ep' - - 'genradix_for_each' - - 'genradix_for_each_from' - - 'hash_for_each' - - 'hash_for_each_possible' - - 'hash_for_each_possible_rcu' - - 'hash_for_each_possible_rcu_notrace' - - 'hash_for_each_possible_safe' - - 'hash_for_each_rcu' - - 'hash_for_each_safe' - - 'hashmap__for_each_entry' - - 'hashmap__for_each_entry_safe' - - 'hashmap__for_each_key_entry' - - 'hashmap__for_each_key_entry_safe' - - 'hctx_for_each_ctx' - - 'hists__for_each_format' - - 'hists__for_each_sort_list' - - 'hlist_bl_for_each_entry' - - 'hlist_bl_for_each_entry_rcu' - - 'hlist_bl_for_each_entry_safe' - - 'hlist_for_each' - - 'hlist_for_each_entry' - - 'hlist_for_each_entry_continue' - - 'hlist_for_each_entry_continue_rcu' - - 'hlist_for_each_entry_continue_rcu_bh' - - 'hlist_for_each_entry_from' - - 'hlist_for_each_entry_from_rcu' - - 'hlist_for_each_entry_rcu' - - 'hlist_for_each_entry_rcu_bh' - - 'hlist_for_each_entry_rcu_notrace' - - 'hlist_for_each_entry_safe' - - 'hlist_for_each_entry_srcu' - - 'hlist_for_each_safe' - - 'hlist_nulls_for_each_entry' - - 'hlist_nulls_for_each_entry_from' - - 'hlist_nulls_for_each_entry_rcu' - - 'hlist_nulls_for_each_entry_safe' - - 'i3c_bus_for_each_i2cdev' - - 'i3c_bus_for_each_i3cdev' - - 'idr_for_each_entry' - - 'idr_for_each_entry_continue' - - 'idr_for_each_entry_continue_ul' - - 'idr_for_each_entry_ul' - - 'in_dev_for_each_ifa_rcu' - - 'in_dev_for_each_ifa_rtnl' - - 'inet_bind_bucket_for_each' - - 'inet_lhash2_for_each_icsk' - - 'inet_lhash2_for_each_icsk_continue' - - 'inet_lhash2_for_each_icsk_rcu' - - 'interval_tree_for_each_double_span' - - 'interval_tree_for_each_span' - - 'intlist__for_each_entry' - - 'intlist__for_each_entry_safe' - - 'iopt_for_each_contig_area' - - 'kcore_copy__for_each_phdr' - - 'key_for_each' - - 'key_for_each_safe' - - 'klp_for_each_func' - - 'klp_for_each_func_safe' - - 'klp_for_each_func_static' - - 'klp_for_each_object' - - 'klp_for_each_object_safe' - - 'klp_for_each_object_static' - - 'kunit_suite_for_each_test_case' - - 'kvm_for_each_memslot' - - 'kvm_for_each_memslot_in_gfn_range' - - 'kvm_for_each_vcpu' - - 'libbpf_nla_for_each_attr' - - 'list_for_each' - - 'list_for_each_codec' - - 'list_for_each_codec_safe' - - 'list_for_each_continue' - - 'list_for_each_entry' - - 'list_for_each_entry_continue' - - 'list_for_each_entry_continue_rcu' - - 'list_for_each_entry_continue_reverse' - - 'list_for_each_entry_from' - - 'list_for_each_entry_from_rcu' - - 'list_for_each_entry_from_reverse' - - 'list_for_each_entry_lockless' - - 'list_for_each_entry_rcu' - - 'list_for_each_entry_reverse' - - 'list_for_each_entry_safe' - - 'list_for_each_entry_safe_continue' - - 'list_for_each_entry_safe_from' - - 'list_for_each_entry_safe_reverse' - - 'list_for_each_entry_srcu' - - 'list_for_each_from' - - 'list_for_each_prev' - - 'list_for_each_prev_safe' - - 'list_for_each_safe' - - 'llist_for_each' - - 'llist_for_each_entry' - - 'llist_for_each_entry_safe' - - 'llist_for_each_safe' - - 'map__for_each_symbol' - - 'map__for_each_symbol_by_name' - - 'map_for_each_event' - - 'map_for_each_metric' - - 'maps__for_each_entry' - - 'maps__for_each_entry_safe' - - 'mci_for_each_dimm' - - 'media_device_for_each_entity' - - 'media_device_for_each_intf' - - 'media_device_for_each_link' - - 'media_device_for_each_pad' - - 'msi_for_each_desc' - - 'nanddev_io_for_each_page' - - 'netdev_for_each_lower_dev' - - 'netdev_for_each_lower_private' - - 'netdev_for_each_lower_private_rcu' - - 'netdev_for_each_mc_addr' - - 'netdev_for_each_uc_addr' - - 'netdev_for_each_upper_dev_rcu' - - 'netdev_hw_addr_list_for_each' - - 'nft_rule_for_each_expr' - - 'nla_for_each_attr' - - 'nla_for_each_nested' - - 'nlmsg_for_each_attr' - - 'nlmsg_for_each_msg' - - 'nr_neigh_for_each' - - 'nr_neigh_for_each_safe' - - 'nr_node_for_each' - - 'nr_node_for_each_safe' - - 'of_for_each_phandle' - - 'of_property_for_each_string' - - 'of_property_for_each_u32' - - 'pci_bus_for_each_resource' - - 'pci_doe_for_each_off' - - 'pcl_for_each_chunk' - - 'pcl_for_each_segment' - - 'pcm_for_each_format' - - 'perf_config_items__for_each_entry' - - 'perf_config_sections__for_each_entry' - - 'perf_config_set__for_each_entry' - - 'perf_cpu_map__for_each_cpu' - - 'perf_evlist__for_each_entry' - - 'perf_evlist__for_each_entry_reverse' - - 'perf_evlist__for_each_entry_safe' - - 'perf_evlist__for_each_evsel' - - 'perf_evlist__for_each_mmap' - - 'perf_hpp_list__for_each_format' - - 'perf_hpp_list__for_each_format_safe' - - 'perf_hpp_list__for_each_sort_list' - - 'perf_hpp_list__for_each_sort_list_safe' - - 'perf_pmu__for_each_hybrid_pmu' - - 'ping_portaddr_for_each_entry' - - 'ping_portaddr_for_each_entry_rcu' - - 'plist_for_each' - - 'plist_for_each_continue' - - 'plist_for_each_entry' - - 'plist_for_each_entry_continue' - - 'plist_for_each_entry_safe' - - 'plist_for_each_safe' - - 'pnp_for_each_card' - - 'pnp_for_each_dev' - - 'protocol_for_each_card' - - 'protocol_for_each_dev' - - 'queue_for_each_hw_ctx' - - 'radix_tree_for_each_slot' - - 'radix_tree_for_each_tagged' - - 'rb_for_each' - - 'rbtree_postorder_for_each_entry_safe' - - 'rdma_for_each_block' - - 'rdma_for_each_port' - - 'rdma_umem_for_each_dma_block' - - 'resort_rb__for_each_entry' - - 'resource_list_for_each_entry' - - 'resource_list_for_each_entry_safe' - - 'rhl_for_each_entry_rcu' - - 'rhl_for_each_rcu' - - 'rht_for_each' - - 'rht_for_each_entry' - - 'rht_for_each_entry_from' - - 'rht_for_each_entry_rcu' - - 'rht_for_each_entry_rcu_from' - - 'rht_for_each_entry_safe' - - 'rht_for_each_from' - - 'rht_for_each_rcu' - - 'rht_for_each_rcu_from' - - 'rq_for_each_bvec' - - 'rq_for_each_segment' - - 'rq_list_for_each' - - 'rq_list_for_each_safe' - - 'scsi_for_each_prot_sg' - - 'scsi_for_each_sg' - - 'sctp_for_each_hentry' - - 'sctp_skb_for_each' - - 'sec_for_each_insn' - - 'sec_for_each_insn_continue' - - 'sec_for_each_insn_from' - - 'shdma_for_each_chan' - - 'shost_for_each_device' - - 'sk_for_each' - - 'sk_for_each_bound' - - 'sk_for_each_entry_offset_rcu' - - 'sk_for_each_from' - - 'sk_for_each_rcu' - - 'sk_for_each_safe' - - 'sk_nulls_for_each' - - 'sk_nulls_for_each_from' - - 'sk_nulls_for_each_rcu' - - 'snd_array_for_each' - - 'snd_pcm_group_for_each_entry' - - 'snd_soc_dapm_widget_for_each_path' - - 'snd_soc_dapm_widget_for_each_path_safe' - - 'snd_soc_dapm_widget_for_each_sink_path' - - 'snd_soc_dapm_widget_for_each_source_path' - - 'strlist__for_each_entry' - - 'strlist__for_each_entry_safe' - - 'sym_for_each_insn' - - 'sym_for_each_insn_continue_reverse' - - 'symbols__for_each_entry' - - 'tb_property_for_each' - - 'tcf_act_for_each_action' - - 'tcf_exts_for_each_action' - - 'udp_portaddr_for_each_entry' - - 'udp_portaddr_for_each_entry_rcu' - - 'usb_hub_for_each_child' - - 'v4l2_device_for_each_subdev' - - 'v4l2_m2m_for_each_dst_buf' - - 'v4l2_m2m_for_each_dst_buf_safe' - - 'v4l2_m2m_for_each_src_buf' - - 'v4l2_m2m_for_each_src_buf_safe' - - 'virtio_device_for_each_vq' - - 'while_for_each_ftrace_op' - - 'xa_for_each' - - 'xa_for_each_marked' - - 'xa_for_each_range' - - 'xa_for_each_start' - - 'xas_for_each' - - 'xas_for_each_conflict' - - 'xas_for_each_marked' - - 'xbc_array_for_each_value' - - 'xbc_for_each_key_value' - - 'xbc_node_for_each_array_value' - - 'xbc_node_for_each_child' - - 'xbc_node_for_each_key_value' - - 'xbc_node_for_each_subkey' - - 'zorro_for_each_dev' - -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentGotoLabels: false -IndentPPDirectives: None -IndentWidth: 8 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 8 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true - -# Taken from git's rules -PenaltyBreakAssignment: 10 -PenaltyBreakBeforeFirstCallParameter: 30 -PenaltyBreakComment: 10 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 10 -PenaltyExcessCharacter: 100 -PenaltyReturnTypeOnItsOwnLine: 60 - -PointerAlignment: Right -ReflowComments: false -SortIncludes: false -SortUsingDeclarations: false -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatementsExceptForEachMacros -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp03 -TabWidth: 8 -UseTab: Always -... diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ba9b0a9..0000000 --- a/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*.cmd -*.ko -*.mod* -*.o -*.orig -modules.order -Module.symvers -.cache.mk -.thinlto-cache/ -.repo/ -/gcip-kernel-driver @@ -34,7 +34,6 @@ gxp-objs += \ gxp-trace.o \ gxp-vd.o - ifeq ($(GXP_CHIP),CALLISTO) gxp-objs += \ @@ -54,7 +53,6 @@ gxp-objs += \ GMODULE_PATH := $(OUT_DIR)/../private/google-modules EDGETPU_CHIP := rio - endif ifeq ($(CONFIG_$(GXP_CHIP)),m) diff --git a/callisto/csrs.h b/callisto/csrs.h index df58916..1a0abc1 100644 --- a/callisto/csrs.h +++ b/callisto/csrs.h @@ -8,8 +8,6 @@ #ifndef __CALLISTO_CSRS_H__ #define __CALLISTO_CSRS_H__ -/* TODO(b/232083805): Update values in this file. Also remove unused fields. */ - #define GXP_REG_DOORBELLS_SET_WRITEMASK 0x1 #define GXP_REG_DOORBELLS_CLEAR_WRITEMASK 0x1 diff --git a/callisto/iova.h b/callisto/iova.h index bc55c6c..52751b7 100644 --- a/callisto/iova.h +++ b/callisto/iova.h @@ -13,7 +13,6 @@ #define GXP_IOVA_EXT_TPU_MBX (0x1A050000) #define GXP_IOVA_FIRMWARE(_x_) (0xFA000000 + (_x_) * 0x00100000) #define GXP_IOVA_SHARED_BUFFER (0xFA3A8000) -#define GXP_IOVA_FW_DATA (0xFA400000) #define GXP_IOVA_PRIV_FW_DATA (0xFA500000) #define GXP_IOVA_TPU_MBX_BUFFER(_x_) (0xFE100000 + (_x_) * 0x00040000) diff --git a/gxp-client.c b/gxp-client.c index a776542..ea4b9c1 100644 --- a/gxp-client.c +++ b/gxp-client.c @@ -180,9 +180,6 @@ int gxp_client_acquire_block_wakelock(struct gxp_client *client, lockdep_assert_held(&client->semaphore); if (!client->has_block_wakelock) { - ret = gcip_pm_get(gxp->power_mgr->pm); - if (ret) - return ret; *acquired_wakelock = true; if (client->vd) { down_write(&gxp->vd_semaphore); @@ -206,20 +203,17 @@ int gxp_client_acquire_block_wakelock(struct gxp_client *client, return 0; err_wakelock_release: - if (*acquired_wakelock) { - gcip_pm_put(gxp->power_mgr->pm); - *acquired_wakelock = false; - } + *acquired_wakelock = false; return ret; } -void gxp_client_release_block_wakelock(struct gxp_client *client) +bool gxp_client_release_block_wakelock(struct gxp_client *client) { struct gxp_dev *gxp = client->gxp; lockdep_assert_held(&client->semaphore); if (!client->has_block_wakelock) - return; + return false; gxp_client_release_vd_wakelock(client); @@ -229,8 +223,9 @@ void gxp_client_release_block_wakelock(struct gxp_client *client) up_write(&gxp->vd_semaphore); } - gcip_pm_put(gxp->power_mgr->pm); client->has_block_wakelock = false; + + return true; } int gxp_client_acquire_vd_wakelock(struct gxp_client *client, diff --git a/gxp-client.h b/gxp-client.h index 470622b..cfda34a 100644 --- a/gxp-client.h +++ b/gxp-client.h @@ -82,6 +82,8 @@ int gxp_client_allocate_virtual_device(struct gxp_client *client, * * The caller must have locked client->semaphore. * + * Note that this function won't increase the PM count. (i.e., won't call gcip_pm_get) + * * Return: * * 0 - Success * * Otherwise - Errno returned by block wakelock acquisition @@ -93,8 +95,12 @@ int gxp_client_acquire_block_wakelock(struct gxp_client *client, * revokes the power votes. * * The caller must have locked client->semaphore. + * + * Note that this function won't decrease the PM count. (i.e., won't call gcip_pm_put) + * + * Return: false only when @client hasn't held the block wakelock. */ -void gxp_client_release_block_wakelock(struct gxp_client *client); +bool gxp_client_release_block_wakelock(struct gxp_client *client); /** * gxp_client_acquire_vd_wakelock() - Acquires a VD wakelock for the current * virtual device to start the virtual device or resume it if it's suspended. diff --git a/gxp-common-platform.c b/gxp-common-platform.c index c9fa143..916603a 100644 --- a/gxp-common-platform.c +++ b/gxp-common-platform.c @@ -636,12 +636,6 @@ gxp_etm_trace_start_command(struct gxp_client *client, goto out; } - /* - * TODO (b/185260919): Pass the etm trace configuration to system FW - * once communication channel between kernel and system FW is ready - * (b/185819530). - */ - out: up_read(&gxp->vd_semaphore); out_unlock_client_semaphore: @@ -679,13 +673,6 @@ static int gxp_etm_trace_sw_stop_command(struct gxp_client *client, ret = -EINVAL; goto out; } - - /* - * TODO (b/185260919): Pass the etm stop signal to system FW once - * communication channel between kernel and system FW is ready - * (b/185819530). - */ - out: up_read(&gxp->vd_semaphore); out_unlock_client_semaphore: @@ -723,13 +710,6 @@ static int gxp_etm_trace_cleanup_command(struct gxp_client *client, ret = -EINVAL; goto out; } - - /* - * TODO (b/185260919): Pass the etm clean up signal to system FW once - * communication channel between kernel and system FW is ready - * (b/185819530). - */ - out: up_read(&gxp->vd_semaphore); out_unlock_client_semaphore: @@ -786,12 +766,6 @@ gxp_etm_get_trace_info_command(struct gxp_client *client, goto out_free_header; } - /* - * TODO (b/185260919): Get trace information from system FW once - * communication channel between kernel and system FW is ready - * (b/185819530). - */ - if (copy_to_user((void __user *)ibuf.trace_header_addr, trace_header, GXP_TRACE_HEADER_SIZE)) { ret = -EFAULT; @@ -1150,6 +1124,27 @@ static int gxp_acquire_wake_lock(struct gxp_client *client, !validate_wake_lock_power(gxp, &ibuf)) return -EINVAL; + /* + * We intentionally don't call `gcip_pm_*` functions while holding @client->semaphore. + * + * As the `gcip_pm_put` function cancels KCI works synchronously and the KCI works may hold + * @client->semaphore in some logics such as MCU FW crash handler, it can cause deadlock + * issues potentially if we call `gcip_pm_put` after holding @client->semaphore. + * + * Therefore, we decided to decouple calling the `gcip_pm_put` function from holding + * @client->semaphore and applied the same thing to the `gcip_pm_get` function to keep them + * symmetric. + */ + if (ibuf.components_to_wake & WAKELOCK_BLOCK) { + ret = gcip_pm_get(gxp->power_mgr->pm); + if (ret) { + dev_err(gxp->dev, + "Failed to increase the PM count or power up the block (ret=%d)\n", + ret); + return ret; + } + } + down_write(&client->semaphore); if ((ibuf.components_to_wake & WAKELOCK_VIRTUAL_DEVICE) && (!client->vd)) { @@ -1187,10 +1182,7 @@ static int gxp_acquire_wake_lock(struct gxp_client *client, } } -out: - up_write(&client->semaphore); - - return ret; + goto out; err_acquiring_vd_wl: /* @@ -1199,17 +1191,25 @@ err_acquiring_vd_wl: * VIRTUAL_DEVICE wakelock after successfully acquiring the BLOCK * wakelock, then release it before returning the error code. */ - if (acquired_block_wakelock) + if (acquired_block_wakelock) { gxp_client_release_block_wakelock(client); + acquired_block_wakelock = false; + } +out: up_write(&client->semaphore); + if ((ibuf.components_to_wake & WAKELOCK_BLOCK) && !acquired_block_wakelock) + gcip_pm_put(gxp->power_mgr->pm); + return ret; } static int gxp_release_wake_lock(struct gxp_client *client, __u32 __user *argp) { + struct gxp_dev *gxp = client->gxp; u32 wakelock_components; + bool released_block_wakelock = false; int ret = 0; if (copy_from_user(&wakelock_components, argp, @@ -1222,10 +1222,13 @@ static int gxp_release_wake_lock(struct gxp_client *client, __u32 __user *argp) gxp_client_release_vd_wakelock(client); if (wakelock_components & WAKELOCK_BLOCK) - gxp_client_release_block_wakelock(client); + released_block_wakelock = gxp_client_release_block_wakelock(client); up_write(&client->semaphore); + if (released_block_wakelock) + gcip_pm_put(gxp->power_mgr->pm); + return ret; } diff --git a/gxp-debug-dump.c b/gxp-debug-dump.c index d099e7b..53ea055 100644 --- a/gxp-debug-dump.c +++ b/gxp-debug-dump.c @@ -505,12 +505,6 @@ static int gxp_map_fw_rw_section(struct gxp_dev *gxp, dma_addr_t fw_rw_section_daddr = CORE_FIRMWARE_RW_ADDR(virt_core_id); const size_t n_reg = ARRAY_SIZE(vd->ns_regions); - if (!gxp_fw_data_use_per_vd_config(vd)) { - dev_err(gxp->dev, "Unsupported Image config version = %d.", - gxp->fw_loader_mgr->core_img_cfg.config_version); - return -EOPNOTSUPP; - } - for (idx = 0; idx < n_reg; idx++) { sgt = vd->ns_regions[idx].sgt; if (!sgt) diff --git a/gxp-debug-dump.h b/gxp-debug-dump.h index aeb8229..158c8b9 100644 --- a/gxp-debug-dump.h +++ b/gxp-debug-dump.h @@ -24,11 +24,13 @@ #define GXP_NUM_COMMON_SEGMENTS 2 #define GXP_NUM_CORE_SEGMENTS 8 +/* 1 segment for RO and 1 for RW */ +#define GXP_NUM_CORE_DATA_SEGMENTS 2 #define GXP_NUM_BUFFER_MAPPINGS 32 #define GXP_SEG_HEADER_NAME_LENGTH 32 -#define GXP_NUM_SEGMENTS_PER_CORE \ - (GXP_NUM_COMMON_SEGMENTS + GXP_NUM_CORE_SEGMENTS + \ - GXP_NUM_BUFFER_MAPPINGS + 1) +#define GXP_NUM_SEGMENTS_PER_CORE \ + (GXP_NUM_COMMON_SEGMENTS + GXP_NUM_CORE_SEGMENTS + GXP_NUM_CORE_DATA_SEGMENTS + \ + GXP_NUM_BUFFER_MAPPINGS) #define GXP_Q7_ICACHE_SIZE 131072 /* I-cache size in bytes */ #define GXP_Q7_ICACHE_LINESIZE 64 /* I-cache line size in bytes */ diff --git a/gxp-dma-iommu.c b/gxp-dma-iommu.c index 665a8d1..1d60888 100644 --- a/gxp-dma-iommu.c +++ b/gxp-dma-iommu.c @@ -273,7 +273,6 @@ void gxp_dma_init_default_resources(struct gxp_dev *gxp) gxp->mbx[i].daddr = GXP_IOVA_MAILBOX(i); for (core = 0; core < GXP_NUM_CORES; core++) gxp->fwbufs[core].daddr = GXP_IOVA_FIRMWARE(core); - gxp->fwdatabuf.daddr = GXP_IOVA_FW_DATA; } int gxp_dma_domain_attach_device(struct gxp_dev *gxp, @@ -321,13 +320,6 @@ int gxp_dma_map_core_resources(struct gxp_dev *gxp, if (ret) goto err; } - /* TODO(b/265748027): directly remove this map */ - if (gxp->fwdatabuf.daddr) - ret = iommu_map(domain, gxp->fwdatabuf.daddr, - gxp->fwdatabuf.paddr, gxp->fwdatabuf.size, - IOMMU_READ | IOMMU_WRITE); - if (ret) - goto err; /* Only map the TPU mailboxes if they were found on probe */ if (gxp->tpu_dev.mbx_paddr) { for (i = 0; i < GXP_NUM_CORES; i++) { @@ -374,8 +366,6 @@ void gxp_dma_unmap_core_resources(struct gxp_dev *gxp, EXT_TPU_MBX_SIZE); } } - if (gxp->fwdatabuf.daddr) - iommu_unmap(domain, gxp->fwdatabuf.daddr, gxp->fwdatabuf.size); for (i = 0; i < GXP_NUM_CORES; i++) { if (!(BIT(i) & core_list)) continue; diff --git a/gxp-firmware-data.c b/gxp-firmware-data.c index a98a183..0c2c5ae 100644 --- a/gxp-firmware-data.c +++ b/gxp-firmware-data.c @@ -182,8 +182,7 @@ void gxp_fw_data_destroy(struct gxp_dev *gxp) void gxp_fw_data_populate_vd_cfg(struct gxp_dev *gxp, struct gxp_virtual_device *vd) { - if (gxp_fw_data_use_per_vd_config(vd)) - _gxp_fw_data_populate_vd_cfg(gxp, vd); + _gxp_fw_data_populate_vd_cfg(gxp, vd); } int gxp_fw_data_set_core_telemetry_descriptors(struct gxp_dev *gxp, u8 type, diff --git a/gxp-firmware-data.h b/gxp-firmware-data.h index 89bf9e4..a4da548 100644 --- a/gxp-firmware-data.h +++ b/gxp-firmware-data.h @@ -90,11 +90,6 @@ int gxp_fw_data_set_core_telemetry_descriptors(struct gxp_dev *gxp, u8 type, u32 gxp_fw_data_get_core_telemetry_device_status(struct gxp_dev *gxp, uint core, u8 type); -static inline bool gxp_fw_data_use_per_vd_config(struct gxp_virtual_device *vd) -{ - return vd->config_version >= FW_DATA_PROTOCOL_PER_VD_CONFIG; -} - /** * gxp_fw_data_resource() - Returns the resource of data region for host<->core * communication. diff --git a/gxp-firmware.c b/gxp-firmware.c index 5b1e5ab..7118a23 100644 --- a/gxp-firmware.c +++ b/gxp-firmware.c @@ -19,6 +19,7 @@ #include <gcip/gcip-alloc-helper.h> #include <gcip/gcip-common-image-header.h> #include <gcip/gcip-image-config.h> +#include <gcip/gcip-pm.h> #include "gxp-bpm.h" #include "gxp-client.h" @@ -92,6 +93,28 @@ err: return ret; } +static bool check_firmware_config_version(struct gxp_dev *gxp, + const struct firmware *core_firmware[GXP_NUM_CORES]) +{ + struct gcip_common_image_header *hdr = + (struct gcip_common_image_header *)core_firmware[0]->data; + struct gcip_image_config *cfg; + + if (unlikely(core_firmware[0]->size < GCIP_FW_HEADER_SIZE)) + return false; + cfg = get_image_config_from_hdr(hdr); + if (!cfg) { + dev_err(gxp->dev, "Core firmware doesn't have a valid image config"); + return false; + } + if (cfg->config_version < FW_DATA_PROTOCOL_PER_VD_CONFIG) { + dev_err(gxp->dev, "Unsupported firmware image config version %d", + cfg->config_version); + return false; + } + return true; +} + static int elf_load_segments(struct gxp_dev *gxp, const u8 *elf_data, size_t size, const struct gxp_mapped_resource *buffer) @@ -295,11 +318,7 @@ static void gxp_program_reset_vector(struct gxp_dev *gxp, uint core, static void *get_scratchpad_base(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint core) { - if (vd && gxp_fw_data_use_per_vd_config(vd)) - return vd->core_cfg.vaddr + - (vd->core_cfg.size / GXP_NUM_CORES) * core; - - return gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF; + return vd->core_cfg.vaddr + (vd->core_cfg.size / GXP_NUM_CORES) * core; } static void reset_core_config_region(struct gxp_dev *gxp, @@ -308,17 +327,10 @@ static void reset_core_config_region(struct gxp_dev *gxp, struct gxp_host_control_region *core_cfg; core_cfg = get_scratchpad_base(gxp, vd, core); - if (gxp_fw_data_use_per_vd_config(vd)) { - core_cfg->core_alive_magic = 0; - core_cfg->top_access_ok = 0; - core_cfg->boot_status = GXP_BOOT_STATUS_NONE; - gxp_firmware_set_boot_mode(gxp, vd, core, - GXP_BOOT_MODE_COLD_BOOT); - } else { - memset(core_cfg, 0, AURORA_SCRATCHPAD_LEN); - gxp_firmware_set_boot_mode(gxp, vd, core, - GXP_BOOT_MODE_REQUEST_COLD_BOOT); - } + core_cfg->core_alive_magic = 0; + core_cfg->top_access_ok = 0; + core_cfg->boot_status = GXP_BOOT_STATUS_NONE; + gxp_firmware_set_boot_mode(gxp, vd, core, GXP_BOOT_MODE_COLD_BOOT); } static int gxp_firmware_handshake(struct gxp_dev *gxp, @@ -518,23 +530,23 @@ static ssize_t load_dsp_firmware_store(struct device *dev, int ret; /* - * Lock the VD semaphore to ensure no core is executing the firmware - * while requesting new firmware. + * TODO(b/281047946): Ensure no firmware is executing while requesting + * core firmware, which includes MCU firmware in MCU mode. + * + * Here we don't lock @gxp->vd_semaphore since it'll introduce wrong lock + * dependency, and this interface is only for developer debugging. We + * don't insist on preventing race condition here. */ - down_read(&gxp->vd_semaphore); - if (mgr->firmware_running) { dev_warn(dev, "Cannot update firmware when any core is running\n"); - ret = -EBUSY; - goto err_out; + return -EBUSY; } name_buf = fw_name_from_attr_buf(buf); if (IS_ERR(name_buf)) { dev_err(gxp->dev, "Invalid firmware prefix requested: %s\n", buf); - ret = PTR_ERR(name_buf); - goto err_out; + return PTR_ERR(name_buf); } dev_notice(gxp->dev, "Requesting firmware be reloaded: %s\n", name_buf); @@ -554,13 +566,10 @@ static ssize_t load_dsp_firmware_store(struct device *dev, } kfree(name_buf); - up_read(&gxp->vd_semaphore); return count; err_firmware_load: kfree(name_buf); -err_out: - up_read(&gxp->vd_semaphore); return ret; } @@ -637,18 +646,25 @@ static int debugfs_firmware_run_set(void *data, u64 val) list_add(&client->list_entry, &gxp->client_list); mutex_unlock(&gxp->client_list_lock); + ret = gcip_pm_get(gxp->power_mgr->pm); + if (ret) { + dev_err(gxp->dev, + "Failed to increase the PM count or power up the block (ret=%d)\n", ret); + goto out_destroy_client; + } + down_write(&client->semaphore); ret = gxp_client_allocate_virtual_device(client, GXP_NUM_CORES, 0); if (ret) { dev_err(gxp->dev, "Failed to allocate VD\n"); - goto err_destroy_client; + goto err_pm_put; } ret = gxp_client_acquire_block_wakelock(client, &acquired_block_wakelock); if (ret) { dev_err(gxp->dev, "Failed to acquire BLOCK wakelock\n"); - goto err_destroy_client; + goto err_pm_put; } ret = gxp_client_acquire_vd_wakelock(client, uud_states); @@ -666,8 +682,9 @@ out: err_release_block_wakelock: gxp_client_release_block_wakelock(client); -err_destroy_client: +err_pm_put: up_write(&client->semaphore); + gcip_pm_put(gxp->power_mgr->pm); out_destroy_client: mutex_lock(&gxp->client_list_lock); list_del(&gxp->debugfs_client->list_entry); @@ -829,6 +846,10 @@ int gxp_firmware_load_core_firmware( ret = request_dsp_firmware(gxp, name_prefix, core_firmware); if (ret) return ret; + if (!check_firmware_config_version(gxp, core_firmware)) { + ret = -EOPNOTSUPP; + goto error; + } ret = gxp_firmware_load_into_memories(gxp, core_firmware); if (ret) goto error; @@ -866,7 +887,7 @@ void gxp_firmware_disable_ext_interrupts(struct gxp_dev *gxp, uint core) static inline uint select_core(struct gxp_virtual_device *vd, uint virt_core, uint phys_core) { - return gxp_fw_data_use_per_vd_config(vd) ? virt_core : phys_core; + return virt_core; } static int gxp_firmware_setup(struct gxp_dev *gxp, @@ -1129,27 +1150,10 @@ void gxp_firmware_set_boot_mode(struct gxp_dev *gxp, { struct gxp_host_control_region *core_cfg; - /* Callers shouldn't call the function under this condition. */ - if (!gxp->fwbufs[core].vaddr) - return; - core_cfg = get_scratchpad_base(gxp, vd, core); core_cfg->boot_mode = mode; } -u32 gxp_firmware_get_boot_mode(struct gxp_dev *gxp, - struct gxp_virtual_device *vd, uint core) -{ - struct gxp_host_control_region *core_cfg; - - /* Callers shouldn't call the function under this condition. */ - if (!gxp->fwbufs[core].vaddr) - return 0; - - core_cfg = get_scratchpad_base(gxp, vd, core); - return core_cfg->boot_mode; -} - void gxp_firmware_set_boot_status(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint core, u32 status) diff --git a/gxp-firmware.h b/gxp-firmware.h index e1f44ce..9058f4d 100644 --- a/gxp-firmware.h +++ b/gxp-firmware.h @@ -15,34 +15,8 @@ #include "gxp-config.h" #include "gxp-internal.h" -#if !IS_ENABLED(CONFIG_GXP_TEST) - -#ifdef CHIP_AURORA_SCRATCHPAD_OFF - -#define AURORA_SCRATCHPAD_OFF CHIP_AURORA_SCRATCHPAD_OFF -#define AURORA_SCRATCHPAD_LEN CHIP_AURORA_SCRATCHPAD_LEN - -#else /* CHIP_AURORA_SCRATCHPAD_OFF */ - -#define AURORA_SCRATCHPAD_OFF 0x000FF000 /* Last 4KB of ELF load region */ -#define AURORA_SCRATCHPAD_LEN 0x00001000 /* 4KB */ - -#endif /* CHIP_AURORA_SCRATCHPAD_OFF */ - -#else /* CONFIG_GXP_TEST */ -/* Firmware memory is shrunk in unit tests. */ -#define AURORA_SCRATCHPAD_OFF 0x000F0000 -#define AURORA_SCRATCHPAD_LEN 0x00010000 - -#endif /* CONFIG_GXP_TEST */ - #define Q7_ALIVE_MAGIC 0x55555555 -#define SCRATCHPAD_MSG_OFFSET(_msg_) (_msg_ << 2) - -#define PRIVATE_FW_DATA_SIZE SZ_2M -#define SHARED_FW_DATA_SIZE SZ_1M - /* Indexes same as image_config.IommuMappingIdx in the firmware side. */ enum gxp_imgcfg_idx { CORE_CFG_REGION_IDX, @@ -131,13 +105,6 @@ void gxp_firmware_set_boot_mode(struct gxp_dev *gxp, u32 mode); /* - * Returns the specified core's boot mode or boot status. - * This function should be called only after the firmware has been run. - */ -u32 gxp_firmware_get_boot_mode(struct gxp_dev *gxp, - struct gxp_virtual_device *vd, uint core); - -/* * Sets the specified core's boot status or suspend request value. */ void gxp_firmware_set_boot_status(struct gxp_dev *gxp, diff --git a/gxp-host-device-structs.h b/gxp-host-device-structs.h index efb39a9..508d019 100644 --- a/gxp-host-device-structs.h +++ b/gxp-host-device-structs.h @@ -104,50 +104,6 @@ /* There was an attempt to use the buffers but their content was invalid. */ #define GXP_CORE_TELEMETRY_DEVICE_STATUS_SANITY_CHECK_FAILED (1 << 1) -/* Definitions for host->device boot mode requests */ -/* - * Request that the core performs a normal cold boot on the next power-on event. - * This does not actually wake the core up, but's required before powering the - * core up if cold boot is desired. - * Core power-on could be performed using any wake-up source like the doorbells. - */ -#define GXP_BOOT_MODE_REQUEST_COLD_BOOT 0 - -/* - * Request that the core suspends on the next suspend signal arrival. This does - * not trigger a suspend operation. A subsequent mailbox command or notification - * is needed to trigger the actual transition. - */ -#define GXP_BOOT_MODE_REQUEST_SUSPEND 1 - -/* - * Request the core resumes on the next power on-event. This does not trigger a - * resume operation, but's required before powering the core up if warm - * boot/resume is desired. - * Core power-on could be performed using any wake-up source like direct LPM - * transition into PS0. - */ -#define GXP_BOOT_MODE_REQUEST_RESUME 2 - -/* Cold boot status definitions */ -#define GXP_BOOT_MODE_STATUS_COLD_BOOT_PENDING 0 -#define GXP_BOOT_MODE_STATUS_COLD_BOOT_COMPLETED 3 - -/* Core suspend status definitions */ -#define GXP_BOOT_MODE_STATUS_SUSPEND_PENDING 1 -#define GXP_BOOT_MODE_STATUS_SUSPEND_STARTED 4 -#define GXP_BOOT_MODE_STATUS_SUSPEND_COMPLETED 5 -#define GXP_BOOT_MODE_STATUS_SUSPEND_ABORTED 6 - -/* Core resume/warm boot status definitions */ -#define GXP_BOOT_MODE_STATUS_RESUME_PENDING 2 -#define GXP_BOOT_MODE_STATUS_RESUME_STARTED 7 -#define GXP_BOOT_MODE_STATUS_RESUME_COMPLETED 8 -#define GXP_BOOT_MODE_STATUS_RESUME_FAILED 9 - -/* Invalid boot mode request code */ -#define GXP_BOOT_MODE_STATUS_INVALID_MODE 10 - /* * A structure describing the core telemetry (logging and tracing) parameters * and buffers. @@ -9,6 +9,7 @@ #include <linux/mutex.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/workqueue.h> #include <gcip/gcip-telemetry.h> #include <gcip/gcip-usage-stats.h> @@ -169,6 +170,7 @@ gxp_reverse_kci_handle_response(struct gcip_kci *kci, struct gxp_mailbox *mbx = gcip_kci_get_data(kci); struct gxp_dev *gxp = mbx->gxp; struct gxp_kci *gxp_kci = mbx->data; + struct gxp_mcu_firmware *mcu_fw = gxp_mcu_firmware_of(gxp); if (resp->code <= GCIP_RKCI_CHIP_CODE_LAST) { gxp_kci_handle_rkci(gxp_kci, resp); @@ -177,10 +179,12 @@ gxp_reverse_kci_handle_response(struct gcip_kci *kci, switch (resp->code) { case GCIP_RKCI_FIRMWARE_CRASH: - gxp_mcu_firmware_crash_handler(gxp, resp->retval); + if (resp->retval == GCIP_FW_CRASH_UNRECOVERABLE_FAULT) + schedule_work(&mcu_fw->fw_crash_handler_work); + else + dev_warn(gxp->dev, "MCU non-fatal crash: %u", resp->retval); break; case GCIP_RKCI_JOB_LOCKUP: - /* TODO(b/239638427): Handle job lookup */ dev_dbg(gxp->dev, "Job lookup received from MCU firmware"); break; default: diff --git a/gxp-mcu-firmware.c b/gxp-mcu-firmware.c index a4f1f40..b95bab9 100644 --- a/gxp-mcu-firmware.c +++ b/gxp-mcu-firmware.c @@ -14,6 +14,7 @@ #include <linux/resource.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/workqueue.h> #include <gcip/gcip-common-image-header.h> #include <gcip/gcip-image-config.h> @@ -35,6 +36,17 @@ #include "gxp-mcu.h" #include "gxp-pm.h" +#if IS_GXP_TEST +#define TEST_FLUSH_KCI_WORKERS(kci) \ + do { \ + kthread_flush_worker(&(kci).mbx->response_worker); \ + flush_work(&(kci).mbx->mbx_impl.gcip_kci->work); \ + flush_work(&(kci).mbx->mbx_impl.gcip_kci->rkci.work); \ + } while (0) +#else +#define TEST_FLUSH_KCI_WORKERS(...) +#endif + /* Value of Magic field in the common header "DSPF' as a 32-bit LE int */ #define GXP_FW_MAGIC 0x46505344 @@ -270,6 +282,9 @@ static void gxp_mcu_firmware_stop_locked(struct gxp_mcu_firmware *mcu_fw) if (ret) dev_err(gxp->dev, "Failed to transit MCU to PG state after KCI shutdown: %d", ret); + /* To test the case of the MCU FW sending FW_CRASH RKCI in the middle. */ + TEST_FLUSH_KCI_WORKERS(mcu->kci); + gxp_kci_cancel_work_queues(&mcu->kci); /* * Clears up all remaining KCI commands. Otherwise, MCU may drain them improperly after it @@ -486,6 +501,14 @@ static void image_config_unmap(void *data, dma_addr_t daddr, size_t size, gxp_iommu_unmap(gxp, gxp_iommu_get_domain_for_dev(gxp), daddr, size); } +static void gxp_mcu_firmware_crash_handler_work(struct work_struct *work) +{ + struct gxp_mcu_firmware *mcu_fw = + container_of(work, struct gxp_mcu_firmware, fw_crash_handler_work); + + gxp_mcu_firmware_crash_handler(mcu_fw->gxp, GCIP_FW_CRASH_UNRECOVERABLE_FAULT); +} + int gxp_mcu_firmware_init(struct gxp_dev *gxp, struct gxp_mcu_firmware *mcu_fw) { static const struct gcip_image_config_ops image_config_parser_ops = { @@ -509,6 +532,8 @@ int gxp_mcu_firmware_init(struct gxp_dev *gxp, struct gxp_mcu_firmware *mcu_fw) mcu_fw->gxp = gxp; mcu_fw->status = GCIP_FW_INVALID; mutex_init(&mcu_fw->lock); + INIT_WORK(&mcu_fw->fw_crash_handler_work, gxp_mcu_firmware_crash_handler_work); + ret = device_add_group(gxp->dev, &firmware_attr_group); if (ret) dev_err(gxp->dev, "failed to create firmware device group"); @@ -519,6 +544,7 @@ void gxp_mcu_firmware_exit(struct gxp_mcu_firmware *mcu_fw) { if (IS_GXP_TEST && (!mcu_fw || !mcu_fw->gxp)) return; + cancel_work_sync(&mcu_fw->fw_crash_handler_work); device_remove_group(mcu_fw->gxp->dev, &firmware_attr_group); } @@ -570,34 +596,17 @@ void gxp_mcu_firmware_crash_handler(struct gxp_dev *gxp, dev_err(gxp->dev, "Unrecoverable MCU firmware fault, handle it"); /* - * Prevent @gxp->client_list is being changed while handling the crash. - * The user cannot open or close a fd until this function releases the lock. - */ - mutex_lock(&gxp->client_list_lock); - - /* - * Hold @client->semaphore first to prevent deadlock. - * By holding this lock, clients cannot proceed most IOCTLs. - */ - list_for_each_entry (client, &gxp->client_list, list_entry) { - down_write(&client->semaphore); - } - - /* - * Holding @client->semaphore will block the most client actions, but let's make sure - * it by holding the locks directly related to the actions we want to block accordingly. - * For example, in the case of the block wakelock, the debug dump can try to acquire it - * which cannot be blocked by holding @client->semaphore. - */ - - /* - * We have to block allocating a new vd by the runtime. Otherwise, if it is holding the - * block wakelock, it will try to send a `allocate_vmbox` KCI to the crashed MCU firmware. + * In the case of stopping MCU FW while it is handling `CLIENT_FATAL_ERROR` RKCI, it will + * acquire locks in this order: + * gcip_pm_put -> holds @pm->lock -> gxp_mcu_firmware_stop -> holds @mcu_fw->lock + * -> waits for the completion of RKCI handler -> gxp_vd_invalidate_with_client_id + * -> holds @gxp->client_list_lock -> hold @client->semaphore -> holds @gxp->vd_semaphore * - * The runtime cannot allocate a new virtual device or closing its client until this - * function releases the lock. + * Also, in the case of starting MCU FW, the locking order will be: + * gcip_pm_get -> holds @pm->lock -> gxp_mcu_firmware_start -> holds @mcu_fw->lock + * + * To prevent a deadlock issue, we have to follow the same locking order from here. */ - down_write(&gxp->vd_semaphore); /* * Holding the PM lock due to the reasons listed below. @@ -619,6 +628,34 @@ void gxp_mcu_firmware_crash_handler(struct gxp_dev *gxp, goto out_unlock_pm; } + /* Hold @mcu_fw->lock because manipulating the MCU FW state must be a critical section. */ + mutex_lock(&mcu_fw->lock); + + /* + * Prevent @gxp->client_list is being changed while handling the crash. + * The user cannot open or close a fd until this function releases the lock. + */ + mutex_lock(&gxp->client_list_lock); + + /* + * Hold @client->semaphore first to prevent deadlock. + * By holding this lock, clients cannot proceed most IOCTLs. + */ + list_for_each_entry (client, &gxp->client_list, list_entry) { + down_write(&client->semaphore); + } + + /* + * Holding @client->semaphore will block the most client actions, but let's make sure + * it by holding the locks directly related to the actions we want to block accordingly. + * For example, in the case of the block wakelock, the debug dump can try to acquire it + * which cannot be blocked by holding @client->semaphore. + * + * However, we don't lock @gxp->vd_semaphore for not increasing lock dependency since + * holding @gxp->client_list_lock and @client->semaphore is enough to ensure no new VD + * being allocated. + */ + /* * Discard all pending/unconsumed UCI responses and change the state of all virtual devices * to GXP_VD_UNAVAILABLE. From now on, all clients cannot request new UCI commands. @@ -631,8 +668,6 @@ void gxp_mcu_firmware_crash_handler(struct gxp_dev *gxp, } /* Turn off and on the MCU PSM and restart the MCU firmware. */ - mutex_lock(&mcu_fw->lock); - ret = wait_for_pg_state_locked(gxp, crash_type == GCIP_FW_CRASH_HW_WDG_TIMEOUT); if (ret) { dev_err(gxp->dev, "Failed to transit MCU LPM state to PG (ret=%d)", ret); @@ -644,12 +679,11 @@ void gxp_mcu_firmware_crash_handler(struct gxp_dev *gxp, dev_err(gxp->dev, "Failed to run MCU firmware (ret=%d)", ret); out: - mutex_unlock(&mcu_fw->lock); -out_unlock_pm: - gcip_pm_unlock(pm); - up_write(&gxp->vd_semaphore); list_for_each_entry (client, &gxp->client_list, list_entry) { up_write(&client->semaphore); } mutex_unlock(&gxp->client_list_lock); + mutex_unlock(&mcu_fw->lock); +out_unlock_pm: + gcip_pm_unlock(pm); } diff --git a/gxp-mcu-firmware.h b/gxp-mcu-firmware.h index fb05edb..4049aa5 100644 --- a/gxp-mcu-firmware.h +++ b/gxp-mcu-firmware.h @@ -9,6 +9,7 @@ #define __GXP_MCU_FIRMWARE_H__ #include <linux/mutex.h> +#include <linux/workqueue.h> #include <gcip/gcip-firmware.h> #include <gcip/gcip-image-config.h> @@ -25,6 +26,9 @@ struct gxp_mcu_firmware { struct gcip_fw_info fw_info; struct gcip_image_config_parser cfg_parser; bool is_secure; + + /* Worker to handle the MCU FW unrecoverable crash. */ + struct work_struct fw_crash_handler_work; }; /* @@ -37,8 +37,7 @@ #define SHUTDOWN_DELAY_US_MIN 200 #define SHUTDOWN_DELAY_US_MAX 400 -/* TODO(b/279201155): set default to true once confirmed it works as expected */ -static bool gxp_slow_clk_on_idle; +static bool gxp_slow_clk_on_idle = true; module_param_named(slow_clk, gxp_slow_clk_on_idle, bool, 0660); /* diff --git a/gxp-usage-stats.c b/gxp-usage-stats.c index 1e5d3f9..4b859b3 100644 --- a/gxp-usage-stats.c +++ b/gxp-usage-stats.c @@ -100,10 +100,8 @@ void gxp_usage_stats_init(struct gxp_dev *gxp) int ret; ustats = devm_kzalloc(gxp->dev, sizeof(*gxp->usage_stats), GFP_KERNEL); - if (!ustats) { - dev_warn(gxp->dev, "failed to allocate memory for usage stats\n"); + if (!ustats) return; - } args.version = GXP_USAGE_METRIC_VERSION; args.dev = gxp->dev; @@ -548,8 +548,6 @@ static void vd_save_doorbells(struct gxp_virtual_device *vd) uint base_doorbell; uint i; - if (!gxp_fw_data_use_per_vd_config(vd)) - return; base_doorbell = GXP_DOORBELLS_START + gxp_vd_hw_slot_id(vd) * GXP_NUM_DOORBELLS_PER_VD; for (i = 0; i < ARRAY_SIZE(vd->doorbells_state); i++) { @@ -566,8 +564,6 @@ static void vd_restore_doorbells(struct gxp_virtual_device *vd) uint base_doorbell; uint i; - if (!gxp_fw_data_use_per_vd_config(vd)) - return; base_doorbell = GXP_DOORBELLS_START + gxp_vd_hw_slot_id(vd) * GXP_NUM_DOORBELLS_PER_VD; for (i = 0; i < ARRAY_SIZE(vd->doorbells_state); i++) @@ -577,20 +573,6 @@ static void vd_restore_doorbells(struct gxp_virtual_device *vd) gxp_doorbell_clear(gxp, base_doorbell + i); } -static void set_config_version(struct gxp_dev *gxp, - struct gxp_virtual_device *vd) -{ - vd->config_version = gxp->fw_loader_mgr->core_img_cfg.config_version; - /* - * Let gxp_dma_map_core_resources() map this region only when using the - * legacy protocol. - * - * TODO(b/265748027): remove this - */ - if (gxp_fw_data_use_per_vd_config(vd)) - gxp->fwdatabuf.daddr = 0; -} - static void debug_dump_lock(struct gxp_dev *gxp, struct gxp_virtual_device *vd) { if (!mutex_trylock(&vd->debug_dump_lock)) { @@ -684,7 +666,6 @@ struct gxp_virtual_device *gxp_vd_allocate(struct gxp_dev *gxp, if (err) goto error_unassign_cores; - set_config_version(gxp, vd); /* After map_fw_image_config because it needs vd->vd/core_cfg. */ gxp_fw_data_populate_vd_cfg(gxp, vd); err = gxp_dma_map_core_resources(gxp, vd->domain, vd->core_list, @@ -962,33 +943,23 @@ void gxp_vd_stop(struct gxp_virtual_device *vd) static inline uint select_core(struct gxp_virtual_device *vd, uint virt_core, uint phys_core) { - return gxp_fw_data_use_per_vd_config(vd) ? virt_core : phys_core; + return virt_core; } static bool boot_state_is_suspend(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint core, u32 *boot_state) { - if (gxp_fw_data_use_per_vd_config(vd)) { - *boot_state = gxp_firmware_get_boot_status(gxp, vd, core); - return *boot_state == GXP_BOOT_STATUS_SUSPENDED; - } - - *boot_state = gxp_firmware_get_boot_mode(gxp, vd, core); - return *boot_state == GXP_BOOT_MODE_STATUS_SUSPEND_COMPLETED; + *boot_state = gxp_firmware_get_boot_status(gxp, vd, core); + return *boot_state == GXP_BOOT_STATUS_SUSPENDED; } static bool boot_state_is_active(struct gxp_dev *gxp, struct gxp_virtual_device *vd, uint core, u32 *boot_state) { - if (gxp_fw_data_use_per_vd_config(vd)) { - *boot_state = gxp_firmware_get_boot_status(gxp, vd, core); - return *boot_state == GXP_BOOT_STATUS_ACTIVE; - } - - *boot_state = gxp_firmware_get_boot_mode(gxp, vd, core); - return *boot_state == GXP_BOOT_MODE_STATUS_RESUME_COMPLETED; + *boot_state = gxp_firmware_get_boot_status(gxp, vd, core); + return *boot_state == GXP_BOOT_STATUS_ACTIVE; } /* @@ -1044,15 +1015,8 @@ void gxp_vd_suspend(struct gxp_virtual_device *vd) continue; } /* Mark the boot mode as a suspend event */ - if (gxp_fw_data_use_per_vd_config(vd)) { - gxp_firmware_set_boot_status(gxp, vd, core, - GXP_BOOT_STATUS_NONE); - gxp_firmware_set_boot_mode(gxp, vd, core, - GXP_BOOT_MODE_SUSPEND); - } else { - gxp_firmware_set_boot_mode( - gxp, vd, core, GXP_BOOT_MODE_REQUEST_SUSPEND); - } + gxp_firmware_set_boot_status(gxp, vd, core, GXP_BOOT_STATUS_NONE); + gxp_firmware_set_boot_mode(gxp, vd, core, GXP_BOOT_MODE_SUSPEND); /* * Request a suspend event by sending a mailbox * notification. @@ -1169,15 +1133,8 @@ int gxp_vd_resume(struct gxp_virtual_device *vd) } } /* Mark this as a resume power-up event. */ - if (gxp_fw_data_use_per_vd_config(vd)) { - gxp_firmware_set_boot_status(gxp, vd, core, - GXP_BOOT_STATUS_NONE); - gxp_firmware_set_boot_mode(gxp, vd, core, - GXP_BOOT_MODE_RESUME); - } else { - gxp_firmware_set_boot_mode( - gxp, vd, core, GXP_BOOT_MODE_REQUEST_RESUME); - } + gxp_firmware_set_boot_status(gxp, vd, core, GXP_BOOT_STATUS_NONE); + gxp_firmware_set_boot_mode(gxp, vd, core, GXP_BOOT_MODE_RESUME); /* * Power on the core by explicitly switching its PSM to * PS0 (LPM_ACTIVE_STATE). @@ -1448,6 +1405,22 @@ void gxp_vd_put(struct gxp_virtual_device *vd) kfree(vd); } +static void gxp_vd_invalidate_locked(struct gxp_dev *gxp, struct gxp_virtual_device *vd) +{ + lockdep_assert_held_write(&gxp->vd_semaphore); + + dev_err(gxp->dev, "Invalidate a VD, VDID=%d, client_id=%d", vd->vdid, + vd->client_id); + + if (vd->state != GXP_VD_UNAVAILABLE) { + vd->state = GXP_VD_UNAVAILABLE; + if (vd->invalidate_eventfd) + gxp_eventfd_signal(vd->invalidate_eventfd); + } else { + dev_dbg(gxp->dev, "This VD is already invalidated"); + } +} + void gxp_vd_invalidate_with_client_id(struct gxp_dev *gxp, int client_id, uint core_list, bool release_vmbox) { @@ -1497,7 +1470,7 @@ void gxp_vd_invalidate_with_client_id(struct gxp_dev *gxp, int client_id, uint c return; } - gxp_vd_invalidate(gxp, client->vd); + gxp_vd_invalidate_locked(gxp, client->vd); /* * Release @client->semaphore first because we need this lock to block ioctls while @@ -1514,18 +1487,9 @@ void gxp_vd_invalidate_with_client_id(struct gxp_dev *gxp, int client_id, uint c void gxp_vd_invalidate(struct gxp_dev *gxp, struct gxp_virtual_device *vd) { - lockdep_assert_held_write(&gxp->vd_semaphore); - - dev_err(gxp->dev, "Invalidate a VD, VDID=%d, client_id=%d", vd->vdid, - vd->client_id); - - if (vd->state != GXP_VD_UNAVAILABLE) { - vd->state = GXP_VD_UNAVAILABLE; - if (vd->invalidate_eventfd) - gxp_eventfd_signal(vd->invalidate_eventfd); - } else { - dev_dbg(gxp->dev, "This VD is already invalidated"); - } + down_write(&gxp->vd_semaphore); + gxp_vd_invalidate_locked(gxp, vd); + up_write(&gxp->vd_semaphore); } void gxp_vd_generate_debug_dump(struct gxp_dev *gxp, @@ -1590,7 +1554,7 @@ void gxp_vd_release_vmbox(struct gxp_dev *gxp, struct gxp_virtual_device *vd) dev_err(gxp->dev, "Firmware failed to gracefully release a VMBox for client %d, core_list=%d", vd->client_id, core_list); - gxp_vd_invalidate(gxp, vd); + gxp_vd_invalidate_locked(gxp, vd); gxp_vd_generate_debug_dump(gxp, vd, core_list); } else { dev_err(gxp->dev, "Failed to request releasing VMBox for client %d: %d", @@ -137,8 +137,6 @@ struct gxp_virtual_device { /* A constant ID assigned after VD is allocated. For debug only. */ int vdid; struct gcip_image_config_parser cfg_parser; - /* The config version specified in firmware's image config. */ - u32 config_version; /* Protects @dma_fence_list. */ struct mutex fence_list_lock; /* List of GXP DMA fences owned by this VD. */ |