Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21005885ybl; Sun, 5 Jan 2020 17:19:39 -0800 (PST) X-Google-Smtp-Source: APXvYqw89e+v+Qam2pv63CRzMdBEpq4IDizrf1e731uu62/LGzhQN5VE9tMDwRUN9r376NAadMcR X-Received: by 2002:a9d:74c7:: with SMTP id a7mr116645587otl.7.1578273579584; Sun, 05 Jan 2020 17:19:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578273579; cv=none; d=google.com; s=arc-20160816; b=RFONJ9y/ZI2JHKPY/UPqgJxwV4c2iTqdSbpRMWMTwWKiGjiPuWGhnkDZ2t5QrgoIQC gP/cZe+DPUoTytdkbAx37mqwdlmS+OmlSXHW5njpRliadABkoagIu+y5DXTp9cY8LHgq X3VkMVAuOxxVsuuwtiVtjlOWlVPeBIx9p8W7l1+ziNVIY55NeFlww+KxCv+c8S/1QKRB /zlfzeSVwplZpuBrTUJe3/xmUSfYtIiaEDbaVCSbzNXZvr4cin5afmecCizexJy6Ah1C lnCa9iqB1uig/EsiMs2m0sEH2DVg0GK9Pmq4MracjHifftda4C7cu05cIxaxv8rdxf3k UwSQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PqNp1UdCqeyiLALCUBHMvdBWRB+JgxkXykXZjY6I1uo=; b=dRTOzNzk7sbPd+GgLZafJN7BXEVYoM6ksfAJ/r4cAh90vwvU9baSABXTAXDfINjmvK mRFduomlWVJF0Jp5KtTgqGcDaJzOs4lS6Dl+HFPDKqDkFTD7XEW9VauKuWJ0CDT9x4Ty Q7wxF3JpLZCQHEmXGDAxsbJTEz7lgR+g33sK5dsjmmAXk7GncQpAi9zCpg+ZTJXPQHlO T5qixbJ15M3DOBL7Y/vygs8FvijIWpDNL3hltfCGNm3AeLBQ0K4wN7p4dH9CFK65gWQ4 tjqE0v3kom40e2VvdgZfK3GQkbQOqyvJpE2kJ7I9UnDSVlUY680ubDkLIMrIVHcAMigt MyYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tQMIeYZS; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si32973241otf.285.2020.01.05.17.19.27; Sun, 05 Jan 2020 17:19:39 -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=@gmail.com header.s=20161025 header.b=tQMIeYZS; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgAFBSH (ORCPT + 99 others); Sun, 5 Jan 2020 20:18:07 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46705 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbgAFBR2 (ORCPT ); Sun, 5 Jan 2020 20:17:28 -0500 Received: by mail-lf1-f67.google.com with SMTP id f15so35286888lfl.13; Sun, 05 Jan 2020 17:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PqNp1UdCqeyiLALCUBHMvdBWRB+JgxkXykXZjY6I1uo=; b=tQMIeYZSkToGF6IJkOekvw6u5tCQsNIXAfZ/9TpuCG721oFTlzA6XNgIOlv4IqLDl9 JDIMPtndCK0LMXEs8mwiEoaemrsPoTC7EPGwCwQ7cnK5WvsUR+QGa5rjQomB4vQld2WJ c0E4WnMFCA+3eLMLgQ8gavW3dnqTgidaM/9EYzWjkgGC4/4whvrv3iB9Lcz/dcTICL3Y ZLj3iFAN9iOPBCL9mdWRw6nJ3WjWFBpI/s/dTXfpApl17eR3Lq97hAWUD6YZzoANEdC/ 1B/Ykt92HLZ0guAmkeUZp0urH7oTMjSl3fVYMhHDVDy3easer8D5a4XjxWRRkvlSR/Fb LSng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PqNp1UdCqeyiLALCUBHMvdBWRB+JgxkXykXZjY6I1uo=; b=kQSgyrZ6AwjBHEsSJ1gIBE67snOolXLIem5tbRwqEmlWuaAmsT0tqAjR24SVscinj9 aszX5jl6UDgurCuCPMlbBeQCl+3Ja+1QZgGCMjipkZIdRs87lIE+GuuMbsU44/JKrHKm 9CHU7TQLuiUQOoAGejZUITMjImH+fqyrudVmOqSxm/4Nsjj400SIWQEEFZName2lagG8 kxSWLJPyqCYOsdDz4YUHj5B7mtn+JQ5s6SSKfBM7qozVD0sVvpDHQHifHq8fEaMg19TT 8uHdr4Fc01GSnojrHo5bLfLcVfXgDfmV1OIGcprUBPedswLnVAcvPcF1Yh7k4nDqcVUj EG7w== X-Gm-Message-State: APjAAAWHsObD5tkMYsAGIfjTD8INYAwODFdtshT1hkAmKuW0VWTZJL2z KJpYYVCprvQsg/f7zmlhTI0= X-Received: by 2002:ac2:5ec3:: with SMTP id d3mr55630899lfq.176.1578273445929; Sun, 05 Jan 2020 17:17:25 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id y14sm28353271ljk.46.2020.01.05.17.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:25 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/13] dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list Date: Mon, 6 Jan 2020 04:17:00 +0300 Message-Id: <20200106011708.7463-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interrupt handler puts a half-completed DMA descriptor on a free list and then schedules tasklet to process bottom half of the descriptor that executes client's callback, this creates possibility to pick up the busy descriptor from the free list. Thus let's disallow descriptor's re-use until it is fully processed. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 1b8a11804962..aafad50d075e 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -281,7 +281,7 @@ static struct tegra_dma_desc *tegra_dma_desc_get( /* Do not allocate if desc are waiting for ack */ list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) { - if (async_tx_test_ack(&dma_desc->txd)) { + if (async_tx_test_ack(&dma_desc->txd) && !dma_desc->cb_count) { list_del(&dma_desc->node); spin_unlock_irqrestore(&tdc->lock, flags); dma_desc->txd.flags = 0; -- 2.24.0