OpenCloudOS-Kernel/drivers/base/firmware_loader
Fabio M. De Francesco f2d57765b7 firmware_loader: Replace kmap() with kmap_local_page()
The use of kmap() is being deprecated in favor of kmap_local_page().

Two main problems with kmap(): (1) It comes with an overhead as mapping
space is restricted and protected by a global lock for synchronization and
(2) kmap() also requires global TLB invalidation when the kmap’s pool
wraps and it might block when the mapping space is fully utilized until a
slot becomes available.

kmap_local_page() is preferred over kmap() and kmap_atomic(). Where it
cannot mechanically replace the latters, code refactor should be considered
(special care must be taken if kernel virtual addresses are aliases in
different contexts).

With kmap_local_page() the mappings are per thread, CPU local, can take
page faults, and can be called from any context (including interrupts).

Call kmap_local_page() in firmware_loader wherever kmap() is currently
used. In firmware_rw() use the helpers copy_{from,to}_page() instead of
open coding the local mappings + memcpy().

Successfully tested with "firmware" selftests on a QEMU/KVM 32-bits VM
with 4GB RAM, booting a kernel with HIGHMEM64GB enabled.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20220714235030.12732-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-28 16:32:56 +02:00
..
builtin kbuild: do not quote string values in include/config/auto.conf 2022-01-08 18:03:57 +09:00
Kconfig firmware_loader: enable XZ by default if compressed support is enabled 2022-06-03 15:46:03 -07:00
Makefile firmware_loader: Add firmware-upload support 2022-04-26 12:34:28 +02:00
fallback.c firmware_loader: Split sysfs support from fallback 2022-04-26 12:34:09 +02:00
fallback.h firmware_loader: Split sysfs support from fallback 2022-04-26 12:34:09 +02:00
fallback_platform.c firmware: Store opt_flags in fw_priv 2020-10-05 13:37:04 +02:00
fallback_table.c firmware_loader: move firmware sysctl to its own files 2022-01-22 08:33:35 +02:00
firmware.h firmware_loader: Add firmware-upload support 2022-04-26 12:34:28 +02:00
main.c firmware_loader: Replace kmap() with kmap_local_page() 2022-07-28 16:32:56 +02:00
sysfs.c firmware_loader: Replace kmap() with kmap_local_page() 2022-07-28 16:32:56 +02:00
sysfs.h firmware_loader: Move definitions from sysfs_upload.h to sysfs.h 2022-04-29 16:49:44 +02:00
sysfs_upload.c firmware_loader: describe 'module' parameter of firmware_upload_register() 2022-05-03 15:11:34 +02:00
sysfs_upload.h firmware_loader: Move definitions from sysfs_upload.h to sysfs.h 2022-04-29 16:49:44 +02:00