msm: camera: sensor: Request allocating DMA-able memory from DMA zone

When DMA I/O is performed to or from high memory, an area is allocated
in low memory known as a bounce buffer. When data travels between a
device and high memory, it is first copied through the bounce buffer.
Systems with a large amount of high memory and intense I/O activity
can create a large number of bounce buffers that can cause memory
shortage problems.
In general, when communicating to SPI framework,it's recommended to
use gfp_dma,since the buffer mm client passes is used by the spi
driver for dma ops.

CRs-Fixed: 967770
Change-Id: Idd7e0229d1a128516298ee18bf2c798e6218c71b
Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
This commit is contained in:
Azam Sadiq Pasha Kapatrala Syed 2016-02-03 15:50:10 -08:00 committed by David Keitel
parent 848dca3bc3
commit a1c04d7f2e

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -132,7 +132,7 @@ int32_t msm_camera_spi_tx_helper(struct msm_camera_i2c_client *client,
if (tx) if (tx)
ctx = tx; ctx = tx;
else else
ctx = kzalloc(len, GFP_KERNEL); ctx = kzalloc(len, GFP_KERNEL | GFP_DMA);
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
@ -140,7 +140,7 @@ int32_t msm_camera_spi_tx_helper(struct msm_camera_i2c_client *client,
if (rx) if (rx)
crx = rx; crx = rx;
else else
crx = kzalloc(len, GFP_KERNEL); crx = kzalloc(len, GFP_KERNEL | GFP_DMA);
if (!crx) { if (!crx) {
if (!tx) if (!tx)
kfree(ctx); kfree(ctx);
@ -190,14 +190,14 @@ int32_t msm_camera_spi_tx_read(struct msm_camera_i2c_client *client,
if (tx) if (tx)
ctx = tx; ctx = tx;
else else
ctx = kzalloc(hlen, GFP_KERNEL); ctx = kzalloc(hlen, GFP_KERNEL | GFP_DMA);
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
if (num_byte) { if (num_byte) {
if (rx) if (rx)
crx = rx; crx = rx;
else else
crx = kzalloc(num_byte, GFP_KERNEL); crx = kzalloc(num_byte, GFP_KERNEL | GFP_DMA);
if (!crx) { if (!crx) {
if (!tx) if (!tx)
kfree(ctx); kfree(ctx);
@ -462,7 +462,7 @@ int32_t msm_camera_spi_write_seq(struct msm_camera_i2c_client *client,
/* single page write */ /* single page write */
if ((addr % page_size) + num_byte <= page_size) { if ((addr % page_size) + num_byte <= page_size) {
len = header_len + num_byte; len = header_len + num_byte;
tx = kmalloc(len, GFP_KERNEL); tx = kmalloc(len, GFP_KERNEL | GFP_DMA);
if (!tx) if (!tx)
goto NOMEM; goto NOMEM;
rc = msm_camera_spi_page_program(client, addr, data, rc = msm_camera_spi_page_program(client, addr, data,
@ -473,7 +473,7 @@ int32_t msm_camera_spi_write_seq(struct msm_camera_i2c_client *client,
} }
/* multi page write */ /* multi page write */
len = header_len + page_size; len = header_len + page_size;
tx = kmalloc(len, GFP_KERNEL); tx = kmalloc(len, GFP_KERNEL | GFP_DMA);
if (!tx) if (!tx)
goto NOMEM; goto NOMEM;
while (num_byte) { while (num_byte) {
@ -516,7 +516,7 @@ int32_t msm_camera_spi_write(struct msm_camera_i2c_client *client,
return rc; return rc;
S_I2C_DBG("Data: 0x%x\n", data); S_I2C_DBG("Data: 0x%x\n", data);
len = header_len + (uint8_t)data_type; len = header_len + (uint8_t)data_type;
tx = kmalloc(len, GFP_KERNEL); tx = kmalloc(len, GFP_KERNEL | GFP_DMA);
if (!tx) if (!tx)
goto NOMEM; goto NOMEM;
if (data_type == MSM_CAMERA_I2C_BYTE_DATA) { if (data_type == MSM_CAMERA_I2C_BYTE_DATA) {
@ -618,7 +618,7 @@ int32_t msm_camera_spi_send_burst(struct msm_camera_i2c_client *client,
__func__, header_len, chunk_num, residue); __func__, header_len, chunk_num, residue);
len = info->chunk_size * data_type + header_len; len = info->chunk_size * data_type + header_len;
SPIDBG("buffer allocation size = %d\n", len); SPIDBG("buffer allocation size = %d\n", len);
ctx = kmalloc(len, GFP_KERNEL); ctx = kmalloc(len, GFP_KERNEL | GFP_DMA);
if (!ctx) { if (!ctx) {
pr_err("%s %d memory alloc fail!\n", __func__, __LINE__); pr_err("%s %d memory alloc fail!\n", __func__, __LINE__);
return rc; return rc;
@ -815,7 +815,7 @@ int32_t msm_camera_spi_read_burst(struct msm_camera_i2c_client *client,
if ((client->addr_type != MSM_CAMERA_I2C_WORD_ADDR) if ((client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
|| (data_type != MSM_CAMERA_I2C_WORD_DATA)) || (data_type != MSM_CAMERA_I2C_WORD_DATA))
return rc; return rc;
tx_buf = kzalloc(len, GFP_KERNEL); tx_buf = kzalloc(len, GFP_KERNEL | GFP_DMA);
if (!tx_buf) if (!tx_buf)
return -ENOMEM; return -ENOMEM;