Commit Graph

1068409 Commits

Author SHA1 Message Date
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
Vincent Whitchurch
f15bd09d1e BACKPORT: squashfs: cache partial compressed blocks
Before commit 93e72b3c61 ("squashfs: migrate from ll_rw_block
usage to BIO"), compressed blocks read by squashfs were cached in the page
cache, but that is not the case after that commit.  That has lead to
squashfs having to re-read a lot of sectors from disk/flash.

For example, the first sectors of every metadata block need to be read
twice from the disk.  Once partially to read the length, and a second time
to read the block itself.  Also, in linear reads of large files, the last
sectors of one data block are re-read from disk when reading the next data
block, since the compressed blocks are of variable sizes and not aligned
to device blocks.  This extra I/O results in a degrade in read performance
of, for example, ~16% in one scenario on my ARM platform using squashfs
with dm-verity and NAND.

Since the decompressed data is cached in the page cache or squashfs'
internal metadata and fragment caches, caching _all_ compressed pages
would lead to a lot of double caching and is undesirable.  But make the
code cache any disk blocks which were only partially requested, since
these are the ones likely to include data which is needed by other file
system blocks.  This restores read performance in my test scenario.

The compressed block caching is only applied when the disk block size is
equal to the page size, to avoid having to deal with caching sub-page
reads.

[akpm@linux-foundation.org: fs/squashfs/block.c needs linux/pagemap.h]
[vincent.whitchurch@axis.com: fix page update race]
  Link: https://lkml.kernel.org/r/20230526-squashfs-cache-fixup-v1-1-d54a7fa23e7b@axis.com
[vincent.whitchurch@axis.com: fix page indices]
  Link: https://lkml.kernel.org/r/20230526-squashfs-cache-fixup-v1-2-d54a7fa23e7b@axis.com
[akpm@linux-foundation.org: fix layout, per hch]
Link: https://lkml.kernel.org/r/20230510-squashfs-cache-v4-1-3bd394e1ee71@axis.com
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
[block.c: bio_alloc_clone() -> bio_clone_fast()]
(cherry picked from commit e994f5b677)
Change-Id: I34f6478501c0da6b8f67af4e6d173040a486f5a5
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
9d4be29185 UPSTREAM: squashfs: fix buffer release race condition in readahead code
Fix a buffer release race condition, where the error value was used after
release.

Link: https://lkml.kernel.org/r/20221020223616.7571-4-phillip@squashfs.org.uk
Fixes: b09a7a036d ("squashfs: support reading fragments in readahead call")
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Reported-by: Marc Miltenberger <marcmiltenberger@gmail.com>
Cc: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Cc: Slade Watkins <srw@sladewatkins.net>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit e11c4e088b)
Change-Id: I9afd4abbfd8a50910670ba7a327aa0d825856560
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
813c3dec23 UPSTREAM: squashfs: fix extending readahead beyond end of file
The readahead code will try to extend readahead to the entire size of the
Squashfs data block.

But, it didn't take into account that the last block at the end of the
file may not be a whole block.  In this case, the code would extend
readahead to beyond the end of the file, leaving trailing pages.

Fix this by only requesting the expected number of pages.

Link: https://lkml.kernel.org/r/20221020223616.7571-3-phillip@squashfs.org.uk
Fixes: 8fc78b6fe2 ("squashfs: implement readahead")
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Reported-by: Marc Miltenberger <marcmiltenberger@gmail.com>
Cc: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Cc: Slade Watkins <srw@sladewatkins.net>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: <stable@vger.kernel.org>

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit c9199de82b)
Change-Id: Ic2d449471ab6caa8acbde2eba48b781d47ad0e2a
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
dec4ef3ce4 UPSTREAM: squashfs: fix read regression introduced in readahead code
Patch series "squashfs: fix some regressions introduced in the readahead
code".

This patchset fixes 3 regressions introduced by the recent readahead code
changes.  The first regression is causing "snaps" to randomly fail after a
couple of hours or days, which how the regression came to light.

This patch (of 3):

If a file isn't a whole multiple of the page size, the last page will have
trailing bytes unfilled.

There was a mistake in the readahead code which did this.  In particular
it incorrectly assumed that the last page in the readahead page array
(page[nr_pages - 1]) will always contain the last page in the block, which
if we're at file end, will be the page that needs to be zero filled.

