From patchwork Fri Aug 23 16:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13775578 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95781C5321D for ; Fri, 23 Aug 2024 16:31:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B907C10EC73; Fri, 23 Aug 2024 16:31:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="FzMn1uA0"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D38610EC73; Fri, 23 Aug 2024 16:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724430702; x=1755966702; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=LQMHyKVEk5Sd65kgPIny1LTWyfVrYiYHslf4MDHVTKk=; b=FzMn1uA0Dg0xMVJaVyh0Jzu0mc70EbBZ+9AF/ccDwwVF3VkJVRsae/IP WZ+XWwstMs77rQKMSUA6l3V8OyauVa7w+2dUN5DW85CUECb5IiIdHfN6r A8VEl2C2BUs9YUItCijXfGGcyqmnCdh9rGhwXo27lC8AJsMmWIjepdjJE HgcxYKRC/fhwEKCh7lnqnRCOP/LQwDXPxzbTUjZmrV7TbiiUtFTLByhwV hf/vlcqK73AOFPJ9bfTOx2pq4eUBGBcmOPAkrSM+pZf/PEMjr068ZVIb2 15UbDw484bqw0z7k9xhQuIYAZ3S9Bb6gzltlzCbVDYLf7HodVKZM4Y7Z8 A==; X-CSE-ConnectionGUID: T1iH1dZcRYCU0Or6krE4KQ== X-CSE-MsgGUID: 9jG0nlAtS7W75wCPKGr/hQ== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="33529906" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="33529906" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 09:31:41 -0700 X-CSE-ConnectionGUID: D1uJMW4OTySh3gMFICLeYw== X-CSE-MsgGUID: 8DGR6+mMQrOrDeNkplTB0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="62556585" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 23 Aug 2024 09:31:41 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 23 Aug 2024 09:31:40 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 23 Aug 2024 09:31:37 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 23 Aug 2024 09:31:37 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 23 Aug 2024 09:31:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PXRF4XKXV2rhzs0V3JjB4TWUVbPbEsQiSLcPVPTLtMmJg6FGb2CpuAUfyeLZ4O4QOPPP3lDP/Z80NbxvNHcq9upc65aKLPxQ1M9aloNprt4XhJwIAnP7eJEjbALTeROJgwcnV7SwEqFRozj61vLOKswNkz6blA9Yq1Vlf9dWcyaC92/hTsjdBHG2zWR4eXEjAvlTAxhgnRzAqC5sntmgAvKLbFQoeBE1kYeD/C/xtIT8hTODkDkrCetPOKZ6c20vH/ZfT+v/S+fXcgfxkNSDcoYFtbYJfiQoGNsqrPNnYAmcirSCTnU+Y1EHtP+jpIecljs3BiH57dkSr1Wk1nThOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1GFpx2pDW5hR/tY9q1DIIzoFf5cZGjGy54QPf5P2lbw=; b=cZTVtC75qbVP4+en8HFUFijCAit20yD/ReSHKQLg9Yd1F7Ep4UF37RVvQmmYqNLlMF05J9KkfNeRzNuOc9j7e7SShNUVhM+VI3uejzZzEx09kvxrtkbZDMC0Mpf7jeFMTF4WWpuxSyyg14XLUbBBfdLmRuXMMbWdDkK7rnivs6NEdnt4G4N6qD5gWGbldUaROIwf+jll2LEhjk/cC/1m6S95b67HMsCoMNVEzohjWgTVNAAikYFiBL+29scJQ3RSzpa8hqkTU2vWTgi33ojei/LEsoljFJLeFgESqvWllSo4aQyUrGFqkC4QsZ1V5Lhl11TrVUeRdKgLTKpvPjHxkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by BL1PR11MB6026.namprd11.prod.outlook.com (2603:10b6:208:391::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 16:31:35 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%4]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 16:31:35 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , , CC: David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simon Ser , Matthew Wilcox , Oded Gabbay , =?utf-8?q?Christian_K=C3=B6nig?= , James Zhu , Pekka Paalanen , Emil Velikov , Alex Deucher , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [PATCH v7 1/3] drm: Use XArray instead of IDR for minors Date: Fri, 23 Aug 2024 18:30:46 +0200 Message-ID: <20240823163048.2676257-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240823163048.2676257-1-michal.winiarski@intel.com> References: <20240823163048.2676257-1-michal.winiarski@intel.com> X-ClientProxiedBy: ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|BL1PR11MB6026:EE_ X-MS-Office365-Filtering-Correlation-Id: 266334bd-516e-44b5-277a-08dcc3910e1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+Q7yTjq/kkBpsaIxFY/D9nzWF4Dbj9X?= =?utf-8?q?DugN7RPEUYoyxOFze0WqaS02v3R5RCQmrKLRKPLwNYx2mwRudHHsj5razZruLjniu?= =?utf-8?q?3Y5Ef6QOFhaGcVAPDg250KZHCukDJ8fenGTQI83ytBUQi58p8H1Mj0y9wCI7JZbZr?= =?utf-8?q?VQlzmGjgCDIAtJ9Y9xb55inTbUKWvarCI5tJSjSECN1YKk4jQkK4m63vfzV4QKEEQ?= =?utf-8?q?nCD3qWOzdHtwswNQmagm0OlgFMTtf9PclyPMDRXOHkhNoul3sKechgY/iwRrNfTWb?= =?utf-8?q?IMpb77uS0rKyFj19yHL5bt8mB13jEt+taTOu68SyBnOycF7G84Zfhn7JgUTpGOG2m?= =?utf-8?q?5l2KYeAnK9CdZZpe7iwtMnfgwlCH3aHKh5Yi/WpyzF1quy/yTKFtctGxuoNhTYecE?= =?utf-8?q?o8CuhPeY2qsJt8jaVLHD+a+DIiUrqRljwSt4ABlM9G25bdhnxvN+mga+4yYX8zFhD?= =?utf-8?q?Lb1pk1ErqM5MTcuyBS7Jt/6tcqdia53+w8jKBOMPl5BczUoBN0TNcy5PdrLGByA7j?= =?utf-8?q?jyKZR8MtyeFLVatQY9kHFNyPLraKuYoGY9UBdP0Rlz/UsbhMxTOCmEVcUSYKqPqog?= =?utf-8?q?jvVOHvA7DuQrM0H94/rl7UOyR2+aMOuo+8em5FgPj/6LFxEnTV2pjcJVHVmvCixc4?= =?utf-8?q?GwBHGQziY0Dnjiu/ttMPJJ3MbEeEWO47H7s07ModInA37kB9g99bj0T3qnznwE/7L?= =?utf-8?q?k2AJJSOYPMAhlcwybdhEpUan4n7Tng8iB/fB7uW77EmEmVo8ailtx6N49O1iD2tKH?= =?utf-8?q?FuY4Jj4KU2rwPNoqzshb1iLbQRR7uG1NPMK8vIHQ7mgutLt+5CTpneMAhBdAY30yG?= =?utf-8?q?fJR+UuRoZpwJQJjv0Z7QrMtdvrW7G+FqJ4zpfB8VVhL7e91INwan6C0xyE72O6ZD1?= =?utf-8?q?jcU6/T1QsoNrSbOHN90ZQDsg0GCJ1vW9Cxr8uhvinsa+s9XzLXMKhEW8lNq8/cvQf?= =?utf-8?q?rxIgLg1dxa3TmoJoO/0WniAcIkLbMPGPfVaPCTGAffPExh6cS8AK7MkeRpd5VopbO?= =?utf-8?q?G2XFp/6qFHHfIVF+vlysFjhouaFQ1qWhQLmJA/k2HyGY5A+wyT78SIRDwAZZ5trdQ?= =?utf-8?q?NJoTyVzViRDVvCNjt/NKX1CrG4lrNtKRhwTXGz9WjRKFOprXLJ6i6g9VNazLQIBMG?= =?utf-8?q?X2XdFWW4JyoGyn3E8OxjGGITLG5roDGq1jCyzchwvwdEayoBNsM1pUwOBUu5J55iJ?= =?utf-8?q?uoTT1nLR0vq5LAnMc9bU5BZuTRpIir/8XLUG7fYA/tH5Fv9tWAPGpJ3iyfl/XjxbU?= =?utf-8?q?obqYskyEtV1G67PW0ZM0ENhr2BcOO0GZIWg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?bSIl9tbcjSSqAjL31faoa1t89wlj?= =?utf-8?q?NU1GBTVOJD2sNIewgAXGeDQaQZOdOe37uymsd9OA0X1I1irg5pkaP/lecotaG1eMx?= =?utf-8?q?rwhotAhSNzVb7aHCVkwWjLGuko+WBuS5W1ygTXcFQjDHBSkUIvHBH2lsUQFiH1+C1?= =?utf-8?q?+vKyNmapBn0N3Efd+JbAfhKh4S0uR823+tXoS7DhcNFZgG6X30NStPPtPHhtKOVt/?= =?utf-8?q?XP33k65Gr5I8YDdDpG3ScPN82Uj6ouAS/MIWvFM3Bt9zxL5yeCi8F0sIcGAz/n6Y+?= =?utf-8?q?DykI3hMhMnHMTbvYZz1dFVvgjDhFYm3xbQ6ZZSUruQPgwa5d9cZWEqE2T4vwOKl4/?= =?utf-8?q?G40y8F9h61mTJa1zswbwQW65VUaxb8GlX1r+Tt4u/ioLnU0bokxj4bAsafqWt4FQs?= =?utf-8?q?gdAWseGqrjXeMXbBKd6AriE4SaykawpVR0vPnxsb2nDdsSuNLO2tOesKvBzhGbd/G?= =?utf-8?q?hbeEamPEgSgeIDg76Qksyd94p4LKbtkJQFTXj8llcQrf3pgbni0U54egmpsLCo1s2?= =?utf-8?q?Wy5xnmaG65KrsXYK8aAiyiOdqNXqsZNCVFznXmtFLMeEF7NAzQn7SAoaLN6ENUG1R?= =?utf-8?q?uLLcp7tARzJDswofu1avs8pUxQXweRl86xR7E+YcC/+L7VC8aWtrTqcRGwhzBcusA?= =?utf-8?q?Opx/rSQ+H6o5CRfSKKFknZx5CaNHB4yw8GTOXbwGmMNGbjhaS2fe35P7vZVr2Yfg6?= =?utf-8?q?rE5TRV4OWmd8/rFNURQ/u0iC73fFQTTyTxNPja4348XG5qPTXdvPdrmzPWo2csWxN?= =?utf-8?q?PTHt3gqXOPm1sH6Usx4ZnjnM0H3tjt4/C9Bsd+18WY4ZhU15erSAHsJKVXEvXw5bX?= =?utf-8?q?0jOo9ugpe3ZLF7MDABTCUeMI/sMsyWi9p5DXC95668eMclaHVXe0mtKEELVfIo9bE?= =?utf-8?q?EYf+DibDqd+nKPh6l1x426hYH5N4LvDiCDeDkxfmT8y82xL1kxhITPtDgJUv7b/26?= =?utf-8?q?X/6AZv/ps7lsLQB9o1ELilfrtT/BVEaDqcmFwo/nG1ra1/NK3m2JCyv+IvZ/M3/0M?= =?utf-8?q?WdXg98EDj3pLc7Y3JzI20wfT2ajMqOYZAtttjwiCc+AnnFylyN0atkrsJLgHyJdpU?= =?utf-8?q?SdI+hRhbRDgK/d2Yukmllr/5BO2U8U89Xll1jBllym2fhB+Vt94pQsNDDInP87avM?= =?utf-8?q?yqmXPnZeR+Wx3egUqYos7UYeUyTYMl84QR0zG/8KYqxS6kBvI/kilLp8vg98i+m72?= =?utf-8?q?S+ALfGEtolWKv2xd/uvjWfbu/vGNiFYg5Ys2iQVsRHoJlZ1B39+6VSUfKPv2tMlWF?= =?utf-8?q?V8j47FGcmMjCwTRAYRV00+1EsTUzY/2oHxc0QBEQLl2bkDRUxegXSW3/ZmJhTFbQv?= =?utf-8?q?S7FoQTZ8Ygp14TywmWFLQ7oKhmWeXrUWkoarFxgQBxqTey5T9gFp/0Z94suLglQcA?= =?utf-8?q?MizmFmcvQAjLnVaX1gRFGKNOjyUQirDmC8nHPoAD4feZQxL23T9jItvB+cOGUfC38?= =?utf-8?q?rg6auYxsO8+/2TscBnOBd4KjoYVJXcN8CoujVKREfb6Sc872dsBzRb90BLi16pSjb?= =?utf-8?q?7SVbJtWB8HiKcUNpn1lCAfqAeqhotQ19dQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 266334bd-516e-44b5-277a-08dcc3910e1d X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 16:31:35.5510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wwzDsNgzmco0SBGXjM1tjct8QpbzCzMnYzMquFgjuH8GMwhPUC2I5ZWGkVhz4Z1S/0p0b7wKSJ5AHAnE3BDNS9rdqJPrc+xPiS9qI1fIFyc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6026 X-OriginatorOrg: intel.com X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" IDR is deprecated, and since XArray manages its own state with internal locking, it simplifies the locking on DRM side. Additionally, don't use the IRQ-safe variant, since operating on drm minor is not done in IRQ context. Suggested-by: Matthew Wilcox Acked-by: James Zhu Signed-off-by: Michał Winiarski --- drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 93543071a5008..ae675a588a1df 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"); MODULE_DESCRIPTION("DRM shared core routines"); MODULE_LICENSE("GPL and additional rights"); -static DEFINE_SPINLOCK(drm_minor_lock); -static struct idr drm_minors_idr; +static DEFINE_XARRAY_ALLOC(drm_minors_xa); /* * If the drm core fails to init for whatever reason, @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev, static void drm_minor_alloc_release(struct drm_device *dev, void *data) { struct drm_minor *minor = data; - unsigned long flags; WARN_ON(dev != minor->dev); put_device(minor->kdev); - if (minor->type == DRM_MINOR_ACCEL) { + if (minor->type == DRM_MINOR_ACCEL) accel_minor_remove(minor->index); - } else { - spin_lock_irqsave(&drm_minor_lock, flags); - idr_remove(&drm_minors_idr, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); - } + else + xa_erase(&drm_minors_xa, minor->index); } +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); }) + static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type) { struct drm_minor *minor; - unsigned long flags; - int r; + int index, r; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); if (!minor) @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type) minor->type = type; minor->dev = dev; - idr_preload(GFP_KERNEL); if (type == DRM_MINOR_ACCEL) { r = accel_minor_alloc(); + index = r; } else { - spin_lock_irqsave(&drm_minor_lock, flags); - r = idr_alloc(&drm_minors_idr, - NULL, - 64 * type, - 64 * (type + 1), - GFP_NOWAIT); - spin_unlock_irqrestore(&drm_minor_lock, flags); + r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL); } - idr_preload_end(); if (r < 0) return r; - minor->index = r; + minor->index = index; r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor); if (r) @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type) static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type) { struct drm_minor *minor; - unsigned long flags; + void *entry; int ret; DRM_DEBUG("\n"); @@ -189,9 +179,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type) if (minor->type == DRM_MINOR_ACCEL) { accel_minor_replace(minor, minor->index); } else { - spin_lock_irqsave(&drm_minor_lock, flags); - idr_replace(&drm_minors_idr, minor, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); + entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL); + if (xa_is_err(entry)) { + ret = xa_err(entry); + goto err_debugfs; + } + WARN_ON(entry); } DRM_DEBUG("new minor registered %d\n", minor->index); @@ -205,20 +198,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type) static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type) { struct drm_minor *minor; - unsigned long flags; minor = *drm_minor_get_slot(dev, type); if (!minor || !device_is_registered(minor->kdev)) return; /* replace @minor with NULL so lookups will fail from now on */ - if (minor->type == DRM_MINOR_ACCEL) { + if (minor->type == DRM_MINOR_ACCEL) accel_minor_replace(NULL, minor->index); - } else { - spin_lock_irqsave(&drm_minor_lock, flags); - idr_replace(&drm_minors_idr, NULL, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); - } + else + xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL); device_del(minor->kdev); dev_set_drvdata(minor->kdev, NULL); /* safety belt */ @@ -237,13 +226,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ struct drm_minor *drm_minor_acquire(unsigned int minor_id) { struct drm_minor *minor; - unsigned long flags; - spin_lock_irqsave(&drm_minor_lock, flags); - minor = idr_find(&drm_minors_idr, minor_id); + xa_lock(&drm_minors_xa); + minor = xa_load(&drm_minors_xa, minor_id); if (minor) drm_dev_get(minor->dev); - spin_unlock_irqrestore(&drm_minor_lock, flags); + xa_unlock(&drm_minors_xa); if (!minor) { return ERR_PTR(-ENODEV); @@ -1071,7 +1059,7 @@ static void drm_core_exit(void) unregister_chrdev(DRM_MAJOR, "drm"); debugfs_remove(drm_debugfs_root); drm_sysfs_destroy(); - idr_destroy(&drm_minors_idr); + WARN_ON(!xa_empty(&drm_minors_xa)); drm_connector_ida_destroy(); } @@ -1080,7 +1068,6 @@ static int __init drm_core_init(void) int ret; drm_connector_ida_init(); - idr_init(&drm_minors_idr); drm_memcpy_init_early(); ret = drm_sysfs_init();