• Home
  • Raw
  • Download

Lines Matching +full:firmware +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
3 * main.c - Multi purpose firmware loading support
7 * Please see Documentation/driver-api/firmware/ for more information.
25 #include <linux/firmware.h>
42 #include "firmware.h"
46 MODULE_DESCRIPTION("Multi purpose firmware loading support");
57 * Names of firmware images which have been cached successfully
59 * helper can trace which firmware images have been cached
73 const char *name; member
78 const char *name; member
95 /* Builtin firmware support */
102 static bool fw_copy_to_prealloc_buf(struct firmware *fw, in fw_copy_to_prealloc_buf()
107 if (size < fw->size) in fw_copy_to_prealloc_buf()
109 memcpy(buf, fw->data, fw->size); in fw_copy_to_prealloc_buf()
113 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, in fw_get_builtin_firmware() argument
119 if (strcmp(name, b_fw->name) == 0) { in fw_get_builtin_firmware()
120 fw->size = b_fw->size; in fw_get_builtin_firmware()
121 fw->data = b_fw->data; in fw_get_builtin_firmware()
129 static bool fw_is_builtin_firmware(const struct firmware *fw) in fw_is_builtin_firmware()
134 if (fw->data == b_fw->data) in fw_is_builtin_firmware()
140 #else /* Module case - no builtin firmware support */
142 static inline bool fw_get_builtin_firmware(struct firmware *fw, in fw_get_builtin_firmware()
143 const char *name, void *buf, in fw_get_builtin_firmware() argument
149 static inline bool fw_is_builtin_firmware(const struct firmware *fw) in fw_is_builtin_firmware()
157 struct fw_state *fw_st = &fw_priv->fw_st; in fw_state_init()
159 init_completion(&fw_st->completion); in fw_state_init()
160 fw_st->status = FW_STATUS_UNKNOWN; in fw_state_init()
191 fw_priv->fw_name = kstrdup_const(fw_name, GFP_ATOMIC); in __allocate_fw_priv()
192 if (!fw_priv->fw_name) { in __allocate_fw_priv()
197 kref_init(&fw_priv->ref); in __allocate_fw_priv()
198 fw_priv->fwc = fwc; in __allocate_fw_priv()
199 fw_priv->data = dbuf; in __allocate_fw_priv()
200 fw_priv->allocated_size = size; in __allocate_fw_priv()
201 fw_priv->offset = offset; in __allocate_fw_priv()
202 fw_priv->opt_flags = opt_flags; in __allocate_fw_priv()
205 INIT_LIST_HEAD(&fw_priv->pending_list); in __allocate_fw_priv()
208 pr_debug("%s: fw-%s fw_priv=%p\n", __func__, fw_name, fw_priv); in __allocate_fw_priv()
218 list_for_each_entry(tmp, &fwc->head, list) in __lookup_fw_priv()
219 if (!strcmp(tmp->fw_name, fw_name)) in __lookup_fw_priv()
224 /* Returns 1 for batching firmware requests with the same name */
235 spin_lock(&fwc->lock); in alloc_lookup_fw_priv()
237 * Do not merge requests that are marked to be non-cached or in alloc_lookup_fw_priv()
243 kref_get(&tmp->ref); in alloc_lookup_fw_priv()
244 spin_unlock(&fwc->lock); in alloc_lookup_fw_priv()
246 pr_debug("batched request - sharing the same struct fw_priv and lookup for multiple requests\n"); in alloc_lookup_fw_priv()
253 INIT_LIST_HEAD(&tmp->list); in alloc_lookup_fw_priv()
255 list_add(&tmp->list, &fwc->head); in alloc_lookup_fw_priv()
257 spin_unlock(&fwc->lock); in alloc_lookup_fw_priv()
261 return tmp ? 0 : -ENOMEM; in alloc_lookup_fw_priv()
265 __releases(&fwc->lock) in __free_fw_priv()
268 struct firmware_cache *fwc = fw_priv->fwc; in __free_fw_priv()
270 pr_debug("%s: fw-%s fw_priv=%p data=%p size=%u\n", in __free_fw_priv()
271 __func__, fw_priv->fw_name, fw_priv, fw_priv->data, in __free_fw_priv()
272 (unsigned int)fw_priv->size); in __free_fw_priv()
274 list_del(&fw_priv->list); in __free_fw_priv()
275 spin_unlock(&fwc->lock); in __free_fw_priv()
279 else if (!fw_priv->allocated_size) in __free_fw_priv()
280 vfree(fw_priv->data); in __free_fw_priv()
282 kfree_const(fw_priv->fw_name); in __free_fw_priv()
288 struct firmware_cache *fwc = fw_priv->fwc; in free_fw_priv()
289 spin_lock(&fwc->lock); in free_fw_priv()
290 if (!kref_put(&fw_priv->ref, __free_fw_priv)) in free_fw_priv()
291 spin_unlock(&fwc->lock); in free_fw_priv()
297 return fw_priv->is_paged_buf; in fw_is_paged_buf()
304 if (!fw_priv->pages) in fw_free_paged_buf()
307 vunmap(fw_priv->data); in fw_free_paged_buf()
309 for (i = 0; i < fw_priv->nr_pages; i++) in fw_free_paged_buf()
310 __free_page(fw_priv->pages[i]); in fw_free_paged_buf()
311 kvfree(fw_priv->pages); in fw_free_paged_buf()
312 fw_priv->pages = NULL; in fw_free_paged_buf()
313 fw_priv->page_array_size = 0; in fw_free_paged_buf()
314 fw_priv->nr_pages = 0; in fw_free_paged_buf()
320 if (fw_priv->page_array_size < pages_needed) { in fw_grow_paged_buf()
322 fw_priv->page_array_size * 2); in fw_grow_paged_buf()
328 return -ENOMEM; in fw_grow_paged_buf()
329 memcpy(new_pages, fw_priv->pages, in fw_grow_paged_buf()
330 fw_priv->page_array_size * sizeof(void *)); in fw_grow_paged_buf()
331 memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) * in fw_grow_paged_buf()
332 (new_array_size - fw_priv->page_array_size)); in fw_grow_paged_buf()
333 kvfree(fw_priv->pages); in fw_grow_paged_buf()
334 fw_priv->pages = new_pages; in fw_grow_paged_buf()
335 fw_priv->page_array_size = new_array_size; in fw_grow_paged_buf()
338 while (fw_priv->nr_pages < pages_needed) { in fw_grow_paged_buf()
339 fw_priv->pages[fw_priv->nr_pages] = in fw_grow_paged_buf()
342 if (!fw_priv->pages[fw_priv->nr_pages]) in fw_grow_paged_buf()
343 return -ENOMEM; in fw_grow_paged_buf()
344 fw_priv->nr_pages++; in fw_grow_paged_buf()
353 if (!fw_priv->pages) in fw_map_paged_buf()
356 vunmap(fw_priv->data); in fw_map_paged_buf()
357 fw_priv->data = vmap(fw_priv->pages, fw_priv->nr_pages, 0, in fw_map_paged_buf()
359 if (!fw_priv->data) in fw_map_paged_buf()
360 return -ENOMEM; in fw_map_paged_buf()
367 * XZ-compressed firmware support
375 return xz_ret == XZ_MEM_ERROR ? -ENOMEM : -EINVAL; in fw_decompress_xz_error()
380 /* single-shot decompression onto the pre-allocated buffer */
388 xz_dec = xz_dec_init(XZ_SINGLE, (u32)-1); in fw_decompress_xz_single()
390 return -ENOMEM; in fw_decompress_xz_single()
395 xz_buf.out_size = fw_priv->allocated_size; in fw_decompress_xz_single()
396 xz_buf.out = fw_priv->data; in fw_decompress_xz_single()
402 fw_priv->size = xz_buf.out_pos; in fw_decompress_xz_single()
416 xz_dec = xz_dec_init(XZ_DYNALLOC, (u32)-1); in fw_decompress_xz_pages()
418 return -ENOMEM; in fw_decompress_xz_pages()
424 fw_priv->is_paged_buf = true; in fw_decompress_xz_pages()
425 fw_priv->size = 0; in fw_decompress_xz_pages()
427 if (fw_grow_paged_buf(fw_priv, fw_priv->nr_pages + 1)) { in fw_decompress_xz_pages()
428 err = -ENOMEM; in fw_decompress_xz_pages()
433 page = fw_priv->pages[fw_priv->nr_pages - 1]; in fw_decompress_xz_pages()
439 fw_priv->size += xz_buf.out_pos; in fw_decompress_xz_pages()
457 /* if the buffer is pre-allocated, we can perform in single-shot mode */ in fw_decompress_xz()
458 if (fw_priv->data) in fw_decompress_xz()
465 /* direct firmware loading support */
469 "/lib/firmware/updates/" UTS_RELEASE,
470 "/lib/firmware/updates",
471 "/lib/firmware/" UTS_RELEASE,
472 "/lib/firmware"
481 MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default p…
493 int rc = -ENOENT; in fw_get_filesystem_firmware()
499 if (!decompress && fw_priv->data) { in fw_get_filesystem_firmware()
500 buffer = fw_priv->data; in fw_get_filesystem_firmware()
501 msize = fw_priv->allocated_size; in fw_get_filesystem_firmware()
506 return -ENOMEM; in fw_get_filesystem_firmware()
517 fw_path[i], fw_priv->fw_name, suffix); in fw_get_filesystem_firmware()
519 rc = -ENAMETOOLONG; in fw_get_filesystem_firmware()
523 fw_priv->size = 0; in fw_get_filesystem_firmware()
528 * firmware was not completely loaded. in fw_get_filesystem_firmware()
530 if ((fw_priv->opt_flags & FW_OPT_PARTIAL) && buffer) in fw_get_filesystem_firmware()
533 /* load firmware files from the mount namespace of init */ in fw_get_filesystem_firmware()
534 rc = kernel_read_file_from_path_initns(path, fw_priv->offset, in fw_get_filesystem_firmware()
539 if (rc != -ENOENT) in fw_get_filesystem_firmware()
550 dev_dbg(device, "Loading firmware from %s\n", path); in fw_get_filesystem_firmware()
553 fw_priv->fw_name); in fw_get_filesystem_firmware()
563 dev_dbg(device, "direct-loading %s\n", in fw_get_filesystem_firmware()
564 fw_priv->fw_name); in fw_get_filesystem_firmware()
565 if (!fw_priv->data) in fw_get_filesystem_firmware()
566 fw_priv->data = buffer; in fw_get_filesystem_firmware()
567 fw_priv->size = size; in fw_get_filesystem_firmware()
577 /* firmware holds the ownership of pages */
578 static void firmware_free_data(const struct firmware *fw) in firmware_free_data()
581 if (!fw->priv) { in firmware_free_data()
582 vfree(fw->data); in firmware_free_data()
585 free_fw_priv(fw->priv); in firmware_free_data()
588 /* store the pages buffer info firmware from buf */
589 static void fw_set_page_data(struct fw_priv *fw_priv, struct firmware *fw) in fw_set_page_data()
591 fw->priv = fw_priv; in fw_set_page_data()
592 fw->size = fw_priv->size; in fw_set_page_data()
593 fw->data = fw_priv->data; in fw_set_page_data()
595 pr_debug("%s: fw-%s fw_priv=%p data=%p size=%u\n", in fw_set_page_data()
596 __func__, fw_priv->fw_name, fw_priv, fw_priv->data, in fw_set_page_data()
597 (unsigned int)fw_priv->size); in fw_set_page_data()
605 if (fwn->magic == (unsigned long)&fw_cache) in fw_name_devm_release()
606 pr_debug("%s: fw_name-%s devm-%p released\n", in fw_name_devm_release()
607 __func__, fwn->name, res); in fw_name_devm_release()
608 kfree_const(fwn->name); in fw_name_devm_release()
616 return (fwn->magic == (unsigned long)&fw_cache) && in fw_devm_match()
617 !strcmp(fwn->name, match_data); in fw_devm_match()
621 const char *name) in fw_find_devm_name() argument
626 fw_devm_match, (void *)name); in fw_find_devm_name()
630 static bool fw_cache_is_setup(struct device *dev, const char *name) in fw_cache_is_setup() argument
634 fwn = fw_find_devm_name(dev, name); in fw_cache_is_setup()
641 /* add firmware name into devres list */
642 static int fw_add_devm_name(struct device *dev, const char *name) in fw_add_devm_name() argument
646 if (fw_cache_is_setup(dev, name)) in fw_add_devm_name()
652 return -ENOMEM; in fw_add_devm_name()
653 fwn->name = kstrdup_const(name, GFP_KERNEL); in fw_add_devm_name()
654 if (!fwn->name) { in fw_add_devm_name()
656 return -ENOMEM; in fw_add_devm_name()
659 fwn->magic = (unsigned long)&fw_cache; in fw_add_devm_name()
665 static bool fw_cache_is_setup(struct device *dev, const char *name) in fw_cache_is_setup() argument
670 static int fw_add_devm_name(struct device *dev, const char *name) in fw_add_devm_name() argument
676 int assign_fw(struct firmware *fw, struct device *device) in assign_fw()
678 struct fw_priv *fw_priv = fw->priv; in assign_fw()
682 if (!fw_priv->size || fw_state_is_aborted(fw_priv)) { in assign_fw()
684 return -ENOENT; in assign_fw()
688 * add firmware name into devres list so that we can auto cache in assign_fw()
689 * and uncache firmware for device. in assign_fw()
694 /* don't cache firmware handled without uevent */ in assign_fw()
695 if (device && (fw_priv->opt_flags & FW_OPT_UEVENT) && in assign_fw()
696 !(fw_priv->opt_flags & FW_OPT_NOCACHE)) { in assign_fw()
697 ret = fw_add_devm_name(device, fw_priv->fw_name); in assign_fw()
705 * After caching firmware image is started, let it piggyback in assign_fw()
706 * on request firmware. in assign_fw()
708 if (!(fw_priv->opt_flags & FW_OPT_NOCACHE) && in assign_fw()
709 fw_priv->fwc->state == FW_LOADER_START_CACHE) in assign_fw()
718 /* prepare firmware and firmware_buf structs;
719 * return 0 if a firmware is already assigned, 1 if need to load one,
723 _request_firmware_prepare(struct firmware **firmware_p, const char *name, in _request_firmware_prepare() argument
727 struct firmware *firmware; in _request_firmware_prepare() local
731 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); in _request_firmware_prepare()
732 if (!firmware) { in _request_firmware_prepare()
733 dev_err(device, "%s: kmalloc(struct firmware) failed\n", in _request_firmware_prepare()
735 return -ENOMEM; in _request_firmware_prepare()
738 if (fw_get_builtin_firmware(firmware, name, dbuf, size)) { in _request_firmware_prepare()
739 dev_dbg(device, "using built-in %s\n", name); in _request_firmware_prepare()
743 ret = alloc_lookup_fw_priv(name, &fw_cache, &fw_priv, dbuf, size, in _request_firmware_prepare()
748 * of requesting firmware. in _request_firmware_prepare()
750 firmware->priv = fw_priv; in _request_firmware_prepare()
755 fw_set_page_data(fw_priv, firmware); in _request_firmware_prepare()
774 static void fw_abort_batch_reqs(struct firmware *fw) in fw_abort_batch_reqs()
779 if (!fw || !fw->priv) in fw_abort_batch_reqs()
782 fw_priv = fw->priv; in fw_abort_batch_reqs()
791 _request_firmware(const struct firmware **firmware_p, const char *name, in _request_firmware() argument
795 struct firmware *fw = NULL; in _request_firmware()
802 return -EINVAL; in _request_firmware()
804 if (!name || name[0] == '\0') { in _request_firmware()
805 ret = -EINVAL; in _request_firmware()
809 ret = _request_firmware_prepare(&fw, name, device, buf, size, in _request_firmware()
815 * We are about to try to access the firmware file. Because we may have been in _request_firmware()
821 ret = -ENOMEM; in _request_firmware()
826 ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL); in _request_firmware()
833 if (ret == -ENOENT && nondirect) in _request_firmware()
834 ret = fw_get_filesystem_firmware(device, fw->priv, ".xz", in _request_firmware()
837 if (ret == -ENOENT && nondirect) in _request_firmware()
838 ret = firmware_fallback_platform(fw->priv); in _request_firmware()
843 "Direct firmware load for %s failed with error %d\n", in _request_firmware()
844 name, ret); in _request_firmware()
846 ret = firmware_fallback_sysfs(fw, name, device, in _request_firmware()
866 * request_firmware() - send firmware request and wait for it
867 * @firmware_p: pointer to firmware image
868 * @name: name of firmware file
869 * @device: device for which firmware is being loaded
871 * @firmware_p will be used to return a firmware image by the name
872 * of @name for device @device.
876 * @name will be used as $FIRMWARE in the uevent environment and
878 * firmware image for this or any other device.
886 request_firmware(const struct firmware **firmware_p, const char *name, in request_firmware() argument
893 ret = _request_firmware(firmware_p, name, device, NULL, 0, 0, in request_firmware()
901 * firmware_request_nowarn() - request for an optional fw module
902 * @firmware: pointer to firmware image
903 * @name: name of firmware file
904 * @device: device for which firmware is being loaded
909 * failures to find the firmware file with it are still suppressed. It is
913 int firmware_request_nowarn(const struct firmware **firmware, const char *name, in firmware_request_nowarn() argument
920 ret = _request_firmware(firmware, name, device, NULL, 0, 0, in firmware_request_nowarn()
928 * request_firmware_direct() - load firmware directly without usermode helper
929 * @firmware_p: pointer to firmware image
930 * @name: name of firmware file
931 * @device: device for which firmware is being loaded
934 * fall back to usermode helper even if the firmware couldn't be loaded
938 int request_firmware_direct(const struct firmware **firmware_p, in request_firmware_direct()
939 const char *name, struct device *device) in request_firmware_direct() argument
944 ret = _request_firmware(firmware_p, name, device, NULL, 0, 0, in request_firmware_direct()
953 * firmware_request_platform() - request firmware with platform-fw fallback
954 * @firmware: pointer to firmware image
955 * @name: name of firmware file
956 * @device: device for which firmware is being loaded
960 * requested firmware embedded in the platform's main (e.g. UEFI) firmware.
962 int firmware_request_platform(const struct firmware **firmware, in firmware_request_platform() argument
963 const char *name, struct device *device) in firmware_request_platform() argument
969 ret = _request_firmware(firmware, name, device, NULL, 0, 0, in firmware_request_platform()
977 * firmware_request_cache() - cache firmware for suspend so resume can use it
978 * @name: name of firmware file
979 * @device: device for which firmware should be cached for
982 * require loading firmware on system reboot. This optimization may still
983 * require the firmware present on resume from suspend. This routine can be
984 * used to ensure the firmware is present on resume from suspend in these
988 int firmware_request_cache(struct device *device, const char *name) in firmware_request_cache() argument
993 ret = fw_add_devm_name(device, name); in firmware_request_cache()
1001 * request_firmware_into_buf() - load firmware into a previously allocated buffer
1002 * @firmware_p: pointer to firmware image
1003 * @name: name of firmware file
1004 * @device: device for which firmware is being loaded and DMA region allocated
1005 * @buf: address of buffer to load firmware into
1009 * allocate a buffer to hold the firmware data. Instead, the firmware
1013 * This function doesn't cache firmware either.
1016 request_firmware_into_buf(const struct firmware **firmware_p, const char *name, in request_firmware_into_buf() argument
1021 if (fw_cache_is_setup(device, name)) in request_firmware_into_buf()
1022 return -EOPNOTSUPP; in request_firmware_into_buf()
1025 ret = _request_firmware(firmware_p, name, device, buf, size, 0, in request_firmware_into_buf()
1033 * request_partial_firmware_into_buf() - load partial firmware into a previously allocated buffer
1034 * @firmware_p: pointer to firmware image
1035 * @name: name of firmware file
1036 * @device: device for which firmware is being loaded and DMA region allocated
1037 * @buf: address of buffer to load firmware into
1045 request_partial_firmware_into_buf(const struct firmware **firmware_p, in request_partial_firmware_into_buf()
1046 const char *name, struct device *device, in request_partial_firmware_into_buf() argument
1051 if (fw_cache_is_setup(device, name)) in request_partial_firmware_into_buf()
1052 return -EOPNOTSUPP; in request_partial_firmware_into_buf()
1055 ret = _request_firmware(firmware_p, name, device, buf, size, offset, in request_partial_firmware_into_buf()
1064 * release_firmware() - release the resource associated with a firmware image
1065 * @fw: firmware resource to release
1067 void release_firmware(const struct firmware *fw) in release_firmware()
1081 const char *name; member
1084 void (*cont)(const struct firmware *fw, void *context);
1091 const struct firmware *fw; in request_firmware_work_func()
1095 _request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0, 0, in request_firmware_work_func()
1096 fw_work->opt_flags); in request_firmware_work_func()
1097 fw_work->cont(fw, fw_work->context); in request_firmware_work_func()
1098 put_device(fw_work->device); /* taken in request_firmware_nowait() */ in request_firmware_work_func()
1100 module_put(fw_work->module); in request_firmware_work_func()
1101 kfree_const(fw_work->name); in request_firmware_work_func()
1106 * request_firmware_nowait() - asynchronous version of request_firmware
1107 * @module: module requesting the firmware
1108 * @uevent: sends uevent to copy the firmware image if this flag
1109 * is non-zero else the firmware copy must be done manually.
1110 * @name: name of firmware file
1111 * @device: device for which firmware is being loaded
1114 * @fw may be %NULL if firmware request fails.
1115 * @cont: function will be called asynchronously when the firmware
1121 * - sleep for as small periods as possible since it may
1122 * increase kernel boot time of built-in device drivers
1123 * requesting firmware in their ->probe() methods, if
1126 * - can't sleep at all if @gfp is GFP_ATOMIC.
1131 const char *name, struct device *device, gfp_t gfp, void *context, in request_firmware_nowait() argument
1132 void (*cont)(const struct firmware *fw, void *context)) in request_firmware_nowait()
1138 return -ENOMEM; in request_firmware_nowait()
1140 fw_work->module = module; in request_firmware_nowait()
1141 fw_work->name = kstrdup_const(name, gfp); in request_firmware_nowait()
1142 if (!fw_work->name) { in request_firmware_nowait()
1144 return -ENOMEM; in request_firmware_nowait()
1146 fw_work->device = device; in request_firmware_nowait()
1147 fw_work->context = context; in request_firmware_nowait()
1148 fw_work->cont = cont; in request_firmware_nowait()
1149 fw_work->opt_flags = FW_OPT_NOWAIT | in request_firmware_nowait()
1152 if (!uevent && fw_cache_is_setup(device, name)) { in request_firmware_nowait()
1153 kfree_const(fw_work->name); in request_firmware_nowait()
1155 return -EOPNOTSUPP; in request_firmware_nowait()
1159 kfree_const(fw_work->name); in request_firmware_nowait()
1161 return -EFAULT; in request_firmware_nowait()
1164 get_device(fw_work->device); in request_firmware_nowait()
1165 INIT_WORK(&fw_work->work, request_firmware_work_func); in request_firmware_nowait()
1166 schedule_work(&fw_work->work); in request_firmware_nowait()
1175 * cache_firmware() - cache one firmware image in kernel memory space
1176 * @fw_name: the firmware image name
1178 * Cache firmware in kernel memory so that drivers can use it when
1179 * system isn't ready for them to request firmware image from userspace.
1181 * nowait version to get the cached firmware without any interacting
1184 * Return 0 if the firmware image has been cached successfully
1191 const struct firmware *fw; in cache_firmware()
1209 spin_lock(&fwc->lock); in lookup_fw_priv()
1211 spin_unlock(&fwc->lock); in lookup_fw_priv()
1217 * uncache_firmware() - remove one cached firmware image
1218 * @fw_name: the firmware image name
1220 * Uncache one firmware image which has been cached successfully
1223 * Return 0 if the firmware cache has been removed successfully
1230 struct firmware fw; in uncache_firmware()
1243 return -EINVAL; in uncache_firmware()
1246 static struct fw_cache_entry *alloc_fw_cache_entry(const char *name) in alloc_fw_cache_entry() argument
1254 fce->name = kstrdup_const(name, GFP_ATOMIC); in alloc_fw_cache_entry()
1255 if (!fce->name) { in alloc_fw_cache_entry()
1264 static int __fw_entry_found(const char *name) in __fw_entry_found() argument
1269 list_for_each_entry(fce, &fwc->fw_names, list) { in __fw_entry_found()
1270 if (!strcmp(fce->name, name)) in __fw_entry_found()
1278 const char *name = fw_priv->fw_name; in fw_cache_piggyback_on_request() local
1279 struct firmware_cache *fwc = fw_priv->fwc; in fw_cache_piggyback_on_request()
1282 spin_lock(&fwc->name_lock); in fw_cache_piggyback_on_request()
1283 if (__fw_entry_found(name)) in fw_cache_piggyback_on_request()
1286 fce = alloc_fw_cache_entry(name); in fw_cache_piggyback_on_request()
1288 list_add(&fce->list, &fwc->fw_names); in fw_cache_piggyback_on_request()
1289 kref_get(&fw_priv->ref); in fw_cache_piggyback_on_request()
1290 pr_debug("%s: fw: %s\n", __func__, name); in fw_cache_piggyback_on_request()
1293 spin_unlock(&fwc->name_lock); in fw_cache_piggyback_on_request()
1298 kfree_const(fce->name); in free_fw_cache_entry()
1309 ret = cache_firmware(fce->name); in __async_dev_cache_fw_image()
1311 spin_lock(&fwc->name_lock); in __async_dev_cache_fw_image()
1312 list_del(&fce->list); in __async_dev_cache_fw_image()
1313 spin_unlock(&fwc->name_lock); in __async_dev_cache_fw_image()
1319 /* called with dev->devres_lock held */
1324 const char *fw_name = fwn->name; in dev_create_fw_entry()
1330 list_add(&fce->list, head); in dev_create_fw_entry()
1337 return (fwn->magic == (unsigned long)match_data); in devm_name_match()
1352 list_del(&fce->list); in dev_cache_fw_image()
1354 spin_lock(&fwc->name_lock); in dev_cache_fw_image()
1355 /* only one cache entry for one firmware */ in dev_cache_fw_image()
1356 if (!__fw_entry_found(fce->name)) { in dev_cache_fw_image()
1357 list_add(&fce->list, &fwc->fw_names); in dev_cache_fw_image()
1362 spin_unlock(&fwc->name_lock); in dev_cache_fw_image()
1376 spin_lock(&fwc->name_lock); in __device_uncache_fw_images()
1377 while (!list_empty(&fwc->fw_names)) { in __device_uncache_fw_images()
1378 fce = list_entry(fwc->fw_names.next, in __device_uncache_fw_images()
1380 list_del(&fce->list); in __device_uncache_fw_images()
1381 spin_unlock(&fwc->name_lock); in __device_uncache_fw_images()
1383 uncache_firmware(fce->name); in __device_uncache_fw_images()
1386 spin_lock(&fwc->name_lock); in __device_uncache_fw_images()
1388 spin_unlock(&fwc->name_lock); in __device_uncache_fw_images()
1392 * device_cache_fw_images() - cache devices' firmware
1395 * successfully before, the firmware names are recored into the
1399 * time when system is not ready to complete loading firmware.
1409 cancel_delayed_work_sync(&fwc->work); in device_cache_fw_images()
1414 fwc->state = FW_LOADER_START_CACHE; in device_cache_fw_images()
1418 /* wait for completion of caching firmware for all devices */ in device_cache_fw_images()
1425 * device_uncache_fw_images() - uncache devices' firmware
1442 * device_uncache_fw_images_delay() - uncache devices firmwares
1487 /* stop caching firmware once syscore_suspend is reached */