Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2678419imj; Mon, 11 Feb 2019 06:55:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGxrKQE2vU/ty1f0Yz90clQ0Jho5XYSgwmo7L4lGgsTV1pGclHqj8LsWfT48JYP3HHRzs7 X-Received: by 2002:a17:902:b60e:: with SMTP id b14mr36790672pls.301.1549896919204; Mon, 11 Feb 2019 06:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549896919; cv=none; d=google.com; s=arc-20160816; b=f+jUOkvgDIZfRCFKrX+GYwmNliIxm9PeI4AhrFEq6qoWTgRSCj4Tz6qcchjAgXk88H IEjK3zpfOV3KtlRTUy/RlpkWMMwRM+GE57bsy83s5wntgw1/xPI3rQI/kuA44a3sYd7C I83cyMFmHgtTn9wskhKKcOwIlIFZbT/D+9E9iYJ9obtbuuj6F7Ihupm8OADRmquSCOfg R80eSLI904DFt6lsG4dRzQMYBXxmdwZUW7g9zXvdlw+stVb6/8sS78Swx/tQ+9c+R+VN jLfqFqEqG8KxjGXzT3etAuYWpju8UOKe+a+1BcJ4MV+DjcX0scO4E84xgFDTXF055OU3 Htfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=liW1RkZmlEeGBMotlCHEbfKGuNwl2szy1jZA+N2+U24=; b=scKXRa2flBE87/RFMIbVsbcPRp+u93ESAln2qPwvqyr/6/kPr2JW2aFRxW66kvBD2/ hqK0keeyyORKXTWviwvdZcEUW52RgzoeUeqKP/3oQYCJwA1M/UkxfO7sTa4xmk2wGwoF JHFdjFyGgkFxbAFtQoZE1kgpz2GvjvLfB3sTG4FssTyUljvCfGnEgl+uYjDh1bm5iN5w LVCsmJYxPNdoYutBLywtwphKx98lLJ1+lduUWBzcTYH0oSNlu+S38zzVM/0oMlA4lztE eQpTK5LAiLMQhJmpn4Jh0pwJQ5VTI3Ht9JAhEtXLHmEttpzO73sPzkaK0eYRYAl+z592 nCTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X4+T3RDS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si9378145pgw.380.2019.02.11.06.55.03; Mon, 11 Feb 2019 06:55:19 -0800 (PST) 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=@kernel.org header.s=default header.b=X4+T3RDS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388343AbfBKOyE (ORCPT + 99 others); Mon, 11 Feb 2019 09:54:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:40600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388716AbfBKOx6 (ORCPT ); Mon, 11 Feb 2019 09:53:58 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 63A212229E; Mon, 11 Feb 2019 14:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896837; bh=fUsrkfuueEfaA7jY6DSulXutg5Qs9wqdtVNZYDTHXtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4+T3RDSIxM/mkPwFdf1zbV7kpw/AbJ/rtZTfxGC7tRNGjAmxV8mrqwua6MLZlpXc QsYlFVt8i09s+LB9VRaPJTF4InYAdXDvgoLMigIsHB0u05nf4u69y3rX3HL09gPl4A GzeKYAPZOG7VqRiReA3YnHXv4FPukrnygxBuA/uc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leonid Iziumtsev , Vinod Koul Subject: [PATCH 4.19 290/313] dmaengine: imx-dma: fix wrong callback invoke Date: Mon, 11 Feb 2019 15:19:30 +0100 Message-Id: <20190211141912.470401704@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leonid Iziumtsev commit 341198eda723c8c1cddbb006a89ad9e362502ea2 upstream. Once the "ld_queue" list is not empty, next descriptor will migrate into "ld_active" list. The "desc" variable will be overwritten during that transition. And later the dmaengine_desc_get_callback_invoke() will use it as an argument. As result we invoke wrong callback. That behaviour was in place since: commit fcaaba6c7136 ("dmaengine: imx-dma: fix callback path in tasklet"). But after commit 4cd13c21b207 ("softirq: Let ksoftirqd do its job") things got worse, since possible delay between tasklet_schedule() from DMA irq handler and actual tasklet function execution got bigger. And that gave more time for new DMA request to be submitted and to be put into "ld_queue" list. It has been noticed that DMA issue is causing problems for "mxc-mmc" driver. While stressing the system with heavy network traffic and writing/reading to/from sd card simultaneously the timeout may happen: 10013000.sdhci: mxcmci_watchdog: read time out (status = 0x30004900) That often lead to file system corruption. Signed-off-by: Leonid Iziumtsev Signed-off-by: Vinod Koul Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/dma/imx-dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c @@ -617,7 +617,7 @@ static void imxdma_tasklet(unsigned long { struct imxdma_channel *imxdmac = (void *)data; struct imxdma_engine *imxdma = imxdmac->imxdma; - struct imxdma_desc *desc; + struct imxdma_desc *desc, *next_desc; unsigned long flags; spin_lock_irqsave(&imxdma->lock, flags); @@ -647,10 +647,10 @@ static void imxdma_tasklet(unsigned long list_move_tail(imxdmac->ld_active.next, &imxdmac->ld_free); if (!list_empty(&imxdmac->ld_queue)) { - desc = list_first_entry(&imxdmac->ld_queue, struct imxdma_desc, - node); + next_desc = list_first_entry(&imxdmac->ld_queue, + struct imxdma_desc, node); list_move_tail(imxdmac->ld_queue.next, &imxdmac->ld_active); - if (imxdma_xfer_desc(desc) < 0) + if (imxdma_xfer_desc(next_desc) < 0) dev_warn(imxdma->dev, "%s: channel: %d couldn't xfer desc\n", __func__, imxdmac->channel); }