Commit Graph

1068416 Commits

Author SHA1 Message Date
Bart Van Assche
2e83e40f6a Revert "ANDROID: scsi: ufs: Enable zoned write pipelining"
Prepare for applying the FROMLIST version of this patch.

This reverts commit d701aaaeb4.

Bug: 234829282
Change-Id: I7f267cf661807c7c8c96ea05966d77b338d62de2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-10 21:03:40 +00:00
Bart Van Assche
e08f97fe80 Revert "ANDROID: scsi: ufs: Disable zoned write pipelining"
Prepare for applying the FROMLIST version of this patch.

This reverts commit ca743f9d51.

Bug: 234829282
Change-Id: Id95600f80be575da720b098a86aa46b84d33a733
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-10 21:03:40 +00:00
Bart Van Assche
a0565250b3 Revert "ANDROID: scsi: core: Delay unaligned write error retries"
Prepare for applying the FROMLIST version of this patch.

This reverts commit 2dffc600ca.

Bug: 234829282
Change-Id: I58fad37a8586350676b6d9be93aa01b1ce170a00
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-10 21:03:40 +00:00
Bart Van Assche
053f022ed4 Revert "ANDROID: scsi: core: Limit zoned write retries"
Prepare for applying the FROMLIST version of this patch.

This reverts commit 3bfdcf06e4.

Bug: 234829282
Change-Id: I5b2492d9b1475f69a0650a7621a2ea1606d7fb92
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-10 21:03:40 +00:00
Lecopzer Chen
8c7e6396da ANDROID: GKI: update mtktv symbol
update for gki modules protected symbols

11 function symbol(s) added
  'void baswap(bdaddr_t*, const bdaddr_t*)'
  'void bt_procfs_cleanup(struct net*, const char*)'
  'int bt_procfs_init(struct net*, const char*, struct bt_sock_list*, int(*)(struct seq_file*, void*))'
  'void bt_sock_link(struct bt_sock_list*, struct sock*)'
  'int bt_sock_register(int, const struct net_proto_family*)'
  'void bt_sock_unlink(struct bt_sock_list*, struct sock*)'
  'void bt_sock_unregister(int)'
  'int generic_mii_ioctl(struct mii_if_info*, struct mii_ioctl_data*, int, unsigned int*)'
  'bool l2cap_is_socket(struct socket*)'
  'int mii_ethtool_set_link_ksettings(struct mii_if_info*, const struct ethtool_link_ksettings*)'
  'int mii_nway_restart(struct mii_if_info*)'

Bug: 295293717
Change-Id: I14162165fc644243d4d73aa32a0cd8cb5c10846e
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-10 13:46:18 +00:00
Lecopzer Chen
7d47dd77f1 ANDROID: GKI: Add mtktv ABI symbol list, media, trace and remaining subsys
43 function symbol(s) added
  'int __devm_mdiobus_register(struct device*, struct mii_bus*, struct module*)'
  'void __insert_inode_hash(struct inode*, unsigned long)'
  'int __mdiobus_register(struct mii_bus*, struct module*)'
  'void __sock_recv_cmsgs(struct msghdr*, struct sock*, struct sk_buff*)'
  'int __trace_bputs(unsigned long, const char*)'
  'int __traceiter_android_vh_oom_check_panic(void*, struct oom_control*, int*)'
  'void _trace_android_vh_record_pcpu_rwsem_starttime(struct task_struct*, unsigned long)'
  'int block_is_partially_uptodate(struct page*, unsigned long, unsigned long)'
  'int buffer_migrate_page(struct address_space*, struct page*, struct page*, enum migrate_mode)'
  'struct inode* igrab(struct inode*)'
  'int iio_read_channel_scale(struct iio_channel*, int*, int*)'
  'void invalidate_bh_lrus()'
  'void io_schedule()'
  'u64 jiffies64_to_nsecs(u64)'
  'int kern_path(const char*, unsigned int, struct path*)'
  'int kmsg_dump_register(struct kmsg_dumper*)'
  'int kmsg_dump_unregister(struct kmsg_dumper*)'
  'int kstrtoul_from_user(const char*, size_t, unsigned int, unsigned long*)'
  'enum led_default_state led_init_default_state_get(struct fwnode_handle*)'
  'int lzo1x_1_compress(const unsigned char*, size_t, unsigned char*, size_t*, void*)'
  'int lzo1x_decompress_safe(const unsigned char*, size_t, unsigned char*, size_t*)'
  'struct media_link* media_create_intf_link(struct media_entity*, struct media_interface*, u32)'
  'int media_create_pad_links(const struct media_device*, u32, struct media_entity*, u16, u32, struct media_entity*, u16, u32, bool)'
  'int media_device_register_entity(struct media_device*, struct media_entity*)'
  'int media_device_register_entity_notify(struct media_device*, struct media_entity_notify*)'
  'void media_device_unregister_entity(struct media_entity*)'
  'struct media_intf_devnode* media_devnode_create(struct media_device*, u32, u32, u32, u32)'
  'void media_devnode_remove(struct media_intf_devnode*)'
  'struct media_link* media_entity_find_link(struct media_pad*, struct media_pad*)'
  'int media_get_pad_index(struct media_entity*, bool, enum media_pad_signal_type)'
  'struct dentry* mount_bdev(struct file_system_type*, int, const char*, void*, int(*)(struct super_block*, void*, int))'
  'struct list_head* seq_list_next(void*, struct list_head*, loff_t*)'
  'struct list_head* seq_list_start(struct list_head*, loff_t)'
  'int seq_open_private(struct file*, const struct seq_operations*, int)'
  'int sprint_symbol_no_offset(char*, unsigned long)'
  'unsigned int stack_trace_save_regs(struct pt_regs*, unsigned long*, unsigned int, unsigned int)'
  'ssize_t store_sampling_rate(struct gov_attr_set*, const char*, size_t)'
  'int sysfs_merge_group(struct kobject*, const struct attribute_group*)'
  'void sysfs_unmerge_group(struct kobject*, const struct attribute_group*)'
  'int trace_array_destroy(struct trace_array*)'
  'struct trace_array* trace_array_get_by_name(const char*)'
  'int trace_array_init_printk(struct trace_array*)'
  'int trace_array_printk(struct trace_array*, unsigned long, const char*, ...)'

4 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_oom_check_panic'
  'const struct fwnode_operations irqchip_fwnode_ops'
  'struct workqueue_struct* system_freezable_power_efficient_wq'
  'struct srcu_struct tracepoint_srcu'

