diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..ece29c364 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +common/.kunit diff --git a/android/abi_gki_aarch64_xiaomi2 b/android/abi_gki_aarch64_xiaomi2 new file mode 100644 index 000000000..bbaae6d45 --- /dev/null +++ b/android/abi_gki_aarch64_xiaomi2 @@ -0,0 +1,2833 @@ +[abi_symbol_list] + activate_task + add_cpu + add_device_randomness + add_taint + add_timer + add_timer_on + add_uevent_var + add_wait_queue + add_wait_queue_priority + adjust_managed_page_count + alarm_cancel + alarm_init + alarm_start_relative + alloc_chrdev_region + alloc_io_pgtable_ops + alloc_netdev_mqs + __alloc_pages + __alloc_pages_bulk + alloc_pages_exact + __alloc_percpu + __alloc_percpu_gfp + __alloc_skb + alloc_skb_with_frags + alloc_workqueue + alt_cb_patch_nops + amba_driver_register + amba_driver_unregister + android_debug_symbol + android_rvh_probe_register + anon_inode_getfd + arc4_crypt + arc4_setkey + __arch_clear_user + __arch_copy_from_user + __arch_copy_to_user + arch_freq_scale + arch_wb_cache_pmem + arm64_use_ng_mappings + arm_smccc_1_1_get_conduit + arm_smccc_1_2_hvc + arm_smccc_1_2_smc + arm_smccc_get_version + __arm_smccc_hvc + __arm_smccc_smc + async_schedule_node + async_schedule_node_domain + atomic_notifier_call_chain + atomic_notifier_chain_register + atomic_notifier_chain_unregister + autoremove_wake_function + available_idle_cpu + backlight_device_register + backlight_device_set_brightness + backlight_device_unregister + __balance_callbacks + balance_dirty_pages_ratelimited + balance_push_callback + bcmp + bdi_alloc + bdi_put + bdi_register + bdi_unregister + bio_add_page + bio_alloc_bioset + bio_crypt_set_ctx + bio_endio + bio_end_io_acct_remapped + bio_put + bio_start_io_acct + __bitmap_and + __bitmap_andnot + __bitmap_clear + __bitmap_equal + bitmap_find_next_zero_area_off + bitmap_free + bitmap_from_arr32 + __bitmap_or + bitmap_print_to_pagebuf + __bitmap_set + __bitmap_weight + bitmap_zalloc + __blk_alloc_disk + blk_crypto_evict_key + blk_crypto_init_key + blk_crypto_keyslot_index + blk_crypto_register + blk_crypto_reprogram_all_keys + blk_crypto_start_using_key + blkdev_get_by_dev + blkdev_get_by_path + blkdev_put + blk_execute_rq + blk_fill_rwbs + __blk_mq_alloc_disk + blk_mq_alloc_request + blk_mq_alloc_sq_tag_set + blk_mq_alloc_tag_set + blk_mq_destroy_queue + __blk_mq_end_request + blk_mq_free_request + blk_mq_free_tag_set + blk_mq_freeze_queue + blk_mq_init_queue + blk_mq_map_queues + blk_mq_quiesce_queue + blk_mq_quiesce_tagset + blk_mq_sched_mark_restart_hctx + blk_mq_sched_try_insert_merge + blk_mq_sched_try_merge + blk_mq_start_request + blk_mq_tagset_busy_iter + blk_mq_unfreeze_queue + blk_mq_unique_tag + blk_mq_unquiesce_queue + blk_mq_unquiesce_tagset + blk_mq_wait_quiesce_done + blk_pm_runtime_init + blk_put_queue + blk_queue_flag_clear + blk_queue_flag_set + blk_queue_io_min + blk_queue_io_opt + blk_queue_logical_block_size + blk_queue_max_discard_sectors + blk_queue_max_write_zeroes_sectors + blk_queue_physical_block_size + blk_queue_update_dma_pad + blk_queue_write_cache + blk_req_needs_zone_write_lock + __blk_req_zone_write_lock + __blk_req_zone_write_unlock + blk_rq_map_kern + blk_update_request + blocking_notifier_call_chain + blocking_notifier_chain_register + blocking_notifier_chain_unregister + bpf_trace_run1 + bpf_trace_run10 + bpf_trace_run11 + bpf_trace_run12 + bpf_trace_run2 + bpf_trace_run3 + bpf_trace_run4 + bpf_trace_run5 + bpf_trace_run6 + bpf_trace_run7 + bpf_trace_run8 + bpf_trace_run9 + bsg_job_done + bsg_remove_queue + bsg_setup_queue + build_skb + bus_find_device + bus_for_each_dev + bus_get_dev_root + bus_register + bus_register_notifier + bus_unregister + bus_unregister_notifier + cache_line_size + call_netdevice_notifiers + call_rcu + call_usermodehelper + cancel_delayed_work + cancel_delayed_work_sync + cancel_work + cancel_work_sync + capable + cdev_add + cdev_alloc + cdev_del + cdev_device_add + cdev_device_del + cdev_init + cgroup_add_legacy_cftypes + cgroup_rm_cftypes + cgroup_taskset_first + cgroup_taskset_next + __check_object_size + check_preempt_curr + class_create + class_destroy + class_find_device + class_for_each_device + class_register + class_unregister + clear_page + __ClearPageMovable + clk_bulk_disable + clk_bulk_enable + clk_bulk_prepare + clk_bulk_unprepare + clk_disable + clk_enable + __clk_get_name + clk_get_parent + clk_get_rate + clk_hw_get_flags + clk_hw_get_name + clk_hw_get_num_parents + clk_hw_get_parent + clk_hw_register + clk_hw_round_rate + clk_hw_unregister + __clk_is_enabled + clk_mux_determine_rate_flags + clk_prepare + clk_put + clk_restore_context + clk_round_rate + clk_save_context + clk_set_rate + clk_unprepare + clockevent_delta2ns + clockevents_register_device + clocks_calc_mult_shift + __clocksource_register_scale + cma_alloc + cma_for_each_area + cma_get_name + cma_release + compact_node_async + compat_ptr_ioctl + complete + complete_all + completion_done + component_add + component_bind_all + component_del + component_master_add_with_match + component_master_del + component_match_add_release + component_unbind_all + config_ep_by_speed + config_group_init_type_name + console_lock + console_printk + console_suspend_enabled + console_unlock + __const_udelay + consume_skb + contig_page_data + _copy_from_iter + __copy_overflow + __cpu_active_mask + cpu_all_bits + cpu_bit_bitmap + cpu_busy_with_softirqs + __cpu_dying_mask + cpufreq_boost_enabled + cpufreq_cpu_get + cpufreq_cpu_get_raw + cpufreq_cpu_put + cpufreq_disable_fast_switch + cpufreq_driver_fast_switch + __cpufreq_driver_target + cpufreq_enable_boost_support + cpufreq_enable_fast_switch + cpufreq_freq_attr_scaling_available_freqs + cpufreq_generic_frequency_table_verify + cpufreq_generic_suspend + cpufreq_get_policy + cpufreq_policy_transition_delay_us + cpufreq_register_driver + cpufreq_register_governor + cpufreq_register_notifier + cpufreq_table_index_unsorted + cpufreq_unregister_driver + __cpuhp_remove_state + __cpuhp_setup_state + __cpuhp_setup_state_cpuslocked + __cpuhp_state_add_instance + __cpuhp_state_remove_instance + cpuidle_governor_latency_req + cpuidle_pause_and_lock + cpuidle_register_governor + cpuidle_resume_and_unlock + cpu_irqtime + cpu_latency_qos_add_request + cpu_latency_qos_remove_request + cpumask_any_and_distribute + cpumask_any_distribute + cpu_number + __cpu_online_mask + cpu_pm_register_notifier + cpu_pm_unregister_notifier + __cpu_possible_mask + cpupri_find_fitness + cpu_scale + cpus_read_lock + cpus_read_unlock + cpu_subsys + cpu_topology + crc32_be + crc32_le + crypto_aead_decrypt + crypto_aead_encrypt + crypto_aead_setauthsize + crypto_aead_setkey + crypto_alloc_aead + crypto_alloc_akcipher + crypto_alloc_base + crypto_alloc_shash + crypto_alloc_skcipher + crypto_comp_compress + crypto_comp_decompress + crypto_destroy_tfm + crypto_has_alg + __crypto_memneq + crypto_register_alg + crypto_register_scomp + crypto_req_done + crypto_shash_digest + crypto_shash_final + crypto_shash_finup + crypto_shash_setkey + crypto_shash_update + crypto_skcipher_decrypt + crypto_skcipher_encrypt + crypto_skcipher_setkey + crypto_unregister_alg + crypto_unregister_scomp + __crypto_xor + css_next_child + csum_partial + _ctype + dapm_regulator_event + deactivate_locked_super + deactivate_task + debugfs_attr_read + debugfs_attr_write + debugfs_create_blob + debugfs_create_bool + debugfs_create_dir + debugfs_create_file + debugfs_create_symlink + debugfs_create_u32 + debugfs_create_u64 + debugfs_create_x32 + debugfs_file_get + debugfs_file_put + debugfs_lookup + debugfs_remove + debugfs_rename + dec_zone_page_state + default_llseek + deferred_free + delayed_work_timer_fn + del_gendisk + destroy_workqueue + dev_addr_mod + _dev_alert + dev_alloc_name + dev_change_flags + __dev_change_net_namespace + dev_close + _dev_crit + dev_driver_string + _dev_err + dev_err_probe + dev_fetch_sw_netstats + devfreq_add_device + devfreq_add_governor + devfreq_get_devfreq_by_node + devfreq_get_freq_range + devfreq_monitor_resume + devfreq_monitor_start + devfreq_monitor_stop + devfreq_monitor_suspend + devfreq_recommended_opp + devfreq_remove_device + devfreq_remove_governor + devfreq_resume_device + devfreq_suspend_device + devfreq_update_interval + __dev_fwnode + __dev_get_by_index + dev_get_by_index + dev_get_by_name + dev_get_regmap + dev_get_stats + device_add + device_add_disk + device_add_groups + device_attach + device_create + device_create_file + device_create_with_groups + device_del + device_destroy + device_for_each_child + device_get_child_node_count + device_get_match_data + device_get_named_child_node + device_get_next_child_node + device_initialize + device_link_add + device_link_remove + device_match_any + device_match_fwnode + device_match_name + device_property_present + device_property_read_string + device_property_read_u32_array + device_property_read_u64_array + device_register + device_release_driver + device_remove_file + device_remove_file_self + device_remove_groups + device_rename + device_set_of_node_from_dev + device_set_wakeup_capable + device_unregister + device_wakeup_disable + device_wakeup_enable + _dev_info + dev_kfree_skb_any_reason + devlink_alloc_ns + devlink_flash_update_status_notify + devlink_free + devlink_health_reporter_state_update + devlink_priv + devlink_region_create + devlink_region_destroy + devlink_register + devlink_unregister + __devm_add_action + devm_backlight_device_register + devm_bitmap_zalloc + devm_blk_crypto_profile_init + devm_clk_bulk_get_all + devm_clk_bulk_get_optional + devm_clk_get + devm_clk_get_optional + devm_clk_hw_register_fixed_factor + devm_clk_put + dev_mc_sync_multiple + dev_mc_unsync + devm_devfreq_add_device + devm_devfreq_remove_device + __devm_drm_dev_alloc + devm_extcon_dev_allocate + devm_extcon_dev_register + devm_free_irq + devm_fwnode_gpiod_get_index + devm_fwnode_iio_channel_get_by_name + devm_gen_pool_create + devm_gpiochip_add_data_with_key + devm_gpiod_get_optional + devm_gpio_request + devm_gpio_request_one + devm_hwspin_lock_register + devm_i2c_new_dummy_device + devm_iio_channel_get + devm_iio_device_alloc + __devm_iio_device_register + devm_input_allocate_device + devm_ioremap + devm_ioremap_resource + devm_iounmap + devm_kasprintf + devm_kfree + devm_kmalloc + devm_kstrdup + devm_led_classdev_register_ext + devm_mbox_controller_register + devm_mfd_add_devices + __devm_of_phy_provider_register + devm_of_platform_populate + devm_phy_create + devm_phy_get + devm_pinctrl_get + devm_pinctrl_put + devm_pinctrl_register + devm_pinctrl_register_and_init + devm_platform_get_and_ioremap_resource + devm_platform_ioremap_resource + devm_platform_ioremap_resource_byname + devm_power_supply_register + devm_pwm_get + devm_regmap_add_irq_chip + devm_regmap_field_alloc + __devm_regmap_init + __devm_regmap_init_i2c + __devm_regmap_init_spmi_ext + devm_regulator_bulk_get + devm_regulator_get + devm_regulator_put + devm_regulator_register + devm_request_any_context_irq + devm_request_threaded_irq + __devm_reset_control_get + devm_reset_controller_register + devm_rproc_add + devm_rproc_alloc + devm_rtc_allocate_device + __devm_rtc_register_device + devm_snd_soc_register_card + devm_snd_soc_register_component + devm_thermal_of_cooling_device_register + devm_thermal_of_zone_register + devm_thermal_of_zone_unregister + _dev_notice + dev_open + dev_pm_clear_wake_irq + dev_pm_opp_add_dynamic + dev_pm_opp_clear_config + dev_pm_opp_disable + dev_pm_opp_enable + dev_pm_opp_find_freq_ceil + dev_pm_opp_find_freq_floor + dev_pm_opp_free_cpufreq_table + dev_pm_opp_get_max_transition_latency + dev_pm_opp_get_of_node + dev_pm_opp_get_opp_count + dev_pm_opp_get_suspend_opp_freq + dev_pm_opp_get_voltage + dev_pm_opp_init_cpufreq_table + dev_pm_opp_of_add_table + dev_pm_opp_of_cpumask_add_table + dev_pm_opp_of_cpumask_remove_table + dev_pm_opp_of_get_opp_desc_node + dev_pm_opp_of_get_sharing_cpus + dev_pm_opp_of_register_em + dev_pm_opp_of_remove_table + dev_pm_opp_put + dev_pm_opp_remove + dev_pm_opp_set_config + dev_pm_qos_add_request + dev_pm_qos_read_value + dev_pm_qos_remove_request + dev_pm_qos_update_request + dev_pm_set_wake_irq + _dev_printk + __dev_queue_xmit + devres_add + __devres_alloc_node + devres_free + dev_set_mtu + dev_set_name + dev_set_threaded + dev_uc_sync_multiple + dev_uc_unsync + _dev_warn + disable_irq + disable_irq_nosync + divider_round_rate_parent + dma_alloc_attrs + dma_async_device_register + dma_async_device_unregister + dma_async_tx_descriptor_init + dma_buf_attach + dma_buf_begin_cpu_access + dma_buf_begin_cpu_access_partial + dma_buf_detach + dma_buf_end_cpu_access + dma_buf_end_cpu_access_partial + dma_buf_export + dma_buf_fd + dma_buf_get + dma_buf_map_attachment + dma_buf_map_attachment_unlocked + dma_buf_mmap + dma_buf_put + dma_buf_unmap_attachment + dma_buf_unmap_attachment_unlocked + dma_buf_vmap + dma_buf_vmap_unlocked + dma_buf_vunmap + dma_buf_vunmap_unlocked + dma_contiguous_default_area + dma_fence_add_callback + dma_fence_context_alloc + dma_fence_default_wait + dma_fence_get_status + dma_fence_init + dma_fence_release + dma_fence_remove_callback + dma_fence_signal + dma_fence_signal_locked + dma_fence_signal_timestamp + dma_fence_wait_timeout + dma_free_attrs + dma_get_any_slave_channel + dma_get_sgtable_attrs + dma_get_slave_caps + dma_heap_add + dma_heap_buffer_alloc + dma_heap_buffer_free + dma_heap_find + dma_heap_get_dev + dma_heap_get_drvdata + dma_heap_get_name + dma_heap_put + dmam_alloc_attrs + dma_map_page_attrs + dma_map_sg_attrs + dma_map_sgtable + dmam_free_coherent + dma_mmap_attrs + dma_pool_alloc + dma_pool_create + dma_pool_destroy + dma_pool_free + dma_release_channel + dma_request_chan + __dma_request_channel + dma_set_coherent_mask + dma_set_mask + dma_sync_sg_for_cpu + dma_sync_sg_for_device + dma_sync_single_for_cpu + dma_sync_single_for_device + dma_unmap_page_attrs + dma_unmap_sg_attrs + do_SAK + do_trace_netlink_extack + double_rq_lock + down + downgrade_write + down_interruptible + down_killable + down_read + down_read_killable + down_read_trylock + down_timeout + down_trylock + down_write + down_write_killable + d_path + driver_find_device + driver_register + driver_unregister + drm_add_edid_modes + drm_atomic_add_affected_planes + drm_atomic_commit + drm_atomic_get_connector_state + drm_atomic_get_crtc_state + drm_atomic_get_new_private_obj_state + drm_atomic_get_old_private_obj_state + drm_atomic_get_private_obj_state + drm_atomic_helper_check + drm_atomic_helper_cleanup_planes + drm_atomic_helper_commit_cleanup_done + drm_atomic_helper_commit_hw_done + drm_atomic_helper_commit_modeset_disables + drm_atomic_helper_commit_modeset_enables + drm_atomic_helper_commit_planes + drm_atomic_helper_commit_tail + __drm_atomic_helper_connector_destroy_state + __drm_atomic_helper_connector_duplicate_state + __drm_atomic_helper_connector_reset + __drm_atomic_helper_crtc_destroy_state + __drm_atomic_helper_crtc_duplicate_state + __drm_atomic_helper_crtc_reset + drm_atomic_helper_disable_plane + drm_atomic_helper_duplicate_state + drm_atomic_helper_page_flip + __drm_atomic_helper_plane_destroy_state + __drm_atomic_helper_plane_duplicate_state + __drm_atomic_helper_plane_reset + drm_atomic_helper_prepare_planes + __drm_atomic_helper_private_obj_duplicate_state + drm_atomic_helper_set_config + drm_atomic_helper_shutdown + drm_atomic_helper_swap_state + drm_atomic_helper_update_plane + drm_atomic_helper_wait_for_dependencies + drm_atomic_private_obj_fini + drm_atomic_private_obj_init + drm_atomic_set_crtc_for_connector + drm_atomic_set_crtc_for_plane + drm_atomic_set_fb_for_plane + drm_atomic_set_mode_for_crtc + drm_atomic_state_alloc + __drm_atomic_state_free + drm_compat_ioctl + drm_connector_attach_encoder + drm_connector_cleanup + drm_connector_init + drm_connector_list_iter_begin + drm_connector_list_iter_end + drm_connector_list_iter_next + drm_connector_register + drm_connector_unregister + drm_connector_update_edid_property + drm_crtc_add_crc_entry + drm_crtc_arm_vblank_event + drm_crtc_cleanup + __drm_crtc_commit_free + drm_crtc_commit_wait + drm_crtc_handle_vblank + drm_crtc_init_with_planes + drm_crtc_send_vblank_event + drm_crtc_vblank_get + drm_crtc_vblank_off + drm_crtc_vblank_on + drm_crtc_wait_one_vblank + ___drm_dbg + __drm_debug + __drm_dev_dbg + drm_dev_printk + drm_dev_put + drm_dev_register + drm_dev_unregister + drm_display_mode_from_cea_vic + drm_edid_dup + drm_edid_duplicate + drm_edid_free + drm_edid_get_monitor_name + drm_edid_raw + drm_edid_read_ddc + drm_encoder_cleanup + drm_encoder_init + __drm_err + drm_event_reserve_init_locked + drm_gem_fb_create_handle + drm_gem_fb_create_with_funcs + drm_gem_fb_destroy + drm_gem_handle_create + drm_gem_mmap + drm_gem_object_free + drm_gem_object_release + drm_gem_prime_fd_to_handle + drm_gem_prime_handle_to_fd + drm_gem_private_object_init + drm_gem_vm_close + drm_gem_vm_open + drm_get_edid + drm_helper_probe_single_connector_modes + drm_ioctl + drm_kms_helper_hotplug_event + drm_kms_helper_poll_disable + drm_kms_helper_poll_enable + drm_kms_helper_poll_fini + drm_kms_helper_poll_init + drmm_mode_config_init + drm_mode_config_cleanup + drm_mode_config_reset + drm_mode_duplicate + drm_mode_object_find + drm_mode_object_put + drm_mode_probed_add + drm_modeset_acquire_fini + drm_modeset_acquire_init + drm_modeset_backoff + drm_modeset_drop_locks + drm_modeset_lock + drm_modeset_lock_all_ctx + drm_modeset_lock_single_interruptible + drm_modeset_unlock + drm_mode_vrefresh + drm_object_attach_property + drm_object_property_set_value + drm_open + drm_panel_add + drm_panel_init + drm_panel_remove + drm_plane_cleanup + drm_plane_create_alpha_property + drm_plane_create_blend_mode_property + drm_plane_create_rotation_property + drm_plane_create_zpos_property + drm_poll + drm_prime_gem_destroy + drm_printf + __drm_printfn_debug + drm_property_blob_get + drm_property_blob_put + drm_property_create + drm_property_create_bitmask + drm_property_create_blob + drm_property_create_bool + drm_property_create_enum + drm_property_create_range + drm_property_create_signed_range + drm_property_lookup_blob + drm_property_replace_blob + drm_read + drm_release + drm_send_event_locked + drm_universal_plane_init + drm_vblank_init + drm_writeback_connector_init + drm_writeback_queue_job + drm_writeback_signal_completion + drop_reasons_register_subsys + drop_reasons_unregister_subsys + dump_page + dump_stack + dw_pcie_find_capability + dw_pcie_find_ext_capability + dw_pcie_host_deinit + dw_pcie_host_init + dw_pcie_link_up + dw_pcie_own_conf_map_bus + dw_pcie_read_dbi + dw_pcie_setup_rc + dw_pcie_wait_for_link + dw_pcie_write_dbi + __dynamic_pr_debug + elevator_alloc + elv_bio_merge_ok + elv_rb_add + elv_rb_del + elv_rb_find + elv_rb_former_request + elv_rb_latter_request + elv_register + elv_rqhash_add + elv_rqhash_del + elv_unregister + emergency_restart + enable_irq + ether_setup + eth_mac_addr + __ethtool_get_link_ksettings + ethtool_op_get_link + ethtool_op_get_ts_info + eth_type_trans + eventfd_ctx_do_read + eventfd_ctx_fdget + eventfd_ctx_fileget + eventfd_ctx_put + eventfd_ctx_remove_wait_queue + eventfd_signal + extcon_set_property + extcon_set_property_capability + extcon_set_state + extcon_set_state_sync + fasync_helper + __fdget + fd_install + fget + filp_close + filp_open_block + _find_first_bit + _find_first_zero_bit + find_get_pid + _find_next_bit + _find_next_zero_bit + find_task_by_vpid + find_vma_intersection + find_vpid + finish_wait + firmware_request_nowarn + fixed_size_llseek + flush_dcache_page + flush_delayed_work + flush_signals + flush_work + __flush_workqueue + folio_add_lru + __folio_batch_release + __folio_lock + __folio_put + folio_unlock + folio_wait_bit + for_each_kernel_tracepoint + fortify_panic + fpsimd_context_busy + fput + free_io_pgtable_ops + free_irq + free_netdev + __free_pages + free_pages + free_pages_exact + free_percpu + freezer_active + freezer_cgrp_subsys + freezing_slow_path + freq_qos_add_notifier + freq_qos_add_request + freq_qos_remove_request + freq_qos_update_request + fs_bio_set + fwnode_get_name + fwnode_get_next_child_node + fwnode_irq_get + fwnode_property_present + fwnode_property_read_u32_array + gcd + generic_access_phys + generic_device_group + generic_file_llseek + generic_handle_domain_irq + generic_handle_irq + generic_shutdown_super + genlmsg_multicast_allns + genlmsg_put + genl_register_family + genl_unregister_family + gen_pool_add_owner + gen_pool_alloc_algo_owner + gen_pool_avail + gen_pool_best_fit + gen_pool_create + gen_pool_destroy + gen_pool_dma_alloc + gen_pool_free_owner + gen_pool_has_addr + gen_pool_set_algo + gen_pool_size + gen_pool_virt_to_phys + get_cpu_device + get_cpu_idle_time + get_device + __get_free_pages + get_governor_parent_kobj + gether_cleanup + gether_connect + gether_get_dev_addr + gether_get_host_addr + gether_get_host_addr_cdc + gether_get_host_addr_u8 + gether_get_ifname + gether_get_qmult + gether_register_netdev + gether_set_dev_addr + gether_set_gadget + gether_set_host_addr + gether_set_ifname + gether_set_qmult + gether_setup_name_default + get_net_ns_by_fd + get_net_ns_by_pid + get_pfnblock_flags_mask + get_pid_task + get_random_bytes + get_random_u16 + get_slabinfo + __get_task_comm + get_unused_fd_flags + get_user_pages + gov_attr_set_init + gov_attr_set_put + governor_sysfs_ops + gpiochip_add_pin_range + gpiochip_generic_config + gpiochip_generic_free + gpiochip_generic_request + gpiochip_get_data + gpiochip_line_is_valid + gpiochip_lock_as_irq + gpiochip_unlock_as_irq + gpiod_direction_input + gpiod_direction_output + gpiod_direction_output_raw + gpiod_get_optional + gpiod_get_raw_value + gpiod_get_raw_value_cansleep + gpiod_put + gpiod_set_raw_value + gpiod_set_raw_value_cansleep + gpiod_set_value_cansleep + gpiod_to_irq + gpio_free + gpio_free_array + gpio_request + gpio_request_array + gpio_request_one + gpio_to_desc + handle_bad_irq + handle_edge_irq + handle_level_irq + handle_nested_irq + handle_sysrq + hci_alloc_dev_priv + hci_free_dev + hci_recv_frame + hci_register_dev + hci_unregister_dev + hex_dump_to_buffer + housekeeping_cpumask + housekeeping_overridden + housekeeping_test_cpu + hrtimer_active + hrtimer_cancel + hrtimer_forward + __hrtimer_get_remaining + hrtimer_init + hrtimer_start_range_ns + hrtimer_try_to_cancel + __hw_addr_init + __hw_addr_sync + __hw_addr_unsync + hwrng_register + hwrng_unregister + hwspin_lock_free + hwspin_lock_get_id + hwspin_lock_request_specific + __hwspin_lock_timeout + hwspin_lock_unregister + __hwspin_trylock + __hwspin_unlock + i2c_adapter_type + i2c_add_adapter + i2c_add_numbered_adapter + i2c_bus_type + i2c_client_get_device_id + i2c_del_adapter + i2c_del_driver + i2c_find_device_by_fwnode + i2c_for_each_dev + i2c_generic_scl_recovery + i2c_get_adapter + i2c_match_id + i2c_new_dummy_device + i2c_put_adapter + i2c_recover_bus + i2c_register_driver + i2c_smbus_read_byte_data + i2c_smbus_read_i2c_block_data + i2c_smbus_read_word_data + i2c_smbus_write_byte_data + i2c_smbus_write_i2c_block_data + i2c_smbus_write_word_data + i2c_transfer + i2c_transfer_buffer_flags + i2c_verify_client + i3c_generic_ibi_alloc_pool + i3c_generic_ibi_free_pool + i3c_generic_ibi_get_free_slot + i3c_generic_ibi_recycle_slot + i3c_master_add_i3c_dev_locked + i3c_master_disec_locked + i3c_master_enec_locked + i3c_master_get_free_addr + i3c_master_queue_ibi + i3c_master_register + i3c_master_set_info + i3c_master_unregister + ida_alloc_range + ida_destroy + ida_free + idr_alloc + idr_destroy + idr_find + idr_for_each + idr_get_next + idr_remove + iio_read_channel_processed + iio_read_channel_raw + inc_zone_page_state + in_egroup_p + inet_csk_get_port + __inet_lookup_established + init_dummy_netdev + init_net + __init_rwsem + init_srcu_struct + __init_swait_queue_head + init_task + init_timer_key + init_uts_ns + init_wait_entry + __init_waitqueue_head + input_allocate_device + input_close_device + input_event + input_ff_create + input_ff_destroy + input_free_device + input_mt_init_slots + input_mt_report_slot_state + input_open_device + input_register_device + input_register_handle + input_register_handler + input_set_abs_params + input_set_capability + input_unregister_device + input_unregister_handle + input_unregister_handler + insert_resource + invalidate_mapping_pages + iomem_resource + iommu_alloc_resv_region + iommu_device_register + iommu_device_sysfs_add + iommu_device_sysfs_remove + iommu_device_unregister + iommu_dma_get_resv_regions + iommu_fwspec_add_ids + iommu_fwspec_free + iommu_get_domain_for_dev + iommu_group_get + iommu_iova_to_phys + iommu_map + iommu_map_sg + iommu_unmap + ioremap_prot + io_schedule_timeout + iounmap + iov_iter_bvec + iov_iter_extract_pages + iov_iter_get_pages2 + iov_iter_npages + iov_iter_revert + iput + __ipv6_addr_type + ipv6_ext_hdr + ipv6_find_hdr + ipv6_skip_exthdr + __irq_apply_affinity_hint + irq_chip_set_wake_parent + irq_dispose_mapping + __irq_domain_add + irq_domain_free_irqs_common + irq_domain_remove + irq_domain_set_info + irq_domain_xlate_onetwocell + irq_do_set_affinity + irq_get_irq_data + irq_modify_status + irq_of_parse_and_map + __irq_resolve_mapping + irq_set_affinity + irq_set_chained_handler_and_data + irq_set_chip + irq_set_chip_data + irq_set_irq_type + irq_set_irq_wake + irq_set_parent + irq_to_desc + irq_work_queue + irq_work_queue_on + irq_work_sync + is_dma_buf_file + is_vmalloc_addr + iterate_dir + jiffies + jiffies_to_msecs + jiffies_to_usecs + kasan_flag_enabled + kasprintf + kernel_kobj + kernel_neon_begin + kernel_neon_end + kernel_param_lock + kernel_param_unlock + kernel_sigaction + kernfs_find_and_get_ns + kernfs_path_from_node + key_put + keyring_alloc + __kfifo_alloc + __kfifo_free + __kfifo_in + __kfifo_init + __kfifo_out + __kfifo_out_peek + __kfifo_to_user + kfree + kfree_const + kfree_sensitive + kfree_skb_list_reason + kfree_skb_reason + kill_fasync + kill_pid + kimage_vaddr + kimage_voffset + __kmalloc + kmalloc_caches + kmalloc_large + kmalloc_node_trace + kmalloc_trace + kmem_cache_alloc + kmem_cache_create + kmem_cache_create_usercopy + kmem_cache_destroy + kmem_cache_free + kmemdup + kmsg_dump_get_buffer + kmsg_dump_register + kmsg_dump_rewind + kmsg_dump_unregister + kobject_add + kobject_create_and_add + kobject_del + kobject_get + kobject_init + kobject_init_and_add + kobject_put + kobject_set_name + kobject_uevent + kobject_uevent_env + krealloc + kset_create_and_add + kset_unregister + ksoftirqd + kstrdup + kstrdup_const + kstrndup + kstrtobool + kstrtobool_from_user + kstrtoint + kstrtoint_from_user + kstrtoll + kstrtou16 + kstrtou8 + kstrtouint + kstrtouint_from_user + kstrtoull + kthread_bind + kthread_bind_mask + kthread_cancel_work_sync + kthread_create_on_cpu + kthread_create_on_node + kthread_create_worker + kthread_delayed_work_timer_fn + kthread_destroy_worker + kthread_flush_work + kthread_flush_worker + __kthread_init_worker + kthread_park + kthread_parkme + kthread_queue_delayed_work + kthread_queue_work + kthread_should_park + kthread_should_stop + kthread_stop + kthread_unpark + kthread_worker_fn + ktime_get + ktime_get_coarse_real_ts64 + ktime_get_coarse_with_offset + ktime_get_mono_fast_ns + ktime_get_raw + ktime_get_raw_ts64 + ktime_get_real_seconds + ktime_get_real_ts64 + ktime_get_seconds + ktime_get_ts64 + ktime_get_with_offset + kvfree + kvfree_call_rcu + kvmalloc_node + __list_add_valid_or_report + __list_del_entry_valid_or_report + list_sort + __local_bh_enable_ip + lockref_get + lock_sock_nested + logfc + log_post_read_mmio + log_post_write_mmio + log_read_mmio + log_write_mmio + lookup_bdev + lookup_user_key + mas_find + match_string + mbox_chan_received_data + mbox_chan_txdone + mbox_free_channel + mbox_request_channel_byname + mbox_send_message + media_device_init + __media_device_register + media_device_unregister + memblock_free + mem_cgroup_move_account + mem_cgroup_update_lru_size + memcg_sockets_enabled_key + memchr + memchr_inv + memcmp + memcpy + __memcpy_fromio + __memcpy_toio + memdup_user + memmove + memory_cgrp_subsys + memory_cgrp_subsys_enabled_key + memory_cgrp_subsys_on_dfl_key + memparse + mempool_alloc + mempool_alloc_slab + mempool_create + mempool_destroy + mempool_free + mempool_free_slab + memremap + mem_section + memset + memset64 + __memset_io + memstart_addr + memunmap + mfd_add_devices + mfd_remove_devices + mfd_remove_devices_late + migrate_swap + __migrate_task + mipi_dsi_dcs_read + mipi_dsi_dcs_set_display_brightness + mipi_dsi_dcs_set_display_off + mipi_dsi_host_register + mipi_dsi_host_unregister + misc_deregister + misc_register + __mmap_lock_do_trace_acquire_returned + __mmap_lock_do_trace_released + __mmap_lock_do_trace_start_locking + __mmdrop + mod_delayed_work_on + __mod_lruvec_state + mod_node_page_state + mod_timer + __module_get + module_layout + module_put + __mod_zone_page_state + __msecs_to_jiffies + msi_domain_first_desc + msi_lock_descs + msi_next_desc + msi_unlock_descs + msleep + msleep_interruptible + mtree_load + __mutex_init + mutex_is_locked + mutex_lock + mutex_lock_interruptible + mutex_lock_killable + mutex_trylock + mutex_unlock + napi_complete_done + napi_disable + napi_enable + napi_gro_flush + napi_gro_receive + __napi_schedule + __napi_schedule_irqoff + napi_schedule_prep + __netdev_alloc_frag_align + __netdev_alloc_skb + netdev_change_features + netdev_err + netdev_increment_features + netdev_info + netdev_lower_state_changed + netdev_rx_handler_register + netdev_rx_handler_unregister + netdev_set_default_ethtool_ops + netif_carrier_off + netif_carrier_on + netif_device_attach + netif_device_detach + netif_napi_add_weight + __netif_napi_del + netif_receive_skb + netif_receive_skb_list + netif_rx + netif_tx_stop_all_queues + netif_tx_wake_queue + netlink_broadcast + __netlink_kernel_create + netlink_kernel_release + netlink_register_notifier + netlink_unicast + netlink_unregister_notifier + net_ns_type_operations + net_ratelimit + nf_register_net_hooks + nf_unregister_net_hooks + nla_find + nla_memcpy + __nla_parse + nla_put + nla_put_64bit + nla_put_nohdr + nla_reserve + nla_strscpy + __nla_validate + __nlmsg_put + nonseekable_open + noop_llseek + nr_cpu_ids + nr_irqs + nr_swap_pages + nsec_to_clock_t + ns_to_timespec64 + n_tty_ioctl_helper + __num_online_cpus + nvmem_register + nvmem_unregister + of_address_to_resource + of_alias_get_id + of_clk_add_hw_provider + of_clk_del_provider + of_clk_get + of_clk_get_by_name + of_clk_hw_onecell_get + of_count_phandle_with_args + of_cpu_device_node_get + of_cpu_node_to_id + of_css + of_device_get_match_data + of_device_is_available + of_device_is_compatible + of_dma_configure_id + of_dma_controller_free + of_dma_controller_register + of_dma_is_coherent + of_drm_find_panel + of_find_compatible_node + of_find_device_by_node + of_find_matching_node_and_match + of_find_node_by_name + of_find_node_opts_by_path + of_find_property + of_find_gpio + of_fwnode_ops + of_get_child_by_name + of_get_compatible_child + of_get_cpu_node + of_get_named_gpio + of_get_next_available_child + of_get_next_child + of_get_next_cpu_node + of_get_pci_domain_nr + of_get_property + of_get_regulator_init_data + of_iomap + of_irq_get + of_irq_get_byname + of_machine_compatible_match + of_match_device + of_match_node + of_n_addr_cells + of_node_name_prefix + of_n_size_cells + __of_parse_phandle_with_args + of_phandle_iterator_init + of_phandle_iterator_next + of_platform_depopulate + of_platform_populate + of_property_count_elems_of_size + of_property_match_string + of_property_read_string + of_property_read_string_helper + of_property_read_u32_index + of_property_read_u64 + of_property_read_u64_index + of_property_read_variable_u16_array + of_property_read_variable_u32_array + of_property_read_variable_u64_array + of_property_read_variable_u8_array + of_prop_next_string + of_prop_next_u32 + of_reserved_mem_device_init_by_idx + of_reserved_mem_device_release + of_reserved_mem_lookup + __of_reset_control_get + of_root + on_each_cpu_cond_mask + oops_in_progress + osq_lock + osq_unlock + page_frag_free + page_pinner_inited + __page_pinner_put_page + page_pool_alloc_pages + page_pool_create + page_pool_destroy + page_pool_put_defragged_page + panic + panic_notifier_list + param_array_ops + param_get_int + param_get_uint + param_ops_bool + param_ops_byte + param_ops_charp + param_ops_int + param_ops_short + param_ops_string + param_ops_uint + param_ops_ullong + param_ops_ulong + param_ops_ushort + param_set_uint + param_set_uint_minmax + passthru_features_check + pci_alloc_irq_vectors + pci_ats_supported + pci_bus_type + pci_choose_state + pci_clear_master + pci_device_group + pci_device_is_present + pci_disable_ats + pci_disable_device + pcie_capability_clear_and_set_word_locked + pcie_capability_clear_and_set_word_unlocked + pcie_capability_read_dword + pcie_capability_read_word + pcie_capability_write_word + pcie_link_speed + pci_enable_ats + pci_enable_device + pci_find_bus + pci_find_ext_capability + pci_free_irq + pci_free_irq_vectors + pci_get_device + pci_iomap + pci_iounmap + pci_irq_vector + pci_load_and_free_saved_state + pci_load_saved_state + pcim_enable_device + pcim_iomap_regions + pcim_iomap_table + pcim_iounmap_regions + pci_msi_mask_irq + pci_msi_unmask_irq + pci_read_config_dword + pci_read_config_word + __pci_register_driver + pci_request_irq + pci_restore_state + pci_save_state + pci_set_master + pci_set_power_state + pci_speed_string + pci_store_saved_state + pci_unregister_driver + pci_walk_bus + pci_write_config_dword + pci_write_config_word + percpu_counter_add_batch + percpu_counter_batch + __per_cpu_offset + per_cpu_ptr_to_phys + perf_event_create_kernel_counter + perf_event_disable + perf_event_enable + perf_event_release_kernel + perf_event_update_userpage + perf_pmu_migrate_context + perf_pmu_register + perf_pmu_unregister + perf_trace_buf_alloc + perf_trace_run_bpf_submit + pfn_is_map_memory + phy_exit + phy_init + phy_power_off + phy_power_on + phy_set_mode_ext + pick_highest_pushable_task + pick_migrate_task + pid_task + pinconf_generic_dt_node_to_map + pinctrl_dev_get_drvdata + pinctrl_enable + pinctrl_find_gpio_range_from_pin + pinctrl_force_default + pinctrl_force_sleep + pinctrl_get + pinctrl_lookup_state + pinctrl_put + pinctrl_register_mappings + pinctrl_select_state + pinctrl_unregister_mappings + pinctrl_utils_free_map + pin_user_pages + pin_user_pages_fast + pin_user_pages_remote + platform_device_add + platform_device_alloc + platform_device_del + platform_device_put + platform_device_register_full + platform_device_unregister + __platform_driver_probe + __platform_driver_register + platform_driver_unregister + platform_get_irq + platform_get_irq_byname + platform_get_irq_byname_optional + platform_get_irq_optional + platform_get_resource + platform_get_resource_byname + platform_irq_count + platform_msi_domain_alloc_irqs + platform_msi_domain_free_irqs + __platform_register_drivers + platform_unregister_drivers + __pm_relax + pm_relax + pm_runtime_allow + __pm_runtime_disable + pm_runtime_enable + pm_runtime_forbid + __pm_runtime_idle + pm_runtime_no_callbacks + __pm_runtime_resume + pm_runtime_set_autosuspend_delay + __pm_runtime_set_status + __pm_runtime_suspend + __pm_runtime_use_autosuspend + pm_schedule_suspend + __pm_stay_awake + pm_stay_awake + pm_wakeup_dev_event + pm_wakeup_ws_event + policy_has_boost_freq + power_supply_changed + power_supply_get_by_name + power_supply_get_drvdata + power_supply_get_property + power_supply_is_system_supplied + power_supply_put + power_supply_reg_notifier + power_supply_set_property + power_supply_unregister + power_supply_unreg_notifier + preempt_schedule + preempt_schedule_notrace + prepare_to_wait + prepare_to_wait_event + print_hex_dump + _printk + _printk_deferred + probe_irq_off + probe_irq_on + proc_create + proc_create_data + proc_create_net_single + proc_create_seq_private + proc_create_single_data + proc_dointvec + proc_dointvec_minmax + proc_do_large_bitmap + proc_dostring + proc_douintvec_minmax + proc_mkdir + proc_mkdir_data + proc_remove + proc_set_user + pskb_expand_head + __pskb_pull_tail + ___pskb_trim + put_cmsg + __put_cred + put_device + put_disk + __put_net + put_pid + __put_task_struct + put_unused_fd + pwm_apply_state + pwmchip_add + pwmchip_remove + pwm_get_chip_data + pwm_request_from_chip + queue_delayed_work_on + queue_work_on + radix_tree_delete + radix_tree_gang_lookup + radix_tree_insert + radix_tree_lookup + radix_tree_next_chunk + ___ratelimit + raw_notifier_call_chain + raw_notifier_chain_register + raw_notifier_chain_unregister + _raw_read_lock + _raw_read_lock_bh + _raw_read_lock_irqsave + _raw_read_unlock + _raw_read_unlock_bh + _raw_read_unlock_irqrestore + _raw_spin_lock + _raw_spin_lock_bh + _raw_spin_lock_irq + _raw_spin_lock_irqsave + raw_spin_rq_lock_nested + raw_spin_rq_unlock + _raw_spin_trylock + _raw_spin_trylock_bh + _raw_spin_unlock + _raw_spin_unlock_bh + _raw_spin_unlock_irq + _raw_spin_unlock_irqrestore + _raw_write_lock + _raw_write_lock_bh + _raw_write_lock_irqsave + _raw_write_unlock + _raw_write_unlock_bh + _raw_write_unlock_irqrestore + rb_erase + rb_first + rb_first_postorder + rb_insert_color + rb_next + rb_next_postorder + rb_prev + rb_replace_node + rcu_barrier + __rcu_read_lock + __rcu_read_unlock + rdev_get_drvdata + rdev_get_regmap + read_cache_page + rebuild_sched_domains + refcount_warn_saturate + __refrigerator + regcache_cache_only + regcache_drop_region + regcache_mark_dirty + regcache_sync + regcache_sync_region + __register_blkdev + __register_chrdev + register_chrdev_region + register_inet6addr_notifier + register_inetaddr_notifier + register_kprobe + register_memory_notifier + register_netdev + register_netdevice + register_netdevice_notifier + register_oom_notifier + register_pernet_device + register_pernet_subsys + register_pm_notifier + register_reboot_notifier + register_restart_handler + __register_rpmsg_driver + register_shrinker + register_syscore_ops + register_sysctl_sz + register_sys_off_handler + register_virtio_device + register_virtio_driver + register_vmap_purge_notifier + regmap_add_irq_chip + regmap_async_complete + regmap_bulk_read + regmap_bulk_write + regmap_del_irq_chip + regmap_field_read + regmap_field_update_bits_base + regmap_get_val_bytes + regmap_irq_get_virq + regmap_multi_reg_write + regmap_multi_reg_write_bypassed + regmap_raw_read + regmap_raw_write + regmap_raw_write_async + regmap_read + regmap_register_patch + regmap_update_bits_base + regmap_write + regulator_allow_bypass + regulator_bulk_disable + regulator_bulk_enable + regulator_count_voltages + regulator_disable + regulator_disable_regmap + regulator_enable + regulator_enable_regmap + regulator_get + regulator_get_bypass_regmap + regulator_get_drvdata + regulator_get_optional + regulator_get_voltage + regulator_get_voltage_sel_regmap + regulator_is_enabled + regulator_is_enabled_regmap + regulator_list_voltage_linear + regulator_list_voltage_linear_range + regulator_map_voltage_linear + regulator_map_voltage_linear_range + regulator_put + regulator_register + regulator_set_bypass_regmap + regulator_set_load + regulator_set_voltage + regulator_set_voltage_sel_regmap + regulator_unregister + release_firmware + __release_region + release_sock + remap_pfn_range + remap_vmalloc_range + remove_cpu + remove_proc_entry + remove_proc_subtree + remove_resource + remove_wait_queue + request_firmware + request_firmware_direct + request_firmware_nowait + __request_module + __request_region + request_threaded_irq + resched_curr + reset_control_assert + reset_control_deassert + return_address + rfkill_alloc + rfkill_blocked + rfkill_destroy + rfkill_register + rfkill_resume_polling + rfkill_set_hw_state_reason + rfkill_unregister + rhashtable_free_and_destroy + rhashtable_init + rhashtable_insert_slow + rhltable_init + __rht_bucket_nested + rht_bucket_nested + rht_bucket_nested_insert + root_mem_cgroup + root_task_group + round_jiffies + round_jiffies_relative + round_jiffies_up + rpmsg_create_channel + rpmsg_create_ept + rpmsg_destroy_ept + rpmsg_find_device + rpmsg_register_device + rpmsg_register_device_override + rpmsg_release_channel + rpmsg_send + rpmsg_sendto + rpmsg_unregister_device + rproc_add_carveout + rproc_add_subdev + rproc_boot + rproc_coredump + rproc_coredump_add_segment + rproc_da_to_va + rproc_detach + rproc_elf_get_boot_addr + rproc_elf_load_segments + rproc_elf_sanity_check + rproc_mem_entry_init + rproc_of_parse_firmware + rproc_remove_subdev + rproc_shutdown + rps_needed + rtc_class_close + rtc_class_open + rtc_read_time + rtc_time64_to_tm + rtc_tm_to_time64 + rtc_update_irq + rtnl_is_locked + rtnl_link_register + rtnl_link_unregister + rtnl_lock + rtnl_unlock + runqueues + sbitmap_queue_min_shallow_depth + sbitmap_weight + sched_clock + sched_feat_keys + sched_feat_names + sched_setattr + sched_set_fifo + sched_set_fifo_low + sched_set_normal + sched_setscheduler + sched_setscheduler_nocheck + sched_show_task + schedule + schedule_timeout + schedule_timeout_interruptible + schedule_timeout_uninterruptible + scnprintf + __scsi_add_device + scsi_add_host_with_dma + scsi_alloc_request + scsi_autopm_get_device + scsi_autopm_put_device + scsi_block_requests + scsi_change_queue_depth + scsi_command_size_tbl + scsi_device_get + scsi_device_lookup + scsi_device_put + scsi_device_quiesce + scsi_dma_map + scsi_dma_unmap + scsi_done + scsi_execute_cmd + scsi_host_alloc + scsi_host_lookup + scsi_host_put + scsi_is_host_device + __scsi_iterate_devices + scsi_normalize_sense + scsi_print_command + scsi_print_sense_hdr + scsi_register_driver + scsi_remove_device + scsi_remove_host + scsi_report_bus_reset + scsi_scan_host + scsi_unblock_requests + scsi_host_busy + sdev_prefix_printk + security_file_ioctl + select_fallback_rq + send_sig + send_sig_info + seq_buf_printf + seq_lseek + seq_open + seq_printf + seq_putc + seq_puts + seq_read + seq_release + seq_write + set_capacity + set_capacity_and_notify + set_cpus_allowed_ptr + set_disk_ro + set_freezable + set_next_entity + set_normalized_timespec64 + set_page_dirty + set_page_dirty_lock + __SetPageMovable + set_task_cpu + set_user_nice + sg_alloc_table + sg_alloc_table_from_pages_segment + sg_copy_from_buffer + sg_copy_to_buffer + sget_dev + sg_free_table + sg_init_one + sg_init_table + sg_nents + sg_next + __sg_page_iter_dma_next + __sg_page_iter_next + __sg_page_iter_start + sg_pcopy_from_buffer + shmem_file_setup + show_regs + shrink_slab + si_mem_available + simple_attr_open + simple_attr_read + simple_attr_release + simple_attr_write + simple_open + simple_read_from_buffer + simple_strtol + simple_strtoul + simple_write_to_buffer + single_open + single_release + si_swapinfo + skb_add_rx_frag + skb_checksum_help + skb_clone + skb_clone_sk + skb_complete_wifi_ack + skb_copy + skb_copy_bits + skb_copy_datagram_iter + skb_copy_expand + skb_copy_header + skb_csum_hwoffload_help + skb_dequeue + skb_dump + skb_ensure_writable + __skb_get_hash + __skb_gso_segment + skb_pull + skb_pull_rcsum + skb_push + skb_put + skb_queue_head + skb_queue_purge_reason + skb_queue_tail + skb_realloc_headroom + skb_splice_bits + skb_split + skb_to_sgvec + skb_trim + skb_unlink + sk_error_report + __sk_flush_backlog + sk_free + skip_spaces + __sk_mem_reclaim + sk_msg_alloc + sk_msg_clone + sk_msg_free + sk_msg_free_nocharge + sk_msg_free_partial + sk_msg_memcopy_from_iter + sk_msg_return_zero + sk_msg_trim + sk_msg_zerocopy_from_iter + sk_psock_drop + sk_psock_msg_verdict + sk_psock_tls_strp_read + sk_stream_error + sk_stream_wait_memory + smp_call_function + smp_call_function_single + smp_call_function_single_async + snd_compr_stop_error + snd_ctl_notify + snd_hwdep_new + snd_pcm_format_name + snd_pcm_format_physical_width + snd_pcm_format_width + snd_pcm_hw_constraint_list + snd_pcm_period_elapsed + snd_soc_add_component_controls + snd_soc_bytes_get + snd_soc_bytes_info + snd_soc_bytes_put + snd_soc_bytes_tlv_callback + snd_soc_card_get_kcontrol + snd_soc_card_get_kcontrol_locked + snd_soc_component_disable_pin + snd_soc_component_enable_pin + snd_soc_component_force_enable_pin + snd_soc_component_get_pin_status + snd_soc_component_init_regmap + snd_soc_component_notify_control + snd_soc_component_read + snd_soc_component_test_bits + snd_soc_component_update_bits + snd_soc_component_write + snd_soc_dai_active + snd_soc_dai_set_fmt + snd_soc_dai_set_tdm_slot + snd_soc_dapm_add_routes + snd_soc_dapm_del_routes + snd_soc_dapm_get_enum_double + snd_soc_dapm_get_volsw + snd_soc_dapm_ignore_suspend + snd_soc_dapm_kcontrol_dapm + snd_soc_dapm_kcontrol_widget + snd_soc_dapm_mixer_update_power + snd_soc_dapm_mux_update_power + snd_soc_dapm_new_controls + snd_soc_dapm_new_widgets + snd_soc_dapm_put_enum_double + snd_soc_dapm_put_volsw + snd_soc_dapm_sync + snd_soc_get_enum_double + snd_soc_get_volsw + snd_soc_get_volsw_range + snd_soc_get_volsw_sx + snd_soc_info_enum_double + snd_soc_info_volsw + snd_soc_info_volsw_range + snd_soc_info_volsw_sx + snd_soc_new_compress + snd_soc_of_parse_card_name + snd_soc_params_to_bclk + snd_soc_pm_ops + snd_soc_put_enum_double + snd_soc_put_volsw + snd_soc_put_volsw_range + snd_soc_put_volsw_sx + snd_soc_register_component + snd_soc_rtdcom_lookup + snd_soc_unregister_card + snd_soc_unregister_component + snd_usb_find_csint_desc + snd_usb_find_format + snd_usb_hw_params + snd_usb_register_platform_ops + snprintf + __sock_create + sock_recv_errqueue + sock_release + sort + __spi_alloc_controller + spi_bus_type + spi_controller_resume + spi_controller_suspend + spi_delay_exec + spi_finalize_current_transfer + spi_mem_default_supports_op + spi_register_controller + __spi_register_driver + spi_setup + spi_sync + spi_unregister_controller + spmi_controller_add + spmi_controller_alloc + spmi_controller_remove + __spmi_driver_register + sprintf + srcu_init_notifier_head + srcu_notifier_call_chain + srcu_notifier_chain_register + srcu_notifier_chain_unregister + __srcu_read_lock + __srcu_read_unlock + sscanf + __stack_chk_fail + stack_depot_fetch + stack_depot_save + stack_trace_print + stack_trace_save + static_key_disable + static_key_enable + static_key_slow_dec + static_key_slow_inc + stop_machine + stop_one_cpu + stop_one_cpu_nowait + strcasecmp + strchr + strcmp + strcpy + strcspn + stream_open + strim + strlcpy + strlen + strncasecmp + strncat + strncmp + strncpy + strncpy_from_user + strnlen + strnstr + strpbrk + strrchr + strscpy + strsep + strspn + strstr + submit_bio + submit_bio_wait + sum_mthp_stat + __sw_hweight16 + __sw_hweight32 + __sw_hweight64 + __sw_hweight8 + sync_blockdev + sync_file_create + sync_file_get_fence + synchronize_irq + synchronize_net + synchronize_rcu + synchronize_srcu + syscon_regmap_lookup_by_phandle + sysctl_sched_features + sysctl_vals + sysfs_create_bin_file + sysfs_create_file_ns + sysfs_create_files + sysfs_create_group + sysfs_create_groups + sysfs_create_link + sysfs_emit + sysfs_emit_at + sysfs_notify + sysfs_remove_bin_file + sysfs_remove_file_ns + sysfs_remove_files + sysfs_remove_group + sysfs_remove_groups + sysfs_remove_link + sysfs_streq + sysrq_mask + system_cpucaps + system_freezable_power_efficient_wq + system_freezable_wq + system_highpri_wq + system_long_wq + system_power_efficient_wq + system_state + system_unbound_wq + system_wq + sys_tz + __tasklet_hi_schedule + tasklet_init + tasklet_kill + __tasklet_schedule + tasklet_setup + tasklet_unlock_wait + tasklist_lock + __task_pid_nr_ns + __task_rq_lock + task_rq_lock + task_sched_runtime + tcp_bpf_sendmsg_redir + tcp_get_info + tcp_memory_pressure + tcp_poll + tcp_rate_check_app_limited + tcp_read_done + tcp_read_sock + tcp_recv_skb + tcp_register_ulp + tcp_sendmsg_locked + tcp_unregister_ulp + thermal_cooling_device_register + thermal_cooling_device_unregister + thermal_of_cooling_device_register + thermal_pressure + thermal_zone_get_temp + thermal_zone_get_zone_by_name + tick_nohz_get_sleep_length + time64_to_tm + timer_delete + timer_delete_sync + topology_clear_scale_freq_source + topology_update_done + _totalram_pages + touch_softlockup_watchdog + __trace_bprintk + trace_event_buffer_commit + trace_event_buffer_reserve + trace_event_printf + trace_event_raw_init + trace_event_reg + trace_handle_return + __traceiter_android_rvh_account_irq + __traceiter_android_rvh_arm64_serror_panic + __traceiter_android_rvh_armv8pmu_counter_overflowed + __traceiter_android_rvh_before_do_sched_yield + __traceiter_android_rvh_build_perf_domains + __traceiter_android_rvh_can_migrate_task + __traceiter_android_rvh_check_preempt_wakeup + __traceiter_android_rvh_context_switch + __traceiter_android_rvh_cpu_cgroup_attach + __traceiter_android_rvh_cpu_cgroup_online + __traceiter_android_rvh_cpufreq_transition + __traceiter_android_rvh_dequeue_task + __traceiter_android_rvh_do_sched_yield + __traceiter_android_rvh_enqueue_task + __traceiter_android_rvh_enqueue_task_fair + __traceiter_android_rvh_find_busiest_queue + __traceiter_android_rvh_find_lowest_rq + __traceiter_android_rvh_fiq_dump + __traceiter_android_rvh_flush_task + __traceiter_android_rvh_get_nohz_timer_target + __traceiter_android_rvh_gic_v3_set_affinity + __traceiter_android_rvh_iommu_setup_dma_ops + __traceiter_android_rvh_is_cpu_allowed + __traceiter_android_rvh_logbuf + __traceiter_android_rvh_new_task_stats + __traceiter_android_rvh_perf_rotate_context + __traceiter_android_rvh_psci_cpu_suspend + __traceiter_android_rvh_replace_next_task_fair + __traceiter_android_rvh_rto_next_cpu + __traceiter_android_rvh_sched_balance_rt + __traceiter_android_rvh_sched_cpu_dying + __traceiter_android_rvh_sched_cpu_starting + __traceiter_android_rvh_sched_exec + __traceiter_android_rvh_sched_fork_init + __traceiter_android_rvh_sched_newidle_balance + __traceiter_android_rvh_sched_nohz_balancer_kick + __traceiter_android_rvh_sched_setaffinity + __traceiter_android_rvh_schedule + __traceiter_android_rvh_select_task_rq_fair + __traceiter_android_rvh_select_task_rq_rt + __traceiter_android_rvh_set_cpus_allowed_by_task + __traceiter_android_rvh_set_cpus_allowed_comm + __traceiter_android_rvh_set_cpus_allowed_ptr + __traceiter_android_rvh_set_task_cpu + __traceiter_android_rvh_tick_entry + __traceiter_android_rvh_try_to_wake_up + __traceiter_android_rvh_ttwu_cond + __traceiter_android_rvh_uclamp_eff_get + __traceiter_android_rvh_update_cpu_capacity + __traceiter_android_rvh_update_misfit_status + __traceiter_android_rvh_wake_up_new_task + __traceiter_android_vh_alloc_pages_failure_bypass + __traceiter_android_vh_alloc_pages_reclaim_bypass + __traceiter_android_vh_alloc_pages_slowpath + __traceiter_android_vh_alter_mutex_list_add + __traceiter_android_vh_alter_rwsem_list_add + __traceiter_android_vh_anon_vma_name_recog + __traceiter_android_vh_binder_alloc_new_buf_locked + __traceiter_android_vh_binder_preset + __traceiter_android_vh_binder_proc_transaction + __traceiter_android_vh_binder_reply + __traceiter_android_vh_binder_restore_priority + __traceiter_android_vh_binder_set_priority + __traceiter_android_vh_binder_trans + __traceiter_android_vh_binder_transaction_init + __traceiter_android_vh_binder_wait_for_work + __traceiter_android_vh_clear_rwsem_writer_owned + __traceiter_android_vh_compact_finished + __traceiter_android_vh_cpufreq_resolve_freq + __traceiter_android_vh_cpu_idle_enter + __traceiter_android_vh_cpu_idle_exit + __traceiter_android_vh_customize_pmd_gfp_bypass + __traceiter_android_vh_customize_thp_gfp_orders + __traceiter_android_vh_del_page_from_lrulist + __traceiter_android_vh_do_futex + __traceiter_android_vh_do_send_sig_info + __traceiter_android_vh_drain_all_pages_bypass + __traceiter_android_vh_dup_task_struct + __traceiter_android_vh_filemap_add_folio + __traceiter_android_vh_free_mod_mem + __traceiter_android_vh_free_task + __traceiter_android_vh_freq_qos_update_request + __traceiter_android_vh_freq_table_limits + __traceiter_android_vh_futex_wait_end + __traceiter_android_vh_futex_wake_traverse_plist + __traceiter_android_vh_futex_wake_up_q_finish + __traceiter_android_vh_get_page_wmark + __traceiter_android_vh_ipi_stop + __traceiter_android_vh_logbuf + __traceiter_android_vh_lruvec_del_folio + __traceiter_android_vh_madvise_cold_or_pageout_abort + __traceiter_android_vh_mem_cgroup_alloc + __traceiter_android_vh_mem_cgroup_charge + __traceiter_android_vh_mem_cgroup_css_offline + __traceiter_android_vh_mem_cgroup_css_online + __traceiter_android_vh_mem_cgroup_free + __traceiter_android_vh_mm_direct_reclaim_enter + __traceiter_android_vh_mmput + __traceiter_android_vh_mpam_set + __traceiter_android_vh_mutex_can_spin_on_owner + __traceiter_android_vh_mutex_opt_spin_finish + __traceiter_android_vh_mutex_opt_spin_start + __traceiter_android_vh_mutex_unlock_slowpath + __traceiter_android_vh_mutex_wait_finish + __traceiter_android_vh_mutex_wait_start + __traceiter_android_vh_percpu_rwsem_wq_add + __traceiter_android_vh_printk_caller + __traceiter_android_vh_printk_caller_id + __traceiter_android_vh_ra_tuning_max_page + __traceiter_android_vh_record_pcpu_rwsem_starttime + __traceiter_android_vh_record_rwsem_lock_starttime + __traceiter_android_vh_record_rwsem_reader_owned + __traceiter_android_vh_restore_mm_flags + __traceiter_android_vh_rwsem_direct_rsteal + __traceiter_android_vh_rwsem_optimistic_rspin + __traceiter_android_vh_rwsem_read_wait_finish + __traceiter_android_vh_rwsem_read_wait_start + __traceiter_android_vh_save_vmalloc_stack + __traceiter_android_vh_scheduler_tick + __traceiter_android_vh_set_mod_perm_after_init + __traceiter_android_vh_set_mod_perm_before_init + __traceiter_android_vh_should_memcg_bypass + __traceiter_android_vh_show_stack_hash + __traceiter_android_vh_shrink_node + __traceiter_android_vh_shrink_node_memcgs + __traceiter_android_vh_shrink_slab_bypass + __traceiter_android_vh_slab_alloc_node + __traceiter_android_vh_slab_free + __traceiter_android_vh_split_large_folio_bypass + __traceiter_android_vh_thp_vma_allowable_orders + __traceiter_android_vh_tune_mmap_readaround + __traceiter_android_vh_tune_scan_type + __traceiter_android_vh_ufs_abort_success_ctrl + __traceiter_android_vh_ufs_check_int_errors + __traceiter_android_vh_ufs_compl_command + __traceiter_android_vh_ufs_compl_rsp_check_done + __traceiter_android_vh_ufs_err_check_ctrl + __traceiter_android_vh_ufs_err_handler + __traceiter_android_vh_ufs_err_print_ctrl + __traceiter_android_vh_ufs_fill_prdt + __traceiter_android_vh_ufs_perf_huristic_ctrl + __traceiter_android_vh_ufs_prepare_command + __traceiter_android_vh_ufs_send_command + __traceiter_android_vh_ufs_send_command_post_change + __traceiter_android_vh_ufs_send_tm_command + __traceiter_android_vh_ufs_send_uic_command + __traceiter_android_vh_ufs_update_sdev + __traceiter_android_vh_ufs_update_sysfs + __traceiter_android_vh_update_page_mapcount + __traceiter_android_vh_update_topology_flags_workfn + __traceiter_android_vh_update_vma_flags + __traceiter_android_vh_vmscan_kswapd_done + __traceiter_block_rq_insert + __traceiter_clock_set_rate + __traceiter_cma_alloc_finish + __traceiter_cma_release + __traceiter_cpu_frequency_limits + __traceiter_cpu_idle + __traceiter_gpu_mem_total + __traceiter_ipi_entry + __traceiter_ipi_raise + __traceiter_irq_handler_entry + __traceiter_irq_handler_exit + __traceiter_mmap_lock_acquire_returned + __traceiter_mmap_lock_released + __traceiter_mmap_lock_start_locking + __traceiter_sched_overutilized_tp + __traceiter_sched_stat_wait + __traceiter_sched_switch + __traceiter_sk_data_ready + __traceiter_softirq_entry + __traceiter_softirq_exit + __traceiter_suspend_resume + __traceiter_workqueue_execute_end + __traceiter_workqueue_execute_start + trace_output_call + __tracepoint_android_rvh_account_irq + __tracepoint_android_rvh_arm64_serror_panic + __tracepoint_android_rvh_armv8pmu_counter_overflowed + __tracepoint_android_rvh_before_do_sched_yield + __tracepoint_android_rvh_build_perf_domains + __tracepoint_android_rvh_can_migrate_task + __tracepoint_android_rvh_check_preempt_wakeup + __tracepoint_android_rvh_context_switch + __tracepoint_android_rvh_cpu_cgroup_attach + __tracepoint_android_rvh_cpu_cgroup_online + __tracepoint_android_rvh_cpufreq_transition + __tracepoint_android_rvh_dequeue_task + __tracepoint_android_rvh_do_sched_yield + __tracepoint_android_rvh_enqueue_task + __tracepoint_android_rvh_enqueue_task_fair + __tracepoint_android_rvh_find_busiest_queue + __tracepoint_android_rvh_find_lowest_rq + __tracepoint_android_rvh_fiq_dump + __tracepoint_android_rvh_flush_task + __tracepoint_android_rvh_get_nohz_timer_target + __tracepoint_android_rvh_gic_v3_set_affinity + __tracepoint_android_rvh_iommu_setup_dma_ops + __tracepoint_android_rvh_is_cpu_allowed + __tracepoint_android_rvh_logbuf + __tracepoint_android_rvh_new_task_stats + __tracepoint_android_rvh_perf_rotate_context + __tracepoint_android_rvh_psci_cpu_suspend + __tracepoint_android_rvh_replace_next_task_fair + __tracepoint_android_rvh_rto_next_cpu + __tracepoint_android_rvh_sched_balance_rt + __tracepoint_android_rvh_sched_cpu_dying + __tracepoint_android_rvh_sched_cpu_starting + __tracepoint_android_rvh_sched_exec + __tracepoint_android_rvh_sched_fork_init + __tracepoint_android_rvh_sched_newidle_balance + __tracepoint_android_rvh_sched_nohz_balancer_kick + __tracepoint_android_rvh_sched_setaffinity + __tracepoint_android_rvh_schedule + __tracepoint_android_rvh_select_task_rq_fair + __tracepoint_android_rvh_select_task_rq_rt + __tracepoint_android_rvh_set_cpus_allowed_by_task + __tracepoint_android_rvh_set_cpus_allowed_comm + __tracepoint_android_rvh_set_cpus_allowed_ptr + __tracepoint_android_rvh_set_task_cpu + __tracepoint_android_rvh_tick_entry + __tracepoint_android_rvh_try_to_wake_up + __tracepoint_android_rvh_ttwu_cond + __tracepoint_android_rvh_uclamp_eff_get + __tracepoint_android_rvh_update_cpu_capacity + __tracepoint_android_rvh_update_misfit_status + __tracepoint_android_rvh_wake_up_new_task + __tracepoint_android_vh_alloc_pages_failure_bypass + __tracepoint_android_vh_alloc_pages_reclaim_bypass + __tracepoint_android_vh_alloc_pages_slowpath + __tracepoint_android_vh_alter_mutex_list_add + __tracepoint_android_vh_alter_rwsem_list_add + __tracepoint_android_vh_anon_vma_name_recog + __tracepoint_android_vh_binder_alloc_new_buf_locked + __tracepoint_android_vh_binder_preset + __tracepoint_android_vh_binder_proc_transaction + __tracepoint_android_vh_binder_reply + __tracepoint_android_vh_binder_restore_priority + __tracepoint_android_vh_binder_set_priority + __tracepoint_android_vh_binder_trans + __tracepoint_android_vh_binder_transaction_init + __tracepoint_android_vh_binder_wait_for_work + __tracepoint_android_vh_clear_rwsem_writer_owned + __tracepoint_android_vh_compact_finished + __tracepoint_android_vh_cpufreq_resolve_freq + __tracepoint_android_vh_cpu_idle_enter + __tracepoint_android_vh_cpu_idle_exit + __tracepoint_android_vh_customize_pmd_gfp_bypass + __tracepoint_android_vh_customize_thp_gfp_orders + __tracepoint_android_vh_del_page_from_lrulist + __tracepoint_android_vh_do_futex + __tracepoint_android_vh_do_send_sig_info + __tracepoint_android_vh_drain_all_pages_bypass + __tracepoint_android_vh_dup_task_struct + __tracepoint_android_vh_filemap_add_folio + __tracepoint_android_vh_free_mod_mem + __tracepoint_android_vh_free_task + __tracepoint_android_vh_freq_qos_update_request + __tracepoint_android_vh_freq_table_limits + __tracepoint_android_vh_futex_wait_end + __tracepoint_android_vh_futex_wake_traverse_plist + __tracepoint_android_vh_futex_wake_up_q_finish + __tracepoint_android_vh_get_page_wmark + __tracepoint_android_vh_ipi_stop + __tracepoint_android_vh_logbuf + __tracepoint_android_vh_lruvec_del_folio + __tracepoint_android_vh_madvise_cold_or_pageout_abort + __tracepoint_android_vh_mem_cgroup_alloc + __tracepoint_android_vh_mem_cgroup_charge + __tracepoint_android_vh_mem_cgroup_css_offline + __tracepoint_android_vh_mem_cgroup_css_online + __tracepoint_android_vh_mem_cgroup_free + __tracepoint_android_vh_mm_direct_reclaim_enter + __tracepoint_android_vh_mmput + __tracepoint_android_vh_mpam_set + __tracepoint_android_vh_mutex_can_spin_on_owner + __tracepoint_android_vh_mutex_opt_spin_finish + __tracepoint_android_vh_mutex_opt_spin_start + __tracepoint_android_vh_mutex_unlock_slowpath + __tracepoint_android_vh_mutex_wait_finish + __tracepoint_android_vh_mutex_wait_start + __tracepoint_android_vh_percpu_rwsem_wq_add + __tracepoint_android_vh_printk_caller + __tracepoint_android_vh_printk_caller_id + __tracepoint_android_vh_ra_tuning_max_page + __tracepoint_android_vh_record_pcpu_rwsem_starttime + __tracepoint_android_vh_record_rwsem_lock_starttime + __tracepoint_android_vh_record_rwsem_reader_owned + __tracepoint_android_vh_restore_mm_flags + __tracepoint_android_vh_rwsem_direct_rsteal + __tracepoint_android_vh_rwsem_optimistic_rspin + __tracepoint_android_vh_rwsem_read_wait_finish + __tracepoint_android_vh_rwsem_read_wait_start + __tracepoint_android_vh_save_vmalloc_stack + __tracepoint_android_vh_scheduler_tick + __tracepoint_android_vh_set_mod_perm_after_init + __tracepoint_android_vh_set_mod_perm_before_init + __tracepoint_android_vh_should_memcg_bypass + __tracepoint_android_vh_show_stack_hash + __tracepoint_android_vh_shrink_node + __tracepoint_android_vh_shrink_node_memcgs + __tracepoint_android_vh_shrink_slab_bypass + __tracepoint_android_vh_slab_alloc_node + __tracepoint_android_vh_slab_free + __tracepoint_android_vh_split_large_folio_bypass + __tracepoint_android_vh_thp_vma_allowable_orders + __tracepoint_android_vh_tune_mmap_readaround + __tracepoint_android_vh_tune_scan_type + __tracepoint_android_vh_ufs_abort_success_ctrl + __tracepoint_android_vh_ufs_check_int_errors + __tracepoint_android_vh_ufs_compl_command + __tracepoint_android_vh_ufs_compl_rsp_check_done + __tracepoint_android_vh_ufs_err_check_ctrl + __tracepoint_android_vh_ufs_err_handler + __tracepoint_android_vh_ufs_err_print_ctrl + __tracepoint_android_vh_ufs_fill_prdt + __tracepoint_android_vh_ufs_perf_huristic_ctrl + __tracepoint_android_vh_ufs_prepare_command + __tracepoint_android_vh_ufs_send_command + __tracepoint_android_vh_ufs_send_command_post_change + __tracepoint_android_vh_ufs_send_tm_command + __tracepoint_android_vh_ufs_send_uic_command + __tracepoint_android_vh_ufs_update_sdev + __tracepoint_android_vh_ufs_update_sysfs + __tracepoint_android_vh_update_page_mapcount + __tracepoint_android_vh_update_topology_flags_workfn + __tracepoint_android_vh_update_vma_flags + __tracepoint_android_vh_vmscan_kswapd_done + __tracepoint_block_rq_insert + __tracepoint_clock_set_rate + __tracepoint_cma_alloc_finish + __tracepoint_cma_release + __tracepoint_cpu_frequency_limits + __tracepoint_cpu_idle + __tracepoint_gpu_mem_total + __tracepoint_ipi_entry + __tracepoint_ipi_raise + __tracepoint_irq_handler_entry + __tracepoint_irq_handler_exit + __tracepoint_mmap_lock_acquire_returned + __tracepoint_mmap_lock_released + __tracepoint_mmap_lock_start_locking + tracepoint_probe_register + tracepoint_probe_register_prio + tracepoint_probe_unregister + __tracepoint_sched_overutilized_tp + __tracepoint_sched_stat_wait + __tracepoint_sched_switch + __tracepoint_sk_data_ready + __tracepoint_softirq_entry + __tracepoint_softirq_exit + __tracepoint_suspend_resume + __tracepoint_workqueue_execute_end + __tracepoint_workqueue_execute_start + trace_print_array_seq + trace_print_flags_seq + trace_print_hex_seq + trace_print_symbols_seq + trace_raw_output_prep + trace_seq_printf + trace_seq_putc + __trace_trigger_soft_disabled + try_module_get + try_to_free_mem_cgroup_pages + try_wait_for_completion + __tty_alloc_driver + tty_chars_in_buffer + tty_driver_flush_buffer + tty_flip_buffer_push + __tty_insert_flip_string_flags + tty_ldisc_flush + tty_port_init + tty_port_link_device + tty_register_driver + tty_register_ldisc + tty_set_termios + tty_std_termios + tty_termios_baud_rate + tty_termios_encode_baud_rate + tty_unregister_driver + tty_unregister_ldisc + tty_write_room + typec_get_drvdata + typec_partner_set_identity + typec_register_partner + typec_register_port + typec_set_data_role + typec_set_pwr_opmode + typec_set_pwr_role + typec_set_vconn_role + typec_unregister_partner + typec_unregister_port + uart_add_one_port + uart_console_device + uart_console_write + uart_get_baud_rate + uart_handle_cts_change + uart_handle_dcd_change + uart_insert_char + uart_parse_options + uart_register_driver + uart_remove_one_port + uart_resume_port + uart_set_options + uart_suspend_port + uart_try_toggle_sysrq + uart_unregister_driver + uart_update_timeout + uart_write_wakeup + uart_xchar_out + uclamp_eff_value + __udelay + unlock_page + unmap_mapping_range + unpin_user_page + unpin_user_pages + unpin_user_pages_dirty_lock + unregister_blkdev + __unregister_chrdev + unregister_chrdev_region + unregister_inet6addr_notifier + unregister_inetaddr_notifier + unregister_kprobe + unregister_memory_notifier + unregister_netdev + unregister_netdevice_notifier + unregister_netdevice_queue + unregister_oom_notifier + unregister_pernet_device + unregister_pernet_subsys + unregister_pm_notifier + unregister_reboot_notifier + unregister_rpmsg_driver + unregister_shrinker + unregister_syscore_ops + unregister_sysctl_table + unregister_virtio_device + unregister_virtio_driver + unregister_vmap_purge_notifier + up + update_devfreq + update_rq_clock + up_read + up_write + usb_assign_descriptors + usb_control_msg + usb_debug_root + usb_device_match_id + usb_ep_alloc_request + usb_ep_autoconfig + usb_ep_disable + usb_ep_enable + usb_ep_free_request + usb_ep_queue + usb_free_all_descriptors + usb_function_register + usb_function_unregister + usb_gstrings_attach + usb_hcd_check_unlink_urb + usb_hcd_giveback_urb + usb_hc_died + usb_hcd_is_primary_hcd + usb_hcd_link_urb_to_ep + usb_hcd_poll_rh_status + usb_hcd_unlink_urb_from_ep + usb_initialize_gadget + usb_interface_id + usb_match_one_id + usb_os_desc_prepare_interf_dir + usb_pipe_type_check + usb_put_function_instance + usb_register_notify + usb_role_switch_get + usb_role_switch_put + usb_role_switch_set_role + usb_speed_string + usb_state_string + usb_unregister_notify + __usecs_to_jiffies + usleep_range_state + utf16s_to_utf8s + uuid_null + uuid_parse + v4l2_ctrl_handler_free + v4l2_ctrl_handler_init_class + v4l2_ctrl_handler_setup + v4l2_ctrl_new_custom + v4l2_ctrl_new_std + v4l2_ctrl_new_std_menu + v4l2_ctrl_subscribe_event + v4l2_device_register + v4l2_device_unregister + v4l2_event_dequeue + v4l2_event_pending + v4l2_event_queue + v4l2_event_queue_fh + v4l2_event_subscribe + v4l2_event_unsubscribe + v4l2_fh_add + v4l2_fh_del + v4l2_fh_exit + v4l2_fh_init + v4l2_fh_open + v4l2_fh_release + v4l2_format_info + v4l2_src_change_event_subscribe + vb2_buffer_done + vb2_create_bufs + vb2_dma_sg_memops + vb2_dqbuf + vb2_expbuf + vb2_mmap + vb2_ops_wait_finish + vb2_ops_wait_prepare + vb2_plane_cookie + vb2_plane_vaddr + vb2_poll + vb2_prepare_buf + vb2_qbuf + vb2_querybuf + vb2_queue_init + vb2_queue_release + vb2_reqbufs + vb2_streamoff + vb2_streamon + vcalloc + vchan_dma_desc_free_list + vchan_find_desc + vchan_init + vchan_tx_desc_free + vchan_tx_submit + verify_pkcs7_signature + vfree + vfs_iter_read + vfs_llseek + video_devdata + video_device_alloc + video_device_release + video_ioctl2 + __video_register_device + video_unregister_device + virtio_check_driver_offered_feature + virtio_reset_device + virtqueue_add_inbuf + virtqueue_add_outbuf + virtqueue_disable_cb + virtqueue_enable_cb + virtqueue_get_buf + virtqueue_get_vring_size + virtqueue_kick + virtqueue_kick_prepare + virtqueue_notify + vmalloc + vmalloc_nr_pages + vmalloc_to_page + vmalloc_to_pfn + vmalloc_user + vmap + vmf_insert_pfn_prot + vm_node_stat + vm_unmapped_area + vm_zone_stat + vprintk + vring_del_virtqueue + vring_interrupt + vring_new_virtqueue + vring_transport_features + vscnprintf + vsnprintf + vsprintf + vunmap + vzalloc + wait_for_completion + wait_for_completion_interruptible + wait_for_completion_interruptible_timeout + wait_for_completion_io_timeout + wait_for_completion_timeout + wait_for_device_probe + wait_woken + __wake_up + wake_up_if_idle + wake_up_process + wakeup_source_register + wakeup_source_unregister + __warn_printk + wireless_nlevent_flush + wireless_send_event + woken_wake_function + work_busy + __write_overflow_field + x509_load_certificate_list + __xa_alloc + __xa_cmpxchg + xa_erase + xa_load + xas_find diff --git a/arch/arm64/configs/vendor/ext_config/debug-parrot-cusco.config b/arch/arm64/configs/vendor/ext_config/debug-parrot-cusco.config new file mode 100644 index 000000000..6649ba19f --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/debug-parrot-cusco.config @@ -0,0 +1,5 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# diff --git a/arch/arm64/configs/vendor/ext_config/debug-parrot-cuscoi.config b/arch/arm64/configs/vendor/ext_config/debug-parrot-cuscoi.config new file mode 100644 index 000000000..6649ba19f --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/debug-parrot-cuscoi.config @@ -0,0 +1,5 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# diff --git a/arch/arm64/configs/vendor/ext_config/debug-parrot-paros.config b/arch/arm64/configs/vendor/ext_config/debug-parrot-paros.config new file mode 100644 index 000000000..6649ba19f --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/debug-parrot-paros.config @@ -0,0 +1,5 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# diff --git a/arch/arm64/configs/vendor/ext_config/debug-parrot.config b/arch/arm64/configs/vendor/ext_config/debug-parrot.config new file mode 100644 index 000000000..bcb15f5dc --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/debug-parrot.config @@ -0,0 +1,6 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_SUSPEND_DEBUG=m diff --git a/arch/arm64/configs/vendor/ext_config/factory-parrot.config b/arch/arm64/configs/vendor/ext_config/factory-parrot.config new file mode 100644 index 000000000..0ad8bd5af --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/factory-parrot.config @@ -0,0 +1,6 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# + diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-cusco.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-cusco.config new file mode 100644 index 000000000..5d89e6035 --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-cusco.config @@ -0,0 +1,11 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_CUSCO_DTB=y +CONFIG_UFSFEATURE=y +CONFIG_UFSHID=y +CONFIG_MICRON_UFSHID=y +CONFIG_SCSI_SKHID=y +CONFIG_SCHED_MOTO_UNFAIR=m diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-cuscoi.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-cuscoi.config new file mode 100644 index 000000000..5d89e6035 --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-cuscoi.config @@ -0,0 +1,11 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_CUSCO_DTB=y +CONFIG_UFSFEATURE=y +CONFIG_UFSHID=y +CONFIG_MICRON_UFSHID=y +CONFIG_SCSI_SKHID=y +CONFIG_SCHED_MOTO_UNFAIR=m diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-gki.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-gki.config new file mode 100644 index 000000000..0ad8bd5af --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-gki.config @@ -0,0 +1,6 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# + diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-mona.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-mona.config new file mode 100644 index 000000000..6912fc64f --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-mona.config @@ -0,0 +1,11 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_MONA_DTB=y +CONFIG_SCHED_MOTO_UNFAIR=m +CONFIG_UFSFEATURE=y +CONFIG_UFSHID=y +CONFIG_MICRON_UFSHID=y +CONFIG_SCSI_SKHID=y \ No newline at end of file diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-monai.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-monai.config new file mode 100644 index 000000000..d2fade289 --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-monai.config @@ -0,0 +1,11 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_MONAI_DTB=y +CONFIG_SCHED_MOTO_UNFAIR=m +CONFIG_UFSFEATURE=y +CONFIG_UFSHID=y +CONFIG_MICRON_UFSHID=y +CONFIG_SCSI_SKHID=y \ No newline at end of file diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-paro.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-paro.config new file mode 100644 index 000000000..a578f2892 --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-paro.config @@ -0,0 +1,7 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_PARO_DTB=y + diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-paros.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-paros.config new file mode 100644 index 000000000..5fa6cd187 --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-paros.config @@ -0,0 +1,14 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_PAROS_DTB=y +CONFIG_UFSFEATURE=y +CONFIG_UFSHID=y +CONFIG_MICRON_UFSHID=y +CONFIG_SCSI_SKHID=y +CONFIG_SCHED_MOTO_UNFAIR=m + +# Motorola fix Longsys UFS CP0 Timeout Issue Support. +CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT=y \ No newline at end of file diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot-perf.config b/arch/arm64/configs/vendor/ext_config/moto-parrot-perf.config new file mode 100644 index 000000000..0ad8bd5af --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot-perf.config @@ -0,0 +1,6 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# + diff --git a/arch/arm64/configs/vendor/ext_config/moto-parrot.config b/arch/arm64/configs/vendor/ext_config/moto-parrot.config new file mode 100644 index 000000000..f7f67f1ed --- /dev/null +++ b/arch/arm64/configs/vendor/ext_config/moto-parrot.config @@ -0,0 +1,7 @@ +# +# Please avoid changing the Qualcomm defconfig files and use this file to +# add any Motorola-specific configuration changes that are applicable to +# userdebug, eng, and user builds. +# +CONFIG_MMI_DEVICE_DTBS=y + diff --git a/arch/arm64/configs/vendor/parrot_consolidate.config b/arch/arm64/configs/vendor/parrot_consolidate.config index 6d9ed495d..f3ae0430d 100644 --- a/arch/arm64/configs/vendor/parrot_consolidate.config +++ b/arch/arm64/configs/vendor/parrot_consolidate.config @@ -1,10 +1,9 @@ CONFIG_ARM_SMMU_SELFTEST=y CONFIG_ATOMIC64_SELFTEST=m -CONFIG_CMA_DEBUG=y +# CONFIG_CMA_DEBUG is not set CONFIG_CMA_DEBUGFS=y -CONFIG_CORESIGHT_SOURCE_ETM4X=m -CONFIG_DEBUG_PAGEALLOC=y -CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y +# CONFIG_CORESIGHT_SOURCE_ETM4X is not set +# CONFIG_DEBUG_PAGEALLOC is not set CONFIG_DEBUG_SPINLOCK=y CONFIG_DETECT_HUNG_TASK=y CONFIG_LKDTM=m @@ -17,7 +16,7 @@ CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG=y CONFIG_RCU_TORTURE_TEST=m CONFIG_REGMAP_QTI_DEBUGFS_ALLOW_WRITE=y CONFIG_RUNTIME_TESTING_MENU=y -CONFIG_SCHED_WALT_DEBUG=m +# CONFIG_SCHED_WALT_DEBUG is not set CONFIG_SDHCI_MSM_DBG=y CONFIG_TEST_USER_COPY=m CONFIG_UFS_DBG=y diff --git a/arch/arm64/configs/vendor/parrot_perf.config b/arch/arm64/configs/vendor/parrot_perf.config index f6265c769..f0febcfef 100644 --- a/arch/arm64/configs/vendor/parrot_perf.config +++ b/arch/arm64/configs/vendor/parrot_perf.config @@ -58,6 +58,7 @@ CONFIG_HVC_GUNYAH=m CONFIG_HWSPINLOCK_QCOM=m CONFIG_I2C_MSM_GENI=m CONFIG_INPUT_PM8941_PWRKEY=m +CONFIG_INPUT_QCOM_HV_HAPTICS=m CONFIG_INPUT_QPNP_POWER_ON=m CONFIG_INTERCONNECT_QCOM_BCM_VOTER=m CONFIG_INTERCONNECT_QCOM_DEBUG=m @@ -162,7 +163,7 @@ CONFIG_QCOM_MEM_BUF_DEV=m CONFIG_QCOM_MEM_BUF_DEV_GH=y CONFIG_QCOM_MEM_BUF_GH=y CONFIG_QCOM_MEM_BUF_MSGQ=m -CONFIG_QCOM_MEM_OFFLINE=m +# CONFIG_QCOM_MEM_OFFLINE is not set CONFIG_QCOM_MINIDUMP=m CONFIG_QCOM_MINIDUMP_FTRACE=y CONFIG_QCOM_MINIDUMP_PANIC_CPUFREQ_INFO=y @@ -212,7 +213,7 @@ CONFIG_QCOM_VADC_COMMON=m CONFIG_QCOM_VA_MINIDUMP=m CONFIG_QCOM_VM_ALIVE_LOG_DUMPER=y CONFIG_QCOM_VM_DMESG_DUMPER=m -CONFIG_QCOM_WATCHDOG_BARK_TIME=11000 +CONFIG_QCOM_WATCHDOG_BARK_TIME=16000 CONFIG_QCOM_WATCHDOG_IPI_PING=y CONFIG_QCOM_WATCHDOG_PET_TIME=9360 # CONFIG_QCOM_WATCHDOG_USERSPACE_PET is not set diff --git a/build.config.moto b/build.config.moto new file mode 100644 index 000000000..f2c2b3df3 --- /dev/null +++ b/build.config.moto @@ -0,0 +1 @@ +apply_defconfig_fragment ${KERNEL_DIR}/arch/${ARCH}/configs/vendor/ext_config/moto_fragment.config diff --git a/build.config.msm.parrot b/build.config.msm.parrot index 175837bb5..7bff135ef 100644 --- a/build.config.msm.parrot +++ b/build.config.msm.parrot @@ -31,3 +31,4 @@ KERNEL_VENDOR_CMDLINE+=' bootconfig ' ## Inheriting MSM configs . "${KERNEL_DIR}"/build.config.msm.common . "${KERNEL_DIR}"/build.config.msm.perf +. "${KERNEL_DIR}"/build.config.moto diff --git a/build_with_bazel.py b/build_with_bazel.py index 9d1827d99..5705e5d97 100755 --- a/build_with_bazel.py +++ b/build_with_bazel.py @@ -62,7 +62,7 @@ class Target: class BazelBuilder: """Helper class for building with Bazel""" - def __init__(self, target_list, skip_list, out_dir, cache_dir, dry_run, gki_headers, user_opts): + def __init__(self, target_list, skip_list, out_dir, cache_dir, dry_run, gki_headers, user_opts, abl_only): BazelBuilder.targets_done = [] self.workspace = os.path.realpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") @@ -86,6 +86,7 @@ class BazelBuilder: self.dry_run = dry_run self.gki_headers = gki_headers self.user_opts = user_opts + self.abl_only = abl_only self.process_list = [] if len(self.target_list) > 1 and out_dir: logging.error("cannot specify multiple targets with one out dir") @@ -187,7 +188,9 @@ class BazelBuilder: for label in label_list: if any((skip_re.match(label) for skip_re in skip_list_re)): continue - + if self.abl_only and re.search(r"_abl_dist", label) is None: + logging.info("force to skip target label: [%s]" , label) + continue if v == "ALL": real_variant = re.search( r"//{}:[^_]*_([^_]+)_".format(self.kernel_dir), label @@ -488,6 +491,12 @@ def main(): action="store_true", help="Run menuconfig for - and exit without building", ) + parser.add_argument( + "-a", + "--abl_only", + action="store_true", + help="only build abl target and skip all other non abl targets", + ) parser.add_argument( "-d", "--dry-run", @@ -523,7 +532,8 @@ def main(): args.cache_dir, args.dry_run, args.gki_headers, - user_opts + user_opts, + args.abl_only ) try: if args.menuconfig: diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 31756a580..09b66ecae 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -17,6 +17,7 @@ #include #include #include +#include #define PON_REV2 0x01 @@ -150,7 +151,20 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) struct pm8941_pwrkey *pwrkey = _data; unsigned int sts; int err; + struct timespec64 timestamp; + struct tm tm; + char buff[255]; + /* get the time stamp in readable format to print*/ + ktime_get_real_ts64(×tamp); + time64_to_tm(timestamp.tv_sec, 0, &tm); + snprintf(buff, sizeof(buff), + "%u-%02d-%02d %02d:%02d:%02d.%06ld UTC", + (int) tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, + timestamp.tv_nsec); + + pr_info("Enter %s at: %s\n", __func__, buff); if (pwrkey->sw_debounce_time_us) { if (ktime_before(ktime_get(), pwrkey->sw_debounce_end_time)) { dev_dbg(pwrkey->dev, @@ -165,6 +179,8 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) return IRQ_HANDLED; sts &= pwrkey->data->status_bit; + pr_info("pwrkey->code=%d, pwrkey->last_status=0x%02X, sts=0x%02X\n", pwrkey->code, + pwrkey->last_status, sts); if (pwrkey->sw_debounce_time_us && !sts) pwrkey->sw_debounce_end_time = ktime_add_us(ktime_get(), diff --git a/drivers/input/misc/qcom-hv-haptics-debugfs.c b/drivers/input/misc/qcom-hv-haptics-debugfs.c index f5cf75039..4df186a9a 100644 --- a/drivers/input/misc/qcom-hv-haptics-debugfs.c +++ b/drivers/input/misc/qcom-hv-haptics-debugfs.c @@ -221,6 +221,7 @@ static ssize_t fifo_s_dbgfs_read(struct file *fp, char __user *buf, size_t count return rc; } +u8 samples_dbg[MMAP_FIFO_LEN_PER_LSB]; static ssize_t fifo_s_dbgfs_write(struct file *fp, const char __user *buf, size_t count, loff_t *ppos) { @@ -229,7 +230,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp, char *str, *kbuf, *token; int rc, i = 0; int val; - u8 *samples; kbuf = kzalloc(count + 1, GFP_KERNEL); if (!kbuf) @@ -245,12 +245,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp, str[count] = '\0'; *ppos += count; - samples = kcalloc(fifo->num_s, sizeof(*samples), GFP_KERNEL); - if (!samples) { - rc = -ENOMEM; - goto exit; - } - while ((token = strsep(&str, " ")) != NULL) { rc = kstrtoint(token, 0, &val); if (rc < 0) { @@ -261,13 +255,13 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp, if (val > 0xff) val = 0xff; - samples[i++] = (u8)val; - /* only support fifo pattern no longer than before */ - if (i >= fifo->num_s) + samples_dbg[i++] = (u8)val; + if (i >= MMAP_FIFO_LEN_PER_LSB) break; } - memcpy(fifo->samples, samples, fifo->num_s); + fifo->samples = samples_dbg; + fifo->num_s = i; fifo->play_length_us = get_fifo_play_length_us(fifo, effect->t_lra_us); if (fifo->play_length_us == -EINVAL) { pr_err("get fifo play length failed\n"); @@ -277,7 +271,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp, rc = count; exit2: - kfree(samples); exit: kfree(kbuf); return rc; diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 28748dcce..4398daddb 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -491,6 +491,11 @@ #define is_between(val, min, max) \ (((min) <= (max)) && ((min) <= (val)) && ((val) <= (max))) +/* + * rc_clk_cal_count default value if caliration failed and dts not set + * this value get from haptics_get_closeloop_lra_period() + */ +#define LRA_F0_CAL_COUNT 0x244 enum hap_status_sel { CAL_TLRA_CL_STS = 0x00, @@ -1260,6 +1265,7 @@ static int haptics_get_closeloop_lra_period( HAP_STATUS_DATA_MSB_SDAM_OFFSET, rc); return rc; } + dev_info(chip->dev, "read calibration result from SDAM 0x%x, 0x%x\n", val[0], val[1]); } else { rc = haptics_get_status_data(chip, CAL_TLRA_CL_STS, val); if (rc < 0) @@ -1386,7 +1392,7 @@ static int haptics_get_closeloop_lra_period( chip->config.rc_clk_cal_count = 0; } - dev_dbg(chip->dev, "OL_TLRA %u us, CL_TLRA %u us, RC_CLK_CAL_COUNT %#x\n", + dev_info(chip->dev, "OL_TLRA %u us, CL_TLRA %u us, RC_CLK_CAL_COUNT %#x\n", chip->config.t_lra_us, chip->config.cl_t_lra_us, chip->config.rc_clk_cal_count); return 0; @@ -2751,7 +2757,8 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip, return rc; pat_sel_mmap = &chip->mmap.pat_sel_mmap[effect->pat_sel]; - length = pat_sel_mmap->length / + //length = pat_sel_mmap->length / + length = play->effect->fifo->num_s / chip->mmap.hw_info.pat_mem_play_step; addr = pat_sel_mmap->start_addr / HAP530_MMAP_PAT_LEN_PER_LSB; val[0] = addr & HAP_PTN_PATX_MEM_LEN_LO_MASK; @@ -3022,7 +3029,7 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip, } play->vmax_mv = (magnitude * effects[i].vmax_mv) / 0x7fff; - dev_dbg(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined", + dev_info(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined", effects[i].id, play->vmax_mv); rc = haptics_load_predefined_effect(chip, &effects[i]); @@ -3879,6 +3886,10 @@ static int haptics_init_lra_period_config(struct haptics_chip *chip) /* get calibrated close loop period */ t_lra_us = chip->config.t_lra_us; + if (t_lra_us != 0) { + dev_info(chip->dev, "show lra frequency %ld Hz\n", USEC_PER_SEC / t_lra_us); + } + rc = haptics_get_closeloop_lra_period(chip, true); if (!rc && chip->config.cl_t_lra_us != 0) t_lra_us = chip->config.cl_t_lra_us; @@ -4376,6 +4387,7 @@ static int haptics_parse_effect_fifo_data(struct haptics_chip *chip, return rc; } + effect->t_lra_us = config->t_lra_us; effect->fifo->num_s = tmp; effect->fifo->period_per_s = T_LRA; rc = of_property_read_u32(node, "qcom,wf-fifo-period", &tmp); @@ -5963,6 +5975,53 @@ static int haptics_start_auto_brake_calibration(struct haptics_chip *chip) return haptics_auto_brake_pbs_trigger(chip); } +static int haptics_start_play(struct haptics_chip *chip, bool enable) +{ + int rc; + u8 amplitude; + u32 vmax_mv = chip->config.vmax_mv; + + mutex_lock(&chip->play.lock); + if (enable) { + /* Stop other mode playing if there is any */ + rc = haptics_enable_play(chip, false); + if (rc < 0) { + dev_err(chip->dev, "Stop playing failed, rc=%d\n", rc); + goto unlock; + } + + rc = haptics_set_vmax_mv(chip, vmax_mv); + if (rc < 0) + goto unlock; + + amplitude = get_direct_play_max_amplitude(chip); + rc = haptics_set_direct_play(chip, amplitude); + if (rc < 0) + goto unlock; + + rc = haptics_enable_hpwr_vreg(chip, true); + if (rc < 0) + goto unlock; + + chip->play.pattern_src = DIRECT_PLAY; + rc = haptics_enable_play(chip, true); + if (rc < 0) + goto unlock; + + mutex_unlock(&chip->play.lock); + return rc; + } + +unlock: + /* Disable play in case it's not been disabled */ + haptics_enable_play(chip, false); + rc = haptics_enable_hpwr_vreg(chip, false); + + mutex_unlock(&chip->play.lock); + + return rc; +} + static int haptics_start_lra_calibrate(struct haptics_chip *chip) { int rc; @@ -6168,12 +6227,38 @@ static ssize_t i_gain_error_show(const struct class *c, } static const CLASS_ATTR_RO(i_gain_error); +static ssize_t enable_play_store(const struct class *c, + const struct class_attribute *attr, const char *buf, size_t count) +{ + struct haptics_chip *chip = container_of(c, + struct haptics_chip, hap_class); + int val; + int rc; + + if (kstrtoint(buf, 0, &val)) + return -EINVAL; + + if (val) { + rc = haptics_start_play(chip, true); + if (rc < 0) + return rc; + } else { + rc = haptics_start_play(chip, false); + if (rc < 0) + return rc; + } + + return count; +} +static CLASS_ATTR_WO(enable_play); + static struct attribute *hap_class_attrs[] = { &class_attr_lra_calibration.attr, &class_attr_lra_frequency_hz.attr, &class_attr_lra_impedance.attr, &class_attr_primitive_duration.attr, &class_attr_visense_enabled.attr, + &class_attr_enable_play.attr, NULL, }; ATTRIBUTE_GROUPS(hap_class); @@ -6444,6 +6529,54 @@ static int haptics_probe(struct platform_device *pdev) haptics_runtime_autosuspend(chip); phapchip = chip; + if (of_property_read_bool(chip->dev->of_node, "moto,cal_again")) { + u32 t_lra_us_min, t_lra_us_max, f0_cal_count; + u32 cl_f_lra = USEC_PER_SEC / chip->config.cl_t_lra_us; + dev_err(chip->dev, "In XBL cal F0 is %d Hz\n", cl_f_lra); + rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-us-min", &t_lra_us_min); + if (rc < 0) { + dev_err(chip->dev, "Read T-LRA-min failed, rc=%d\n", rc); + goto continue_on; + } + rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-us-max", &t_lra_us_max); + if (rc < 0) { + dev_err(chip->dev, "Read T-LRA-max failed, rc=%d\n", rc); + goto continue_on; + } + /* If calibration failed in XBL,will be calibrate again */ + if (chip->config.cl_t_lra_us < t_lra_us_min || chip->config.cl_t_lra_us > t_lra_us_max) { + dev_err(chip->dev, "The start up cal fail, cal again in kernel\n"); + rc = haptics_start_lra_calibrate(chip); + if (rc < 0) { + dev_err(chip->dev, "Cal again failed in kernel\n"); + goto continue_on; + } + cl_f_lra = USEC_PER_SEC / chip->config.cl_t_lra_us; + dev_err(chip->dev, "Latest cal F0 is %d Hz\n", cl_f_lra); + + /* If cal failed in kernel, force set manual freq */ + if (chip->config.cl_t_lra_us < t_lra_us_min || chip->config.cl_t_lra_us > t_lra_us_max) { + rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-cal-count", &f0_cal_count); + if (rc < 0) { + dev_err(chip->dev, "Read cal-count failed, rc=%d\n", rc); + f0_cal_count = LRA_F0_CAL_COUNT; + } + dev_err(chip->dev, "Failure of all cal, set manual freq to %dHz, f0_count to %d\n", + cl_f_lra, f0_cal_count); + + chip->config.cl_t_lra_us = chip->config.t_lra_us; + chip->config.rc_clk_cal_count = f0_cal_count; + rc = haptics_config_openloop_lra_period(chip, chip->config.cl_t_lra_us); + if (rc < 0) + dev_err(chip->dev, "Config manual freq failed, rc=%d\n", rc); + rc = haptics_set_manual_rc_clk_cal(chip); + if (rc < 0) + dev_err(chip->dev, "Config manual cal count failed, rc=%d\n", rc); + } + } + } + +continue_on: return 0; remove_v_gain_error: class_remove_file(&chip->hap_class, &class_attr_v_gain_error); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index a62999d1f..cd13df344 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -2183,7 +2183,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) * to 5-10sec worth of reprogramming the context bank, while * the system appears to be locked up to the user. */ - pm_runtime_set_autosuspend_delay(smmu->dev, 20); + pm_runtime_set_autosuspend_delay(smmu->dev, 15); pm_runtime_use_autosuspend(smmu->dev); rpm_put: diff --git a/drivers/mailbox/qcom-ipcc.c b/drivers/mailbox/qcom-ipcc.c index 347d40c7b..2933a07fd 100644 --- a/drivers/mailbox/qcom-ipcc.c +++ b/drivers/mailbox/qcom-ipcc.c @@ -154,6 +154,12 @@ static int qcom_ipcc_mbox_send_data(struct mbox_chan *chan, void *data) hwirq = qcom_ipcc_get_hwirq(mchan->client_id, mchan->signal_id); writel(hwirq, ipcc->base + IPCC_REG_SEND_ID); + /* All data writes need to be flushed to memory before the write index + * is updated. This protects against a race condition where the remote + * reads stale data because the write index was written before the data. + */ + wmb(); + return 0; } diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 1ca47b3c3..3de7b0c93 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -35,10 +35,13 @@ #include +#include +#include #include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #include "cqhci.h" #include "../core/core.h" +#include "../core/queue.h" #include #define CORE_MCI_VERSION 0x50 @@ -221,6 +224,33 @@ #define SDHCI_CMD_FLAGS_MASK 0xff +/* Copied from mmc/core/block.c to access the request queue */ +struct mmc_blk_data { + struct device *parent; + struct gendisk *disk; + struct mmc_queue queue; + struct list_head part; + struct list_head rpmbs; + + unsigned int flags; + + struct kref kref; + unsigned int read_only; + unsigned int part_type; + unsigned int reset_done; + /* + * Only set in main mmc_blk_data associated + * with mmc_card with dev_set_drvdata, and keeps + * track of the current selected device partition. + */ + unsigned int part_curr; + int area_type; + + /* debugfs files (only in main mmc_blk_data) */ + struct dentry *status_dentry; + struct dentry *ext_csd_dentry; +}; + struct sdhci_msm_offset { u32 core_hc_mode; u32 core_mci_data_cnt; @@ -518,6 +548,7 @@ struct sdhci_msm_host { bool skip_bus_bw_voting; struct sdhci_msm_bus_vote_data *bus_vote_data; struct delayed_work bus_vote_work; + struct delayed_work sdcard_hotplut_work; struct workqueue_struct *workq; /* QoS work queue */ struct sdhci_msm_qos_req *sdhci_qos; struct irq_affinity_notify affinity_notify; @@ -3981,6 +4012,48 @@ static int sdhci_msm_start_signal_voltage_switch(struct mmc_host *mmc, return -EAGAIN; } +static void moto_sdcard_event_work(struct work_struct *work) +{ + struct sdhci_msm_host *msm_host = container_of(work, struct sdhci_msm_host, sdcard_hotplut_work.work); + struct mmc_host *mmc = NULL; + struct mmc_card *card = NULL; + struct mmc_blk_data *md = NULL; + + if ((msm_host != NULL) && (mmc_card_is_removable(msm_host->mmc))) { + mmc = msm_host->mmc; + + if (mmc != NULL) + card = mmc->card; + else + goto done; + + if (card != NULL) + md = dev_get_drvdata(&card->dev); + else + goto done; + + if (md != NULL) { + pr_debug("mmc update the removable card discard sectors to max\n"); + blk_queue_max_discard_sectors(md->queue.queue, UINT_MAX); + } + } +done: + if (msm_host != NULL) + cancel_delayed_work(&msm_host->sdcard_hotplut_work); +} + +static void sdhci_msm_init_card(struct mmc_host *host, + struct mmc_card *card) +{ + struct sdhci_host *sdhci_host = mmc_priv(host); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci_host); + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); + + if (mmc_card_is_removable(host)) { + schedule_delayed_work(&msm_host->sdcard_hotplut_work, msecs_to_jiffies(2*HZ)); + } +} + #define MAX_TEST_BUS 60 #define DRIVER_NAME "sdhci_msm" #define SDHCI_MSM_DUMP(f, x...) \ @@ -5228,6 +5301,8 @@ static int sdhci_msm_probe(struct platform_device *pdev) if (ret) goto pltfm_free; + INIT_DELAYED_WORK(&msm_host->sdcard_hotplut_work, moto_sdcard_event_work); + /* Setup regulators */ ret = sdhci_msm_vreg_init(&pdev->dev, msm_host, true); if (ret) { @@ -5286,6 +5361,7 @@ static int sdhci_msm_probe(struct platform_device *pdev) host->mmc_host_ops.start_signal_voltage_switch = sdhci_msm_start_signal_voltage_switch; host->mmc_host_ops.execute_tuning = sdhci_msm_execute_tuning; + host->mmc_host_ops.init_card = sdhci_msm_init_card; msm_host->workq = create_workqueue("sdhci_msm_generic_swq"); if (!msm_host->workq) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 3923e9c4d..e0439031f 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -42,6 +42,24 @@ #define QUP_MASK GENMASK(5, 0) #define SPARE_MASK GENMASK(15, 8) +#ifdef CONFIG_SUSPEND_DEBUG_MODULE +/** + * extract GPIO pin from bit-field used for gpio_tlmm_config + */ +#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff) +#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf) +#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1) +#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3) +#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf) + +#define GPIO_CFG(gpio, func, dir, pull, drvstr) \ + ((((gpio) & 0x3FF) << 4) | \ + ((func) & 0xf) | \ + (((dir) & 0x1) << 14) | \ + (((pull) & 0x3) << 15) | \ + (((drvstr) & 0xF) << 17)) +#endif + /** * struct msm_pinctrl - state for a pinctrl-msm device * @dev: device handle. @@ -769,6 +787,115 @@ static void msm_gpio_pin_status_get(struct msm_pinctrl *pctrl, const struct msm_ *val = !!(io_reg & BIT(g->in_bit)); } +#ifdef CONFIG_SUSPEND_DEBUG_MODULE +int tlmm_get_inout(unsigned gpio) +{ + const struct msm_pingroup *g; + u32 val; + + if (msm_pinctrl_data == NULL) + return -ENODEV; + if (gpio >= msm_pinctrl_data->chip.ngpio) + return -ENODEV; + if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio)) + return -EINVAL; + + g = &msm_pinctrl_data->soc->groups[gpio]; + + val = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->io_reg); + return !!(val & BIT(g->in_bit)); +} +EXPORT_SYMBOL_GPL(tlmm_get_inout); + +int tlmm_set_inout(unsigned gpio, unsigned value) +{ + const struct msm_pingroup *g; + unsigned long flags; + u32 val; + + if (msm_pinctrl_data == NULL) + return -ENODEV; + if (gpio >= msm_pinctrl_data->chip.ngpio) + return -ENODEV; + if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio)) + return -EINVAL; + + g = &msm_pinctrl_data->soc->groups[gpio]; + + raw_spin_lock_irqsave(&msm_pinctrl_data->lock, flags); + + val = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->io_reg); + if (value) + val |= BIT(g->out_bit); + else + val &= ~BIT(g->out_bit); + writel_relaxed(val, msm_pinctrl_data->regs[g->tile] + g->io_reg); + + raw_spin_unlock_irqrestore(&msm_pinctrl_data->lock, flags); + return 0; +} +EXPORT_SYMBOL_GPL(tlmm_set_inout); + +int tlmm_get_config(unsigned gpio, unsigned *cfg) +{ + const struct msm_pingroup *g; + u32 ctl_reg; + + if (msm_pinctrl_data == NULL) + return -ENODEV; + if (gpio >= msm_pinctrl_data->chip.ngpio) + return -ENODEV; + if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio)) + return -EINVAL; + + g = &msm_pinctrl_data->soc->groups[gpio]; + ctl_reg = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->ctl_reg); + pr_debug("%s(), %d, ctl_reg=%x\n", __func__, __LINE__, ctl_reg); + + *cfg = GPIO_CFG(gpio, (ctl_reg >> g->mux_bit) & 7, + !!(ctl_reg & BIT(g->oe_bit)), (ctl_reg >> g->pull_bit) & 3, + (ctl_reg >> g->drv_bit) & 7); + + return 0; +} +EXPORT_SYMBOL_GPL(tlmm_get_config); + +int tlmm_set_config(unsigned config) +{ + const struct msm_pingroup *g; + unsigned long flags; + u32 ctl_reg; + u32 val; + unsigned gpio = GPIO_PIN(config); + + pr_debug("%s(), %d, gpio=%d\n", __func__, __LINE__, gpio); + if (msm_pinctrl_data == NULL) + return -ENODEV; + if (gpio >= msm_pinctrl_data->chip.ngpio) + return -ENODEV; + if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio)) + return -EINVAL; + + config = (config & ~0x40000000); + g = &msm_pinctrl_data->soc->groups[gpio]; + ctl_reg = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->ctl_reg); + + pr_debug("%s(), %d, ctl_reg=%x\n", __func__, __LINE__, ctl_reg); + + raw_spin_lock_irqsave(&msm_pinctrl_data->lock, flags); + val = (((GPIO_DIR(config) & 1) << g->oe_bit) | + ((GPIO_DRVSTR(config) & 7) << g->drv_bit) | + ((GPIO_FUNC(config) & 7) << g->mux_bit) | + ((GPIO_PULL(config) & 3) << g->pull_bit)); + pr_debug("%s(), %d, val=%x\n", __func__, __LINE__, val); + writel_relaxed(val, msm_pinctrl_data->regs[g->tile] + g->ctl_reg); + raw_spin_unlock_irqrestore(&msm_pinctrl_data->lock, flags); + return 0; +} +EXPORT_SYMBOL_GPL(tlmm_set_config); +#endif + + #ifdef CONFIG_DEBUG_FS static void msm_gpio_dbg_show_one(struct seq_file *s, diff --git a/drivers/power/reset/qcom-dload-mode.c b/drivers/power/reset/qcom-dload-mode.c index 7772d495a..9be19664c 100644 --- a/drivers/power/reset/qcom-dload-mode.c +++ b/drivers/power/reset/qcom-dload-mode.c @@ -18,6 +18,9 @@ #include #include +static char *sys_restart_mode = "NULL"; +module_param(sys_restart_mode, charp, 0644); + enum qcom_download_dest { QCOM_DOWNLOAD_DEST_UNKNOWN = -1, QCOM_DOWNLOAD_DEST_QPST = 0, @@ -39,10 +42,13 @@ struct qcom_dload { #define QCOM_DOWNLOAD_BOTHDUMP (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP) +#define DUMP_MODE_NAME_LEN 8 + +static char dump_mode_name[DUMP_MODE_NAME_LEN]; static int enable_dump = IS_ENABLED(CONFIG_POWER_RESET_QCOM_DOWNLOAD_MODE_DEFAULT); static enum qcom_download_mode current_download_mode = QCOM_DOWNLOAD_NODUMP; -static enum qcom_download_mode dump_mode = QCOM_DOWNLOAD_FULLDUMP; +static enum qcom_download_mode dump_mode = QCOM_DOWNLOAD_BOTHDUMP; static int set_download_mode(enum qcom_download_mode mode) { @@ -115,6 +121,8 @@ static int param_set_download_mode(const char *val, module_param_call(download_mode, param_set_download_mode, param_get_int, &enable_dump, 0644); +module_param_string(name, dump_mode_name, DUMP_MODE_NAME_LEN, 0644); + /* interface for exporting attributes */ struct reset_attribute { struct attribute attr; @@ -281,11 +289,31 @@ static int qcom_dload_reboot(struct notifier_block *this, unsigned long event, struct qcom_dload *poweroff = container_of(this, struct qcom_dload, reboot_nb); + pr_info("%s: sys_restart_mode [%s]\n", __func__, sys_restart_mode); + if (!strcmp(sys_restart_mode, "panic")) { + /* Trigger a real panic on debug setting */ + BUG(); + } + if (!strcmp(sys_restart_mode, "recovery_panic")) { + if (!strcmp(cmd, "recovery")) { + /* Trigger a real panic on debug setting */ + BUG(); + } + } + + /* Clean shutdown, disable dump mode to allow normal restart */ + if (!poweroff->in_panic) + set_download_mode(QCOM_DOWNLOAD_NODUMP); + poweroff->in_reboot = true; set_download_mode(QCOM_DOWNLOAD_NODUMP); if (cmd) { if (!strcmp(cmd, "edl")) +#if 0 set_download_mode(QCOM_DOWNLOAD_EDL); +#else + pr_err("EDL mode disabled\n"); +#endif else if (!strcmp(cmd, "qcom_dload")) msm_enable_dump_mode(true); } @@ -340,6 +368,16 @@ static int qcom_dload_probe(struct platform_device *pdev) } poweroff->dload_dest_addr = map_prop_mem("qcom,msm-imem-dload-type"); + + if (!strncmp("full", dump_mode_name, DUMP_MODE_NAME_LEN)) + dump_mode = QCOM_DOWNLOAD_FULLDUMP; + else if (!strncmp("mini", dump_mode_name, DUMP_MODE_NAME_LEN)) + dump_mode = QCOM_DOWNLOAD_MINIDUMP; + else if (!strncmp("both", dump_mode_name, DUMP_MODE_NAME_LEN)) + dump_mode = QCOM_DOWNLOAD_BOTHDUMP; + else + dump_mode = QCOM_DOWNLOAD_NODUMP; + msm_enable_dump_mode(enable_dump); dump_mode = qcom_scm_get_download_mode(&temp) ? dump_mode : temp; pr_info("%s: Current dump mode: 0x%x\n", __func__, dump_mode); diff --git a/drivers/power/supply/qti_battery_charger.c b/drivers/power/supply/qti_battery_charger.c index 76dcfaca1..650490627 100644 --- a/drivers/power/supply/qti_battery_charger.c +++ b/drivers/power/supply/qti_battery_charger.c @@ -46,18 +46,29 @@ #define BC_WLS_FW_GET_VERSION 0x44 #define BC_SHUTDOWN_NOTIFY 0x47 #define BC_CHG_CTRL_LIMIT_EN 0x48 +#define BC_WLS_CHECK_CHIP_ID 0x49 #define BC_HBOOST_VMAX_CLAMP_NOTIFY 0x79 #define BC_GENERIC_NOTIFY 0x80 /* Generic definitions */ #define MAX_STR_LEN 128 -#define BC_WAIT_TIME_MS 1000 -#define WLS_FW_PREPARE_TIME_MS 1000 -#define WLS_FW_WAIT_TIME_MS 500 +#define BC_WAIT_TIME_MS 2000 +#define WLS_FW_PREPARE_TIME_MS 2000 +#define WLS_FW_WAIT_TIME_MS 5000 #define WLS_FW_UPDATE_TIME_MS 1000 #define WLS_FW_BUF_SIZE 128 #define DEFAULT_RESTRICT_FCC_UA 1000000 +#define AP_BIN_FW_UPDATE 1 +#define ADSP_FW_UPDATE 2 + +enum usb_connector_type { + USB_CONNECTOR_TYPE_TYPEC, + USB_CONNECTOR_TYPE_MICRO_USB, +}; + +static bool wls_fw_udating = false; + enum psy_type { PSY_TYPE_BATTERY, PSY_TYPE_USB, @@ -101,6 +112,8 @@ enum battery_property_id { BATT_CHG_CTRL_END_THR, BATT_CURR_AVG, BATT_PARALLEL_CELL_COUNT, + BATT_QNS_VOLT_MAX, + BATT_CHG_QNS_CTRL_LIM_MAX, BATT_PROP_MAX, }; @@ -139,6 +152,14 @@ enum wireless_property_id { WLS_PROP_MAX, }; +enum wireless_vendor { + WLS_IDT, + WLS_CPS, + WLS_CPS4019, + WLS_CPS4038 = 0x4038, + WLS_SC9624 = 0x9624, +}; + enum { QTI_POWER_SUPPLY_USB_TYPE_HVDCP = 0x80, QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3, @@ -178,11 +199,17 @@ struct battery_model_resp_msg { char model[MAX_STR_LEN]; }; +struct wireless_check_chip_id { + struct pmic_glink_hdr hdr; + u32 ret_code; +}; + struct wireless_fw_check_req { struct pmic_glink_hdr hdr; u32 fw_version; u32 fw_size; u32 fw_crc; + u32 bin_or_h; }; struct wireless_fw_check_resp { @@ -251,6 +278,7 @@ struct battery_chg_dev { void *notifier_cookie; u32 *thermal_levels; const char *wls_fw_name; + const char *sc_wls_fw_name; int curr_thermal_level; int num_thermal_levels; int shutdown_volt_mv; @@ -264,15 +292,24 @@ struct battery_chg_dev { bool ship_mode_immediate; bool debug_battery_detected; bool wls_fw_update_reqd; + u32 wls_chip_id; u32 wls_fw_version; + u32 wls_fw_vendor; u16 wls_fw_crc; u32 wls_fw_update_time_ms; + int wls_fw_size_min; struct notifier_block reboot_notifier; u32 thermal_fcc_ua; u32 restrict_fcc_ua; u32 last_fcc_ua; u32 usb_icl_ua; u32 thermal_fcc_step; + u32 connector_type; + u32 usb_prev_mode; + u32 tbatt_filter_interval_ms; + u32 tbatt_filter_offset_degree; + int tbatt_filter_save_degree; + bool tbatt_filter_en; bool restrict_chg_en; u8 chg_ctrl_start_thr; u8 chg_ctrl_end_thr; @@ -281,6 +318,7 @@ struct battery_chg_dev { bool initialized; bool notify_en; bool error_prop; + struct power_supply *combo_batt_psy; }; static const int battery_prop_map[BATT_PROP_MAX] = { @@ -362,6 +400,34 @@ int unregister_hboost_event_notifier(struct notifier_block *nb) } EXPORT_SYMBOL(unregister_hboost_event_notifier); +static bool jiffies_timer_expire(struct battery_chg_dev *bcdev, bool clear_jiffies) { + unsigned long cur_jiffies = jiffies; + static unsigned long last_jiffies = 0; + unsigned long intr_timeout = msecs_to_jiffies(bcdev->tbatt_filter_interval_ms); + bool ret = false; + + if (!last_jiffies) + last_jiffies = cur_jiffies; + + if (time_after(cur_jiffies, intr_timeout + last_jiffies)) + ret = true; + else + ret = false; + + if (ret) { + pr_err("expire:%dms, curr_jiffies:%dms, last jiffies:%d", + bcdev->tbatt_filter_interval_ms, jiffies_to_msecs(cur_jiffies), jiffies_to_msecs(last_jiffies)); + last_jiffies = cur_jiffies; + + } + + if (clear_jiffies) { + last_jiffies = cur_jiffies; + } + + return ret; +} + static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data, int len) { @@ -369,7 +435,7 @@ static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data, down_read(&bcdev->state_sem); if (atomic_read(&bcdev->state) == PMIC_GLINK_STATE_DOWN) { - pr_debug("glink state is down\n"); + pr_err("glink state is down\n"); up_read(&bcdev->state_sem); return -ENOTCONN; } @@ -381,7 +447,7 @@ static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data, rc = wait_for_completion_timeout(&bcdev->fw_buf_ack, msecs_to_jiffies(WLS_FW_WAIT_TIME_MS)); if (!rc) { - pr_err("Error, timed out sending message\n"); + pr_err("Error, timed out sending message, tims_ms %d\n", WLS_FW_WAIT_TIME_MS); return -ETIMEDOUT; } @@ -450,6 +516,11 @@ static int write_property_id(struct battery_chg_dev *bcdev, { struct battery_charger_req_msg req_msg = { { 0 } }; + if (wls_fw_udating) { + pr_debug("wireless doing fw update, refuse to write_property_id"); + return -ETIMEDOUT; + } + req_msg.property_id = prop_id; req_msg.battery_id = 0; req_msg.value = val; @@ -469,6 +540,11 @@ static int read_property_id(struct battery_chg_dev *bcdev, { struct battery_charger_req_msg req_msg = { { 0 } }; + if (wls_fw_udating && prop_id != USB_ADAP_TYPE) { + pr_debug("wireless doing fw update, refuse to read_property_id"); + return -ETIMEDOUT; + } + req_msg.property_id = prop_id; req_msg.battery_id = 0; req_msg.value = 0; @@ -774,6 +850,16 @@ static void handle_message(struct battery_chg_dev *bcdev, void *data, len); } break; + case BC_WLS_CHECK_CHIP_ID: + if (len == sizeof(*fw_check_msg)) { + fw_check_msg = data; + bcdev->wls_chip_id = fw_check_msg->ret_code; + ack_set = true; + } else { + pr_err("Incorrect response length %zu for wls_fw_check_update\n", + len); + } + break; default: pr_err("Unknown opcode: %u\n", resp_msg->hdr.opcode); break; @@ -990,8 +1076,18 @@ static int wls_psy_get_prop(struct power_supply *psy, return prop_id; rc = read_property_id(bcdev, pst, prop_id); +#ifdef QCOM_BASE if (rc < 0) return rc; +#else + if (rc == -ETIMEDOUT) { + pr_debug("read prop:%d timeout, use old prop value\n", prop_id); + rc = 0; + } else if (rc < 0) { + pr_err("read prop:%d error, rc = %d", prop_id, rc); + return rc; + } +#endif pval->intval = pst->prop[prop_id]; @@ -1121,8 +1217,18 @@ static int usb_psy_get_prop(struct power_supply *psy, return prop_id; rc = read_property_id(bcdev, pst, prop_id); +#ifdef QCOM_BASE if (rc < 0) return rc; +#else + if (rc == -ETIMEDOUT) { + pr_debug("read prop:%d timeout, use old prop value\n", prop_id); + rc = 0; + } else if (rc < 0) { + pr_err("read prop:%d error, rc = %d", prop_id, rc); + return rc; + } +#endif pval->intval = pst->prop[prop_id]; if (prop == POWER_SUPPLY_PROP_TEMP) @@ -1334,7 +1440,7 @@ static int __battery_psy_set_charge_current(struct battery_chg_dev *bcdev, static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, int val) { - int rc; + int rc = 0; u32 fcc_ua, prev_fcc_ua; if (!bcdev->num_thermal_levels) @@ -1357,11 +1463,74 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, prev_fcc_ua = bcdev->thermal_fcc_ua; bcdev->thermal_fcc_ua = fcc_ua; - rc = __battery_psy_set_charge_current(bcdev, fcc_ua); - if (!rc) - bcdev->curr_thermal_level = val; - else - bcdev->thermal_fcc_ua = prev_fcc_ua; + if (prev_fcc_ua != bcdev->thermal_fcc_ua) { + rc = __battery_psy_set_charge_current(bcdev, fcc_ua); + if (!rc) + bcdev->curr_thermal_level = val; + else + bcdev->thermal_fcc_ua = prev_fcc_ua; + } + + return rc; +} + +static int battery_psy_set_cycle_count(struct battery_chg_dev *bcdev, + int CycleCount) +{ + int rc; + + rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], + BATT_CYCLE_COUNT, CycleCount); + if (rc < 0) { + pr_err("Failed to set cycle count %d, rc=%d\n", CycleCount, rc); + } else { + pr_err("Set CycleCount to %d\n", CycleCount); + } + + return rc; +} +static int tbatt_filter_handler(struct battery_chg_dev *bcdev, int batt_temp) +{ + int ret = batt_temp; + if (batt_temp == -400) + return ret; + + if (!bcdev->tbatt_filter_save_degree) { + bcdev->tbatt_filter_save_degree = batt_temp; + jiffies_timer_expire(bcdev, true); + ret = batt_temp; + } else { + if (abs(bcdev->tbatt_filter_save_degree - batt_temp) > bcdev->tbatt_filter_offset_degree && + !jiffies_timer_expire(bcdev, false)) { + ret = bcdev->tbatt_filter_save_degree; + pr_err("fliter out tbatt: %d, report last temp %d\n", batt_temp, bcdev->tbatt_filter_save_degree); + } else { + jiffies_timer_expire(bcdev, true); + ret = batt_temp; + bcdev->tbatt_filter_save_degree = batt_temp; + } + } + return ret; +} + +static int battery_psy_set_battery_fv(struct battery_chg_dev *bcdev, int val) +{ + int rc; + rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], + BATT_QNS_VOLT_MAX, val); + if (rc < 0) + pr_err("%s:%d failed to write property", __func__, __LINE__); + + return rc; +} + +static int battery_psy_set_battery_fcc(struct battery_chg_dev *bcdev, int val) +{ + int rc; + rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], + BATT_CHG_QNS_CTRL_LIM_MAX, val); + if (rc < 0) + pr_err("%s:%d failed to write property", __func__, __LINE__); return rc; } @@ -1388,8 +1557,18 @@ static int battery_psy_get_prop(struct power_supply *psy, return prop_id; rc = read_property_id(bcdev, pst, prop_id); +#ifdef QCOM_BASE if (rc < 0) return rc; +#else + if (rc == -ETIMEDOUT) { + pr_err("read prop:%d timeout, use old prop value\n", prop_id); + rc = 0; + } else if (rc < 0) { + pr_err("read prop:%d error, rc = %d", prop_id, rc); + return rc; + } +#endif switch (prop) { case POWER_SUPPLY_PROP_MODEL_NAME: @@ -1397,13 +1576,41 @@ static int battery_psy_get_prop(struct power_supply *psy, break; case POWER_SUPPLY_PROP_CAPACITY: pval->intval = DIV_ROUND_CLOSEST(pst->prop[prop_id], 100); + if (bcdev->combo_batt_psy) { + power_supply_get_property(bcdev->combo_batt_psy, + prop, pval); + } if (IS_ENABLED(CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG) && (bcdev->fake_soc >= 0 && bcdev->fake_soc <= 100)) pval->intval = bcdev->fake_soc; break; case POWER_SUPPLY_PROP_TEMP: - pval->intval = DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10); + if (bcdev->tbatt_filter_en) { + pval->intval = tbatt_filter_handler(bcdev, DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10)); + } else { + pval->intval = DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10); + } break; + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT: + pval->intval = bcdev->curr_thermal_level; + break; + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX: + pval->intval = bcdev->num_thermal_levels; + break; + case POWER_SUPPLY_PROP_STATUS: + case POWER_SUPPLY_PROP_CURRENT_NOW: + case POWER_SUPPLY_PROP_CHARGE_FULL: + case POWER_SUPPLY_PROP_CHARGE_COUNTER: + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: + if (bcdev->combo_batt_psy) { + pval->intval = pst->prop[prop_id]; + power_supply_get_property(bcdev->combo_batt_psy, + prop, pval); + break; + } else { + pval->intval = pst->prop[prop_id]; + break; + } default: pval->intval = pst->prop[prop_id]; break; @@ -1425,6 +1632,14 @@ static int battery_psy_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD: return battery_psy_set_charge_end_threshold(bcdev, pval->intval); + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT: + return battery_psy_set_charge_current(bcdev, pval->intval); + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + return battery_psy_set_battery_fv(bcdev, pval->intval); + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX: + return battery_psy_set_battery_fcc(bcdev, pval->intval); + case POWER_SUPPLY_PROP_CYCLE_COUNT: + return battery_psy_set_cycle_count(bcdev, pval->intval); default: return -EINVAL; } @@ -1438,6 +1653,10 @@ static int battery_psy_prop_is_writeable(struct power_supply *psy, switch (prop) { case POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD: case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD: + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT: + case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX: + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + case POWER_SUPPLY_PROP_CYCLE_COUNT: return 1; default: break; @@ -1520,6 +1739,18 @@ static int battery_chg_init_psy(struct battery_chg_dev *bcdev) return rc; } + if (of_find_property(bcdev->dev->of_node, "mmi,combo-batt-psy", NULL)) { + bcdev->combo_batt_psy = devm_power_supply_get_by_phandle( + bcdev->dev, + "mmi,combo-batt-psy"); + if (IS_ERR_OR_NULL(bcdev->combo_batt_psy)) { + pr_err("Couldn't get the combo-batt-psy\n"); + if (!bcdev->combo_batt_psy) + return -ENODEV; + else + return PTR_ERR(bcdev->combo_batt_psy); + } + } return 0; } @@ -1580,7 +1811,7 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev, msg.fw_chunk_id = i + 1; memcpy(msg.buf, ptr, WLS_FW_BUF_SIZE); - pr_debug("sending FW chunk %u\n", i + 1); + pr_info("sending FW chunk %u\n", i + 1); rc = battery_chg_fw_write(bcdev, &msg, sizeof(msg)); if (rc < 0) return rc; @@ -1591,7 +1822,7 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev, memset(msg.buf, 0, WLS_FW_BUF_SIZE); memcpy(msg.buf, ptr, partial_chunk_size); - pr_debug("sending partial FW chunk %u\n", i + 1); + pr_info("sending partial FW chunk %u\n", i + 1); rc = battery_chg_fw_write(bcdev, &msg, sizeof(msg)); if (rc < 0) return rc; @@ -1600,8 +1831,22 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev, return 0; } +static int wireless_check_chip_id(struct battery_chg_dev *bcdev) +{ + struct wireless_check_chip_id req_msg = {}; + + bcdev->wls_chip_id = 0x0000; + + req_msg.hdr.owner = MSG_OWNER_BC; + req_msg.hdr.type = MSG_TYPE_REQ_RESP; + req_msg.hdr.opcode = BC_WLS_CHECK_CHIP_ID; + req_msg.ret_code = 0; + + return battery_chg_write(bcdev, &req_msg, sizeof(req_msg)); +} + static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev, - u32 version, size_t size) + u32 version, size_t size, u32 bin_or_h) { struct wireless_fw_check_req req_msg = {}; @@ -1613,6 +1858,7 @@ static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev, req_msg.fw_version = version; req_msg.fw_size = size; req_msg.fw_crc = bcdev->wls_fw_crc; + req_msg.bin_or_h = bin_or_h; return battery_chg_write(bcdev, &req_msg, sizeof(req_msg)); } @@ -1621,15 +1867,23 @@ static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev, #define IDT9415_FW_MINOR_VER_OFFSET 0x86 #define IDT_FW_MAJOR_VER_OFFSET 0x94 #define IDT_FW_MINOR_VER_OFFSET 0x96 -static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force) +#define CPS_FW_MAJOR_VER_OFFSET 0xc4 +#define CPS_FW_MINOR_VER_OFFSET 0xc5 +#define CPS4019_FW_MAJOR_VER_OFFSET1 0xc4 +#define CPS4019_FW_MAJOR_VER_OFFSET2 0xc5 +#define CPS4019_FW_MINOR_VER_OFFSET1 0xc6 +#define CPS4019_FW_MINOR_VER_OFFSET2 0xc7 +#define SC9624_FW_VER_OFFSET 0x104 + +static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force, int bin_or_h) { const struct firmware *fw; struct psy_state *pst; - u32 version; - u16 maj_ver, min_ver; + u32 version = 0; + u16 maj_ver, min_ver, maj_ver1, maj_ver2, min_ver1, min_ver2; int rc; - if (!bcdev->wls_fw_name) { + if (!bcdev->wls_fw_name && !bcdev->sc_wls_fw_name) { pr_err("wireless FW name is not specified\n"); return -EINVAL; } @@ -1651,17 +1905,94 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force) if (rc < 0) goto out; - if ((pst->prop[BATT_CAPACITY] / 100) < 50) { - pr_err("Battery SOC should be at least 50%% or connect charger\n"); + if ((pst->prop[BATT_CAPACITY] / 100) < 20) { + pr_err("Battery SOC should be at least 20%% or connect charger\n"); rc = -EINVAL; goto out; } } - rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev); - if (rc) { - pr_err("Couldn't get firmware rc=%d\n", rc); - goto out; + if (bcdev->sc_wls_fw_name) + { + rc = wireless_check_chip_id(bcdev); + if (rc) { + pr_err("Couldn't get chip id rc=%d\n", rc); + goto out; + } + + pr_err("wireless chip id = %04x\n", bcdev->wls_chip_id); + if(bcdev->wls_chip_id == WLS_SC9624) { + rc = firmware_request_nowarn(&fw, bcdev->sc_wls_fw_name, bcdev->dev); + if (rc) { + pr_err("Couldn't get southchip firmware rc=%d\n", rc); + goto out; + } + // version = min_ver << 16 | maj_ver; + version = *(u32 *)&fw->data[SC9624_FW_VER_OFFSET]; + pr_info("southchip fw version: %08x\n", version); + } else{ + rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev); + if (rc) { + pr_err("Couldn't get southchip firmware rc=%d\n", rc); + goto out; + } + if (bcdev->wls_fw_vendor == WLS_CPS4019) { + maj_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET1)); + maj_ver = maj_ver1 >> 8; + maj_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET2)); + maj_ver2 = maj_ver2 & 0xFF00; + maj_ver = maj_ver + maj_ver2; + min_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET1)); + min_ver = min_ver1 >> 8; + min_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET2)); + min_ver2 = min_ver2 & 0xFF00; + min_ver = min_ver + min_ver2; + pr_info("WLS_CPS 4019 maj_ver %#x, min_ver %#x\n", maj_ver, min_ver); + version = maj_ver << 16 | min_ver; + } else if (bcdev->wls_fw_vendor == WLS_CPS) { + maj_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MAJOR_VER_OFFSET)); + maj_ver = maj_ver >> 8; + min_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MINOR_VER_OFFSET)); + min_ver = min_ver >> 8; + pr_info("WLS_CPS maj_ver %#x, min_ver %#x\n", maj_ver, min_ver); + version = maj_ver << 16 | min_ver; + } else { + maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET)); + min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET)); + version = maj_ver << 16 | min_ver; + } + } + } else { + rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev); + if (rc) { + pr_err("Couldn't get southchip firmware rc=%d\n", rc); + goto out; + } + if (bcdev->wls_fw_vendor == WLS_CPS4019) { + maj_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET1)); + maj_ver = maj_ver1 >> 8; + maj_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET2)); + maj_ver2 = maj_ver2 & 0xFF00; + maj_ver = maj_ver + maj_ver2; + min_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET1)); + min_ver = min_ver1 >> 8; + min_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET2)); + min_ver2 = min_ver2 & 0xFF00; + min_ver = min_ver + min_ver2; + pr_info("WLS_CPS 4019 maj_ver %#x, min_ver %#x\n", maj_ver, min_ver); + version = maj_ver << 16 | min_ver; + } else if (bcdev->wls_fw_vendor == WLS_CPS) { + maj_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MAJOR_VER_OFFSET)); + maj_ver = maj_ver >> 8; + min_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MINOR_VER_OFFSET)); + min_ver = min_ver >> 8; + pr_info("WLS_CPS maj_ver %#x, min_ver %#x\n", maj_ver, min_ver); + version = maj_ver << 16 | min_ver; + } else { + maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET)); + min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET)); + version = maj_ver << 16 | min_ver; + } } if (!fw || !fw->data || !fw->size) { @@ -1670,32 +2001,24 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force) goto release_fw; } - if (fw->size < SZ_16K) { - pr_err("Invalid firmware size %zu\n", fw->size); + if (fw->size < bcdev->wls_fw_size_min) { + pr_err("Invalid firmware size (%zu < %d)\n", fw->size, bcdev->wls_fw_size_min); rc = -EINVAL; goto release_fw; } - if (strstr(bcdev->wls_fw_name, "9412")) { - maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET)); - min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET)); - } else { - maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT9415_FW_MAJOR_VER_OFFSET)); - min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT9415_FW_MINOR_VER_OFFSET)); - } - version = maj_ver << 16 | min_ver; - if (force) version = UINT_MAX; - pr_debug("FW size: %zu version: %#x\n", fw->size, version); - - rc = wireless_fw_check_for_update(bcdev, version, fw->size); + pr_info("FW size: %zu version: %#x bin_or_h:%x\n", fw->size, version, bin_or_h); + rc = wireless_fw_check_for_update(bcdev, version, fw->size, bin_or_h); if (rc < 0) { pr_err("Wireless FW update not needed, rc=%d\n", rc); goto release_fw; } + pr_info("southchip %d\n", bcdev->wls_fw_update_reqd); + if (!bcdev->wls_fw_update_reqd) { pr_warn("Wireless FW update not required\n"); goto release_fw; @@ -1703,13 +2026,17 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force) /* Wait for IDT to be setup by charger firmware */ msleep(WLS_FW_PREPARE_TIME_MS); - + wls_fw_udating = true; reinit_completion(&bcdev->fw_update_ack); + if(bin_or_h == 1) { //bin send from AP to ADSP rc = wireless_fw_send_firmware(bcdev, fw); if (rc < 0) { pr_err("Failed to send FW chunk, rc=%d\n", rc); goto release_fw; } + } else if(bin_or_h == 2) { + bcdev->wls_fw_update_time_ms = 40*1000;//40s + } pr_debug("Waiting for fw_update_ack\n"); rc = wait_for_completion_timeout(&bcdev->fw_update_ack, @@ -1731,7 +2058,7 @@ release_fw: release_firmware(fw); out: pm_relax(bcdev->dev); - + wls_fw_udating = false; return rc; } @@ -1798,19 +2125,24 @@ static ssize_t wireless_fw_version_show(const struct class *c, } static CLASS_ATTR_RO(wireless_fw_version); + static ssize_t wireless_fw_force_update_store(const struct class *c, const struct class_attribute *attr, const char *buf, size_t count) { struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, battery_class); - bool val; + int val; int rc; - if (kstrtobool(buf, &val) || !val) - return -EINVAL; - rc = wireless_fw_update(bcdev, true); + if (kstrtoint(buf, 0, &val) || + (val != AP_BIN_FW_UPDATE && val != ADSP_FW_UPDATE)) { + pr_err("%s: invalid FW update mode %d\n", __func__, val); + return -EINVAL; + } + + rc = wireless_fw_update(bcdev, true, val); //force update if (rc < 0) return rc; @@ -1824,13 +2156,16 @@ static ssize_t wireless_fw_update_store(const struct class *c, { struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, battery_class); - bool val; + int val; int rc; - if (kstrtobool(buf, &val) || !val) - return -EINVAL; + if (kstrtoint(buf, 0, &val) || + (val != AP_BIN_FW_UPDATE && val != ADSP_FW_UPDATE)) { + pr_err("%s: invalid FW update mode %d\n", __func__, val); + return -EINVAL; + } - rc = wireless_fw_update(bcdev, false); + rc = wireless_fw_update(bcdev, false, val); if (rc < 0) return rc; @@ -2293,13 +2628,42 @@ static int battery_chg_parse_dt(struct battery_chg_dev *bcdev) int i, rc, len; u32 prev, val; + bcdev->tbatt_filter_en = of_property_read_bool(node, "qcom,tbatt-filter-en"); + + rc = of_property_read_u32(node, "qcom,tbatt-filter-interval-ms", + &bcdev->tbatt_filter_interval_ms); + if (rc < 0) { + bcdev->tbatt_filter_interval_ms = 5000; + } + + rc = of_property_read_u32(node, "qcom,tbatt-filter-offset-degree", + &bcdev->tbatt_filter_offset_degree); + if (rc < 0) { + bcdev->tbatt_filter_offset_degree = 50; + } + of_property_read_string(node, "qcom,wireless-fw-name", &bcdev->wls_fw_name); + of_property_read_string(node, "qcom,wireless-fw-name-sc", + &bcdev->sc_wls_fw_name); + of_property_read_u32(node, "qcom,shutdown-voltage", &bcdev->shutdown_volt_mv); bcdev->ship_mode_immediate = of_property_read_bool(node, "qcom,ship-mode-immediate"); + rc = of_property_read_u32(node, "qcom,wireless-fw-size_min", + &bcdev->wls_fw_size_min); + if (rc < 0) { + bcdev->wls_fw_size_min = SZ_16K; + pr_info("%s fw size min do not defined, use 16k as default (%d)\n", + __func__, bcdev->wls_fw_size_min); + } + + if (bcdev->wls_fw_name && strstr(bcdev->wls_fw_name, "cps4019")) + bcdev->wls_fw_vendor = WLS_CPS4019; + else if (bcdev->wls_fw_name && strstr(bcdev->wls_fw_name, "cps")) + bcdev->wls_fw_vendor = WLS_CPS; rc = read_property_id(bcdev, pst, BATT_CHG_CTRL_LIM_MAX); if (rc < 0) { diff --git a/drivers/regulator/debug-regulator.c b/drivers/regulator/debug-regulator.c index ee5f56ccf..396d734f6 100644 --- a/drivers/regulator/debug-regulator.c +++ b/drivers/regulator/debug-regulator.c @@ -591,6 +591,156 @@ void devm_regulator_debug_unregister(struct regulator_dev *rdev) } EXPORT_SYMBOL(devm_regulator_debug_unregister); +#ifdef CONFIG_SUSPEND_DEBUG_MODULE +/* Add for vreg debug */ +#define VREG_NUM_MAX 100 + +struct regulator_dump { + char *buf; + int pos; + int id; +}; + +int _vreg_dump_info(struct regulator_dev *rdev, void *data) +{ + struct regulator_dump *dump = data; + const struct regulator_ops *ops = rdev->desc->ops; + unsigned on, mv; + char *p = dump->buf + dump->pos; + + p += snprintf(p, PAGE_SIZE, "[%2d]%s: ", + dump->id++, rdev->desc->name); + + on = mv = 0; + + if (ops->is_enabled) + on = ops->is_enabled(rdev); + if (ops->get_voltage) + mv = ops->get_voltage(rdev) / 1000; + + p += snprintf(p, PAGE_SIZE, "%s ", on ? "on " : "off"); + p += snprintf(p, PAGE_SIZE, "%4d mv ", mv); + p += snprintf(p, PAGE_SIZE, "\n"); + + dump->pos = p - dump->buf; + return 0; +} + +int vreg_dump_info(char *buf) +{ + struct debug_regulator *dreg; + struct regulator_dump data; + + data.buf = buf; + data.pos = 0; + data.id = 0; + + list_for_each_entry(dreg, &debug_reg_list, list) + _vreg_dump_info(dreg->rdev, &data); + + return data.pos; +} +EXPORT_SYMBOL_GPL(vreg_dump_info); + +/* save vreg config before sleep */ +static unsigned before_sleep_fetched; +static unsigned before_sleep_configs[VREG_NUM_MAX]; +int _vreg_before_sleep_save_configs(struct regulator_dev *rdev, void *data) +{ + struct regulator_dump *dump = data; + const struct regulator_ops *ops = rdev->desc->ops; + unsigned on, mv; + + if (dump->id >= VREG_NUM_MAX) + return -EINVAL; + + on = mv = 0; + + if (ops->is_enabled) + on = ops->is_enabled(rdev); + if (ops->get_voltage) + mv = ops->get_voltage(rdev) / 1000; + + before_sleep_configs[dump->id++] = mv | (on << 31); + return 0; +} + +void vreg_before_sleep_save_configs(void) +{ + struct debug_regulator *dreg; + struct regulator_dump data; + + /* only save vreg configs when it has been fetched */ + if (!before_sleep_fetched) + return; + + pr_debug("%s(), before_sleep_fetched=%d\n", + __func__, before_sleep_fetched); + + data.buf = NULL; + data.pos = 0; + data.id = 0; + + list_for_each_entry(dreg, &debug_reg_list, list) + _vreg_before_sleep_save_configs(dreg->rdev, &data); + + before_sleep_fetched = false; +} +EXPORT_SYMBOL_GPL(vreg_before_sleep_save_configs); + +int _vreg_before_sleep_dump_info(struct regulator_dev *rdev, void *data) +{ + struct regulator_dump *dump = data; + char *p = dump->buf + dump->pos; + unsigned on, mv; + + if (dump->id >= VREG_NUM_MAX) + return -EINVAL; + + p += snprintf(p, PAGE_SIZE, "[%2d]%s: ", + dump->id, rdev->desc->name); + + mv = before_sleep_configs[dump->id]; + on = (mv & 0x80000000) >> 31; + mv &= ~0x80000000; + + p += snprintf(p, PAGE_SIZE, "%s ", on ? "on " : "off"); + p += snprintf(p, PAGE_SIZE, "%4d mv ", mv); + p += snprintf(p, PAGE_SIZE, "\n"); + + dump->id++; + dump->pos = p - dump->buf; + return 0; +} + +int vreg_before_sleep_dump_info(char *buf) +{ + struct debug_regulator *dreg; + struct regulator_dump data; + char *p = buf; + + data.buf = p; + data.pos = 0; + data.id = 0; + + p += snprintf(p, PAGE_SIZE, "vreg_before_sleep:\n"); + data.pos = p - data.buf; + + pr_debug("%s(), before_sleep_fetched=%d\n", + __func__, before_sleep_fetched); + + if (!before_sleep_fetched) { + list_for_each_entry(dreg, &debug_reg_list, list) + _vreg_before_sleep_dump_info(dreg->rdev, &data); + + before_sleep_fetched = true; + } + + return data.pos; +} +EXPORT_SYMBOL_GPL(vreg_before_sleep_dump_info); +#endif + static int _regulator_is_enabled(struct regulator_dev *rdev) { if (rdev->ena_pin) diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c index 816e64e6f..563085ae5 100644 --- a/drivers/remoteproc/qcom_q6v5.c +++ b/drivers/remoteproc/qcom_q6v5.c @@ -26,6 +26,10 @@ #define Q6V5_LOAD_STATE_MSG_LEN 64 #define Q6V5_PANIC_DELAY_MS 200 +static char qcom_ssr_reason[256]; +static char *ssr_reason = qcom_ssr_reason; +module_param(ssr_reason, charp, S_IRUGO); + static int q6v5_load_state_toggle(struct qcom_q6v5 *q6v5, bool enable) { int ret; @@ -171,6 +175,8 @@ static irqreturn_t q6v5_wdog_interrupt(int irq, void *data) q6v5->running = false; trace_rproc_qcom_event(dev_name(q6v5->dev), "q6v5_wdog", msg); + memset(qcom_ssr_reason, 0, sizeof(qcom_ssr_reason)); + strlcpy(qcom_ssr_reason, msg, min((size_t)len, (size_t)sizeof(qcom_ssr_reason))); if (q6v5->ssr_subdev) qcom_notify_early_ssr_clients(q6v5->ssr_subdev); @@ -202,7 +208,8 @@ static irqreturn_t q6v5_fatal_interrupt(int irq, void *data) dev_err(q6v5->dev, "fatal error received: %s\n", msg); else dev_err(q6v5->dev, "fatal error without message\n"); - + memset(qcom_ssr_reason, 0, sizeof(qcom_ssr_reason)); + strlcpy(qcom_ssr_reason, msg, min((size_t)len, (size_t)sizeof(qcom_ssr_reason))); if (q6v5->crash_stack) { msg = qcom_smem_get(q6v5->smem_host_id, q6v5->crash_stack, &len); if (!IS_ERR(msg) && len > 0 && msg[0]) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index fa1c4c90e..ac0be7d38 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -4,6 +4,53 @@ # menu "Qualcomm SoC drivers" +config MMI_DEVICE_DTBS + depends on ARCH_QCOM + default n + bool "Motorola Mobility Device DTBs" + help + Only include Motorola device specific DTBs to limit the number that + get built during kernel completion. + +config PAROS_DTB + depends on MMI_DEVICE_DTBS + default n + bool "Motorola Mobility Paros Device DTBs" + help + Only include Motorola Paros device specific device tree + +config MONA_DTB + depends on MMI_DEVICE_DTBS + default n + bool "Motorola Mobility Mona Device DTBs" + help + Only include Motorola MOna device specific device tree + + +config MONAI_DTB + depends on MMI_DEVICE_DTBS + default n + bool "Motorola Mobility Monai Device DTBs" + help + Only include Motorola Monai device specific device tree + + +config PARO_DTB + depends on MMI_DEVICE_DTBS + default n + bool "Motorola Mobility Paro Device DTBs" + help + Only include Motorola Paro device specific device tree + + +config CUSCO_DTB + depends on MMI_DEVICE_DTBS + default n + bool "Motorola Mobility Cusco Device DTB" + help + Only include Motorola Cusco device specific DTB. + + config SPS tristate "SPS support" select GENERIC_ALLOCATOR @@ -600,8 +647,8 @@ config QCOM_WDOG_BITE_EARLY_PANIC config QCOM_WATCHDOG_BARK_TIME depends on QCOM_WDT_CORE int "Qualcomm Technologies, Inc. Watchdog bark time in ms" - default 11000 - range 11000 11000 + default 16000 + range 11000 22000 help The amount of time, in milliseconds, that should elapse after a watchdog timer reset before a bark interrupt is sent from the diff --git a/drivers/soc/qcom/fsa4480-i2c.c b/drivers/soc/qcom/fsa4480-i2c.c index 0dee1386c..1b815e94f 100644 --- a/drivers/soc/qcom/fsa4480-i2c.c +++ b/drivers/soc/qcom/fsa4480-i2c.c @@ -12,6 +12,7 @@ #include #include #include +#include #define FSA4480_I2C_NAME "fsa4480-driver" @@ -29,6 +30,8 @@ #define FSA4480_DELAY_L_AGND 0x10 #define FSA4480_RESET 0x1E +static u32 add_fsa4480_reset_probe_value = 0; + struct fsa4480_priv { struct regmap *regmap; struct device *dev; @@ -102,7 +105,7 @@ static int fsa4480_usbc_event_changed(struct notifier_block *nb, if (!dev) return -EINVAL; - dev_dbg(dev, "%s: USB change event received, supply mode %d, usbc mode %d, expected %d\n", + dev_info(dev, "%s: USB change event received, supply mode %d, usbc mode %d, expected %d\n", __func__, acc, fsa_priv->usbc_mode.counter, TYPEC_ACCESSORY_AUDIO); @@ -141,7 +144,7 @@ static int fsa4480_usbc_analog_setup_switches(struct fsa4480_priv *fsa_priv) /* get latest mode again within locked context */ mode = atomic_read(&(fsa_priv->usbc_mode)); - dev_dbg(dev, "%s: setting GPIOs active = %d\n", + dev_info(dev, "%s: setting GPIOs active = %d\n", __func__, mode != TYPEC_ACCESSORY_NONE); switch (mode) { @@ -327,12 +330,20 @@ static void fsa4480_update_reg_defaults(struct regmap *regmap) for (i = 0; i < ARRAY_SIZE(fsa_reg_i2c_defaults); i++) regmap_write(regmap, fsa_reg_i2c_defaults[i].reg, fsa_reg_i2c_defaults[i].val); + + if (add_fsa4480_reset_probe_value) { + regmap_write(regmap, FSA4480_SWITCH_CONTROL, 0x18); + } + } static int fsa4480_probe(struct i2c_client *i2c) { struct fsa4480_priv *fsa_priv; + struct device_node *np = i2c->dev.of_node; int rc = 0; + int ret = 0; + u32 prev_control = 0, prev_enable = 0; fsa_priv = devm_kzalloc(&i2c->dev, sizeof(*fsa_priv), GFP_KERNEL); @@ -341,7 +352,17 @@ static int fsa4480_probe(struct i2c_client *i2c) fsa_priv->dev = &i2c->dev; + ret = of_property_read_u32(np, "add-fsa4480-reset-probe", &add_fsa4480_reset_probe_value); + if (ret) { + dev_err(fsa_priv->dev, "%s get add fsa4480-reset-probe failed,ret = %d\n", __func__, ret); + } + + fsa_priv->regmap = devm_regmap_init_i2c(i2c, &fsa4480_regmap_config); + + dev_info(fsa_priv->dev, "%s add_fsa4480_reset_probe_value = %d\n", __func__, add_fsa4480_reset_probe_value); + + if (IS_ERR_OR_NULL(fsa_priv->regmap)) { dev_err(fsa_priv->dev, "%s: Failed to initialize regmap: %d\n", __func__, rc); @@ -354,6 +375,13 @@ static int fsa4480_probe(struct i2c_client *i2c) } fsa4480_update_reg_defaults(fsa_priv->regmap); + + if (add_fsa4480_reset_probe_value) { + regmap_read(fsa_priv->regmap, FSA4480_SWITCH_CONTROL, &prev_control); + regmap_read(fsa_priv->regmap, FSA4480_SWITCH_SETTINGS, &prev_enable); + dev_info(fsa_priv->dev, "%s default Read control:%u enable:%u \n", __func__, prev_control, prev_enable); + } + devm_regmap_qti_debugfs_register(fsa_priv->dev, fsa_priv->regmap); fsa_priv->ucsi_nb.notifier_call = fsa4480_usbc_event_changed; @@ -395,6 +423,16 @@ static void fsa4480_remove(struct i2c_client *i2c) dev_set_drvdata(&i2c->dev, NULL); } +static void fsa4480_shutdown(struct i2c_client *i2c) +{ + if (add_fsa4480_reset_probe_value) { + struct fsa4480_priv *fsa_priv = + (struct fsa4480_priv *)i2c_get_clientdata(i2c); + regmap_write(fsa_priv->regmap, FSA4480_RESET, 0x01); + dev_info(fsa_priv->dev, "%s write FSA4480 RESET shutdown okay\n", __func__); + } +} + static const struct of_device_id fsa4480_i2c_dt_match[] = { { .compatible = "qcom,fsa4480-i2c", @@ -410,6 +448,7 @@ static struct i2c_driver fsa4480_i2c_driver = { }, .probe = fsa4480_probe, .remove = fsa4480_remove, + .shutdown = fsa4480_shutdown, }; static int __init fsa4480_init(void) diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c index 5708063c5..74de66aeb 100644 --- a/drivers/soc/qcom/qcom_stats.c +++ b/drivers/soc/qcom/qcom_stats.c @@ -99,6 +99,9 @@ struct subsystem_data { u32 smem_item; u32 pid; bool not_present; +#ifdef CONFIG_SUSPEND_DEBUG_MODULE + bool debugfs; +#endif }; static struct subsystem_data subsystems[] = { @@ -724,6 +727,53 @@ int cx_stats_get_ss_vote_info(int ss_count, } EXPORT_SYMBOL_GPL(cx_stats_get_ss_vote_info); +#ifdef CONFIG_SUSPEND_DEBUG_MODULE +static ssize_t print_supsystem_sleep_stats(int i, struct sleep_stats *stat, + const char *name) +{ + static uint64_t prev_duration[ARRAY_SIZE(subsystems)]; + u64 accumulated = stat->accumulated; + uint64_t delta_duration; + /* + * If a subsystem is in sleep when reading the sleep stats adjust + * the accumulated sleep duration to show actual sleep time. + */ + if (stat->last_entered_at > stat->last_exited_at) + accumulated += arch_timer_read_counter() + - stat->last_entered_at; + + delta_duration = accumulated - prev_duration[i]; + prev_duration[i] = accumulated; + return printk("%s:\tAccumulated Duration:0x%llx, %llu.%03llu\n\n", + name, accumulated, delta_duration / 19200000L, delta_duration % 19200000L * 1000 / 19200000L); +} + +ssize_t show_subsystem_sleep_stats(void) +{ + ssize_t length = 0; + int i = 0; + struct subsystem_data *subsystem; + struct sleep_stats *stat; + + for (i = 0; i < ARRAY_SIZE(subsystems); i++) { + subsystem = &subsystems[i]; + if (!subsystem->debugfs) + continue; + + stat = qcom_smem_get(subsystem->pid, subsystem->smem_item, NULL); + if (IS_ERR(stat)) + continue; + + length += print_supsystem_sleep_stats(i, stat, + subsystem->name); + } + + return length; +} + +EXPORT_SYMBOL_GPL(show_subsystem_sleep_stats); +#endif + int ddr_stats_get_change_his(struct ddr_stats_change_his_info *ddr_his_info) { static const char buf[MAX_MSG_LEN] = "{class: misc_debug, res: ddr_his}"; @@ -1042,6 +1092,9 @@ static void qcom_create_subsystem_stat_files(struct dentry *root, for (j = 0; j < ARRAY_SIZE(subsystems); j++) { if (!strcmp(subsystems[j].name, name)) { +#ifdef CONFIG_SUSPEND_DEBUG_MODULE + subsystems[j].debugfs = true; +#endif debugfs_create_file(subsystems[j].name, 0400, root, (void *)&subsystems[j], &qcom_subsystem_sleep_stats_fops); diff --git a/drivers/ufs/host/Kconfig b/drivers/ufs/host/Kconfig index b246ce8f7..4e04841cc 100644 --- a/drivers/ufs/host/Kconfig +++ b/drivers/ufs/host/Kconfig @@ -165,3 +165,45 @@ config SCSI_UFS_CRYPTO_QTI Select this to enable QCOM Hardware Wrapped Key support for the ICE hardware. + +config UFSFEATURE + bool "UFS feature activate" + depends on SCSI_UFSHCD + help + UFS feature activate such as tw, hid and etc. + +config UFSHID + bool "UFS Host Initiated Defrag support" + depends on SCSI_UFSHCD && UFSFEATURE + help + UFS HID Feature Enable + +config UFSHID_POC + bool "UFSHID_POC test" + depends on SCSI_UFSHCD && UFSFEATURE && UFSHID + help + UFS HID POC test + 1. block to enter suspend state + 2. auto_hibern8 enable/disable (HCI) + 3. set flag bDefragOperation + 4. debug msg enable (default : disable) + +config MICRON_UFSHID + tristate "micron Host Initiated Defrag support" + depends on SCSI_UFSHCD && UFSFEATURE && UFSHID + help + Enable Micron HID feature + +config SCSI_SKHID + bool "SKHix UFS Host Initiated Defrag supportr" + depends on SCSI_UFSHCD + help + SKHix UFS HID Feature Enable + +config UFS_LONGSYS_RT_CP_TIMEOUT + bool "Moto fix Longsys UFS CP0 Timeout issue with hooks" + depends on SCSI_UFSHCD + default n + help + Enable on products that use Longsys UFS. + This require Kernel support on mcq vendor hook like in kernel 5.15. \ No newline at end of file diff --git a/drivers/ufs/host/Makefile b/drivers/ufs/host/Makefile index 7eb54b938..3426b4968 100644 --- a/drivers/ufs/host/Makefile +++ b/drivers/ufs/host/Makefile @@ -4,6 +4,10 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210. obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o +ufs-qcom-y += ufs_qcom.o +ufs-qcom-$(CONFIG_UFSFEATURE) += vendor/ufsfeature.o vendor/ufsfeature-mimic.o +ufs-qcom-$(CONFIG_UFSHID) += vendor/ufshid.o +ufs-qcom-$(CONFIG_SCSI_SKHID) += vendor/ufs-manual-gc.o obj-$(CONFIG_SCSI_UFS_CRYPTO_QTI) += ufshcd-crypto-qti.o obj-$(CONFIG_SCSI_UFS_EXYNOS) += ufs-exynos.o obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 28c9b65f8..2b1955012 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -40,6 +40,7 @@ #include +#include #include #include "ufshcd-pltfrm.h" #include @@ -49,6 +50,9 @@ #include #include #include +#if defined(CONFIG_SCSI_SKHID) +char storage_mfrid[32]; +#endif #define MCQ_QCFGPTR_MASK GENMASK(7, 0) #define MCQ_QCFGPTR_UNIT 0x200 @@ -462,6 +466,34 @@ static inline void cancel_dwork_unvote_cpufreq(struct ufs_hba *hba) } } + +#if defined(CONFIG_SCSI_SKHID) +static int get_storage_info(struct ufs_hba *hba) +{ + int ret = 0; + struct property *p; + struct device_node *n; + + memset(storage_mfrid, 0, sizeof(storage_mfrid)); + n = of_find_node_by_path("/chosen/mmi,storage"); + if (n == NULL) { + ret = 1; + goto err; + } + + for_each_property_of_node(n, p) { + if (!strcmp(p->name, "manufacturer") && p->value) + strlcpy(storage_mfrid, (char *)p->value, sizeof(storage_mfrid)); + } + + of_node_put(n); + + dev_info(hba->dev, "manufacturer parsed from choosen is %s\n", storage_mfrid); +err: + return ret; +} +#endif + static int ufs_qcom_get_pwr_dev_param(struct ufs_qcom_dev_params *qcom_param, struct ufs_pa_layer_attr *dev_max, struct ufs_pa_layer_attr *agreed_pwr) @@ -553,6 +585,83 @@ static int ufs_qcom_get_pwr_dev_param(struct ufs_qcom_dev_params *qcom_param, return 0; } +#if defined(CONFIG_UFSFEATURE) +static void ufs_vh_prep_fn(void *data, struct ufs_hba *hba, struct request *rq, + struct ufshcd_lrb *lrbp, int *err) +{ + *err = ufsf_prep_fn(ufs_qcom_get_ufsf(hba), lrbp); +} + +static void ufs_vh_compl_command(void *data, struct ufs_hba *hba, + struct ufshcd_lrb *lrbp) +{ + struct scsi_cmnd *cmd = lrbp->cmd; + int scsi_status, result, ocs; + unsigned long *outstanding_reqs; + unsigned long out_tasks = 0; + unsigned long ongoing_cnt = 0; + int tmp_tag, nr_tag; + + if (!cmd) + return; + + ocs = lrbp->utr_descriptor_ptr->header.ocs & MASK_OCS; + if (ocs != OCS_SUCCESS) + goto check_last_req; + + result = lrbp->ucd_rsp_ptr->header.transaction_code; + if (result != UPIU_TRANSACTION_RESPONSE) + goto check_last_req; + + scsi_status = lrbp->ucd_rsp_ptr->header.status; + if (scsi_status != SAM_STAT_GOOD) + goto check_last_req;; + + ufsf_upiu_check_for_ccd(lrbp); + + outstanding_reqs = &hba->outstanding_reqs; + nr_tag = hba->nutrs; + + for_each_set_bit(tmp_tag, outstanding_reqs, nr_tag) { + ongoing_cnt = 1; + break; + } + + out_tasks = hba->outstanding_tasks; + +check_last_req: +#if defined(CONFIG_UFSHID) + /* Check if it is the last request to be completed */ + if (!out_tasks && !ongoing_cnt) { + struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba); + + schedule_work(&ufsf->on_idle_work); + } +#endif + ; +} +#endif + +#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT) +static void ufs_longsys_clear_cp_flag_hook(void *data, struct ufs_hba *hba, struct ufshcd_lrb *lrbp) +{ + if (!lrbp || !lrbp->ucd_req_ptr || !lrbp->cmd) + return; + + struct request *rq = scsi_cmd_to_rq(lrbp->cmd); + struct ufs_dev_info *dev_info = &hba->dev_info; + unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); + + if (ioprio_class == IOPRIO_CLASS_RT && dev_info->wmanufacturerid == UFS_VENDOR_LONGSYS) { + struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; + + if (ucd_req_ptr->header.flags & UPIU_CMD_FLAGS_CP){ + ucd_req_ptr->header.flags &= ~UPIU_CMD_FLAGS_CP; + } + } +} +#endif + static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd) { return container_of(rcd, struct ufs_qcom_host, rcdev); @@ -2040,8 +2149,12 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op, struct ufs_qcom_host *host = ufshcd_get_variant(hba); int err = 0; - if (status == PRE_CHANGE) + if (status == PRE_CHANGE) { +#if defined(CONFIG_UFSFEATURE) + ufsf_suspend(ufs_qcom_get_ufsf(hba), pm_op == UFS_SYSTEM_PM); +#endif return 0; + } /* * If UniPro link is not active or OFF, PHY ref_clk, main PHY analog @@ -2083,6 +2196,11 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) { struct ufs_qcom_host *host = ufshcd_get_variant(hba); int err; +#if defined(CONFIG_UFSFEATURE) + struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba); + + schedule_work(&ufsf->resume_work); +#endif if (host->vddp_ref_clk && (hba->rpm_lvl > UFS_PM_LVL_3 || hba->spm_lvl > UFS_PM_LVL_3)) @@ -4188,6 +4306,18 @@ static int ufs_qcom_init(struct ufs_hba *hba) ufs_qcom_parse_irq_affinity(hba); ufs_qcom_ber_mon_init(hba); ufs_qcom_storage_boost_param_init(hba); + +#if defined(CONFIG_SCSI_SKHID) + get_storage_info(hba); + if ((IS_SKHYNIX_DEVICE(storage_mfrid)) || (IS_HYNIX_DEVICE(storage_mfrid))) { + err = pixel_init(hba); + if (err) { + return err; + } + pixel_init_manual_gc(hba); + } +#endif + host->ufs_ipc_log_ctx = ipc_log_context_create(UFS_QCOM_MAX_LOG_SZ, "ufs-qcom", 0); if (!host->ufs_ipc_log_ctx) @@ -4629,6 +4759,10 @@ static void ufs_qcom_event_notify(struct ufs_hba *hba, bool ber_th_exceeded = false; bool disable_ber = true; +#if defined(CONFIG_UFSFEATURE) + if (evt == UFS_EVT_WL_SUSP_ERR) + ufsf_resume(ufs_qcom_get_ufsf(hba), true); +#endif switch (evt) { case UFS_EVT_PA_ERR: if (disable_ber) { @@ -5230,6 +5364,9 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba) struct ufs_qcom_host *host = ufshcd_get_variant(hba); int ret = 0; +#if defined(CONFIG_UFSFEATURE) + ufsf_reset_host(ufs_qcom_get_ufsf(hba)); +#endif /* reset gpio is optional */ if (!host->device_reset) return -EOPNOTSUPP; @@ -5319,6 +5456,9 @@ static struct ufs_dev_quirk ufs_qcom_dev_fixups[] = { static void ufs_qcom_fixup_dev_quirks(struct ufs_hba *hba) { ufshcd_fixup_dev_quirks(hba, ufs_qcom_dev_fixups); +#if defined(CONFIG_UFSFEATURE) + ufsf_set_init_state(hba); +#endif } /* Resources */ @@ -5546,6 +5686,16 @@ out: return ret; } +static void ufs_qcom_config_scsi_dev(struct scsi_device *sdev) +{ +#if defined(CONFIG_UFSFEATURE) + struct ufs_hba *hba = shost_priv(sdev->host); + struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba); + + ufsf_slave_configure(ufsf, sdev); +#endif +} + /* * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -5577,8 +5727,24 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .op_runtime_config = ufs_qcom_op_runtime_config, .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs, .config_esi = ufs_qcom_config_esi, + .config_scsi_dev = ufs_qcom_config_scsi_dev, }; +#if defined(CONFIG_UFSFEATURE) +static void ufs_samsung_register_hooks(void) +{ + register_trace_android_vh_ufs_prepare_command(ufs_vh_prep_fn, NULL); + register_trace_android_vh_ufs_compl_command(ufs_vh_compl_command, NULL); +} +#endif + +#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT) +static void ufs_longsys_register_hooks(void) +{ + register_trace_android_vh_ufs_send_command(ufs_longsys_clear_cp_flag_hook, NULL); +} +#endif + /** * QCOM specific sysfs group and nodes */ @@ -6365,6 +6531,14 @@ static int ufs_qcom_probe(struct platform_device *pdev) return dev_err_probe(dev, err, "ufshcd_pltfrm_init() failed\n"); ufs_qcom_register_hooks(); +#if defined(CONFIG_UFSFEATURE) + /* Register hook for Samsung feature */ + ufs_samsung_register_hooks(); +#endif +#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT) + /* Register hook for Longsys feature */ + ufs_longsys_register_hooks(); +#endif return err; } @@ -6401,7 +6575,9 @@ static int ufs_qcom_remove(struct platform_device *pdev) if (msm_minidump_enabled()) atomic_notifier_chain_unregister(&panic_notifier_list, &host->ufs_qcom_panic_nb); - +#if defined(CONFIG_UFSFEATURE) + ufsf_remove(ufs_qcom_get_ufsf(hba)); +#endif ufshcd_remove(hba); if (host->esi_enabled) platform_msi_domain_free_irqs(hba->dev); diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 6e294a813..b73971fe2 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -16,6 +16,17 @@ #include #include +#if defined(CONFIG_UFSFEATURE) +#include "vendor/ufsfeature.h" +#endif +#if defined(CONFIG_SCSI_SKHID) +#include "vendor/ufs-manual-gc.h" +#endif + +#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT) +#define UFS_VENDOR_LONGSYS 0xBD6 +#endif + #define MAX_UFS_QCOM_HOSTS 2 #define MAX_U32 (~(u32)0) #define MPHY_TX_FSM_STATE 0x41 @@ -32,6 +43,22 @@ #define UFS_VENDOR_MICRON 0x12C +#if defined(CONFIG_SCSI_SKHID) +#define IS_SKHYNIX_DEVICE(mfrid) (0 == strncasecmp(mfrid,"SKHYNIX", sizeof("SKHYNIX"))) +#define IS_HYNIX_DEVICE(mfrid) (0 == strncasecmp(mfrid,"HYNIX", sizeof("HYNIX"))) +#endif + +#if defined(CONFIG_UFSFEATURE) || defined(CONFIG_SCSI_SKHID) +#ifndef ufshcd_set_eh_in_progress + /* UFSHCD error handling flags */ + enum { + UFSHCD_EH_IN_PROGRESS = (1 << 0), + }; + #define ufshcd_eh_in_progress(h) \ + ((h)->eh_flags & UFSHCD_EH_IN_PROGRESS) +#endif +#endif + #define SLOW 1 #define FAST 2 @@ -625,6 +652,14 @@ struct ufs_qcom_host { unsigned int boost_monitor_timer; u32 min_boost_thres; u32 max_boost_thres; +#if defined(CONFIG_UFSFEATURE) + struct ufsf_feature ufsf; +#endif +#if defined(CONFIG_SCSI_SKHID) + struct work_struct update_sysfs_work; + /* manual_gc */ + struct ufs_manual_gc manual_gc; +#endif }; static inline u32 @@ -757,4 +792,12 @@ static inline void ufs_qcom_ice_debug(struct ufs_qcom_host *host) } #endif /* !CONFIG_SCSI_UFS_CRYPTO */ +#if defined(CONFIG_UFSFEATURE) +static inline struct ufsf_feature *ufs_qcom_get_ufsf(struct ufs_hba *hba) +{ + struct ufs_qcom_host *host = ufshcd_get_variant(hba); + + return &host->ufsf; +} +#endif #endif /* UFS_QCOM_H_ */ diff --git a/drivers/ufs/host/ufs_qcom.c b/drivers/ufs/host/ufs_qcom.c new file mode 120000 index 000000000..5334690d7 --- /dev/null +++ b/drivers/ufs/host/ufs_qcom.c @@ -0,0 +1 @@ +ufs-qcom.c \ No newline at end of file diff --git a/drivers/ufs/host/vendor/ufs-manual-gc.c b/drivers/ufs/host/vendor/ufs-manual-gc.c new file mode 100644 index 000000000..741bbddf0 --- /dev/null +++ b/drivers/ufs/host/vendor/ufs-manual-gc.c @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Pixel-Specific UFS feature support + * + * Copyright 2020 Google LLC + * + * Authors: Jaegeuk Kim + */ + +#include "ufs-qcom.h" +#include + +extern struct workqueue_struct *system_highpri_wq; + +/* for manual gc */ +static ssize_t manual_gc_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + u32 status = MANUAL_GC_OFF; + if (ufs->manual_gc.state == MANUAL_GC_DISABLE) + return scnprintf(buf, PAGE_SIZE, "%s", "disabled\n"); + if (ufs->manual_gc.hagc_support) { + int err; + if (!ufshcd_eh_in_progress(hba)) { + pm_runtime_get_sync(hba->dev); + err = ufshcd_query_attr_retry(hba, + UPIU_QUERY_OPCODE_READ_ATTR, + QUERY_ATTR_IDN_MANUAL_GC_STATUS, 0, 0, &status); + pm_runtime_put_sync(hba->dev); + ufs->manual_gc.hagc_support = err ? false: true; + } + } + if (!ufs->manual_gc.hagc_support) + return scnprintf(buf, PAGE_SIZE, "%s", "bkops\n"); + return scnprintf(buf, PAGE_SIZE, "%s", + status == MANUAL_GC_OFF ? "off\n" : "on\n"); +} + +static int manual_gc_enable(struct ufs_hba *hba, u32 *value) +{ + int ret; + if (ufshcd_eh_in_progress(hba)) + return -EBUSY; + pm_runtime_get_sync(hba->dev); + ret = ufshcd_query_attr_retry(hba, + UPIU_QUERY_OPCODE_WRITE_ATTR, + QUERY_ATTR_IDN_MANUAL_GC_CONT, 0, 0, + value); + pm_runtime_put_sync(hba->dev); + return ret; +} + +static u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) +{ + if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) + return hba->dev_info.wb_dedicated_lu; + return 0; +} + +static ssize_t manual_gc_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + u32 value; + int err = 0; + if (kstrtou32(buf, 0, &value)) + return -EINVAL; + if (value >= MANUAL_GC_MAX) + return -EINVAL; + if (ufshcd_eh_in_progress(hba)) + return -EBUSY; + if (value == MANUAL_GC_DISABLE || value == MANUAL_GC_ENABLE) { + ufs->manual_gc.state = value; + return count; + } + if (ufs->manual_gc.state == MANUAL_GC_DISABLE) + return count; + if (ufs->manual_gc.hagc_support) + ufs->manual_gc.hagc_support = + manual_gc_enable(hba, &value) ? false : true; + pm_runtime_get_sync(hba->dev); + + if (!ufs->manual_gc.hagc_support) { + err = ufshcd_bkops_ctrl(hba, (value == MANUAL_GC_ON) ? + BKOPS_STATUS_NON_CRITICAL: + BKOPS_STATUS_CRITICAL); + if (!hba->auto_bkops_enabled) + err = -EAGAIN; + } + /* flush wb buffer */ + if (hba->dev_info.wspecversion >= 0x0310) { + enum query_opcode opcode = (value == MANUAL_GC_ON) ? + UPIU_QUERY_OPCODE_SET_FLAG: + UPIU_QUERY_OPCODE_CLEAR_FLAG; + u8 index = ufshcd_wb_get_query_index(hba); + + ufshcd_query_flag_retry(hba, opcode, + QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8, + index, NULL); + ufshcd_query_flag_retry(hba, opcode, + QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index, NULL); + } + if (err || hrtimer_active(&ufs->manual_gc.hrtimer)) { + pm_runtime_put_sync(hba->dev); + return count; + } else { + /* pm_runtime_put_sync in delay_ms */ + hrtimer_start(&ufs->manual_gc.hrtimer, + ms_to_ktime(ufs->manual_gc.delay_ms), + HRTIMER_MODE_REL); + } + return count; +} + +/* for manual gc */ +static ssize_t manual_gc_status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + u32 status = MANUAL_GC_OFF; + if (ufs->manual_gc.state == MANUAL_GC_DISABLE) + return scnprintf(buf, PAGE_SIZE, "%s", "disabled\n"); + if (ufs->manual_gc.hagc_support) { + int err; + if (!ufshcd_eh_in_progress(hba)) { + pm_runtime_get_sync(hba->dev); + err = ufshcd_query_attr_retry(hba, + UPIU_QUERY_OPCODE_READ_ATTR, + QUERY_ATTR_IDN_MANUAL_GC_STATUS, 0, 0, &status); + pm_runtime_put_sync(hba->dev); + ufs->manual_gc.hagc_support = err ? false: true; + } + } + if (!ufs->manual_gc.hagc_support) + return scnprintf(buf, PAGE_SIZE, "%s", "bkops\n"); + return scnprintf(buf, PAGE_SIZE, "%u", status); +} + +static ssize_t manual_gc_hold_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + return snprintf(buf, PAGE_SIZE, "%lu\n", ufs->manual_gc.delay_ms); +} + +static ssize_t manual_gc_hold_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + unsigned long value; + if (kstrtoul(buf, 0, &value)) + return -EINVAL; + ufs->manual_gc.delay_ms = value; + return count; +} + +static enum hrtimer_restart pixel_mgc_hrtimer_handler(struct hrtimer *timer) +{ + struct ufs_qcom_host *ufs = container_of(timer, struct ufs_qcom_host, + manual_gc.hrtimer); + queue_work(ufs->manual_gc.mgc_workq, &ufs->manual_gc.hibern8_work); + return HRTIMER_NORESTART; +} + +static void pixel_mgc_hibern8_work(struct work_struct *work) +{ + struct ufs_qcom_host *ufs = container_of(work, struct ufs_qcom_host, + manual_gc.hibern8_work); + pm_runtime_put_sync(ufs->hba->dev); + /* bkops will be disabled when power down */ +} + +void pixel_init_manual_gc(struct ufs_hba *hba) +{ + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + struct ufs_manual_gc *mgc = &ufs->manual_gc; + char wq_name[sizeof("ufs_mgc_hibern8_work") + 5]; + mgc->state = MANUAL_GC_ENABLE; + mgc->hagc_support = true; + mgc->delay_ms = UFSHCD_MANUAL_GC_HOLD_HIBERN8; + + hrtimer_init(&mgc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + mgc->hrtimer.function = pixel_mgc_hrtimer_handler; + + INIT_WORK(&mgc->hibern8_work, pixel_mgc_hibern8_work); + snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_mgc_hibern8_work_%d", + hba->host->host_no); + ufs->manual_gc.mgc_workq = create_singlethread_workqueue(wq_name); +} + +static DEVICE_ATTR_RW(manual_gc); +static DEVICE_ATTR_RO(manual_gc_status); +static DEVICE_ATTR_RW(manual_gc_hold); + +static struct attribute *pixel_sysfs_ufshcd_attrs[] = { + &dev_attr_manual_gc.attr, + &dev_attr_manual_gc_hold.attr, + NULL +}; + +static struct attribute *pixel_sysfs_ufshcd_hagc_status_attrs[] = { + &dev_attr_manual_gc_status.attr, + NULL +}; + +static const struct attribute_group pixel_sysfs_hagc_status_group = { + .name = "attributes_hid", + .attrs = pixel_sysfs_ufshcd_hagc_status_attrs, +}; + +static const struct attribute_group pixel_sysfs_default_group = { + .attrs = pixel_sysfs_ufshcd_attrs, +}; + +static const struct attribute_group *pixel_sysfs_hid_groups[] = { + &pixel_sysfs_default_group, + &pixel_sysfs_hagc_status_group, + NULL, +}; + + +static void pixel_ufs_update_sysfs_work(struct work_struct *work) +{ + struct ufs_qcom_host *ufs = container_of(work, struct ufs_qcom_host, + update_sysfs_work); + struct ufs_hba *hba = ufs->hba; + int err; + err = sysfs_create_groups(&hba->dev->kobj, + pixel_sysfs_hid_groups); + if (err) + dev_err(hba->dev, "%s: Failed to add a pixel group\n", + __func__); +} + +static void pixel_ufs_update_sysfs(void *data, struct ufs_hba *hba) +{ + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + queue_work(system_highpri_wq, &ufs->update_sysfs_work); +} + +int pixel_init(struct ufs_hba *hba) +{ + struct ufs_qcom_host *ufs = ufshcd_get_variant(hba); + int ret; + ret = register_trace_android_vh_ufs_update_sysfs( + pixel_ufs_update_sysfs, NULL); + if (ret) + return ret; + INIT_WORK(&ufs->update_sysfs_work, pixel_ufs_update_sysfs_work); + return 0; +} diff --git a/drivers/ufs/host/vendor/ufs-manual-gc.h b/drivers/ufs/host/vendor/ufs-manual-gc.h new file mode 100644 index 000000000..662544841 --- /dev/null +++ b/drivers/ufs/host/vendor/ufs-manual-gc.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Manual GC support + * + * Copyright 2020 Google LLC + * + * Authors: Jaegeuk Kim + */ + +#ifndef _UFS_MANUAL_GC_H_ +#define _UFS_MANUAL_GC_H_ + +#include +#include + +/* manual gc */ +struct ufs_manual_gc { + int state; + bool hagc_support; + struct hrtimer hrtimer; + unsigned long delay_ms; + struct work_struct hibern8_work; + struct workqueue_struct *mgc_workq; +}; + +#define UFSHCD_MANUAL_GC_HOLD_HIBERN8 2000 /* 2 seconds */ + +#define QUERY_ATTR_IDN_MANUAL_GC_CONT 0x12 +#define QUERY_ATTR_IDN_MANUAL_GC_STATUS 0x13 + +enum { + MANUAL_GC_OFF = 0, + MANUAL_GC_ON, + MANUAL_GC_DISABLE, + MANUAL_GC_ENABLE, + MANUAL_GC_MAX, +}; + +extern void pixel_init_manual_gc(struct ufs_hba *hba); +extern int pixel_init(struct ufs_hba *hba); +#endif diff --git a/drivers/ufs/host/vendor/ufsfeature-mimic.c b/drivers/ufs/host/vendor/ufsfeature-mimic.c new file mode 100644 index 000000000..917a71e97 --- /dev/null +++ b/drivers/ufs/host/vendor/ufsfeature-mimic.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Samsung UFS Feature Mimic for android15-6.6 + * commit 3009510505edcc8a0622b6c99925fb841b5e132e + * Date: Fri Aug 16 14:33:14 2024 +0000 + * + * from + * + * linux/drivers/ufs/core/ufshcd.c + */ + +#include + +void ufsf_scsi_unblock_requests(struct ufs_hba *hba) +{ + if (atomic_dec_and_test(&hba->scsi_block_reqs_cnt)) + scsi_unblock_requests(hba->host); +} + +void ufsf_scsi_block_requests(struct ufs_hba *hba) +{ + if (atomic_inc_return(&hba->scsi_block_reqs_cnt) == 1) + scsi_block_requests(hba->host); +} + +static u32 ufsf_pending_cmds(struct ufs_hba *hba) +{ + const struct scsi_device *sdev; + u32 pending = 0; + + lockdep_assert_held(hba->host->host_lock); + __shost_for_each_device(sdev, hba->host) + pending += sbitmap_weight(&sdev->budget_map); + + return pending; +} + +int ufsf_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us) +{ + unsigned long flags; + int ret = 0; + u32 tm_doorbell; + u32 tr_pending; + bool timeout = false, do_last_check = false; + ktime_t start; + + ufshcd_hold(hba); + spin_lock_irqsave(hba->host->host_lock, flags); + /* + * Wait for all the outstanding tasks/transfer requests. + * Verify by checking the doorbell registers are clear. + */ + start = ktime_get(); + do { + if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) { + ret = -EBUSY; + goto out; + } + + tm_doorbell = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); + tr_pending = ufsf_pending_cmds(hba); + if (!tm_doorbell && !tr_pending) { + timeout = false; + break; + } else if (do_last_check) { + break; + } + + spin_unlock_irqrestore(hba->host->host_lock, flags); + io_schedule_timeout(msecs_to_jiffies(20)); + if (ktime_to_us(ktime_sub(ktime_get(), start)) > + wait_timeout_us) { + timeout = true; + /* + * We might have scheduled out for long time so make + * sure to check if doorbells are cleared by this time + * or not. + */ + do_last_check = true; + } + spin_lock_irqsave(hba->host->host_lock, flags); + } while (tm_doorbell || tr_pending); + + if (timeout) { + dev_err(hba->dev, + "%s: timedout waiting for doorbell to clear (tm=0x%x, tr=0x%x)\n", + __func__, tm_doorbell, tr_pending); + ret = -EBUSY; + } +out: + spin_unlock_irqrestore(hba->host->host_lock, flags); + ufshcd_release(hba); + return ret; +} + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/ufs/host/vendor/ufsfeature.c b/drivers/ufs/host/vendor/ufsfeature.c new file mode 100755 index 000000000..0147a6273 --- /dev/null +++ b/drivers/ufs/host/vendor/ufsfeature.c @@ -0,0 +1,420 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Universal Flash Storage Feature Support + * + * Copyright (C) 2017-2018 Samsung Electronics Co., Ltd. + * + * Authors: + * Yongmyung Lee + * Jinyoung Choi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * See the COPYING file in the top-level directory or visit + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This program is provided "AS IS" and "WITH ALL FAULTS" and + * without warranty of any kind. You are solely responsible for + * determining the appropriateness of using and distributing + * the program and assume all risks associated with your exercise + * of rights with respect to the program, including but not limited + * to infringement of third party rights, the risks and costs of + * program errors, damage to or loss of data, programs or equipment, + * and unavailability or interruption of operations. Under no + * circumstances will the contributor of this Program be liable for + * any damages of any kind arising from your use or distribution of + * this program. + * + * The Linux Foundation chooses to take subject only to the GPLv2 + * license terms, and distributes only under these terms. + */ + +#include "ufsfeature.h" +#include +#include "../core/ufshcd-priv.h" +#include "ufs-qcom.h" + +#if defined(CONFIG_SCSI_SKHID) +extern char storage_mfrid[32]; +#endif + +static int ufsf_read_desc(struct ufs_hba *hba, u8 desc_id, u8 desc_index, + u8 selector, u8 *desc_buf, u32 size) +{ + int err = 0; + + ufshcd_rpm_get_sync(hba); + + err = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, + desc_id, desc_index, selector, + desc_buf, &size); + if (err) + ERR_MSG("reading Device Desc failed. err = %d", err); + + ufshcd_rpm_put_sync(hba); + + return err; +} + +static int ufsf_read_dev_desc(struct ufsf_feature *ufsf) +{ + u8 desc_buf[UFSF_QUERY_DESC_DEVICE_MAX_SIZE]; + int ret; + + ret = ufsf_read_desc(ufsf->hba, QUERY_DESC_IDN_DEVICE, 0, + UFSFEATURE_SELECTOR, desc_buf, + UFSF_QUERY_DESC_DEVICE_MAX_SIZE); + if (ret) + return ret; + + INFO_MSG("device lu count %d", desc_buf[DEVICE_DESC_PARAM_NUM_LU]); + + INFO_MSG("length=%u(0x%x) bSupport=0x%.2x, extend=0x%.2x_%.2x", + desc_buf[DEVICE_DESC_PARAM_LEN], + desc_buf[DEVICE_DESC_PARAM_LEN], + desc_buf[DEVICE_DESC_PARAM_UFS_FEAT], + desc_buf[DEVICE_DESC_PARAM_EX_FEAT_SUP+2], + desc_buf[DEVICE_DESC_PARAM_EX_FEAT_SUP+3]); + + INFO_MSG("samsung extend=0x%.2x_%.2x", + desc_buf[DEVICE_DESC_PARAM_SAMSUNG_SUP+2], + desc_buf[DEVICE_DESC_PARAM_SAMSUNG_SUP+3]); + + INFO_MSG("Driver Feature Version : (%.6X%s)", UFSFEATURE_DD_VER, + UFSFEATURE_DD_VER_POST); + +#if defined(CONFIG_UFSHID) + ufshid_get_dev_info(ufsf, desc_buf); +#endif + return 0; +} + +void ufsf_device_check(struct ufs_hba *hba) +{ + struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba); + + if (ufsf_read_dev_desc(ufsf)) + return; +} + +inline void ufsf_rpm_put_noidle(struct ufs_hba *hba) +{ + pm_runtime_put_noidle(&hba->ufs_device_wlun->sdev_gendev); +} + +#define PRINT_BUF_SIZE 1024 +void ufsf_print_buf(const unsigned char *field, int size) +{ + unsigned char buf[PRINT_BUF_SIZE]; + int count; + int i; + + if (size > PRINT_BUF_SIZE) + size = PRINT_BUF_SIZE; + + count = snprintf(buf, 10, "(0x0000):"); + + for (i = 0; i < size; i++) { + count += snprintf(buf + count, 4, " %02X", field[i]); + + if ((i + 1) % 16 == 0) { + buf[count] = '\n'; + buf[count + 1] = '\0'; + printk(buf); + count = 0; + count += snprintf(buf, 10, "(0x%04X):", i + 1); + } else if ((i + 1) % 4 == 0) + count += snprintf(buf + count, 3, " :"); + } + buf[count] = '\n'; + buf[count + 1] = '\0'; + printk(buf); +} + +/* + * Mimic ufshcd_copy_sense_data() + */ +#define UFS_SENSE_SIZE 18 +static inline void ufsf_copy_sense_data(struct ufshcd_lrb *lrbp) +{ + u8 *const sense_buffer = lrbp->cmd->sense_buffer; + u16 resp_len; + int len; + + resp_len = be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length); + if (sense_buffer && resp_len) { + int len_to_copy; + + len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); + len_to_copy = min_t(int, UFS_SENSE_SIZE, len); + + memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, + len_to_copy); + } +} + +void ufsf_upiu_check_for_ccd(struct ufshcd_lrb *lrbp) +{ + unsigned char *cdb = lrbp->cmd->cmnd; + int data_seg_len, sense_data_len; + struct utp_cmd_rsp *sr = &lrbp->ucd_rsp_ptr->sr; + + if (cdb[0] != VENDOR_OP || cdb[1] != VENDOR_CCD) + return; + + data_seg_len = + be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length); + + sense_data_len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); + + if (data_seg_len != CCD_DATA_SEG_LEN || + sense_data_len != CCD_SENSE_DATA_LEN) { + WARN_MSG("CCD info is wrong. so check it."); + WARN_MSG("CCD data_seg_len = %d, sense_data_len %d", + data_seg_len, sense_data_len); + } else { + INFO_MSG("CCD info is correct!!"); + } + + INFO_MSG("sense : %02X %02X %02X %02X %02X %02X\n", + sr->sense_data[0], sr->sense_data[1], sr->sense_data[2], + sr->sense_data[3], sr->sense_data[4], sr->sense_data[5]); + + /* + * sense_len will be not set as Descriptor Type isn't 0x70 + * if not set sense_len, sense will not be able to copy + * in sg_scsi_ioctl() + */ + lrbp->cmd->sense_len = CCD_SENSE_DATA_LEN; + + ufsf_copy_sense_data(lrbp); +} + +inline bool ufsf_is_valid_lun(int lun) +{ + return lun < UFS_UPIU_MAX_GENERAL_LUN; +} + +inline void ufsf_slave_configure(struct ufsf_feature *ufsf, + struct scsi_device *sdev) +{ + if (!ufsf_is_valid_lun(sdev->lun)) + return; + + ufsf->sdev_ufs_lu[sdev->lun] = sdev; + INFO_MSG("lun[%d] sdev(%p) q(%p)", (int)sdev->lun, sdev, + sdev->request_queue); + + if (!ufsf->check_init) + schedule_work(&ufsf->device_check_work); +} + +inline int ufsf_prep_fn(struct ufsf_feature *ufsf, struct ufshcd_lrb *lrbp) +{ + int ret = 0; + + /* This is for READ10_DEBUG (ufs-util) */ + if (get_unaligned_be32(lrbp->cmd->cmnd + 2) == READ10_DEBUG_LBA) { + lrbp->lun = READ10_DEBUG_LUN; + INFO_MSG("Change lun to 0x%X", lrbp->lun); + return ret; + } + + return ret; +} + +/* + * called by ufshcd_vops_device_reset() + */ +inline void ufsf_reset_host(struct ufsf_feature *ufsf) +{ + struct ufs_hba *hba = ufsf->hba; + struct Scsi_Host *host = hba->host; + unsigned long flags; + u32 eh_flags; + + if (!ufsf->check_init) + return; + + /* + * Check if it is error handling(eh) context. + * + * In the following cases, we can enter here even though it is not in eh + * context. + * - when ufshcd_is_link_off() is true in ufshcd_resume() + * - when ufshcd_vops_suspend() fails in ufshcd_suspend() + */ + spin_lock_irqsave(host->host_lock, flags); + eh_flags = ufshcd_eh_in_progress(hba); + spin_unlock_irqrestore(host->host_lock, flags); + if (!eh_flags) + return; + +#if defined(CONFIG_UFSHID) + INFO_MSG("run reset_host.. hid_state(%d) -> HID_RESET", + ufshid_get_state(ufsf)); + if (ufshid_get_state(ufsf) == HID_PRESENT) + ufshid_reset_host(ufsf); +#endif + + schedule_work(&ufsf->reset_wait_work); +} + +inline void ufsf_init(struct ufsf_feature *ufsf) +{ +#if defined(CONFIG_UFSHID) + if (ufshid_get_state(ufsf) == HID_NEED_INIT) + ufshid_init(ufsf); +#endif + + ufsf->check_init = true; +} + +inline void ufsf_reset(struct ufsf_feature *ufsf) +{ +#if defined(CONFIG_UFSHID) + if (ufshid_get_state(ufsf) == HID_RESET) + ufshid_reset(ufsf); +#endif +} + +inline void ufsf_remove(struct ufsf_feature *ufsf) +{ +#if defined(CONFIG_UFSHID) + if (ufshid_get_state(ufsf) == HID_PRESENT) + ufshid_remove(ufsf); +#endif +} + +static void ufsf_device_check_work_handler(struct work_struct *work) +{ + struct ufsf_feature *ufsf; + + ufsf = container_of(work, struct ufsf_feature, device_check_work); +#if defined(CONFIG_SCSI_SKHID) + if ((IS_SKHYNIX_DEVICE(storage_mfrid)) || (IS_HYNIX_DEVICE(storage_mfrid))) + return; +#endif + + if (ufsf->check_init) + return; + + ufsf_device_check(ufsf->hba); + ufsf_init(ufsf); +} + +/* + * worker to change the feature state to present after processing the error handler. + */ +static void ufsf_reset_wait_work_handler(struct work_struct *work) +{ + struct ufsf_feature *ufsf; + struct ufs_hba *hba; + struct Scsi_Host *host; + u32 ufshcd_state; + unsigned long flags; + + ufsf = container_of(work, struct ufsf_feature, reset_wait_work); + hba = ufsf->hba; + host = hba->host; + + /* + * Wait completion of hba->eh_work. + * + * reset_wait_work is scheduled at ufsf_reset_host(), + * so it can be waken up before eh_work is completed. + * + * ufsf_reset must be called after eh_work has completed. + */ + flush_work(&hba->eh_work); + + spin_lock_irqsave(host->host_lock, flags); + ufshcd_state = hba->ufshcd_state; + spin_unlock_irqrestore(host->host_lock, flags); + + if (ufshcd_state == UFSHCD_STATE_OPERATIONAL) + ufsf_reset(ufsf); +} + +static void ufsf_resume_work_handler(struct work_struct *work) +{ + struct ufsf_feature *ufsf = container_of(work, struct ufsf_feature, resume_work); + struct ufs_hba *hba = ufsf->hba; + bool is_link_off = ufshcd_is_link_off(hba); + + /* + * Resume of UFS feature should be called after power & link state + * are changed to active. Therefore, it is synchronized as follows. + * + * System PM: waits to acquire the semaphore used by ufshcd_wl_resume() + * Runtime PM: resume using ufshcd_rpm_get_sync() + */ + down(&hba->host_sem); + ufshcd_rpm_get_sync(hba); + + if (ufshcd_is_ufs_dev_active(hba) && ufshcd_is_link_active(hba)) + ufsf_resume(ufsf, is_link_off); + + ufshcd_rpm_put(hba); + up(&hba->host_sem); +} + +#if defined(CONFIG_UFSHID) +static void ufsf_on_idle(struct work_struct *work) +{ + struct ufsf_feature *ufsf; + + ufsf = container_of(work, struct ufsf_feature, on_idle_work); + if (ufshid_get_state(ufsf) == HID_PRESENT) + ufshid_on_idle(ufsf); +} +#endif + +inline void ufsf_set_init_state(struct ufs_hba *hba) +{ + struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba); + + ufsf->hba = hba; + + INIT_WORK(&ufsf->device_check_work, ufsf_device_check_work_handler); + INIT_WORK(&ufsf->reset_wait_work, ufsf_reset_wait_work_handler); + INIT_WORK(&ufsf->resume_work, ufsf_resume_work_handler); +#if defined(CONFIG_UFSHID) + INIT_WORK(&ufsf->on_idle_work, ufsf_on_idle); + ufshid_set_state(ufsf, HID_NEED_INIT); +#endif +} + +inline void ufsf_suspend(struct ufsf_feature *ufsf, bool is_system_pm) +{ + /* + * Wait completion of reset_wait_work. + * + * When suspend occurrs immediately after reset + * and reset_wait_work is executed late, + * we can enter here before ufsf_reset() cleans up the feature's reset sequence. + */ + flush_work(&ufsf->reset_wait_work); + +#if defined(CONFIG_UFSHID) + if (ufshid_get_state(ufsf) == HID_PRESENT) + ufshid_suspend(ufsf, is_system_pm); +#endif +} + +inline void ufsf_resume(struct ufsf_feature *ufsf, bool is_link_off) +{ +#if defined(CONFIG_UFSHID) + if (ufshid_get_state(ufsf) == HID_SUSPEND) + ufshid_resume(ufsf, is_link_off); +#endif +} + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/ufs/host/vendor/ufsfeature.h b/drivers/ufs/host/vendor/ufsfeature.h new file mode 100644 index 000000000..dac8bfd43 --- /dev/null +++ b/drivers/ufs/host/vendor/ufsfeature.h @@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Universal Flash Storage Feature Support + * + * Copyright (C) 2017-2018 Samsung Electronics Co., Ltd. + * + * Authors: + * Yongmyung Lee + * Jinyoung Choi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * See the COPYING file in the top-level directory or visit + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This program is provided "AS IS" and "WITH ALL FAULTS" and + * without warranty of any kind. You are solely responsible for + * determining the appropriateness of using and distributing + * the program and assume all risks associated with your exercise + * of rights with respect to the program, including but not limited + * to infringement of third party rights, the risks and costs of + * program errors, damage to or loss of data, programs or equipment, + * and unavailability or interruption of operations. Under no + * circumstances will the contributor of this Program be liable for + * any damages of any kind arising from your use or distribution of + * this program. + * + * The Linux Foundation chooses to take subject only to the GPLv2 + * license terms, and distributes only under these terms. + */ + +#ifndef _UFSFEATURE_H_ +#define _UFSFEATURE_H_ + +#include +#include +#include +#include "ufshid.h" + +#define UFS_UPIU_MAX_GENERAL_LUN 8 + +/* Version info */ +#define UFSFEATURE_DD_VER 0x020500 +#define UFSFEATURE_DD_VER_POST "" + +/* For read10 debug */ +#define READ10_DEBUG_LUN 0x7F +#define READ10_DEBUG_LBA 0x48504230 + +/* For Chip Crack Detection */ +#define VENDOR_OP 0xC0 +#define VENDOR_CCD 0x51 +#define CCD_DATA_SEG_LEN 0x08 +#define CCD_SENSE_DATA_LEN 0x06 +#define CCD_DESC_TYPE 0x81 + +/* Description */ +#define UFSF_QUERY_DESC_DEVICE_MAX_SIZE 0xFF +#define UFSF_QUERY_DESC_CONFIGURAION_MAX_SIZE 0xE6 +#define UFSF_QUERY_DESC_UNIT_MAX_SIZE 0x2D +#define UFSF_QUERY_DESC_GEOMETRY_MAX_SIZE 0xFF + +/* Descriptor idn for Query Request */ +#define UFSF_QUERY_DESC_IDN_VENDOR_DEVICE 0xF0 +#define UFSF_QUERY_DESC_IDN_VENDOR_GEOMETRY 0xF7 + +/* query_flag */ +#define MASK_QUERY_UPIU_FLAG_LOC 0xFF + +#define INFO_MSG(msg, args...) pr_info("%s:%d info: " msg "\n", \ + __func__, __LINE__, ##args) +#define ERR_MSG(msg, args...) pr_err("%s:%d err: " msg "\n", \ + __func__, __LINE__, ##args) +#define WARN_MSG(msg, args...) pr_warn("%s:%d warn: " msg "\n", \ + __func__, __LINE__, ##args) + +#define seq_scan_lu(lun) for (lun = 0; lun < UFS_UPIU_MAX_GENERAL_LUN; lun++) + +#define UFSFEATURE_SELECTOR 0x01 + +#define TMSG(ufsf, lun, msg, args...) \ + do { if (ufsf->sdev_ufs_lu[lun] && \ + ufsf->sdev_ufs_lu[lun]->request_queue) \ + blk_add_trace_msg( \ + ufsf->sdev_ufs_lu[lun]->request_queue, \ + msg, ##args); \ + } while (0) \ + +struct ufsf_lu_desc { + /* Common info */ + int lu_enable; /* 03h bLUEnable */ + int lu_queue_depth; /* 06h lu queue depth info*/ + int lu_logblk_size; /* 0Ah bLogicalBlockSize. default 0x0C = 4KB */ + u64 lu_logblk_cnt; /* 0Bh qLogicalBlockCount. */ +}; + +struct ufsf_feature { + struct ufs_hba *hba; + struct scsi_device *sdev_ufs_lu[UFS_UPIU_MAX_GENERAL_LUN]; + bool check_init; + struct work_struct device_check_work; + + struct work_struct reset_wait_work; + struct work_struct resume_work; + +#if defined(CONFIG_UFSHID) + struct work_struct on_idle_work; + atomic_t hid_state; + struct ufshid_dev *hid_dev; +#endif +}; + +struct ufs_hba; +struct ufshcd_lrb; + +void ufsf_device_check(struct ufs_hba *hba); +void ufsf_upiu_check_for_ccd(struct ufshcd_lrb *lrbp); +bool ufsf_is_valid_lun(int lun); +void ufsf_slave_configure(struct ufsf_feature *ufsf, struct scsi_device *sdev); +int ufsf_prep_fn(struct ufsf_feature *ufsf, struct ufshcd_lrb *lrbp); +void ufsf_reset_lu(struct ufsf_feature *ufsf); +void ufsf_reset_host(struct ufsf_feature *ufsf); +void ufsf_init(struct ufsf_feature *ufsf); +void ufsf_reset(struct ufsf_feature *ufsf); +void ufsf_remove(struct ufsf_feature *ufsf); +void ufsf_set_init_state(struct ufs_hba *hba); +void ufsf_suspend(struct ufsf_feature *ufsf, bool is_system_pm); +void ufsf_resume(struct ufsf_feature *ufsf, bool is_link_off); +void ufsf_print_buf(const unsigned char *field, int size); + +/* mimic */ +void ufsf_scsi_unblock_requests(struct ufs_hba *hba); +void ufsf_scsi_block_requests(struct ufs_hba *hba); +int ufsf_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us); +void ufsf_rpm_put_noidle(struct ufs_hba *hba); + +/* Device descriptor parameters offsets in bytes*/ +#define DEVICE_DESC_PARAM_EX_FEAT_SUP 0x4F +#define DEVICE_DESC_PARAM_SAMSUNG_SUP 0xFB + +#if defined(CONFIG_UFSHID) +#if defined(CONFIG_MICRON_UFSHID) +#define QUERY_FLAG_IDN_HID_EN 0x13 +#endif + +/* Attribute idn for Query requests */ +#define QUERY_ATTR_IDN_HID_OPERATION 0x20 +#define QUERY_ATTR_IDN_HID_FRAG_LEVEL 0x21 +#if defined(CONFIG_MICRON_UFSHID) +#define QUERY_ATTR_IDN_HID_FRAG_STATUS 0x31 +#define QUERY_ATTR_IDN_HID_PROGRESS 0x32 +#endif + +#define DEVICE_DESC_PARAM_HID_VER 0x59 +#endif +#endif /* End of Header */ diff --git a/drivers/ufs/host/vendor/ufshid.c b/drivers/ufs/host/vendor/ufshid.c new file mode 100644 index 000000000..422a174e2 --- /dev/null +++ b/drivers/ufs/host/vendor/ufshid.c @@ -0,0 +1,1097 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Universal Flash Storage Host Initiated Defrag + * + * Copyright (C) 2019 Samsung Electronics Co., Ltd. + * + * Authors: + * Yongmyung Lee + * Jinyoung Choi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * See the COPYING file in the top-level directory or visit + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This program is provided "AS IS" and "WITH ALL FAULTS" and + * without warranty of any kind. You are solely responsible for + * determining the appropriateness of using and distributing + * the program and assume all risks associated with your exercise + * of rights with respect to the program, including but not limited + * to infringement of third party rights, the risks and costs of + * program errors, damage to or loss of data, programs or equipment, + * and unavailability or interruption of operations. Under no + * circumstances will the contributor of this Program be liable for + * any damages of any kind arising from your use or distribution of + * this program. + * + * The Linux Foundation chooses to take subject only to the GPLv2 + * license terms, and distributes only under these terms. + */ + +#include +#include "../core/ufshcd-priv.h" +#include "ufsfeature.h" +#include "ufshid.h" + +static int ufshid_create_sysfs(struct ufshid_dev *hid); + +static inline int ufshid_schedule_delayed_work(struct delayed_work *work, + unsigned long delay) +{ + return queue_delayed_work(system_freezable_wq, work, delay); +} + +inline int ufshid_get_state(struct ufsf_feature *ufsf) +{ + return atomic_read(&ufsf->hid_state); +} + +inline void ufshid_set_state(struct ufsf_feature *ufsf, int state) +{ + atomic_set(&ufsf->hid_state, state); +} + +static inline int ufshid_is_not_present(struct ufshid_dev *hid) +{ + enum UFSHID_STATE cur_state = ufshid_get_state(hid->ufsf); + + if (cur_state != HID_PRESENT) { + INFO_MSG("hid_state != HID_PRESENT (%d)", cur_state); + return -ENODEV; + } + return 0; +} + +static int ufshid_read_attr(struct ufshid_dev *hid, u8 idn, u32 *attr_val) +{ + struct ufs_hba *hba = hid->ufsf->hba; + int ret = 0; + + ufshcd_rpm_get_sync(hba); + + ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, idn, 0, + UFSFEATURE_SELECTOR, attr_val); + if (ret) { + ERR_MSG("read attr [0x%.2X] fail. (%d)", idn, ret); + goto err_out; + } + + HID_DEBUG(hid, "hid_attr read [0x%.2X] %u (0x%X)", idn, *attr_val, + *attr_val); + TMSG(hid->ufsf, 0, "[ufshid] read_attr IDN %s (%d)", + idn == QUERY_ATTR_IDN_HID_OPERATION ? "HID_OP" : + idn == QUERY_ATTR_IDN_HID_FRAG_LEVEL ? "HID_LEV" : "UNKNOWN", idn); + +err_out: + ufsf_rpm_put_noidle(hba); + + return ret; +} + +static int ufshid_write_attr(struct ufshid_dev *hid, u8 idn, u32 val) +{ + struct ufs_hba *hba = hid->ufsf->hba; + int ret = 0; + + ufshcd_rpm_get_sync(hba); + + ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, idn, 0, + UFSFEATURE_SELECTOR, &val); + if (ret) { + ERR_MSG("write attr [0x%.2X] fail. (%d)", idn, ret); + goto err_out; + } + + HID_DEBUG(hid, "hid_attr write [0x%.2X] %u (0x%X)", idn, val, val); + TMSG(hid->ufsf, 0, "[ufshid] write_attr IDN %s (%d)", + idn == QUERY_ATTR_IDN_HID_OPERATION ? "HID_OP" : + idn == QUERY_ATTR_IDN_HID_FRAG_LEVEL ? "HID_LEV" : "UNKNOWN", idn); +err_out: + ufsf_rpm_put_noidle(hba); + + return ret; +} + +#if defined(CONFIG_MICRON_UFSHID) +static int ufshid_set_flag(struct ufshid_dev *hid, u8 idn) +{ + struct ufs_hba *hba = hid->ufsf->hba; + int ret = 0; + bool flag_result; + ufshcd_rpm_get_sync(hba); + + ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, idn, 0,&flag_result); + + if (ret) { + ERR_MSG("set flag [0x%.2X] fail. (%d)", idn, ret); + goto err_out; + } + + HID_DEBUG(hid, "hid_flag set [0x%.2X] result [0x%.2X] ", idn, flag_result); +err_out: + pm_runtime_mark_last_busy(hba->dev); + ufsf_rpm_put_noidle(hba); + + return ret; +} + +static int ufshid_clear_flag(struct ufshid_dev *hid, u8 idn) +{ + struct ufs_hba *hba = hid->ufsf->hba; + int ret = 0; + + ufshcd_rpm_get_sync(hba); + + ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG, idn, 0,NULL); + if (ret) { + ERR_MSG("clear flag [0x%.2X] fail. (%d)", idn, ret); + goto err_out; + } + + HID_DEBUG(hid, "hid_flag set [0x%.2X] ", idn); +err_out: + pm_runtime_mark_last_busy(hba->dev); + ufsf_rpm_put_noidle(hba); + + return ret; +} +#endif + +static inline void ufshid_version_check(int spec_version) +{ + INFO_MSG("Support HID Spec : Driver = (%.4x), Device = (%.4x)", + UFSHID_VER, spec_version); + INFO_MSG("HID Driver version (%.6X%s)", + UFSHID_DD_VER, UFSHID_DD_VER_POST); +} + +void ufshid_get_dev_info(struct ufsf_feature *ufsf, u8 *desc_buf) +{ + int spec_version; + struct ufs_hba *hba; + + ufsf->hid_dev = NULL; + + hba = ufsf->hba; + if (hba->dev_info.wmanufacturerid == UFS_VENDOR_SAMSUNG) { + if (!(get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EX_FEAT_SUP) & + UFS_FEATURE_SUPPORT_HID_BIT)) { + INFO_MSG("bUFSExFeaturesSupport: HID not support"); + goto err_out; + } + + INFO_MSG("bUFSExFeaturesSupport: HID support"); + spec_version = get_unaligned_be16(desc_buf + DEVICE_DESC_PARAM_HID_VER); + ufshid_version_check(spec_version); + } +#ifndef CONFIG_MICRON_UFSHID + else if (hba->dev_info.wmanufacturerid == UFS_VENDOR_MICRON) { + INFO_MSG(" ufshid support Micron HID"); + } else { + INFO_MSG("ufshid can not support this ufs !!!"); + goto err_out; + } +#endif + + ufsf->hid_dev = kzalloc(sizeof(struct ufshid_dev), GFP_KERNEL); + if (!ufsf->hid_dev) { + ERR_MSG("hid_dev memalloc fail"); + goto err_out; + } + + ufsf->hid_dev->ufsf = ufsf; + return; +err_out: + ufshid_set_state(ufsf, HID_FAILED); +} + +static int ufshid_execute_query_op(struct ufshid_dev *hid, enum UFSHID_OP op, + u32 *attr_val) +{ + if (ufshid_write_attr(hid, QUERY_ATTR_IDN_HID_OPERATION, op)) + return -EINVAL; + + msleep(200); + + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_FRAG_LEVEL, attr_val)) + return -EINVAL; + + HID_DEBUG(hid, "Frag_lv %d Frag_stat %d HID_need_exec %d", + HID_GET_FRAG_LEVEL(*attr_val), + HID_FRAG_UPDATE_STAT(*attr_val), + HID_EXECUTE_REQ_STAT(*attr_val)); + + return 0; +} + +static int ufshid_get_analyze_and_issue_execute(struct ufshid_dev *hid) +{ + u32 attr_val; + int ret; + struct ufs_hba *hba = hid->ufsf->hba; + + if (hba->dev_info.wmanufacturerid == UFS_VENDOR_MICRON) { +#if defined(CONFIG_MICRON_UFSHID) + int frag_level; + //get micron ufs frag level + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_FRAG_STATUS, &frag_level)) + return -EINVAL; + //get micron ufs hid execution progress + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_PROGRESS, &attr_val)) + return -EINVAL; + HID_DEBUG(hid, "micron frag_level= %d attr_val= %d",frag_level,attr_val); + + if (attr_val != HID_PROG_ONGOING) { + if(frag_level!= HID_LEV_GREEN_MICRON) { + ufshid_set_flag(hid, QUERY_FLAG_IDN_HID_EN); + return HID_REQUIRED; + } else { + return HID_NOT_REQUIRED; + } + } else { + return HID_REQUIRED; + } +#endif + } else if(hba->dev_info.wmanufacturerid == UFS_VENDOR_SAMSUNG) { + ret = ufshid_execute_query_op(hid, HID_OP_EXECUTE, &attr_val); + if (ret) + return ret; + + if (HID_GET_FRAG_LEVEL(attr_val) == HID_LEV_GRAY) + return -EAGAIN; + + return (HID_EXECUTE_REQ_STAT(attr_val)) ? + HID_REQUIRED : HID_NOT_REQUIRED; + } + return -EINVAL; +} + +static inline void ufshid_issue_disable(struct ufshid_dev *hid) +{ + u32 attr_val; + struct ufs_hba *hba = hid->ufsf->hba; + + if(hba->dev_info.wmanufacturerid == UFS_VENDOR_MICRON) { +#if defined(CONFIG_MICRON_UFSHID) + //get micron ufs hid execution progress + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_PROGRESS, &attr_val)) + return; + HID_DEBUG(hid, "micron hid progress = %d",attr_val); + + if(attr_val == HID_PROG_ONGOING) { + if (ufshid_clear_flag(hid, QUERY_FLAG_IDN_HID_EN)) + return; + } +#endif + }else if(hba->dev_info.wmanufacturerid == UFS_VENDOR_SAMSUNG) { + ufshid_execute_query_op(hid, HID_OP_DISABLE, &attr_val); + } + return; +} + +/* + * Lock status: hid_sysfs lock was held when called. + */ +static void ufshid_auto_hibern8_enable(struct ufshid_dev *hid, + unsigned int val) +{ + struct ufs_hba *hba = hid->ufsf->hba; + unsigned long flags; + u32 reg; + + val = !!val; + + /* Update auto hibern8 timer value if supported */ + if (!ufshcd_is_auto_hibern8_supported(hba)) + return; + + ufshcd_rpm_get_sync(hba); + ufshcd_hold(hba); + ufsf_scsi_block_requests(hba); + /* wait for all the outstanding requests to finish */ + ufsf_wait_for_doorbell_clr(hba, U64_MAX); + spin_lock_irqsave(hba->host->host_lock, flags); + + reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER); + INFO_MSG("ahit-reg 0x%X", reg); + + if (val ^ (reg != 0)) { + if (val) { + hba->ahit = hid->ahit; + } else { + /* + * Store current ahit value. + * We don't know who set the ahit value to different + * from the initial value + */ + hid->ahit = reg; + hba->ahit = 0; + } + + ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER); + + /* Make sure the timer gets applied before further operations */ + mb(); + + INFO_MSG("[Before] is_auto_enabled %d", hid->is_auto_enabled); + hid->is_auto_enabled = val; + + reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER); + INFO_MSG("[After] is_auto_enabled %d ahit-reg 0x%X", + hid->is_auto_enabled, reg); + } else { + INFO_MSG("is_auto_enabled %d. so it does not changed", + hid->is_auto_enabled); + } + + spin_unlock_irqrestore(hba->host->host_lock, flags); + ufsf_scsi_unblock_requests(hba); + ufshcd_release(hba); + ufsf_rpm_put_noidle(hba); +} + +static void ufshid_block_enter_suspend(struct ufshid_dev *hid) +{ + struct ufs_hba *hba = hid->ufsf->hba; + struct device *dev = &hba->ufs_device_wlun->sdev_gendev; + unsigned long flags; + +#if defined(CONFIG_UFSHID_POC) + if (unlikely(hid->block_suspend)) + return; + + hid->block_suspend = true; +#endif + ufshcd_rpm_get_sync(hba); + ufshcd_hold(hba); + + spin_lock_irqsave(hba->host->host_lock, flags); + HID_DEBUG(hid, + "dev->power.usage_count %d hba->clk_gating.active_reqs %d", + atomic_read(&dev->power.usage_count), + hba->clk_gating.active_reqs); + spin_unlock_irqrestore(hba->host->host_lock, flags); +} + +/* + * If the return value is not err, pm_runtime_put_noidle() must be called once. + * IMPORTANT : ufshid_hold_runtime_pm() & ufshid_release_runtime_pm() pair. + */ +static int ufshid_hold_runtime_pm(struct ufshid_dev *hid) +{ + struct ufs_hba *hba = hid->ufsf->hba; + + /* Case of system suspend */ + if (ufshid_get_state(hid->ufsf) == HID_SUSPEND && + !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) + return -ENODEV; + + /* + * After calling ufshcd_rpm_get_sync(), + * it is guaranteed that the wlun device is RPM_ACTIVE. + */ + ufshcd_rpm_get_sync(hba); + + /* + * Since HID resume is performed by a separate worker, + * it is sometimes judged to be in HID_SUSPEND state. + * Therefore, wait until ufshid_resume() changes the state + * of HID to HID_PRESENT. + */ + if (ufshid_get_state(hid->ufsf) == HID_SUSPEND && + !wait_for_completion_timeout(&hid->resume_compl, + WAIT_HID_RESUME_TIMEOUT)) { + WARN_MSG("Waiting for HID resume times out"); + return -ETIMEDOUT; + } + + if (ufshid_is_not_present(hid)) + return -ENODEV; + + return 0; +} + +static inline void ufshid_release_runtime_pm(struct ufshid_dev *hid) +{ + struct ufs_hba *hba = hid->ufsf->hba; + + ufsf_rpm_put_noidle(hba); +} + +static void ufshid_allow_enter_suspend(struct ufshid_dev *hid) +{ + struct ufs_hba *hba = hid->ufsf->hba; + struct device *dev = &hba->ufs_device_wlun->sdev_gendev; + unsigned long flags; + +#if defined(CONFIG_UFSHID_POC) + if (unlikely(!hid->block_suspend)) + return; + + hid->block_suspend = false; +#endif + ufshcd_release(hba); + ufsf_rpm_put_noidle(hba); + + spin_lock_irqsave(hba->host->host_lock, flags); + HID_DEBUG(hid, + "dev->power.usage_count %d hba->clk_gating.active_reqs %d", + atomic_read(&dev->power.usage_count), + hba->clk_gating.active_reqs); + spin_unlock_irqrestore(hba->host->host_lock, flags); +} + +/* + * Lock status: hid_sysfs lock was held when called. + */ +static int ufshid_trigger_off(struct ufshid_dev *hid) + __must_hold(&hid->sysfs_lock) +{ + int ret; + + if (!hid->hid_trigger) + return 0; + + ret = ufshid_hold_runtime_pm(hid); + if (ret) + return ret; + + hid->hid_trigger = false; + HID_DEBUG(hid, "hid_trigger 1 -> 0"); + + ufshid_issue_disable(hid); + + ufshid_auto_hibern8_enable(hid, 1); + + ufshid_allow_enter_suspend(hid); + + ufshid_release_runtime_pm(hid); + + return 0; +} + +/* + * Lock status: hid_sysfs lock was held when called. + */ +static int ufshid_trigger_on(struct ufshid_dev *hid) + __must_hold(&hid->sysfs_lock) +{ + int ret; + + if (hid->hid_trigger) + return 0; + + ret = ufshid_hold_runtime_pm(hid); + if (ret) + return ret; + + hid->hid_trigger = true; + HID_DEBUG(hid, "trigger 0 -> 1"); + + ufshid_block_enter_suspend(hid); + + ufshid_auto_hibern8_enable(hid, 0); + + ufshid_schedule_delayed_work(&hid->hid_trigger_work, 0); + + ufshid_release_runtime_pm(hid); + + return 0; +} + +static void ufshid_trigger_work_fn(struct work_struct *dwork) +{ + struct ufshid_dev *hid; + int ret; + + hid = container_of(dwork, struct ufshid_dev, hid_trigger_work.work); + + if (ufshid_is_not_present(hid)) + return; + + HID_DEBUG(hid, "start hid_trigger_work_fn"); + + mutex_lock(&hid->sysfs_lock); + if (!hid->hid_trigger) { + HID_DEBUG(hid, "hid_trigger == false, return"); + goto finish_work; + } + + ret = ufshid_get_analyze_and_issue_execute(hid); + if (ret == HID_REQUIRED || ret == -EAGAIN) { + HID_DEBUG(hid, "REQUIRED or AGAIN (%d), so re-sched (%u ms)", + ret, hid->hid_trigger_delay); + } else { + HID_DEBUG(hid, "NOT_REQUIRED or err (%d), so trigger off", ret); + ret = ufshid_trigger_off(hid); + if (likely(!ret)) + goto finish_work; + + WARN_MSG("trigger off fail.. must check it"); + } + mutex_unlock(&hid->sysfs_lock); + ufshid_schedule_delayed_work(&hid->hid_trigger_work, + msecs_to_jiffies(hid->hid_trigger_delay)); + + HID_DEBUG(hid, "end hid_trigger_work_fn"); + return; +finish_work: + mutex_unlock(&hid->sysfs_lock); +} + +void ufshid_init(struct ufsf_feature *ufsf) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + int ret; + + INFO_MSG("HID_INIT_START"); + + if (!hid) { + ERR_MSG("hid is not found. it is very weired. must check it"); + ufshid_set_state(ufsf, HID_FAILED); + return; + } + + hid->hid_trigger = false; + hid->hid_trigger_delay = HID_TRIGGER_WORKER_DELAY_MS_DEFAULT; + hid->hid_on_idle_delay = HID_ON_IDLE_DELAY_MS_DEFAULT; + INIT_DELAYED_WORK(&hid->hid_trigger_work, ufshid_trigger_work_fn); + + hid->hid_debug = false; +#if defined(CONFIG_UFSHID_POC) + hid->hid_debug = true; + hid->block_suspend = false; +#endif + + /* If HCI supports auto hibern8, UFS Driver use it default */ + if (ufshcd_is_auto_hibern8_supported(ufsf->hba)) + hid->is_auto_enabled = true; + else + hid->is_auto_enabled = false; + + /* Save default Auto-Hibernate Idle Timer register value */ + hid->ahit = ufsf->hba->ahit; + + ret = ufshid_create_sysfs(hid); + if (ret) { + ERR_MSG("sysfs init fail. so hid driver disabled"); + kfree(hid); + ufshid_set_state(ufsf, HID_FAILED); + return; + } + + INFO_MSG("UFS HID create sysfs finished"); + + ufshid_set_state(ufsf, HID_PRESENT); +} + +void ufshid_reset_host(struct ufsf_feature *ufsf) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + + if (!hid) + return; + + ufshid_set_state(ufsf, HID_RESET); + cancel_delayed_work_sync(&hid->hid_trigger_work); +} + +void ufshid_reset(struct ufsf_feature *ufsf) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + + if (!hid) + return; + + ufshid_set_state(ufsf, HID_PRESENT); + + /* + * hid_trigger will be checked under sysfs_lock in worker. + */ + if (hid->hid_trigger) + ufshid_schedule_delayed_work(&hid->hid_trigger_work, 0); + + INFO_MSG("reset completed."); +} + +static inline void ufshid_remove_sysfs(struct ufshid_dev *hid) +{ + int ret; + + ret = kobject_uevent(&hid->kobj, KOBJ_REMOVE); + INFO_MSG("kobject removed (%d)", ret); + kobject_del(&hid->kobj); +} + +void ufshid_remove(struct ufsf_feature *ufsf) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + int ret; + + if (!hid) + return; + + INFO_MSG("start HID release"); + + mutex_lock(&hid->sysfs_lock); + + ret = ufshid_trigger_off(hid); + if (unlikely(ret)) + ERR_MSG("trigger off fail ret (%d)", ret); + + ufshid_remove_sysfs(hid); + + ufshid_set_state(ufsf, HID_FAILED); + + mutex_unlock(&hid->sysfs_lock); + + cancel_delayed_work_sync(&hid->hid_trigger_work); + + kfree(hid); + + INFO_MSG("end HID release"); +} + +#define SPM_ACTIVE_POWER_LEVEL 1 +void ufshid_suspend(struct ufsf_feature *ufsf, bool is_system_pm) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + + if (!hid) + return; + + if (unlikely(hid->hid_trigger)) + ERR_MSG("hid_trigger was set to block the suspend. so weird"); + ufshid_set_state(ufsf, HID_SUSPEND); + + init_completion(&hid->resume_compl); + + cancel_delayed_work_sync(&hid->hid_trigger_work); +} + +void ufshid_resume(struct ufsf_feature *ufsf, bool is_link_off) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + + if (!hid) + return; + + ufshid_set_state(ufsf, HID_PRESENT); + + complete(&hid->resume_compl); +} + +/* + * this function is called in irq context. + * so cancel_delayed_work_sync() do not use due to waiting. + */ +void ufshid_on_idle(struct ufsf_feature *ufsf) +{ + struct ufshid_dev *hid = ufsf->hid_dev; + + if (!hid) + return; + /* + * When hid_trigger_work will be scheduled, + * check hid_trigger under sysfs_lock. + */ + if (!hid->hid_trigger) + return; + + if (delayed_work_pending(&hid->hid_trigger_work)) + cancel_delayed_work(&hid->hid_trigger_work); + + ufshid_schedule_delayed_work(&hid->hid_trigger_work, + hid->hid_on_idle_delay); +} + +/* sysfs function */ +static ssize_t ufshid_sysfs_show_version(struct ufshid_dev *hid, char *buf) +{ + INFO_MSG("HID version (%.4X) D/D version (%.6X%s)", + UFSHID_VER, UFSHID_DD_VER, UFSHID_DD_VER_POST); + + return snprintf(buf, PAGE_SIZE, + "HID version (%.4X) D/D version (%.6X%s)\n", + UFSHID_VER, UFSHID_DD_VER, UFSHID_DD_VER_POST); +} + +static ssize_t ufshid_sysfs_show_trigger(struct ufshid_dev *hid, char *buf) +{ + INFO_MSG("hid_trigger %d", hid->hid_trigger); + + return snprintf(buf, PAGE_SIZE, "%d\n", hid->hid_trigger); +} + +static ssize_t ufshid_sysfs_store_trigger(struct ufshid_dev *hid, + const char *buf, size_t count) +{ + bool val; + ssize_t ret; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + INFO_MSG("HID_trigger %d", val); + + if (val == hid->hid_trigger) + return count; + + if (val) + ret = ufshid_trigger_on(hid); + else + ret = ufshid_trigger_off(hid); + + if (ret) { + INFO_MSG("Changing trigger val %d is fail (%ld)", val, ret); + return ret; + } + + return count; +} + +static ssize_t ufshid_sysfs_show_trigger_interval(struct ufshid_dev *hid, + char *buf) +{ + INFO_MSG("hid_trigger_interval %d", hid->hid_trigger_delay); + + return snprintf(buf, PAGE_SIZE, "%d\n", hid->hid_trigger_delay); +} + +static ssize_t ufshid_sysfs_store_trigger_interval(struct ufshid_dev *hid, + const char *buf, + size_t count) +{ + unsigned int val; + + if (kstrtouint(buf, 0, &val)) + return -EINVAL; + + if (val < HID_TRIGGER_WORKER_DELAY_MS_MIN || + val > HID_TRIGGER_WORKER_DELAY_MS_MAX) { + INFO_MSG("hid_trigger_interval (min) %4dms ~ (max) %4dms", + HID_TRIGGER_WORKER_DELAY_MS_MIN, + HID_TRIGGER_WORKER_DELAY_MS_MAX); + return -EINVAL; + } + + hid->hid_trigger_delay = val; + INFO_MSG("hid_trigger_interval %d", hid->hid_trigger_delay); + + return count; +} + +static ssize_t ufshid_sysfs_show_on_idle_delay(struct ufshid_dev *hid, + char *buf) +{ + INFO_MSG("hid_on_idle_delay %u", hid->hid_on_idle_delay); + + return snprintf(buf, PAGE_SIZE, "%u\n", hid->hid_on_idle_delay); +} + +static ssize_t ufshid_sysfs_store_on_idle_delay(struct ufshid_dev *hid, + const char *buf, + size_t count) +{ + unsigned int val; + + if (kstrtouint(buf, 0, &val)) + return -EINVAL; + + if (val < HID_ON_IDLE_DELAY_MS_MIN || val > HID_ON_IDLE_DELAY_MS_MAX) { + INFO_MSG("hid_on_idle_delay (min) %4dms ~ (max) %4dms", + HID_ON_IDLE_DELAY_MS_MIN, + HID_ON_IDLE_DELAY_MS_MAX); + return -EINVAL; + } + + hid->hid_on_idle_delay = val; + INFO_MSG("hid_on_idle_delay %u", hid->hid_on_idle_delay); + + return count; +} + +static ssize_t ufshid_sysfs_show_debug(struct ufshid_dev *hid, char *buf) +{ + INFO_MSG("debug %d", hid->hid_debug); + + return snprintf(buf, PAGE_SIZE, "%d\n", hid->hid_debug); +} + +static ssize_t ufshid_sysfs_store_debug(struct ufshid_dev *hid, const char *buf, + size_t count) +{ + bool val; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + hid->hid_debug = val; + + INFO_MSG("debug %d", hid->hid_debug); + + return count; +} + +static ssize_t ufshid_sysfs_show_color(struct ufshid_dev *hid, char *buf) +{ + u32 attr_val; + int frag_level; + int ret; + struct ufs_hba *hba = hid->ufsf->hba; + + if(hba->dev_info.wmanufacturerid == UFS_VENDOR_MICRON){ +#if defined(CONFIG_MICRON_UFSHID) + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_FRAG_STATUS, &attr_val)) + return -EINVAL; + frag_level = attr_val; + /*Micron only has two levels RED & GREEN*/ + return snprintf(buf, PAGE_SIZE, "%s\n", + ((frag_level == HID_LEV_GREEN_MICRON)) ? "GREEN" : + ((frag_level ==HID_LEV_RED_MICRON))?"RED":"UNKNOWN"); + + return snprintf(buf, PAGE_SIZE, "%s\n","Error."); +#endif + } else if(hba->dev_info.wmanufacturerid == UFS_VENDOR_SAMSUNG) { + ret = ufshid_execute_query_op(hid, HID_OP_ANALYZE, &attr_val); + if (ret) + return ret; + + frag_level = HID_GET_FRAG_LEVEL(attr_val); + + return snprintf(buf, PAGE_SIZE, "%s\n", + frag_level == HID_LEV_RED ? "RED" : + frag_level == HID_LEV_YELLOW ? "YELLOW" : + frag_level == HID_LEV_GREEN ? "GREEN" : + frag_level == HID_LEV_GRAY ? "GRAY" : "UNKNOWN"); + } + return -EINVAL; +} + +#if defined(CONFIG_UFSHID_POC) +static ssize_t ufshid_sysfs_show_debug_op(struct ufshid_dev *hid, char *buf) +{ + u32 attr_val; + + if (ufshid_read_attr(hid, QUERY_ATTR_IDN_HID_OPERATION, &attr_val)) + return -EINVAL; + + INFO_MSG("hid_op %d", attr_val); + + return snprintf(buf, PAGE_SIZE, "%u\n", attr_val); +} + +static ssize_t ufshid_sysfs_store_debug_op(struct ufshid_dev *hid, + const char *buf, size_t count) +{ + unsigned int val; + + if (kstrtouint(buf, 0, &val)) + return -EINVAL; + + if (val >= HID_OP_MAX) + return -EINVAL; + + if (hid->hid_trigger) { + ERR_MSG("debug_op cannot change, current hid_trigger is ON"); + return -EINVAL; + } + + if (ufshid_write_attr(hid, QUERY_ATTR_IDN_HID_OPERATION, val)) + return -EINVAL; + + INFO_MSG("hid_op %d", val); + + return count; +} + +static ssize_t ufshid_sysfs_show_block_suspend(struct ufshid_dev *hid, + char *buf) +{ + INFO_MSG("block suspend %d", hid->block_suspend); + + return snprintf(buf, PAGE_SIZE, "%d\n", hid->block_suspend); +} + +static ssize_t ufshid_sysfs_store_block_suspend(struct ufshid_dev *hid, + const char *buf, size_t count) +{ + bool val; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + INFO_MSG("HID_block_suspend %d", val); + + if (val == hid->block_suspend) + return count; + + if (val) + ufshid_block_enter_suspend(hid); + else + ufshid_allow_enter_suspend(hid); + + hid->block_suspend = val ? true : false; + + INFO_MSG("block suspend %d", hid->block_suspend); + + return count; +} + +static ssize_t ufshid_sysfs_show_auto_hibern8_enable(struct ufshid_dev *hid, + char *buf) +{ + INFO_MSG("HCI auto hibern8 %d", hid->is_auto_enabled); + + return snprintf(buf, PAGE_SIZE, "%d\n", hid->is_auto_enabled); +} + +static ssize_t ufshid_sysfs_store_auto_hibern8_enable(struct ufshid_dev *hid, + const char *buf, + size_t count) +{ + bool val; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + ufshid_auto_hibern8_enable(hid, val); + + INFO_MSG("HCI auto hibern8 %d", hid->is_auto_enabled); + + return count; +} +#endif + +/* SYSFS DEFINE */ +#define define_sysfs_ro(_name) __ATTR(_name, 0444, \ + ufshid_sysfs_show_##_name, NULL) +#define define_sysfs_rw(_name) __ATTR(_name, 0644, \ + ufshid_sysfs_show_##_name, \ + ufshid_sysfs_store_##_name) + +static struct ufshid_sysfs_entry ufshid_sysfs_entries[] = { + define_sysfs_ro(version), + define_sysfs_ro(color), + define_sysfs_rw(trigger), + define_sysfs_rw(trigger_interval), + define_sysfs_rw(on_idle_delay), + + /* debug */ + define_sysfs_rw(debug), +#if defined(CONFIG_UFSHID_POC) + /* Attribute (RAW) */ + define_sysfs_rw(debug_op), + define_sysfs_rw(block_suspend), + define_sysfs_rw(auto_hibern8_enable), +#endif + __ATTR_NULL +}; + +static ssize_t ufshid_attr_show(struct kobject *kobj, struct attribute *attr, + char *page) +{ + struct ufshid_sysfs_entry *entry; + struct ufshid_dev *hid; + ssize_t error; + + entry = container_of(attr, struct ufshid_sysfs_entry, attr); + if (!entry->show) + return -EIO; + + hid = container_of(kobj, struct ufshid_dev, kobj); + error = ufshid_hold_runtime_pm(hid); + if (error) + return error; + + mutex_lock(&hid->sysfs_lock); + error = entry->show(hid, page); + mutex_unlock(&hid->sysfs_lock); + + ufshid_release_runtime_pm(hid); + return error; +} + +static ssize_t ufshid_attr_store(struct kobject *kobj, struct attribute *attr, + const char *page, size_t length) +{ + struct ufshid_sysfs_entry *entry; + struct ufshid_dev *hid; + ssize_t error; + + entry = container_of(attr, struct ufshid_sysfs_entry, attr); + if (!entry->store) + return -EIO; + + hid = container_of(kobj, struct ufshid_dev, kobj); + error = ufshid_hold_runtime_pm(hid); + if (error) + return error; + + mutex_lock(&hid->sysfs_lock); + error = entry->store(hid, page, length); + mutex_unlock(&hid->sysfs_lock); + + ufshid_release_runtime_pm(hid); + return error; +} + +static const struct sysfs_ops ufshid_sysfs_ops = { + .show = ufshid_attr_show, + .store = ufshid_attr_store, +}; + +static struct kobj_type ufshid_ktype = { + .sysfs_ops = &ufshid_sysfs_ops, + .release = NULL, +}; + +static int ufshid_create_sysfs(struct ufshid_dev *hid) +{ + struct device *dev = hid->ufsf->hba->dev; + struct ufshid_sysfs_entry *entry; + int err; + + hid->sysfs_entries = ufshid_sysfs_entries; + + kobject_init(&hid->kobj, &ufshid_ktype); + mutex_init(&hid->sysfs_lock); + + INFO_MSG("ufshid creates sysfs ufshid %p dev->kobj %p", + &hid->kobj, &dev->kobj); + + err = kobject_add(&hid->kobj, kobject_get(&dev->kobj), "ufshid"); + if (!err) { + for (entry = hid->sysfs_entries; entry->attr.name != NULL; + entry++) { + INFO_MSG("ufshid sysfs attr creates: %s", + entry->attr.name); + err = sysfs_create_file(&hid->kobj, &entry->attr); + if (err) { + ERR_MSG("create entry(%s) failed", + entry->attr.name); + goto kobj_del; + } + } + kobject_uevent(&hid->kobj, KOBJ_ADD); + } else { + ERR_MSG("kobject_add failed"); + } + + return err; +kobj_del: + err = kobject_uevent(&hid->kobj, KOBJ_REMOVE); + INFO_MSG("kobject removed (%d)", err); + kobject_del(&hid->kobj); + return -EINVAL; +} + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/ufs/host/vendor/ufshid.h b/drivers/ufs/host/vendor/ufshid.h new file mode 100644 index 000000000..77804f217 --- /dev/null +++ b/drivers/ufs/host/vendor/ufshid.h @@ -0,0 +1,176 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Universal Flash Storage Host Initiated Defrag + * + * Copyright (C) 2019 Samsung Electronics Co., Ltd. + * + * Authors: + * Yongmyung Lee + * Jinyoung Choi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * See the COPYING file in the top-level directory or visit + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This program is provided "AS IS" and "WITH ALL FAULTS" and + * without warranty of any kind. You are solely responsible for + * determining the appropriateness of using and distributing + * the program and assume all risks associated with your exercise + * of rights with respect to the program, including but not limited + * to infringement of third party rights, the risks and costs of + * program errors, damage to or loss of data, programs or equipment, + * and unavailability or interruption of operations. Under no + * circumstances will the contributor of this Program be liable for + * any damages of any kind arising from your use or distribution of + * this program. + * + * The Linux Foundation chooses to take subject only to the GPLv2 + * license terms, and distributes only under these terms. + */ + +#ifndef _UFSHID_H_ +#define _UFSHID_H_ + +#include +#include +#include +#include +#include +#include +#include + + +#include "../../../block/blk.h" + +#define UFSHID_VER 0x0101 +#define UFSHID_DD_VER 0x010700 +#define UFSHID_DD_VER_POST "" + +#define UFS_FEATURE_SUPPORT_HID_BIT (1 << 0) + +#define HID_TRIGGER_WORKER_DELAY_MS_DEFAULT 2000 +#define HID_TRIGGER_WORKER_DELAY_MS_MIN 100 +#define HID_TRIGGER_WORKER_DELAY_MS_MAX 10000 + +#define HID_ON_IDLE_DELAY_MS_DEFAULT 100 +#define HID_ON_IDLE_DELAY_MS_MIN 10 +#define HID_ON_IDLE_DELAY_MS_MAX 10000 + +#define HID_FRAG_LEVEL_MASK 0xF +#define HID_GET_FRAG_LEVEL(val) (val & HID_FRAG_LEVEL_MASK) +#define HID_FRAG_UPDATE_STAT_SHIFT 30 +#define HID_EXECUTE_REQ_STAT_SHIFT 31 +#define HID_FRAG_UPDATE_STAT(val) ((val >> HID_FRAG_UPDATE_STAT_SHIFT) & 0x1) +#define HID_EXECUTE_REQ_STAT(val) ((val >> HID_EXECUTE_REQ_STAT_SHIFT) & 0x1) + +#define WAIT_HID_RESUME_TIMEOUT (2 * HZ) + +#define HID_DEBUG(hid, msg, args...) \ + do { if (hid->hid_debug) \ + pr_err("%40s:%3d [%01d%02d%02d] " msg "\n", \ + __func__, __LINE__, \ + hid->hid_trigger, \ + atomic_read(&hid->ufsf->hba->dev->power.usage_count),\ + hid->ufsf->hba->clk_gating.active_reqs, ##args); \ + } while (0) + +enum UFSHID_STATE { + HID_NEED_INIT = 0, + HID_PRESENT = 1, + HID_SUSPEND = 2, + HID_FAILED = -2, + HID_RESET = -3, +}; + +enum UFSHID_OP { + HID_OP_DISABLE = 0, + HID_OP_ANALYZE = 1, + HID_OP_EXECUTE = 2, + HID_OP_LBA_EXECUTE = 3, + HID_OP_MAX +}; + +enum { + HID_NO_PARAM = 0, + HID_WITH_PARAM = 1, +}; + +enum { + HID_LEV_GRAY = 0, + HID_LEV_GREEN = 1, + HID_LEV_YELLOW = 2, + HID_LEV_RED = 3, + HID_LEV_UNKNOWN = 4, +}; + +enum { + HID_NOT_REQUIRED = 0, + HID_REQUIRED = 1 +}; + +#if defined(CONFIG_MICRON_UFSHID) +enum { + HID_LEV_GREEN_MICRON = 0, + HID_LEV_RED_MICRON = 1, +}; + +enum { + HID_PROG_IDLE = 0, + HID_PROG_ONGOING = 1, + HID_PROG_STOP = 2, //stopped by Host + HID_PROG_COMPLETE = 3, +}; +#endif + +struct ufshid_dev { + struct ufsf_feature *ufsf; + + unsigned int hid_trigger; /* default value is false */ + struct delayed_work hid_trigger_work; + unsigned int hid_trigger_delay; + unsigned int hid_on_idle_delay; + + u32 ahit; /* to restore ahit value */ + bool is_auto_enabled; + + /* for sysfs */ + struct kobject kobj; + struct mutex sysfs_lock; + struct ufshid_sysfs_entry *sysfs_entries; + + /* for debug */ + bool hid_debug; +#if defined(CONFIG_UFSHID_POC) + bool block_suspend; +#endif + struct completion resume_compl; +}; + +struct ufshid_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct ufshid_dev *hid, char *buf); + ssize_t (*store)(struct ufshid_dev *hid, const char *buf, size_t count); +}; + +struct ufshcd_lrb; + +int ufshid_get_state(struct ufsf_feature *ufsf); +void ufshid_set_state(struct ufsf_feature *ufsf, int state); +void ufshid_get_dev_info(struct ufsf_feature *ufsf, u8 *desc_buf); +void ufshid_set_init_state(struct ufsf_feature *ufsf); +void ufshid_init(struct ufsf_feature *ufsf); +void ufshid_reset(struct ufsf_feature *ufsf); +void ufshid_reset_host(struct ufsf_feature *ufsf); +void ufshid_remove(struct ufsf_feature *ufsf); +void ufshid_suspend(struct ufsf_feature *ufsf, bool is_system_pm); +void ufshid_resume(struct ufsf_feature *ufsf, bool is_link_off); +void ufshid_on_idle(struct ufsf_feature *ufsf); +#endif /* End of Header */ diff --git a/drivers/usb/dwc3/dwc3-msm-core.c b/drivers/usb/dwc3/dwc3-msm-core.c index 129fc4258..2a602d412 100644 --- a/drivers/usb/dwc3/dwc3-msm-core.c +++ b/drivers/usb/dwc3/dwc3-msm-core.c @@ -55,6 +55,11 @@ #include "xhci.h" #include "debug-ipc.h" +#undef dev_dbg +#undef pr_debug +#define dev_dbg dev_info +#define pr_debug pr_info + #define NUM_LOG_PAGES 12 /* dload specific suppot */ @@ -2398,6 +2403,30 @@ static void gsi_free_trbs(struct usb_ep *ep, struct usb_gsi_request *req) req->buf_base_addr = NULL; sg_free_table(&req->sgt_data_buff); } + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,6,87) +static int gsi_set_xfer_resource(struct dwc3_ep *dep) +{ + struct dwc3_gadget_ep_cmd_params params; + int ret; + + if (dep->flags & DWC3_EP_RESOURCE_ALLOCATED) + return 0; + + memset(¶ms, 0x00, sizeof(params)); + + params.param0 = DWC3_DEPXFERCFG_NUM_XFER_RES(1); + + ret = dwc3_core_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETTRANSFRESOURCE, + ¶ms); + if (ret) + return ret; + + dep->flags |= DWC3_EP_RESOURCE_ALLOCATED; + return 0; +} +#endif + /** * Configures GSI EPs. For GSI EPs we need to set interrupter numbers. * @@ -2415,6 +2444,9 @@ static void gsi_configure_ep(struct usb_ep *ep, struct usb_gsi_request *request) int n = request->ep_intr_num - 1; u32 reg; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,6,87) + gsi_set_xfer_resource(dep); +#endif /* setup dummy doorbell as IPA connection isn't setup yet */ dwc3_msm_write_reg(mdwc->base, GSI_DBL_ADDR_H(mdwc->gsi_reg, n), upper_32_bits(mdwc->dummy_gsi_db_dma)); @@ -4635,6 +4667,7 @@ skip_update: if (mdwc->resume_pending) { pm_runtime_resume(mdwc->dev); mdwc->resume_pending = false; + dev_dbg(mdwc->dev, "%s: set resume_pending to false\n", __func__); } if (atomic_read(&mdwc->pm_suspended)) { @@ -4727,6 +4760,10 @@ static irqreturn_t msm_dwc3_pwr_irq(int irq, void *data) /* set this to call dwc3_msm_resume() */ mdwc->resume_pending = true; return IRQ_WAKE_THREAD; + } else { + /* don't set this to call dwc3_msm_resume()when exit LPM */ + dev_dbg(mdwc->dev, "%s resume_pending=%d, clean resume_pending\n", __func__, mdwc->resume_pending); + mdwc->resume_pending = false; } dwc3_pwr_event_handler(mdwc); @@ -5557,6 +5594,21 @@ static void dwc3_msm_set_dp_only_params(struct dwc3_msm *mdwc) mdwc->ss_phy->flags |= PHY_DP_MODE; } +int dwc3_msm_set_usb_redriver_eq(struct device *dev) +{ + struct dwc3_msm *mdwc = dev_get_drvdata(dev); + + if (!mdwc || !mdwc->redriver) { + dev_err(dev, "dwc3-msm is not initialized yet.\n"); + return -EAGAIN; + } + + usb_redriver_config_dp_eq(mdwc->redriver); + + return 0; +} +EXPORT_SYMBOL(dwc3_msm_set_usb_redriver_eq); + int dwc3_msm_set_dp_mode(struct device *dev, bool dp_connected, int lanes) { struct dwc3_msm *mdwc = dev_get_drvdata(dev); @@ -6501,6 +6553,7 @@ static int dwc3_msm_probe(struct platform_device *pdev) .allow_userspace_control = true, }; + dwc3_msm_set_role(mdwc, USB_ROLE_NONE); role_desc.fwnode = dev_fwnode(&pdev->dev); mdwc->role_switch = usb_role_switch_register(mdwc->dev, &role_desc); @@ -6521,6 +6574,13 @@ static int dwc3_msm_probe(struct platform_device *pdev) PM_QOS_DEFAULT_VALUE); mdwc->force_disconnect = false; + + if (of_property_read_bool(node, + "qcom,force-adb-enable")) { + dev_err(mdwc->dev, "%s: force usb start device mode\n", __func__); + dwc3_start_stop_device(mdwc, true); + } + return 0; put_dwc3: diff --git a/drivers/usb/phy/phy-msm-snps-hs.c b/drivers/usb/phy/phy-msm-snps-hs.c index 4af78084c..ea5b1f37c 100644 --- a/drivers/usb/phy/phy-msm-snps-hs.c +++ b/drivers/usb/phy/phy-msm-snps-hs.c @@ -123,6 +123,9 @@ struct msm_hsphy { int *param_override_seq; int param_override_seq_cnt; + int *host_param_override_seq; + int host_param_override_seq_cnt; + void __iomem *phy_rcal_reg; u32 rcal_mask; @@ -488,9 +491,14 @@ static int msm_hsphy_init(struct usb_phy *uphy) VBUSVLDEXT0, VBUSVLDEXT0); /* set parameter ovrride if needed */ - if (phy->param_override_seq) + if ((phy->phy.flags & PHY_HOST_MODE) && + phy->host_param_override_seq) { + hsusb_phy_write_seq(phy->base, phy->host_param_override_seq, + phy->host_param_override_seq_cnt, 0); + } else if (phy->param_override_seq) { hsusb_phy_write_seq(phy->base, phy->param_override_seq, phy->param_override_seq_cnt, 0); + } if (phy->pre_emphasis) { u8 val = TXPREEMPAMPTUNE0(phy->pre_emphasis) & @@ -924,6 +932,34 @@ static int msm_hsphy_probe(struct platform_device *pdev) if (IS_ERR(phy->phy_reset)) return PTR_ERR(phy->phy_reset); + phy->host_param_override_seq_cnt = of_property_count_elems_of_size( + dev->of_node, + "qcom,host-param-override-seq", + sizeof(*phy->host_param_override_seq)); + if (phy->host_param_override_seq_cnt > 0) { + phy->host_param_override_seq = devm_kcalloc(dev, + phy->host_param_override_seq_cnt, + sizeof(*phy->host_param_override_seq), + GFP_KERNEL); + if (!phy->host_param_override_seq) + return -ENOMEM; + + if (phy->host_param_override_seq_cnt % 2) { + dev_err(dev, "invalid host_param_override_seq_len\n"); + return -EINVAL; + } + + ret = of_property_read_u32_array(dev->of_node, + "qcom,host-param-override-seq", + phy->host_param_override_seq, + phy->host_param_override_seq_cnt); + if (ret) { + dev_err(dev, "qcom,host_param-override-seq read failed %d\n", + ret); + return ret; + } + } + phy->param_override_seq_cnt = of_property_count_elems_of_size( dev->of_node, "qcom,param-override-seq", diff --git a/drivers/usb/phy/phy-msm-ssusb-qmp.c b/drivers/usb/phy/phy-msm-ssusb-qmp.c index 997bae78b..dcc568741 100644 --- a/drivers/usb/phy/phy-msm-ssusb-qmp.c +++ b/drivers/usb/phy/phy-msm-ssusb-qmp.c @@ -18,6 +18,7 @@ #include #include #include +#include enum core_ldo_levels { CORE_LEVEL_NONE = 0, @@ -151,6 +152,11 @@ struct msm_ssphy_qmp { u32 *qmp_phy_init_seq; int init_seq_len; enum qmp_phy_type phy_type; + + /* debugfs entries */ + struct dentry *root; + struct qmp_reg_val *qmp_phy_tune_seq; + int qmp_phy_tune_seq_cnt; }; static const struct of_device_id msm_usb_id_table[] = { @@ -414,6 +420,7 @@ static int configure_phy_regs(struct usb_phy *uphy, struct msm_ssphy_qmp *phy = container_of(uphy, struct msm_ssphy_qmp, phy); int i; + struct qmp_reg_val *tune_reg; if (!reg) { dev_err(uphy->dev, "NULL PHY configuration\n"); @@ -424,6 +431,14 @@ static int configure_phy_regs(struct usb_phy *uphy, writel_relaxed(reg->val, phy->base + reg->offset); reg++; } + + for (i = 0; i < phy->qmp_phy_tune_seq_cnt; i++) { + tune_reg = &phy->qmp_phy_tune_seq[i]; + if (((tune_reg->val >> 16) & 0x0FFF) == 0xDEF) + continue; + writel_relaxed(tune_reg->val, phy->base + tune_reg->offset); + } + return 0; } @@ -1020,6 +1035,86 @@ static int usb3_get_regulators(struct msm_ssphy_qmp *phy) return 0; } + +static int msm_ssphy_qmp_tune_reg_show(struct seq_file *s, void *unused) +{ + int i; + u32 val; + struct msm_ssphy_qmp *phy = s->private; + struct qmp_reg_val *tune_seq = phy->qmp_phy_tune_seq; + + for (i = 0; i < phy->qmp_phy_tune_seq_cnt; i++) { + val = readl_relaxed(phy->base + tune_seq[i].offset); + seq_printf(s, "reg[0x%04x] = 0x%08x(0x%08x)\n", + tune_seq[i].offset, val, tune_seq[i].val); + } + + return 0; +} + +static int msm_ssphy_qmp_tune_reg_open(struct inode *inode, struct file *file) +{ + return single_open(file, msm_ssphy_qmp_tune_reg_show, inode->i_private); +} + +static ssize_t msm_ssphy_qmp_tune_reg_write(struct file *file, + const char __user *ubuf, size_t count, loff_t *ppos) +{ + int i; + int ret; + char buf[64]; + struct qmp_reg_val reg; + struct seq_file *s = file->private_data; + struct msm_ssphy_qmp *phy = s->private; + struct qmp_reg_val *tune_seq = phy->qmp_phy_tune_seq; + int seq_cnt = phy->qmp_phy_tune_seq_cnt; + + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) + return -EFAULT; + + ret = sscanf((const char *)buf, "%x, %x", ®.offset, ®.val); + if (ret != 2) { + pr_err("Invalid ssphy tune register seq input\n"); + return -EINVAL; + } + + for (i = 0; i < seq_cnt; i++) { + if (tune_seq[i].offset == reg.offset) { + memcpy(&tune_seq[i], ®, sizeof(reg)); + return count; + } + } + + tune_seq = kzalloc(sizeof(reg) * (seq_cnt + 1), GFP_KERNEL); + if (!tune_seq) + return -ENOMEM; + + if (phy->qmp_phy_tune_seq) { + memcpy(tune_seq, phy->qmp_phy_tune_seq, sizeof(reg) * seq_cnt); + kfree(phy->qmp_phy_tune_seq); + } + tune_seq[seq_cnt] = reg; + phy->qmp_phy_tune_seq = tune_seq; + phy->qmp_phy_tune_seq_cnt = seq_cnt + 1; + + return count; +} + +static const struct file_operations msm_ssphy_qmp_tune_reg_fops = { + .open = msm_ssphy_qmp_tune_reg_open, + .write = msm_ssphy_qmp_tune_reg_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static void msm_ssphy_qmp_create_debugfs(struct msm_ssphy_qmp *phy) +{ + phy->root = debugfs_create_dir(dev_name(phy->phy.dev), NULL); + debugfs_create_file("phy_tune_reg", 0644, phy->root, phy, + &msm_ssphy_qmp_tune_reg_fops); +} + static int msm_ssphy_qmp_probe(struct platform_device *pdev) { struct msm_ssphy_qmp *phy; @@ -1225,6 +1320,9 @@ static int msm_ssphy_qmp_probe(struct platform_device *pdev) /* Placed at the end to ensure the probe is complete */ ret = usb_add_phy_dev(&phy->phy); + if (!ret) + msm_ssphy_qmp_create_debugfs(phy); + err: return ret; } @@ -1236,6 +1334,12 @@ static int msm_ssphy_qmp_remove(struct platform_device *pdev) if (!phy) return 0; + if (phy->qmp_phy_tune_seq) { + kfree(phy->qmp_phy_tune_seq); + phy->qmp_phy_tune_seq = NULL; + phy->qmp_phy_tune_seq_cnt = 0; + } + debugfs_remove_recursive(phy->root); usb_remove_phy(&phy->phy); msm_ssphy_qmp_enable_clks(phy, false); msm_ssusb_qmp_ldo_enable(phy, 0); diff --git a/drivers/usb/redriver/Kconfig b/drivers/usb/redriver/Kconfig index 783243931..75f9e3e76 100644 --- a/drivers/usb/redriver/Kconfig +++ b/drivers/usb/redriver/Kconfig @@ -21,4 +21,10 @@ config USB_REDRIVER_NB7VPQ904M it have i2c program interface. Say Y/M here if you want to support it. +config USB_REDRIVER_PS5169 + tristate "USB 3.1 Gen1/Gen2 10Gbps re-driver driver for PS5169" + select REGMAP_I2C + help + Say Y here if you want to support USB super speed re-driver PS5169. + endmenu diff --git a/drivers/usb/redriver/Makefile b/drivers/usb/redriver/Makefile index 32f42cbc4..4d9dfb765 100644 --- a/drivers/usb/redriver/Makefile +++ b/drivers/usb/redriver/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_USB_REDRIVER) += redriver.o obj-$(CONFIG_USB_REDRIVER_NB7VPQ904M) += nb7vpq904m.o +obj-$(CONFIG_USB_REDRIVER_PS5169) += ps5169.o diff --git a/drivers/usb/redriver/ps5169.c b/drivers/usb/redriver/ps5169.c new file mode 100644 index 000000000..b0a5d097c --- /dev/null +++ b/drivers/usb/redriver/ps5169.c @@ -0,0 +1,1049 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* dp eq */ +#define PS5169_DP_EQ0_REG 0x52 +#define PS5169_DP_EQ0_MASK 0x70 +#define PS5169_DP_EQ1_REG 0x5e +#define PS5169_DP_EQ1_MASK 0x07 + +#define PS5169_DP_EQ_MAX 5 +#define PS5169_DP_EQ_DEFAULT 0 +static const struct ps5169_dp_eq { + unsigned int eq0; /* 0x52 bit 6:4 */ + unsigned int eq1; /* 0x5e bit 2:0 */ +} dp_eq[] = { + {0x00, 0x04}, /* 0:2db */ + {0x10, 0x05}, /* 1:5.5db */ + {0x20, 0x06}, /* 2:6.5db */ + {0x30, 0x06}, /* 3:7.5db */ + {0x40, 0x06}, /* 4:8db */ + {0x50, 0x07}, /* 5:8.5db */ + {0x60, 0x07}, /* 6:9.5db */ + {0x70, 0x07}, /* 7:10db ??? */ +}; + +#define PS5169_DP_EQ0_VAL(eq) dp_eq[eq].eq0 +#define PS5169_DP_EQ1_VAL(eq) dp_eq[eq].eq1 + +/* dp gain */ +#define PS5169_DP_GAIN_REG 0x5c +#define PS5169_DP_GAIN_MASK BIT(4) +#define PS5169_DP_GAIN_MAX 1 /* -0.9db */ +#define PS5169_DP_GAIN_DEFAULT 0 /* 0 db */ + +/* usb tx eq */ +#define PS5169_USB_TX_EQ0_REG 0x50 +#define PS5169_USB_TX_EQ0_MASK 0x70 +#define PS5169_USB_TX_EQ1_REG 0x5d +#define PS5169_USB_TX_EQ1_MASK 0x70 +#define PS5169_USB_TX_EQ2_REG 0x54 +#define PS5169_USB_TX_EQ2_MASK 0xf0 + +#define PS5169_USB_TX_EQ_MAX 7 +#define PS5169_USB_TX_EQ_DEFAULT 1 +static const struct ps5169_usb_tx_eq { + unsigned int eq0; /* 0x50 bit 6:4 */ + unsigned int eq1; /* 0x5d bit 6:4 */ + unsigned int eq2; /* 0x54 bit 7:4 */ +} usb_tx_eq[] = { + {0x00, 0x40, 0x00}, /* 0:2db */ + {0x10, 0x50, 0x10}, /* 1:5.5db */ + {0x20, 0x60, 0x10}, /* 2:6.5db */ + {0x30, 0x60, 0x50}, /* 3:7.5db */ + {0x40, 0x60, 0xc0}, /* 4:8db */ + {0x50, 0x70, 0x50}, /* 5:8.5db */ + {0x60, 0x70, 0xf0}, /* 6:9.5db */ + {0x70, 0x70, 0xf0}, /* 7:10db ???? */ +}; + +#define PS5169_USB_TX_EQ0_VAL(eq) usb_tx_eq[eq].eq0 +#define PS5169_USB_TX_EQ1_VAL(eq) usb_tx_eq[eq].eq1 +#define PS5169_USB_TX_EQ2_VAL(eq) usb_tx_eq[eq].eq2 + +/* usb tx gain */ +#define PS5169_USB_TX_GAIN_REG 0x5c +#define PS5169_USB_TX_GAIN_MASK BIT(0) +#define PS5169_USB_TX_GAIN_MAX 1 /* -0.9db */ +#define PS5169_USB_TX_GAIN_DEFAULT 0 /* 0db */ + +/* usb rx eq */ +#define PS5169_USB_RX_EQ0_REG 0x51 +#define PS5169_USB_RX_EQ0_MASK 0x70 +#define PS5169_USB_RX_EQ1_REG 0x77 +#define PS5169_USB_RX_EQ1_MASK 0xf0 +#define PS5169_USB_RX_EQ2_REG 0x54 +#define PS5169_USB_RX_EQ2_MASK 0x0f +#define PS5169_USB_RX_EQ3_REG 0x78 +#define PS5169_USB_RX_EQ3_MASK 0xe1 + +#define PS5169_USB_RX_EQ_MAX 7 +static const struct ps5169_usb_rx_eq { + unsigned int eq0; /* 0x51 bit 7:4 2:1 */ + unsigned int eq1; /* 0x77 bit 7:4 */ + unsigned int eq2; /* 0x54 bit 3:0 */ + unsigned int eq3; /* 0x78 bit 7:5 0 */ +} usb_rx_eq[] = { + {0x86, 0x00, 0x00, 0x20}, /* 0:5.2db */ + {0x96, 0x00, 0x01, 0x20}, /* 1:6db */ + {0xa6, 0x50, 0x01, 0x40}, /* 2:7db */ + {0xb6, 0x50, 0x05, 0x40}, /* 3:8db */ + {0xc6, 0xb0, 0x0c, 0x80}, /* 4:8.8db */ + {0xd6, 0xf0, 0x05, 0x80}, /* 5:9.6db */ + {0xe6, 0xf0, 0x0f, 0x80}, /* 6:10.4db */ + {0xf6, 0x30, 0x0f, 0xa1}, /* 7:11.2db */ +}; + +#define PS5169_USB_RX_EQ0_VAL(eq) usb_rx_eq[eq].eq0 +#define PS5169_USB_RX_EQ1_VAL(eq) usb_rx_eq[eq].eq1 +#define PS5169_USB_RX_EQ2_VAL(eq) usb_rx_eq[eq].eq2 +#define PS5169_USB_RX_EQ3_VAL(eq) usb_rx_eq[eq].eq3 + +/* usb rx gain */ +#define PS5169_USB_RX_GAIN_REG 0x5c +#define PS5169_USB_RX_GAIN_MASK BIT(2) +#define PS5169_USB_RX_GAIN_MAX 1 /* -0.9db */ +#define PS5169_USB_RX_GAIN_DEFAULT 0 /* 0db */ + +/* configuration */ +#define PS5169_CONFIG_REG 0x40 +#define PS5169_CONFIG_REG_DEFAULT 0x40 +#define PS5169_PD_ACTIVE BIT(7) +#define PS5169_USB3_EN BIT(6) +#define PS5169_DP_EN BIT(5) +#define PS5169_FLIPPED BIT(4) +#define PS5169_EMODE BIT(3) + +/* chip id */ +#define PS5169_CHIPID_REG 0xAC +#define PS5169_CHIP_ID 0x6987 + +enum operation_mode { + OP_MODE_NONE, /* 4 lanes disabled */ + OP_MODE_USB3, /* 2 lanes for USB and 2 lanes disabled */ + OP_MODE_DP, /* 4 lanes DP */ + OP_MODE_USB3_AND_DP, /* 2 lanes for USB and 2 lanes DP */ + OP_MODE_DEFAULT, /* 4 lanes USB */ +}; + +#define NOTIFIER_PRIORITY 1 + +struct ps5169_redriver { + struct usb_redriver r; + struct device *dev; + struct i2c_client *client; + struct regulator *vcc; + struct regulator *vio; + struct regmap *regmap; + struct reg_sequence *config_seqs; + unsigned int config_seqs_cnt; + struct dentry *debug_root; + + /* tuning purpose */ + unsigned int dpeq; + unsigned int dpgain; + unsigned int usbtxeq; + unsigned int usbtxgain; + unsigned int usbrxeq; + unsigned int usbrxgain; + + int typec_orientation; + enum operation_mode op_mode; + + int enable_gpio; + + struct work_struct pullup_work; + bool work_ongoing; + bool config_dp_eq; + + struct work_struct host_work; +}; + +static const char * const opmode_string[] = { + [OP_MODE_NONE] = "NONE", + [OP_MODE_USB3] = "USB3", + [OP_MODE_DP] = "DP", + [OP_MODE_USB3_AND_DP] = "USB3 and DP", + [OP_MODE_DEFAULT] = "DEFAULT", +}; +#define OPMODESTR(x) opmode_string[x] + + +static inline int ps5169_redriver_write_reg_bits(struct ps5169_redriver *ps5169, + unsigned int reg, unsigned int val, unsigned int mask); +static void ps5169_config_work_mode(struct ps5169_redriver *ps5169, + enum operation_mode mode); +static int ps5169_config_seqs_init(struct ps5169_redriver *ps5169); + +static int ps5169_redriver_enable_chip(struct ps5169_redriver *ps5169, bool en) +{ + if (!gpio_is_valid(ps5169->enable_gpio)) { + dev_err(ps5169->dev, "%s: Invalid enable_gpio: %d\n", __func__, + ps5169->enable_gpio); + return -EINVAL; + } + + gpio_set_value(ps5169->enable_gpio, en); + if (en) + mdelay(10); + + return 0; +} + +static int ps5169_notify_connect(struct usb_redriver *r, int ort) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + enum operation_mode mode = ps5169->op_mode; + + if (ps5169->op_mode == OP_MODE_NONE) + mode = OP_MODE_USB3; + + dev_info(ps5169->dev, "%s: op mode %s -> %s, orientation %s\n", + __func__, + OPMODESTR(ps5169->op_mode), OPMODESTR(mode), + ort == ORIENTATION_CC1 ? "CC1" : "CC2"); + + ps5169->op_mode = mode; + ps5169->typec_orientation = ort; + ps5169_redriver_enable_chip(ps5169, true); + ps5169_config_seqs_init(ps5169); + ps5169_config_work_mode(ps5169, ps5169->op_mode); + + return 0; +} + +static int ps5169_notify_disconnect(struct usb_redriver *r) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + + if (ps5169->op_mode == OP_MODE_NONE) + return 0; + + dev_info(ps5169->dev, "%s: op mode %s -> %s\n", __func__, + OPMODESTR(ps5169->op_mode), OPMODESTR(OP_MODE_NONE)); + + ps5169->op_mode = OP_MODE_NONE; + ps5169_redriver_enable_chip(ps5169, false); + + return 0; +} + +static int ps5169_release_usb_lanes(struct usb_redriver *r, int ort, int num) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + enum operation_mode mode = ps5169->op_mode; + + if (num == 4) + mode = OP_MODE_DP; + else if (num == 2) + mode = OP_MODE_USB3_AND_DP; + else + mode = ps5169->op_mode; + + ps5169->typec_orientation = ort; + if (mode != ps5169->op_mode) { + dev_info(ps5169->dev, "%s: op mode %s -> %s\n", __func__, + OPMODESTR(ps5169->op_mode), OPMODESTR(mode)); + ps5169->op_mode = mode; + ps5169_redriver_enable_chip(ps5169, true); + ps5169_config_seqs_init(ps5169); + ps5169_config_work_mode(ps5169, mode); + } + return 0; +} + +static void ps5169_gadget_pullup_work(struct work_struct *w) +{ + struct ps5169_redriver *ps5169 = + container_of(w, struct ps5169_redriver, pullup_work); + + ps5169_redriver_enable_chip(ps5169, false); + usleep_range(1000, 1500); + ps5169_redriver_enable_chip(ps5169, true); + ps5169_config_seqs_init(ps5169); + ps5169_config_work_mode(ps5169, ps5169->op_mode); + + ps5169->work_ongoing = false; +} + +static int ps5169_gadget_pullup_enter(struct usb_redriver *r, int is_on) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + u64 time = 0; + + dev_info(ps5169->dev, "%s: mode %s, %d, %d\n", __func__, + OPMODESTR(ps5169->op_mode), is_on, ps5169->work_ongoing); + + if (ps5169->op_mode != OP_MODE_USB3) + return -EINVAL; + + if (!is_on) + return 0; + + while (ps5169->work_ongoing) { + udelay(1); + if (time++ > 500000) { + dev_warn(ps5169->dev, "pullup timeout\n"); + break; + } + } + + dev_info(ps5169->dev, "pull-up disable work took %llu us\n", time); + return 0; +} + +static int ps5169_gadget_pullup_exit(struct usb_redriver *r, int is_on) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + + dev_info(ps5169->dev, "%s: mode %s, %d, %d\n", __func__, + OPMODESTR(ps5169->op_mode), is_on, ps5169->work_ongoing); + + if (ps5169->op_mode != OP_MODE_USB3) + return -EINVAL; + + if (is_on) + return 0; + + ps5169->work_ongoing = true; + queue_work(system_highpri_wq, &ps5169->pullup_work); + + return 0; +} + +static void ps5169_host_work(struct work_struct *w) +{ + struct ps5169_redriver *ps5169 = + container_of(w, struct ps5169_redriver, host_work); + + ps5169_redriver_enable_chip(ps5169, false); + usleep_range(2000, 2500); + ps5169_redriver_enable_chip(ps5169, true); + ps5169_config_seqs_init(ps5169); + ps5169_config_work_mode(ps5169, ps5169->op_mode); +} + +static int ps5169_host_powercycle(struct usb_redriver *r) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + + if (ps5169->op_mode != OP_MODE_USB3) + return -EINVAL; + + schedule_work(&ps5169->host_work); + + return 0; +} + +static void ps5169_redriver_gpio_init(struct ps5169_redriver *ps5169) +{ + struct device *dev = ps5169->dev; + int rc; + + ps5169->enable_gpio = of_get_named_gpio(dev->of_node, "redriver,enable-gpio", 0); + if (!gpio_is_valid(ps5169->enable_gpio)) { + dev_err(dev, "Failed to get enable gpio\n"); + return; + } + + rc = devm_gpio_request_one(dev, ps5169->enable_gpio, + GPIOF_OUT_INIT_LOW, + "redriver-enable-gpio"); + if (rc < 0) { + dev_err(dev, "Failed to request enable gpio\n"); + ps5169->enable_gpio = -EINVAL; + return; + } +} + +static inline int ps5169_redriver_write_reg_bits(struct ps5169_redriver *ps5169, + unsigned int reg, unsigned int val, unsigned int mask) +{ + int ret = regmap_update_bits(ps5169->regmap, reg, mask, val); + + if (ret < 0) + dev_err(&ps5169->client->dev, "error update reg %u, ret=%d\n", reg, ret); + + dev_dbg(&ps5169->client->dev, "update reg[%u]=[%x], %x\n", reg, val, mask); + return ret; +} + +static int ps5169_config_dp_eq(struct ps5169_redriver *ps5169, + unsigned int eq) +{ + if (eq > PS5169_DP_EQ_MAX) { + dev_err(&ps5169->client->dev, "error dp eq value %u\n", eq); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_DP_EQ0_REG, + PS5169_DP_EQ0_VAL(eq), PS5169_DP_EQ0_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_DP_EQ1_REG, + PS5169_DP_EQ1_VAL(eq), PS5169_DP_EQ1_MASK); + + return 0; +} + +static int ps5169_config_dp_gain(struct ps5169_redriver *ps5169, + unsigned int gain) +{ + if (gain > PS5169_DP_GAIN_MAX) { + dev_err(&ps5169->client->dev, "error dp gain value %u\n", gain); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_DP_GAIN_REG, gain, + PS5169_DP_GAIN_MASK); + + return 0; +} + +static int ps5169_config_usb_tx_eq(struct ps5169_redriver *ps5169, + unsigned int eq) +{ + if (eq > PS5169_USB_TX_EQ_MAX) { + dev_err(&ps5169->client->dev, "error usb tx eq value %u\n", eq); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_TX_EQ0_REG, + PS5169_USB_TX_EQ0_VAL(eq), PS5169_USB_TX_EQ0_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_TX_EQ1_REG, + PS5169_USB_TX_EQ1_VAL(eq), PS5169_USB_TX_EQ1_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_TX_EQ2_REG, + PS5169_USB_TX_EQ2_VAL(eq), PS5169_USB_TX_EQ2_MASK); + + return 0; +} + +static int ps5169_config_usb_tx_gain(struct ps5169_redriver *ps5169, + unsigned int gain) +{ + if (gain > PS5169_USB_TX_GAIN_MAX) { + dev_err(&ps5169->client->dev, + "error usb tx gain value %u\n", gain); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_TX_GAIN_REG, gain, + PS5169_USB_TX_GAIN_MASK); + + return 0; +} + +static int ps5169_config_usb_rx_eq(struct ps5169_redriver *ps5169, + unsigned int eq) +{ + if (eq > PS5169_USB_RX_EQ_MAX) { + dev_err(&ps5169->client->dev, "error usb rx eq value %u\n", eq); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_RX_EQ0_REG, + PS5169_USB_RX_EQ0_VAL(eq), PS5169_USB_RX_EQ0_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_RX_EQ1_REG, + PS5169_USB_RX_EQ1_VAL(eq), PS5169_USB_RX_EQ1_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_RX_EQ2_REG, + PS5169_USB_RX_EQ2_VAL(eq), PS5169_USB_RX_EQ2_MASK); + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_RX_EQ3_REG, + PS5169_USB_RX_EQ3_VAL(eq), PS5169_USB_RX_EQ3_MASK); + + return 0; +} + +static int ps5169_config_usb_rx_gain(struct ps5169_redriver *ps5169, + unsigned int gain) +{ + if (gain > PS5169_USB_RX_GAIN_MAX) { + dev_err(&ps5169->client->dev, + "error usb rx gain value %u\n", gain); + return -EINVAL; + } + + ps5169_redriver_write_reg_bits(ps5169, PS5169_USB_RX_GAIN_REG, gain, + PS5169_USB_RX_GAIN_MASK); + + return 0; +} + +/* save user configuration and dump for device tree */ +static inline void update_config_reg(struct ps5169_redriver *ps5169, + unsigned int reg, unsigned int val, unsigned int mask) +{ + int i; + + for (i = 0; i < ps5169->config_seqs_cnt; i++) + if (ps5169->config_seqs[i].reg == reg) { + ps5169->config_seqs[i].def &= ~mask; + ps5169->config_seqs[i].def |= (val & mask); + break; + } + + if (i == ps5169->config_seqs_cnt) + pr_err("can't find reg %u in init regs\n", reg); +} + +static int dp_eq_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->dpeq; + + return 0; +} + +static int dp_eq_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_dp_eq(ps5169, val); + if (ret) + return ret; + + ps5169->dpeq = val; + + update_config_reg(ps5169, PS5169_DP_EQ0_REG, + PS5169_DP_EQ0_VAL(val), PS5169_DP_EQ0_MASK); + + update_config_reg(ps5169, PS5169_DP_EQ1_REG, + PS5169_DP_EQ1_VAL(val), PS5169_DP_EQ1_MASK); + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(dp_eq_ops, dp_eq_get, dp_eq_set, "%llu\n"); + +static int dp_gain_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->dpgain; + + return 0; +} + +static int dp_gain_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_dp_gain(ps5169, val); + if (ret) + return ret; + + ps5169->dpgain = val; + + update_config_reg(ps5169, PS5169_DP_GAIN_REG, val, + PS5169_DP_GAIN_MASK); + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(dp_gain_ops, dp_gain_get, dp_gain_set, "%llu\n"); + +static int usb_tx_eq_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->usbtxeq; + + return 0; +} + +static int usb_tx_eq_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_usb_tx_eq(ps5169, val); + if (ret) + return ret; + + ps5169->usbtxeq = val; + + update_config_reg(ps5169, PS5169_USB_TX_EQ0_REG, + PS5169_USB_TX_EQ0_VAL(val), PS5169_USB_TX_EQ0_MASK); + + update_config_reg(ps5169, PS5169_USB_TX_EQ1_REG, + PS5169_USB_TX_EQ1_VAL(val), PS5169_USB_TX_EQ1_MASK); + + update_config_reg(ps5169, PS5169_USB_TX_EQ2_REG, + PS5169_USB_TX_EQ2_VAL(val), PS5169_USB_TX_EQ2_MASK); + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(usb_tx_eq_ops, usb_tx_eq_get, usb_tx_eq_set, "%llu\n"); + +static int usb_tx_gain_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->usbtxgain; + + return 0; +} + +static int usb_tx_gain_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_usb_tx_gain(ps5169, val); + if (ret) + return ret; + + ps5169->usbtxgain = val; + + update_config_reg(ps5169, PS5169_USB_TX_GAIN_REG, val, + PS5169_USB_TX_GAIN_MASK); + + return ret; +} + +DEFINE_DEBUGFS_ATTRIBUTE(usb_tx_gain_ops, + usb_tx_gain_get, usb_tx_gain_set, "%llu\n"); + +static int usb_rx_eq_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->usbrxeq; + + return 0; +} + +static int usb_rx_eq_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_usb_rx_eq(ps5169, val); + if (ret) + return ret; + + ps5169->usbtxeq = val; + + update_config_reg(ps5169, PS5169_USB_RX_EQ0_REG, + PS5169_USB_RX_EQ0_VAL(val), PS5169_USB_RX_EQ0_MASK); + + update_config_reg(ps5169, PS5169_USB_RX_EQ1_REG, + PS5169_USB_RX_EQ1_VAL(val), PS5169_USB_RX_EQ1_MASK); + + update_config_reg(ps5169, PS5169_USB_RX_EQ2_REG, + PS5169_USB_RX_EQ2_VAL(val), PS5169_USB_RX_EQ2_MASK); + + update_config_reg(ps5169, PS5169_USB_RX_EQ3_REG, + PS5169_USB_RX_EQ3_VAL(val), PS5169_USB_RX_EQ3_MASK); + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(usb_rx_eq_ops, + usb_rx_eq_get, usb_rx_eq_set, "%llu\n"); + +static int usb_rx_gain_get(void *data, u64 *val) +{ + struct ps5169_redriver *ps5169 = data; + + *val = ps5169->usbrxgain; + + return 0; +} + +static int usb_rx_gain_set(void *data, u64 val) +{ + int ret; + + struct ps5169_redriver *ps5169 = data; + + ret = ps5169_config_usb_rx_gain(ps5169, val); + if (ret) + return ret; + + ps5169->usbrxgain = val; + + update_config_reg(ps5169, PS5169_USB_RX_GAIN_REG, val, + PS5169_USB_RX_GAIN_MASK); + + return ret; +} + +static int config_seqs_show(struct seq_file *s, void *unused) +{ + struct ps5169_redriver *ps5169 = s->private; + int i; + + for (i = 0; i < ps5169->config_seqs_cnt; i++) + seq_printf(s, "0x%02x 0x%02x %u\n", + ps5169->config_seqs[i].reg, + ps5169->config_seqs[i].def, + ps5169->config_seqs[i].delay_us); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(config_seqs); + +DEFINE_DEBUGFS_ATTRIBUTE(usb_rx_gain_ops, + usb_rx_gain_get, usb_rx_gain_set, "%llu\n"); + +static void ps5169_debugfs_create(struct ps5169_redriver *ps5169) +{ + struct i2c_client *client = ps5169->client; + + ps5169->debug_root = debugfs_create_dir("ps5169", NULL); + if (!ps5169->debug_root) { + dev_warn(&client->dev, "couldn't create debug dir\n"); + return; + } + + debugfs_create_file("dp-eq", 0644, + ps5169->debug_root, ps5169, &dp_eq_ops); + + debugfs_create_file("dp-gain", 0644, + ps5169->debug_root, ps5169, &dp_gain_ops); + + debugfs_create_file("usb-tx-eq", 0644, + ps5169->debug_root, ps5169, &usb_tx_eq_ops); + + debugfs_create_file("usb-tx-gain", 0644, + ps5169->debug_root, ps5169, &usb_tx_gain_ops); + + debugfs_create_file("usb-rx-eq", 0644, + ps5169->debug_root, ps5169, &usb_rx_eq_ops); + + debugfs_create_file("usb-rx-gain", 0644, + ps5169->debug_root, ps5169, &usb_rx_gain_ops); + + debugfs_create_file("config_seqs", 0444, + ps5169->debug_root, ps5169, &config_seqs_fops); +} + +static int ps5169_config_seqs_init(struct ps5169_redriver *ps5169) +{ + int ret = 0; + + regmap_register_patch(ps5169->regmap, + ps5169->config_seqs, ps5169->config_seqs_cnt); + + ret = ps5169_redriver_write_reg_bits(ps5169, PS5169_CONFIG_REG, + PS5169_PD_ACTIVE, PS5169_PD_ACTIVE); + + return ret; +} + +void usb_redriver_config_dp_eq(struct usb_redriver *r) +{ + struct ps5169_redriver *ps5169 = + container_of(r, struct ps5169_redriver, r); + + if (IS_ERR_OR_NULL(ps5169)) + return -EINVAL; + + if (ps5169->config_dp_eq) { + ps5169_redriver_write_reg_bits(ps5169, 0x52, 0x00, 0xff); + ps5169_redriver_write_reg_bits(ps5169, 0x5e, 0x04, 0xff); + dev_info(ps5169->dev, "%s, done.\n", __func__); + } +} +EXPORT_SYMBOL(usb_redriver_config_dp_eq); + +static void ps5169_config_work_mode(struct ps5169_redriver *ps5169, + enum operation_mode mode) +{ + struct i2c_client *client = ps5169->client; + unsigned int val, mask; + + switch (mode) { + case OP_MODE_NONE: + mask = PS5169_PD_ACTIVE | PS5169_USB3_EN | PS5169_DP_EN; + val = PS5169_PD_ACTIVE; + dev_dbg(&client->dev, "write config %02x | %02x\n", val, mask); + ps5169_redriver_write_reg_bits(ps5169, + PS5169_CONFIG_REG, val, mask); + ps5169_redriver_write_reg_bits(ps5169, 0xa0, 0x02, 0xff); + ps5169_redriver_write_reg_bits(ps5169, 0xa1, 0x00, 0xff); + break; + case OP_MODE_USB3: + mask = PS5169_PD_ACTIVE | PS5169_USB3_EN | PS5169_DP_EN | + PS5169_FLIPPED; + val = PS5169_PD_ACTIVE | PS5169_USB3_EN; + if (ps5169->typec_orientation == ORIENTATION_CC2) + val |= PS5169_FLIPPED; + dev_dbg(&client->dev, "write config %02x | %02x\n", val, mask); + ps5169_redriver_write_reg_bits(ps5169, + PS5169_CONFIG_REG, val, mask); + break; + case OP_MODE_DP: + mask = PS5169_PD_ACTIVE | PS5169_USB3_EN | PS5169_DP_EN | + PS5169_FLIPPED; + val = PS5169_PD_ACTIVE | PS5169_DP_EN; + if (ps5169->typec_orientation == ORIENTATION_CC2) + val |= PS5169_FLIPPED; + dev_dbg(&client->dev, "write config %02x | %02x\n", val, mask); + ps5169_redriver_write_reg_bits(ps5169, + PS5169_CONFIG_REG, val, mask); + ps5169_redriver_write_reg_bits(ps5169, 0xa0, 0x00, 0xff); + ps5169_redriver_write_reg_bits(ps5169, 0xa1, 0x04, 0xff); + break; + case OP_MODE_USB3_AND_DP: + mask = PS5169_PD_ACTIVE | PS5169_USB3_EN | PS5169_DP_EN | + PS5169_FLIPPED; + val = PS5169_PD_ACTIVE | PS5169_USB3_EN | PS5169_DP_EN; + if (ps5169->typec_orientation == ORIENTATION_CC2) + val |= PS5169_FLIPPED; + dev_dbg(&client->dev, "write config %02x | %02x\n", val, mask); + ps5169_redriver_write_reg_bits(ps5169, + PS5169_CONFIG_REG, val, mask); + ps5169_redriver_write_reg_bits(ps5169, 0xa0, 0x00, 0xff); + ps5169_redriver_write_reg_bits(ps5169, 0xa1, 0x04, 0xff); + break; + default: + pr_err("operation mode is not support\n"); + return; + } +} + + +static const struct regmap_config ps5169_regmap = { + .max_register = 0xff, + .reg_bits = 8, + .val_bits = 8, +}; + +static int ps5169_i2c_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct ps5169_redriver *ps5169; + int ret, size = 0; + u32 device_id; + + ps5169 = devm_kzalloc(dev, sizeof(*ps5169), GFP_KERNEL); + if (!ps5169) + return -ENOMEM; + + ps5169->dev = dev; + ps5169->client = client; + ps5169_redriver_gpio_init(ps5169); + + of_get_property(dev->of_node, "config-seq", &size); + if (!size || size % (3 * sizeof(unsigned int))) { + dev_err(dev, "no config-seq or size is wrong\n"); + return -EINVAL; + } + + ps5169->config_seqs = devm_kzalloc(dev, size, GFP_KERNEL); + if (!ps5169->config_seqs) + return -ENOMEM; + ps5169->config_seqs_cnt = size / (3 * sizeof(unsigned int)); + of_property_read_u32_array(dev->of_node, + "config-seq", + (u32 *)ps5169->config_seqs, + ps5169->config_seqs_cnt * 3); + + ps5169->regmap = devm_regmap_init_i2c(client, &ps5169_regmap); + if (IS_ERR(ps5169->regmap)) { + ret = PTR_ERR(ps5169->regmap); + dev_err(dev, "failed to allocate register map: %d\n", ret); + return ret; + } + + ps5169->config_dp_eq = of_property_read_bool(dev->of_node, "redriver,config-dp-eq"); + + ps5169->vcc = devm_regulator_get_optional(&client->dev, "vcc"); + if (IS_ERR(ps5169->vcc) || ps5169->vcc == NULL) { + dev_err(&client->dev, "Could not get vcc power regulator\n"); + } else { + ret = regulator_enable(ps5169->vcc); + if (ret) + dev_err(&client->dev, "Could not enable vcc power regulator\n"); + } + ps5169->vio = devm_regulator_get_optional(&client->dev, "vio"); + if (IS_ERR(ps5169->vio) || ps5169->vio == NULL) { + dev_err(&client->dev, "Could not get vio power regulator\n"); + } else { + ret = regulator_enable(ps5169->vio); + if (ret) + dev_err(&client->dev, "Could not enable vio power regulator\n"); + } + + ps5169_redriver_enable_chip(ps5169, true); + ret = regmap_raw_read(ps5169->regmap, PS5169_CHIPID_REG, &device_id, 2); + if (ret != 0) { + dev_err(dev, "%s,device id read failed:%d\n", __func__, ret); + } else if (device_id != PS5169_CHIP_ID) { + dev_err(dev, "%s,device id unknown: 0x%x\n", __func__, device_id); + } + dev_info(dev, "%s,device_id=0x%x\n", __func__, device_id); + + i2c_set_clientdata(client, ps5169); + + ps5169_config_seqs_init(ps5169); + + /* how about USB enumerated before this driver load */ + ps5169_config_work_mode(ps5169, OP_MODE_NONE); + ps5169->op_mode = OP_MODE_NONE; + ps5169_redriver_enable_chip(ps5169, false); + + ps5169_debugfs_create(ps5169); + INIT_WORK(&ps5169->pullup_work, ps5169_gadget_pullup_work); + INIT_WORK(&ps5169->host_work, ps5169_host_work); + + ps5169->r.of_node = ps5169->dev->of_node; + ps5169->r.release_usb_lanes = ps5169_release_usb_lanes; + ps5169->r.notify_connect = ps5169_notify_connect; + ps5169->r.notify_disconnect = ps5169_notify_disconnect; + ps5169->r.gadget_pullup_enter = ps5169_gadget_pullup_enter; + ps5169->r.gadget_pullup_exit = ps5169_gadget_pullup_exit; + ps5169->r.host_powercycle = ps5169_host_powercycle; + usb_add_redriver(&ps5169->r); + + dev_info(dev, "%s,ps5169 probe done.\n", __func__); + + return 0; +} + +static void ps5169_i2c_remove(struct i2c_client *client) +{ + struct ps5169_redriver *ps5169 = i2c_get_clientdata(client); + + if (usb_remove_redriver(&ps5169->r)) + return; + + debugfs_remove(ps5169->debug_root); + if (!IS_ERR_OR_NULL(ps5169->vcc)) { + if (regulator_is_enabled(ps5169->vcc)) + regulator_disable(ps5169->vcc); + devm_regulator_put(ps5169->vcc); + } + if (!IS_ERR_OR_NULL(ps5169->vio)) { + if (regulator_is_enabled(ps5169->vio)) + regulator_disable(ps5169->vio); + devm_regulator_put(ps5169->vio); + } +} + +static int __maybe_unused redriver_i2c_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct ps5169_redriver *ps5169 = i2c_get_clientdata(client); + + dev_dbg(ps5169->dev, "%s: SS USB redriver suspend.\n", + __func__); + + /* + * 1. when in 4 lanes display mode, it can't disable; + * 2. when in NONE mode, there is no need to re-disable; + * 3. when in DEFAULT mode, there is no adsp and can't disable; + */ + if (ps5169->op_mode == OP_MODE_DP || + ps5169->op_mode == OP_MODE_NONE || + ps5169->op_mode == OP_MODE_DEFAULT) + return 0; + + ps5169_redriver_enable_chip(ps5169, false); + + return 0; +} + +static int __maybe_unused redriver_i2c_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct ps5169_redriver *ps5169 = i2c_get_clientdata(client); + + dev_dbg(ps5169->dev, "%s: SS USB redriver resume.\n", + __func__); + + /* no suspend happen in following mode */ + if (ps5169->op_mode == OP_MODE_DP || + ps5169->op_mode == OP_MODE_NONE || + ps5169->op_mode == OP_MODE_DEFAULT) + return 0; + + ps5169_redriver_enable_chip(ps5169, true); + ps5169_config_seqs_init(ps5169); + ps5169_config_work_mode(ps5169, ps5169->op_mode); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(redriver_i2c_pm, redriver_i2c_suspend, + redriver_i2c_resume); + +static void ps5169_i2c_shutdown(struct i2c_client *client) +{ + struct ps5169_redriver *ps5169 = i2c_get_clientdata(client); + int ret; + + ret = ps5169_redriver_enable_chip(ps5169, false); + if (ret < 0) + dev_err(&client->dev, + "%s: fail to disable redriver.\n", + __func__); + else + dev_dbg(&client->dev, + "%s: successfully disable redriver.\n", + __func__); +} + +static const struct of_device_id ps5169_match_table[] = { + { .compatible = "parade,ps5169-redriver",}, + { }, +}; + +static const struct i2c_device_id ps5169_i2c_id[] = { + { "ps5169 redriver", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, ps5169_i2c_id); + +static struct i2c_driver ps5169_i2c_driver = { + .driver = { + .name = "ps5169 redriver", + .of_match_table = ps5169_match_table, + .pm = &redriver_i2c_pm, + }, + + .probe = ps5169_i2c_probe, + .remove = ps5169_i2c_remove, + + .shutdown = ps5169_i2c_shutdown, + + .id_table = ps5169_i2c_id, +}; +module_i2c_driver(ps5169_i2c_driver); + +MODULE_DESCRIPTION("Parade PS5169 USB3.1 Gen2 Type-C 10Gbps Linear Redriver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/usb/repeater/repeater-qti-pmic-eusb2.c b/drivers/usb/repeater/repeater-qti-pmic-eusb2.c index 711f05bbc..1eb127629 100644 --- a/drivers/usb/repeater/repeater-qti-pmic-eusb2.c +++ b/drivers/usb/repeater/repeater-qti-pmic-eusb2.c @@ -174,9 +174,9 @@ static void eusb2_repeater_update_seq(struct eusb2_repeater *er, { int i; - dev_dbg(er->ur.dev, "param override seq count:%d\n", cnt); + dev_info(er->ur.dev, "param override seq count:%d\n", cnt); for (i = 0; i < cnt; i = i+2) { - dev_dbg(er->ur.dev, "write 0x%02x to 0x%02x\n", + dev_info(er->ur.dev, "write 0x%02x to 0x%02x\n", seq[i], seq[i+1]); eusb2_repeater_reg_write(er, seq[i+1], seq[i]); } diff --git a/include/linux/sched/walt.h b/include/linux/sched/walt.h index cbc3e912c..a46dea024 100644 --- a/include/linux/sched/walt.h +++ b/include/linux/sched/walt.h @@ -124,6 +124,9 @@ struct walt_task_struct { u64 active_time; u64 last_win_size; int boost; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + u16 ux_type; // Moto huangzq2: add ux flag for moto_sched +#endif bool wake_up_idle; bool misfit; bool rtg_high_prio; @@ -200,6 +203,57 @@ static inline void set_wake_up_idle(bool wake_up_idle) extern int sched_lpm_disallowed_time(int cpu, u64 *timeout); extern int set_task_boost(int boost, u64 period); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +// Moto huangzq2: export api for moto_sched +extern int set_moto_sched_enabled(int enable); + +struct msched_ops { + int (*task_get_mvp_prio)(struct task_struct *p, bool with_inherit); + unsigned int (*task_get_mvp_limit)(struct task_struct *p, int mvp_prio); + void (*binder_inherit_ux_type)(struct task_struct *task); + void (*binder_clear_inherited_ux_type)(struct task_struct *task); + void (*binder_ux_type_set)(struct task_struct *task); + void (*queue_ux_task)(struct rq *rq, struct task_struct *task, int enqueue); +}; + +extern struct msched_ops *moto_sched_ops; +extern void set_moto_sched_ops(struct msched_ops *ops); + +static inline int moto_task_get_mvp_prio(struct task_struct *p, bool with_inherit) { + if (moto_sched_ops != NULL && moto_sched_ops->task_get_mvp_prio != NULL) + return moto_sched_ops->task_get_mvp_prio(p, with_inherit); + + return -1; +} + +static inline unsigned int moto_task_get_mvp_limit(struct task_struct *p, int mvp_prio) { + if (moto_sched_ops != NULL && moto_sched_ops->task_get_mvp_limit != NULL) + return moto_sched_ops->task_get_mvp_limit(p, mvp_prio); + + return -1; +} + +static inline void moto_binder_inherit_ux_type(struct task_struct *task) { + if (moto_sched_ops != NULL && moto_sched_ops->binder_inherit_ux_type != NULL) + return moto_sched_ops->binder_inherit_ux_type(task); +} + +static inline void moto_binder_clear_inherited_ux_type(struct task_struct *task) { + if (moto_sched_ops != NULL && moto_sched_ops->binder_clear_inherited_ux_type != NULL) + return moto_sched_ops->binder_clear_inherited_ux_type(task); +} + +static inline void moto_binder_ux_type_set(struct task_struct *task) { + if (moto_sched_ops != NULL && moto_sched_ops->binder_ux_type_set != NULL) + return moto_sched_ops->binder_ux_type_set(task); +} + +static inline void moto_queue_ux_task(struct rq *rq, struct task_struct *task, int enqueue) { + if (moto_sched_ops != NULL && moto_sched_ops->queue_ux_task != NULL) + return moto_sched_ops->queue_ux_task(rq, task, enqueue); +} +#endif + struct notifier_block; extern void core_ctl_notifier_register(struct notifier_block *n); extern void core_ctl_notifier_unregister(struct notifier_block *n); diff --git a/include/linux/soc/qcom/panel_event_notifier.h b/include/linux/soc/qcom/panel_event_notifier.h index ad4ecf9bc..b54030af1 100644 --- a/include/linux/soc/qcom/panel_event_notifier.h +++ b/include/linux/soc/qcom/panel_event_notifier.h @@ -24,6 +24,7 @@ enum panel_event_notifier_client { PANEL_EVENT_NOTIFIER_CLIENT_SECONDARY_TOUCH, PANEL_EVENT_NOTIFIER_CLIENT_ECM, PANEL_EVENT_NOTIFIER_CLIENT_BATTERY_CHARGER, + PANEL_EVENT_NOTIFIER_CLIENT_FPS, PANEL_EVENT_NOTIFIER_CLIENT_MAX }; diff --git a/include/linux/usb/dwc3-msm.h b/include/linux/usb/dwc3-msm.h index 6095f1331..78ad4f201 100644 --- a/include/linux/usb/dwc3-msm.h +++ b/include/linux/usb/dwc3-msm.h @@ -290,6 +290,7 @@ int msm_ep_update_ops(struct usb_ep *ep); int msm_ep_clear_ops(struct usb_ep *ep); int msm_ep_set_mode(struct usb_ep *ep, enum usb_hw_ep_mode mode); int dwc3_core_stop_hw_active_transfers(struct dwc3 *dwc); +int dwc3_msm_set_usb_redriver_eq(struct device *dev); #else void dwc3_msm_notify_event(struct dwc3 *dwc, enum dwc3_notify_event event, unsigned int value) @@ -322,6 +323,8 @@ int msm_ep_set_mode(struct usb_ep *ep, enum usb_hw_ep_mode mode) { return -ENODEV; } inline int dwc3_core_stop_hw_active_transfers(struct dwc3 *dwc) { return 0; } +inline int dwc3_msm_set_usb_redriver_eq(struct device *dev) +{ return 0; } #endif #ifdef CONFIG_ARM64 diff --git a/include/linux/usb/redriver.h b/include/linux/usb/redriver.h index 126321843..12b927e33 100644 --- a/include/linux/usb/redriver.h +++ b/include/linux/usb/redriver.h @@ -75,6 +75,7 @@ void usb_redriver_notify_disconnect(struct usb_redriver *ur); void usb_redriver_gadget_pullup_enter(struct usb_redriver *ur, int is_on); void usb_redriver_gadget_pullup_exit(struct usb_redriver *ur, int is_on); void usb_redriver_host_powercycle(struct usb_redriver *ur); +void usb_redriver_config_dp_eq(struct usb_redriver *ur); #else @@ -95,6 +96,10 @@ static inline int usb_remove_redriver(struct usb_redriver *ur) return 0; } +static inline void usb_redriver_config_dp_eq(struct usb_redriver *ur) +{ +} + #define usb_put_redriver(ur) do {} while (0) #define usb_redriver_release_lanes(ur, ort, num) do {} while (0) diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 4b31629c5..613e01b2d 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -350,3 +350,22 @@ config ENERGY_MODEL The exact usage of the energy model is subsystem-dependent. If in doubt, say N. + +config SUSPEND_DEBUG + tristate "Enable snapshot of regulator and tlmm when suspend" + depends on SUSPEND + default n + help + This allows you to dump the regulator state and tlmm configuration + before suspend. It doesn't work only if you have read the system + file node /sys/privae/tlmm_before_sleep and vreg_before_sleep + +config GPIO_VALID_ARRAY + bool "Check if a gpio is valid in an array" + depends on SUSPEND_DEBUG + default n + help + This allows you to use an array maintained manually to indicate + if a GPIO can be accessed by APPS. It's only needed when the GPIO + is still unaccessible although gpiochip_line_is_valid() returns + true. diff --git a/kernel/power/Makefile b/kernel/power/Makefile index 3e84020e7..759e89139 100644 --- a/kernel/power/Makefile +++ b/kernel/power/Makefile @@ -23,3 +23,5 @@ obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o obj-$(CONFIG_SUSPEND) += wakeup_reason.o obj-$(CONFIG_ENERGY_MODEL) += energy_model.o + +obj-$(CONFIG_SUSPEND_DEBUG) += user_sysfs_private.o diff --git a/kernel/power/user_sysfs_private.c b/kernel/power/user_sysfs_private.c new file mode 100644 index 000000000..482490a7a --- /dev/null +++ b/kernel/power/user_sysfs_private.c @@ -0,0 +1,923 @@ +/* +* Copyright (C) 2012 lenovo, Inc. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_PINCTRL_MSM_MODULE +#include "../../drivers/pinctrl/qcom/pinctrl-msm.h" +#endif +#include +#include "user_sysfs_private.h" + +#define GPIO_CFG(gpio, func, dir, pull, drvstr) \ + ((((gpio) & 0x3FF) << 4) | \ + ((func) & 0xf) | \ + (((dir) & 0x1) << 14) | \ + (((pull) & 0x3) << 15) | \ + (((drvstr) & 0xF) << 17)) + +/** + * extract GPIO pin from bit-field used for gpio_tlmm_config + */ +#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff) +#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf) +#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1) +#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3) +#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf) + +#define TLMM_NUM_GPIO 255 + +#define HAL_OUTPUT_VAL(config) (((config)&0x40000000)>>30) + +static int before_sleep_fetched; +module_param(before_sleep_fetched, int, 0644); +static unsigned before_sleep_configs[TLMM_NUM_GPIO]; + +static int before_sleep_table_enabled; +module_param(before_sleep_table_enabled, int, 0644); +static unsigned before_sleep_table_configs[TLMM_NUM_GPIO]; + +#ifdef CONFIG_GPIO_VALID_ARRAY +static unsigned tz_configs[TLMM_NUM_GPIO]; +#endif + +#ifndef CONFIG_PINCTRL_MSM_MODULE +int tlmm_get_inout(unsigned gpio) +{ + return 0; +} + +int tlmm_set_inout(unsigned gpio, unsigned value) +{ + return 0; +} + +int tlmm_get_config(unsigned gpio, unsigned *cfg) +{ + return -EINVAL; +} + +int tlmm_set_config(unsigned config) +{ + return -EINVAL; +} +#endif + +static int tlmm_dump_cfg(char *buf, int size, + unsigned gpio, unsigned cfg, int output_val) +{ + /* mA */ + static const char * const drvstr_str[] = { + "2", "4", "6", "8", "10", "12", "14", "16" }; + /* "NO_PULL", "PULL_DOWN", "KEEPER", "PULL_UP" */ + static const char * const pull_str[] = { "N", "D", "K", "U" }; + /* "Input", "Output" */ + static const char * const dir_str[] = { "I", "O" }; + char func_str[20]; + + char *p = buf; + + int drvstr = GPIO_DRVSTR(cfg); + int pull = GPIO_PULL(cfg); + int dir = GPIO_DIR(cfg); + int func = GPIO_FUNC(cfg); + + /* pr_debug("%s(), drvstr=%d, pull=%d, dir=%d, func=%d\n", */ + /* __func__, drvstr, pull, dir, func); */ + snprintf(func_str, sizeof(func_str), "%d", func); + + p += snprintf(p, size - (p - buf), "%d: %s%s%s%s", gpio, func_str, + pull_str[pull], dir_str[dir], drvstr_str[drvstr]); + + p += snprintf(p, size - (p - buf), " = %d", output_val); + + p += snprintf(p, size - (p - buf), "\n"); + + return p - buf; +} + +static int tlmm_dump_header(char *buf, int size) +{ + char *p = buf; + + p += snprintf(p, size - (p - buf), + "0:GPIO\n"); + p += snprintf(p, size - (p - buf), + "N:NO_PULL D:PULL_DOWN K:KEEPER U:PULL_UP\n"); + p += snprintf(p, size - (p - buf), + "I:Input O:Output\n"); + p += snprintf(p, size - (p - buf), + "2:2, 4, 6, 8, 10, 12, 14, 16 mA (driver strength)\n\n"); + return p - buf; +} + +int tlmm_dump_info(char *buf, int size, int tlmm_num, int tlmm_count) +{ + unsigned i; + char *p = buf; + unsigned cfg; + int output_val = 0; + int ret; + + if (tlmm_num < 0 || tlmm_num >= TLMM_NUM_GPIO) + return p - buf; + + if (tlmm_count == 1) { +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[tlmm_num]) + return p - buf; +#endif + ret = tlmm_get_config(tlmm_num, &cfg); + if (ret == 0) { + output_val = tlmm_get_inout(tlmm_num); + + p += tlmm_dump_cfg(p, size - (p - buf), + tlmm_num, cfg, output_val); + } + } else { + p += tlmm_dump_header(p, size - (p - buf)); + p += snprintf(p, size - (p - buf), + "Format: gpio func pull dir strength [output]\n"); + p += snprintf(p, size - (p - buf), + "Shortcut: gpio output\n"); + p += snprintf(p, size - (p - buf), + "echo 20 0 D O 2 1, Config tlmm 20 and output 1\n"); + p += snprintf(p, size - (p - buf), + "echo 20 1, Set tlmm 20 to output 1\n"); + + for (i = tlmm_num; i < tlmm_num + tlmm_count; ++i) { + if (i >= TLMM_NUM_GPIO) + break; + +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[i]) + continue; +#endif + ret = tlmm_get_config(i, &cfg); + if (ret == 0) { + output_val = tlmm_get_inout(i); + + p += tlmm_dump_cfg(p, size - (p - buf), + i, cfg, output_val); + } + } + pr_debug("%s(), %d\n", __func__, __LINE__); + p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf)); + } + return p - buf; +} + +/* save tlmm config before sleep */ +void tlmm_before_sleep_save_configs(void) +{ + unsigned i; + int ret; + + /* only save tlmm configs when it has been fetched */ + if (!before_sleep_fetched) + return; + + pr_debug("%s(), Save tlmms before suspend!\n", __func__); + before_sleep_fetched = false; + for (i = 0; i < TLMM_NUM_GPIO; ++i) { + unsigned cfg; + int output_val = 0; + +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[i]) + continue; +#endif + ret = tlmm_get_config(i, &cfg); + if (ret == -ENODEV) + break; + output_val = tlmm_get_inout(i); + + before_sleep_configs[i] = cfg | (output_val << 30); + } +} +EXPORT_SYMBOL_GPL(tlmm_before_sleep_save_configs); + +int tlmm_before_sleep_dump_info(char *buf, int size) +{ + unsigned i; + char *p = buf; + + p += snprintf(p, size - (p - buf), "tlmm_before_sleep:\n"); + if (!before_sleep_fetched) { + before_sleep_fetched = true; + + p += tlmm_dump_header(p, size - (p - buf)); + + for (i = 0; i < TLMM_NUM_GPIO; ++i) { + unsigned cfg; + int output_val = 0; + +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[i]) + continue; +#endif + cfg = before_sleep_configs[i]; + output_val = HAL_OUTPUT_VAL(cfg); + /* cfg &= ~0x40000000; */ + p += tlmm_dump_cfg(p, size - (p - buf), + i, cfg, output_val); + } + p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf)); + } + return p - buf; +} + +/* set tlmms config before sleep */ +void tlmm_before_sleep_set_configs(void) +{ + int res; + unsigned i; + + /* only set tlmms before sleep when it's enabled */ + if (!before_sleep_table_enabled) + return; + + pr_debug("%s(), Set tlmms before suspend!\n", __func__); + for (i = 0; i < TLMM_NUM_GPIO; ++i) { + unsigned cfg; + int gpio; + int dir; + int func; + int output_val = 0; + +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[i]) + continue; +#endif + cfg = before_sleep_table_configs[i]; + + gpio = GPIO_PIN(cfg); + if (gpio != i) + continue; + + output_val = HAL_OUTPUT_VAL(cfg); + dir = GPIO_DIR(cfg); + func = GPIO_FUNC(cfg); + + pr_debug("%s(), [%d]: 0x%x\n", __func__, i, cfg); + if (gpio < TLMM_NUM_GPIO) + res = tlmm_set_config(cfg & ~0x40000000); + if (res == -ENODEV) { + pr_debug("Error: Config failed.\n"); + break; + } + + if ((func == 0) && (dir == 1)) + tlmm_set_inout(i, output_val); + } +} +EXPORT_SYMBOL_GPL(tlmm_before_sleep_set_configs); + +#ifdef CONFIG_GPIO_VALID_ARRAY +int tlmm_tz_dump_info(char *buf, int size) +{ + unsigned i; + char *p = buf; + + p += snprintf(p, size - (p - buf), + "Format: gpio skip\n"); + p += snprintf(p, size - (p - buf), + "Skip tlmms that locked by TZ.\n"); + + for (i = 0; i < TLMM_NUM_GPIO; ++i) { + p += snprintf(p, size - (p - buf), "%d: ", i); + p += snprintf(p, size - (p - buf), "%d\n", tz_configs[i]); + } + p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf)); + return p - buf; +} +#endif + +int tlmm_before_sleep_table_set_cfg(unsigned gpio, unsigned cfg) +{ + if (gpio >= TLMM_NUM_GPIO && gpio != 255 && gpio != 256) { + pr_debug("gpio >= TLMM_NUM_GPIO && gpio != 255 && gpio != 256!\n"); + return -EINVAL; + } + + if (gpio < TLMM_NUM_GPIO) { + before_sleep_table_configs[gpio] = cfg; + before_sleep_table_enabled = true; + } else if (gpio == 255) + before_sleep_table_enabled = true; + else if (gpio == 256) + before_sleep_table_enabled = false; + + return 0; +} + +int tlmm_before_sleep_table_dump_info(char *buf, int size) +{ + unsigned i; + char *p = buf; + + p += tlmm_dump_header(p, size - (p - buf)); + p += snprintf(p, size - (p - buf), + "Format: gpio function pull direction strength [output]\n"); + p += snprintf(p, size - (p - buf), + "Set tlmm before suspend.\n"); + p += snprintf(p, size - (p - buf), + "echo 20 0 D O 2 1, tlmm 20 output 1\n"); + p += snprintf(p, size - (p - buf), + "echo 20, Disable tlmm 20's setting\n"); + p += snprintf(p, size - (p - buf), + "echo 255, Enable the setting\n"); + p += snprintf(p, size - (p - buf), + "echo 256, Disable the setting\n"); + + for (i = 0; i < TLMM_NUM_GPIO; ++i) { + unsigned cfg; + int output_val = 0; + +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[i]) + continue; +#endif + cfg = before_sleep_table_configs[i]; + output_val = HAL_OUTPUT_VAL(cfg); + /* cfg &= ~0x40000000; */ + p += tlmm_dump_cfg(p, size - (p - buf), i, cfg, output_val); + } + p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf)); + return p - buf; +} + +#define private_attr(_name) \ +static struct kobj_attribute _name##_attr = { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = 0644, \ + }, \ + .show = _name##_show, \ + .store = _name##_store, \ +} + +static int tlmm_num; +static ssize_t tlmm_num_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += snprintf(p, PAGE_SIZE, "Start gpio to check by cat tlmm\n"); + p += snprintf(p, PAGE_SIZE - (p - buf), "0~%d\n", TLMM_NUM_GPIO - 1); + p += snprintf(p, PAGE_SIZE - (p - buf), "%d\n", tlmm_num); + return p - buf; +} + +static ssize_t tlmm_num_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t n) +{ + int gpio; + int res; + + res = kstrtoint(buf, 10, &gpio); + pr_debug("res=%d. %d\n", res, gpio); + + if (res != 0) + goto tlmm_num_store_wrong_para; + + if (gpio >= TLMM_NUM_GPIO) + goto tlmm_num_store_wrong_para; + + tlmm_num = gpio; + pr_debug("tlmm_num: %d\n", tlmm_num); + + goto tlmm_num_store_ok; + +tlmm_num_store_wrong_para: + pr_debug("Wrong Input.\n"); + pr_debug("Format: tlmm_num\n"); + pr_debug(" tlmm_num: 0~%d\n", TLMM_NUM_GPIO - 1); + +tlmm_num_store_ok: + return n; +} +static int tlmm_count = TLMM_NUM_GPIO; +static ssize_t tlmm_count_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += snprintf(p, PAGE_SIZE, "Number of gpios to check by cat tlmm\n"); + p += snprintf(p, PAGE_SIZE - (p - buf), "0~%d\n", TLMM_NUM_GPIO); + p += snprintf(p, PAGE_SIZE - (p - buf), "%d\n", tlmm_count); + return p - buf; +} + +static ssize_t tlmm_count_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + int gpio; + int res; + + res = kstrtoint(buf, 10, &gpio); + pr_debug("res=%d. %d\n", res, gpio); + + if (res != 0) + goto tlmm_count_store_wrong_para; + + if (gpio >= TLMM_NUM_GPIO) + goto tlmm_count_store_wrong_para; + + tlmm_count = gpio; + pr_debug("tlmm_count: %d\n", tlmm_count); + + goto tlmm_count_store_ok; + +tlmm_count_store_wrong_para: + pr_debug("Wrong Input.\n"); + pr_debug("Format: tlmm_count\n"); + pr_debug(" tlmm_count: 0~%d\n", TLMM_NUM_GPIO); + +tlmm_count_store_ok: + return n; +} + +static ssize_t tlmm_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + char *p = buf; + + p += tlmm_dump_info(buf, PAGE_SIZE, tlmm_num, tlmm_count); + return p - buf; +} + +static ssize_t tlmm_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t n) +{ + char pull_c, dir_c; + int gpio, func, pull, dir, drvstr, output_val; + unsigned cfg; + int res; + + res = sscanf(buf, "%d %d %c %c %d %d", + &gpio, &func, &pull_c, &dir_c, &drvstr, &output_val); + pr_debug("res=%d. %d %d %c %c %d %d\n", + res, gpio, func, pull_c, dir_c, drvstr, output_val); + + /* Add a shortcut wrting format to change an output gpio's value */ + if (res == 2 && gpio < TLMM_NUM_GPIO && (func == 0 || func == 1)) { + output_val = func; + goto tlmm_store_only_output_val; + } + if ((res != 5) && (res != 6)) + goto tlmm_store_wrong_para; + + if (gpio >= TLMM_NUM_GPIO) + goto tlmm_store_wrong_para; + + if ('N' == pull_c) + pull = 0; + else if ('D' == pull_c) + pull = 1; + else if ('K' == pull_c) + pull = 2; + else if ('U' == pull_c) + pull = 3; + else + goto tlmm_store_wrong_para; + + if ('I' == dir_c) + dir = 0; + else if ('O' == dir_c) + dir = 1; + else + goto tlmm_store_wrong_para; + + drvstr = drvstr/2 - 1; /* 2mA -> 0, 4mA -> 1, 6mA -> 2, ... */ + if (drvstr > 7) + goto tlmm_store_wrong_para; + + if (output_val > 1) + goto tlmm_store_wrong_para; + + pr_debug("final set: %d %d %d %d %d %d\n", + gpio, func, pull, dir, drvstr, output_val); + + cfg = GPIO_CFG(gpio, func, dir, pull, drvstr); + if (gpio < TLMM_NUM_GPIO) { +#ifdef CONFIG_GPIO_VALID_ARRAY + if (tz_configs[gpio]) + res = -1; + else +#endif + res = tlmm_set_config(cfg); + if (res < 0) { + pr_debug("Error: Config failed.\n"); + goto tlmm_store_wrong_para; + } + } + pr_debug("final set: %d %d %d %d %d %d\n", + gpio, func, pull, dir, drvstr, output_val); + if ((func == 0) && (dir == 1)) /* gpio output */ +tlmm_store_only_output_val: + tlmm_set_inout(gpio, output_val); + + goto tlmm_store_ok; + +tlmm_store_wrong_para: + pr_debug("Wrong Input or gpio is locked by TZ.\n"); + pr_debug("Standard Format: gpio_num function pull direction strength [output_value]\n"); + pr_debug("Shortcut Format: gpio_num output_value\n"); + pr_debug(" gpio_num: 0 ~ 145\n"); + pr_debug(" function: number, where 0 is GPIO\n"); + pr_debug(" pull: 'N': NO_PULL, 'D':PULL_DOWN, 'K':KEEPER, 'U': PULL_UP\n"); + pr_debug(" direction: 'I': Input, 'O': Output\n"); + pr_debug(" strength: 2, 4, 6, 8, 10, 12, 14, 16\n"); + pr_debug(" output_value: Optional. 0 or 1. valid if GPIO output\n"); + pr_debug(" e.g. 'echo 20 0 D I 2' ==> set pin 20 as GPIO input\n"); + pr_debug(" e.g. 'echo 20 0 D O 2 1' ==> set pin 20 as GPIO output and the output = 1\n"); + pr_debug(" e.g. 'echo 20 1' ==> set output gpio pin 20 output = 1\n"); + +tlmm_store_ok: + return n; +} + +#ifdef CONFIG_GPIO_VALID_ARRAY +static ssize_t tlmm_tz_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += tlmm_tz_dump_info(buf, PAGE_SIZE); + return p - buf; +} + +static ssize_t tlmm_tz_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + int gpio, func = 0; + int res; + + res = sscanf(buf, "%d %d", &gpio, &func); + pr_debug("res=%d. %d %d\n", res, gpio, func); + + if (res == 1) + func = 1; + + pr_debug("final set: %d %d\n", gpio, func); + + if (gpio >= TLMM_NUM_GPIO) + goto tlmm_tz_store_wrong_para; + + tz_configs[gpio] = func; + + goto tlmm_tz_store_ok; + +tlmm_tz_store_wrong_para: + pr_debug("Wrong Input.\n"); + pr_debug("Format: gpio [0|1]\n"); + +tlmm_tz_store_ok: + return n; +} +#endif + +/* Set GPIO's sleep config from sysfs */ +static ssize_t tlmm_before_sleep_table_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += tlmm_before_sleep_table_dump_info(buf, PAGE_SIZE); + return p - buf; +} + +static ssize_t tlmm_before_sleep_table_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + char pull_c, dir_c; + int gpio, func = 0, pull = 0, dir = 0, drvstr = 0, output_val = 0; + int ignore; + unsigned cfg; + int res; + + res = sscanf(buf, "%d %d %c %c %d %d", + &gpio, &func, &pull_c, &dir_c, &drvstr, &output_val); + pr_debug("res=%d. %d %d %c %c %d %d\n", + res, gpio, func, pull_c, dir_c, drvstr, output_val); + + /* if only gpio, means ignore(disable) the gpio's sleep config */ + if (res == 1) { + ignore = 1; + pr_debug("final set: to disable gpio %d sleep config\n", gpio); + } else { + ignore = 0; + + if ((res != 5) && (res != 6)) + goto tlmm_before_sleep_table_store_wrong_para; + + if (gpio >= TLMM_NUM_GPIO) + goto tlmm_before_sleep_table_store_wrong_para; + + if ('N' == pull_c) + pull = 0; + else if ('D' == pull_c) + pull = 1; + else if ('K' == pull_c) + pull = 2; + else if ('U' == pull_c) + pull = 3; + else + goto tlmm_before_sleep_table_store_wrong_para; + + if ('I' == dir_c) + dir = 0; + else if ('O' == dir_c) + dir = 1; + else + goto tlmm_before_sleep_table_store_wrong_para; + + drvstr = drvstr/2 - 1; /* 2mA -> 0, 4mA -> 1, 6mA -> 2, ... */ + if (drvstr > 7) + goto tlmm_before_sleep_table_store_wrong_para; + + pr_debug("final set: %d %d %d %d %d\n", + gpio, func, pull, dir, drvstr); + } + + cfg = GPIO_CFG(ignore ? 0xff : gpio, func, dir, pull, drvstr); + res = tlmm_before_sleep_table_set_cfg(gpio, cfg | (output_val << 30)); + if (res < 0) { + pr_debug("Error: Config failed.\n"); + goto tlmm_before_sleep_table_store_wrong_para; + } + + goto tlmm_before_sleep_table_store_ok; + +tlmm_before_sleep_table_store_wrong_para: + pr_debug("Wrong Input.\n"); + pr_debug("Format: refer to tlmm's format except 'echo gpio_num > xxx' to disable the gpio's setting\n"); + +tlmm_before_sleep_table_store_ok: + return n; +} + +static ssize_t tlmm_before_sleep_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += tlmm_before_sleep_dump_info(buf, PAGE_SIZE); + return p - buf; +} + +static ssize_t tlmm_before_sleep_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + pr_err("%s: no support.\n", __func__); + return n; +} + +static ssize_t vreg_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + char *p = buf; + + p += vreg_dump_info(buf); + return p - buf; +} + +static ssize_t vreg_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t n) +{ + pr_err("%s: no support.\n", __func__); + return n; +} + +static ssize_t vreg_before_sleep_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + char *p = buf; + + p += vreg_before_sleep_dump_info(buf); + return p - buf; +} + +static ssize_t vreg_before_sleep_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + pr_err("%s: no support.\n", __func__); + return n; +} + +static ssize_t wake_lock_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + char *s = buf; + + pm_get_active_wakeup_sources(s, PAGE_SIZE - (s - buf)); + s += strlen(s); + + return (s - buf); +} + +static ssize_t wake_lock_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + pr_err("%s: no support yet.\n", __func__); + + return -EPERM; +} + +private_attr(tlmm_num); +private_attr(tlmm_count); +private_attr(tlmm); +#ifdef CONFIG_GPIO_VALID_ARRAY +private_attr(tlmm_tz); +#endif +private_attr(tlmm_before_sleep_table); +private_attr(tlmm_before_sleep); +private_attr(vreg_before_sleep); +private_attr(vreg); +private_attr(wake_lock); + +static struct attribute *g_private_attr[] = { + &tlmm_num_attr.attr, + &tlmm_count_attr.attr, + &tlmm_attr.attr, +#ifdef CONFIG_GPIO_VALID_ARRAY + &tlmm_tz_attr.attr, +#endif + &tlmm_before_sleep_table_attr.attr, + &tlmm_before_sleep_attr.attr, + &vreg_attr.attr, + &vreg_before_sleep_attr.attr, + &wake_lock_attr.attr, + NULL, +}; + +static struct attribute_group private_attr_group = { + .attrs = g_private_attr, +}; + +static struct kobject *sysfs_private_kobj; + +#ifdef CONFIG_GPIO_VALID_ARRAY +static const struct of_device_id msm_tz_gpio_match_table[] = { + {.compatible = "qcom,tz_gpio"}, + {}, +}; + +static int tlmm_tz_init(void) +{ + struct device_node *node; + const __be32 *list; + int size; + int result = 0; + + node = of_find_matching_node(NULL, msm_tz_gpio_match_table); + pr_debug("%s(), %d, node=%p\n", __func__, __LINE__, node); + + if (!node) + return -ENODEV; + + list = of_get_property(node, "tlmm-tz", &size); + pr_debug("%s(), %d, size=%d\n", __func__, __LINE__, size); + + if (!list || !size) + return -ENODEV; + + /* + * Size is in bytes. Convert to size of uint32_t + */ + size /= sizeof(*list); + + while (size) { + unsigned long gpio = be32_to_cpup(list++); + + pr_debug("%s(), %d, gpio=%ld\n", __func__, __LINE__, gpio); + if (gpio < TLMM_NUM_GPIO) + tz_configs[gpio] = 1; + size--; + } + + return result; +} +#endif + +#ifdef CONFIG_PM_SLEEP +static void pm_suspend_marker(char *annotation) +{ + struct timespec64 timestamp; + struct tm tm; + char buff[255]; + + /* get the time stamp in readable format to print*/ + ktime_get_real_ts64(×tamp); + time64_to_tm(timestamp.tv_sec, 0, &tm); + snprintf(buff, sizeof(buff), + "%u-%02d-%02d %02d:%02d:%02d.%06ld UTC", + (int) tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, + timestamp.tv_nsec); + + pr_info("mmi_suspend_dbg_%s at: %s\n", annotation, buff); +} + +static int mmi_suspend_dbg_suspend(struct device *device) +{ + pm_suspend_marker("suspend"); + + vreg_before_sleep_save_configs(); + tlmm_before_sleep_set_configs(); + tlmm_before_sleep_save_configs(); + + return 0; +} + +static int mmi_suspend_dbg_resume(struct device *device) +{ + pm_suspend_marker("resume"); + + show_subsystem_sleep_stats(); + + return 0; +} +#else +#define mmi_suspend_dbg_suspend NULL +#define mmi_suspend_dbg_resume NULL +#endif + +static const struct dev_pm_ops mmi_dev_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mmi_suspend_dbg_suspend, mmi_suspend_dbg_resume) +}; + +static const struct of_device_id mmi_suspend_dbg_match_table[] = { + {.compatible = "mmi,suspend_dbg"}, + {}, +}; +MODULE_DEVICE_TABLE(of, mmi_suspend_dbg_match_table); + +static struct platform_driver mmi_suspend_dbg_driver = { + .driver = { + .name = "mmi_suspend_dbg", + .owner = THIS_MODULE, + .pm = &mmi_dev_pm_ops, + .of_match_table = mmi_suspend_dbg_match_table, + }, +}; + +static int __init sysfs_private_init(void) +{ + int result; + + pr_debug("%s(), %d\n", __func__, __LINE__); + + sysfs_private_kobj = kobject_create_and_add("private", NULL); + if (!sysfs_private_kobj) + return -ENOMEM; + + result = sysfs_create_group(sysfs_private_kobj, &private_attr_group); + pr_debug("%s(), %d, result=%d\n", __func__, __LINE__, result); + +#ifdef CONFIG_GPIO_VALID_ARRAY + result = tlmm_tz_init(); + pr_debug("%s(), %d, result=%d\n", __func__, __LINE__, result); +#endif + result = platform_driver_register(&mmi_suspend_dbg_driver); + if (result) + pr_err("mmi_suspend_dbg failed to register driver\n"); + return result; +} + +static void __exit sysfs_private_exit(void) +{ + pr_debug("%s(), %d\n", __func__, __LINE__); + sysfs_remove_group(sysfs_private_kobj, &private_attr_group); + + kobject_put(sysfs_private_kobj); + platform_driver_unregister(&mmi_suspend_dbg_driver); +} + +module_init(sysfs_private_init); +module_exit(sysfs_private_exit); + +MODULE_LICENSE("GPL"); diff --git a/kernel/power/user_sysfs_private.h b/kernel/power/user_sysfs_private.h new file mode 100644 index 000000000..b3bc39658 --- /dev/null +++ b/kernel/power/user_sysfs_private.h @@ -0,0 +1,24 @@ +#ifndef USER_SYSFS_PRIVATE_H +#define USER_SYSFS_PRIVATE_H + +extern void tlmm_before_sleep_set_configs(void); +extern void tlmm_before_sleep_save_configs(void); + +/* drivers/base/power/wakeup.c */ +extern int wakelock_dump_active_info(char *buf, int size); + +/* drivers/regulator/core.c */ +extern void vreg_before_sleep_save_configs(void); +extern int vreg_dump_info(char *buf); +extern int vreg_before_sleep_dump_info(char *buf); + +/* drivers/soc/qcom/soc_sleep_stats.c */ +extern ssize_t show_subsystem_sleep_stats(void); + +/* drivers/pinctrl/qcom/pinctrl-msm.c */ +extern int tlmm_get_inout(unsigned gpio); +extern int tlmm_set_inout(unsigned gpio, unsigned val); +extern int tlmm_set_config(unsigned config); +extern int tlmm_get_config(unsigned gpio, unsigned *cfg); + +#endif diff --git a/kernel/sched/walt/Kconfig b/kernel/sched/walt/Kconfig index 4157dffa0..e19053656 100644 --- a/kernel/sched/walt/Kconfig +++ b/kernel/sched/walt/Kconfig @@ -38,4 +38,12 @@ config SCHED_CONSERVATIVE_BOOST_LPM_BIAS modes on a cpu if conservative boost is active. The cpu will not enter low power mode for a hysteresis time period, which can be configured from userspace. + +config SCHED_MOTO_UNFAIR + tristate "Enable moto unfair scheduler" + depends on SCHED_WALT + default n + help + This feature will allow the scheduler to maintain more detailed + mvp scheduling. endmenu diff --git a/kernel/sched/walt/trace.h b/kernel/sched/walt/trace.h index 08bada4e3..e4d1d6585 100644 --- a/kernel/sched/walt/trace.h +++ b/kernel/sched/walt/trace.h @@ -990,6 +990,71 @@ TRACE_EVENT(walt_lb_cpu_util, __entry->cpu_util, __entry->capacity_orig) ); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +TRACE_EVENT(sched_cpu_util, + + TP_PROTO(int cpu, struct cpumask *lowest_mask), + + TP_ARGS(cpu, lowest_mask), + + TP_STRUCT__entry( + __field(unsigned int, cpu) + __field(unsigned int, nr_running) + __field(long, cpu_util) + __field(long, cpu_util_cum) + __field(unsigned long, capacity_curr) + __field(unsigned long, capacity) + __field(unsigned long, capacity_orig) + __field(unsigned int, idle_exit_latency) + __field(u64, irqload) + __field(int, online) + __field(int, inactive) + __field(int, halted) + __field(int, reserved) + __field(int, high_irq_load) + __field(unsigned int, nr_rtg_high_prio_tasks) + __field(u64, prs_gprs) + __field(unsigned int, lowest_mask) + __field(unsigned long, thermal_pressure) + __field(unsigned int, walt_mvp_taks) + ), + + TP_fast_assign( + struct walt_rq *wrq = &per_cpu(walt_rq, cpu); + __entry->cpu = cpu; + __entry->nr_running = cpu_rq(cpu)->nr_running; + __entry->cpu_util = cpu_util(cpu); + __entry->cpu_util_cum = cpu_util_cum(cpu); + __entry->capacity_curr = capacity_curr_of(cpu); + __entry->capacity = capacity_of(cpu); + __entry->capacity_orig = capacity_orig_of(cpu); + __entry->idle_exit_latency = walt_get_idle_exit_latency(cpu_rq(cpu)); + __entry->irqload = sched_irqload(cpu); + __entry->online = cpu_online(cpu); + __entry->inactive = !cpu_active(cpu); + __entry->halted = (cpu_halted(cpu)<<1) + cpu_partial_halted(cpu); + __entry->reserved = is_reserved(cpu); + __entry->high_irq_load = sched_cpu_high_irqload(cpu); + __entry->nr_rtg_high_prio_tasks = walt_nr_rtg_high_prio(cpu); + __entry->prs_gprs = wrq->prev_runnable_sum + wrq->grp_time.prev_runnable_sum; + if (!lowest_mask) + __entry->lowest_mask = 0; + else + __entry->lowest_mask = cpumask_bits(lowest_mask)[0]; + __entry->thermal_pressure = arch_scale_thermal_pressure(cpu); + __entry->walt_mvp_taks = walt_mvp_taks(cpu); + ), + + TP_printk("cpu=%d nr_running=%d cpu_util=%ld cpu_util_cum=%ld capacity_curr=%lu capacity=%lu capacity_orig=%lu idle_exit_latency=%u irqload=%llu online=%u, inactive=%u, halted=%u, reserved=%u, high_irq_load=%u nr_rtg_hp=%u prs_gprs=%llu lowest_mask=0x%x thermal_pressure=%lu nr_mvp=%u", + __entry->cpu, __entry->nr_running, __entry->cpu_util, + __entry->cpu_util_cum, __entry->capacity_curr, + __entry->capacity, __entry->capacity_orig, + __entry->idle_exit_latency, __entry->irqload, __entry->online, + __entry->inactive, __entry->halted, __entry->reserved, __entry->high_irq_load, + __entry->nr_rtg_high_prio_tasks, __entry->prs_gprs, + __entry->lowest_mask, __entry->thermal_pressure, __entry->walt_mvp_taks) +); +#else TRACE_EVENT(sched_cpu_util, TP_PROTO(int cpu, struct cpumask *lowest_mask), @@ -1057,6 +1122,7 @@ TRACE_EVENT(sched_cpu_util, __entry->enforce_high_irq, __entry->nr_rtg_high_prio_tasks, __entry->prs_gprs, __entry->lowest_mask, __entry->thermal_pressure) ); +#endif TRACE_EVENT(sched_compute_energy, @@ -1292,6 +1358,69 @@ TRACE_EVENT(sched_task_util, /* * Tracepoint for find_best_target */ +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +TRACE_EVENT(sched_find_best_target, + + TP_PROTO(struct task_struct *tsk, + unsigned long min_util, int start_cpu, + unsigned long candidates, + int most_spare_cap, + int order_index, int end_index, + int skip, bool running, + int most_spare_rq_cpu, int least_mvp_cpu, int mvp_prio), + + TP_ARGS(tsk, min_util, start_cpu, candidates, + most_spare_cap, + order_index, end_index, skip, running, + most_spare_rq_cpu, least_mvp_cpu, mvp_prio), + + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN) + __field(pid_t, pid) + __field(unsigned long, min_util) + __field(int, start_cpu) + __field(unsigned long, candidates) + __field(int, most_spare_cap) + __field(int, order_index) + __field(int, end_index) + __field(int, skip) + __field(bool, running) + __field(int, most_spare_rq_cpu) + __field(int, least_mvp_cpu) + __field(int, mvp_prio) + ), + + TP_fast_assign( + memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); + __entry->pid = tsk->pid; + __entry->min_util = min_util; + __entry->start_cpu = start_cpu; + __entry->candidates = candidates; + __entry->most_spare_cap = most_spare_cap; + __entry->order_index = order_index; + __entry->end_index = end_index; + __entry->skip = skip; + __entry->running = running; + __entry->most_spare_rq_cpu = most_spare_rq_cpu; + __entry->least_mvp_cpu = least_mvp_cpu; + __entry->mvp_prio = mvp_prio; + ), + + TP_printk("pid=%d comm=%s start_cpu=%d candidates=%#lx most_spare_cap=%d order_index=%d end_index=%d skip=%d running=%d min_util=%lu spare_rq_cpu=%d least_mvp_cpu=%d mvp_prio=%d", + __entry->pid, __entry->comm, + __entry->start_cpu, + __entry->candidates, + __entry->most_spare_cap, + __entry->order_index, + __entry->end_index, + __entry->skip, + __entry->running, + __entry->min_util, + __entry->most_spare_rq_cpu, + __entry->least_mvp_cpu, + __entry->mvp_prio) +); +#else TRACE_EVENT(sched_find_best_target, TP_PROTO(struct task_struct *tsk, @@ -1350,6 +1479,7 @@ TRACE_EVENT(sched_find_best_target, __entry->most_spare_rq_cpu, __entry->cpu_rq_runnable_cnt) ); +#endif TRACE_EVENT(sched_enq_deq_task, @@ -1461,6 +1591,57 @@ DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_pick_next, TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit), TP_ARGS(p, wts, limit)); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +// Moto wangwang: add more trace for debugging. +DECLARE_EVENT_CLASS(walt_cfs_mvp_task_template2, + + TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2), + + TP_ARGS(p, wts, limit, p2, wts2), + + TP_STRUCT__entry( + __array(char, comm, TASK_COMM_LEN) + __field(pid_t, pid) + __field(int, prio) + __field(int, mvp_prio) + __field(int, cpu) + __field(u64, exec) + __field(unsigned int, limit) + __field(pid_t, pid2) + __field(int, prio2) + __field(int, mvp_prio2) + ), + + TP_fast_assign( + memcpy(__entry->comm, p->comm, TASK_COMM_LEN); + __entry->pid = p->pid; + __entry->prio = p->prio; + __entry->mvp_prio = wts->mvp_prio; + __entry->cpu = task_cpu(p); + __entry->exec = wts->total_exec; + __entry->limit = limit; + __entry->pid2 = p2->pid; + __entry->prio2 = p2->prio; + __entry->mvp_prio2 = wts2->mvp_prio; + ), + + TP_printk("comm=%s pid=%d prio=%d mvp_prio=%d cpu=%d exec=%llu limit=%u pid2=%d prio2=%d, mvp_prio2=%d", + __entry->comm, __entry->pid, __entry->prio, + __entry->mvp_prio, __entry->cpu, __entry->exec, + __entry->limit, + __entry->pid2, __entry->prio2, __entry->mvp_prio2) +); + +/* called upon when MVP (current) is not preempted by waking task */ +DEFINE_EVENT(walt_cfs_mvp_task_template2, walt_cfs_mvp_wakeup_nopreempt, + TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2), + TP_ARGS(p, wts, limit, p2, wts2)); + +/* called upon when MVP (waking task) preempts the current */ +DEFINE_EVENT(walt_cfs_mvp_task_template2, walt_cfs_mvp_wakeup_preempt, + TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2), + TP_ARGS(p, wts, limit, p2, wts2)); +#else /* called upon when MVP (current) is not preempted by waking task */ DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_nopreempt, TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit), @@ -1470,6 +1651,7 @@ DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_nopreempt, DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_preempt, TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit), TP_ARGS(p, wts, limit)); +#endif #define SPAN_SIZE (NR_CPUS/4) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index bf1cec87d..86f1d37c3 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -119,6 +119,22 @@ static struct syscore_ops walt_syscore_ops = { .suspend = walt_suspend }; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +// Moto huangzq2 +int moto_sched_enabled = 0; +int set_moto_sched_enabled(int enable) { + moto_sched_enabled = enable; + return 0; +} +EXPORT_SYMBOL(set_moto_sched_enabled); + +struct msched_ops *moto_sched_ops = NULL; +void set_moto_sched_ops(struct msched_ops *ops) { + moto_sched_ops = ops; +} +EXPORT_SYMBOL_GPL(set_moto_sched_ops); +#endif + /* *@boost:should be 0,1,2. *@period:boost time based on ms units. @@ -5313,10 +5329,18 @@ static void walt_do_sched_yield(void *unused, struct rq *rq) walt_lockdep_assert_rq(rq, NULL); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto wangwang: don't deactivate mvp tasks when moto_sched enabled. + if (unlikely(!moto_sched_enabled) && !list_empty(&wts->mvp_list) && wts->mvp_list.next) { + if (!pipeline_in_progress() || !walt_pipeline_low_latency_task(curr)) + walt_cfs_deactivate_mvp_task(rq, curr, 3); // Moto huangzq2: debugging enhancement. + } +#else if (!list_empty(&wts->mvp_list) && wts->mvp_list.next) { if (!pipeline_in_progress() || !walt_pipeline_low_latency_task(curr)) walt_cfs_deactivate_mvp_task(rq, curr); } +#endif if (per_cpu(rt_task_arrival_time, cpu_of(rq))) per_cpu(rt_task_arrival_time, cpu_of(rq)) = 0; @@ -5561,7 +5585,9 @@ static void walt_init(struct work_struct *work) walt_rt_init(); walt_cfs_init(); walt_halt_init(); +#if !IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) walt_mvp_lock_ordering_init(); +#endif wait_for_completion_interruptible(&tick_sched_clock_completion); diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index ee8c32cc0..620e4307b 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -964,6 +964,16 @@ static inline unsigned int walt_nr_rtg_high_prio(int cpu) return wrq->walt_stats.nr_rtg_high_prio_tasks; } +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +extern int moto_sched_enabled; +static inline unsigned int walt_mvp_taks(int cpu) +{ + struct walt_rq *wrq = &per_cpu(walt_rq, cpu); + + return wrq->num_mvp_tasks; +} +#endif + static inline bool task_in_related_thread_group(struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; @@ -1223,10 +1233,23 @@ static inline bool walt_flag_test(struct task_struct *p, unsigned int feature) /* higher number, better priority */ #define WALT_RTG_MVP 0 + +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +/* Moto huangzq2: reserve mvp prioriteis (11~100) for moto_sched */ +#define UX_PRIO_TOPAPP 70 // must be aligned with moto_sched! +#define UX_PRIO_KSWAPD 65 // must be aligned with moto_sched! + +#define WALT_BINDER_MVP 101 +#define WALT_TASK_BOOST_MVP UX_PRIO_TOPAPP // align to UX_PRIO_TOPAPP in moto_sched + +#define WALT_LL_MVP 103 +#define WALT_PIPELINE_MVP 104 +#else #define WALT_BINDER_MVP 1 #define WALT_TASK_BOOST_MVP 2 #define WALT_LL_MVP 3 #define WALT_PIPELINE_MVP 4 +#endif #define WALT_NOT_MVP -1 @@ -1370,7 +1393,12 @@ extern struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf, DECLARE_PER_CPU(u64, rt_task_arrival_time); extern int walt_get_mvp_task_prio(struct task_struct *p); + +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +extern void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p, unsigned int reason); // Moto huangzq2: debugging enhancement. +#else extern void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p); +#endif void inc_rq_walt_stats(struct rq *rq, struct task_struct *p); void dec_rq_walt_stats(struct rq *rq, struct task_struct *p); diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index c040f8bd0..3905d2ff2 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -106,6 +106,9 @@ struct find_best_target_env { int end_index; bool strict_max; int skip_cpu; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + int mvp_prio; +#endif u64 prs[8]; }; @@ -275,8 +278,10 @@ static inline bool walt_should_reject_fbt_cpu(struct walt_rq *wrq, struct task_s if (fbt_env->skip_cpu == cpu) return true; +#if !IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) if (wrq->num_mvp_tasks > 0 && per_task_boost(p) != TASK_BOOST_STRICT_MAX) return true; +#endif return false; } @@ -341,6 +346,10 @@ static void walt_find_best_target(struct sched_domain *sd, int packing_cpu, cpu; unsigned int search_sibling_cluster = 0; bool visited_clusters[MAX_CLUSTERS] = {[0 ... (MAX_CLUSTERS-1)] = false}; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + int mvp_min_tasks = INT_MAX; // Moto chentao: spread mvp tasks. + int least_mvp_cpu = -1; // Moto huangzq2 +#endif /* Find start CPU based on boost value */ start_cpu = fbt_env->start_cpu; @@ -419,6 +428,26 @@ retry: if (walt_should_reject_fbt_cpu(wrq, p, i, order_index, fbt_env)) continue; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto huangzq2: skip long exec mvp tasks like top app or kswapd. + if (likely(moto_sched_enabled) && wrq->num_mvp_tasks > 0) { + struct walt_task_struct *rq_wts = list_first_entry(&wrq->mvp_tasks, struct walt_task_struct, mvp_list); + if (rq_wts != NULL && (rq_wts->mvp_prio == UX_PRIO_TOPAPP || rq_wts->mvp_prio == UX_PRIO_KSWAPD)) { + continue; + } + } + + if (likely(moto_sched_enabled) + && (wrq->num_mvp_tasks < mvp_min_tasks // least mvp tasks, select it. + || (wrq->num_mvp_tasks == mvp_min_tasks && i == prev_cpu))) { // same mvp tasks but prev_cpu, also select it. + mvp_min_tasks = wrq->num_mvp_tasks; + least_mvp_cpu = i; + } + + if (wrq->num_mvp_tasks > 0) + continue; +#endif + /* * p's blocked utilization is still accounted for on prev_cpu * so prev_cpu will receive a negative bias due to the double @@ -561,6 +590,10 @@ retry: if (unlikely(cpumask_empty(candidates))) { if (most_spare_cap_cpu != -1) cpumask_set_cpu(most_spare_cap_cpu, candidates); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + else if (least_mvp_cpu != -1) + cpumask_set_cpu(least_mvp_cpu, candidates); +#endif else if (cpu_active(prev_cpu) && (cpu_rq(prev_cpu)->nr_running < DIRE_STRAITS_PREV_NR_LIMIT)) cpumask_set_cpu(prev_cpu, candidates); @@ -583,10 +616,17 @@ out: goto retry; } +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + trace_sched_find_best_target(p, min_task_util, start_cpu, cpumask_bits(candidates)[0], + most_spare_cap_cpu, order_index, end_index, + fbt_env->skip_cpu, task_on_rq_queued(p), least_nr_cpu, + least_mvp_cpu, fbt_env->mvp_prio); +#else trace_sched_find_best_target(p, min_task_util, start_cpu, cpumask_bits(candidates)[0], most_spare_cap_cpu, order_index, end_index, fbt_env->skip_cpu, task_on_rq_queued(p), least_nr_cpu, cpu_rq_runnable_cnt); +#endif } static inline unsigned long @@ -990,6 +1030,13 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, if (!pd) goto fail; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // TODO: Mark it here becuase of potential overhead of walt_get_mvp_task_prio, + // pls unmark it once we have further optimization based on current mvp_prio, + // for example, select big core on top app. + // fbt_env.mvp_prio = walt_get_mvp_task_prio(p); + fbt_env.mvp_prio = WALT_NOT_MVP; +#endif fbt_env.is_rtg = is_rtg; fbt_env.start_cpu = start_cpu; fbt_env.order_index = order_index; @@ -1170,6 +1217,12 @@ static void binder_set_priority_hook(void *data, */ wts->low_latency &= ~WALT_LOW_LATENCY_BINDER_BIT; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto huangzq2: inherit ux type + if (bndrtrans && bndrtrans->need_reply) { + moto_binder_inherit_ux_type(task); + } +#endif } static void binder_restore_priority_hook(void *data, @@ -1182,6 +1235,13 @@ static void binder_restore_priority_hook(void *data, if (bndrtrans && wts->boost == TASK_BOOST_STRICT_MAX) wts->boost = bndrtrans->android_vendor_data1; + +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto huangzq2: clear inherited ux type + if (bndrtrans) { + moto_binder_clear_inherited_ux_type(task); + } +#endif } /* @@ -1194,6 +1254,10 @@ static void binder_restore_priority_hook(void *data, */ int walt_get_mvp_task_prio(struct task_struct *p) { +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + int mvp_prio; // Moto huangzq2 +#endif + if (walt_pipeline_low_latency_task(p)) return WALT_PIPELINE_MVP; @@ -1206,12 +1270,44 @@ int walt_get_mvp_task_prio(struct task_struct *p) if (walt_binder_low_latency_task(p)) return WALT_BINDER_MVP; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + mvp_prio = moto_task_get_mvp_prio(p, true); + if (mvp_prio > WALT_NOT_MVP) // Moto huangzq2 + return mvp_prio; +#endif + if (task_rtg_high_prio(p)) return WALT_RTG_MVP; return WALT_NOT_MVP; } +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +// Moto huangzq2 +static inline unsigned int __walt_cfs_mvp_task_limit(struct task_struct *p, int mvp_prio) +{ + unsigned int limit; // Moto huangzq2 + + /* Binder MVP tasks are high prio but have only single slice */ + if (mvp_prio == WALT_BINDER_MVP) + return WALT_MVP_SLICE; + + if (mvp_prio == WALT_PIPELINE_MVP) + return 2 * WALT_MVP_LIMIT; + + limit = moto_task_get_mvp_limit(p, mvp_prio); // Moto huangzq2 + if (limit > 0) + return limit; + + return WALT_MVP_LIMIT; +} + +static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p) +{ + struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; + return __walt_cfs_mvp_task_limit(p, wts->mvp_prio); +} +#else static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; @@ -1220,11 +1316,9 @@ static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p) if (wts->mvp_prio == WALT_BINDER_MVP) return WALT_MVP_SLICE; - if (wts->mvp_prio == WALT_PIPELINE_MVP) - return 2 * WALT_MVP_LIMIT; - return WALT_MVP_LIMIT; } +#endif static void walt_cfs_insert_mvp_task(struct walt_rq *wrq, struct walt_task_struct *wts, bool at_front) @@ -1248,11 +1342,19 @@ static void walt_cfs_insert_mvp_task(struct walt_rq *wrq, struct walt_task_struc wrq->num_mvp_tasks++; } +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) +void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p, unsigned int reason) // Moto huangzq2: debugging enhancement. +#else void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p) +#endif { struct walt_rq *wrq = &per_cpu(walt_rq, cpu_of(rq)); struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + trace_walt_cfs_deactivate_mvp_task(rq->curr, wts, reason); // MOto wangwang: debugging enhancement. +#endif + list_del_init(&wts->mvp_list); wts->mvp_prio = WALT_NOT_MVP; wrq->num_mvp_tasks--; @@ -1326,8 +1428,12 @@ static void walt_cfs_account_mvp_runtime(struct rq *rq, struct task_struct *curr limit = walt_cfs_mvp_task_limit(curr); if (wts->total_exec > limit) { +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + walt_cfs_deactivate_mvp_task(rq, curr, 2); // Moto huangzq2: debugging enhancement. +#else walt_cfs_deactivate_mvp_task(rq, curr); trace_walt_cfs_deactivate_mvp_task(curr, wts, limit); +#endif return; } @@ -1354,8 +1460,13 @@ void walt_cfs_enqueue_task(struct rq *rq, struct task_struct *p) * it was once MVP but got demoted, it will not be MVP until * it goes to sleep again. */ +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + if (wts->total_exec > __walt_cfs_mvp_task_limit(p, mvp_prio)) // Moto huangzq2: use __walt_cfs_mvp_task_limit + return; +#else if (wts->total_exec > walt_cfs_mvp_task_limit(p)) return; +#endif wts->mvp_prio = mvp_prio; walt_cfs_insert_mvp_task(wrq, wts, task_on_cpu(rq, p)); @@ -1369,14 +1480,24 @@ void walt_cfs_enqueue_task(struct rq *rq, struct task_struct *p) wts->sum_exec_snapshot_for_total = p->se.sum_exec_runtime; wts->sum_exec_snapshot_for_slice = p->se.sum_exec_runtime; } + +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto chentao8: enqueue task + moto_queue_ux_task(rq, p, 1); +#endif } void walt_cfs_dequeue_task(struct rq *rq, struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + if (!list_empty(&wts->mvp_list) && wts->mvp_list.next) + walt_cfs_deactivate_mvp_task(rq, p, 1); // Moto huangzq2: debugging enhancement. +#else if (!list_empty(&wts->mvp_list) && wts->mvp_list.next) walt_cfs_deactivate_mvp_task(rq, p); +#endif /* * Reset the exec time during sleep so that it starts @@ -1386,6 +1507,11 @@ void walt_cfs_dequeue_task(struct rq *rq, struct task_struct *p) */ if (READ_ONCE(p->__state) != TASK_RUNNING) wts->total_exec = 0; + +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + // Moto chentao8: dequeue task + moto_queue_ux_task(rq, p, 0); +#endif } void walt_cfs_tick(struct rq *rq) @@ -1455,8 +1581,17 @@ static void walt_cfs_check_preempt_wakeup(void *unused, struct rq *rq, struct ta */ skip_mvp = wrq->skip_mvp; walt_cfs_account_mvp_runtime(rq, c); +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + if (likely(moto_sched_enabled)) + resched = ((skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) || + (wts_p->mvp_prio > wts_c->mvp_prio)) && (wrq->mvp_tasks.next == &wts_p->mvp_list); // Moto wangwang: fix preemption issue. + else + resched = (skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) || + (wts_p->mvp_prio > wts_c->mvp_prio); +#else resched = (skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) || (wts_p->mvp_prio > wts_c->mvp_prio); +#endif /* * current is no longer eligible to run. It must have been @@ -1470,11 +1605,19 @@ static void walt_cfs_check_preempt_wakeup(void *unused, struct rq *rq, struct ta /* current is the first in the queue, so no preemption */ *nopreempt = true; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + trace_walt_cfs_mvp_wakeup_nopreempt(c, wts_c, walt_cfs_mvp_task_limit(c), p, wts_p); // Moto wangwang: debugging enhancement. +#else trace_walt_cfs_mvp_wakeup_nopreempt(c, wts_c, walt_cfs_mvp_task_limit(c)); +#endif return; preempt: *preempt = true; +#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR) + trace_walt_cfs_mvp_wakeup_preempt(p, wts_p, walt_cfs_mvp_task_limit(p), c, wts_c); // Moto wangwang: debugging enhancement. +#else trace_walt_cfs_mvp_wakeup_preempt(p, wts_p, walt_cfs_mvp_task_limit(p)); +#endif } #ifdef CONFIG_FAIR_GROUP_SCHED @@ -1511,6 +1654,9 @@ static void walt_cfs_replace_next_task_fair(void *unused, struct rq *rq, struct /* RQ is in MVP throttled state*/ if (wrq->skip_mvp) return; + /* We don't have MVP tasks queued */ + if (list_empty(&wrq->mvp_tasks)) + return; if (list_empty(&wrq->mvp_tasks)) { wrq->mvp_arrival_time = 0; diff --git a/modules.list.msm.parrot b/modules.list.msm.parrot index f7784dd14..fbe182c8e 100644 --- a/modules.list.msm.parrot +++ b/modules.list.msm.parrot @@ -13,7 +13,6 @@ dispcc-parrot.ko gcc-sm4450.ko dispcc-sm4450.ko sched-walt.ko -sched-walt-debug.ko qcom_wdt_core.ko qcom_cpucp.ko qcom_ipc_logging.ko diff --git a/modules.vendor_blocklist.msm.parrot b/modules.vendor_blocklist.msm.parrot index 43fd1ed60..99ab06002 100644 --- a/modules.vendor_blocklist.msm.parrot +++ b/modules.vendor_blocklist.msm.parrot @@ -63,3 +63,9 @@ blocklist vsock blocklist vsock_diag blocklist xc4000 blocklist xc5000 +blocklist goodix_fod_mmi.ko +blocklist rbs_fod_mmi.ko +blocklist watchdogtest +blocklist anc_fps_mmi +blocklist fpc1020_mmi + diff --git a/msm_kernel_la.bzl b/msm_kernel_la.bzl index 4d9f629db..bbfefa741 100644 --- a/msm_kernel_la.bzl +++ b/msm_kernel_la.bzl @@ -108,6 +108,7 @@ EOF ] + [fragment for fragment in build_config_fragments] + [ "build.config.msm.common", "build.config.msm.perf", + "build.config.moto", ], ) diff --git a/parrot.bzl b/parrot.bzl index 43a6d1313..d9767bc6b 100644 --- a/parrot.bzl +++ b/parrot.bzl @@ -1,6 +1,7 @@ load(":image_opts.bzl", "boot_image_opts") load(":msm_kernel_la.bzl", "define_msm_la") load(":target_variants.bzl", "la_variants") +load(":moto_product.bzl", "mmi_product_name") target_name = "parrot" @@ -65,6 +66,7 @@ def define_parrot(): "drivers/iio/adc/qcom-vadc-common.ko", "drivers/iio/adc/qti-glink-adc.ko", "drivers/input/misc/pm8941-pwrkey.ko", + "drivers/input/misc/qcom-hv-haptics.ko", "drivers/input/misc/qpnp-power-on.ko", "drivers/interconnect/qcom/icc-bcm-voter.ko", "drivers/interconnect/qcom/icc-debug.ko", @@ -151,7 +153,6 @@ def define_parrot(): "drivers/soc/qcom/gic_intr_routing.ko", "drivers/soc/qcom/hung_task_enh.ko", "drivers/soc/qcom/mdt_loader.ko", - "drivers/soc/qcom/mem-offline.ko", "drivers/soc/qcom/mem_buf/mem_buf.ko", "drivers/soc/qcom/mem_buf/mem_buf_dev.ko", "drivers/soc/qcom/mem_buf/mem_buf_msgq.ko", @@ -255,16 +256,25 @@ def define_parrot(): _parrot_consolidate_in_tree_modules = _parrot_in_tree_modules + [ # keep sorted - "drivers/hwtracing/coresight/coresight-etm4x.ko", "drivers/misc/lkdtm/lkdtm.ko", "kernel/locking/locktorture.ko", + "kernel/power/user_sysfs_private.ko", "kernel/rcu/rcutorture.ko", - "kernel/sched/walt/sched-walt-debug.ko", + #"kernel/sched/walt/sched-walt-debug.ko", "kernel/torture.ko", "lib/atomic64_test.ko", "lib/test_user_copy.ko", ] + _parrot_moto_in_tree_modules = { + "mona": [ + # keep sorted + ], + "monai": [ + # keep sorted + ], + } + kernel_vendor_cmdline_extras = ["bootconfig"] for variant in la_variants: @@ -273,7 +283,7 @@ def define_parrot(): if variant == "consolidate": mod_list = _parrot_consolidate_in_tree_modules - board_bootconfig_extras += ["androidboot.serialconsole=1"] + #board_bootconfig_extras += ["androidboot.serialconsole=1"] board_kernel_cmdline_extras += [ # do not sort "console=ttyMSM0,115200n8", @@ -290,12 +300,17 @@ def define_parrot(): mod_list = _parrot_in_tree_modules board_kernel_cmdline_extras += ["nosoftlockup console=ttynull qcom_geni_serial.con_enabled=0"] kernel_vendor_cmdline_extras += ["nosoftlockup console=ttynull qcom_geni_serial.con_enabled=0"] - board_bootconfig_extras += ["androidboot.serialconsole=0"] + #board_bootconfig_extras += ["androidboot.serialconsole=0"] + + moto_in_tree_modules = [ ] + for p, v in _parrot_moto_in_tree_modules.items(): + if p == mmi_product_name: + moto_in_tree_modules = v define_msm_la( msm_target = target_name, variant = variant, - in_tree_module_list = mod_list, + in_tree_module_list = mod_list + moto_in_tree_modules, boot_image_opts = boot_image_opts( kernel_vendor_cmdline_extras = kernel_vendor_cmdline_extras, board_kernel_cmdline_extras = board_kernel_cmdline_extras,