Files
android_kernel_fxtec_sm6115/include/linux
Igor Pylypiv a0c66ac8b7 Revert "module, async: async_synchronize_full() on module init iff async is used"
[ Upstream commit 67d6212afda218d564890d1674bab28e8612170f ]

This reverts commit 774a1221e8.

We need to finish all async code before the module init sequence is
done.  In the reverted commit the PF_USED_ASYNC flag was added to mark a
thread that called async_schedule().  Then the PF_USED_ASYNC flag was
used to determine whether or not async_synchronize_full() needs to be
invoked.  This works when modprobe thread is calling async_schedule(),
but it does not work if module dispatches init code to a worker thread
which then calls async_schedule().

For example, PCI driver probing is invoked from a worker thread based on
a node where device is attached:

	if (cpu < nr_cpu_ids)
		error = work_on_cpu(cpu, local_pci_probe, &ddi);
	else
		error = local_pci_probe(&ddi);

We end up in a situation where a worker thread gets the PF_USED_ASYNC
flag set instead of the modprobe thread.  As a result,
async_synchronize_full() is not invoked and modprobe completes without
waiting for the async code to finish.

The issue was discovered while loading the pm80xx driver:
(scsi_mod.scan=async)

modprobe pm80xx                      worker
...
  do_init_module()
  ...
    pci_call_probe()
      work_on_cpu(local_pci_probe)
                                     local_pci_probe()
                                       pm8001_pci_probe()
                                         scsi_scan_host()
                                           async_schedule()
                                           worker->flags |= PF_USED_ASYNC;
                                     ...
      < return from worker >
  ...
  if (current->flags & PF_USED_ASYNC) <--- false
  	async_synchronize_full();

Commit 21c3c5d280 ("block: don't request module during elevator init")
fixed the deadlock issue which the reverted commit 774a1221e8
("module, async: async_synchronize_full() on module init iff async is
used") tried to fix.

Since commit 0fdff3ec6d ("async, kmod: warn on synchronous
request_module() from async workers") synchronous module loading from
async is not allowed.

Given that the original deadlock issue is fixed and it is no longer
allowed to call synchronous request_module() from async we can remove
PF_USED_ASYNC flag to make module init consistently invoke
async_synchronize_full() unless async module probe is requested.

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Reviewed-by: Changyuan Lyu <changyuanl@google.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-02-23 11:58:38 +01:00
..
2019-12-13 08:51:18 +01:00
2021-04-14 08:22:36 +02:00
2019-10-05 13:10:03 +02:00
2019-07-03 13:14:48 +02:00
2019-11-24 08:19:14 +01:00
2021-12-08 08:50:13 +01:00
2021-12-08 08:50:13 +01:00
2021-01-30 13:32:12 +01:00
2019-10-17 13:45:42 -07:00
2021-05-22 10:59:50 +02:00
2019-12-13 08:52:43 +01:00
2021-03-04 09:39:44 +01:00
2021-02-07 14:48:38 +01:00
2021-11-26 11:35:57 +01:00
2019-12-31 16:35:38 +01:00
2021-07-11 12:49:26 +02:00
2020-07-29 10:16:52 +02:00
2021-06-30 08:48:18 -04:00
2021-09-03 09:58:00 +02:00
2020-03-18 07:14:17 +01:00
2019-06-11 12:20:52 +02:00
2021-12-14 10:18:04 +01:00
2020-04-02 15:28:22 +02:00
2018-11-13 11:08:51 -08:00
2020-12-11 13:25:01 +01:00
2020-04-02 15:28:23 +02:00
2021-12-14 10:18:06 +01:00