[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=Ue9Z+NmqviCXEN2pHxWZaAcTbFzzn=xxfg8d8QzPwp4A@mail.gmail.com>
Date: Thu, 6 Jan 2022 08:13:03 -0800
From: Doug Anderson <dianders@...omium.org>
To: Vinod Koul <vkoul@...nel.org>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>,
Mark Brown <broonie@...nel.org>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>,
Matthias Kaehlcke <mka@...omium.org>,
linux-spi <linux-spi@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] spi: qcom: geni: set the error code for gpi transfer
Hi,
On Sun, Jan 2, 2022 at 11:11 PM Vinod Koul <vkoul@...nel.org> wrote:
>
> Before we invoke spi_finalize_current_transfer() in
> spi_gsi_callback_result() we should set the spi->cur_msg->status as
> appropriate (0 for success, error otherwise).
>
> The helps to return error on transfer and not wait till it timesout on
> error
>
> Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
> Signed-off-by: Vinod Koul <vkoul@...nel.org>
> ---
>
> Changes in v2:
> - add missing spi_finalize_current_transfer() for dma error case
>
> drivers/spi/spi-geni-qcom.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index 413fa1a7a936..b82f3ddff0f4 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
> @@ -346,17 +346,21 @@ spi_gsi_callback_result(void *cb, const struct dmaengine_result *result)
> {
> struct spi_master *spi = cb;
>
> + spi->cur_msg->status = -EIO;
> if (result->result != DMA_TRANS_NOERROR) {
> dev_err(&spi->dev, "DMA txn failed: %d\n", result->result);
> + spi_finalize_current_transfer(spi);
> return;
> }
>
> if (!result->residue) {
> + spi->cur_msg->status = 0;
> dev_dbg(&spi->dev, "DMA txn completed\n");
> - spi_finalize_current_transfer(spi);
> } else {
> dev_err(&spi->dev, "DMA xfer has pending: %d\n", result->residue);
> }
> +
> + spi_finalize_current_transfer(spi);
> }
What you have here should work and seems fine, though it's a bit
awkward. Every exit path now calls spi_finalize_current_transfer().
IMO this would be slightly cleaner like this (also moving the error
cases to both be first)
if (result->result != DMA_TRANS_NOERROR) {
dev_err(...);
} else if (result->residue)
dev_err(...);
} else {
spi->cur_msg->status = 0;
dev_dbg(...);
}
spi_finalize_current_transfer(spi);
I'll let Mark decide if he wants it to be respun with the above, wants
a follow-on patch, or doesn't care either way. In any case:
Reviewed-by: Douglas Anderson <dianders@...omium.org>
Powered by blists - more mailing lists