Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp447529ybb; Wed, 25 Mar 2020 03:04:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvGyBD1G+vsCWnFLShNC+n2d1F74E+25AieDNer3Xu4vl9oAYEIrtAsOa9KTNyhW6Qlmyx2 X-Received: by 2002:a05:6808:c8:: with SMTP id t8mr1803776oic.3.1585130646919; Wed, 25 Mar 2020 03:04:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1585130646; cv=pass; d=google.com; s=arc-20160816; b=Gz30FkK1pOKXJLJNEGb6D+1llNUsx00qnHbGdLsPZ3O30C6H2rJpHv1AZZqQ3OHVjm JhSDVQ6zdtIVUkjdCSMYyeWnUF6ycI4/C5R1HVklRIpAHdF8hFRRF94LAUHQen8U0bN/ 0bBzedPWklafwljIxDpAcsoQRoKEXaTvpW1N9HMMJ9xMjUvapVnKhd4e8i8+pwc7aglW i2Pc75FbMvKQ1R/GJemEGvQj9IRdyb7uqUObo9XZaKawbzWRUVFsFTBQB3RWAAUeoAo5 nnYHD+uMnfk30rv0C2bRNyKQYnKVjQ6I15mk7cKvTMF/UnP/r6s2OrfLa/tfpY6Oj8Tf ZgXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=g4nkXgqwEGwu3C0mhI4fV+lNIIWf2s6jvVCjObQIz68=; b=t9lG9lXHBe0N/Blp0AWRJUHmfoxQ/rL//q51eC2x3VJXNUiRtodB+Fap3FWnAjW0Zd LX7zekuwNgzwhDfDvBJ9/HcHFPP4g6Ka3o9BKShsrfF3fDD2FfKYg+dXYexEV3qv86X3 n1ogMZnEuIX6GI6c3ZJzIOtsjoa3VkysME73cln0AoSqwviSRq+fqHiLGxfG9wQwQ/+H l+v2eIaFi2bND8FPez1XbgjqQ0PsMHOnOgIcZzYVXk+qEhXHf4fjfvsNmSv9XlmDUiCR 80xDwurnhfUn84ltMJeltVnnF9hpxey2gtBpPurcLs2pupcm73ep9zQvhb/infQkw+Yj o4rQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GIKz4C1B; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si10707391oia.257.2020.03.25.03.03.50; Wed, 25 Mar 2020 03:04:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GIKz4C1B; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbgCYKDS (ORCPT + 99 others); Wed, 25 Mar 2020 06:03:18 -0400 Received: from mail-eopbgr30045.outbound.protection.outlook.com ([40.107.3.45]:47872 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726154AbgCYKDS (ORCPT ); Wed, 25 Mar 2020 06:03:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NK1NUQf8uXZklPxWkw5QaNWlP6Q/b8P0CtRFHak8/6z/XRI3/wDb+r7++aQ4uMxQ9yJYYhP5yGoy4+3HzMghgJRP/quSx6/ellxFKXZCxPpQiqGxQ9YuWZwrY0tD2KN6FaIk19skUh5yy6Xq+rNqS7onN5WjiA9SogOpI/GnV/p2A2xX8CzIciJGDttuQBgnUGBrhA5X2eY4vL+GcdSJEkH9l7YCQZbaeioAl9ASCPgL6w06WkEEubKYojxOk9BZEV+0+xd32mzfr9vs7rM9ErFuobkx1QiAcNdd1J+SP9KNi5MWQ8l+i1VvCHdfVYogIdswHGKhxWpJCuGuW4mgkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g4nkXgqwEGwu3C0mhI4fV+lNIIWf2s6jvVCjObQIz68=; b=dXZ3F91TqYp55MAIrdLrtXecW0k0zK1qddEnj/lRTF0CDvf3YCCTwHu6gZTq5/xRAgARbABATKlPr9xB2oduQzDjmi6mNhmAVlxz5TCN1hO8KrTrpop1Tus2yu03ML4Cn+XGEkc2LDhHtdP2VJBe4+LAwsu1VnqiAgF4C8JjJpYuOQRp8vP8f1x1U/rCGUoKhFnEF2DmQR5DTeJq/NmckBHe9hr/MIARiYBoLnmWbJkieTvsboUkNghJIbezFx48Dd9EgxireY0vZXZjFrLtsdX73+xOZDOEalkS3GyBHFnjUcCjGSzhN6OUlHES3LeF1rke11eKLQKrEySSU6Q6ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g4nkXgqwEGwu3C0mhI4fV+lNIIWf2s6jvVCjObQIz68=; b=GIKz4C1Bfp4OByPTwFllga9goP6+6jUuQ4m1IbdPFADu3F5B7mni+s/JEP4HlHIxxVuEe3JrsDn/rRcx6iKJjvU+mRQPSCPZWB+WUaAPNBR4fFiGnwfb9XUa2NaN+dSLyarN383emBY2oAQlxzQWwqKTN77YQk45NXThnO4ZI6M= Received: from VI1PR0402MB3600.eurprd04.prod.outlook.com (52.134.3.146) by VI1PR0402MB3856.eurprd04.prod.outlook.com (52.134.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Wed, 25 Mar 2020 10:03:14 +0000 Received: from VI1PR0402MB3600.eurprd04.prod.outlook.com ([fe80::c991:848b:cc80:2768]) by VI1PR0402MB3600.eurprd04.prod.outlook.com ([fe80::c991:848b:cc80:2768%7]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 10:03:14 +0000 From: Andy Duan To: Michael Walle , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jiri Slaby , Greg Kroah-Hartman , Leonard Crestez Subject: RE: [EXT] [PATCH v2 1/2] tty: serial: fsl_lpuart: move dma_request_chan() Thread-Topic: [EXT] [PATCH v2 1/2] tty: serial: fsl_lpuart: move dma_request_chan() Thread-Index: AQHWAoTFksFC9Hjm7kudzC7IE2Rl+KhZE/PA Date: Wed, 25 Mar 2020 10:03:13 +0000 Message-ID: References: <20200325090658.25967-1-michael@walle.cc> In-Reply-To: <20200325090658.25967-1-michael@walle.cc> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=fugang.duan@nxp.com; x-originating-ip: [119.31.174.68] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b4d6e59f-2adb-45b5-4e5a-08d7d0a3bb82 x-ms-traffictypediagnostic: VI1PR0402MB3856:|VI1PR0402MB3856: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2512; x-forefront-prvs: 0353563E2B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(366004)(376002)(346002)(136003)(39860400002)(396003)(7696005)(86362001)(71200400001)(186003)(478600001)(26005)(6506007)(2906002)(110136005)(9686003)(66946007)(316002)(81166006)(64756008)(66476007)(5660300002)(55016002)(76116006)(54906003)(66556008)(4326008)(8676002)(8936002)(52536014)(33656002)(81156014)(66446008);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB3856;H:VI1PR0402MB3600.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jjv5TcjgXBkckTSUG4KjBd1lOmiBerXpQaG9QgxcloQJYh8a7TiAP8b7pQYWU3tbOKTc9BQXCjHgh2OzPMb7MMOtVG3L2LNAwnFsqB6lFdg4KS1jikia4K73X1bT5ea7yHnokxHhCvSv4fObmyzspNcZBuQBWFr4sFdMbyPhPktMrK/UprWB52r2XaI5oZZ3nATALMQ3nhF59N/SAmfYxMtrChO37v86MYMoSwBc0aI+GXDYANMCeBixLJHrQsJLCl42pH5inL/GYUPMOjagyAfXnBUTp9L0Ads2pXaQJL0Vqb25IsKsgerzSQybsO9rVjfPEGynwK8lG9sm/qLOzV3qTFhBVpkDhozfQjCjbB4ZclRtuFldo4waIkG6obJ3QyIrhjy5hmeAdvpxVnBZ16qMwpccHmaKmMeRJLK/3USshimY5Spc86li4qHOZXCm x-ms-exchange-antispam-messagedata: H4ftV4Yd9OCE92T01SpXakxxVXRxEyaeQRtbjTL4dj2PWjvz5FXGc++XgvROhOPExiUbFbGNVbDBYHY2Bnr/3TKZQl4jWAV69YfEka5BHerrnJYcs3+FrqxD9/R79qC8jyX0fUkS3A2qZb8/OJWQkw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4d6e59f-2adb-45b5-4e5a-08d7d0a3bb82 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2020 10:03:13.8681 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Y9Hcio84Kg5J8P7DAghKKw43jDaNB1ReIczzziLyU+wmItUvc5HHQ29IX2QapRA+Pae4kkr4fWCRuGo2pvc62w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3856 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Walle Sent: Wednesday, March 25, 2020 5:07= PM > Move dma_request_chan() out of the atomic context. First this call should= not > be in the atomic context at all and second the > dev_info_once() may cause a hang because because the console takes this > spinlock, too. >=20 > Fixes: 159381df1442f ("tty: serial: fsl_lpuart: fix DMA operation when us= ing > IOMMU") > Reported-by: Leonard Crestez > Signed-off-by: Michael Walle Reviewed-by: Fugang Duan > --- > changes since v1: > - instead of just moving the dev_info_once() out of the spinlock protect= ed > section, move the whole dma_request_chan(). Thanks Andy! >=20 > I've tested this on my board. Andy, Leonard, can you double check it? For= all > which are not aware, this deadlock happens only if you have the kernel > console output on the lpuart, so if someone wants to test it, make sure y= ou > have something like console=3DttyLP0,115200. >=20 > drivers/tty/serial/fsl_lpuart.c | 36 +++++++++++++++++++++------------ > 1 file changed, 23 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpu= art.c index > 9c6a018b1390..131018979b77 100644 > --- a/drivers/tty/serial/fsl_lpuart.c > +++ b/drivers/tty/serial/fsl_lpuart.c > @@ -1510,20 +1510,33 @@ static void rx_dma_timer_init(struct lpuart_port > *sport) > add_timer(&sport->lpuart_timer); } >=20 > -static void lpuart_tx_dma_startup(struct lpuart_port *sport) > +static void lpuart_request_dma(struct lpuart_port *sport) > { > - u32 uartbaud; > - int ret; > - > sport->dma_tx_chan =3D dma_request_chan(sport->port.dev, "tx"); > if (IS_ERR(sport->dma_tx_chan)) { > dev_info_once(sport->port.dev, > "DMA tx channel request failed, > operating without tx DMA (%ld)\n", > PTR_ERR(sport->dma_tx_chan)); > sport->dma_tx_chan =3D NULL; > - goto err; > } >=20 > + sport->dma_rx_chan =3D dma_request_chan(sport->port.dev, "rx"); > + if (IS_ERR(sport->dma_rx_chan)) { > + dev_info_once(sport->port.dev, > + "DMA rx channel request failed, > operating without rx DMA (%ld)\n", > + PTR_ERR(sport->dma_rx_chan)); > + sport->dma_rx_chan =3D NULL; > + } > +} > + > +static void lpuart_tx_dma_startup(struct lpuart_port *sport) { > + u32 uartbaud; > + int ret; > + > + if (!sport->dma_tx_chan) > + goto err; > + > ret =3D lpuart_dma_tx_request(&sport->port); > if (!ret) > goto err; > @@ -1549,14 +1562,8 @@ static void lpuart_rx_dma_startup(struct > lpuart_port *sport) { > int ret; >=20 > - sport->dma_rx_chan =3D dma_request_chan(sport->port.dev, "rx"); > - if (IS_ERR(sport->dma_rx_chan)) { > - dev_info_once(sport->port.dev, > - "DMA rx channel request failed, > operating without rx DMA (%ld)\n", > - PTR_ERR(sport->dma_rx_chan)); > - sport->dma_rx_chan =3D NULL; > + if (!sport->dma_rx_chan) > goto err; > - } >=20 > ret =3D lpuart_start_rx_dma(sport); > if (ret) > @@ -1592,6 +1599,8 @@ static int lpuart_startup(struct uart_port *port) > sport->rxfifo_size =3D UARTFIFO_DEPTH((temp >> > UARTPFIFO_RXSIZE_OFF) & >=20 > UARTPFIFO_FIFOSIZE_MASK); >=20 > + lpuart_request_dma(sport); > + > spin_lock_irqsave(&sport->port.lock, flags); >=20 > lpuart_setup_watermark_enable(sport); > @@ -1649,11 +1658,12 @@ static int lpuart32_startup(struct uart_port > *port) > sport->port.fifosize =3D sport->txfifo_size; > } >=20 > + lpuart_request_dma(sport); > + > spin_lock_irqsave(&sport->port.lock, flags); >=20 > lpuart32_setup_watermark_enable(sport); >=20 > - > lpuart_rx_dma_startup(sport); > lpuart_tx_dma_startup(sport); >=20 > -- > 2.20.1