From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>
Cc: Magnus Damm <magnus.damm@gmail.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
Yoshihiro Kaneko <ykaneko0929@gmail.com>,
Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>,
Koji Matsuoka <koji.matsuoka.xm@renesas.com>,
Wolfram Sang <wsa@the-dreams.de>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
linux-serial@vger.kernel.org, linux-sh@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v3 23/33] serial: sh-sci: Simplify sci_submit_rx() error handling
Date: Fri, 21 Aug 2015 20:02:47 +0200 [thread overview]
Message-ID: <1440180177-6924-24-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1440180177-6924-1-git-send-email-geert+renesas@glider.be>
Simplify the error handling in sci_submit_rx() by
- Moving it to the end of the function,
- Just calling dmaengine_terminate_all() instead of calling
async_tx_ack() for all already submitted descriptors.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
- No changes,
v2:
- New.
---
drivers/tty/serial/sh-sci.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 1191a6c486640983..9c2bc0f23d3af08c 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1398,28 +1398,16 @@ static void sci_submit_rx(struct sci_port *s)
desc = dmaengine_prep_slave_sg(chan,
sg, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);
+ if (!desc)
+ goto fail;
- if (desc) {
- s->desc_rx[i] = desc;
- desc->callback = sci_dma_rx_complete;
- desc->callback_param = s;
- s->cookie_rx[i] = dmaengine_submit(desc);
- }
+ s->desc_rx[i] = desc;
+ desc->callback = sci_dma_rx_complete;
+ desc->callback_param = s;
+ s->cookie_rx[i] = dmaengine_submit(desc);
+ if (dma_submit_error(s->cookie_rx[i]))
+ goto fail;
- if (!desc || dma_submit_error(s->cookie_rx[i])) {
- if (i) {
- async_tx_ack(s->desc_rx[0]);
- s->cookie_rx[0] = -EINVAL;
- }
- if (desc) {
- async_tx_ack(desc);
- s->cookie_rx[i] = -EINVAL;
- }
- dev_warn(s->port.dev,
- "Failed to re-start Rx DMA, using PIO\n");
- sci_rx_dma_release(s, true);
- return;
- }
dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__,
s->cookie_rx[i], i);
}
@@ -1427,6 +1415,18 @@ static void sci_submit_rx(struct sci_port *s)
s->active_rx = s->cookie_rx[0];
dma_async_issue_pending(chan);
+ return;
+
+fail:
+ if (i)
+ dmaengine_terminate_all(chan);
+ for (i = 0; i < 2; i++) {
+ s->desc_rx[i] = NULL;
+ s->cookie_rx[i] = -EINVAL;
+ }
+ s->active_rx = -EINVAL;
+ dev_warn(s->port.dev, "Failed to re-start Rx DMA, using PIO\n");
+ sci_rx_dma_release(s, true);
}
static void work_fn_rx(struct work_struct *work)
--
1.9.1
next prev parent reply other threads:[~2015-08-21 18:02 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-21 18:02 [PATCH v3 00/33] serial: sh-sci: Miscellaneous and DMA Improvements Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 01/33] serial: sh-sci: Replace buggy big #ifdef by runtime logic Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 02/33] serial: sh-sci: Prevent compiler warnings on 64-bit Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 03/33] serial: sh-sci: Correct SCIF_ERROR_CLEAR for plain SCIF Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 04/33] serial: sh-sci: Use SCIF_DR instead of hardcoded literal 1 Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 05/33] serial: sh-sci: Use SCSMR_CKS instead of hardcoded literal 3 Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 06/33] serial: sh-sci: Drop path in reference to serial_core.c Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 07/33] serial: sh-sci: Improve readability of sampling rate configuration Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 08/33] serial: sh-sci: Make sci_irq_desc[] const Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 09/33] serial: sh-sci: Make sci_regmap[] const Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 10/33] serial: sh-sci: Remove useless memory allocation failure printks Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 11/33] serial: sh-sci: Remove bogus sci_handle_fifo_overrun() call on (H)SCIF Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 12/33] serial: sh-sci: Return IRQ_HANDLED when overrun if detected Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 13/33] serial: sh-sci: Improve DMA error messages Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 14/33] serial: sh-sci: Improve comments for DMA timeout calculation Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 15/33] serial: sh-sci: Handle DMA init failures inside sci_request_dma() Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 16/33] serial: sh-sci: Use correct device for DMA mapping with IOMMU Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 17/33] serial: sh-sci: Use min_t()/max_t() instead of casts Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 18/33] serial: sh-sci: Switch to dma_map_single() for DMA transmission Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 19/33] serial: sh-sci: Fix TX buffer mapping leak Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 20/33] serial: sh-sci: Use DMA submission helpers instead of open-coding Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 21/33] serial: sh-sci: Switch to generic DMA residue handling Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 22/33] serial: sh-sci: Stop acknowledging DMA transmit completions Geert Uytterhoeven
2015-08-21 18:02 ` Geert Uytterhoeven [this message]
2015-08-21 18:02 ` [PATCH v3 24/33] serial: sh-sci: Do not resubmit DMA descriptors Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 25/33] serial: sh-sci: Fix exclusion of work_fn_rx and sci_dma_rx_complete Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 26/33] serial: sh-sci: Fix race condition between RX worker and cleanup Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 27/33] serial: sh-sci: Pass scatterlist to sci_dma_rx_push() Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 28/33] serial: sh-sci: Use tty_insert_flip_string() for DMA receive Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 29/33] serial: sh-sci: Use incrementing pointers instead of stack array Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 30/33] serial: sh-sci: Fix NULL pointer dereference if HIGHMEM is enabled Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 31/33] serial: sh-sci: Don't call sci_rx_interrupt() on error when using DMA Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 32/33] serial: sh-sci: Don't kick tx in sci_er_interrupt() " Geert Uytterhoeven
2015-08-21 18:02 ` [PATCH v3 33/33] serial: sh-sci: Don't call sci_dma_rx_push() if no data has arrived Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440180177-6924-24-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=g.liakhovetski@gmx.de \
--cc=gregkh@linuxfoundation.org \
--cc=iwamatsu@nigauri.org \
--cc=jslaby@suse.com \
--cc=kazuya.mizuguchi.ks@renesas.com \
--cc=koji.matsuoka.xm@renesas.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-serial@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=wsa@the-dreams.de \
--cc=ykaneko0929@gmail.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).