Commit Graph

1068192 Commits

Author SHA1 Message Date
Qais Yousef
858f6f1541 ANDROID: sched/fair: unlink misfit from cpu overutilized
Partially applies patch from Vincent Guittot

	e5ed0550c0: ("sched/fair: unlink misfit task from cpu overutilized")

The full patch improves the search logic under thermal pressure, but
it's a bit intrusive to fully backport. We are interested in the part
that unlinks misfit from overutilized only.

Bug: 283975667
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I2ae21499b846d13d3889f8cacdb70652817b066f
2023-06-06 19:51:56 +00:00
Stanley Chang
a393cfd70d UPSTREAM: dt-bindings: usb: snps,dwc3: Add 'snps,parkmode-disable-hs-quirk' quirk
Add a new 'snps,parkmode-disable-hs-quirk' DT quirk to dwc3 core for
disable the high-speed parkmode.

For some USB wifi devices, if enable this feature it will reduce the
performance. Therefore, add an option for disabling HS park mode by
device-tree.

In Synopsys's dwc3 data book:
In a few high speed devices when an IN request is sent within 900ns of the
ACK of the previous packet, these devices send a NAK. When connected to
these devices, if required, the software can disable the park mode if you
see performance drop in your system. When park mode is disabled,
pipelining of multiple packet is disabled and instead one packet at a time
is requested by the scheduler. This allows up to 12 NAKs in a micro-frame
and improves performance of these slow devices.

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

Bug:285992796
(cherry picked from commit 4a2f152af1
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git master)
Change-Id: If445a42082326b981f75ed21bc92a4b7c2fff685
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-06-06 19:22:36 +00:00
Stanley Chang
d47ecf2f59 UPSTREAM: usb: dwc3: core: add support for disabling High-speed park mode
Setting the PARKMODE_DISABLE_HS bit in the DWC3_USB3_GUCTL1.
When this bit is set to '1' all HS bus instances in park mode are disabled

For some USB wifi devices, if enable this feature it will reduce the
performance. Therefore, add an option for disabling HS park mode by
device-tree.

In Synopsys's dwc3 data book:
In a few high speed devices when an IN request is sent within 900ns of the
ACK of the previous packet, these devices send a NAK. When connected to
these devices, if required, the software can disable the park mode if you
see performance drop in your system. When park mode is disabled,
pipelining of multiple packet is disabled and instead one packet at a time
is requested by the scheduler. This allows up to 12 NAKs in a micro-frame
and improves performance of these slow devices.

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

Bug:285992796
(cherry picked from commit d21a797a3e
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git master)
Change-Id: I81f3a0bf15d2405fbb85bbe3a55cdbeb015ce48e
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-06-06 19:22:36 +00:00
Bin Yang
cfb11ffd57 UPSTREAM: usb: dwc3: core: do not use 3.0 clock when operating in 2.0 mode
In the 3.0 device core, if the core is programmed to operate in
2.0 only, then setting the GUCTL1.DEV_FORCE_20_CLK_FOR_30_CLK makes
the internal 2.0(utmi/ulpi) clock to be routed as the 3.0 (pipe)
clock. Enabling this feature allows the pipe3 clock to be not-running
when forcibly operating in 2.0 device mode.

Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Link: https://lore.kernel.org/r/20220228135700.1089526-6-pgwipeout@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug:285984663
(cherry picked from commit 62b20e6e0d
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git master)
Change-Id: I104aefd490413cc3ee8d9bceefba01c5b29a3250
Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
2023-06-06 19:22:36 +00:00
vincent wang
5a5805873e ANDROID: GKI: Update symbol list for Lenovo
Add symbol list for Lenovo

1 function symbol added
	'rebuild_sched_domains()'

Bug: 286015587
Change-Id: I35fe23cc6314fb6b7bf564f0fd749141f4c33752
Signed-off-by: vincent wang <vincentwang3@lenovo.com>
2023-06-06 18:15:52 +00:00
Stephen Dickey
7624f5afdf ANDROID: kernel/sched: rebuild_sched_domains export
Vendor module needs to rebuild sched domains at boot, in the
event that cpufreq initializes the energy model too late.

Bug: 242898038
Change-Id: Ifaf1223366ac81c3f3c382dd0f61110fce9c1b20
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
(cherry picked from commit 20ba031cf8)
2023-06-06 18:15:52 +00:00
Robert Lee
872144a3a9 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - snd_pcm_hw_constraint_integer
  - snd_soc_set_runtime_hwparams

Bug: 264508873
Change-Id: I5616a0aa475456abdfb466d62c08accd5f8b222f
Signed-off-by: Robert Lee <lerobert@google.com>
2023-06-06 12:05:41 +08:00
Wanwei Jiang
fa700b32b1 ANDROID: GKI: Update symbol list for Amlogic
Add the following symbols:
  - bpf_trace_run8
  - dma_fence_get_stub
  - spi_finalize_current_message
  - strim

Bug: 284949440
Change-Id: Ife34464786b780e74dbe08e7acb5611556337597
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
2023-06-05 20:44:39 +00:00
erinwang2
5ef78a29d1 ANDROID: GKI: Add symbol list for lenovo
Add symbol list for lenovo

