• Home
  • Raw
  • Download

Lines Matching refs:fw_priv

81 static inline struct fw_priv *to_fw_priv(struct kref *ref)  in to_fw_priv()
83 return container_of(ref, struct fw_priv, ref); in to_fw_priv()
155 static void fw_state_init(struct fw_priv *fw_priv) in fw_state_init() argument
157 struct fw_state *fw_st = &fw_priv->fw_st; in fw_state_init()
163 static inline int fw_state_wait(struct fw_priv *fw_priv) in fw_state_wait() argument
165 return __fw_state_wait_common(fw_priv, MAX_SCHEDULE_TIMEOUT); in fw_state_wait()
168 static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv);
170 static struct fw_priv *__allocate_fw_priv(const char *fw_name, in __allocate_fw_priv()
177 struct fw_priv *fw_priv; in __allocate_fw_priv() local
187 fw_priv = kzalloc(sizeof(*fw_priv), GFP_ATOMIC); in __allocate_fw_priv()
188 if (!fw_priv) in __allocate_fw_priv()
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()
193 kfree(fw_priv); 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()
203 fw_state_init(fw_priv); 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()
210 return fw_priv; in __allocate_fw_priv()
213 static struct fw_priv *__lookup_fw_priv(const char *fw_name) in __lookup_fw_priv()
215 struct fw_priv *tmp; in __lookup_fw_priv()
227 struct fw_priv **fw_priv, in alloc_lookup_fw_priv() argument
233 struct fw_priv *tmp; in alloc_lookup_fw_priv()
245 *fw_priv = tmp; in alloc_lookup_fw_priv()
259 *fw_priv = tmp; in alloc_lookup_fw_priv()
267 struct fw_priv *fw_priv = to_fw_priv(ref); in __free_fw_priv() local
268 struct firmware_cache *fwc = fw_priv->fwc; 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()
277 if (fw_is_paged_buf(fw_priv)) in __free_fw_priv()
278 fw_free_paged_buf(fw_priv); 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()
283 kfree(fw_priv); in __free_fw_priv()
286 static void free_fw_priv(struct fw_priv *fw_priv) in free_fw_priv() argument
288 struct firmware_cache *fwc = fw_priv->fwc; in free_fw_priv()
290 if (!kref_put(&fw_priv->ref, __free_fw_priv)) in free_fw_priv()
295 bool fw_is_paged_buf(struct fw_priv *fw_priv) in fw_is_paged_buf() argument
297 return fw_priv->is_paged_buf; in fw_is_paged_buf()
300 void fw_free_paged_buf(struct fw_priv *fw_priv) in fw_free_paged_buf() argument
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()
317 int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed) in fw_grow_paged_buf() argument
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()
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()
344 fw_priv->nr_pages++; in fw_grow_paged_buf()
350 int fw_map_paged_buf(struct fw_priv *fw_priv) in fw_map_paged_buf() argument
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()
381 static int fw_decompress_xz_single(struct device *dev, struct fw_priv *fw_priv, in fw_decompress_xz_single() argument
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()
407 static int fw_decompress_xz_pages(struct device *dev, struct fw_priv *fw_priv, in fw_decompress_xz_pages() argument
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()
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()
447 err = fw_map_paged_buf(fw_priv); in fw_decompress_xz_pages()
454 static int fw_decompress_xz(struct device *dev, struct fw_priv *fw_priv, in fw_decompress_xz() argument
458 if (fw_priv->data) in fw_decompress_xz()
459 return fw_decompress_xz_single(dev, fw_priv, in_size, in_buffer); in fw_decompress_xz()
461 return fw_decompress_xz_pages(dev, fw_priv, in_size, in_buffer); in fw_decompress_xz()
484 fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, in fw_get_filesystem_firmware() argument
487 struct fw_priv *fw_priv, 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()
517 fw_path[i], fw_priv->fw_name, suffix); in fw_get_filesystem_firmware()
523 fw_priv->size = 0; in fw_get_filesystem_firmware()
530 if ((fw_priv->opt_flags & FW_OPT_PARTIAL) && buffer) in fw_get_filesystem_firmware()
534 rc = kernel_read_file_from_path_initns(path, fw_priv->offset, in fw_get_filesystem_firmware()
553 fw_priv->fw_name); in fw_get_filesystem_firmware()
554 rc = decompress(device, fw_priv, size, buffer); in fw_get_filesystem_firmware()
559 fw_free_paged_buf(fw_priv); 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()
569 fw_state_done(fw_priv); in fw_get_filesystem_firmware()
589 static void fw_set_page_data(struct fw_priv *fw_priv, struct firmware *fw) in fw_set_page_data() argument
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()
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()
678 struct fw_priv *fw_priv = fw->priv; in assign_fw() local
682 if (!fw_priv->size || fw_state_is_aborted(fw_priv)) { 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()
708 if (!(fw_priv->opt_flags & FW_OPT_NOCACHE) && in assign_fw()
709 fw_priv->fwc->state == FW_LOADER_START_CACHE) in assign_fw()
710 fw_cache_piggyback_on_request(fw_priv); in assign_fw()
713 fw_set_page_data(fw_priv, fw); in assign_fw()
728 struct fw_priv *fw_priv; in _request_firmware_prepare() local
743 ret = alloc_lookup_fw_priv(name, &fw_cache, &fw_priv, dbuf, size, in _request_firmware_prepare()
750 firmware->priv = fw_priv; in _request_firmware_prepare()
753 ret = fw_state_wait(fw_priv); in _request_firmware_prepare()
755 fw_set_page_data(fw_priv, firmware); in _request_firmware_prepare()
776 struct fw_priv *fw_priv; in fw_abort_batch_reqs() local
782 fw_priv = fw->priv; in fw_abort_batch_reqs()
784 if (!fw_state_is_aborted(fw_priv)) in fw_abort_batch_reqs()
785 fw_state_aborted(fw_priv); in fw_abort_batch_reqs()
1187 static struct fw_priv *lookup_fw_priv(const char *fw_name) in lookup_fw_priv()
1189 struct fw_priv *tmp; in lookup_fw_priv()
1212 struct fw_priv *fw_priv; in uncache_firmware() local
1220 fw_priv = lookup_fw_priv(fw_name); in uncache_firmware()
1221 if (fw_priv) { in uncache_firmware()
1222 free_fw_priv(fw_priv); in uncache_firmware()
1259 static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv) in fw_cache_piggyback_on_request() argument
1261 const char *name = fw_priv->fw_name; in fw_cache_piggyback_on_request()
1262 struct firmware_cache *fwc = fw_priv->fwc; in fw_cache_piggyback_on_request()
1272 kref_get(&fw_priv->ref); in fw_cache_piggyback_on_request()
1507 static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv) in fw_cache_piggyback_on_request() argument