Bug: 293831482
Change-Id: If762f88971a9d8c2013c407838e46669a78719ff
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-09 17:02:02 +00:00
Lecopzer Chen
655a288103 ANDROID: GKI: Add mtktv ABI symbol list, cpufreq and misc
32 function symbol(s) added
  'void clk_bulk_put_all(int, struct clk_bulk_data*)'
  'struct clk* clk_register_divider_table(struct device*, const char*, const char*, unsigned long, void*, u8, u8, u8, const struct clk_div_table*, spinlock_t*)'
  'void console_verbose()'
  'void cpufreq_dbs_governor_exit(struct cpufreq_policy*)'
  'int cpufreq_dbs_governor_init(struct cpufreq_policy*)'
  'void cpufreq_dbs_governor_limits(struct cpufreq_policy*)'
  'int cpufreq_dbs_governor_start(struct cpufreq_policy*)'
  'void cpufreq_dbs_governor_stop(struct cpufreq_policy*)'
  'void cpufreq_update_policy(unsigned int)'
  'struct dentry* d_add_ci(struct dentry*, struct inode*, struct qstr*)'
  'unsigned int dbs_update(struct cpufreq_policy*)'
  'void dev_get_tstats64(struct net_device*, struct rtnl_link_stats64*)'
  'int device_match_of_node(struct device*, const void*)'
  'struct regmap* device_node_to_regmap(struct device_node*)'
  'void devm_devfreq_remove_device(struct device*, struct devfreq*)'
  'int devm_extcon_register_notifier(struct device*, struct extcon_dev*, unsigned int, struct notifier_block*)'
  'struct gpio_desc* devm_gpiod_get_index_optional(struct device*, const char*, unsigned int, enum gpiod_flags)'
  'int devm_hwspin_lock_unregister(struct device*, struct hwspinlock_device*)'
  'struct mii_bus* devm_mdiobus_alloc_size(struct device*, int)'
  'void drm_atomic_state_default_clear(struct drm_atomic_state*)'
  'void drm_display_mode_from_videomode(const struct videomode*, struct drm_display_mode*)'
  'void end_page_writeback(struct page*)'
  'int eth_platform_get_mac_address(struct device*, u8*)'
  'void ftrace_dump(enum ftrace_dump_mode)'
  'void* gen_pool_dma_alloc(struct gen_pool*, size_t, dma_addr_t*)'
  'struct gen_pool* gen_pool_get(struct device*, const char*)'
  'int generic_error_remove_page(struct address_space*, struct page*)'
  'void gov_update_cpu_data(struct dbs_data*)'
  'struct gpio_chip* gpiochip_find(void*, int(*)(struct gpio_chip*, void*))'
  'int gpiod_is_active_low(const struct gpio_desc*)'
  'int idr_alloc_u32(struct idr*, void*, u32*, unsigned long, gfp_t)'
  'void* idr_get_next_ul(struct idr*, unsigned long*)'

Bug: 293831482
Change-Id: Icc54949b24588b4d3e2ef59783b494bf3cd682c0
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-09 17:02:02 +00:00
Lecopzer Chen
663ca511e8 ANDROID: GKI: Add mtktv ABI symbol list, net, eth, regulator and pinmux
36 function symbol(s) added
  'void net_selftest(struct net_device*, struct ethtool_test*, u64*)'
  'int net_selftest_get_count()'
  'void net_selftest_get_strings(u8*)'
  'struct thermal_cooling_device* of_cpufreq_cooling_register(struct cpufreq_policy*)'
  'void path_put(const struct path*)'
  'ssize_t perf_event_sysfs_show(struct device*, struct device_attribute*, char*)'
  'struct phy_device* phy_connect(struct net_device*, const char*, void(*)(struct net_device*), phy_interface_t)'
  'void phy_disconnect(struct phy_device*)'
  'int phy_do_ioctl_running(struct net_device*, struct ifreq*, int)'
  'int phy_ethtool_get_link_ksettings(struct net_device*, struct ethtool_link_ksettings*)'
  'int phy_ethtool_nway_reset(struct net_device*)'
  'int phy_ethtool_set_link_ksettings(struct net_device*, const struct ethtool_link_ksettings*)'
  'void phy_start(struct phy_device*)'
  'void phy_stop(struct phy_device*)'
  'int phy_suspend(struct phy_device*)'
  'pid_t pid_vnr(struct pid*)'
  'void pinconf_generic_dump_config(struct pinctrl_dev*, struct seq_file*, unsigned long)'
  'int pinctrl_count_index_with_args(const struct device_node*, const char*)'
  'int pinctrl_generic_add_group(struct pinctrl_dev*, const char*, int*, int, void*)'
  'int pinctrl_generic_get_group_count(struct pinctrl_dev*)'
  'const char* pinctrl_generic_get_group_name(struct pinctrl_dev*, unsigned int)'
  'int pinctrl_generic_get_group_pins(struct pinctrl_dev*, unsigned int, const unsigned int**, unsigned int*)'
  'int pinctrl_generic_remove_group(struct pinctrl_dev*, unsigned int)'
  'int pinctrl_parse_index_with_args(const struct device_node*, const char*, int, struct of_phandle_args*)'
  'int pinctrl_register_and_init(struct pinctrl_desc*, struct device*, void*, struct pinctrl_dev**)'
  'int pinmux_generic_add_function(struct pinctrl_dev*, const char*, const char**, unsigned int, void*)'
  'struct function_desc* pinmux_generic_get_function(struct pinctrl_dev*, unsigned int)'
  'int pinmux_generic_get_function_count(struct pinctrl_dev*)'
  'int pinmux_generic_get_function_groups(struct pinctrl_dev*, unsigned int, const char* const**, unsigned int*)'
  'const char* pinmux_generic_get_function_name(struct pinctrl_dev*, unsigned int)'
  'int pinmux_generic_remove_function(struct pinctrl_dev*, unsigned int)'
  'void proc_set_user(struct proc_dir_entry*, kuid_t, kgid_t)'
  'int regulator_set_mode(struct regulator*, unsigned int)'
  'int regulator_set_voltage_time(struct regulator*, int, int)'
  'int sb_min_blocksize(struct super_block*, int)'
  'int schedule_hrtimeout(ktime_t*, enum hrtimer_mode)'

Bug: 293831482
Change-Id: I83226962af59b23418594dbc4ca816f9a0456b45
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-09 17:02:02 +00:00
Lecopzer Chen
99c011c37d ANDROID: GKI: Add mtktv ABI symbol list, pwm, serial and snd
22 function symbol(s) added
  'void pwm_free(struct pwm_device*)'
  'struct pwm_device* pwm_request(int, const char*)'
  'void serial8250_do_pm(struct uart_port*, unsigned int, unsigned int)'
  'void serial8250_do_set_termios(struct uart_port*, struct ktermios*, struct ktermios*)'
  'void serial8250_do_shutdown(struct uart_port*)'
  'int serial8250_do_startup(struct uart_port*)'
  'struct uart_8250_port* serial8250_get_port(int)'
  'unsigned int serial8250_modem_status(struct uart_8250_port*)'
  'int serial8250_register_8250_port(const struct uart_8250_port*)'
  'void serial8250_resume_port(int)'
  'void serial8250_rpm_get(struct uart_8250_port*)'
  'void serial8250_rpm_put(struct uart_8250_port*)'
  'void serial8250_rpm_put_tx(struct uart_8250_port*)'
  'unsigned char serial8250_rx_chars(struct uart_8250_port*, unsigned char)'
  'void serial8250_suspend_port(int)'
  'void serial8250_tx_chars(struct uart_8250_port*)'
  'void serial8250_unregister_port(int)'
  'bool sk_capable(const struct sock*, int)'
  'int snd_compress_new(struct snd_card*, int, int, const char*, struct snd_compr*)'
  'struct snd_kcontrol* snd_ctl_find_id(struct snd_card*, struct snd_ctl_elem_id*)'
  'int snd_pcm_format_big_endian(snd_pcm_format_t)'
  'const char* snd_pcm_format_name(snd_pcm_format_t)'

Bug: 293831482
Change-Id: I4b664a3b232f0a038ed59ec523f09eab3e3506cc
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-09 17:02:02 +00:00
Lecopzer Chen
b85af8a6dd ANDROID: GKI: Add mtktv ABI symbol list, usb and v4l2
usb and v4l2 part

46 function symbol(s) added
  'struct usb_host_interface* usb_altnum_to_altsetting(const struct usb_interface*, unsigned int)'
  'int usb_anchor_empty(struct usb_anchor*)'
  'int usb_control_msg_recv(struct usb_device*, __u8, __u8, __u8, __u16, __u16, void*, __u16, int, gfp_t)'
  'int usb_control_msg_send(struct usb_device*, __u8, __u8, __u8, __u16, __u16, const void*, __u16, int, gfp_t)'
  'void usb_deregister_dev(struct usb_interface*, struct usb_class_driver*)'
  'int usb_driver_set_configuration(struct usb_device*, int)'
  'void usb_enable_lpm(struct usb_device*)'
  'struct usb_interface* usb_find_interface(struct usb_driver*, int)'
  'struct urb* usb_get_urb(struct urb*)'
  'int usb_lock_device_for_reset(struct usb_device*, const struct usb_interface*)'
  'int usb_register_dev(struct usb_interface*, struct usb_class_driver*)'
  'int usb_reset_configuration(struct usb_device*)'
  'void usb_reset_endpoint(struct usb_device*, unsigned int)'
  'int usb_string(struct usb_device*, int, char*, size_t)'
  'void usb_unlink_anchored_urbs(struct usb_anchor*)'
  'void v4l2_ctrl_request_complete(struct media_request*, struct v4l2_ctrl_handler*)'
  'int v4l2_ctrl_request_setup(struct media_request*, struct v4l2_ctrl_handler*)'
  'int v4l2_event_pending(struct v4l2_fh*)'
  'void v4l2_event_queue(struct video_device*, const struct v4l2_event*)'
  'int v4l2_fh_is_singular(struct v4l2_fh*)'
  'void v4l2_m2m_buf_copy_metadata(const struct vb2_v4l2_buffer*, struct vb2_v4l2_buffer*, bool)'
  'int v4l2_m2m_ioctl_prepare_buf(struct file*, void*, struct v4l2_buffer*)'
  'int v4l2_m2m_ioctl_qbuf(struct file*, void*, struct v4l2_buffer*)'
  'int v4l2_m2m_querybuf(struct file*, struct v4l2_m2m_ctx*, struct v4l2_buffer*)'
  'int v4l2_m2m_register_media_controller(struct v4l2_m2m_dev*, struct video_device*, int)'
  'void v4l2_m2m_request_queue(struct media_request*)'
  'void v4l2_m2m_unregister_media_controller(struct v4l2_m2m_dev*)'
  'int vb2_core_dqbuf(struct vb2_queue*, unsigned int*, void*, bool)'
  'int vb2_core_expbuf(struct vb2_queue*, int*, unsigned int, unsigned int, unsigned int, unsigned int)'
  '__poll_t vb2_core_poll(struct vb2_queue*, struct file*, poll_table*)'
  'int vb2_core_qbuf(struct vb2_queue*, unsigned int, void*, struct media_request*)'
  'void vb2_core_querybuf(struct vb2_queue*, unsigned int, void*)'
  'int vb2_core_queue_init(struct vb2_queue*)'
  'void vb2_core_queue_release(struct vb2_queue*)'
  'int vb2_core_reqbufs(struct vb2_queue*, enum vb2_memory, unsigned int*)'
  'int vb2_core_streamoff(struct vb2_queue*, unsigned int)'
  'int vb2_core_streamon(struct vb2_queue*, unsigned int)'
  'int vb2_request_validate(struct media_request*)'
  'void videomode_from_timing(const struct display_timing*, struct videomode*)'
  'int walk_iomem_res_desc(unsigned long, unsigned long, u64, u64, void*, int(*)(struct resource*, void*))'
  'long work_on_cpu_safe(int, long(*)(void*), void*)'
  'int xhci_add_endpoint(struct usb_hcd*, struct usb_device*, struct usb_host_endpoint*)'
  'int xhci_check_bandwidth(struct usb_hcd*, struct usb_device*)'
  'int xhci_drop_endpoint(struct usb_hcd*, struct usb_device*, struct usb_host_endpoint*)'
  'struct xhci_ep_ctx* xhci_get_ep_ctx(struct xhci_hcd*, struct xhci_container_ctx*, unsigned int)'
  'void xhci_reset_bandwidth(struct usb_hcd*, struct usb_device*)'

Bug: 293831482
Change-Id: I4e3686f92e09964c6253008ca014ffe2770581da
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-08-09 17:02:02 +00:00
Kalesh Singh
0f986fae12 FROMGIT: BACKPORT: Multi-gen LRU: Fix can_swap in lru_gen_look_around()
walk->can_swap might be invalid since it's not guaranteed to be
initialized for the particular lruvec.  Instead deduce it from the folio
type (anon/file).

Link: https://lkml.kernel.org/r/20230802025606.346758-3-kaleshsingh@google.com
Fixes: 018ee47f14 ("mm: multi-gen LRU: exploit locality in rmap")
Change-Id: I1ae78011d4972d87bac9f2db8c56352cdb7a9be6
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> [mediatek]
Tested-by: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Aneesh Kumar K V <aneesh.kumar@linux.ibm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Steven Barrett <steven@liquorix.net>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit fdf19e8c8f1cdcee4eccf4c98a875f44f39d8b9d https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 288383787
Bug: 291719697
[ Kalesh Singh - Fix trivial conflict in lru_gen_look_around() ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-03 20:46:17 +00:00
Kalesh Singh
12fb1c3ef5 FROMGIT: BACKPORT: Multi-gen LRU: Avoid race in inc_min_seq()
inc_max_seq() will try to inc_min_seq() if nr_gens == MAX_NR_GENS. This
is because the generations are reused (the last oldest now empty
generation will become the next youngest generation).

inc_min_seq() is retried until successful, dropping the lru_lock
and yielding the CPU on each failure, and retaking the lock before
trying again:

        while (!inc_min_seq(lruvec, type, can_swap)) {
                spin_unlock_irq(&lruvec->lru_lock);
                cond_resched();
                spin_lock_irq(&lruvec->lru_lock);
        }

However, the initial condition that required incrementing the min_seq
(nr_gens == MAX_NR_GENS) is not retested. This can change by another
call to inc_max_seq() from run_aging() with force_scan=true from the
debugfs interface.

Since the eviction stalls when the nr_gens == MIN_NR_GENS, avoid
unnecessarily incrementing the min_seq by rechecking the number of
generations before each attempt.

This issue was uncovered in previous discussion on the list by Yu Zhao
and Aneesh Kumar [1].

[1] https://lore.kernel.org/linux-mm/CAOUHufbO7CaVm=xjEb1avDhHVvnC8pJmGyKcFf2iY_dpf+zR3w@mail.gmail.com/

Link: https://lkml.kernel.org/r/20230802025606.346758-2-kaleshsingh@google.com
Fixes: d6c3af7d8a ("mm: multi-gen LRU: debugfs interface")
Change-Id: I89e84ef2927eb1b0091f1be28bd03eb04dee4c57
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> [mediatek]
Tested-by: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Aneesh Kumar K V <aneesh.kumar@linux.ibm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Steven Barrett <steven@liquorix.net>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 250dbd10306126b06415afda8adfc27b2b780428 https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 288383787
Bug: 291719697
[ Fix trivial conflict in inc_max_seq() due to page -> folio
   Kalesh Singh ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-03 20:46:17 +00:00
Kalesh Singh
bf03a7c90a FROMGIT: BACKPORT: Multi-gen LRU: Fix per-zone reclaim
MGLRU has a LRU list for each zone for each type (anon/file) in each
generation:

	long nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];

The min_seq (oldest generation) can progress independently for each
type but the max_seq (youngest generation) is shared for both anon and
file. This is to maintain a common frame of reference.

In order for eviction to advance the min_seq of a type, all the per-zone
lists in the oldest generation of that type must be empty.

The eviction logic only considers pages from eligible zones for
eviction or promotion.

    scan_folios() {
	...
	for (zone = sc->reclaim_idx; zone >= 0; zone--)  {
	    ...
	    sort_folio(); 	// Promote
	    ...
	    isolate_folio(); 	// Evict
	}
	...
    }

Consider the system has the movable zone configured and default 4
generations. The current state of the system is as shown below
(only illustrating one type for simplicity):

Type: ANON

	Zone    DMA32     Normal    Movable    Device

	Gen 0       0          0        4GB         0

	Gen 1       0        1GB        1MB         0

	Gen 2     1MB        4GB        1MB         0

	Gen 3     1MB        1MB        1MB         0

Now consider there is a GFP_KERNEL allocation request (eligible zone
index <= Normal), evict_folios() will return without doing any work
since there are no pages to scan in the eligible zones of the oldest
generation. Reclaim won't make progress until triggered from a ZONE_MOVABLE
allocation request; which may not happen soon if there is a lot of free
memory in the movable zone. This can lead to OOM kills, although there
is 1GB pages in the Normal zone of Gen 1 that we have not yet tried to
reclaim.

This issue is not seen in the conventional active/inactive LRU since
there are no per-zone lists.

If there are no (not enough) folios to scan in the eligible zones, move
folios from ineligible zone (zone_index > reclaim_index) to the next
generation. This allows for the progression of min_seq and reclaiming
from the next generation (Gen 1).

Qualcomm, Mediatek and raspberrypi [1] discovered this issue independently.

[1] https://github.com/raspberrypi/linux/issues/5395

Link: https://lkml.kernel.org/r/20230802025606.346758-1-kaleshsingh@google.com
Fixes: ac35a49023 ("mm: multi-gen LRU: minimal implementation")
Change-Id: I5bbf44bd7ffe42f4347df4be59a75c1603c9b947
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Reported-by: Charan Teja Kalla <quic_charante@quicinc.com>
Reported-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> [mediatek]
Tested-by: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Steven Barrett <steven@liquorix.net>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Aneesh Kumar K V <aneesh.kumar@linux.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 1462260adc41c5974362cb54ff577c2a15b8c7b2 https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 288383787
Bug: 291719697
[ folio -> page renames - Kalesh Singh ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-03 20:46:17 +00:00
Bart Van Assche
0c5273e138 BACKPORT: FROMGIT: block: Improve performance for BLK_MQ_F_BLOCKING drivers
blk_mq_run_queue() runs the queue asynchronously if BLK_MQ_F_BLOCKING
has been set. This is suboptimal since running the queue asynchronously
is slower than running the queue synchronously. This patch modifies
blk_mq_run_queue() as follows if BLK_MQ_F_BLOCKING has been set:
- Run the queue synchronously if it is allowed to sleep.
- Run the queue asynchronously if it is not allowed to sleep.
Additionally, blk_mq_run_hw_queue(hctx, false) calls are modified into
blk_mq_run_hw_queue(hctx, hctx->flags & BLK_MQ_F_BLOCKING) if the caller
may be invoked from atomic context.

The following caller chains have been reviewed:

blk_mq_run_hw_queue(hctx, false)
  blk_mq_get_tag()      /* may sleep, hence the functions it calls may also sleep */
  blk_execute_rq()             /* may sleep */
  blk_mq_run_hw_queues(q, async=false)
    blk_freeze_queue_start()   /* may sleep */
    blk_mq_requeue_work()      /* may sleep */
    scsi_kick_queue()
      scsi_requeue_run_queue() /* may sleep */
      scsi_run_host_queues()
        scsi_ioctl_reset()     /* may sleep */
  blk_mq_insert_requests(hctx, ctx, list, run_queue_async=false)
    blk_mq_dispatch_plug_list(plug, from_sched=false)
      blk_mq_flush_plug_list(plug, from_schedule=false)
        __blk_flush_plug(plug, from_schedule=false)
	blk_add_rq_to_plug()
	  blk_mq_submit_bio()  /* may sleep if REQ_NOWAIT has not been set */
  blk_mq_plug_issue_direct()
    blk_mq_flush_plug_list()   /* see above */
  blk_mq_dispatch_plug_list(plug, from_sched=false)
    blk_mq_flush_plug_list()   /* see above */
  blk_mq_try_issue_directly()
    blk_mq_submit_bio()        /* may sleep if REQ_NOWAIT has not been set */
  blk_mq_try_issue_list_directly(hctx, list)
    blk_mq_insert_requests() /* see above */

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: I597e0fa587057ac22e52f73351cbfa1de2c72a6b
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230721172731.955724-4-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 291379528
(cherry picked from commit 65a558f66c git://git.kernel.dk/linux-block for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-03 19:14:25 +00:00
Bart Van Assche
d12306bb95 FROMGIT: scsi: Remove a blk_mq_run_hw_queues() call
blk_mq_kick_requeue_list() calls blk_mq_run_hw_queues() asynchronously.
Leave out the direct blk_mq_run_hw_queues() call. This patch causes
scsi_run_queue() to call blk_mq_run_hw_queues() asynchronously instead
of synchronously. Since scsi_run_queue() is not called from the hot I/O
submission path, this patch does not affect the hot path.

This patch prepares for allowing blk_mq_run_hw_queue() to sleep if
BLK_MQ_F_BLOCKING has been set. scsi_run_queue() may be called from
atomic context and must not sleep. Hence the removal of the
blk_mq_run_hw_queues(q, false) call. See also scsi_unblock_requests().

Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Change-Id: Ia7447d2cc803cb56728a902fd8562e85640d5fd0
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20230721172731.955724-3-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 291379528
(cherry picked from commit d42e2e3448 git://git.kernel.dk/linux-block for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-03 19:14:25 +00:00
Bart Van Assche
8bb4682c76 BACKPORT: FROMGIT: scsi: Inline scsi_kick_queue()
Inline scsi_kick_queue() to prepare for modifying the second argument
passed to blk_mq_run_hw_queues().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Change-Id: I595673bbdd357fd27eb61e5f2605257b8c20ecd6
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20230721172731.955724-2-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 291379528
(cherry picked from commit b5ca9acff5 git://git.kernel.dk/linux-block for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-08-03 19:14:25 +00:00
Giuliano Procida
4bbc8e45b2 ANDROID: ABI: Update STG ABI to format version 2
If you have trouble reading this new file format, please refresh your
prebuilt version of STG with repo sync.

Bug: 294213765
Change-Id: I4d7ee716231956c5f4da1343cc0db5170aaaa3b1
Signed-off-by: Giuliano Procida <gprocida@google.com>
2023-08-02 15:53:46 +01:00
Stanley Chang
a9bc04930f ANDROID: GKI: usb: phy: use ANDROID_KABI_USE for api notify_port_status
In struct usb_phy, the reserved slot 0 is reserved for a notify_port_status
callback addition for ABI freeze. Now this api is accepted on upstream.
Therefore, use ANDROID_KABI_USE to apply this api.

Bug: 286930662
Change-Id: Iae894f9dfff77fd1f23bb48fefdb9b682c54de57
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Stanley Chang
7aa67c1a12 FROMGIT: dt-bindings: phy: realtek: Add Realtek DHC RTD SoC USB 3.0 PHY
Document the USB PHY bindings for Realtek SoCs.
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB
controller and using USB 3.0 PHY transceiver.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230725033318.8361-5-stanley_chang@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 286930662
(cherry picked from commit d6ef688786
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Change-Id: Ic16e843003c090d5f2ccee6881133a9f782b0c72
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Stanley Chang
d58cdad855 FROMGIT: dt-bindings: phy: realtek: Add Realtek DHC RTD SoC USB 2.0 PHY
Document the USB PHY bindings for Realtek SoCs.
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB
controller and using USB 2.0 PHY transceiver.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230725033318.8361-4-stanley_chang@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 286930662
(cherry picked from commit 612ad27a30
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Change-Id: I338ac63f15c10687d79b98a6c68f8901b07869a5
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Stanley Chang
6e97af079d FROMGIT: phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB
controller. Added the driver to drive the USB 3.0 PHY transceivers.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
Link: https://lore.kernel.org/r/20230725033318.8361-3-stanley_chang@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 286930662
(cherry picked from commit adda6e82a7
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Change-Id: Icba27bdd44778e4d09006c86acf805d97db5746b
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Stanley Chang
3dadac8ba6 FROMGIT: phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB
controller. Added the driver to drive the USB 2.0 PHY transceivers.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
Link: https://lore.kernel.org/r/20230725033318.8361-2-stanley_chang@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 286930662
(cherry picked from commit 134e6d25f6
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Change-Id: Ia558a759e5bb288bc368335516863738e29bc142
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Stanley Chang
a600af2c26 FROMGIT: usb: phy: add usb phy notify port status API
In Realtek SoC, the parameter of usb phy is designed to can dynamic
tuning base on port status. Therefore, add a notify callback of phy
driver when usb port status change.

The Realtek phy driver is designed to dynamically adjust disconnection
level and calibrate phy parameters. When the device connected bit changes
and when the disconnected bit changes, do port status change notification:

Check if portstatus is USB_PORT_STAT_CONNECTION and portchange is
USB_PORT_STAT_C_CONNECTION.
1. The device is connected, the driver lowers the disconnection level and
   calibrates the phy parameters.
2. The device disconnects, the driver increases the disconnect level and
   calibrates the phy parameters.

When controller to notify connect that device is already ready. If we
adjust the disconnection level in notify_connect, the disconnect may have
been triggered at this stage. So we need to change that as early as
possible. The status change of connection is before port reset.
Therefore, we add an api to notify phy the port status changes. In this
stage, the device is not port enable, and it will not trigger
disconnection.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
Link: https://lore.kernel.org/r/20230725033318.8361-1-stanley_chang@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 286930662
(cherry picked from commit a08799cf17
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Change-Id: Ie7d903d00896aba02675642a1e168ea8d426024a
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-08-01 21:24:36 +00:00
Ramji Jiyani
46ee6c3cdd ANDROID: GKI: Create symbol files in include/config
Create input symbol files to generate GKI modules header
under include/config. By placing files in this generated
directory, the default filters that ignore certain files
will work without any special handling required, and they
will also be available to inspect after the build to inspect
for the debugging purposes.

abi_gki_protected_exports: Input for gki_module_protected_exports.h
From :- ${objtree}/abi_gki_protected_exports
To :- include/config/abi_gki_protected_exports

all_kmi_symbols: Input for gki_module_unprotected.h
- Rename to abi_gki_kmi_symbols
From :- all_kmi_symbols
To :- include/config/abi_gki_kmi_symbols

Bug: 286529877
Test: TH
Test: Manual verification of the generated files
Change-Id: Iafa10631e7712a8e1e87a2f56cfd614de6b1053a
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-08-01 21:21:47 +00:00
Paul Lawrence
9c0a91f91a ANDROID: fuse-bpf: Use stored bpf for create_open
create_open would always take its parent directory's bpf for the created
object. Modify to use the bpf stored in fuse_dentry which is set by
lookup.

Bug: 291705489
Test: fuse_test passes, adb push file /sdcard/Android/data works
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I0a1ea2a291a8fdf67923f1827176b2ea96bd4c2d
2023-07-31 23:09:43 +00:00
Paul Lawrence
77092bb630 ANDROID: fuse-bpf: Add bpf to negative fuse_dentry
Store the results of a negative lookup in the fuse_dentry so later
opcodes can use them to create files

Bug: 291705489
Test: fuse_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I725e714a1d6ce43f24431d07c24e96349ef1a55c
2023-07-31 23:09:43 +00:00
Paul Lawrence
fe475ca0b5 ANDROID: fuse-bpf: Check inode not null
fuse_iget_backing returns an inode or null, not a ERR_PTR. So check it's
not NULL

Also make sure we put the inode if d_splice_alias fails

Bug: 293349757
Test: fuse_test runs
Signed_off_by: Paul Lawrence <paullawrence@google.com>

Change-Id: I1eadad32f80bab6730e461412b4b7ab4d6c56bf2
2023-07-31 23:09:43 +00:00
Paul Lawrence
feb5ea6684 ANDROID: fuse-bpf: Fix flock test compile error
Bug: 293161755
Test: fuse_test compiles
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I249672bab85966e20a26018f65f135fe15c6eff5
2023-07-31 23:09:43 +00:00
Daniel Rosenberg
3c49a49167 ANDROID: fuse-bpf: Add partial flock support
This adds passthrough support for flock on fuse-bpf files. It does not
give any control via a bpf filter. The flock will act as though it was
taken on the lower file.

Bug: 289882899
Test: fuse_test -t32 (flock_test)
Change-Id: Iba0b9630766cedbd3195532c5e929891593cfe30
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2023-07-31 23:09:43 +00:00
Peter Korsgaard
95e1c94a22 UPSTREAM: dm init: add dm-mod.waitfor to wait for asynchronously probed block devices
commit 035641b01e upstream.

Just calling wait_for_device_probe() is not enough to ensure that
asynchronously probed block devices are available (E.G. mmc, usb), so
add a "dm-mod.waitfor=<device1>[,..,<deviceN>]" parameter to get
dm-init to explicitly wait for specific block devices before
initializing the tables with logic similar to the rootwait logic that
was introduced with commit  cc1ed7542c ("init: wait for
asynchronously scanned block devices").

E.G. with dm-verity on mmc using:
dm-mod.waitfor="PARTLABEL=hash-a,PARTLABEL=root-a"

[    0.671671] device-mapper: init: waiting for all devices to be available before creating mapped devices
[    0.671679] device-mapper: init: waiting for device PARTLABEL=hash-a ...
[    0.710695] mmc0: new HS200 MMC card at address 0001
[    0.711158] mmcblk0: mmc0:0001 004GA0 3.69 GiB
[    0.715954] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB
[    0.722085] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB
[    0.728093] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev (249:0)
[    0.738274]  mmcblk0: p1 p2 p3 p4 p5 p6 p7
[    0.751282] device-mapper: init: waiting for device PARTLABEL=root-a ...
[    0.751306] device-mapper: init: all devices available
[    0.751683] device-mapper: verity: sha256 using implementation "sha256-generic"
[    0.759344] device-mapper: ioctl: dm-0 (vroot) is ready
[    0.766540] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.

Change-Id: I6aa87e1164f9d4857074bafc9194d4085cdfcddc
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Cc: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 293688634
(cherry picked from commit 866bf37b7c)
Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
2023-07-31 10:08:31 +08:00
Qais Yousef
098173a46b ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __get_task_comm
  - teo_cpu_get_util_threshold
  - teo_cpu_set_util_threshold

Bug: 289293494
Change-Id: I33aabcbcd2d16e085ff6ef9b40d9c66241efba73
Signed-off-by: Qais Yousef <qyousef@google.com>
2023-07-30 18:28:40 +00:00
Qais Yousef
619a5f635c ANDROID: cpuidle: teo: Export a function that allows modifying util_threshold
There are some corner cases where we do worse in power because the
threshold is too low. Until these cases are better understood and
addressed upstream, provide a function for vendors to override this
value with something more suitable in their modules.

Bug: 289293494
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I95dd36718a317f3fcb2a9f4bc87dd3390a4f7d7d
2023-07-30 18:28:40 +00:00
Ramji Jiyani
d92dd7312f Revert "ANDROID: GKI: Remove temp build file abi_gki_protected_exports"
This reverts commit 1281598c53.

Reason for revert: Replaced by http://aosp/2679995

Change-Id: I0b69cc68780ad572b64d81f1a39f5b9c2fddc4a9
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-07-27 20:33:49 +00:00
Petri Gynther
924b7017dd ANDROID: Update the ABI symbol list
Adding the following symbols:
  - drm_edid_is_valid

Bug: 293142328
Change-Id: I307bdd226542fe8ffe4c657a9e1987c193a9d064
Signed-off-by: Petri Gynther <pgynther@google.com>
2023-07-27 00:05:41 +00:00
Eric Biggers
c82392dabd BACKPORT: blk-crypto: use dynamic lock class for blk_crypto_profile::lock
When a device-mapper device is passing through the inline encryption
support of an underlying device, calls to blk_crypto_evict_key() take
the blk_crypto_profile::lock of the device-mapper device, then take the
blk_crypto_profile::lock of the underlying device (nested).  This isn't
a real deadlock, but it causes a lockdep report because there is only
one lock class for all instances of this lock.

Lockdep subclasses don't really work here because the hierarchy of block
devices is dynamic and could have more than 2 levels.

Instead, register a dynamic lock class for each blk_crypto_profile, and
associate that with the lock.

This avoids false-positive lockdep reports like the following:

    ============================================
    WARNING: possible recursive locking detected
    6.4.0-rc5 #2 Not tainted
    --------------------------------------------
    fscryptctl/1421 is trying to acquire lock:
    ffffff80829ca418 (&profile->lock){++++}-{3:3}, at: __blk_crypto_evict_key+0x44/0x1c0

                   but task is already holding lock:
    ffffff8086b68ca8 (&profile->lock){++++}-{3:3}, at: __blk_crypto_evict_key+0xc8/0x1c0

                   other info that might help us debug this:
     Possible unsafe locking scenario:

           CPU0
           ----
      lock(&profile->lock);
      lock(&profile->lock);

                    *** DEADLOCK ***

     May be due to missing lock nesting notation

Fixes: 1b26283970 ("block: Keyslot Manager for Inline Encryption")
Reported-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230610061139.212085-1-ebiggers@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

Bug: 286427075
(cherry picked from commit 2fb48d88e7)
(added '#ifdef CONFIG_LOCKDEP' to keep the KMI tooling happy)
Change-Id: I21c0f941a36663c956a5c89324813bbaac0633ef
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-07-26 19:44:33 +00:00
Vincent Donnefort
44cf75cc35 ANDROID: KVM: arm64: Fix memory ordering for pKVM module callbacks
Registration of module callbacks for the pKVM hypervisor is lockless
thanks to the use of a cmpxchg.

Problem, a CPU can speculatively execute an indirect branch and
speculatively read variables used in that branch. We then need to order
the memory access between variables potentially set in the driver init
(before the callback registration happen) and the call to that
registered callback.

e.g. in the case of the serial.

 CPU0:                                   CPU1:

   driver_init():                        hyp_serial_enabled()
     base_addr = 0xdeadbeef;               enabled = __hyp_putc
     barrier();                            barrier();
     ops->register_serial_driver(putc);    if (enabled)
                                                __hyp_putc(); /* read base_addr */

This is the same for the SMC and PSCI handler callbacks. The abort and
fault callbacks are not impacted: the driver init can only happen before
the kernel is deprivileged i.e. before the host stage-2 is in place and
then before any of those callbacks can be triggered.

Instead of a full barrier, we can use the acquire/release semantics:
relaxing cmpxchg to cmpxchg_release in the registration path and use a
load_acquire in hyp_serial_enabled().

Bug: 292470326
Change-Id: I4b5fe3713fe40cc5ab42ea0e9cdf54e8315dfb44
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-07-26 08:22:10 +00:00
Wanwei Jiang
fddd85ce63 ANDROID: GKI: Update symbol list for Amlogic
1 function symbol(s) added
  'int param_get_short(char*, const struct kernel_param*)'

Bug: 293011191
Change-Id: I4ed37ee6ab10eaba9922c23978c8b82fef9a66d4
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
2023-07-25 22:39:58 +08:00
M A Ramdhan
f686a35a77 UPSTREAM: net/sched: cls_fw: Fix improper refcount update leads to use-after-free
[ Upstream commit 0323bce598 ]

In the event of a failure in tcf_change_indev(), fw_set_parms() will
immediately return an error after incrementing or decrementing
reference counter in tcf_bind_filter().  If attacker can control
reference counter to zero and make reference freed, leading to
use after free.

In order to prevent this, move the point of possible failure above the
point where the TC_FW_CLASSID is handled.

Bug: 292252062
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: M A Ramdhan <ramdhan@starlabs.sg>
Signed-off-by: M A Ramdhan <ramdhan@starlabs.sg>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Message-ID: <20230705161530.52003-1-ramdhan@starlabs.sg>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c91fb29bb0)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I9bf6f540b4eb23ea5641fb3efe6f3e621d7b6151
2023-07-25 13:14:41 +00:00
Pablo Neira Ayuso
625e1470a9 UPSTREAM: netfilter: nf_tables: fix chain binding transaction logic
[ Upstream commit 4bedf9eee0 ]

Add bound flag to rule and chain transactions as in 6a0a8d10a3
("netfilter: nf_tables: use-after-free in failing rule with bound set")
to skip them in case that the chain is already bound from the abort
path.

This patch fixes an imbalance in the chain use refcnt that triggers a
WARN_ON on the table and chain destroy path.

This patch also disallows nested chain bindings, which is not
supported from userspace.

The logic to deal with chain binding in nft_data_hold() and
nft_data_release() is not correct. The NFT_TRANS_PREPARE state needs a
special handling in case a chain is bound but next expressions in the
same rule fail to initialize as described by 1240eb93f0 ("netfilter:
nf_tables: incorrect error path handling with NFT_MSG_NEWRULE").

The chain is left bound if rule construction fails, so the objects
stored in this chain (and the chain itself) are released by the
transaction records from the abort path, follow up patch ("netfilter:
nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound set/chain")
completes this error handling.

When deleting an existing rule, chain bound flag is set off so the
rule expression .destroy path releases the objects.

Bug: 292097846
Fixes: d0e2c7de92 ("netfilter: nf_tables: add NFT_CHAIN_BINDING")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 891cd2eddd)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I8a8cf012e9e6fd0d0081f3f7616c9cf31ea02989
2023-07-25 12:26:59 +01:00
Konstantin Komarov
de818a4efb UPSTREAM: fs/ntfs3: Check fields while reading
commit 0e8235d28f upstream.

Added new functions index_hdr_check and index_buf_check.
Now we check all stuff for correctness while reading from disk.
Also fixed bug with stale nfs data.

Bug: 286390611
Reported-by: van fantasy <g1042620637@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Fixes: 82cae269cf ("fs/ntfs3: Add initialization of super block")
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 000a9a72ef)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I2b17511acdef8617aea3fecb45d2f11e49145097
2023-07-25 08:17:28 +01:00
Ramji Jiyani
48fffa48b0 ANDROID: GKI: Move GKI module headers to generated includes
Change build time generated GKI module headers location
From :- kernel/module/gki_module_*.h
To :- include/generated/gki_module_*.h

This prevents the kernel source from being contaminated.
By placing the header files in a generated directory,
the default filters that ignore certain files will work
without any special handling required.

Bug: 286529877
Test: Manual verification & TH
Change-Id: Ie247d1c132ddae54906de2e2850e95d7ae9edd50
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
(cherry picked from commit e9cba885543fc50a5b59ff7234d02b74a380573c)
2023-07-24 17:57:22 +00:00
Yifan Hong
c51761363c ANDROID: set kmi_symbol_list_add_only for Kleaf builds.
On KMI frozen branches, symbols may no longer be removed
from KMI symbol lists.

This change sets kmi_symbol_list_add_only=true for Kleaf builds.

Test: Treehugger
Bug: 292106238
Change-Id: I74cf98ebad2705b92468c996e9b3b472447e8203
Signed-off-by: Yifan Hong <elsk@google.com>
2023-07-24 15:42:36 +00:00
Ramji Jiyani
1281598c53 ANDROID: GKI: Remove temp build file abi_gki_protected_exports
abi_gki_protected_exports is a prepped list of symbols protected
from being exported by unsigned modules; and input to generate
gki_module_protected_exports.h during kernel build.

Delete it once header is generated so it is not lingering in the
source when kernel sournce is being built in-place i.e. OBJ is
not set during the build.

Bug: 286529877
Test: Manual verification & TH
Change-Id: Ia06db62da03289b8f90917bcd302c81c8a4d31d2
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-07-24 06:26:20 +00:00
Wanwei Jiang
48916f9971 ANDROID: GKI: Update symbol list for Amlogic
12 function symbol(s) added
  'int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl*, s32)'
  'int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl*, s64)'
  'const void* __v4l2_find_nearest_size(const void*, size_t, size_t, size_t, size_t, s32, s32)'
  'int media_create_pad_link(struct media_entity*, u16, struct media_entity*, u16, u32)'
  'struct media_pad* media_entity_remote_pad(const struct media_pad*)'
  'int media_pipeline_start(struct media_entity*, struct media_pipeline*)'
  'void media_pipeline_stop(struct media_entity*)'
  'struct v4l2_ctrl* v4l2_ctrl_find(struct v4l2_ctrl_handler*, u32)'
  'struct v4l2_ctrl* v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler*, const struct v4l2_ctrl_ops*, u32, u8, u8, const s64*)'
  'int v4l2_event_subdev_unsubscribe(struct v4l2_subdev*, struct v4l2_fh*, struct v4l2_event_subscription*)'
  'int v4l2_subdev_link_validate(struct media_link*)'
  'int vb2_ioctl_prepare_buf(struct file*, void*, struct v4l2_buffer*)'

Bug: 292213601
Change-Id: Id17b074aa5de1687d89f54e95476bbb21bc32bf6
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
2023-07-21 22:28:23 +08:00
Takashi Iwai
c2591e463d UPSTREAM: ASoC: soc-pcm: Move debugfs removal out of spinlock
The recent fix for DPCM locking also covered the loop in
dpcm_be_disconnect() with the FE stream lock.  This caused an
unexpected side effect, thought: calling debugfs_remove_recursive() in
the spinlock may lead to lockdep splats as the code there assumes the
SOFTIRQ-safe context.

For avoiding the problem, this patch changes the disconnection
procedure to two phases: at first, the matching entries are removed
from the linked list, then the resources are freed outside the lock.

Bug: 291825551
Fixes: b7898396f4 ("ASoC: soc-pcm: Fix and cleanup DPCM locking")
Reported-and-tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I7a793b029cfbddb6082afe001c08890c54c67045
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 9f620684c1)
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
2023-07-20 10:10:37 -07:00
Takashi Iwai
4dc2398a95 UPSTREAM: ASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks
The recent change for DPCM locking caused spurious lockdep warnings.
Actually the warnings are false-positive, as those are triggered due
to the nested stream locks for FE and BE.  Since both locks belong to
the same lock class, lockdep sees it as if a deadlock.

For fixing this, we need to take PCM stream locks for BE with the
nested lock primitives.  Since currently snd_pcm_stream_lock*() helper
assumes only the top-level single locking, a new helper function
snd_pcm_stream_lock_irqsave_nested() is defined for a single-depth
nested lock, which is now used in the BE DAI trigger that is always
performed inside a FE stream lock.

Bug: 291825551
Fixes: b2ae806630 ("ASoC: soc-pcm: serialize BE triggers")
Reported-and-tested-by: Hans de Goede <hdegoede@redhat.com>
Reported-and-tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/73018f3c-9769-72ea-0325-b3f8e2381e30@redhat.com
Link: https://lore.kernel.org/alsa-devel/9a0abddd-49e9-872d-2f00-a1697340f786@samsung.com
Change-Id: I163307c958c1e86f8d15c637a4d8739286b6d062
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 3c75c0ea5d)
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
2023-07-20 10:09:05 -07:00
Miklos Szeredi
1dd1248e12 FROMLIST: fuse: revalidate: don't invalidate if interrupted
If the LOOKUP request triggered from fuse_dentry_revalidate() is
interrupted, then the dentry will be invalidated, possibly resulting in
submounts being unmounted.

Reported-by: Xu Rongbo <xurongbo@baidu.com>
Fixes: 9e6268db49 ("[PATCH] FUSE - read-write operations")
Cc: <stable@vger.kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Bug: 282905757
Link: https://lore.kernel.org/all/CAJfpegswN_CJJ6C3RZiaK6rpFmNyWmXfaEpnQUJ42KCwNF5tWw@mail.gmail.com/
Signed-off-by: Paul Lawrence <paullawrence@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:ae5b9259d42efa1bbd42d807fd3b3a991ddb51be)
Merged-In: I8c62f5aeeb450de78c6a38a6f8728c900a0fc9bd
Change-Id: I8c62f5aeeb450de78c6a38a6f8728c900a0fc9bd
2023-07-20 16:31:22 +00:00
Wanwei Jiang
ef049b5a71 ANDROID: GKI: Update symbol list for Amlogic
1 function symbol(s) added
  'int pci_write_config_byte(const struct pci_dev*, int, u8)'

Bug: 291887954
Change-Id: I232ed8eb6f4f2b8e7e64716c8d82a70d2b3f998b
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
2023-07-19 19:12:59 +00:00
Phillip Lougher
88829ece33 UPSTREAM: squashfs: always build "file direct" version of page actor
Squashfs_readahead uses the "file direct" version of the page actor, and
so build it unconditionally.

Link: https://lkml.kernel.org/r/20220617083810.337573-3-hsinyi@chromium.org

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reported-by: kernel test robot <lkp@intel.com>
Cc: Hou Tao <houtao1@huawei.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miao Xie <miaoxie@huawei.com>
Cc: Xiongwei Song <Xiongwei.Song@windriver.com>
Cc: Zhang Yi <yi.zhang@huawei.com>
Cc: Zheng Liang <zhengliang6@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit db98b43086)
Change-Id: Ia094ba6a443927fa323ce69a4409dd6297e6938a
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Vincent Whitchurch
044746150d UPSTREAM: squashfs: fix cache race with migration
Migration replaces the page in the mapping before copying the contents and
the flags over from the old page, so check that the page in the page cache
is really up to date before using it.  Without this, stressing squashfs
reads with parallel compaction sometimes results in squashfs reporting
data corruption.

Link: https://lkml.kernel.org/r/20230629-squashfs-cache-migration-v1-1-d50ebe55099d@axis.com
Fixes: e994f5b677 ("squashfs: cache partial compressed blocks")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit 08bab74ae6)
Change-Id: I71307d68bede9e55521e5313ede5d57f9bc726bd
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00