Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp453468lqi; Thu, 7 Mar 2024 02:08:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUy0vs0mSg/rJuzIqimvUraxjbaTgd7MywsXXGuURAp6Y7L1cFWKS5Mzclna1cLHwYSd7eTUbjmA2pA1AkE44/qOR/fL0udbDPF+4pgQQ== X-Google-Smtp-Source: AGHT+IGt7EG2wmFtB2GgXtakKkBKAGwvQQVgV5tIg2w8UdMgF+/PMuHDbeiKiGs8flm/NV3Y5S+k X-Received: by 2002:a17:906:aa0e:b0:a45:4ba5:2917 with SMTP id ko14-20020a170906aa0e00b00a454ba52917mr7459129ejb.75.1709806115035; Thu, 07 Mar 2024 02:08:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709806115; cv=pass; d=google.com; s=arc-20160816; b=RveVTNYRC+btvRo6le5AiBUjIfdOfHQGlHDVPqDao9vV1eBVGQEV+p30+Zia+ndRCq IO5l5g/5A+xZs/WldmyYQ6skoFy5LU2XlRC5UlTWT5JNbdzTihVY/69FBPnVaVGRYjwf wsrM/46KbjbtTSUKL8i1I4AJt9OguuMSKv+wvEC7BiFZhmDLVDFNv0CUiq4xna7Plogd ogVDFHXJ/IDB6W45iSl7BfIWcpt9NDKs/QLI6RvRLIDZ8pHSXdjU5Z3fmgH/ywqEE+Py lcqC51nx5jpiqqQFQsmyjNQQOKtg8Wyz0UG5cO5TXeWOG1CKbVcTlQIZqGCiiCU6uf4X K1mA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=d/AxLRpsUHIVLv5pAaSheWeekhAHfnPjwxXQfah+6YU=; fh=ThUcshtYyhL/9JFsRjeEEOo8dAIaN2s39kf/dHZH3pg=; b=v+c0m6yy9Ytf/mSRZdh6hcEGuFiuqtTBeWQVfBh+QzNemWksNYyxmR9VoR/e/qp9uI /FznNvAiHsuZJPATI5ikHwvUf8Iam6E0JzgX7HhDQWS1NmdMUEfOdnHKfQXif3U9KAuo ZSCPMPc8ig/V6xVDCuOUOfB0/f8b0f59Qf1jPrBaTXetGM7NWRrPFOGA7NFR/nkTe9au 1poO+x7+libjtD/9cXxA7+L9cENahv+N4VebhuPaAq2dtqeazll25GS5JemYVUQzYcwo xsL6Sq237j6tmqQADPauizJGohso3pkfhKXhnyj8vh18YArC0iFY+7v4EQuZg/ZWnqO8 lkRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Qj8U/JRm"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-95295-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dm13-20020a170907948d00b00a45c98f5841si656922ejc.986.2024.03.07.02.08.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 02:08:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95295-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; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Qj8U/JRm"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-95295-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 B3F891F257E2 for ; Thu, 7 Mar 2024 10:07:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6665712AAD4; Thu, 7 Mar 2024 10:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Qj8U/JRm" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E64129A9D; Thu, 7 Mar 2024 10:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805816; cv=none; b=ksxWS8TEOw104dXSl4G8RT+Ere0fZUcMVyL+8CxoNS0ZhipOEF26jtgiizBy/+GiBfe2a7Cbx/UFIZ7LDtd2CLEIZtprKZPjlHF+nUB4kervKElGG8kLhMQja+4FuHVC9DMJU+eUybjlr8cN4gCeqk0lEXVlwRhKROEhBS6js4Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805816; c=relaxed/simple; bh=ZmM/KDvL4dsGZN7+nQnXpHO7MKx8VXGPnCH7JpgtyqY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jLY0LYDRBbKLFei3Y4AUzpAjTrT9BohKrrPMIJyuRMTzIYwtkEeHrS9d5a2InMdvfWhUicNS9A9guNUDztO83qnlAQavGrlPIAYmO98hGIbli792pPMmOSrTraLi9iYxZfbv1KWHRyzrVa2o3qPtPgioesJRl/yRHpj2uaiOKdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Qj8U/JRm; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 52EB5C000E; Thu, 7 Mar 2024 10:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709805807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=d/AxLRpsUHIVLv5pAaSheWeekhAHfnPjwxXQfah+6YU=; b=Qj8U/JRmx+7EoLMa7KGqnsUrERG4eKO3WkyNvqdMaHf+F+FS51elY5zNcM83F7cBUVVo3H TIALt9cEtANxEtLjHm6wipmzdgXMrEsHTyCA4Jr6sRlLX10Lps6MMIVb7O0y9hnw9x3anP AUWCeDHdFvCPKGQZSUdBwn5lE9PtNMs6WbrlwMDOo/wuz3yu5bI5ENuBOtI+TPbwZDK3kT CO7vJ88N3r9yNKo2KfCL+ypGZ0D2z2rzi/tx8UHhGuAJ3DDIbkGI3Dspz496RQ8p6hnO82 TZXJYQ9GFvUxD9M6zY0MzrlZOufVcpJfayMu9Dnr4t3b7Oim0c6UQSBGBwuoug== From: Kory Maincent To: Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, Richard Cochran Subject: [PATCH net-next] ptp: Move from simple ida to xarray Date: Thu, 7 Mar 2024 11:03:26 +0100 Message-Id: <20240307100327.887758-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: kory.maincent@bootlin.com Move from simple ida to xarray for storing and loading the ptp_clock pointer. This prepares support for future hardware timestamp selection by being able to link the ptp clock index to its pointer. Signed-off-by: Kory Maincent --- --- drivers/ptp/ptp_clock.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index 3aaf1a3430c5..392c880d9f34 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -31,7 +31,7 @@ struct class *ptp_class; static dev_t ptp_devt; -static DEFINE_IDA(ptp_clocks_map); +static DEFINE_XARRAY_ALLOC(ptp_clocks_map); /* time stamp event queue operations */ @@ -201,7 +201,7 @@ static void ptp_clock_release(struct device *dev) bitmap_free(tsevq->mask); kfree(tsevq); debugfs_remove(ptp->debugfs_root); - ida_free(&ptp_clocks_map, ptp->index); + xa_erase(&ptp_clocks_map, ptp->index); kfree(ptp); } @@ -246,11 +246,10 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, if (ptp == NULL) goto no_memory; - index = ida_alloc_max(&ptp_clocks_map, MINORMASK, GFP_KERNEL); - if (index < 0) { - err = index; + err = xa_alloc(&ptp_clocks_map, &index, ptp, xa_limit_31b, + GFP_KERNEL); + if (err) goto no_slot; - } ptp->clock.ops = ptp_clock_ops; ptp->info = info; @@ -378,7 +377,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, list_del(&queue->qlist); kfree(queue); no_memory_queue: - ida_free(&ptp_clocks_map, index); + xa_erase(&ptp_clocks_map, index); no_slot: kfree(ptp); no_memory: @@ -511,7 +510,7 @@ static void __exit ptp_exit(void) { class_destroy(ptp_class); unregister_chrdev_region(ptp_devt, MINORMASK + 1); - ida_destroy(&ptp_clocks_map); + xa_destroy(&ptp_clocks_map); } static int __init ptp_init(void) -- 2.25.1