From patchwork Sun Jan 7 10:02:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13512868 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD91D12E58 for ; Sun, 7 Jan 2024 10:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="kIySmNNe" Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id MPysrRwtE9WXyMPz1rZ57p; Sun, 07 Jan 2024 11:02:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1704621739; bh=WHjXr8iYmZyxJWRVeVFfUIvl8ESYTgVff4hTRZ6j4QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kIySmNNe2Zo+v+2ODdcfgIetNBd42jrc8kK0zax81Q2dAITnszJqtjcq5EbTR8Vp0 N6sEdpTJslfgaoDl45o2kiy2ZM8lsLvxMcH/Y04ZJ847XOSjSFOPo0wEkiHsZ2gFcC L3O13SXHpNrTETWVtm5OflWMaLGgxTte43+RnJaO2W/CwJNYP43LdDh06WqhwZnCvR Zu1kcbFcpmZOfvfvriKPytSpidAuJBcgeSpl2JF1dUnNXo3qE0gsh7UdKje0u8ETtf khAEqokUaK13K6Q3uAhL0SUcA07B8oPYEGearxk7NMRp64QJw0CAy6K6YF3Ie8902K jI2HE2bZgy6+g== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 07 Jan 2024 11:02:19 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: vkoul@kernel.org, jiaheng.fan@nxp.com, peng.ma@nxp.com, wen.he_1@nxp.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/3] dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA Date: Sun, 7 Jan 2024 11:02:03 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This dma_alloc_coherent() is undone in the remove function, but not in the error handling path of fsl_qdma_probe(). Switch to the managed version to fix the issue in the probe and simplify the remove function. Fixes: b092529e0aa0 ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs") Signed-off-by: Christophe JAILLET --- drivers/dma/fsl-qdma.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c index 47cb28468049..38409e06040a 100644 --- a/drivers/dma/fsl-qdma.c +++ b/drivers/dma/fsl-qdma.c @@ -563,11 +563,11 @@ static struct fsl_qdma_queue /* * Buffer for queue command */ - status_head->cq = dma_alloc_coherent(&pdev->dev, - sizeof(struct fsl_qdma_format) * - status_size, - &status_head->bus_addr, - GFP_KERNEL); + status_head->cq = dmam_alloc_coherent(&pdev->dev, + sizeof(struct fsl_qdma_format) * + status_size, + &status_head->bus_addr, + GFP_KERNEL); if (!status_head->cq) { devm_kfree(&pdev->dev, status_head); return NULL; @@ -1268,8 +1268,6 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev) static void fsl_qdma_remove(struct platform_device *pdev) { - int i; - struct fsl_qdma_queue *status; struct device_node *np = pdev->dev.of_node; struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev); @@ -1277,12 +1275,6 @@ static void fsl_qdma_remove(struct platform_device *pdev) fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev); of_dma_controller_free(np); dma_async_device_unregister(&fsl_qdma->dma_dev); - - for (i = 0; i < fsl_qdma->block_number; i++) { - status = fsl_qdma->status[i]; - dma_free_coherent(&pdev->dev, sizeof(struct fsl_qdma_format) * - status->n_cq, status->cq, status->bus_addr); - } } static const struct of_device_id fsl_qdma_dt_ids[] = { From patchwork Sun Jan 7 10:02:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13512869 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EA7612B84 for ; Sun, 7 Jan 2024 10:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="NVbya2GM" Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id MPysrRwtE9WXyMPz3rZ58J; Sun, 07 Jan 2024 11:02:22 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1704621742; bh=aJxzVqIgfQ6I8zkGzF9gzvRPzwUJvo/hE6MLhe9DP3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NVbya2GMo5OoRxXFFv5NHUY1L5eI3ttmziRZBoCzBx3k2g4l0RVemOhW3s3ev15Xv JP/ka/4sMZzNpbbS8uvsrd3/rztuz7RryCRIJMQGZFUSLh8VnkKFzr7RVGnExUiksG DEXImPZ8BoBYIrbooWiLi9qNF1goQR+I9HAlwxQVfMQVLwrQCadDteRFR7XJL6CKOO LlUeOs+jWHBgAkrJt5vBJGUAHhaAlVRss9zch1nNUEm58zs3yDixHuNLxi6zKqJo/6 bChNKkx+GYaL1pRF5lQXh79VqNUNTWZRIU6ShctpGHEUEtsiVfFhuGCBmZo2vjYwSJ 9G/EdahnL8X9g== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 07 Jan 2024 11:02:22 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: vkoul@kernel.org, jiaheng.fan@nxp.com, peng.ma@nxp.com, wen.he_1@nxp.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/3] dmaengine: fsl-qdma: Fix a memory leak related to the queue command DMA Date: Sun, 7 Jan 2024 11:02:04 +0100 Message-Id: <7f66aa14f59d32b13672dde28602b47deb294e1f.1704621515.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This dma_alloc_coherent() is undone neither in the remove function, nor in the error handling path of fsl_qdma_probe(). Switch to the managed version to fix both issues. Fixes: b092529e0aa0 ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs") Signed-off-by: Christophe JAILLET --- drivers/dma/fsl-qdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c index 38409e06040a..3a5595a1d442 100644 --- a/drivers/dma/fsl-qdma.c +++ b/drivers/dma/fsl-qdma.c @@ -514,11 +514,11 @@ static struct fsl_qdma_queue queue_temp = queue_head + i + (j * queue_num); queue_temp->cq = - dma_alloc_coherent(&pdev->dev, - sizeof(struct fsl_qdma_format) * - queue_size[i], - &queue_temp->bus_addr, - GFP_KERNEL); + dmam_alloc_coherent(&pdev->dev, + sizeof(struct fsl_qdma_format) * + queue_size[i], + &queue_temp->bus_addr, + GFP_KERNEL); if (!queue_temp->cq) return NULL; queue_temp->block_base = fsl_qdma->block_base + From patchwork Sun Jan 7 10:02:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13512870 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3CED134A6 for ; Sun, 7 Jan 2024 10:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Nc0LOoB1" Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id MPysrRwtE9WXyMPz5rZ58k; Sun, 07 Jan 2024 11:02:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1704621743; bh=guYrmHlQaEIHvMVuPCB9rU52mx7/3tAlTfVlX+gCQPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Nc0LOoB13e1Vp9mhdupgtFzzwr/c6ClTvOLRElyJK8sw2al1sVCU51swf35Nd7DP3 FPi5/N89KAt5lMcBZgNlCur5gjUts6yJRB5+pwWlVVf3Y7BO5sRXPkHFE+JyviyPs1 1Mz67yh96ZIqXVYJTW1I9Y0XQuqjwbCd1RgJdoeBZbiww2xsw78yBwnfWgNhn1rNDR P6LXNjRAzAMCTXmcRycl00hvHtO3POtc26EJWmV4P6mhBfLRtnFltKoYbrKa12Ae+i 0EqUdH87+0wSk44ootj5AMcCMTR7qU98i81pc69HKcNsXxJugIBB+Jt8FATsjuA01+ tOk4F1KFo2qnQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 07 Jan 2024 11:02:23 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: vkoul@kernel.org, jiaheng.fan@nxp.com, peng.ma@nxp.com, wen.he_1@nxp.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/3] dmaengine: fsl-qdma: Remove a useless devm_kfree() Date: Sun, 7 Jan 2024 11:02:05 +0100 Message-Id: <6b7f60aa2b92f73b35c586886daffc1a5ac58697.1704621515.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'status_head' is a managed resource. It will be freed automatically if fsl_qdma_prep_status_queue(), and so fsl_qdma_probe(), fails. Remove the redundant (and harmless) devm_kfree() call. Signed-off-by: Christophe JAILLET --- drivers/dma/fsl-qdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c index 3a5595a1d442..f167c96f3fe8 100644 --- a/drivers/dma/fsl-qdma.c +++ b/drivers/dma/fsl-qdma.c @@ -568,10 +568,9 @@ static struct fsl_qdma_queue status_size, &status_head->bus_addr, GFP_KERNEL); - if (!status_head->cq) { - devm_kfree(&pdev->dev, status_head); + if (!status_head->cq) return NULL; - } + status_head->n_cq = status_size; status_head->virt_head = status_head->cq; status_head->virt_tail = status_head->cq;