Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5727998pxb; Thu, 20 Jan 2022 03:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxllhCrMwGXoZbE+IFrNX/Q9daFFhmgNkywCgBhuKwoAcRPBAusNiTrxR6qbni5b0HSTc/l X-Received: by 2002:a63:a746:: with SMTP id w6mr31416501pgo.583.1642677901517; Thu, 20 Jan 2022 03:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642677901; cv=none; d=google.com; s=arc-20160816; b=ata8ltOUkuH97WnhsS9cFjKxHcWbGqts/MiHXGnTMwjk/WAHlQFY/sk0SFUtiWD+O3 3b5FL8GHJ8pz8u5sxAEUnnqt/qPdPH8Qae86R6CvDbbAxYmY59DpmSmY00pOA7JoVGHC GnTuFWw1zPeA2f10D3V8VeW1Syr7doaZFDpa8r+cPYkJR3SkQTOey3YjQE5ONjDM3vgs YOjAWXivLLCyIGDnai6B9yp5IG9TE/W9UxL404mqJYqWbAH7Ae/P3D/Qq6W+cwI5dRL0 0VzYKtR+l3kxoeSQRa59FttIQ0dTUKTUNU4v20G4ZCx0SoUvsepGyQlci62wQc11GbZh HPsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=17MkQ+D7lcIHENLUZkNE+Wb1M6GLIW0KLmLfLfpyKuY=; b=eyS3C8C05bcOpoFQgTnzAf9wpK+9wSvhSMiq2gRwgknAPpnYtsoXJ4+Uzn97wCa+7w fMXD/wUthGH4+ptz5TN2ScWfXYOazWtLEpaOE9VbO6Le8Z7ED61O4SI/rPVB80f3uSBg vYel0x7e3Skgbixj/sBFnd79ypne4J1nmDXK7N5OP9aOY+3CcN/CrMN8A3X3QA9ktg5U ifBgzYHuG7VoIL86lFLHOqF0M9QOcOrKH2GEyqOhVJZoXlD6Ql/ZG2rviYBWhflzOq4K KKvK8IA/lI9A+0GYBNm+Ff0kGISQ5HtS0DsHTeQ8vkUxKr57v8hjI2KMInRiNOvYJEkt Jv5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mvTY0w/p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id nu3si3482362pjb.74.2022.01.20.03.24.50; Thu, 20 Jan 2022 03:25:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mvTY0w/p"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242941AbiARNsh (ORCPT + 99 others); Tue, 18 Jan 2022 08:48:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242543AbiARNs2 (ORCPT ); Tue, 18 Jan 2022 08:48:28 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B4BC06161C; Tue, 18 Jan 2022 05:48:27 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id br17so70910855lfb.6; Tue, 18 Jan 2022 05:48:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=17MkQ+D7lcIHENLUZkNE+Wb1M6GLIW0KLmLfLfpyKuY=; b=mvTY0w/pN5vJRbVPnoOMSXYgEs0lE5GlWlKV8Luv12ObuBtRxvt7RXJeD2Z0aNH3ce PPMNmQnjVcQOy6g/N73ELDWzPO5QURYj60f7BWVvl2JFCrM8hDCL+Ou6UqO4dWJASTUE p85+YBd1DD4XiFG9c5igQlX+SSZ84TaUlM8j3MmOtnbCR9w97IzXpN0PdmXOAVK/gJoL zMTZ4Ev4EBM5S9UF3Hcub3rkfkbGCeruG6b3ZVGf1C0ZgonWKEWOweucqUJ3XJ7ILIMM iuW8AwkGSe5KaKLAHljj1SOLuHXp8YxWfy0G2Edb0RGSiya/37yP/b5x0O9rPqBNAzXr kcsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=17MkQ+D7lcIHENLUZkNE+Wb1M6GLIW0KLmLfLfpyKuY=; b=C69E5gk22bWcOcu7SHgSG1kbiNeKsaLUDpvqULxcpjrKX2SO7yPZS3inaMw1PHHxNo i29llskcmsY69uM4SPrX5Eokn6nG2bd2El9ftc6pb06UUssgx3Y9MbKWG9Dz3deyTzpd 0tuvUeoO7eF4PkyT3uqRbF+pyU6kG8izgOFWSOmrErCLzYqjuVrc0nUaNPQSyIB6bgeb VQP8qhOswOfnRyLtSUnYh7kmDMwqdoHIWDjjLsPOVJvVotCKkzyZnLdcK+bBGPdeRbH+ 5HWq16GlyC91ptFGuZLW97bk6umuwwMCDTNIhaEMRYV2MavGBZJaLVAkFRQ194EXfMt4 ihYw== X-Gm-Message-State: AOAM532SCUlKmsfxYNHpIxl7lhuGrI3xA9jxTQamRNqZ1glnx6OO5KeG OIgxo3R3+OOSQmmRY8tOPzE= X-Received: by 2002:a05:651c:171c:: with SMTP id be28mr20262368ljb.183.1642513705172; Tue, 18 Jan 2022 05:48:25 -0800 (PST) Received: from [192.168.2.145] (46-138-227-157.dynamic.spd-mgts.ru. [46.138.227.157]) by smtp.googlemail.com with ESMTPSA id t13sm1625887lji.57.2022.01.18.05.48.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 05:48:24 -0800 (PST) Message-ID: <683a71b1-049a-bddf-280d-5d5141b59686@gmail.com> Date: Tue, 18 Jan 2022 16:48:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v16 2/4] dmaengine: tegra: Add tegra gpcdma driver Content-Language: en-US To: Akhil R , "dan.j.williams@intel.com" , "devicetree@vger.kernel.org" , "dmaengine@vger.kernel.org" , Jonathan Hunter , Krishna Yarlagadda , Laxman Dewangan , "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" , "p.zabel@pengutronix.de" , Rajesh Gumasta , "robh+dt@kernel.org" , "thierry.reding@gmail.com" , "vkoul@kernel.org" Cc: Pavan Kunapuli References: <1641830718-23650-1-git-send-email-akhilrajeev@nvidia.com> <1641830718-23650-3-git-send-email-akhilrajeev@nvidia.com> <16c73e83-b990-7d8e-ddfd-7cbbe7e407ea@gmail.com> <1db14c3d-6a96-96dd-be76-b81b3a48a2b1@gmail.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 18.01.2022 08:36, Akhil R пишет: >> 17.01.2022 10:02, Akhil R пишет: >>>> 10.01.2022 19:05, Akhil R пишет: >>>>> +static int tegra_dma_terminate_all(struct dma_chan *dc) >>>>> +{ >>>>> + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); >>>>> + unsigned long flags; >>>>> + LIST_HEAD(head); >>>>> + int err; >>>>> + >>>>> + if (tdc->dma_desc) { >>>> >>>> Needs locking protection against racing with the interrupt handler. >>> tegra_dma_stop_client() waits for the in-flight transfer >>> to complete and prevents any additional transfer to start. >>> Wouldn't it manage the race? Do you see any potential issue there? >> >> You should consider interrupt handler like a process running in a >> parallel thread. The interrupt handler sets tdc->dma_desc to NULL, hence >> you'll get NULL dereference in tegra_dma_stop_client(). > > Is it better if I remove the below part from tegra_dma_stop_client() so > that dma_desc is not accessed at all? > > + wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT); > + tdc->dma_desc->bytes_transferred += > + tdc->dma_desc->bytes_requested - (wcount * 4); > > Because I don't see a point in updating the value there. dma_desc is set > to NULL in the next step in terminate_all() anyway. That isn't going help you much because you also can't release DMA descriptor while interrupt handler still may be running and using that descriptor.