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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 EAC44C433B4 for ; Fri, 23 Apr 2021 01:22:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DB42613CB for ; Fri, 23 Apr 2021 01:22:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DB42613CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=imgtec.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IoxA7R0UMRqa2b+FtgYBEyNdncJ6NmXZ8biZBUc2giQ=; b=ItLmr204JZhAjSo7sOJiOEudP vEvrLvkp9fg/ToNZfja8qmOm35g3h+7pEfpykY8UET75gNN+3f8tCQnN10DyyPwa83Q4MBqcT6DhF w5F2zBTI401ftqr0mNKw8d7JJ/9vqwxSxyd8T/sJp+CZdIfqoxNMhXWSIWDqVBQ9o+7w8V2g1DQbo XATjrfAsoIiONPP9C3a/gPCjU/CKeN280q3eJwEzBWCLE9e6ELvpVe61g11Mk9whpY8by4xTy45ke gq2nC/vnPoobPkiHnfYN4fua3sKrTCQDweJKCf3Gegn8mGzxezrFCU+P0iOV9uxzPLMpuXyx/S2Zy o21+eEX0g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZkUM-000FZL-Sd; Fri, 23 Apr 2021 01:20:11 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZkTr-000FWP-Sl for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 01:19:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=knSJFN6woQoqRmSWeKpa/mjHq3c7kZoaJanH8t7euhQ=; b=2MQDwlx344bNXW6glvX43JMFW+ W4/3TzB2gKIaP/7jaVqeUbMO0kp7LQuAKfDrq4CG16TmI4YBw/iuh/kN9LHNzc2PjRMHQMC35WtHo TVo8axy/E6JS9A9u1Itpo8IF/K5MAGBfQdUQ0VBhMCcnOH5zDFyEQ1+aik6/P81lnixo+dsk+vFnN po40XEZQqK0RbUc8zYUZcbI+6ZZAzxJCanXQn/A4VQCzHWMoSCErAAVeRJo1SMY4El4UfLSnKkInb tt20dwL3MKV5MGW7KDy9uZQ5LzazE4EdBYkmN8Na70J54k8ZrBVX9oHkGlzGamnFvv4P9EjeGeqFj 8Y7Pc/cg==; Received: from mx07-00376f01.pphosted.com ([185.132.180.163]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZkTn-00E4vc-9s for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 01:19:38 +0000 Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 13N0xc8C008391; Fri, 23 Apr 2021 02:19:27 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=dk201812; bh=knSJFN6woQoqRmSWeKpa/mjHq3c7kZoaJanH8t7euhQ=; b=Lw9Abprj6+T2FmhbbI2QRgm0GhrGPHghEzB9+L9nv6CwmvhuoZx9uK8IT2XbM9Hsw4E9 l40rkbf8EGWh9l9gUCj4jgjNaXUuPws9nMW431qXKyRYveCMWnc52ljvRlzvZXgSkuUW ya0vUAU2prTTpbfH65tv+ZAayzltV1PUSLtH3pZt3Up92UBw5QPc5+z2Q3cVZUwnSFR/ lS3yUOYezfYPYyO6r4EzCxqy8UvDj0toLvrezIeN0cw2oiE3vakPCCIqEFuwlIn4EgaD rg5CG3lZ+MpHIT/9zFkLjtym9wECQBVQp9ld8D4aKbiZX36AncZBGTrmB+GEk3nqiCPB DA== Received: from hhmail05.hh.imgtec.org ([217.156.249.195]) by mx07-00376f01.pphosted.com with ESMTP id 382p9395yh-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 23 Apr 2021 02:19:27 +0100 Received: from adrianlarumbe-HP-Elite-7500-Series-MT.hh.imgtec.org (10.100.70.86) by HHMAIL05.hh.imgtec.org (10.100.10.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 23 Apr 2021 02:19:26 +0100 From: Adrian Larumbe To: , CC: , , Subject: [PATCH 4/4] dmaengine: xilinx_dma: Add device synchronisation callback Date: Fri, 23 Apr 2021 02:19:13 +0100 Message-ID: <20210423011913.13122-5-adrian.martinezlarumbe@imgtec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423011913.13122-1-adrian.martinezlarumbe@imgtec.com> References: <20210423011913.13122-1-adrian.martinezlarumbe@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.100.70.86] X-ClientProxiedBy: HHMAIL05.hh.imgtec.org (10.100.10.120) To HHMAIL05.hh.imgtec.org (10.100.10.120) X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Proofpoint-GUID: ZEYxpdMS8Vd_trDFtzcZW3ryaTVAgBZJ X-Proofpoint-ORIG-GUID: ZEYxpdMS8Vd_trDFtzcZW3ryaTVAgBZJ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_181936_180057_0DFEB44C X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This was required as an answer to a very unusual race condition, whereby a thread waiting on a completion signaled in a callback triggered by dmaengine_desc_callback_invoke might immediately attempt to release the DMA channel whilst the channel lock was still free. This would cause the remaining descriptors to be deallocated, and xilinx_dma_chan_desc_cleanup to perform an invalid memory access when attempting to traverse the rest of the channel's done_list. Now, when releasing a DMA channel, it will wait until the tasklet has finished. Signed-off-by: Adrian Larumbe --- drivers/dma/xilinx/xilinx_dma.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index 40c6cf8bf0e6..d4bad999e7f9 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -942,6 +942,13 @@ static void xilinx_dma_free_chan_resources(struct dma_chan *dchan) } +static void xilinx_dma_synchronize(struct dma_chan *dchan) +{ + struct xilinx_dma_chan *chan = to_xilinx_chan(dchan); + + tasklet_kill(&chan->tasklet); +} + /** * xilinx_dma_get_residue - Compute residue for a given descriptor * @chan: Driver specific dma channel @@ -3235,6 +3242,7 @@ static int xilinx_dma_probe(struct platform_device *pdev) xdev->common.device_tx_status = xilinx_dma_tx_status; xdev->common.device_issue_pending = xilinx_dma_issue_pending; xdev->common.device_config = xilinx_dma_slave_config; + xdev->common.device_synchronize = xilinx_dma_synchronize; if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { dma_cap_set(DMA_CYCLIC, xdev->common.cap_mask); xdev->common.device_prep_slave_sg = xilinx_dma_prep_slave_sg; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel