Loading asoc/msm-cpe-lsm.c +24 −20 Original line number Original line Diff line number Diff line /* /* * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2013-2018, 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 Loading Loading @@ -478,18 +478,21 @@ static int msm_cpe_lab_buf_alloc(struct snd_pcm_substream *substream, lab_d->pcm_buf = pcm_buf; lab_d->pcm_buf = pcm_buf; dma_alloc = bufsz * bufcnt; dma_alloc = bufsz * bufcnt; pcm_buf->mem = NULL; pcm_buf->mem = NULL; pcm_buf->mem = dma_alloc_coherent(dma_data->sdev->dev.parent, pcm_buf->mem = kzalloc(dma_alloc, GFP_DMA); dma_alloc, &(pcm_buf->phys), GFP_KERNEL); if (!pcm_buf->mem) { if (!pcm_buf->mem) { dev_err(rtd->dev, "%s:DMA alloc failed size = %x\n", __func__, dma_alloc); rc = -ENOMEM; rc = -ENOMEM; goto fail; goto fail; } } pcm_buf->phys = dma_map_single(dma_data->sdev->dev.parent, pcm_buf->mem, dma_alloc, DMA_BIDIRECTIONAL); if (dma_mapping_error(dma_data->sdev->dev.parent, pcm_buf->phys)) { dev_err(rtd->dev, "%s Error mapping DMA buffers\n", __func__); pcm_buf->phys = (phys_addr_t)NULL; rc = -EFAULT; goto fail; } count = 0; count = 0; while (count < bufcnt) { while (count < bufcnt) { pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz); pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz); Loading @@ -504,13 +507,10 @@ static int msm_cpe_lab_buf_alloc(struct snd_pcm_substream *substream, return 0; return 0; fail: fail: if (pcm_buf) { if (pcm_buf) if (pcm_buf->mem) kfree(pcm_buf->mem); dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc, pcm_buf->mem, pcm_buf->phys); kfree(pcm_buf); kfree(pcm_buf); lab_d->pcm_buf = NULL; lab_d->pcm_buf = NULL; } exit: exit: return rc; return rc; } } Loading Loading @@ -544,8 +544,12 @@ static int msm_cpe_lab_buf_dealloc(struct snd_pcm_substream *substream, pcm_buf = lab_d->pcm_buf; pcm_buf = lab_d->pcm_buf; dma_alloc = bufsz * bufcnt; dma_alloc = bufsz * bufcnt; if (dma_data && pcm_buf) if (dma_data && pcm_buf) dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc, if (pcm_buf->phys) pcm_buf->mem, pcm_buf->phys); dma_unmap_single(dma_data->sdev->dev.parent, pcm_buf->phys, dma_alloc, DMA_BIDIRECTIONAL); if (pcm_buf) kfree(pcm_buf->mem); kfree(pcm_buf); kfree(pcm_buf); lab_d->pcm_buf = NULL; lab_d->pcm_buf = NULL; return rc; return rc; Loading Loading @@ -633,7 +637,7 @@ static int msm_cpe_lab_thread(void *data) memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size); memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size); rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, lab_d->pcm_buf[0].phys, lab_d->pcm_buf[0].mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading @@ -643,7 +647,7 @@ static int msm_cpe_lab_thread(void *data) } } rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, lab_d->pcm_buf[1].phys, lab_d->pcm_buf[1].mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading Loading @@ -678,7 +682,7 @@ static int msm_cpe_lab_thread(void *data) lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) { lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) { rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, next_buf->phys, next_buf->mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading Loading
asoc/msm-cpe-lsm.c +24 −20 Original line number Original line Diff line number Diff line /* /* * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2013-2018, 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 Loading Loading @@ -478,18 +478,21 @@ static int msm_cpe_lab_buf_alloc(struct snd_pcm_substream *substream, lab_d->pcm_buf = pcm_buf; lab_d->pcm_buf = pcm_buf; dma_alloc = bufsz * bufcnt; dma_alloc = bufsz * bufcnt; pcm_buf->mem = NULL; pcm_buf->mem = NULL; pcm_buf->mem = dma_alloc_coherent(dma_data->sdev->dev.parent, pcm_buf->mem = kzalloc(dma_alloc, GFP_DMA); dma_alloc, &(pcm_buf->phys), GFP_KERNEL); if (!pcm_buf->mem) { if (!pcm_buf->mem) { dev_err(rtd->dev, "%s:DMA alloc failed size = %x\n", __func__, dma_alloc); rc = -ENOMEM; rc = -ENOMEM; goto fail; goto fail; } } pcm_buf->phys = dma_map_single(dma_data->sdev->dev.parent, pcm_buf->mem, dma_alloc, DMA_BIDIRECTIONAL); if (dma_mapping_error(dma_data->sdev->dev.parent, pcm_buf->phys)) { dev_err(rtd->dev, "%s Error mapping DMA buffers\n", __func__); pcm_buf->phys = (phys_addr_t)NULL; rc = -EFAULT; goto fail; } count = 0; count = 0; while (count < bufcnt) { while (count < bufcnt) { pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz); pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz); Loading @@ -504,13 +507,10 @@ static int msm_cpe_lab_buf_alloc(struct snd_pcm_substream *substream, return 0; return 0; fail: fail: if (pcm_buf) { if (pcm_buf) if (pcm_buf->mem) kfree(pcm_buf->mem); dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc, pcm_buf->mem, pcm_buf->phys); kfree(pcm_buf); kfree(pcm_buf); lab_d->pcm_buf = NULL; lab_d->pcm_buf = NULL; } exit: exit: return rc; return rc; } } Loading Loading @@ -544,8 +544,12 @@ static int msm_cpe_lab_buf_dealloc(struct snd_pcm_substream *substream, pcm_buf = lab_d->pcm_buf; pcm_buf = lab_d->pcm_buf; dma_alloc = bufsz * bufcnt; dma_alloc = bufsz * bufcnt; if (dma_data && pcm_buf) if (dma_data && pcm_buf) dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc, if (pcm_buf->phys) pcm_buf->mem, pcm_buf->phys); dma_unmap_single(dma_data->sdev->dev.parent, pcm_buf->phys, dma_alloc, DMA_BIDIRECTIONAL); if (pcm_buf) kfree(pcm_buf->mem); kfree(pcm_buf); kfree(pcm_buf); lab_d->pcm_buf = NULL; lab_d->pcm_buf = NULL; return rc; return rc; Loading Loading @@ -633,7 +637,7 @@ static int msm_cpe_lab_thread(void *data) memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size); memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size); rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, lab_d->pcm_buf[0].phys, lab_d->pcm_buf[0].mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading @@ -643,7 +647,7 @@ static int msm_cpe_lab_thread(void *data) } } rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, lab_d->pcm_buf[1].phys, lab_d->pcm_buf[1].mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading Loading @@ -678,7 +682,7 @@ static int msm_cpe_lab_thread(void *data) lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) { lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) { rc = slim_port_xfer(dma_data->sdev, dma_data->ph, rc = slim_port_xfer(dma_data->sdev, dma_data->ph, next_buf->phys, next_buf->mem, hw_params->buf_sz, &lab_d->comp); hw_params->buf_sz, &lab_d->comp); if (rc) { if (rc) { dev_err(rtd->dev, dev_err(rtd->dev, Loading