From patchwork Mon Feb 26 13:39:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 206630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2082115dyb; Mon, 26 Feb 2024 05:42:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgwFb9JpCSQ3lu2yuCRzSbJ6XvgNGhhRa6KYsIbZ6bnAzmBQymuVMlZU1IIjI9isiNyOMWAtVtupQ4p4UTRO/izrnjHg== X-Google-Smtp-Source: AGHT+IFMR84MgUY4Qqc3IPWSKGN5OhezoaGXkhmzkXvUFprzw+YzalrFd2KaFNz9+IVZ5Bkc+U3+ X-Received: by 2002:a17:906:a88e:b0:a43:8e8f:40c8 with SMTP id ha14-20020a170906a88e00b00a438e8f40c8mr263907ejb.0.1708954950972; Mon, 26 Feb 2024 05:42:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708954950; cv=pass; d=google.com; s=arc-20160816; b=nk06MVVWjfz6cLCKhomCTLF5yc4nhCS7q9LH0SgMb6kGQXvT+GDRDoQO3CSfUtOK9x pth5jSR4UNbQYWQIP3HgH2yejAltLig9uHvcB9eHAuqh8u4dxjteO20og+v1/YYAbu2N Zvapggi7X5yIEjnA4eAuSCkWEtj5MYEmBsBS4njAuYI5xzqVryqunYlfl6e1BZn+Z9C/ hYsKGetrXiRtgyzDUCzMz67XB4RM/NUZCUBq1jlkT385HY+6LFOxTJNeHdOMlyjEtOXS dkR62rgkXq9R8a0J1Mk0PIAONTwVi8tMXDJOKN5R3v4naWGz30LJqxq8N0mrB92mfpC3 3v2g== ARC-Message-Signature: i=2; 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:dkim-signature; bh=Vt7pqaInPUQVg2cWblp5rRamZytG6+i7+g/PwgWu1us=; fh=vtlcgQ30nO0QjQR7y1Wfn7g9c11A+T6SWcSZ6WixcJI=; b=bXj24WMS9V58Ccm1WURXo3ZCX38rkqFRDlT5GBbdj1fgr+5UZArSh+1CewengRSbGE r1MeQx3ASOTtO5I0D7nTA61D89IjOzZ0U4csi1+FGi3f2BXwig7g91+7w0mcQ2YKyF93 eJo15BzhLQKqdBxp1Bejp6euDeduuH0gSxyeGmNN3AVmwiod9qZm4s37L5/klDV2itCi VvmfBI2cRAeUhEjTBdZKme2maXg5bgQywiYxt+WWfvUKt+p++cs6Baj8I8Ad1PykQuCE pQA8qAtS+Q0kpK6Ay4WeY7nZuFcMDd6RKxLcPki63mCJxhsvJBcgTo9hKn0SxptvHCJO E6rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dZq1GW+U; 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-81507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81507-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qa18-20020a170907869200b00a3f779a7ba7si2175589ejc.485.2024.02.26.05.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:42:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dZq1GW+U; 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-81507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81507-ouuuleilei=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 73A8E1F27F53 for ; Mon, 26 Feb 2024 13:42:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08C4D12C550; Mon, 26 Feb 2024 13:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dZq1GW+U" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 E61B512BE8A; Mon, 26 Feb 2024 13:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954824; cv=none; b=m3pNUoPHYuh2nTuMTlLrfw4B3b/kovL7RKuL2jneWaPg8a92QUHI0Rw6lZw2TOSGar90rixM7FyhE3G8ZKCBkNDo8n9+sY1QLTYb/nq6d8dJDmXFn+77yisXJ+dQyINrtZjgXPYcZyoUndcA9z5YF9gg48yGBJtd2lGRU0vmSvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954824; c=relaxed/simple; bh=t9DftvwHYXJXtsEXtK9HBnIXPvK2VHYobKs97PldUo8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o3pSApAeDyx3mMCf3WcfoE5IAup/8KUGQxUuon5PSrpoqQR3VlS8djMj7CVOuWH+wERWRfRF0PeEwi9C5dpLSBp1W0e7zq6akdISiVZNhOtpaVFxRchuPLQNvsKgVsqwS41F+RFjF2FfJx9SNVrXYP23YpXIJgejk63y16CFXtk= 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=dZq1GW+U; arc=none smtp.client-ip=217.70.183.194 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 5A97840005; Mon, 26 Feb 2024 13:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708954820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vt7pqaInPUQVg2cWblp5rRamZytG6+i7+g/PwgWu1us=; b=dZq1GW+UEpEo83BboWrvtDMWPAGFxaUcbSnq/vgaLFIGb3CkEZIaUI1YIvvZqlgDXE1Iux qYyuOcp38TVii0QQprYgqIgCWziChp8AMytvNLa7UnWIIH0eMg2FarVR56sIEbv0aV6qhg He2m8S8XsrzJWdk07PZMGgdkCy1QN013XLrsXjHamf3eWAxJ4llWNzrE5eyiHhZkrksWZX GG01sjWDKSJC5RYZ8LRjkmV3J1WiEX5tE3MYHS5DrrDmtKeVPlJajMhrTwdxYmisI4skUW g8Wt4FlGf7hxKjHo2OTdVlQ+PTW2JlHnevhyr+STMMnMqryTb1M57Vans0pN3g== From: Kory Maincent Date: Mon, 26 Feb 2024 14:39:58 +0100 Subject: [PATCH net-next v9 07/13] ptp: Move from simple ida to xarray Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-feature_ptp_netnext-v9-7-455611549f21@bootlin.com> References: <20240226-feature_ptp_netnext-v9-0-455611549f21@bootlin.com> In-Reply-To: <20240226-feature_ptp_netnext-v9-0-455611549f21@bootlin.com> To: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Rahul Rameshbabu , Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791969146352179132 X-GMAIL-MSGID: 1791969146352179132 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 --- Changes in v8: - New patch --- 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..f374b1e89780 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_FLAGS(ptp_clocks_map, XA_FLAGS_LOCK_IRQ | XA_FLAGS_ALLOC); /* 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)