66 function symbol(s) added
  'struct gendisk* __alloc_disk_node(struct request_queue*, int, struct lock_class_key*)'
  'void blk_freeze_queue_start(struct request_queue*)'
  'bool blk_get_queue(struct request_queue*)'
  'void blk_mark_disk_dead(struct gendisk*)'
  'struct request* blk_mq_alloc_request(struct request_queue*, unsigned int, blk_mq_req_flags_t)'
  'struct request* blk_mq_alloc_request_hctx(struct request_queue*, unsigned int, blk_mq_req_flags_t, unsigned int)'
  'int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set*, const struct blk_mq_ops*, unsigned int, unsigned int)'
  'bool blk_mq_complete_request_remote(struct request*)'
  'void blk_mq_delay_kick_requeue_list(struct request_queue*, unsigned long)'
  'void blk_mq_free_request(struct request*)'
  'void blk_mq_freeze_queue(struct request_queue*)'
  'void blk_mq_freeze_queue_wait(struct request_queue*)'
  'int blk_mq_freeze_queue_wait_timeout(struct request_queue*, unsigned long)'
  'int blk_mq_pci_map_queues(struct blk_mq_queue_map*, struct pci_dev*, int)'
  'void blk_mq_requeue_request(struct request*, bool)'
  'struct request* blk_mq_tag_to_rq(struct blk_mq_tags*, unsigned int)'
  'void blk_mq_tagset_busy_iter(struct blk_mq_tag_set*, busy_tag_iter_fn*, void*)'
  'void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set*)'
  'void blk_mq_unfreeze_queue(struct request_queue*)'
  'void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set*, int)'
  'void blk_put_queue(struct request_queue*)'
  'void blk_queue_chunk_sectors(struct request_queue*, unsigned int)'
  'void blk_queue_dma_alignment(struct request_queue*, int)'
  'bool blk_queue_flag_test_and_set(unsigned int, struct request_queue*)'
  'void blk_queue_max_zone_append_sectors(struct request_queue*, unsigned int)'
  'void blk_queue_set_zoned(struct gendisk*, enum blk_zoned_model)'
  'void blk_queue_virt_boundary(struct request_queue*, unsigned long)'
  'int blk_revalidate_disk_zones(struct gendisk*, void(*)(struct gendisk*))'
  'void blk_sync_queue(struct request_queue*)'
  'int blkdev_compat_ptr_ioctl(struct block_device*, fmode_t, unsigned int, unsigned long)'
  'int dev_pm_qos_expose_latency_tolerance(struct device*)'
  'void dev_pm_qos_hide_latency_tolerance(struct device*)'
  'int dev_pm_qos_update_user_latency_tolerance(struct device*, s32)'
  'bool device_remove_file_self(struct device*, const struct device_attribute*)'
  'void devm_release_resource(struct device*, struct resource*)'
  'size_t dma_max_mapping_size(struct device*)'
  'struct fwnode_handle* fwnode_find_reference(const struct fwnode_handle*, const char*, unsigned int)'
  'struct fwnode_handle* fwnode_get_next_child_node(const struct fwnode_handle*, struct fwnode_handle*)'
  'bool irq_check_status_bit(unsigned int, unsigned int)'
  'void irq_domain_associate_many(struct irq_domain*, unsigned int, irq_hw_number_t, int)'
  'int irq_get_percpu_devid_partition(unsigned int, struct cpumask*)'
  'void irq_work_run()'
  'struct mbox_chan* mbox_request_channel_byname(struct mbox_client*, const char*)'
  'void* memchr_inv(const void*, int, size_t)'
  'void* mempool_alloc(mempool_t*, gfp_t)'
  'mempool_t* mempool_create_node(int, mempool_alloc_t*, mempool_free_t*, void*, gfp_t, int)'
  'void mempool_destroy(mempool_t*)'
  'void mempool_free(void*, mempool_t*)'
  'void mempool_kfree(void*, void*)'
  'void* mempool_kmalloc(gfp_t, void*)'
  'int of_reserved_mem_device_init_by_name(struct device*, struct device_node*, const char*)'
  'int param_set_uint_minmax(const char*, const struct kernel_param*, unsigned int, unsigned int)'
  'int pci_aer_clear_nonfatal_status(struct pci_dev*)'
  'int pci_disable_pcie_error_reporting(struct pci_dev*)'
  'phys_addr_t pci_pio_to_address(unsigned long)'
  'int pci_sriov_configure_simple(struct pci_dev*, int)'
  'void pcibios_resource_to_bus(struct pci_bus*, struct pci_bus_region*, struct resource*)'
  'bool pcie_aspm_enabled(struct pci_dev*)'
  'int perf_aux_output_skip(struct perf_output_handle*, unsigned long)'
  'void perf_event_addr_filters_sync(struct perf_event*)'
  'int pinconf_generic_parse_dt_config(struct device_node*, struct pinctrl_dev*, unsigned long**, unsigned int*)'
  'void pinctrl_unregister(struct pinctrl_dev*)'
  'void put_disk(struct gendisk*)'
  'bool this_cpu_has_cap(unsigned int)'
  'void trace_seq_printf(struct trace_seq*, const char*, ...)'
  'void trace_seq_putc(struct trace_seq*, unsigned char)'

Bug: 285569306

Change-Id: I0d844e1026c367aeede6175398784f0776b7120f
Signed-off-by: erinwang2 <erinwang2@lenovo.com>
2023-06-02 22:52:59 -07:00
Sajid Dalvi
93a3eb5322 UPSTREAM: PCI/PM: Reduce D3hot delay with usleep_range()
PCIe r6.0, sec 5.9, requires a 10ms delay between programming a device to
change to or from D3hot and the time the device is next accessed (unless
Readiness Notifications are used).

The 10ms value (PCI_PM_D3HOT_WAIT) doesn't appear directly here because
some chipsets require 120ms for devices *below* them (pci_pm_d3hot_delay)
and some devices require more or less than 10ms (dev->d3hot_delay).

But msleep(10) typically waits about *20*ms, which is more than we need.
Switch to usleep_range() to improve the delay accuracy.

Based on a commit from Sajid in the Pixel 6 kernel tree [1].  On a Pixel 6,
the 10ms delay for the Exynos PCIe device delayed for an average of 19ms.
Switching to usleep_range() decreased the resume time by about 9ms.

[1] 18a8cad68d

[bhelgaas commit log, add timers-howto.rst link]
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/timers/timers-howto.rst?id=v5.19#n73
Link: https://lore.kernel.org/r/20220921212735.2131588-1-willmcvicker@google.com
Signed-off-by: Sajid Dalvi <sdalvi@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

