From patchwork Thu May 17 11:37:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 136141 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp78991lji; Thu, 17 May 2018 04:37:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqp8PuKsMF2WjjpRi2hbyFT4OeKNdg6/wiJAXpnz0urjv39ksEYtGZqMrnF21s6pTt3dKor X-Received: by 2002:a63:755a:: with SMTP id f26-v6mr3950745pgn.30.1526557050779; Thu, 17 May 2018 04:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526557050; cv=none; d=google.com; s=arc-20160816; b=AyrgfvKOKyu3vYUSM2GOOFnla0lltfRX09GWlPaj0bSMKyw9yElVovUWqKpBY6/WC7 LMKTCTdIIMAEmqMwdQHXJt8P3UxjeIyV5jcSMHFNk6j13/N4lhiwWNkeRp0w5lEpn2rC jNeLkavH0q3536X/qcrjQBF0UeaNXfcuinsNhNQUjV+lr3en9HDs6OjFjmeoieY4ZgqZ 1mQE6M/kPHLGZFBZbqANt24xXKUPDjieRmJP9BEhcWCNSd/44gBJUWjb192ChkShBkqf JQ6P9wil/YKfH8KAzXsbikqItkM63sRwIxHFenZdU5nT5LHPVkrvLRUVYwl6gkSptLH5 q1lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=iycoJaJ4mHJoCWwlISzTtiI0HzNtY54T4oKP8dk0vgw=; b=di4A7VoqcpvIZr9lCwS7JeTW2qG0txK94PZtkkz6J2s26gx67yKNKIzYd6XMJW9ixw K1hwMzBJ0L8MUHt6q68gTN0YO2GydOGDUJy1fImUu+4E412Cs81HM3vaGyUWS1UR5/ND /ilGff+RWZtlX27r4r4EU6I6QCUTRzvxppYZ+2k+eSiL0+URqh5YjHhWzUKGIhB5wFin PtTcaDKhqsZfaaMvklRZRXaV5/5C169CCzdrFUZ60NodAA/zsigoxEIV7OssNGq1YHTm KI+OUbtR/r1RtCp+ZJEHHtG/SJ6fACNvCXnfu8nDH15ts+6nKFCP0tkxhLDRYNgyMr2R Eh8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=DmrCkEgx; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5-v6si4656470plj.86.2018.05.17.04.37.30; Thu, 17 May 2018 04:37:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=DmrCkEgx; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbeEQLh3 (ORCPT + 2 others); Thu, 17 May 2018 07:37:29 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59281 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbeEQLh2 (ORCPT ); Thu, 17 May 2018 07:37:28 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180517113726euoutp01b8d996fca83618a868ce2ece89ebdb79~va4uqcSG41995919959euoutp01j; Thu, 17 May 2018 11:37:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180517113726euoutp01b8d996fca83618a868ce2ece89ebdb79~va4uqcSG41995919959euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526557046; bh=v1+5u68E1OHMtheF3vtJFdGfWEAcLlRk/HbxMjksB5o=; h=From:To:Cc:Subject:Date:References:From; b=DmrCkEgxVH1DLdNLihHaLpR6KPTg2Hl4ePcSYd/M7WLgwr5XfaZrJjmYU8at/Gth2 ZFAN4SCdca/KBsSvE7fFS63M2bLMVVuY9rhpPSPo0VICWERAAS1IEbaJsOWt1klh+T 6tTYRMjApGtB+1FDeOBr86NmK+vYxd/k9tXRqqJQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180517113724eucas1p15dca6f3746a3040a537096a887720c96~va4tXSrlB3265732657eucas1p16; Thu, 17 May 2018 11:37:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 29.9D.17380.4796DFA5; Thu, 17 May 2018 12:37:24 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180517113723eucas1p2a0c3519fb85c581951c43f0d3a5e7563~va4sKOwhr3242732427eucas1p2m; Thu, 17 May 2018 11:37:23 +0000 (GMT) X-AuditID: cbfec7f4-6f9ff700000043e4-57-5afd6974ff80 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1E.F5.04183.3796DFA5; Thu, 17 May 2018 12:37:23 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P8V002CXEY8IV50@eusync1.samsung.com>; Thu, 17 May 2018 12:37:23 +0100 (BST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman Subject: [PATCH v2] serial: samsung: check DMA engine capabilities before using DMA mode Date: Thu, 17 May 2018 13:37:14 +0200 Message-id: <20180517113714.8380-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRmVeSWpSXmKPExsWy7djP87olmX+jDKYeFrXYOGM9q0Xz4vVs FufPb2C3mHF+H5PFmcW97BZrj9xltzj8pp3Vgd1j06pONo/9c9ewe/RtWcXo8XmTXABLFJdN SmpOZllqkb5dAlfGifaf7AX/pCrOP73H3MA4UayLkZNDQsBE4v+sZSxdjFwcQgIrGCUOHj3P CuF8ZpQ49+MfUxcjB1jVixMpEPFljBJHv15mhHAamCQ+HGxmBRnFJmAo0fW2iw3EFhFwlph9 diETSBGzwAdGiYXrXzODJIQFoiRev/0IVsQioCrxaXInWDOvgI3E8e7/rBA3yUs8mz6PHaRZ QuAlq8T+X3sZIc5wkfh0QB2iRlji1fEt7BC2jMTlyd0sEHa9RN/3I0wQvT2MEntbpjJBJKwl Dh+/CLaAWYBPYtK26cwQM3klOtqEIEo8JE4sb2GDsB0lVuzbA2YLCcRKXPl4kWUCo+QCRoZV jOKppcW56anFRnmp5XrFibnFpXnpesn5uZsYgVF3+t/xLzsYd/1JOsQowMGoxMO7w/pPlBBr YllxZe4hRgkOZiURXpMvQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8cRp1UUIC6YklqdmpqQWp RTBZJg5OqQbG5dGHG7e6Wvy6F+PUcPfKReF1H5Z7yMrJHn2XkbP4/YU1bIutK7rsfURmKXze 9uLwG5kVZR9PCGxvVV7ygfXDcs2HMRKefK86N27MyMq7vH52ypunno0fbhckTDtyKENyldzO nnBfkfNbVAOiubULNwoIrGu4kdh6y9+I5w33S9HH/BrWycoLlFiKMxINtZiLihMBkFcUtbYC AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFJMWRmVeSWpSXmKPExsVy+t/xy7rFmX+jDH6dU7HYOGM9q0Xz4vVs FufPb2C3mHF+H5PFmcW97BZrj9xltzj8pp3Vgd1j06pONo/9c9ewe/RtWcXo8XmTXABLFJdN SmpOZllqkb5dAlfGifaf7AX/pCrOP73H3MA4UayLkYNDQsBE4sWJlC5GLg4hgSWMEm+Pf2KD cJqYJNbvecncxcjJwSZgKNH1tosNxBYRcJaYfXYhE0gRs8AnRomWRdcYQRLCAlESFxbOALNZ BFQlPk3uZAWxeQVsJI53/wezJQTkJZ5Nn8c+gZFrASPDKkaR1NLi3PTcYiO94sTc4tK8dL3k /NxNjMAQ2Hbs55YdjF3vgg8xCnAwKvHw7rD+EyXEmlhWXJl7iFGCg1lJhNfkC1CINyWxsiq1 KD++qDQntfgQozQHi5I473mDyighgfTEktTs1NSC1CKYLBMHp1QD46K9d6dNOixcZeXYp2lQ /dFk8/+YrVUJOn8+/HJ/GK23jktiXtPxXexRt10OJDZMsns+7fVjXUGtoIM8kq8/Mb63/l9w 212md4t85HzV49onz3JL3fm1RVL3kL5yS4112rsbHLu3nU38ycy2bX/6oupXj58GWK3c2F7F tfG87txJXIUTz//4N0+JpTgj0VCLuag4EQArVba//QEAAA== X-CMS-MailID: 20180517113723eucas1p2a0c3519fb85c581951c43f0d3a5e7563 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180517113723eucas1p2a0c3519fb85c581951c43f0d3a5e7563 X-RootMTR: 20180517113723eucas1p2a0c3519fb85c581951c43f0d3a5e7563 References: Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org DMA engine driver might not always provide all the features needed by serial driver to properly operate in DMA mode, so check that before selecting DMA mode. Signed-off-by: Marek Szyprowski --- v2: - added warnings with exact reason for not using DMA mode --- drivers/tty/serial/samsung.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 64e96926f1ad..2f8fa184aafa 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -856,6 +856,8 @@ static void s3c24xx_serial_break_ctl(struct uart_port *port, int break_state) static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) { struct s3c24xx_uart_dma *dma = p->dma; + struct dma_slave_caps dma_caps; + const char *reason = NULL; int ret; /* Default slave configuration parameters */ @@ -871,17 +873,37 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) dma->rx_chan = dma_request_chan(p->port.dev, "rx"); - if (IS_ERR(dma->rx_chan)) - return PTR_ERR(dma->rx_chan); + if (IS_ERR(dma->rx_chan)) { + reason = "DMA RX channel request failed"; + ret = PTR_ERR(dma->rx_chan); + goto err_warn; + } + + ret = dma_get_slave_caps(dma->rx_chan, &dma_caps); + if (ret < 0 || + dma_caps.residue_granularity < DMA_RESIDUE_GRANULARITY_BURST) { + reason = "insufficient DMA RX engine capabilities"; + ret = -EOPNOTSUPP; + goto err_release_rx; + } dmaengine_slave_config(dma->rx_chan, &dma->rx_conf); dma->tx_chan = dma_request_chan(p->port.dev, "tx"); if (IS_ERR(dma->tx_chan)) { + reason = "DMA TX channel request failed"; ret = PTR_ERR(dma->tx_chan); goto err_release_rx; } + ret = dma_get_slave_caps(dma->tx_chan, &dma_caps); + if (ret < 0 || + dma_caps.residue_granularity < DMA_RESIDUE_GRANULARITY_BURST) { + reason = "insufficient DMA TX engine capabilities"; + ret = -EOPNOTSUPP; + goto err_release_tx; + } + dmaengine_slave_config(dma->tx_chan, &dma->tx_conf); /* RX buffer */ @@ -896,6 +918,7 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf, dma->rx_size, DMA_FROM_DEVICE); if (dma_mapping_error(p->port.dev, dma->rx_addr)) { + reason = "DMA mapping error for RX buffer"; ret = -EIO; goto err_free_rx; } @@ -904,6 +927,7 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf, UART_XMIT_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(p->port.dev, dma->tx_addr)) { + reason = "DMA mapping error for TX buffer"; ret = -EIO; goto err_unmap_rx; } @@ -919,6 +943,9 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) dma_release_channel(dma->tx_chan); err_release_rx: dma_release_channel(dma->rx_chan); +err_warn: + if (reason) + dev_warn(p->port.dev, "%s, DMA will not be used\n", reason); return ret; } @@ -1037,8 +1064,6 @@ static int s3c64xx_serial_startup(struct uart_port *port) if (ourport->dma) { ret = s3c24xx_serial_request_dma(ourport); if (ret < 0) { - dev_warn(port->dev, - "DMA request failed, DMA will not be used\n"); devm_kfree(port->dev, ourport->dma); ourport->dma = NULL; }