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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 CA6D8C433B4 for ; Mon, 12 Apr 2021 09:41:03 +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 119DF6120B for ; Mon, 12 Apr 2021 09:41:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 119DF6120B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zvmSijKEa8j+OidPqED5NpLh1s42qotw1EH7kBGFZzk=; b=RDOdkke8BbHgnSdvt1dHG/BAK i1oWAaNhwOsS16BiPhdhN+HZ/+guQ9Q57fTChtlw6QpKCHSCiCS+xAQkYMqLNi/XEIJNcLu92hd6P +0QWgdK8tKMyGg8WCkgbKU0iirwDTcG1nQ9xXixz+N4d9LVlk/7enpzSGQL3Cc4gHZfhWqfzNWYZK eCZgJ53cQ89WqAd2gNhPxrPNZc5pGSnMs2VyBPyryP6C4oHEIE5L6TJDr5VQOQ9g8jGwya2JVeCPu bLs9MCLfG1wOAGFiRFv3kLaPXfDMT6as8PLdQGdxLigZ+8hhxbGBHYcaT5KEhLtyNOe+pog5hxiSt lymIiOxfA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVt2a-006JSO-DD; Mon, 12 Apr 2021 09:39:33 +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 1lVt2M-006JPo-1I for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:39:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FIa8vzlJ95KgTvemP99zsGvjuO3hsl64E5Vg1pmoZ4w=; b=1xjH2bqprAB2GST8xvozzZy+5l j50OInocEYCjX31YVFiN9/2zkARuLnZ76rlFPdVP+/ZgKI8W1w2LcY/B3S1nJW1VeI3Il4g2YyBGZ HPqFNWGUVEybI5jW/+ed2uCIZXPmG/RmdyMvCxkA4JjJ0zC4rU5ICAXdoWC9MMzx3DV/Rbq4pVO9m sZGpndqpRpY8qxlNDGqSFWYMfW+TEWC5Lc5uHafyEJQZZdWRJgHhpy5pI7obMjlgRvlFBKlz4pdj1 DPMlYAqYXbFLgF3xexaJXpEqC8UeqFbX476M4aF58tyLH2tL9pacBSCwzrNa1NS6tmHy3/UkFA0jf LTaC50Wg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVt2J-0064s0-5d for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:39:16 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BDEB26120B; Mon, 12 Apr 2021 09:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220354; bh=aPImZCrgJujvvKf1wVXHwFUAAvYaRgDhpRe+X56AdfI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=INfHcv6K4T5EPreapejD3JkX/41eszO4nsjC/osCjhYV8BjhUV3lHEcemYgEXx7OF n7xE7VI+TcsLQDkoN6qJzluyveUoI0/xxQ38xXcBRWQhY4sstGGwVzJLlnkHUg4v6J AQqqGaVC4ZB0H9Mvr1uTHgGERU2aQK9Idm/mqgiP0OpBNc58LQ34vXTsbbLeexjU+O OiVVKVY/0sjcQ4qQabSh/YYB57GFJRn+sT6++bYN0Z8ZxPY4+zyabRpt0tF+ouPnjf eMg+St1PeMyZy4+YagkdsTPL5ss6PjPdX1EpV91wOi/pEuWpNQfbKP9oy4S6BDr6+6 sEnQ5QHwoLdJQ== Date: Mon, 12 Apr 2021 15:09:10 +0530 From: Vinod Koul To: Robin Gong Cc: mark.rutland@arm.com, broonie@kernel.org, robh+dt@kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, shawnguo@kernel.org, festevam@gmail.com, s.hauer@pengutronix.de, martin.fuzzey@flowbird.group, u.kleine-koenig@pengutronix.de, dan.j.williams@intel.com, matthias.schiffer@ew.tq-group.com, frieder.schrempf@kontron.de, m.felsch@pengutronix.de, xiaoning.wang@nxp.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, dmaengine@vger.kernel.org, linux-imx@nxp.com Subject: Re: [PATCH v14 12/12] dmaengine: imx-sdma: add terminated list for freed descriptor in worker Message-ID: References: <1617809456-17693-1-git-send-email-yibin.gong@nxp.com> <1617809456-17693-13-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1617809456-17693-13-git-send-email-yibin.gong@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_023915_277297_5A8C9695 X-CRM114-Status: GOOD ( 21.46 ) 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 On 07-04-21, 23:30, Robin Gong wrote: > Add terminated list for keeping descriptor so that it could be freed in > worker without any potential involving next descriptor raised up before > this descriptor freed, because vchan_get_all_descriptors get all > descriptors including the last terminated descriptor and the next > descriptor, hence, the next descriptor maybe freed unexpectly when it's > done in worker without this patch. > https://www.spinics.net/lists/dmaengine/msg23367.html Sound like you should implement .device_synchronize() and do the actual work there..? > > Signed-off-by: Robin Gong > Reported-by: Richard Leitner > --- > drivers/dma/imx-sdma.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > index 9519b41..4174580 100644 > --- a/drivers/dma/imx-sdma.c > +++ b/drivers/dma/imx-sdma.c > @@ -381,6 +381,7 @@ struct sdma_channel { > enum dma_status status; > struct imx_dma_data data; > struct work_struct terminate_worker; > + struct list_head terminated; > bool is_ram_script; > }; > > @@ -1041,9 +1042,6 @@ static void sdma_channel_terminate_work(struct work_struct *work) > { > struct sdma_channel *sdmac = container_of(work, struct sdma_channel, > terminate_worker); > - unsigned long flags; > - LIST_HEAD(head); > - > /* > * According to NXP R&D team a delay of one BD SDMA cost time > * (maximum is 1ms) should be added after disable of the channel > @@ -1052,10 +1050,7 @@ static void sdma_channel_terminate_work(struct work_struct *work) > */ > usleep_range(1000, 2000); > > - spin_lock_irqsave(&sdmac->vc.lock, flags); > - vchan_get_all_descriptors(&sdmac->vc, &head); > - spin_unlock_irqrestore(&sdmac->vc.lock, flags); > - vchan_dma_desc_free_list(&sdmac->vc, &head); > + vchan_dma_desc_free_list(&sdmac->vc, &sdmac->terminated); > } > > static int sdma_terminate_all(struct dma_chan *chan) > @@ -1069,6 +1064,13 @@ static int sdma_terminate_all(struct dma_chan *chan) > > if (sdmac->desc) { > vchan_terminate_vdesc(&sdmac->desc->vd); > + /* > + * move out current descriptor into terminated list so that > + * it could be free in sdma_channel_terminate_work alone > + * later without potential involving next descriptor raised > + * up before the last descriptor terminated. > + */ > + vchan_get_all_descriptors(&sdmac->vc, &sdmac->terminated); > sdmac->desc = NULL; > schedule_work(&sdmac->terminate_worker); > } > @@ -2075,6 +2077,7 @@ static int sdma_probe(struct platform_device *pdev) > > sdmac->channel = i; > sdmac->vc.desc_free = sdma_desc_free; > + INIT_LIST_HEAD(&sdmac->terminated); > INIT_WORK(&sdmac->terminate_worker, > sdma_channel_terminate_work); > /* > -- > 2.7.4 -- ~Vinod _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel