linux-next: build failure after merge of the v4l-dvb-next tree
Subsystems (3)
Hi all,
After merging the v4l-dvb-next tree, today's linux-next build (x86_64 allmodconfig) failed like this:
drivers/media/pci/intel/ipu6/ipu6.c: In function 'request_cpd_fw':drivers/media/pci/intel/ipu6/ipu6.c:529:21: error: implicit declaration of function 'vmalloc'; did you mean 'kvmalloc'? [-Werror=implicit-function-declaration]
529 | dst->data = vmalloc(fw->size);
| ^~~~~~~
| kvmallocdrivers/media/pci/intel/ipu6/ipu6.c:529:19: error: assignment to 'const u8 *' {aka 'const unsigned char *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
529 | dst->data = vmalloc(fw->size);
| ^
cc1: all warnings being treated as errors
Caused by commit
25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")
I have used the vl4-dvb-next tree from next-20240430 for today.
Signature · 2 lines
Cheers, Stephen Rothwell
Sakari Ailus
maintainerPATCH 1/1 media: ipu6: Fix vmalloc memory allocation
The driver was calling vmalloc() to allocate memory, something which isn't available except when particular Kconfig settings are enabled.
Use kvmalloc() instead.
---
Hi Stephen,
Thanks for reporting this. I'm a bit surprised this wasn't catched earlier. But it seems vmalloc() is defined in some configuration.
- Sakari
drivers/media/pci/intel/ipu6/ipu6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu6/ipu6.c +1 -1
@@ -526,7 +526,7 @@ static int request_cpd_fw(const struct firmware **firmware_p, const char *name, } dst->size = fw->size; - dst->data =vmalloc (fw->size); + dst->data =kvmalloc (fw->size,GFP_KERNEL );if (!dst->data) {kfree (dst); ret = -ENOMEM ;
Signature · 1 line
2.39.2
Mauro Carvalho Chehab
maintainerRe: [PATCH 1/1] media: ipu6: Fix vmalloc memory allocation
Em Thu, 2 May 2024 09:15:25 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 24 lines
The driver was calling
vmalloc()to allocate memory, something which isn't available except when particularKconfigsettings are enabled.Use
kvmalloc()instead.Reported-by Stephen Rothwell <[email protected]>Fixes 25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")Signed-off-by Sakari Ailus <[email protected]>---
Hi Stephen,Thanks for reporting this. I'm a bit surprised this wasn't catched earlier. But it seems
vmalloc()is defined in some configuration.- Sakari
drivers/media/pci/intel/ipu6/ipu6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/pci/intel/ipu6/ipu6.c +0
-0
drivers/media/pci/intel/ipu6/ipu6.c static int request_cpd_fw(const struct firmware **firmware_p, const char *name, · line 529
Quoted 5 lines
drivers/media/pci/intel/ipu6/ipu6.c +1
-1@@ -526,7 +526,7 @@ static int request_cpd_fw(const struct firmware **firmware_p, const char *name, } dst->size = fw->size; - dst->data =vmalloc (fw->size); + dst->data =kvmalloc (fw->size,GFP_KERNEL );
Where are you freeing it? If I understood the code right, you're storing dst at isp->cpd_fw, but I can't see any code freeing it nor cpw_fw->data at device removal.
Also, there is a logic there at the same function checking for vmalloc:
if (is_vmalloc_addr(fw->data)) {
*firmware_p = fw;
return 0;
}As now the memory may not be inside vmalloc space, shouldn't this be changed as well?
Regards,
Mauro
Quoted 3 lines
drivers/media/pci/intel/ipu6/ipu6.c +0
-0if (!dst->data) {kfree (dst); ret = -ENOMEM ;
Sakari Ailus
maintainerPATCH 1/1 media: intel/ipu6: Don't re-allocate memory for firmware
In reply to Stephen RothwellThe ipu6 driver allocated vmalloc memory for the firmware if request_firmware() somehow managed not to use vmalloc to allocate it.
Still how the memory is allocated by request_firmware() is not specified in its API, so be prepared for kmalloc-allocated firmware, too. Instead of allocating new vmalloc-backed buffer for the firmware, obtain the pages from virtual addresses instead.
---
Hello everyone,
Mauro preferred not to merge the earlier patch. Admittedly, there are better ways to fix the problem. Such as this one.
- Sakari
drivers/media/pci/intel/ipu6/ipu6-buttress.c | 7 +++- drivers/media/pci/intel/ipu6/ipu6.c | 41 +------------------- 2 files changed, 7 insertions(+), 41 deletions(-)
drivers/media/pci/intel/ipu6/ipu6-buttress.c +6 -1
@@ -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 ;
drivers/media/pci/intel/ipu6/ipu6.c +1 -40
53 lines not on this page · raw message
Signature · 1 line
2.39.2