From 775bdbb8ed5594696f83b490f5f3d1d6cbd17f28 Mon Sep 17 00:00:00 2001 From: Vlad Karpovich Date: Mon, 23 Jul 2018 17:15:18 -0500 Subject: [PATCH] ASoC: wm_adsp: Limit I2C transfer buffer size I2C driver on Qcom platform only allows 15 256b TX/RX buffers per transmission. Limit max transfer size to 15*256 = 3840b. Change-Id: I74fc25f845597a1677134b66a36dce8e73d7ac18 Signed-off-by: Vlad Karpovich Signed-off-by: Ravi Vembu Mot-CRs-Fixed: (CR) Reviewed-on: https://gerrit.mot.com/1215137 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Submit-Approved: Jira Key --- sound/soc/codecs/wm_adsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index f46f7e89f33d..5c1ceeba4515 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -45,6 +45,12 @@ #define adsp_dbg(_dsp, fmt, ...) \ dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) +/* + * Max I2C transfer size on Qcom platform, 3840 bytes (15 buffers * 256b) + */ + +#define MAX_I2C_TX_SIZE 0xf00 + #define ADSP1_CONTROL_1 0x00 #define ADSP1_CONTROL_2 0x02 #define ADSP1_CONTROL_3 0x03 @@ -1329,8 +1335,8 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, return ret; while ((len - read_len) > 0) { - toread_len = (len - read_len) > PAGE_SIZE ? - PAGE_SIZE : (len - read_len); + toread_len = (len - read_len) > MAX_I2C_TX_SIZE ? + MAX_I2C_TX_SIZE : (len - read_len); scratch = wm_adsp_buf_alloc(NULL, toread_len, &buf_list); if (!scratch) { @@ -1959,7 +1965,7 @@ static int wm_adsp_write_blocks(struct wm_adsp *dsp, const u8 *data, size_t len, size_t burst_multiple) { - size_t to_write = PAGE_SIZE - (PAGE_SIZE % burst_multiple); + size_t to_write = MAX_I2C_TX_SIZE - (MAX_I2C_TX_SIZE % burst_multiple); size_t remain = len; struct wm_adsp_buf *buf; unsigned int addr_div;