Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE053C05027 for ; Thu, 26 Jan 2023 21:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbjAZVyz (ORCPT ); Thu, 26 Jan 2023 16:54:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233085AbjAZVyn (ORCPT ); Thu, 26 Jan 2023 16:54:43 -0500 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E463D71673 for ; Thu, 26 Jan 2023 13:54:40 -0800 (PST) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.19/8.17.1.19) with ESMTP id 30QGVnw4012820 for ; Thu, 26 Jan 2023 13:54:40 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=7ImpmxP7Ob9uAWzmNXAlXZ2GzYOCB24lKi0O9CGQzBc=; b=KqkMTtrMb15nIb7/axhvbitnXLLvlYSUU9bym5ow/oBPECtZ0nCOB0cH8R+xCd6UaCBc 9tFpsWOoTWmmOjgYUHxWWRQtQTHjIN4fas16vA2+GVyUBzJ6r86JRToq7ciYYGGz/s5j dg09UWI68EtCRR2UNEQfCoBbaC4VjGK4AY+zu9GedW7XT8/TrQDzeWs5iQjWg4nxKrEZ lfVOMPtII6Rn5aIfIzvkGtT4hskD6sUU7LPaHf1myacSufQo5LCD0RJrBspYMnYW/Vk5 Sj/mBR4w9rGmwSrmtIsXVJBT+xujjhWGJ4loJ/nG10u6loVgGYtsuP0qEZEZ5iLfVCGk RA== Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net (PPS) with ESMTPS id 3nbw49tupx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 26 Jan 2023 13:54:40 -0800 Received: from twshared16996.15.frc2.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:21d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Thu, 26 Jan 2023 13:54:37 -0800 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 4BE6AFE80AA0; Thu, 26 Jan 2023 13:51:26 -0800 (PST) From: Keith Busch To: , , , , , CC: , Keith Busch Subject: [PATCHv4 09/12] dmapool: simplify freeing Date: Thu, 26 Jan 2023 13:51:22 -0800 Message-ID: <20230126215125.4069751-10-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126215125.4069751-1-kbusch@meta.com> References: <20230126215125.4069751-1-kbusch@meta.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: -zDRD-5ZcX_8jm_dL8-KWnqarur_qboE X-Proofpoint-GUID: -zDRD-5ZcX_8jm_dL8-KWnqarur_qboE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_09,2023-01-26_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch The actions for busy and not busy are mostly the same, so combine these and remove the unnecessary function. Also, the pool is about to be freed so there's no need to poison the page data since we only check for poison on alloc, which can't be done on a freed pool. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- mm/dmapool.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index 9e98065a68b1f..4dea2a0dbd336 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -312,16 +312,6 @@ static inline bool is_page_busy(struct dma_page *pag= e) return page->in_use !=3D 0; } =20 -static void pool_free_page(struct dma_pool *pool, struct dma_page *page) -{ - dma_addr_t dma =3D page->dma; - - pool_init_page(pool, page); - dma_free_coherent(pool->dev, pool->allocation, page->vaddr, dma); - list_del(&page->page_list); - kfree(page); -} - /** * dma_pool_destroy - destroys a pool of dma memory blocks. * @pool: dma pool that will be destroyed @@ -349,14 +339,14 @@ void dma_pool_destroy(struct dma_pool *pool) mutex_unlock(&pools_reg_lock); =20 list_for_each_entry_safe(page, tmp, &pool->page_list, page_list) { - if (is_page_busy(page)) { + if (!is_page_busy(page)) + dma_free_coherent(pool->dev, pool->allocation, + page->vaddr, page->dma); + else dev_err(pool->dev, "%s %s, %p busy\n", __func__, pool->name, page->vaddr); - /* leak the still-in-use consistent memory */ - list_del(&page->page_list); - kfree(page); - } else - pool_free_page(pool, page); + list_del(&page->page_list); + kfree(page); } =20 kfree(pool); --=20 2.30.2