From 008ef1f5410ff23237c445aae08f31901d724d0b Mon Sep 17 00:00:00 2001 From: David Cohen Date: Wed, 7 Mar 2012 10:59:37 +0200 Subject: [PATCH] [PORT FROM R2] atomisp: acc: use vmalloc() when loading/allocating acceleration firmware BZ: 23757 Currently acceleration API tries to allocate memory for loaded firmware with kmalloc(). As such firmwares used to be bigger than PAGE_SIZE, kmalloc() may get in trouble if memory is too fragmented. vmalloc() is a safer option. Change-Id: I43a4cb829a62ea4672ff20eafcb5d17d7815a54e Signed-off-by: David Cohen Reviewed-on: http://android.intel.com:8080/37828 Reviewed-by: Koski, Anttu Reviewed-by: Toivonen, Tuukka Reviewed-by: Koskinen, Ilkka Tested-by: Koski, Anttu Reviewed-by: Govindapillai, Vinod Reviewed-by: buildbot Tested-by: buildbot Reviewed-on: http://android.intel.com:8080/42095 Reviewed-by: Gross, Mark Tested-by: Lampila, KalleX --- drivers/media/video/atomisp/atomisp_cmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/atomisp/atomisp_cmd.c b/drivers/media/video/atomisp/atomisp_cmd.c index 7eb3317..648a7bf 100644 --- a/drivers/media/video/atomisp/atomisp_cmd.c +++ b/drivers/media/video/atomisp/atomisp_cmd.c @@ -3636,7 +3636,7 @@ __acc_fw_free(struct atomisp_device *isp, struct sh_css_acc_fw *fw) isp->acc_fw[i] = NULL; isp->acc_fw_count--; - kfree(fw); + vfree(fw); } static struct sh_css_acc_fw * @@ -3649,14 +3649,14 @@ __acc_fw_alloc(struct atomisp_device *isp, struct atomisp_acc_fw_load *user_fw) if (user_fw->data == NULL || user_fw->size == 0) return ERR_PTR(-EINVAL); - /* REVISIT: does size need to be multiple of page size? */ - fw = kzalloc(user_fw->size, GFP_KERNEL); + fw = vmalloc(user_fw->size); if (fw == NULL) { v4l2_err(&atomisp_dev, "%s: Failed to alloc acc fw blob\n", __func__); return ERR_PTR(-ENOMEM); } + memset(fw, 0, user_fw->size); ret = copy_from_user(fw, user_fw->data, user_fw->size); if (ret) { @@ -3687,7 +3687,7 @@ __acc_fw_alloc(struct atomisp_device *isp, struct atomisp_acc_fw_load *user_fw) return fw; err: - kfree(fw); + vfree(fw); return ERR_PTR(ret); } -- 2.7.4