Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) Firmware cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) When Linux resumes from suspend some device drivers require firmware lookups to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) re-initialize devices. During resume there may be a period of time during which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) firmware lookups are not possible, during this short period of time firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) requests will fail. Time is of essence though, and delaying drivers to wait for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) the root filesystem for firmware delays user experience with device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) functionality. In order to support these requirements the firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) infrastructure implements a firmware cache for device drivers for most API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) calls, automatically behind the scenes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) The firmware cache makes using certain firmware API calls safe during a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) driver's suspend and resume callback.  Users of these API calls needn't cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) the firmware by themselves for dealing with firmware loss during system resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) The firmware cache works by requesting for firmware prior to suspend and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) caching it in memory. Upon resume device drivers using the firmware API will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) have access to the firmware immediately, without having to wait for the root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) filesystem to mount or dealing with possible race issues with lookups as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) root filesystem mounts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Some implementation details about the firmware cache setup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * The firmware cache is setup by adding a devres entry for each device that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)   uses all synchronous call except :c:func:`request_firmware_into_buf`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * If an asynchronous call is used the firmware cache is only set up for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)   device if the second argument (uevent) to request_firmware_nowait() is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)   true. When uevent is true it requests that a kobject uevent be sent to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)   userspace for the firmware request through the sysfs fallback mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)   if the firmware file is not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * If the firmware cache is determined to be needed as per the above two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)   criteria the firmware cache is setup by adding a devres entry for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)   device making the firmware request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * The firmware devres entry is maintained throughout the lifetime of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)   device. This means that even if you release_firmware() the firmware cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)   will still be used on resume from suspend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * The timeout for the fallback mechanism is temporarily reduced to 10 seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)   as the firmware cache is set up during suspend, the timeout is set back to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)   the old value you had configured after the cache is set up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Upon suspend any pending non-uevent firmware requests are killed to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)   stalling the kernel, this is done with kill_requests_without_uevent(). Kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)   calls requiring the non-uevent therefore need to implement their own firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)   cache mechanism but must not use the firmware API on suspend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)