From 44b3f7c2df7b15c4f6ce8796812a8d7bd9b3a05d Mon Sep 17 00:00:00 2001 From: Sana Venkat Raju <c_vsana@codeaurora.org> Date: Fri, 12 Sep 2014 10:58:41 +0530 Subject: [PATCH] spi_qsd: teardown BAM pipes before turning off clocks Tearing down BAM pipe causes accessing of BAM registers (indirectly by the BAM driver). Register access in turn requires clocking to the internal bus. Lack of clocking may result in to crash. Change-Id: I22bcfdd714024d980f5d66206a65657f9605d3b5 Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org> --- drivers/spi/spi_qsd.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi_qsd.c b/drivers/spi/spi_qsd.c index eb6c5cc437f4..3614f7ee1434 100644 --- a/drivers/spi/spi_qsd.c +++ b/drivers/spi/spi_qsd.c @@ -1855,8 +1855,10 @@ static int msm_spi_transfer_one_message(struct spi_master *master, * get local resources for each transfer to ensure we're in a good * state and not interfering with other EE's using this device */ - if (get_local_resources(dd)) + if (get_local_resources(dd)) { + mutex_unlock(&dd->core_lock); return -EINVAL; + } reset_core(dd); if (dd->use_dma) { @@ -1882,14 +1884,7 @@ static int msm_spi_transfer_one_message(struct spi_master *master, dd->transfer_pending = 0; spin_unlock_irqrestore(&dd->queue_lock, flags); - mutex_unlock(&dd->core_lock); - /* - * If needed, this can be done after the current message is complete, - * and work can be continued upon resume. No motivation for now. - */ - if (dd->suspended) - wake_up_interruptible(&dd->continue_suspend); /* * Put local resources prior to calling finalize to ensure the hw @@ -1897,11 +1892,14 @@ static int msm_spi_transfer_one_message(struct spi_master *master, * different context since we're running in the spi kthread here) to * prevent race conditions between us and any other EE's using this hw. */ - put_local_resources(dd); if (dd->use_dma) { msm_spi_bam_pipe_disconnect(dd, &dd->bam.prod); msm_spi_bam_pipe_disconnect(dd, &dd->bam.cons); } + put_local_resources(dd); + mutex_unlock(&dd->core_lock); + if (dd->suspended) + wake_up_interruptible(&dd->continue_suspend); status_error = dd->cur_msg->status; spi_finalize_current_message(master); return status_error; -- GitLab