Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2472028pxj; Mon, 10 May 2021 03:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLo4sGWskb1c44xxbPd6cA0vvw0ut1D4IY7q7IBg/HG86dz2lo9dhU7nHDl3NtwfYLQnp8 X-Received: by 2002:a05:6638:2643:: with SMTP id n3mr20754744jat.104.1620644206741; Mon, 10 May 2021 03:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644206; cv=none; d=google.com; s=arc-20160816; b=tECiZXMRDti+1KDYeVAuky5Pwszljavg7sPoKfVBlhmALcni2yX99I87uGAQeGkWlU brqP89TeCH/TwOVh3C9iYrGxcYShjrVP7RKDdvTd/J0MMKuJH1MzJ2NdQr6U9SoSH3si MxDUT1pjpNtYO3ge7Ycve93R1JtEPbBJy7qYFOE8dVkAuh+lekFVtVbcMgNGu4Eel3wb osjXm2DVGY83dz0lTDa6eP9/pXzA3TmamSddvxdKYZwetzUAPhkUsXuKPZQri2wDi1XG dVEJ4AmpPnklVcGa5C+jM5d0CJlB1TJoI2rxy241Xm6LNhmTjzOKVcBSscsBArzdnTG7 iWog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=03T0+XAtJV1dsSJZbaeCAVqdKeWYGq2jGzi2xXO42N0=; b=kDfRCgeYUzwhxMkMYdbRLtpb3lyGbPFzrZKITqEnpzDTP4op9sdDGq3SDX1ZMu90sy pP8ES97pGBJ0+c5E1dFaFeaaN69dh59rPkD9R010ajCEWkSWuiIdDyTRdEJGRFRFI5X/ e7LQwfx1Y4qaIXPh4XzuG/XVaHJMcXVjfrYIFVhzwFf0X93njunD+0j4U57Agq2GglUd vwPnK74M+V0Oh3zuA0Le3gfyOi4HxUdM6iV8NN9UPVTogz9KwF53FsZxy1oq0gBsdVBe iQN3n4wtcTTH4l1NYT3RUfYaFNxauee14wh/p16dQV6FkHt2Jm1icIPOo++oTYNh5I+y vJ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CJhyV6FW; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si5115307ioo.82.2021.05.10.03.56.33; Mon, 10 May 2021 03:56:46 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=CJhyV6FW; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbhEJKvv (ORCPT + 99 others); Mon, 10 May 2021 06:51:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbhEJKlZ (ORCPT ); Mon, 10 May 2021 06:41:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A25A661970; Mon, 10 May 2021 10:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642725; bh=M/+vdv7m2BJtYprDvTm8xYCLvC7XflMUiq1xKdH3+S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJhyV6FWc32+99K+sF0RrVIndWJoRYr98HurjY4kfUp7D8thv7zdtgwgMjIoTNfOT b+u7sbsdu6rdbgeaJXqNdGRVgMRd1y/ugBhkMl2hu5moaDai/YyE9sUnH2uBvj3xqL qjdsZIkKJ2cgEk8yfVJ2o/q/VNK9S/rC9+noMpes= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Mark Brown Subject: [PATCH 5.10 025/299] spi: spi-ti-qspi: Free DMA resources Date: Mon, 10 May 2021 12:17:02 +0200 Message-Id: <20210510102005.683125903@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tudor Ambarus commit 1d309cd688a76fb733f0089d36dc630327b32d59 upstream. Release the RX channel and free the dma coherent memory when devm_spi_register_master() fails. Fixes: 5720ec0a6d26 ("spi: spi-ti-qspi: Add DMA support for QSPI mmap read") Cc: stable@vger.kernel.org Signed-off-by: Tudor Ambarus Link: https://lore.kernel.org/r/20210218130950.90155-1-tudor.ambarus@microchip.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-ti-qspi.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- a/drivers/spi/spi-ti-qspi.c +++ b/drivers/spi/spi-ti-qspi.c @@ -733,6 +733,17 @@ static int ti_qspi_runtime_resume(struct return 0; } +static void ti_qspi_dma_cleanup(struct ti_qspi *qspi) +{ + if (qspi->rx_bb_addr) + dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE, + qspi->rx_bb_addr, + qspi->rx_bb_dma_addr); + + if (qspi->rx_chan) + dma_release_channel(qspi->rx_chan); +} + static const struct of_device_id ti_qspi_match[] = { {.compatible = "ti,dra7xxx-qspi" }, {.compatible = "ti,am4372-qspi" }, @@ -886,6 +897,8 @@ no_dma: if (!ret) return 0; + ti_qspi_dma_cleanup(qspi); + pm_runtime_disable(&pdev->dev); free_master: spi_master_put(master); @@ -904,12 +917,7 @@ static int ti_qspi_remove(struct platfor pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - if (qspi->rx_bb_addr) - dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE, - qspi->rx_bb_addr, - qspi->rx_bb_dma_addr); - if (qspi->rx_chan) - dma_release_channel(qspi->rx_chan); + ti_qspi_dma_cleanup(qspi); return 0; }