Bug: 258100247
Change-Id: Iacde62a3ec8e4b924a21fb654c89a18df2ee2b87
(cherry picked from commit 3e347969a5)
Signed-off-by: Sajid Dalvi <sdalvi@google.com>
2023-06-02 20:54:00 +00:00
tfshen
2e56d401bb ANDROID: GKI: Add RTK TV 14 5.15 KMI symbol list
add initial abi_gki_aarch64_rtktv file.

55 function symbol(s) added
  'int __traceiter_android_vh_dmabuf_heap_flags_validation(void*, struct dma_heap*, size_t, unsigned int, unsigned int, bool*)'
  'int add_memory_subsection(int, u64, u64)'
  'int alloc_contig_range(unsigned long, unsigned long, unsigned int, gfp_t, struct acr_info*)'
  'struct thermal_cooling_device* cpufreq_cooling_register(struct cpufreq_policy*)'
  'void cpufreq_cooling_unregister(struct thermal_cooling_device*)'
  'int dev_pm_opp_of_cpumask_add_table(const struct cpumask*)'
  'int dev_pm_opp_of_get_sharing_cpus(struct device*, struct cpumask*)'
  'int device_pm_wait_for_dev(struct device*, struct device*)'
  'void devm_extcon_dev_unregister(struct device*, struct extcon_dev*)'
  'struct phy* devm_of_phy_get_by_index(struct device*, struct device_node*, int)'
  'int drm_gem_mmap_obj(struct drm_gem_object*, unsigned long, struct vm_area_struct*)'
  'void drm_mode_sort(struct list_head*)'
  'void ehci_init_driver(struct hc_driver*, const struct ehci_driver_overrides*)'
  'int ehci_resume(struct usb_hcd*, bool)'
  'int ehci_setup(struct usb_hcd*)'
  'int ehci_suspend(struct usb_hcd*, bool)'
  'void flush_delayed_fput()'
  'int follow_pfn(struct vm_area_struct*, unsigned long, unsigned long*)'
  'void free_contig_range(unsigned long, unsigned long)'
  'void gen_pool_for_each_chunk(struct gen_pool*, void(*)(struct gen_pool*, struct gen_pool_chunk*, void*), void*)'
  'void kmsg_dump_rewind(struct kmsg_dump_iter*)'
  'bool kthread_freezable_should_stop(bool*)'
  'phys_addr_t memblock_end_of_DRAM()'
  'int memblock_free(phys_addr_t, phys_addr_t)'
  'void mii_ethtool_gset(struct mii_if_info*, struct ethtool_cmd*)'
  'time64_t mktime64(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
  'int mmc_get_ext_csd(struct mmc_card*, u8**)'
  'MPI mpi_alloc(unsigned int)'
  'int mpi_cmp(MPI, MPI)'
  'int mpi_cmp_ui(MPI, unsigned long)'
  'void mpi_free(MPI)'
  'void* mpi_get_buffer(MPI, unsigned int*, int*)'
  'unsigned int mpi_get_nbits(MPI)'
  'int mpi_powm(MPI, MPI, MPI, MPI)'
  'MPI mpi_read_raw_data(const void*, size_t)'
  'int nr_ipi_get()'
  'unsigned int radix_tree_gang_lookup(const struct xarray*, void**, unsigned long, unsigned int)'
  'unsigned int radix_tree_gang_lookup_tag(const struct xarray*, void**, unsigned long, unsigned int, unsigned int)'
  'int radix_tree_preload(gfp_t)'
  'void* radix_tree_tag_clear(struct xarray*, unsigned long, unsigned int)'
  'int radix_tree_tag_get(const struct xarray*, unsigned long, unsigned int)'
  'void* radix_tree_tag_set(struct xarray*, unsigned long, unsigned int)'
  'int send_sig_mceerr(int, void*, short, struct task_struct*)'
  'void smpboot_unregister_percpu_thread(struct smp_hotplug_thread*)'
  'int static_key_count(struct static_key*)'
  'int thermal_zone_unbind_cooling_device(struct thermal_zone_device*, int, struct thermal_cooling_device*)'
  'unsigned int uart_get_divisor(struct uart_port*, unsigned int)'
  'void uart_handle_cts_change(struct uart_port*, unsigned int)'
  'void uart_handle_dcd_change(struct uart_port*, unsigned int)'
  'int unregister_console(struct console*)'
  'int unregister_die_notifier(struct notifier_block*)'
  'int usb_gadget_map_request(struct usb_gadget*, struct usb_request*, int)'
  'void usb_gadget_unmap_request(struct usb_gadget*, struct usb_request*, int)'
  'unsigned long vm_mmap(struct file*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)'
  'int vm_munmap(unsigned long, size_t)'

4 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_dmabuf_heap_flags_validation'
  'struct static_key_true init_on_alloc'
  'struct resource ioport_resource'
  'int panic_timeout'

Bug: 285483154
Change-Id: Ic3c7a1639682011a8d016b1d65faba52c97c415a
Signed-off-by: tfshen <tfshen@realtek.com>
2023-06-02 15:13:17 +08:00
Avichal Rakesh
f82b531088 Revert "FROMGIT: usb: gadget: udc: core: Prevent redundant calls to pullup"
This reverts commit b9bb33b73c.

Reason: This patch breaks any USB gadget function that deactivates the
gadget on bind (by setting bind_deactivated = true).

Bug: 285019584

Signed-off-by: Avichal Rakesh <arakesh@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:b59c3ebaf21e40182bad5160dd5d721d8c849f59)
Merged-In: I2885819dd75e9d65de8258b7d2f6fc5d98de6c68
Change-Id: I2885819dd75e9d65de8258b7d2f6fc5d98de6c68
2023-05-30 23:05:30 +00:00
Chungkai Mei
e25b806e1b ANDROID: Update the ABI symbol list
Add the following symbols:
  - __traceiter_android_rvh_schedule
  - __tracepoint_android_rvh_schedule

Bug: 270685154
Test: Build pass
Change-Id: I5dd059785fe33714b92224377ca1251c0f9c38b1
Signed-off-by: Chungkai Mei <chungkai@google.com>
2023-05-30 22:06:22 +00:00
Kalesh Singh
397665b3ed ANDROID: BACKPORT: mm: Multi-gen LRU: remove wait_event_killable()
Android 14 and later default to MGLRU [1] and field telemetry showed
occasional long tail latency (>100ms) in the reclaim path.

Tracing revealed priority inversion in the reclaim path.  In
try_to_inc_max_seq(), when high priority tasks were blocked on
wait_event_killable(), the preemption of the low priority task to call
wake_up_all() caused those high priority tasks to wait longer than
necessary.  In general, this problem is not different from others of its
kind, e.g., one caused by mutex_lock().  However, it is specific to MGLRU
because it introduced the new wait queue lruvec->mm_state.wait.

The purpose of this new wait queue is to avoid the thundering herd
problem.  If many direct reclaimers rush into try_to_inc_max_seq(), only
one can succeed, i.e., the one to wake up the rest, and the rest who
failed might cause premature OOM kills if they do not wait.  So far there
is no evidence supporting this scenario, based on how often the wait has
been hit.  And this begs the question how useful the wait queue is in
practice.

Based on Minchan's recommendation, which is in line with his commit
6d4675e601 ("mm: don't be stuck to rmap lock on reclaim path") and the
rest of the MGLRU code which also uses trylock when possible, remove the
wait queue.

[1] https://android-review.googlesource.com/q/I7ed7fbfd6ef9ce10053347528125dd98c39e50bf

Link: https://lkml.kernel.org/r/20230413214326.2147568-1-kaleshsingh@google.com
Fixes: bd74fdaea1 ("mm: multi-gen LRU: support page table walks")
Change-Id: Ia2c65c92652018bb833e632028075ea27b68477e
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Suggested-by: Minchan Kim <minchan@kernel.org>
Reported-by: Wei Wang <wvw@google.com>
Acked-by: Yu Zhao <yuzhao@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
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 7f63cf2d9b)
Bug: 277906484
[ Kalesh Singh - Fix conflicts in mm/vmscan.c ]
[ Kalesh Singh - Fix up ABI breakages in include/linux/mmzone.h ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-05-27 00:49:46 +00:00
Kalesh Singh
522c6b9c55 BACKPORT: FROMGIT: Multi-gen LRU: fix workingset accounting
On Android app cycle workloads, MGLRU showed a significant reduction in
workingset refaults although pgpgin/pswpin remained relatively unchanged.
This indicated MGLRU may be undercounting workingset refaults.

This has impact on userspace programs, like Android's LMKD, that monitor
workingset refault statistics to detect thrashing.

It was found that refaults were only accounted if the MGLRU shadow entry
was for a recently evicted folio.  However, recently evicted folios should
be accounted as workingset activation, and refaults should be accounted
regardless of recency.

Fix MGLRU's workingset refault and activation accounting to more closely
match that of the conventional active/inactive LRU.

Link: https://lkml.kernel.org/r/20230523205922.3852731-1-kaleshsingh@google.com
Fixes: ac35a49023 ("mm: multi-gen LRU: minimal implementation")
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Reported-by: Charan Teja Kalla <quic_charante@quicinc.com>
Acked-by: Yu Zhao <yuzhao@google.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 02ad728453d2ddb09d7ce5e59854ebb27544d488 https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 284043217
[ Kalesh Singh - Fix conflicts in mm/workingset.c ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: I6d42cca9064e66099fbbc20aa2143961f84b2003
2023-05-26 13:36:54 -07:00
Todd Kjos
9abc9f635a ANDROID: Disable BTI_KERNEL, enable UNWIND_PATCH_PAC_INTO_SCS
Disable CONFIG_ARM64_BTI_KERNEL since significant overhead has been observed
on systems that don't have BTI/PAC hardware support due to increased number
of NOPs added by these features.

BTI is not as important in kernels that have CFI enabled because the protection
these features offer overlap.

Keep PAC enabled and also enable dynamic SCS (CONFIG_UNWIND_PATCH_PAC_INTO_SCS)
which is available starting in v6.2. This removes SCS overhead on systems that
support PAC, and PAC overhead on systems that need SCS instead. This feature uses
runtime code patching, so it won't have the overhead of additional NOPs.

Bug: 267119345
Change-Id: Ifc7d5e502940bd15d13e7f89c5facd10b6c7b8a8
Signed-off-by: Todd Kjos <tkjos@google.com>
2023-05-25 16:09:30 -07:00
Ard Biesheuvel
845c91e987 BACKPORT: arm64: implement dynamic shadow call stack for Clang
Implement dynamic shadow call stack support on Clang, by parsing the
unwind tables at init time to locate all occurrences of PACIASP/AUTIASP
instructions, and replacing them with the shadow call stack push and pop
instructions, respectively.

This is useful because the overhead of the shadow call stack is
difficult to justify on hardware that implements pointer authentication
(PAC), and given that the PAC instructions are executed as NOPs on
hardware that doesn't, we can just replace them without breaking
anything. As PACIASP/AUTIASP are guaranteed to be paired with respect to
manipulations of the return address, replacing them 1:1 with shadow call
stack pushes and pops is guaranteed to result in the desired behavior.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20221027155908.1940624-4-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

(cherry picked from commit 3b619e22c4)
Bug: 283954062
Change-Id: Idca66f03315191a9fb18ed17d5b79c5bfacc51b8
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2023-05-25 16:09:30 -07:00
Ard Biesheuvel
ee09e21c01 UPSTREAM: scs: add support for dynamic shadow call stacks
In order to allow arches to use code patching to conditionally emit the
shadow stack pushes and pops, rather than always taking the performance
hit even on CPUs that implement alternatives such as stack pointer
authentication on arm64, add a Kconfig symbol that can be set by the
arch to omit the SCS codegen itself, without otherwise affecting how
support code for SCS and compiler options (for register reservation, for
instance) are emitted.

Also, add a static key and some plumbing to omit the allocation of
shadow call stack for dynamic SCS configurations if SCS is disabled at
runtime.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20221027155908.1940624-3-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

(cherry picked from commit 9beccca098)
Bug: 283954062
Change-Id: I71ed23533124b071bd6bf5ab91b2af3bbf03b42b
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2023-05-25 16:09:30 -07:00
Ard Biesheuvel
6ec9ba5f69 BACKPORT: arm64: unwind: add asynchronous unwind tables to kernel and modules
Enable asynchronous unwind table generation for both the core kernel as
well as modules, and emit the resulting .eh_frame sections as init code
so we can use the unwind directives for code patching at boot or module
load time.

This will be used by dynamic shadow call stack support, which will rely
on code patching rather than compiler codegen to emit the shadow call
stack push and pop instructions.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20221027155908.1940624-2-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

(cherry picked from commit 68c76ad4a9)
Bug: 283954062
Change-Id: I2e17c7171295dc3859ff385b11a10048f6c87ec5
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2023-05-25 16:09:29 -07:00
Vincent Palomares
24cc65e890 ANDROID: GKI: Expose device async to userspace
Setting CONFIG_PM_ADVANCED_DEBUG=y to expose device async fields
to userspace, allowing to fine-tune the suspend/resume path.

Bug: 235135485
Change-Id: I75060e88ce0c1e199aa8740f446a2c0f8167f3d7
Signed-off-by: Vincent Palomares <paillon@google.com>
2023-05-25 20:29:49 +00:00
Bart Van Assche
c80190b43d ANDROID: scsi: core: Only kick the requeue list if necessary
Instead of running the request queue of each device associated with a
host every 3 ms (BLK_MQ_RESOURCE_DELAY) while host error handling is in
progress, run the request queue after error handling has finished.

Bug: 280478861
Change-Id: Icd06853dc4868778bc7942d7fac6de71a7a80f71
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
1845d499bd ANDROID: scsi: Trace SCSI sense data
Make the SCSI sense data available in the ftrace output.

Bug: 275581839
Change-Id: I0fc87346effe71940a450d3a114365029d851b77
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
99be857cfd ANDROID: block: mq-deadline: Restore npo2 zone size support
Patch "block: mq-deadline: Handle requeued requests correctly" broke
support for zone sizes that are not a power of two. Restore support for
zone sizes that are not a power of two.

Bug: 275581839
Change-Id: I05d1b3253247f21583891502291e4a861bebb15e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
88819308f5 ANDROID: block: Warn if a zoned write is about to be reordered
Make it easier to debug out-of-order zoned writes.

Bug: 275581839
Change-Id: I5d1f1cd47ff1b4c10788edeebba5e80bd82b2bf3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
5d90f7cbaf ANDROID: block: Preserve the order of requeued requests
If a queue is run before all requeued requests have been sent to the I/O
scheduler, the I/O scheduler may dispatch the wrong request. Fix this by
making __blk_mq_run_hw_queue() process the requeue_list instead of
blk_mq_requeue_work().

Bug: 275581839
Change-Id: Id72c0787607f90857ae8e75998d532b96b46b8c2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
a08e170d90 ANDROID: block: Requeue requests if a CPU is unplugged
Requeue requests instead of sending these to the dispatch list if a CPU
is unplugged to prevent reordering of zoned writes.

Bug: 275581839
Change-Id: I2f03ba0832fc9609472c2bfa19d2cdd8abeffd8d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
9102217567 ANDROID: block: Send requeued requests to the I/O scheduler
Make sure that the I/O scheduler has control over which requests are
dispatched.

Bug: 275581839
Change-Id: If8c70df11584b023c452fbba28c67b092ddac850
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
cd4d66e62b ANDROID: block: Send FUA requests to the I/O scheduler
Send requests with the REQ_FUA or REQ_PREFLUSH flag set to the I/O
scheduler. Do not change the behavior for REQ_OP_FLUSH requests.
This patch prevents that zoned writes with the REQ_FUA and/or
REQ_PREFLUSH flag set are reordered against each other.

Bug: 275581839
Change-Id: Ib7f18932a066c40f5b76dc69c1864a080350251d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
0545a08098 ANDROID: block: Simplify blk_mq_sched_bypass_insert()
Combine two return statements into a single return statement.

Bug: 275581839
Change-Id: I543e3dad88766157c0c334def4d525c10334e476
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
Bart Van Assche
4c21e16028 ANDROID: block: Remove a blk_mq_sched_bypass_insert() argument
Remove the 'hctx' argument because it is not used.

Bug: 275581839
Change-Id: I1f632931bc6c3d1ad89c4e6e93417c7301699559
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-25 17:44:43 +00:00
davidwang
443ff5cf3b ANDROID: vendor_hooks: add vendor hook for dma_heap_buffer_alloc
Add android_vh_dmabuf_heap_flags_validation vh for
heap flags with vendor valid check.

Bug: 241733930
Signed-off-by: davidwang <davidwang@realtek.com>
Change-Id: I5c1c111b8231a05f733bc56bda34bc408e708554
(cherry picked from commit fc9630b3cb24f5c0dd111cb49b462268a343f66c)
2023-05-25 02:12:13 +00:00
Carlos Llamas
2c8747d414 ANDROID: 5/24/2023 KMI update
Set KMI_GENERATION=7 for 5/24 KMI update

type 'struct binder_transaction' changed
  byte size changed from 176 to 192
  member 'pid_t from_pid' was added
  member 'pid_t from_tid' was added
  13 members ('struct binder_transaction* from_parent' .. 'kuid_t sender_euid') changed
    offset changed by 64
  member 'ktime_t start_time' was added
  4 members ('struct list_head fd_fixups' .. 'u64 android_vendor_data1') changed
    offset changed by 128

Bug: 283322303
Change-Id: Ic9eaacc3707e86614dfb9fc6abde30ba722ed3bf
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-24 14:39:37 +00:00
Chuang Zhang
99027afdd1 FROMGIT: Binder: Add async from to transaction record
This commit adds support for getting the pid and tid information of
the sender for asynchronous transfers in binderfs transfer records.
In previous versions, it was not possible to obtain this information
from the transfer records. While this information may not be necessary
for all use cases, it can be useful in some scenarios.

Signed-off-by: Chuang Zhang <zhangchuang3@xiaomi.com>
Acked-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/0c1e8bd37c68dd1518bb737b06b768cde9659386.1682333709.git.zhangchuang3@xiaomi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 235773151
(cherry picked from commit c21c0f9a20
 git: //git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 char-misc-next)
Change-Id: I7e729853353522164c4a3dd1094145dfd19af961
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-24 13:53:29 +00:00
Chuang Zhang
5d4d5dbeab BACKPORT: FROMGIT: Binder: Add timestamp to transaction record
This patch adds a timestamp field to the binder_transaction
structure to track the time consumed during transmission
when reading binder_transaction records.

Signed-off-by: Chuang Zhang <zhangchuang3@xiaomi.com>
Acked-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/5ac8c0d09392290be789423f0dd78a520b830fab.1682333709.git.zhangchuang3@xiaomi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 235773151
(cherry picked from commit 800936191a
 git: //git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 char-misc-next)
[cmllamas: resolved minor conflicts with local patches]
Change-Id: If6dab2e9b80c71f9ac3084dc8cf0e519976f55d8
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-24 13:53:29 +00:00
Nick Desaulniers
9e8b2d8ee2 Revert "ANDROID: gki_config: use DWARFv5 rather than DWARFv4"
This reverts commit ad2bd67e07.

Qualcomm is reporting that internal debugging tools in addition to
Lauterbach Trace32 (T32) debugger (vLT_20230509_159359) are having
issues with DWARFv5.

Since the change to the DWARF debug info format was made after the
Android Feature Complete deadline, revert it from android14-* kernel
branches. We'll leave DWARFv5 for android-mainline and try again next
release in android15-*.

Bug: 281863640
Reported-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com>
Change-Id: I5a1657bdf6785d23f3492dc12e6f3df0954b8deb
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2023-05-24 13:53:29 +00:00
Tudor Ambarus
6c4ed97791 UPSTREAM: ext4: avoid a potential slab-out-of-bounds in ext4_group_desc_csum
commit 4f04351888 upstream.

When modifying the block device while it is mounted by the filesystem,
syzbot reported the following:

BUG: KASAN: slab-out-of-bounds in crc16+0x206/0x280 lib/crc16.c:58
Read of size 1 at addr ffff888075f5c0a8 by task syz-executor.2/15586

CPU: 1 PID: 15586 Comm: syz-executor.2 Not tainted 6.2.0-rc5-syzkaller-00205-gc96618275234 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106
 print_address_description+0x74/0x340 mm/kasan/report.c:306
 print_report+0x107/0x1f0 mm/kasan/report.c:417
 kasan_report+0xcd/0x100 mm/kasan/report.c:517
 crc16+0x206/0x280 lib/crc16.c:58
 ext4_group_desc_csum+0x81b/0xb20 fs/ext4/super.c:3187
 ext4_group_desc_csum_set+0x195/0x230 fs/ext4/super.c:3210
 ext4_mb_clear_bb fs/ext4/mballoc.c:6027 [inline]
 ext4_free_blocks+0x191a/0x2810 fs/ext4/mballoc.c:6173
 ext4_remove_blocks fs/ext4/extents.c:2527 [inline]
 ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
 ext4_ext_remove_space+0x24ef/0x46a0 fs/ext4/extents.c:2958
 ext4_ext_truncate+0x177/0x220 fs/ext4/extents.c:4416
 ext4_truncate+0xa6a/0xea0 fs/ext4/inode.c:4342
 ext4_setattr+0x10c8/0x1930 fs/ext4/inode.c:5622
 notify_change+0xe50/0x1100 fs/attr.c:482
 do_truncate+0x200/0x2f0 fs/open.c:65
 handle_truncate fs/namei.c:3216 [inline]
 do_open fs/namei.c:3561 [inline]
 path_openat+0x272b/0x2dd0 fs/namei.c:3714
 do_filp_open+0x264/0x4f0 fs/namei.c:3741
 do_sys_openat2+0x124/0x4e0 fs/open.c:1310
 do_sys_open fs/open.c:1326 [inline]
 __do_sys_creat fs/open.c:1402 [inline]
 __se_sys_creat fs/open.c:1396 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1396
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f72f8a8c0c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f72f97e3168 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f72f8bac050 RCX: 00007f72f8a8c0c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000280
RBP: 00007f72f8ae7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd165348bf R14: 00007f72f97e3300 R15: 0000000000022000

Replace
	le16_to_cpu(sbi->s_es->s_desc_size)
with
	sbi->s_desc_size

It reduces ext4's compiled text size, and makes the code more efficient
(we remove an extra indirect reference and a potential byte
swap on big endian systems), and there is no downside. It also avoids the
potential KASAN / syzkaller failure, as a bonus.

Reported-by: syzbot+fc51227e7100c9294894@syzkaller.appspotmail.com
Reported-by: syzbot+8785e41224a3afd04321@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=70d28d11ab14bd7938f3e088365252aa923cff42
Link: https://syzkaller.appspot.com/bug?id=b85721b38583ecc6b5e72ff524c67302abbc30f3
Link: https://lore.kernel.org/all/000000000000ece18705f3b20934@google.com/
Fixes: 717d50e497 ("Ext4: Uninitialized Block Groups")
Cc: stable@vger.kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20230504121525.3275886-1-tudor.ambarus@linaro.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 269155298
Bug: 270466805
Change-Id: Id14192ab0905c36e154d07d461afb56af7b61488
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
2023-05-24 06:37:40 +00:00
Kajetan Puchalski
0764d6d2f5 BACKPORT: cpuidle: teo: Introduce util-awareness
Modern interactive systems, such as recent Android phones, tend to have
power efficient shallow idle states. Selecting deeper idle states on a
device while a latency-sensitive workload is running can adversely
impact performance due to increased latency. Additionally, if the CPU
wakes up from a deeper sleep before its target residency as is often the
case, it results in a waste of energy on top of that.

At the moment, none of the available idle governors take any scheduling
information into account. They also tend to overestimate the idle
duration quite often, which causes them to select excessively deep idle
states, thus leading to increased wakeup latency and lower performance
with no power saving. For 'menu' while web browsing on Android for
instance, those types of wakeups ('too deep') account for over 24% of
all wakeups.

At the same time, on some platforms idle state 0 can be power efficient
enough to warrant wanting to prefer it over idle state 1. This is
because the power usage of the two states can be so close that
sufficient amounts of too deep state 1 sleeps can completely offset the
state 1 power saving to the point where it would've been more power
efficient to just use state 0 instead. This is, of course, for systems
where state 0 is not a polling state, such as arm-based devices.

Sleeps that happened in state 0 while they could have used state 1 ('too
shallow') only save less power than they otherwise could have. Too deep
sleeps, on the other hand, harm performance and nullify the potential
power saving from using state 1 in the first place. While taking this
into account, it is clear that on balance it is preferable for an idle
governor to have more too shallow sleeps instead of more too deep sleeps
on those kinds of platforms.

This patch specifically tunes TEO to prefer shallower idle states in
order to reduce wakeup latency and achieve better performance.

To this end, before selecting the next idle state it uses the avg_util
signal of a CPU's runqueue in order to determine to what extent the CPU
is being utilized. This util value is then compared to a threshold
defined as a percentage of the CPU's capacity (capacity >> 6 ie. ~1.5%
in the current implementation). If the util is above the threshold, the
index of the idle state selected by TEO metrics will be reduced by 1,
thus selecting a shallower state. If the util is below the threshold,
the governor defaults to the TEO metrics mechanism to try to select the
deepest available idle state based on the closest timer event and its
own correctness.

The main goal of this is to reduce latency and increase performance for
some workloads. Under some workloads it will result in an increase in
power usage (Geekbench 5) while for other workloads it will also result
in a decrease in power usage compared to TEO (PCMark Web, Jankbench,
Speedometer).

It can provide drastically decreased latency and performance benefits in
certain types of workloads that are sensitive to latency.

Example test results:

1. GB5 (better score, latency & more power usage)

| metric                                | menu           | teo               | teo-util-aware    |
| ------------------------------------- | -------------- | ----------------- | ----------------- |
| gmean score                           | 2826.5 (0.0%)  | 2764.8 (-2.18%)   | 2865 (1.36%)      |
| gmean power usage [mW]                | 2551.4 (0.0%)  | 2606.8 (2.17%)    | 2722.3 (6.7%)     |
| gmean too deep %                      | 14.99%         | 9.65%             | 4.02%             |
| gmean too shallow %                   | 2.5%           | 5.96%             | 14.59%            |
| gmean task wakeup latency (asynctask) | 78.16μs (0.0%) | 61.60μs (-21.19%) | 54.45μs (-30.34%) |

2. Jankbench (better score, latency & less power usage)

| metric                                | menu           | teo               | teo-util-aware    |
| ------------------------------------- | -------------- | ----------------- | ----------------- |
| gmean frame duration                  | 13.9 (0.0%)    | 14.7 (6.0%)       | 12.6 (-9.0%)      |
| gmean jank percentage                 | 1.5 (0.0%)     | 2.1 (36.99%)      | 1.3 (-17.37%)     |
| gmean power usage [mW]                | 144.6 (0.0%)   | 136.9 (-5.27%)    | 121.3 (-16.08%)   |
| gmean too deep %                      | 26.00%         | 11.00%            | 2.54%             |
| gmean too shallow %                   | 4.74%          | 11.89%            | 21.93%            |
| gmean wakeup latency (RenderThread)   | 139.5μs (0.0%) | 116.5μs (-16.49%) | 91.11μs (-34.7%)  |
| gmean wakeup latency (surfaceflinger) | 124.0μs (0.0%) | 151.9μs (22.47%)  | 87.65μs (-29.33%) |

Bug: 258723112
Change-Id: Ifea46051fb4b0554349aa50145130e38efa5f163
Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
[ rjw: Comment edits and white space adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 9ce0f7c4bc)
[Build error due to different signature of sched_cpu_util()]
Signed-off-by: Qais Yousef <qyousef@google.com>
2023-05-23 22:11:47 +00:00
Kajetan Puchalski
d52ad10640 UPSTREAM: cpuidle: teo: Optionally skip polling states in teo_find_shallower_state()
Add a no_poll flag to teo_find_shallower_state() that will let the
function optionally not consider polling states.

This allows the caller to guard against the function inadvertently
resulting in TEO putting the CPU in a polling state when that
behaviour is undesirable.

Bug: 258723112
Change-Id: Ic3879fd4428dd4c7b19caaee6f9fd847cdb58483
Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 27f8508801)
Signed-off-by: Qais Yousef <qyousef@google.com>
2023-05-23 22:11:47 +00:00
Qais Yousef
d9a7607f56 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_vh_uclamp_validate
  - __tracepoint_android_vh_uclamp_validate

Bug: 283761535
Change-Id: I74fdbf3162ba5b64696b5ac708e0c429e5a41fd9
Signed-off-by: Qais Yousef <qyousef@google.com>
2023-05-23 20:40:47 +00:00
Qais Yousef
10bca2e53c ANDROID: Add new hook to enable overriding uclamp_validate()
We want to add more special values, specifically for uclamp_max so that
it can be set automatically to the most efficient value based on the
core it's running on.

Bug: 283761535
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I57343c4544f6cac621c855cbb94de0b8d80c51fa
2023-05-23 20:40:47 +00:00
Mostafa Saleh
01ec18c52f ANDROID: KVM: arm64: iommu: Erase pvmfw from EL1 if possible
Kernel IOMMU drivers can report system misconfiguration through
pkvm_iommu_finalize().
Then EL2 can take the proper response, for example if there are missing
IOMMUs, and DMA isolation can't be ensured, it would clear pvmfw so
PVMs can't be launched.
However, this is not clean as userspace can still query pvmfw info
and launch PVMs that loops in undefined instruction aborts as pvmfw
is cleared.
To fix this, before deprivilege, the kernel will erase pvmfw if the
IOMMUs are not finalised.

Bug: 268607700
Test: Launch PVM with missing S2MPU => Fail immediately with -8
Test: Launch PVM with all S2MPU => Pass
Change-Id: I9fd2440805f6b2f2ad4395ce61df5b272ed84fef
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-05-23 13:36:51 +00:00
Bart Van Assche
c44534436f BACKPORT: FROMGIT: block: BFQ: Add several invariant checks
If anything goes wrong with the counters that track the number of
requests, I/O locks up. Make such scenarios easier to debug by adding
invariant checks for the request counters. Additionally, check that
BFQ queues are empty before these are freed.

Cc: Jan Kara <jack@suse.cz>
Cc: Yu Kuai <yukuai3@huawei.com>
Change-Id: I566e972e4c9c5c3e8bb256e6be39f5bb6bec7256
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230516223853.1385255-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 3e49c1e4a6 https://git.kernel.dk/cgit/linux/)
[ bvanassche: backported to kernel v5.15 ]
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
5db3a9fa14 FROMGIT: block: mq-deadline: Fix handling of at-head zoned writes
Before dispatching a zoned write from the FIFO list, check whether there
are any zoned writes in the RB-tree with a lower LBA for the same zone.
This patch ensures that zoned writes happen in order even if at_head is
set for some writes for a zone and not for others.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: I51a3faf0f2dbca7f860cb7fdc103d077a6a97d0a
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230517174230.897144-12-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit a036e698c2 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
499e313515 FROMGIT: block: mq-deadline: Handle requeued requests correctly
Start dispatching from the start of a zone instead of from the starting
position of the most recently dispatched request.

If a zoned write is requeued with an LBA that is lower than already
inserted zoned writes, make sure that it is submitted first.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: I7920302d8996d366efe251805005f9e7170044bb
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230517174230.897144-11-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 0effb390c4 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
2b9a4dc9df FROMGIT: block: mq-deadline: Track the dispatch position
Track the position (sector_t) of the most recently dispatched request
instead of tracking a pointer to the next request to dispatch. This
patch is the basis for patch "Handle requeued requests correctly".
Without this patch it would be significantly more complicated to make
sure that zoned writes are dispatched in LBA order per zone.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: I7ea38c43ae4e80b3a2257b631b58754c60aff4df
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230517174230.897144-10-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 83c46ed675 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
1d129b2b1b BACKPORT: FROMGIT: block: mq-deadline: Reduce lock contention
blk_mq_free_requests() calls dd_finish_request() indirectly. Prevent
nested locking of dd->lock and dd->zone_lock by moving the code for
freeing requests.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: Ib5709f236308f229e35da690ab4cad25f3fcf94d
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230517174230.897144-9-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit b2097bd24b https://git.kernel.dk/cgit/linux/)
[ bvanassche: resolved cherry-picking conflicts ]
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
9a3b2e6468 FROMGIT: block: mq-deadline: Simplify deadline_skip_seq_writes()
Make the deadline_skip_seq_writes() code shorter without changing its
functionality.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: I3d6fa65ccf9af3bc54742acf2ca2a67bd6b13dc1
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230517174230.897144-8-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 3b463cbea9 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
0d84365099 FROMGIT: block: mq-deadline: Clean up deadline_check_fifo()
Change the return type of deadline_check_fifo() from 'int' into 'bool'.
Use time_is_before_eq_jiffies() instead of time_after_eq(). No
functionality has been changed.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Ming Lei <ming.lei@redhat.com>
Change-Id: Ie1ace1db1f1c78246fee60cd9a301cf0d6ad1f89
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230517174230.897144-7-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit e0d85cde95 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
435b2eda27 FROMGIT: block: mq-deadline: Add a word in a source code comment
Add the missing word "and".

Cc: Damien Le Moal <dlemoal@kernel.org>
Suggested-by: Damien Le Moal <dlemoal@kernel.org>
Fixes: 945ffb60c1 ("mq-deadline: add blk-mq adaptation of the deadline IO scheduler")
Change-Id: Ic8e16b13886815418a7d60d310a040ce48d5ebe7
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230517174230.897144-2-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Bug: 275581839
(cherry picked from commit 45b46b6f15 https://git.kernel.dk/cgit/linux/)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00
Bart Van Assche
57f7c5ce85 ANDROID: block: Rename blk_rq_is_seq_zone_write()
Rename this function to align the function name with the function name
used in the upstream Linux kernel.

Bug: 275581839
Change-Id: I085ffacf535e65d8afbb9935a2cca26c4fec0d80
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-19 23:13:26 +00:00