Merge "msm: camera: sensor: Replace cma_alloc with vmalloc" into camera-kernel.lnx.4.0

This commit is contained in:
Jeyaprakash Soundrapandian 2019-12-03 18:55:23 -08:00 • committed by Gerrit - the friendly Code Review server
commit 2478b5c0f7
2 changed files with 39 additions and 37 deletions

View file

@ -300,7 +300,7 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
char name_coeff[32] = {0};
struct device *dev = &(o_ctrl->pdev->dev);
struct cam_sensor_i2c_reg_setting i2c_reg_setting;
struct page *page = NULL;
void *vaddr = NULL;
if (!o_ctrl) {
CAM_ERR(CAM_OIS, "Invalid Args");
@ -327,18 +327,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
i2c_reg_setting.size = total_bytes;
i2c_reg_setting.delay = 0;
fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) *
total_bytes) >> PAGE_SHIFT;
page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)),
fw_size, 0, GFP_KERNEL);
if (!page) {
CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes);
vaddr = vmalloc(fw_size);
if (!vaddr) {
CAM_ERR(CAM_OIS,
"Failed in allocating i2c_array: fw_size: %u", fw_size);
release_firmware(fw);
return -ENOMEM;
}
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
page_address(page));
vaddr);
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
cnt++, ptr++) {
@ -355,9 +354,8 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
goto release_firmware;
}
cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)),
page, fw_size);
page = NULL;
vfree(vaddr);
vaddr = NULL;
fw_size = 0;
release_firmware(fw);
@ -372,18 +370,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
i2c_reg_setting.size = total_bytes;
i2c_reg_setting.delay = 0;
fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) *
total_bytes) >> PAGE_SHIFT;
page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)),
fw_size, 0, GFP_KERNEL);
if (!page) {
CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes);
vaddr = vmalloc(fw_size);
if (!vaddr) {
CAM_ERR(CAM_OIS,
"Failed in allocating i2c_array: fw_size: %u", fw_size);
release_firmware(fw);
return -ENOMEM;
}
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
page_address(page));
vaddr);
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
cnt++, ptr++) {
@ -400,10 +397,10 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
release_firmware:
cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)),
page, fw_size);
vfree(vaddr);
vaddr = NULL;
fw_size = 0;
release_firmware(fw);
return rc;
}

View file

@ -111,7 +111,8 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
uint32_t len, hlen;
uint8_t retries = client->spi_client->retries;
uint32_t txr = 0, rxr = 0;
struct page *page_tx = NULL, *page_rx = NULL;
void *vaddr_tx = NULL;
void *vaddr_rx = NULL;
hlen = cam_camera_spi_get_hlen(inst);
len = hlen + num_byte;
@ -125,30 +126,32 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
if (tx) {
ctx = tx;
} else {
txr = PAGE_ALIGN(len) >> PAGE_SHIFT;
page_tx = cma_alloc(dev_get_cma_area(dev),
txr, 0, GFP_KERNEL);
if (!page_tx)
txr = len;
vaddr_tx = vmalloc(txr);
if (!vaddr_tx) {
CAM_ERR(CAM_SENSOR,
"Fail to allocate Memory: len: %u", txr);
return -ENOMEM;
}
ctx = page_address(page_tx);
ctx = (char *)vaddr_tx;
}
if (num_byte) {
if (rx) {
crx = rx;
} else {
rxr = PAGE_ALIGN(len) >> PAGE_SHIFT;
page_rx = cma_alloc(dev_get_cma_area(dev),
rxr, 0, GFP_KERNEL);
if (!page_rx) {
rxr = len;
vaddr_rx = vmalloc(rxr);
if (!vaddr_rx) {
if (!tx)
cma_release(dev_get_cma_area(dev),
page_tx, txr);
vfree(vaddr_tx);
CAM_ERR(CAM_SENSOR,
"Fail to allocate memory: len: %u",
rxr);
return -ENOMEM;
}
crx = page_address(page_rx);
crx = (char *)vaddr_rx;
}
} else {
crx = NULL;
@ -169,9 +172,11 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
out:
if (!tx)
cma_release(dev_get_cma_area(dev), page_tx, txr);
vfree(vaddr_tx);
vaddr_tx = NULL;
if (!rx)
cma_release(dev_get_cma_area(dev), page_rx, rxr);
vfree(vaddr_rx);
vaddr_rx = NULL;
return rc;
}