Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2105041lkv; Thu, 20 May 2021 03:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcHDnlap4Xdz5PqnQQeG52JncoagYH7WNogkd8OIH7l6CdVhUQxE0tm6Rfi8m6mx9UOhfQ X-Received: by 2002:a05:6602:54:: with SMTP id z20mr4430868ioz.48.1621506698489; Thu, 20 May 2021 03:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506698; cv=none; d=google.com; s=arc-20160816; b=LX5dI/O+l2arqSWKuBzEf6K8XN8VpTKy/iAhhkrAh8isRul0PdYyAWyrxep5XvzJ/v CHiMrreFEWaDLk3Itl6ShrEvqWqXUrz5KLM92/eJg8S/fpcT17mbjHchh6ysMCicNM8z ptuYo+2hsG3/97QoF4dMfMGP9yKvUUlIuEFJJ8li7fy25aUEibyv8Ucs3+4bNGXcWc+8 cNIcxeuHWKaNxXAJF3Pl1/e3em8wZ4aMECK6y3L7fJk5LcLq1ALW5+ktSwptcgxgRgBm tTK4J0yntFFDNOGBfl4zup331LaC0PWhbLbeXqzLBkMzvMETbh3AyozVHQSwAVHnMqj5 mtrw== 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=rXc2SEeXoG6aqGdGx7qoGRb2P7i6Di7JG65kB1iVVvs=; b=tyiQ1FdEmTulK4KTXAVszOTUgGR+rMDBQMkg4uLwDqRK/7LJ0Qeg72lsnoxy3oi1nf Rc4rAcnFNcuD3Yyap489vnt/PwdV65ONc3wlbY3qgNtkPJfZp2mBL2iZwQAv2VMGLWeX yCXJFL8I/mLuP5XkImmq4DYA3b2WE42WdZ8ejvBntXkAGhApTs92F4zG/c9EoZOHbmeS EaJXlSN/Ude1k9/UxxfcqIlorQdvE6XbJK9tccyXmwnvHmRdaSsv9zL8h7TqYgZe6/qO 8XQrF6KKKSzkwvx5bggCidRUQdPqMD6AW7tu+/H4cF30boc3rrmo4mjDTOXn6zGWk6wY sscA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jOaWpa63; 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 l11si2188525jaj.50.2021.05.20.03.31.25; Thu, 20 May 2021 03:31:38 -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=jOaWpa63; 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 S236894AbhETKbT (ORCPT + 99 others); Thu, 20 May 2021 06:31:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235255AbhETKTG (ORCPT ); Thu, 20 May 2021 06:19:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E42D1619A9; Thu, 20 May 2021 09:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504016; bh=/mj8Lz2qhNc0xP33Z4WoVs2t11srSRuqSlt2+4w9z2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOaWpa63xpSRyLyYlADic2lMEK6CI2vSAHcKZgWGXlRoGCSsqsm0mz0MagdiL9Hgc op0IGxWRHWU9V2c2hKoKUBxaIdQ75V8aLqAvthZVIMqSaEDHtRwI+Vr6LGkzLUubf1 0RsUXBC/UjB6MDjD+s7be2Rlt3teLXtsNPEaGT40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Mark Brown Subject: [PATCH 4.14 022/323] spi: spi-ti-qspi: Free DMA resources Date: Thu, 20 May 2021 11:18:34 +0200 Message-Id: <20210520092120.875655092@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -643,6 +643,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" }, @@ -794,6 +805,8 @@ no_dma: if (!ret) return 0; + ti_qspi_dma_cleanup(qspi); + pm_runtime_disable(&pdev->dev); free_master: spi_master_put(master); @@ -812,12 +825,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; }