Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp710771pxv; Thu, 15 Jul 2021 14:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrry+4fSIoJyKZq/UX3mI4c7SFlg4iT1Ve7VsE0cHThnmmPJr14hJ08a1WgtoTfhlZHg8Y X-Received: by 2002:a17:906:bc8b:: with SMTP id lv11mr7578000ejb.331.1626383300750; Thu, 15 Jul 2021 14:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383300; cv=none; d=google.com; s=arc-20160816; b=ZRaWCLxd8/vh6KAOOb72Hy2jmsz/8qhGrtdZGHTOZuf+6J6l3YymvMEPVdFRX2YmDy n2Mskj3RwtX/lx2lt3WS5mvZrESJLlWixdGw9CeF6TTKVlmPG8a1/qk6ttJMLMdBlkas +X7Saua1gwyL6wwIUrCggqXXcwPuGdtqmKKGggiDDWgy43VTr0NC0C5Kjs1qhP8KQfSu m2j83ouzhbWgBrF4Ml3Itna0QObxDxJEBR+Oz5K3+pNB3jKzus6nEactM0E9MfOqrH+7 jY50JLGN2oEfptnvlTBH2cAynVF8d7AABdamOuOHTNUYFB78il/5U0Gd3qrecqStEVu0 rY4Q== 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=qbcxsQhLBXNw6DDlS3PA9VTPngL5kX4CPGEEpGqlcdA=; b=QHCr6bpclfqNK64RZI09+R2YRrEsN2Ng27/GZbOG8S8FuCYdLm2rcB466NHv9DgNX/ sJLVBiCYYw+MY0tJ+MtwWtTHuPfNv8s2F3IY1UHQaPVt8DuwSSQ/L2lhZZBJlrUriorp UJdzMVe+kZU/kWD9K8lhcDAWGE44CO7u/6QHM48oziQ4I9zyBSeMXdFKKNu4IquM2HDK A5o4vAANPnfPw84kqkIb7CUnHuIiT0v3XReOK1slUO/D3xgjpcQQ1iqnlI+bW5YPC8oO ZOS+PeUeHNb3x6gI55RVn+SAFbKu4N46ZVNTylGP3LJ3XxjW/P6cbhxMN3Hlyv5dM6r9 QjLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=olQD7lht; 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 bd17si8375381edb.530.2021.07.15.14.07.52; Thu, 15 Jul 2021 14:08:20 -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=olQD7lht; 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 S244701AbhGOTR6 (ORCPT + 99 others); Thu, 15 Jul 2021 15:17:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243423AbhGOTEY (ORCPT ); Thu, 15 Jul 2021 15:04:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27519613D8; Thu, 15 Jul 2021 19:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375614; bh=m/uSeaYwYSy3F559zEKb0I+NuHdp+bdo7Pc8iYTmtEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olQD7lht5Fp2gAZCR9QWcPRbfX0IvcuDw/FmUGh/NlyajulKK0AhgMTZC1vuHW+za MIrhx957wXxTxQ1zTZNsayGPVOICGVnwocf/7cQn87OeapcNDqIYsegFqP7iSZkCXT Vm2OrQIN+WgZTGu8qQUXJ4cEPQ/p4pkMF1/9F2KQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 5.12 119/242] iwlwifi: pcie: free IML DMA memory allocation Date: Thu, 15 Jul 2021 20:38:01 +0200 Message-Id: <20210715182614.045752776@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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: Johannes Berg [ Upstream commit 310f60f53a86eba680d9bc20a371e13b06a5f903 ] In the case of gen3 devices with image loader (IML) support, we were leaking the IML DMA allocation and never freeing it. Fix that. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20210618105614.07e117dbedb7.I7bb9ebbe0617656986c2a598ea5e827b533bd3b9@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- .../wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 15 ++++++++++----- .../net/wireless/intel/iwlwifi/pcie/internal.h | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c index cecc32e7dbe8..2dbc51daa2f8 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c @@ -79,7 +79,6 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, struct iwl_prph_scratch *prph_scratch; struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl; struct iwl_prph_info *prph_info; - void *iml_img; u32 control_flags = 0; int ret; int cmdq_size = max_t(u32, IWL_CMD_QUEUE_SIZE, @@ -187,14 +186,15 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, trans_pcie->prph_scratch = prph_scratch; /* Allocate IML */ - iml_img = dma_alloc_coherent(trans->dev, trans->iml_len, - &trans_pcie->iml_dma_addr, GFP_KERNEL); - if (!iml_img) { + trans_pcie->iml = dma_alloc_coherent(trans->dev, trans->iml_len, + &trans_pcie->iml_dma_addr, + GFP_KERNEL); + if (!trans_pcie->iml) { ret = -ENOMEM; goto err_free_ctxt_info; } - memcpy(iml_img, trans->iml, trans->iml_len); + memcpy(trans_pcie->iml, trans->iml, trans->iml_len); iwl_enable_fw_load_int_ctx_info(trans); @@ -243,6 +243,11 @@ void iwl_pcie_ctxt_info_gen3_free(struct iwl_trans *trans) trans_pcie->ctxt_info_dma_addr = 0; trans_pcie->ctxt_info_gen3 = NULL; + dma_free_coherent(trans->dev, trans->iml_len, trans_pcie->iml, + trans_pcie->iml_dma_addr); + trans_pcie->iml_dma_addr = 0; + trans_pcie->iml = NULL; + iwl_pcie_ctxt_info_free_fw_img(trans); dma_free_coherent(trans->dev, sizeof(*trans_pcie->prph_scratch), diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h index d9688c7bed07..53af3f29eab8 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h @@ -279,6 +279,8 @@ struct cont_rec { * Context information addresses will be taken from here. * This is driver's local copy for keeping track of size and * count for allocating and freeing the memory. + * @iml: image loader image virtual address + * @iml_dma_addr: image loader image DMA address * @trans: pointer to the generic transport area * @scd_base_addr: scheduler sram base address in SRAM * @kw: keep warm address @@ -329,6 +331,7 @@ struct iwl_trans_pcie { }; struct iwl_prph_info *prph_info; struct iwl_prph_scratch *prph_scratch; + void *iml; dma_addr_t ctxt_info_dma_addr; dma_addr_t prph_info_dma_addr; dma_addr_t prph_scratch_dma_addr; -- 2.30.2