Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2874091ybv; Mon, 24 Feb 2020 13:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqz1t4dKmTNnV/LZ8fPqSiEC2YAkz69/R7Usvmvi5RlVQfWAMdOcfMyFm1cF/4HAUG4y74vR X-Received: by 2002:aca:5303:: with SMTP id h3mr806762oib.109.1582579497509; Mon, 24 Feb 2020 13:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582579497; cv=none; d=google.com; s=arc-20160816; b=oqcRYCP4DJN5ZfpuJUlgu2eGEXVU3r6q/+/sW7yEaBg70ADCxnri7mVATMgRHv+1ka 17BZA8rfUr75AUsfLbtQIvqihzbk8aTO2Opg9x00nMpcwwIxqOzyGpaFi7y20ZyCrw4h gIS8iAW/NlHhn6VychQUTirHND7Of950RqgZAhkKKbfGObrMxsbnf4nSoY4LDiY22N9j eH9IkBlZ/P0TsDKatE50lUAa3vj+4Pn7h1F3FSG2gS+VDXGwJXL1Jn81ifk4Wp6m3oNB +ouSyiPPurvcv9crQxrfhH5K4/d4qTO47//8hijzfbUus5zr3oMU6aHEEpYE1spNf2WG FTyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+Alw2VfADjdpJJBSbePdCZ6yUG04n4Hjc6pfvVEEl84=; b=cFDQnBJKHfGtCa997NYsLi+GTmqB53VLMOBZZd2hoR1lCc3d0kwt3/UbukS9qInzVB HebLcG5OK8FRPcohh+41abhwXOASS4ajgPIQdf1Z/O8E41rtvk05DpROhriMSwEBLYdN LEhftBarMxnL05vtMvXjJqtqSN6jbJrmYge25ySVKd2IhXUunD9q/6UF2qOF0f1+ZrNK G0OLf0icVNnAohIHLSyr42X1lpzMtlapYWftVuuwiLtA1U7TnonuBEapYZhgs65Q2H95 oNlSFprJh58r+n5Z7YyWnzzPnUNGxnCqaofjIRHVMMpJPHgHrSM54BARiSdqh/RwXF6z ObZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YEBbehGB; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24si7220316oth.319.2020.02.24.13.24.44; Mon, 24 Feb 2020 13:24:57 -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=YEBbehGB; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727877AbgBXVXW (ORCPT + 99 others); Mon, 24 Feb 2020 16:23:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:38002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbgBXVXW (ORCPT ); Mon, 24 Feb 2020 16:23:22 -0500 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 1758C218AC; Mon, 24 Feb 2020 21:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582579401; bh=XnkYOmulZ8/lTR2roVqGnBGPNTBbKp8TG7sz+XwMTDk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YEBbehGBXvp3CPzembrHbTI7ud/HJbKPdfdL/5pEC9w0esFKdekF03AbMqJimpl3v GyNxtEab/KQ7pvDrxIQLOiihaSlLV3ofzr6lxx3lXS8nfHcuHYlg/ojkeQRf93SlxT WILXyi0OKIOmyLdmAOyEDENKwyzUFskZ0DxFhC4c= Date: Mon, 24 Feb 2020 16:23:19 -0500 From: Sasha Levin To: Sascha Hauer Cc: Andreas Tobler , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Robin Gong , Vinod Koul Subject: Re: [PATCH 5.4 160/344] dmaengine: imx-sdma: Fix memory leak Message-ID: <20200224212319.GE26320@sasha-vm> References: <20200221072349.335551332@linuxfoundation.org> <20200221072403.369335694@linuxfoundation.org> <1429291b-77c5-41aa-8dee-8858eba6d138@onway.ch> <20200224145718.GD3335@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200224145718.GD3335@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 03:57:18PM +0100, Sascha Hauer wrote: >On Mon, Feb 24, 2020 at 01:24:04PM +0000, Andreas Tobler wrote: >> Hi all, >> >> On 21.02.20 08:39, Greg Kroah-Hartman wrote: >> > From: Sascha Hauer >> > >> > [ Upstream commit 02939cd167095f16328a1bd5cab5a90b550606df ] >> > >> > The current descriptor is not on any list of the virtual DMA channel. >> > Once sdma_terminate_all() is called when a descriptor is currently >> > in flight then this one is forgotten to be freed. We have to call >> > vchan_terminate_vdesc() on this descriptor to re-add it to the lists. >> > Now that we also free the currently running descriptor we can (and >> > actually have to) remove the current descriptor from its list also >> > for the cyclic case. >> > >> > Signed-off-by: Sascha Hauer >> > Reviewed-by: Robin Gong >> > Tested-by: Robin Gong >> > Link: https://lore.kernel.org/r/20191216105328.15198-10-s.hauer@pengutronix.de >> > Signed-off-by: Vinod Koul >> > Signed-off-by: Sasha Levin >> > --- >> > drivers/dma/imx-sdma.c | 19 +++++++++++-------- >> > 1 file changed, 11 insertions(+), 8 deletions(-) >> > >> > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c >> > index c27e206a764c3..66f1b2ac5cde4 100644 >> > --- a/drivers/dma/imx-sdma.c >> > +++ b/drivers/dma/imx-sdma.c >> > @@ -760,12 +760,8 @@ static void sdma_start_desc(struct sdma_channel *sdmac) >> > return; >> > } >> > sdmac->desc = desc = to_sdma_desc(&vd->tx); >> > - /* >> > - * Do not delete the node in desc_issued list in cyclic mode, otherwise >> > - * the desc allocated will never be freed in vchan_dma_desc_free_list >> > - */ >> > - if (!(sdmac->flags & IMX_DMA_SG_LOOP)) >> > - list_del(&vd->node); >> > + >> > + list_del(&vd->node); >> > >> > sdma->channel_control[channel].base_bd_ptr = desc->bd_phys; >> > sdma->channel_control[channel].current_bd_ptr = desc->bd_phys; >> > @@ -1071,7 +1067,6 @@ static void sdma_channel_terminate_work(struct work_struct *work) >> > >> > spin_lock_irqsave(&sdmac->vc.lock, flags); >> > vchan_get_all_descriptors(&sdmac->vc, &head); >> > - sdmac->desc = NULL; >> > spin_unlock_irqrestore(&sdmac->vc.lock, flags); >> > vchan_dma_desc_free_list(&sdmac->vc, &head); >> > sdmac->context_loaded = false; >> > @@ -1080,11 +1075,19 @@ static void sdma_channel_terminate_work(struct work_struct *work) >> > static int sdma_disable_channel_async(struct dma_chan *chan) >> > { >> > struct sdma_channel *sdmac = to_sdma_chan(chan); >> > + unsigned long flags; >> > + >> > + spin_lock_irqsave(&sdmac->vc.lock, flags); >> > >> > sdma_disable_channel(chan); >> > >> > - if (sdmac->desc) >> > + if (sdmac->desc) { >> > + vchan_terminate_vdesc(&sdmac->desc->vd); >> > + sdmac->desc = NULL; >> > schedule_work(&sdmac->terminate_worker); >> > + } >> > + >> > + spin_unlock_irqrestore(&sdmac->vc.lock, flags); >> > >> > return 0; >> > } >> > >> >> This patch breaks our imx6 board with the attached trace. Reverting the >> patch makes it boot again. >> I tried also 5.6-rc3 and it booted too. A closer look into imx-sdma.c >> from 5.6-rc3 showed me some details which might have to be backported as >> well to make this patch work. >> I tried a1ff6a07f5a3951fcac84f064a76d1ad79c10e40 and was somehow >> successful. I still have one trace but the board boots now. >> >> Any insights from the experts? > >This series should be applied as a whole or not, only 7/9 is optional. > >It seems I have to avoid the trigger word "fix" in my commit messages or >make sure these patches won't apply without their dependencies :-/ Or you could just tag the dependencies so that we could take all of them as well? We have a nice "Depends-on:" tag that makes it easy. As with everything in life, you want to communicate more effectively rather than not communicate at all. -- Thanks, Sasha