Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp512895lqb; Wed, 17 Apr 2024 03:15:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0Ky5uKp/QZOdI3tCXAb8i+UnM/1q19GXpWubp/S5xu4UHIkxhSjEu5PPChQj1mJAZwoZ95hFpUIaIzFqa5SVln+zjXNkJW5wAQffEKQ== X-Google-Smtp-Source: AGHT+IFxwIVytZ1y/NUIt8H9r5kehjVhhLnPV4d2fUhPT9RjlwRh8MNsv2XT2cg0/QJA8ct9jfE2 X-Received: by 2002:a05:6871:d082:b0:233:f93b:cd24 with SMTP id mw2-20020a056871d08200b00233f93bcd24mr13232999oac.59.1713348940867; Wed, 17 Apr 2024 03:15:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713348940; cv=pass; d=google.com; s=arc-20160816; b=qCMr2M+WW/joCB/p4UL07pnhTel3S4s64oMyolqNDEkUZcx6qutJjibXLp8zizNELE ElpvhTgG5JAYLWTE9gsgVbMiSdVPpJPuFlBqgYtmxIbjoOWxFkbRzYHSqm5COE6u4mfK VizeMvyIkN/WVZCFNH63T2dtzxjyrkWzMskzGt4AmggU7gMIC48E4ZBUUvdyGfzwJngx ueW0zjuN0K+SnoeCf2oVMUMkJkgPWd7bKeIqYuFaPogZHwQ264VukxdZCYiMOBqUsEOG K8yjvatjEAlze/4AUTjJYpYN0qsRMGx8KXXd+I4ysecxZH6O7boMsRTlSDa6BiSfm89m 5aGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:content-transfer-encoding:in-reply-to:from :content-language:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-filter; bh=27ileZGHOYtN9nZgq/UWvP1r9Ik0Fxmy7wJboV6E4CA=; fh=9kb7XvmYHViIRK1l/9SKeNovLfHwTB3ZKeL9uz6et1E=; b=AJlH7qliMtscS5CNlNnTLaEmWE3Q4wlOmtvrovk+MGUFyy0nrkDMgElyU7Ts56MujC yzVV+LT4u5NQIOkiZWar4SJdAmdJ6LAJc6rSeHkWFUwxrqX0L3q2RSMJof3RDc88vZgL ZNW0Qtk+bD6I8ForK1JrBbJcb9nTF62QV5mDyNZt2EhqE0yyQZ6QZko4RA580bB6OucF 83mLDDgFfeGxWjq040geUVHS2v3jHnfFSXW8+OGI3TVKfZEMrD1jdovr5FMgTd+Qzjdj SBueBIO8r1MqEHPXqjzse8YE6dtsG0G/YiCtX1bYdieZAqamxlv7e+rzjX0cAvtZDC9w OwmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=cIdFVddK; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-148297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q14-20020a65624e000000b005ee3f1a2d57si11073324pgv.885.2024.04.17.03.15.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 03:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=cIdFVddK; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-148297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7CA322833DA for ; Wed, 17 Apr 2024 10:15:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8739813AD34; Wed, 17 Apr 2024 10:15:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="cIdFVddK" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8046D13AD22 for ; Wed, 17 Apr 2024 10:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713348924; cv=none; b=RKnbjTS7eDD5mMGz2QSOfLfZRYNYUDroROZo3yMyiSTQmOLVf95zILvCM3xnbBG4L/pCrI2YSujxNncr6ja/BQB7TCpFKbZl/DS4BdDO9vmzCtTUSi1uGMx1zPMnWl5MW7drSokfEDvrJpH8WH4BjfMcUbg9nabo7h97oIfB9Cg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713348924; c=relaxed/simple; bh=fv5yPdVJiGS5NXE2yj0uhfJpuUPlFc72Nbeee8OJh/U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=ZKjY6MT2AubOcJBK9H3x8+3gdPnU4uFH4Es7FKMPRKB7vFfdooTIrafTRby7mBz45cUf4cXFOyd/O+tADEy3Cv4gJ/K3YXkBzZ2/vWstvJF0WG9WWfzyaObWH4wtE9e0J2a9sGazYS2ZtfrAMJl6upILmmkmdwCerICDITminCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=cIdFVddK; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240417101514euoutp02331bc278fca379a7072077e3d5314656~HCcKox3qY1053510535euoutp02g for ; Wed, 17 Apr 2024 10:15:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240417101514euoutp02331bc278fca379a7072077e3d5314656~HCcKox3qY1053510535euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1713348914; bh=27ileZGHOYtN9nZgq/UWvP1r9Ik0Fxmy7wJboV6E4CA=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=cIdFVddK5hwyQtRUY0GZJDPFDCXuchBE3y3vQGGGEDgSwi5jsHnhOcjZPHBjuAQdH 6o6tYAh1h7H9c2G3sANNz1K35uoHN+S4noifChW+UOsTdpiqh8WEAnd/juhrDcK0QH ENGQe200S6Zh1+bvlQuWYiZNdi1EExLa1CWKAZ0k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240417101514eucas1p10651fb4252d053df51c3592d50e9015f~HCcKUWcw01830918309eucas1p1r; Wed, 17 Apr 2024 10:15:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8F.D6.09624.231AF166; Wed, 17 Apr 2024 11:15:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240417101514eucas1p2b86c86cfe435dec8708bbdc7d04ab963~HCcKBUFOp2346623466eucas1p2t; Wed, 17 Apr 2024 10:15:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240417101514eusmtrp1b68b48086571f7fa320e5f0f1c0beea9~HCcKAnSma2051020510eusmtrp1Q; Wed, 17 Apr 2024 10:15:14 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-fc-661fa132ddd7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 14.D4.09010.231AF166; Wed, 17 Apr 2024 11:15:14 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240417101513eusmtip2de89af895e989e9365557b692c1f92ba~HCcJmJCBu1775617756eusmtip2O; Wed, 17 Apr 2024 10:15:13 +0000 (GMT) Message-ID: <0335b679-da36-42c1-a1ba-8affb7a98d44@samsung.com> Date: Wed, 17 Apr 2024 12:15:13 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 11/15] tty: msm_serial: use dmaengine_prep_slave_sg() To: Jiri Slaby , gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , linux-arm-msm@vger.kernel.org, Anders Roxell Content-Language: en-US From: Marek Szyprowski In-Reply-To: <54679d54-3957-489d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sww6NunVtc7LIE+xZP144mDjmpTwWpPB9XmrBMbUqXf5Twa/vbH+5Hpl4V uWf5PtTeYL0SS3FGoqEWc1FxIgBMvz4WQAMAAA== X-CMS-MailID: 20240417101514eucas1p2b86c86cfe435dec8708bbdc7d04ab963 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20240415211716eucas1p10050cc8d4024707dd6f6331111cd3ce1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240415211716eucas1p10050cc8d4024707dd6f6331111cd3ce1 References: <20240405060826.2521-1-jirislaby@kernel.org> <20240405060826.2521-12-jirislaby@kernel.org> <54679d54-3957-489d-a8b5-b98ea1c8a93c@kernel.org> Hi Jiri, On 16.04.2024 12:23, Jiri Slaby wrote: > On 15. 04. 24, 23:17, Marek Szyprowski wrote: >> On 05.04.2024 08:08, Jiri Slaby (SUSE) wrote: >>> This is a preparatory for the serial-to-kfifo switch. kfifo understands >>> only scatter-gatter approach, so switch to that. >>> >>> No functional change intended, it's just dmaengine_prep_slave_single() >>> inline expanded. >>> >>> And in this case, switch from dma_map_single() to dma_map_sg() too. >>> This >>> needs struct msm_dma changes. I split the rx and tx parts into an >>> union. >>> TX is now struct scatterlist, RX remains the old good phys-virt-count >>> triple. >>> >>> Signed-off-by: Jiri Slaby (SUSE) >>> Cc: Bjorn Andersson >>> Cc: Konrad Dybcio >>> Cc: linux-arm-msm@vger.kernel.org >> >> I've just found that this patch broke UART operation on DragonBoard >> 410c. I briefly checked and didn't notice anything obviously wrong here, >> but the board stops transmitting any data from its serial port after the >> first message. I will try to analyze this issue a bit more tomorrow. > > I double checked, but I see no immediate issues in the patch too. So > please, if you can analyze this more… I've spent some time digging into this issue and frankly speaking I still have no idea WHY it doesn't work (or I seriously mixed something in the scatterlist principles). However I found a workaround to make it working. Maybe it will help a bit guessing what happens there. Here is a workaround: diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index ae7a8e3cf467..fd3f3bf03f33 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -169,6 +169,7 @@ struct msm_dma {                 } rx;                 struct scatterlist tx_sg;         }; +       int                     mapped;         dma_cookie_t            cookie;         u32                     enable_bit;         struct dma_async_tx_descriptor  *desc; @@ -278,6 +279,7 @@ static void msm_stop_dma(struct uart_port *port, struct msm_dma *dma)                 if (dma->dir == DMA_TO_DEVICE) {                         dma_unmap_sg(dev, &dma->tx_sg, 1, dma->dir);                         sg_init_table(&dma->tx_sg, 1); +                       dma->mapped = 0;                 } else                         dma_unmap_single(dev, dma->rx.phys, mapped, dma->dir);         } @@ -434,7 +436,7 @@ static void msm_start_tx(struct uart_port *port)         struct msm_dma *dma = &msm_port->tx_dma;         /* Already started in DMA mode */ -       if (sg_dma_len(&dma->tx_sg)) +       if (dma->mapped)                 return;         msm_port->imr |= MSM_UART_IMR_TXLEV; @@ -462,7 +464,7 @@ static void msm_complete_tx_dma(void *args)         uart_port_lock_irqsave(port, &flags);         /* Already stopped */ -       if (!sg_dma_len(&dma->tx_sg)) +       if (!dma->mapped)                 goto done;         dmaengine_tx_status(dma->chan, dma->cookie, &state); @@ -481,6 +483,7 @@ static void msm_complete_tx_dma(void *args)         count = sg_dma_len(&dma->tx_sg) - state.residue;         uart_xmit_advance(port, count);         sg_init_table(&dma->tx_sg, 1); +       dma->mapped = 0;         /* Restore "Tx FIFO below watermark" interrupt */         msm_port->imr |= MSM_UART_IMR_TXLEV; @@ -522,6 +525,7 @@ static int msm_handle_tx_dma(struct msm_port *msm_port, unsigned int count)         dma->desc->callback_param = msm_port;         dma->cookie = dmaengine_submit(dma->desc); +       dma->mapped = 1;         ret = dma_submit_error(dma->cookie);         if (ret)                 goto unmap; @@ -549,6 +553,7 @@ static int msm_handle_tx_dma(struct msm_port *msm_port, unsigned int count)  unmap:         dma_unmap_sg(port->dev, &dma->tx_sg, 1, dma->dir);         sg_init_table(&dma->tx_sg, 1); +       dma->mapped = 0;         return ret;  } Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland