Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1599033rdb; Mon, 8 Jan 2024 04:44:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeuBsDWhbbwse141gBuPjLxOAj+w1lTiry89RWYUmsaxJV8zIXozSLjyWtK+gwtpzVWuWN X-Received: by 2002:a17:907:90c5:b0:a28:ec67:185f with SMTP id gk5-20020a17090790c500b00a28ec67185fmr1356288ejb.60.1704717854302; Mon, 08 Jan 2024 04:44:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704717854; cv=none; d=google.com; s=arc-20160816; b=Z2C95VDbwZsJNCcJeZa6Hm23c+gYPAlfGZ1QyAq97eT4u7FNfvXrCxYAfuxQMKFTL+ +hregOrTx9J6J6zaOQJ35RHnF9qwEU1Zk3UxnW9AKZX/PdVx4VKqBwzQD8bQYlrnQie0 YWX+SroKER7M3149VFgaL38hZw0gLJVeZ63h0iPYFDmhnP8TQpMi7lfwynkcDJJn7k2F kdEnUVaLkMaE210Obqvco+wdDfUBXwSIdwbh+jtxWd4dkNMHzWiAEJbGXBEIsQ7q0oSk f34CZeJQOAARZIoDlYnzZEi0nPcFWD9QG8uVYXNbhlDwEZonLUyZropb6URtzqvSbzGa 2Gcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=yoiKWEQr4bJRaiiIVrIHBV/Qg2hVIGB+s7gWHplUwcs=; fh=yC+rbCZNfEFN2DLpTF2BdyYiHEbBGXmYn79WNneL20w=; b=QsKr4WS61fFSe0vhTr1L2t1zvofahpFh4WZ/IM9QMqSs6DTb8y1LqyqkSpeWWymelh PTeSkIfKYEYwhQQK0lTOuQw9Y1+bpnABnsTNIz9gr8cOtPpLtzoPne95YofDAOYpqemo Rl+tExLIRzRz64cIS4CFKvmU0zm+ijXav+k0sKGQv4GC+9kaqW6BWY5duunIaF1veQeb xveAAJj3FC5NHe9mNw+wEdQgPDgJj632oAEH1WLFLamSBXoz6UPFw8rYv31Mq4Di6AcO InDrlqobF9PQ7+NCPEYxM0kEwb21AaDzmh8lsBCbcP4ypw4cq1MdNg0/C/U2Wzld8a2A /hzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pv18-20020a170907209200b00a29063e794csi3137945ejb.297.2024.01.08.04.44.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:44:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19546-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0D7F81F22DA2 for ; Mon, 8 Jan 2024 12:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22CF245C1E; Mon, 8 Jan 2024 12:34:52 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CBBB45954 for ; Mon, 8 Jan 2024 12:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A22A6150C; Mon, 8 Jan 2024 04:35:35 -0800 (PST) Received: from [127.0.1.1] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 114313F64C; Mon, 8 Jan 2024 04:34:48 -0800 (PST) From: Cristian Marussi Date: Mon, 08 Jan 2024 12:34:14 +0000 Subject: [PATCH 4/6] firmware: arm_ffa: Simplify ffa_partitions_cleanup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240108-ffa_fixes_6-8-v1-4-75bf7035bc50@arm.com> References: <20240108-ffa_fixes_6-8-v1-0-75bf7035bc50@arm.com> In-Reply-To: <20240108-ffa_fixes_6-8-v1-0-75bf7035bc50@arm.com> To: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Cristian Marussi X-Mailer: b4 0.12.4 On cleanup iterate the XArrays with xa_for_each() and remove the existent entries with xa_erase(), finally destroy the XArray itself. Remove partition_count field from drv_info since no more used anywhwere. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_ffa/driver.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 0ea1dd6e55c4..2426021dbb58 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -107,7 +107,6 @@ struct ffa_drv_info { struct work_struct notif_pcpu_work; struct work_struct irq_work; struct xarray partition_info; - unsigned int partition_count; DECLARE_HASHTABLE(notifier_hash, ilog2(FFA_MAX_NOTIFICATIONS)); struct mutex notify_lock; /* lock to protect notifier hashtable */ }; @@ -1239,7 +1238,6 @@ static void ffa_setup_partitions(void) rwlock_init(&info->rw_lock); xa_store(&drv_info->partition_info, tpbuf->id, info, GFP_KERNEL); } - drv_info->partition_count = count; kfree(pbuf); @@ -1249,29 +1247,18 @@ static void ffa_setup_partitions(void) return; rwlock_init(&info->rw_lock); xa_store(&drv_info->partition_info, drv_info->vm_id, info, GFP_KERNEL); - drv_info->partition_count++; } static void ffa_partitions_cleanup(void) { - struct ffa_dev_part_info **info; - int idx, count = drv_info->partition_count; - - if (!count) - return; - - info = kcalloc(count, sizeof(*info), GFP_KERNEL); - if (!info) - return; - - xa_extract(&drv_info->partition_info, (void **)info, 0, VM_ID_MASK, - count, XA_PRESENT); + struct ffa_dev_part_info *info; + unsigned long idx; - for (idx = 0; idx < count; idx++) - kfree(info[idx]); - kfree(info); + xa_for_each(&drv_info->partition_info, idx, info) { + xa_erase(&drv_info->partition_info, idx); + kfree(info); + } - drv_info->partition_count = 0; xa_destroy(&drv_info->partition_info); } @@ -1547,7 +1534,6 @@ static void __exit ffa_exit(void) ffa_rxtx_unmap(drv_info->vm_id); free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE); - xa_destroy(&drv_info->partition_info); kfree(drv_info); arm_ffa_bus_exit(); } -- 2.34.1