mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 17:45:12 +07:00
e4c2c0ff00
In some cases the platform's main firmware (e.g. the UEFI fw) may contain an embedded copy of device firmware which needs to be (re)loaded into the peripheral. Normally such firmware would be part of linux-firmware, but in some cases this is not feasible, for 2 reasons: 1) The firmware is customized for a specific use-case of the chipset / use with a specific hardware model, so we cannot have a single firmware file for the chipset. E.g. touchscreen controller firmwares are compiled specifically for the hardware model they are used with, as they are calibrated for a specific model digitizer. 2) Despite repeated attempts we have failed to get permission to redistribute the firmware. This is especially a problem with customized firmwares, these get created by the chip vendor for a specific ODM and the copyright may partially belong with the ODM, so the chip vendor cannot give a blanket permission to distribute these. This commit adds a new platform fallback mechanism to the firmware loader which will try to lookup a device fw copy embedded in the platform's main firmware if direct filesystem lookup fails. Drivers which need such embedded fw copies can enable this fallback mechanism by using the new firmware_request_platform() function. Note that for now this is only supported on EFI platforms and even on these platforms firmware_fallback_platform() only works if CONFIG_EFI_EMBEDDED_FIRMWARE is enabled (this gets selected by drivers which need this), in all other cases firmware_fallback_platform() simply always returns -ENOENT. Reported-by: Dave Olsthoorn <dave@bewaar.me> Suggested-by: Peter Jones <pjones@redhat.com> Acked-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20200115163554.101315-5-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
80 lines
2.3 KiB
C
80 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __FIRMWARE_FALLBACK_H
|
|
#define __FIRMWARE_FALLBACK_H
|
|
|
|
#include <linux/firmware.h>
|
|
#include <linux/device.h>
|
|
|
|
#include "firmware.h"
|
|
|
|
/**
|
|
* struct firmware_fallback_config - firmware fallback configuration settings
|
|
*
|
|
* Helps describe and fine tune the fallback mechanism.
|
|
*
|
|
* @force_sysfs_fallback: force the sysfs fallback mechanism to be used
|
|
* as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
|
|
* Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
|
|
* functionality on a kernel where that config entry has been disabled.
|
|
* @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
|
|
* This emulates the behaviour as if we had set the kernel
|
|
* config CONFIG_FW_LOADER_USER_HELPER=n.
|
|
* @old_timeout: for internal use
|
|
* @loading_timeout: the timeout to wait for the fallback mechanism before
|
|
* giving up, in seconds.
|
|
*/
|
|
struct firmware_fallback_config {
|
|
unsigned int force_sysfs_fallback;
|
|
unsigned int ignore_sysfs_fallback;
|
|
int old_timeout;
|
|
int loading_timeout;
|
|
};
|
|
|
|
#ifdef CONFIG_FW_LOADER_USER_HELPER
|
|
int firmware_fallback_sysfs(struct firmware *fw, const char *name,
|
|
struct device *device,
|
|
enum fw_opt opt_flags,
|
|
int ret);
|
|
void kill_pending_fw_fallback_reqs(bool only_kill_custom);
|
|
|
|
void fw_fallback_set_cache_timeout(void);
|
|
void fw_fallback_set_default_timeout(void);
|
|
|
|
int register_sysfs_loader(void);
|
|
void unregister_sysfs_loader(void);
|
|
#else /* CONFIG_FW_LOADER_USER_HELPER */
|
|
static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name,
|
|
struct device *device,
|
|
enum fw_opt opt_flags,
|
|
int ret)
|
|
{
|
|
/* Keep carrying over the same error */
|
|
return ret;
|
|
}
|
|
|
|
static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
|
|
static inline void fw_fallback_set_cache_timeout(void) { }
|
|
static inline void fw_fallback_set_default_timeout(void) { }
|
|
|
|
static inline int register_sysfs_loader(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void unregister_sysfs_loader(void)
|
|
{
|
|
}
|
|
#endif /* CONFIG_FW_LOADER_USER_HELPER */
|
|
|
|
#ifdef CONFIG_EFI_EMBEDDED_FIRMWARE
|
|
int firmware_fallback_platform(struct fw_priv *fw_priv, enum fw_opt opt_flags);
|
|
#else
|
|
static inline int firmware_fallback_platform(struct fw_priv *fw_priv,
|
|
enum fw_opt opt_flags)
|
|
{
|
|
return -ENOENT;
|
|
}
|
|
#endif
|
|
|
|
#endif /* __FIRMWARE_FALLBACK_H */
|