media: intel/ipu6: Don't re-allocate memory for firmware
[linux-block.git] / drivers / media / pci / intel / ipu6 / ipu6-buttress.c
index dbcf1aa87872cc2739cb3e9d0b103f83e829896b..23c537e7ce1ede9f1df211e919445ab027528bba 100644 (file)
@@ -552,12 +552,16 @@ int ipu6_buttress_reset_authentication(struct ipu6_device *isp)
 int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
                               const struct firmware *fw, struct sg_table *sgt)
 {
+       bool is_vmalloc = is_vmalloc_addr(fw->data);
        struct page **pages;
        const void *addr;
        unsigned long n_pages;
        unsigned int i;
        int ret;
 
+       if (!is_vmalloc && !virt_addr_valid(fw->data))
+               return -EDOM;
+
        n_pages = PHYS_PFN(PAGE_ALIGN(fw->size));
 
        pages = kmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
@@ -566,7 +570,8 @@ int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
 
        addr = fw->data;
        for (i = 0; i < n_pages; i++) {
-               struct page *p = vmalloc_to_page(addr);
+               struct page *p = is_vmalloc ?
+                       vmalloc_to_page(addr) : virt_to_page(addr);
 
                if (!p) {
                        ret = -ENOMEM;