Commit ddaf29fd authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

firmware: Free temporary page table after vmapping

Once after performing vmap() to map the S/G pages, our own page table
becomes superfluous since the pages can be released via vfree()
automatically.  Let's change the buffer release code and discard the
page table array for saving some memory.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 64ae0e71
...@@ -222,7 +222,7 @@ static ssize_t firmware_loading_show(struct device *dev, ...@@ -222,7 +222,7 @@ static ssize_t firmware_loading_show(struct device *dev,
/* one pages buffer should be mapped/unmapped only once */ /* one pages buffer should be mapped/unmapped only once */
static int map_fw_priv_pages(struct fw_priv *fw_priv) static int map_fw_priv_pages(struct fw_priv *fw_priv)
{ {
if (!fw_priv->is_paged_buf) if (!fw_priv->pages)
return 0; return 0;
vunmap(fw_priv->data); vunmap(fw_priv->data);
...@@ -230,6 +230,11 @@ static int map_fw_priv_pages(struct fw_priv *fw_priv) ...@@ -230,6 +230,11 @@ static int map_fw_priv_pages(struct fw_priv *fw_priv)
PAGE_KERNEL_RO); PAGE_KERNEL_RO);
if (!fw_priv->data) if (!fw_priv->data)
return -ENOMEM; return -ENOMEM;
/* page table is no longer needed after mapping, let's free */
vfree(fw_priv->pages);
fw_priv->pages = NULL;
return 0; return 0;
} }
......
...@@ -252,13 +252,13 @@ static void __free_fw_priv(struct kref *ref) ...@@ -252,13 +252,13 @@ static void __free_fw_priv(struct kref *ref)
spin_unlock(&fwc->lock); spin_unlock(&fwc->lock);
#ifdef CONFIG_FW_LOADER_USER_HELPER #ifdef CONFIG_FW_LOADER_USER_HELPER
if (fw_priv->is_paged_buf) { if (fw_priv->pages) {
/* free leftover pages */
int i; int i;
vunmap(fw_priv->data);
for (i = 0; i < fw_priv->nr_pages; i++) for (i = 0; i < fw_priv->nr_pages; i++)
__free_page(fw_priv->pages[i]); __free_page(fw_priv->pages[i]);
vfree(fw_priv->pages); vfree(fw_priv->pages);
} else }
#endif #endif
if (!fw_priv->allocated_size) if (!fw_priv->allocated_size)
vfree(fw_priv->data); vfree(fw_priv->data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment