From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E387FC2D0D1 for ; Thu, 19 Dec 2019 19:07:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB1F6222C2 for ; Thu, 19 Dec 2019 19:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576782462; bh=9VgY9uAw+B4n+nnd8eSFFEsf1v/B0bH+Lg+Anl+pMB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Pe1IrzyR0sNueYpQZCqD++YHrvkFzj2OhLYB7Xkfvxl1ihWGkN5uuygPFYmDa97dN CmLt2UiFGYYQETOrdvd4/9oMy7dpkkxgoinjIZ3Oe+qIjYKkmBMc8u1V5yHgqmcCxE hgYAqC41q6SlRrrEZyyb75UfsKsh0MKGkv0eM1PM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728753AbfLSSmy (ORCPT ); Thu, 19 Dec 2019 13:42:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:34316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728465AbfLSSmx (ORCPT ); Thu, 19 Dec 2019 13:42:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F3EB24672; Thu, 19 Dec 2019 18:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780972; bh=9VgY9uAw+B4n+nnd8eSFFEsf1v/B0bH+Lg+Anl+pMB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0HnRasWh2dy+at2zaIcYJ6xPB3GJjnpys/mVTNBuo6box07x1XNNdfyWP6KzNXqs 5uTS/IJmI9sP8DlEWEtbTnkWjtWuEIbxeM7PWeBj70zeNV4HQNBquMgrS89WedrBYq 2WDCcdMuUMFa2DQ3tPDZlovpqX0HRpxao48+uQJA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan Subject: [PATCH 4.9 003/199] tty: serial: fsl_lpuart: use the sg count from dma_map_sg Date: Thu, 19 Dec 2019 19:31:25 +0100 Message-Id: <20191219183214.838507230@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183214.629503389@linuxfoundation.org> References: <20191219183214.629503389@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Peng Fan commit 487ee861de176090b055eba5b252b56a3b9973d6 upstream. The dmaengine_prep_slave_sg needs to use sg count returned by dma_map_sg, not use sport->dma_tx_nents, because the return value of dma_map_sg is not always same with "nents". When enabling iommu for lpuart + edma, iommu framework may concatenate two sgs into one. Fixes: 6250cc30c4c4e ("tty: serial: fsl_lpuart: Use scatter/gather DMA for Tx") Cc: Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/1572932977-17866-1-git-send-email-peng.fan@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/fsl_lpuart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -346,8 +346,8 @@ static void lpuart_dma_tx(struct lpuart_ } sport->dma_tx_desc = dmaengine_prep_slave_sg(sport->dma_tx_chan, sgl, - sport->dma_tx_nents, - DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT); + ret, DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT); if (!sport->dma_tx_desc) { dma_unmap_sg(dev, sgl, sport->dma_tx_nents, DMA_TO_DEVICE); dev_err(dev, "Cannot prepare TX slave DMA!\n");