But the readahead code may not return the last page in the block, which
means it is unmapped and will be skipped by the decompressors (a temporary
buffer used).

In this case the zero filling code will zero out the wrong page, leading
to data corruption.

Fix this by by extending the "page actor" to return the last page if
present, or NULL if a temporary buffer was used.

Link: https://lkml.kernel.org/r/20221020223616.7571-1-phillip@squashfs.org.uk
Link: https://lkml.kernel.org/r/20221020223616.7571-2-phillip@squashfs.org.uk
Fixes: 8fc78b6fe2 ("squashfs: implement readahead")
Link: https://lore.kernel.org/lkml/b0c258c3-6dcf-aade-efc4-d62a8b3a1ce2@alu.unizg.hr/
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Slade Watkins <srw@sladewatkins.net>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Reported-by: Marc Miltenberger <marcmiltenberger@gmail.com>
Cc: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit 9ef8eb6104)
Change-Id: I5394dbd6807da65b99713c3540d0563d828bda95
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
80e656926e UPSTREAM: squashfs: don't call kmalloc in decompressors
The decompressors may be called while in an atomic section.  So move the
kmalloc() out of this path, and into the "page actor" init function.

This fixes a regression introduced by commit
f268eedddf ("squashfs: extend "page actor" to handle missing pages")

Link: https://lkml.kernel.org/r/20220822215430.15933-1-phillip@squashfs.org.uk
Fixes: f268eedddf ("squashfs: extend "page actor" to handle missing pages")
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit 1f13dff09f)
Change-Id: I1363aff27964ab2c7753630e5b7501dc9db8bb00
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
401371c174 UPSTREAM: squashfs: don't use intermediate buffer if pages missing
Now that the "page actor" can handle missing pages, we don't have to fall
back to using an intermediate buffer in Squashfs_readpage_block() if all
the pages necessary can't be obtained.

Link: https://lkml.kernel.org/r/20220611032133.5743-3-phillip@squashfs.org.uk
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Xiongwei Song <Xiongwei.Song@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 290900323
(cherry picked from commit 1bb1a07afa)
Change-Id: Ie16c3e4adab0066680f070a6af2a7a21e99be50d
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
2023-07-19 10:02:33 +00:00
Phillip Lougher
c7f85bb4c4 UPSTREAM: squashfs: extend "page actor" to handle missing pages
Patch series "Squashfs: handle missing pages decompressing into page
cache".

This patchset enables Squashfs to handle missing pages when directly
decompressing datablocks into the page cache.

Previously if the full set of pages needed was not available, Squashfs
would have to fall back to using an intermediate buffer (the older
method), which is slower, involving a memcopy, and it introduces
contention on a shared buffer.

The first patch extends the "page actor" code to handle missing pages.

The second patch updates Squashfs_readpage_block() to use the new
functionality, and removes the code that falls back to using an
intermediate buffer.

This patchset is independent of the readahead work, and it is standalone.
It can be merged on its own.

But the readahead patch for efficiency also needs this patch-set.

This patch (of 2):

This patch extends the "page actor" code to handle missing pages.

Previously if the full set of pages needed to decompress a Squashfs
datablock was unavailable, this would cause decompression to fail on the
missing pages.

In this case direct decompression into the page cache could not be
achieved and the code would fall back to using the older intermediate
buffer method.

With this patch, direct decompression into the page cache can be achieved
with missing pages.

For "multi-shot" decompressors (zlib, xz, zstd), the page actor will
allocate a temporary buffer which is passed to the decompressor, and then
freed by the page actor.

For "single shot" decompressors (lz4, lzo) which decompress into a
contiguous "bounce buffer", and which is then copied into the page cache,
it would be pointless to allocate a temporary buffer, memcpy into it, and
then free it.  For these decompressors -ENOMEM is returned, which
signifies that the memcpy for that page should be skipped.

This also happens if the data block is uncompressed.

Link: https://lkml.kernel.org/r/20220611032133.5743-1-phillip@squashfs.org.uk
Link: https://lkml.kernel.org/r/20220611032133.5743-2-phillip@squashfs.org.uk
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Xiongwei Song <Xiongwei.Song@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

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