From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 AAFC1272E67 for ; Mon, 18 Aug 2025 19:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543674; cv=none; b=e9imrxRvO/WNC/9M3n0v8JKUNR3wHjqextAvAawZBGsxZiiif1BlsZV+aWIJbVR5Kh5UE3x0hy1TYv1PMwEajUhzhtGzaYrOPnW7SHv5gl25N5x9HddMlssOEKhP7FBUkjQpkHa74chs0uD68yW12SeUSGo5UQyW1tvQSrT81m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543674; c=relaxed/simple; bh=ggOUmoAWgcJIqOg3JSRN/dabSPg5VetLhtsTjmVSjEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y0ZNmHft6LGsZXM6JHIAjeoR1V8HUYt5fQhGfwzXIfENUqxt9trFPEX3+1b2cGfuigrgdWFrEqx8o0N/XmXkkQzze0H/NtWpLKtpymntO2AzxW6est70wV8VWaHypKE4DV5Wg+1PkrBvfQgT2+urnLXioCbx8ATDd8dM3KPT7/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=HJ+GC+xj; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HJ+GC+xj" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEuCON030521; Mon, 18 Aug 2025 19:00:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=P8R2w JMavJM/HWLVU4xgPHCCkOrfB5Cm79QNOCOwutk=; b=HJ+GC+xjL5KVGenGyv9Cr I0ENd4JpDbcDVaE5HOVXI6JLPrNxv9wlG9rR9AIxC2hUSSWHqRfvUSDRvUKtn83K FQDlbL9gj4w6wysFALzWXYR6n2e1H57uFGFBdnrBZwPYWJNlc0x2kX1A/LdUrBV1 bS4TP2hcjsrA4Q/RW5DMlMSSXu/cFoT2zI1GwFXlxw8odFrya57T0W704fjChkoj c3OCyh1DQuFgBvg1WbmvPYnVqphu2W5i3PL1HVo0zWL3g3gUVIk03//Lw6/mIIPq bGriSGV9ozR097jR2P4nIWV4XhgygDdm7wEf1tMBaI6EZsAOpDgDU2RlLKDNa8wA w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jj1e3tt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:00:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57II07VV016778; Mon, 18 Aug 2025 19:00:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d7tx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:00:56 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZV035076; Mon, 18 Aug 2025 19:00:56 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-2; Mon, 18 Aug 2025 19:00:55 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 1/6] drm: Convert aux_idr to XArray Date: Mon, 18 Aug 2025 19:00:41 +0000 Message-ID: <20250818190046.157962-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Proofpoint-GUID: kikCSgG1Iz0viikSs0uQBKblV57_AJ0M X-Authority-Analysis: v=2.4 cv=dN2mmPZb c=1 sm=1 tr=0 ts=68a3786a cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=bhnSk7d9TMSBOys-tl0A:9 a=1CNFftbPRP8L7MoqJWF3:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3OCBTYWx0ZWRfXyyb9aci2qd20 JaK82F/XDgzEcGCpN6QeRt6dCL6IxxII4ZMhOSpjxuGrvQLR8u3u0vJ2iqn9BmChpaFefRV4knr aVacq1QO6obv2rDv2h4SbBFrQ2hu13y2Lf4RsWkwWfa5YpNpy8bpc7J7M5W76lNtS2NZkv93Wb0 rqX0G84buQk0uGIMgvNVp9K6YigMYrvN0yTR/J929hKq7hNHWXwk9BVPCAh9W8CBwCSkH/YHqvs 6vwVfSFc9jnxR6f+DUnzna4OFqYaEoh4CElK9ZCw9UZ1A3qceXr7vrWG3rarCdwflKsuKGmy3ua CRWZDF4NY6rR9iw+HuZMCrQvA8MOEkr7djMDlhP1FS+3ysXiP12jBwh3qTIop4vObZSdbmuiX3z Q1MpRliDQw+tBcq6vI5HHsAHJnKpsUJ38Tht+9W6gAwZhPLqZhWZHea3r8U7EmrhKJA4UK3H X-Proofpoint-ORIG-GUID: kikCSgG1Iz0viikSs0uQBKblV57_AJ0M Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox Remove aux_idr_mutex by converting aux_idr to an XArray. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/display/drm_dp_aux_dev.c | 38 ++++++++++-------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_aux_dev.c b/drivers/gpu/drm/dis= play/drm_dp_aux_dev.c index 29555b9f03c8..edecfea44da8 100644 --- a/drivers/gpu/drm/display/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/display/drm_dp_aux_dev.c @@ -52,8 +52,7 @@ struct drm_dp_aux_dev { =20 #define DRM_AUX_MINORS 256 #define AUX_MAX_OFFSET (1 << 20) -static DEFINE_IDR(aux_idr); -static DEFINE_MUTEX(aux_idr_mutex); +static DEFINE_XARRAY_ALLOC(aux_xa); static struct class *drm_dp_aux_dev_class; static int drm_dev_major =3D -1; =20 @@ -61,11 +60,11 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_min= or(unsigned index) { struct drm_dp_aux_dev *aux_dev =3D NULL; =20 - mutex_lock(&aux_idr_mutex); - aux_dev =3D idr_find(&aux_idr, index); + xa_lock(&aux_xa); + aux_dev =3D xa_load(&aux_xa, index); if (aux_dev && !kref_get_unless_zero(&aux_dev->refcount)) aux_dev =3D NULL; - mutex_unlock(&aux_idr_mutex); + xa_unlock(&aux_xa); =20 return aux_dev; } @@ -73,7 +72,7 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor= (unsigned index) static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux) { struct drm_dp_aux_dev *aux_dev; - int index; + int err; =20 aux_dev =3D kzalloc(sizeof(*aux_dev), GFP_KERNEL); if (!aux_dev) @@ -82,14 +81,12 @@ static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(stru= ct drm_dp_aux *aux) atomic_set(&aux_dev->usecount, 1); kref_init(&aux_dev->refcount); =20 - mutex_lock(&aux_idr_mutex); - index =3D idr_alloc(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, GFP_KERNEL); - mutex_unlock(&aux_idr_mutex); - if (index < 0) { + err =3D xa_alloc(&aux_xa, &aux_dev->index, + XA_LIMIT(0, DRM_AUX_MINORS - 1), aux_dev, GFP_KERNEL); + if (err < 0) { kfree(aux_dev); - return ERR_PTR(index); + return ERR_PTR(err); } - aux_dev->index =3D index; =20 return aux_dev; } @@ -250,22 +247,19 @@ static const struct file_operations auxdev_fops =3D { =20 static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_aux(struct drm_dp_aux = *aux) { - struct drm_dp_aux_dev *iter, *aux_dev =3D NULL; - int id; + struct drm_dp_aux_dev *aux_dev; + unsigned long id; =20 /* don't increase kref count here because this function should only be * used by drm_dp_aux_unregister_devnode. Thus, it will always have at * least one reference - the one that drm_dp_aux_register_devnode * created */ - mutex_lock(&aux_idr_mutex); - idr_for_each_entry(&aux_idr, iter, id) { - if (iter->aux =3D=3D aux) { - aux_dev =3D iter; + xa_for_each(&aux_xa, id, aux_dev) { + if (aux_dev->aux =3D=3D aux) break; - } } - mutex_unlock(&aux_idr_mutex); + return aux_dev; } =20 @@ -284,9 +278,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *a= ux) */ aux->drm_dev =3D NULL; =20 - mutex_lock(&aux_idr_mutex); - idr_remove(&aux_idr, aux_dev->index); - mutex_unlock(&aux_idr_mutex); + xa_erase(&aux_xa, aux_dev->index); =20 atomic_dec(&aux_dev->usecount); wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount)); --=20 2.43.0 From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 070D3274B3E for ; Mon, 18 Aug 2025 19:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543674; cv=none; b=QOBdPRfXLIdk5y/GFPWrCbdAnPNcH1/VkoVntzIlRLMg1dh9GTZVM/ZIU0zU9F2RMZsUPexaWQT9LmJxjM2XLvlTXWViv2EJx7ZJVDff+Ned5YtM8+fHAHqKDE2yZyN1kekaBBddFup7Q1DNIKhl11UYQlx9RPQN26if28eQyjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543674; c=relaxed/simple; bh=XYLPAxHSXVybcDQwFcMG0IPx7i7/Um8JTQBGd+GKCis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tg0h5S5N/EsnaE5Y9epmwqM1Xg4PEnFGEkxeVzP4qD69Ce9oLIKpRSSUbHh3uDJF36tqEF408UsFUrBGvf7rHlXRVyKimJG376C0sxtwFMUNFOHtSWGybfPxfe43F+Yng/kq2ZW2ipiMAjkbSI5SJN5DkFzq3ILgrMZUrufs4cY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=P04c4/ns; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="P04c4/ns" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEtnuN020970; Mon, 18 Aug 2025 19:00:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=kfHAn PgnmkpNKS+OEMuVhsU/8JXLMmxSFrlGGE9oFNI=; b=P04c4/nsemFlKYqupYLPw OY7F4q0TALpDgFX1tiYMMVvHXtCrPe1XV7JNL+J0y22oEOiS7ZeQp0PSQB8uTIqe ri24EdcJBYqctPuR+Xhz8HLD0RkcaVJwoxquJjoXXj13F9vrzVoYkEw/zpZ1+2Bp qq4z14rkNJ16nF79obOCsulfRBPI532Y101yuj0UN6NvUeX6EJD0luv1dwn+KVwJ N6Tm+frzeEUAveWFZD2EemyMq9U2roIsgEwlJgatICm0G3AZNb3LmKzIErYf0ZO7 ZoYp8Cn7NmSspcv4ZB8ZV9z53OUG9PJ1nZyeAKMkuiF5tFPOuh7Zzi9FdtCuFwej A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jgs5ku33-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:00:59 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57IICQcX016749; Mon, 18 Aug 2025 19:00:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d7wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:00:58 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZX035076; Mon, 18 Aug 2025 19:00:58 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-3; Mon, 18 Aug 2025 19:00:57 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 2/6] drm: Convert object_name_idr to XArray Date: Mon, 18 Aug 2025 19:00:42 +0000 Message-ID: <20250818190046.157962-3-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Authority-Analysis: v=2.4 cv=DLiP4zNb c=1 sm=1 tr=0 ts=68a3786b cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=DK_Tli1e-HrAiUtdIdsA:9 a=1CNFftbPRP8L7MoqJWF3:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3OCBTYWx0ZWRfX6+6gLROxFPsy S42h3smYPDcgqQMHXSmFpSDZjCSAYNal4CJsOBvb7p9fKdpve4pPC/DEzaergxXdANqmMvqcFev ujPgljE6nxNYR13+GPHMXzhl3pPoI8O4wUohKsgK/1/xITpo0/1BbdYnxYrq2qO2YIo+jCTcj11 23+EvmfOi/z6OVCeimEmR3T/O4+Bu01e4/E3d4ilk55icYui6j3FZfgO1YinD5cVYFdces3+6bY 3yxII6m422TEpFlrSg77xZujQe+xy3jG5y/U+CpuByYZ0mjBB9D+T4PaAfNELzNLH77mnST9TmO mfp5dubSB8st2qygmL2YmLAKb5ygGpJvo0vY7MBF/cV6TbQHv3zEGjCWB+0WkUR0RipKMeI5deu 4WTlKqyAOg7u/NpUldT6+/Y/TYB1QIADHCNXhOfzWjkEnNE6LkCXJ/kHhtve5G15IRH4XPfy X-Proofpoint-ORIG-GUID: hLQLFf36K6JREgNDEIBgb_4nVOueVzLW X-Proofpoint-GUID: hLQLFf36K6JREgNDEIBgb_4nVOueVzLW Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox It's not possible to replace object_name_lock as it protects more code than should be reasonably be run under a spinlock, so the xa_lock is nested under the object_name_lock. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/drm_debugfs.c | 19 ++++++------------- drivers/gpu/drm/drm_gem.c | 11 +++++------ include/drm/drm_device.h | 4 ++-- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 3dfd8b34dceb..2d37ee7f70fb 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -117,27 +117,20 @@ static int drm_clients_info(struct seq_file *m, void = *data) return 0; } =20 -static int drm_gem_one_name_info(int id, void *ptr, void *data) -{ - struct drm_gem_object *obj =3D ptr; - struct seq_file *m =3D data; - - seq_printf(m, "%6d %8zd %7d %8d\n", - obj->name, obj->size, - obj->handle_count, - kref_read(&obj->refcount)); - return 0; -} - static int drm_gem_name_info(struct seq_file *m, void *data) { struct drm_debugfs_entry *entry =3D m->private; struct drm_device *dev =3D entry->dev; + struct drm_gem_object *obj; + unsigned long index; =20 seq_printf(m, " name size handles refcount\n"); =20 mutex_lock(&dev->object_name_lock); - idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m); + xa_for_each(&dev->object_names, index, obj) { + seq_printf(m, "%6d %8zd %7d %8d\n", obj->name, obj->size, + obj->handle_count, kref_read(&obj->refcount)); + } mutex_unlock(&dev->object_name_lock); =20 return 0; diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 4bf0a76bb35e..27a7069d819d 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -96,7 +96,7 @@ drm_gem_init(struct drm_device *dev) struct drm_vma_offset_manager *vma_offset_manager; =20 mutex_init(&dev->object_name_lock); - idr_init_base(&dev->object_name_idr, 1); + xa_init_flags(&dev->object_names, XA_FLAGS_ALLOC1); =20 vma_offset_manager =3D drmm_kzalloc(dev, sizeof(*vma_offset_manager), GFP_KERNEL); @@ -257,7 +257,7 @@ static void drm_gem_object_handle_free(struct drm_gem_o= bject *obj) =20 /* Remove any name for this object */ if (obj->name) { - idr_remove(&dev->object_name_idr, obj->name); + xa_erase(&dev->object_names, obj->name); obj->name =3D 0; } } @@ -908,11 +908,10 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *dat= a, } =20 if (!obj->name) { - ret =3D idr_alloc(&dev->object_name_idr, obj, 1, 0, GFP_KERNEL); + ret =3D xa_alloc(&dev->object_names, &obj->name, obj, + xa_limit_32b, GFP_KERNEL); if (ret < 0) goto err; - - obj->name =3D ret; } =20 args->name =3D (uint64_t) obj->name; @@ -948,7 +947,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data, return -EOPNOTSUPP; =20 mutex_lock(&dev->object_name_lock); - obj =3D idr_find(&dev->object_name_idr, (int) args->name); + obj =3D xa_load(&dev->object_names, (int) args->name); if (obj) { drm_gem_object_get(obj); } else { diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h index e2f894f1b90a..7d8244078d51 100644 --- a/include/drm/drm_device.h +++ b/include/drm/drm_device.h @@ -314,8 +314,8 @@ struct drm_device { /** @object_name_lock: GEM information */ struct mutex object_name_lock; =20 - /** @object_name_idr: GEM information */ - struct idr object_name_idr; + /** @object_names: GEM information */ + struct xarray object_names; =20 /** @vma_offset_manager: GEM information */ struct drm_vma_offset_manager *vma_offset_manager; --=20 2.43.0 From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 2FD602D24A7 for ; Mon, 18 Aug 2025 19:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543680; cv=none; b=TAZtAhNKrSxVpJW/vv79Yl/zK09jHbcBBEnEWLHoWxC5uLo61k38Q+Q2zGimTo+TpUd0pMzqFC20URNMNn4GRTGL5LLWLNBDFIeqFCBsCIrDjip+2hAlF29GCefKV6Tdz6mUImMR9VdDsRLXPm4nORUR4VoUOqRV8fWLbY1frbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543680; c=relaxed/simple; bh=J8FzFJe+D5zlLK80oZ76E2Zxv+yZXN+Ib1vx0wucb98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ltsdyNPX7b2v2hNte61mIk/VxmxHsBU9AwBgkcWuWt58rvgTOa5d6ZRaSxTUM8qcatzE+hAWIMPEsMZbs+I4nf46IDjVz17J3NE8WmZc0W41xA7xUHWlTVIbCaovS7fF4BfXLze6m1FEG1XVbg9FWX7T/KGT2SOPY8ou/4t6yM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=b48qQMJ5; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="b48qQMJ5" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEuHE2020507; Mon, 18 Aug 2025 19:01:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=VBCCe /d9WQBwETiM5fykv7+3abmROBsMk/JwG5aC7Wg=; b=b48qQMJ5ik2AuJZ/lUreZ gqFP0Axpm8Yw2eAEVvS6kHfTq83y0/u5wXDUjtLmV4HZDTst9L4j9zfcdJsM7u2l i07n4X2wM0adLGhOvh70fYieowUikkOjvDy1fyHFIqog5qkaDz8zh/t0I1Nm/4AV aJl3bcUrIW3uaC69ZkpTkxGWoMyEcYMz/7mugYe2kj4VVgKQWxMrdbRDBQOhG2NU nq8fdMHZcYcYFCECpmKvboPj8uTGFW+eJK4UTSRscQrz7rbWrtqgaradsge0m5rx m6ZaLAdChyOya6TvCmZv0OyEK+XHty6JbqPXIxNg30fp98k+9W4FQzJr0fcwHrz0 g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jhkuus3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57IHiIAn016983; Mon, 18 Aug 2025 19:01:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d7yq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:00 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZZ035076; Mon, 18 Aug 2025 19:00:59 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-4; Mon, 18 Aug 2025 19:00:59 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 3/6] drm: Convert syncobj_idr to XArray Date: Mon, 18 Aug 2025 19:00:43 +0000 Message-ID: <20250818190046.157962-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Proofpoint-GUID: X6yXwbbrKMoEawDTRElUtYA6dzYV9wTg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3NyBTYWx0ZWRfX8Sir6UUxhEYJ AxYonMk6soBfBLH5k+Spj1DA4uIdlt0hBuOm6Ez6oQgv4Wl6gEMvfTfPwxTVkWBaMn6TN28p2d5 tQV0wFjDfSZ7YGRAePPGls4dIaPLmhYgqL1gwtQqahsOQzvyEgXE6ifYm+kRD//DBp4Fc6HgKBO 5M+BunyBny+RPTUYHy/T/TcGRvZYRrX5/mcXMORyDR3b3s1WGFiSZcg3KeZVrLh0OdM52uZI0Id rFovQhxaRh6VWUtlcqom7MgM34d7C+O6qUkJj68r8OB37XFyfsV9NX2/PqC5Ve3494ffhEj8Si6 rkBpxP4PBcGOZBSOe446DWYD4pI6Lkmn9fDcziNnYuo8qhN9qSYqZpASv4G3BqDCzRUdPziCsx3 /dTVhul8097ApnfVDEz+Z0yOSbChqErcPMYGPfjln3t/apEAS7TPzJSQ7zhi0vY3Hx+x9Hlp X-Proofpoint-ORIG-GUID: X6yXwbbrKMoEawDTRElUtYA6dzYV9wTg X-Authority-Analysis: v=2.4 cv=HKzDFptv c=1 sm=1 tr=0 ts=68a3786d cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=2SHY49DYBmSurWS0lVIA:9 a=1CNFftbPRP8L7MoqJWF3:22 Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox Remove syncobj_table_lock by converting the syncobj_idr to an XArray. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/drm_syncobj.c | 64 +++++++++++------------------------ include/drm/drm_file.h | 6 ++-- 2 files changed, 22 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 636cd83ca29e..2177a354c9f7 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -249,14 +249,12 @@ struct drm_syncobj *drm_syncobj_find(struct drm_file = *file_private, { struct drm_syncobj *syncobj; =20 - spin_lock(&file_private->syncobj_table_lock); - - /* Check if we currently have a reference on the object */ - syncobj =3D idr_find(&file_private->syncobj_idr, handle); + /* Get a reference on the object */ + xa_lock(&file_private->syncobjs); + syncobj =3D xa_load(&file_private->syncobjs, handle); if (syncobj) drm_syncobj_get(syncobj); - - spin_unlock(&file_private->syncobj_table_lock); + xa_unlock(&file_private->syncobjs); =20 return syncobj; } @@ -597,23 +595,16 @@ int drm_syncobj_get_handle(struct drm_file *file_priv= ate, { int ret; =20 - /* take a reference to put in the idr */ + /* take a reference to put in the XArray */ drm_syncobj_get(syncobj); =20 - idr_preload(GFP_KERNEL); - spin_lock(&file_private->syncobj_table_lock); - ret =3D idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT); - spin_unlock(&file_private->syncobj_table_lock); + ret =3D xa_alloc(&file_private->syncobjs, handle, syncobj, xa_limit_31b, + GFP_KERNEL); =20 - idr_preload_end(); - - if (ret < 0) { + if (ret < 0) drm_syncobj_put(syncobj); - return ret; - } =20 - *handle =3D ret; - return 0; + return ret; } EXPORT_SYMBOL(drm_syncobj_get_handle); =20 @@ -637,9 +628,7 @@ static int drm_syncobj_destroy(struct drm_file *file_pr= ivate, { struct drm_syncobj *syncobj; =20 - spin_lock(&file_private->syncobj_table_lock); - syncobj =3D idr_remove(&file_private->syncobj_idr, handle); - spin_unlock(&file_private->syncobj_table_lock); + syncobj =3D xa_erase(&file_private->syncobjs, handle); =20 if (!syncobj) return -EINVAL; @@ -725,16 +714,10 @@ static int drm_syncobj_fd_to_handle(struct drm_file *= file_private, syncobj =3D fd_file(f)->private_data; drm_syncobj_get(syncobj); =20 - idr_preload(GFP_KERNEL); - spin_lock(&file_private->syncobj_table_lock); - ret =3D idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT); - spin_unlock(&file_private->syncobj_table_lock); - idr_preload_end(); + ret =3D xa_alloc(&file_private->syncobjs, handle, syncobj, xa_limit_31b, + GFP_KERNEL); =20 - if (ret > 0) { - *handle =3D ret; - ret =3D 0; - } else + if (ret < 0) drm_syncobj_put(syncobj); =20 return ret; @@ -813,17 +796,7 @@ static int drm_syncobj_export_sync_file(struct drm_fil= e *file_private, void drm_syncobj_open(struct drm_file *file_private) { - idr_init_base(&file_private->syncobj_idr, 1); - spin_lock_init(&file_private->syncobj_table_lock); -} - -static int -drm_syncobj_release_handle(int id, void *ptr, void *data) -{ - struct drm_syncobj *syncobj =3D ptr; - - drm_syncobj_put(syncobj); - return 0; + xa_init_flags(&file_private->syncobjs, XA_FLAGS_ALLOC1); } =20 /** @@ -837,9 +810,12 @@ drm_syncobj_release_handle(int id, void *ptr, void *da= ta) void drm_syncobj_release(struct drm_file *file_private) { - idr_for_each(&file_private->syncobj_idr, - &drm_syncobj_release_handle, file_private); - idr_destroy(&file_private->syncobj_idr); + struct drm_syncobj *syncobj; + unsigned long index; + + xa_for_each(&file_private->syncobjs, index, syncobj) + drm_syncobj_put(syncobj); + xa_destroy(&file_private->syncobjs); } =20 int diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 5c3b2aa3e69d..68928554d426 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -306,10 +306,8 @@ struct drm_file { /** @table_lock: Protects @object_idr. */ spinlock_t table_lock; =20 - /** @syncobj_idr: Mapping of sync object handles to object pointers. */ - struct idr syncobj_idr; - /** @syncobj_table_lock: Protects @syncobj_idr. */ - spinlock_t syncobj_table_lock; + /** @syncobjs: Mapping of sync object handles to object pointers. */ + struct xarray syncobjs; =20 /** @filp: Pointer to the core file structure. */ struct file *filp; --=20 2.43.0 From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 3E88B273D9A for ; Mon, 18 Aug 2025 19:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543676; cv=none; b=bpGs9TPuiO8N5o8HhCuYSgtP/Ggj04adsNc3121Xp60nEdQPNUWeJTtpWQlAJL80/9pjhmLU40cEELVaUFFbb8laBCMiVu9QFfFvR/bkiD5OUgKNxFVN42QxC7QnjDEYEUGd8EmTauOCOCY4cnaKxrT7aYlHkpOX8fG4+WE3pcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543676; c=relaxed/simple; bh=BT+TjyEVHqq1oejrutGpPkWvMjLia7Y9yIZkSZoi/78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HRIbcylOxmqW0y7dmXKERZMLe6ZS9ghG/IhC/AopmA8CarSRB1qyce9ojnV46xiRqGJtvygUvyUT5hVm3lg/dQgdwzfY9rg4ioawYx6bMJ2gCqOjW0IjDALqMoNHbA5MaCsnxbUhOXTYIndD29x/N6z0f38laHOpkExIndsCckk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=NygvIC3B; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NygvIC3B" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEtqWu025882; Mon, 18 Aug 2025 19:01:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=MSeAY l4WIe1MHOBDjnbrRMd2XBvT8Hoto0h0qC2vqwo=; b=NygvIC3Bfwk9vCeOd9XcT C8ZSktZuryqNHVfMyh2wRSA1QeLanz1Je9I3S4+0gBofnHJEQHZ3gg+COlvTafwJ lPGENfj1A9bTDodV86KJOUb7k28PNFcwVP64n6/bg3MhdOdB0ccQBAKM6AkzORft gSLzodDGw/RQFmHmcIT44FSRvbRbgrVoU8KMa0IjMNAqAVavpMXHsca6kllSIDqY vtyiiNnagnzCcJ+Wip8Eav3ppf9Em9ol8G0azF/4XM/zmN2YNodzHqo3CFYzqkwP vjW2aOxkZt2pZSXMG4F9kBhhg1/4VBNmLdYUI5gtqzPKaJ4J+J4aLA8hvucEoluS Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jgdfksyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:04 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57IIHmra016771; Mon, 18 Aug 2025 19:01:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d82g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:02 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZb035076; Mon, 18 Aug 2025 19:01:01 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-5; Mon, 18 Aug 2025 19:01:00 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 4/6] drm: Convert magic_map to XArray Date: Mon, 18 Aug 2025 19:00:44 +0000 Message-ID: <20250818190046.157962-5-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Proofpoint-ORIG-GUID: TYB0foLI-pnysjVESdICK1vLO11HlgPe X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3OCBTYWx0ZWRfXwy9smJPRc8vw Wpdofehdqebi0jwzRPU6TwVvfe4jJuC0U1asovHF1oMEu7raqcHU1aokXj6ai/WRr1HoXfazdY0 Z3Tjhwn5h1km2+HtObQNrnQ0FdOg3F2bMK8lcKQ1YaiTSMpVqUn89fs/irPsIYn7dPtuq9Xv8fN EG7aJfaFTZ9eqAbuiipfIjvsOFsf3FwhTX93KEXI7kBCu+gPmZAlFdCzURYBtChcaqG1BMfxaTU M9tzo+LSTXv2LY8eF5eXw+SpDIBfWqR3hq4KcGZnBMEnNwSf9MPpptb6mzXjCTfRVq6AuBNc3cx oLg8ALrly5hCKCJJ2Qhk+ZnnwQrZF7HuywloUCCgk0GlOVApn7W6kpXJdI03dI9pH/pE9Tu5k7z E7J2daOoP89aLQss/9GEDJkAb2xHHJB2gu93bF6JadgCZ970giiX/wdEBLIoEejK+7wV0Mj4 X-Proofpoint-GUID: TYB0foLI-pnysjVESdICK1vLO11HlgPe X-Authority-Analysis: v=2.4 cv=OK4n3TaB c=1 sm=1 tr=0 ts=68a37870 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=tR0JZ8r007ulJvwtm9kA:9 a=1CNFftbPRP8L7MoqJWF3:22 Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox Part of the mass conversion of IDR users to the XArray API. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/drm_auth.c | 18 ++++++++---------- include/drm/drm_auth.h | 5 ++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 22aa015df387..41aa20144a9d 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -97,17 +97,16 @@ int drm_getmagic(struct drm_device *dev, void *data, st= ruct drm_file *file_priv) =20 mutex_lock(&dev->master_mutex); if (!file_priv->magic) { - ret =3D idr_alloc(&file_priv->master->magic_map, file_priv, - 1, 0, GFP_KERNEL); - if (ret >=3D 0) - file_priv->magic =3D ret; + ret =3D xa_alloc(&file_priv->master->magic_map, + &file_priv->magic, file_priv, + xa_limit_31b, GFP_KERNEL); } auth->magic =3D file_priv->magic; mutex_unlock(&dev->master_mutex); =20 drm_dbg_core(dev, "%u\n", auth->magic); =20 - return ret < 0 ? ret : 0; + return ret; } =20 int drm_authmagic(struct drm_device *dev, void *data, @@ -119,10 +118,10 @@ int drm_authmagic(struct drm_device *dev, void *data, drm_dbg_core(dev, "%u\n", auth->magic); =20 mutex_lock(&dev->master_mutex); - file =3D idr_find(&file_priv->master->magic_map, auth->magic); + file =3D xa_load(&file_priv->master->magic_map, auth->magic); if (file) { file->authenticated =3D 1; - idr_replace(&file_priv->master->magic_map, NULL, auth->magic); + xa_store(&file_priv->master->magic_map, auth->magic, NULL, 0); } mutex_unlock(&dev->master_mutex); =20 @@ -138,7 +137,7 @@ struct drm_master *drm_master_create(struct drm_device = *dev) return NULL; =20 kref_init(&master->refcount); - idr_init_base(&master->magic_map, 1); + xa_init_flags(&master->magic_map, XA_FLAGS_ALLOC1); master->dev =3D dev; =20 /* initialize the tree of output resource lessees */ @@ -358,7 +357,7 @@ void drm_master_release(struct drm_file *file_priv) mutex_lock(&dev->master_mutex); master =3D file_priv->master; if (file_priv->magic) - idr_remove(&file_priv->master->magic_map, file_priv->magic); + xa_erase(&file_priv->master->magic_map, file_priv->magic); =20 if (!drm_is_current_master_locked(file_priv)) goto out; @@ -425,7 +424,6 @@ static void drm_master_destroy(struct kref *kref) if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_lease_destroy(master); =20 - idr_destroy(&master->magic_map); idr_destroy(&master->leases); idr_destroy(&master->lessee_idr); =20 diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h index 50131383ed81..3026aedbc205 100644 --- a/include/drm/drm_auth.h +++ b/include/drm/drm_auth.h @@ -58,10 +58,9 @@ struct drm_master { */ int unique_len; /** - * @magic_map: Map of used authentication tokens. Protected by - * &drm_device.master_mutex. + * @magic_map: Map of used authentication tokens. */ - struct idr magic_map; + struct xarray magic_map; void *driver_priv; =20 /** --=20 2.43.0 From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 3E813272E48 for ; Mon, 18 Aug 2025 19:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543675; cv=none; b=h6oJ7G+HhexB40SbrU0NF7iv6vxCwPZ9PuhyGp/DGEpNsDLTBvXNl1rt+CQig6T+a8+4k+zf4wmw03D4ZnzrhxtlwR0eFXn6qUQfievaS9b1laTkyA+4wun7M4+0mDH+cfnrYW+ldp1Fl3Of6k1jeMXEgNh26sK6iKrrIKfyEsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543675; c=relaxed/simple; bh=l5K11ix9Uyz8rBx0PJJNAB6HiRQiQI85vXtbPg4YzkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ISVXqpdl3MVaE4BOARRMtsTy8ytxBCh9XEGMdc4yHwOuyOLGphInTRzpE3Ja1cQ9OqSxhnATIR/f8NTie7F2egqiZZjf/cNYlPAP/Go9JmyrZI4fA78+HERJNhLNm2xIupMdXCqKpuHOsASK0LoqaOJL30PV3UEI4B/Ryua5v90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Wf9Nrxnf; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Wf9Nrxnf" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEtnQk030303; Mon, 18 Aug 2025 19:01:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=z6TPL kSjmE9IwF51L2EN1IwxfhH+JEAx1RRQGI35iZk=; b=Wf9Nrxnf4H4gMQWua/pU7 ws54ne3ZBZ/CkZPYwq6GAYkq8GOomoRFsXNCeF8zQEUmmbpfean341WidRLwnliH etNur8ENeBVFyeZ6oMgXhBEieoP4myUIGVdGaxrrcqjXzm28CaNOqz4pnlgsZ//+ c2w7n0kByp6B/UPA/k4+feKpVRsa/LWTywJ86PEclR3UCRhsC4VN4oWKBoTViggp AN+T4RnzewO8nCARZOcZDpwutD/YDr7C9OKkFEmcA0lYSWFxYwJrzkz24X5jB1tM 5hSttD96x85M4IdNSUW8KCSpmA4LvTyklCc4DY6xXCLENVB0mWx0yzx5fx0fOXUa A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jj1e3tte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:04 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57IHvoL1016798; Mon, 18 Aug 2025 19:01:03 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d84w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:03 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZd035076; Mon, 18 Aug 2025 19:01:02 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-6; Mon, 18 Aug 2025 19:01:02 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 5/6] drm: Convert lessee_idr to XArray Date: Mon, 18 Aug 2025 19:00:45 +0000 Message-ID: <20250818190046.157962-6-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Proofpoint-GUID: ZqZ8oPrOZufSZQAn68dibctAiOKf1eC6 X-Authority-Analysis: v=2.4 cv=dN2mmPZb c=1 sm=1 tr=0 ts=68a37870 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=8R3Qa1oyU1R4MiRUWy8A:9 a=1CNFftbPRP8L7MoqJWF3:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3OCBTYWx0ZWRfX+4XsGTXfX2ll BXG3IayFtp6oPeie/x9dp2NgGsZwhTW0fBvOV3brN1cXGbbgVn2YQY9jrWF6QZ0WTU+u/mZIl6F IUx1kPNBFKZmQVjYPxyn9BiXq57YQK5S9BrQ3X2ZaHBFXq7iNqmWgzqMsfzg8lzXcirK+wkF0Xm iNBmwjf9CRqXNNzEUFYCtEkHa4ynsx1KOCT0bTSXCRpSPMD0n2ksN8CbVWOruLOhjzgNgbDv20m vR/AGQwCN3Deha1NGtUQfsuXEN5KEYFGy1bvYjsgqED0NxqaDtu/FFh5cgI5Bgb63ak1WS2I7fo o9xs6yejnka2tNen/Zh3zwNwMIB8WiEQFnchLR1AGkJmIKwA9vvLKfeK+Ofnk1SQz/kbMCCakRx 6FwF94Pkig8mDVVExYk/jXmrXf+DdJm2VEYtFdlUjwd8vH0JGpIxSYVT0/Mu08r1M9Rq+qsr X-Proofpoint-ORIG-GUID: ZqZ8oPrOZufSZQAn68dibctAiOKf1eC6 Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox Part of the mass conversion of IDR users to the XArray API. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/drm_auth.c | 4 +--- drivers/gpu/drm/drm_lease.c | 15 ++++++--------- include/drm/drm_auth.h | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 41aa20144a9d..ca94d148b889 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -143,8 +143,7 @@ struct drm_master *drm_master_create(struct drm_device = *dev) /* initialize the tree of output resource lessees */ INIT_LIST_HEAD(&master->lessees); INIT_LIST_HEAD(&master->lessee_list); - idr_init(&master->leases); - idr_init_base(&master->lessee_idr, 1); + xa_init_flags(&master->lessee_xa, XA_FLAGS_ALLOC1); =20 return master; } @@ -425,7 +424,6 @@ static void drm_master_destroy(struct kref *kref) drm_lease_destroy(master); =20 idr_destroy(&master->leases); - idr_destroy(&master->lessee_idr); =20 kfree(master->unique); kfree(master); diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index 94375c6a5425..a9d5b8a48b24 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -82,7 +82,7 @@ static struct drm_master* _drm_find_lessee(struct drm_master *master, int lessee_id) { lockdep_assert_held(&master->dev->mode_config.idr_mutex); - return idr_find(&drm_lease_owner(master)->lessee_idr, lessee_id); + return xa_load(&drm_lease_owner(master)->lessee_xa, lessee_id); } =20 static int _drm_lease_held_master(struct drm_master *master, int id) @@ -210,7 +210,6 @@ static struct drm_master *drm_lease_create(struct drm_m= aster *lessor, struct idr int error; struct drm_master *lessee; int object; - int id; void *entry; =20 drm_dbg_lease(dev, "lessor %d\n", lessor->lessee_id); @@ -237,13 +236,11 @@ static struct drm_master *drm_lease_create(struct drm= _master *lessor, struct idr } =20 /* Insert the new lessee into the tree */ - id =3D idr_alloc(&(drm_lease_owner(lessor)->lessee_idr), lessee, 1, 0, GF= P_KERNEL); - if (id < 0) { - error =3D id; + error =3D xa_alloc(&drm_lease_owner(lessor)->lessee_xa, + &lessee->lessee_id, lessee, xa_limit_32b, GFP_KERNEL); + if (error < 0) goto out_lessee; - } =20 - lessee->lessee_id =3D id; lessee->lessor =3D drm_master_get(lessor); list_add_tail(&lessee->lessee_list, &lessor->lessees); =20 @@ -276,11 +273,11 @@ void drm_lease_destroy(struct drm_master *master) */ WARN_ON(!list_empty(&master->lessees)); =20 - /* Remove this master from the lessee idr in the owner */ + /* Remove this master from the lessee array in the owner */ if (master->lessee_id !=3D 0) { drm_dbg_lease(dev, "remove master %d from device list of lessees\n", master->lessee_id); - idr_remove(&(drm_lease_owner(master)->lessee_idr), master->lessee_id); + xa_erase(&drm_lease_owner(master)->lessee_xa, master->lessee_id); } =20 /* Remove this master from any lessee list it may be on */ diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h index 3026aedbc205..1b6064afc8b0 100644 --- a/include/drm/drm_auth.h +++ b/include/drm/drm_auth.h @@ -120,12 +120,12 @@ struct drm_master { struct idr leases; =20 /** - * @lessee_idr: + * @lessee_xa: * * All lessees under this owner (only used where @lessor is NULL). * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex. */ - struct idr lessee_idr; + struct xarray lessee_xa; }; =20 struct drm_master *drm_master_get(struct drm_master *master); --=20 2.43.0 From nobody Sat Oct 4 08:08:52 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 AD86E275AF2 for ; Mon, 18 Aug 2025 19:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543678; cv=none; b=kcIFXcKpX2ldG0FWN4qshjw5erLJe+yEKkXqSchqnanGwSy/giAATpSdiZMhxwSonaguNB64g/Cl07A9eD+BPioqjIH7/R4KeC8AtT2X+MCmhbUm0A46D0TwBEle1HqF8WNrIUhzVWoVUhOvS54sReffUQGt2TU9s0UzU2xg9LA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755543678; c=relaxed/simple; bh=lvqYr68z6pHbcyanDASME3E9x0MYc5/TWQ4PZi60V04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uzCCvrBAze/g0nk3vCCT7TdVqfYiQWvYsag3f4qTKzy5wk5exeiepWmADysw66Err1OFWYaIHWWHrlbyaB67OXV/v7CPZNjsQ7bPGmVEAlSAIOBQx4s6on9EbjLKtoNZBH1tlkZjgue4qGouF+m/dgmfS0ldo1Z+uNb9GSha7Zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=muHF6STs; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="muHF6STs" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57IEtnB4030306; Mon, 18 Aug 2025 19:01:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=9mI0l FKwyp53gFKvviW08JnOdUm+IPOCrtiJ8Jlz3H8=; b=muHF6STsct0UGkBKdb0Ha 7/CK2ZUNwlvGcGEOxoWNFpvR8GEK2auA6Oo+5wBVpdPNlS37AdzNqzX+XaaQeyls DX8kffGZ6lWu0ueFzIz1gByLnAFWvRltm0mCr4VQrXaawuS/XshUeGH39g0eplAh cIxcXlw8xbmMr63CZslbLp2djFeflPe3odJmrUEx2n8K8V5VjrdXKpHtNCQ29h6Z Q9ETv5uijPQCLeeN1Oarjm+rs3/woO8MqtkcaHIgls9Qo3OlHNpojyk/Ut+tunU8 yexCOcLswNDMP2iOE9JeCbH/xd0r3rufEPsAgjfOOeWOZLMeUzRM560E6IRTlBCg A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48jj1e3tth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:06 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57IICQcg016749; Mon, 18 Aug 2025 19:01:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 48jge9d87n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Aug 2025 19:01:05 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57IJ0sZf035076; Mon, 18 Aug 2025 19:01:04 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 48jge9d7p3-7; Mon, 18 Aug 2025 19:01:04 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, willy@infradead.org, sidhartha.kumar@oracle.com Subject: [PATCH 6/6] drm: Convert tile_idr to XArray Date: Mon, 18 Aug 2025 19:00:46 +0000 Message-ID: <20250818190046.157962-7-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818190046.157962-1-sidhartha.kumar@oracle.com> References: <20250818190046.157962-1-sidhartha.kumar@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_05,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2507300000 definitions=main-2508180177 X-Proofpoint-GUID: 53vPTNC4LRGXFiS6C5lLqIIujzul0BQp X-Authority-Analysis: v=2.4 cv=dN2mmPZb c=1 sm=1 tr=0 ts=68a37872 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=EcGSMKKx8drgTz_rwpoA:9 a=1CNFftbPRP8L7MoqJWF3:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE4MDE3OCBTYWx0ZWRfXwFdeX1dny7Q4 pLdT2+Oe0Pt5D4+zk4gvcs6YWqS9pc+G9fTC5MHmbc6syLXtmXx5LnDXfl2VA6I1DEMtTFN7Q13 ozy2t3MGpGfzGfKFIUWUZW1pWLnhyTQKIUwY5LenkVS1Gqtb792+S+CPMFb3gHv5jXi0/jTTy2v pfmcXQ1h0e/3fTBDf1wZQKmx+P8Zqt93Z7NzrYmc+iURAOXXEr1NvNHvoy+qJULh0rGonysiWjU lKs5Qz7H/bGxWqzJo9y8VcgdbhF9ZF9r/Edmr8PdJTYLxm0KZ4lEzfg84XcnkgTVPmLsENYKFx7 jg86QPcQZ45cjfp2B0yGh3EzUAHF9ZacOve8Ko7keTJjJ8/TlqZAgDYIHX1MgAdg6HR2USwIp4Z VqIcNT8wyb31XF8OSWxLx3J33YubzYWLwdB+73g6T+WrZMJveYa5wmbikia41/wZypPu6ZpH X-Proofpoint-ORIG-GUID: 53vPTNC4LRGXFiS6C5lLqIIujzul0BQp Content-Type: text/plain; charset="utf-8" From: Matthew Wilcox Convert tile_idr to an Xarray. Signed-off-by: Matthew Wilcox Signed-off-by: Sidhartha Kumar --- drivers/gpu/drm/drm_connector.c | 26 ++++++++++---------------- drivers/gpu/drm/drm_mode_config.c | 3 +-- include/drm/drm_mode_config.h | 12 ++++++------ 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c index 48b08c9611a7..91cfe06ca199 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -3489,9 +3489,7 @@ static void drm_tile_group_free(struct kref *kref) struct drm_tile_group *tg =3D container_of(kref, struct drm_tile_group, r= efcount); struct drm_device *dev =3D tg->dev; =20 - mutex_lock(&dev->mode_config.idr_mutex); - idr_remove(&dev->mode_config.tile_idr, tg->id); - mutex_unlock(&dev->mode_config.idr_mutex); + xa_erase(&dev->mode_config.tiles, tg->id); kfree(tg); } =20 @@ -3523,19 +3521,18 @@ struct drm_tile_group *drm_mode_get_tile_group(stru= ct drm_device *dev, const char topology[8]) { struct drm_tile_group *tg; - int id; + unsigned long id; =20 - mutex_lock(&dev->mode_config.idr_mutex); - idr_for_each_entry(&dev->mode_config.tile_idr, tg, id) { + xa_lock(&dev->mode_config.tiles); + xa_for_each(&dev->mode_config.tiles, id, tg) { if (!memcmp(tg->group_data, topology, 8)) { if (!kref_get_unless_zero(&tg->refcount)) tg =3D NULL; - mutex_unlock(&dev->mode_config.idr_mutex); - return tg; + break; } } - mutex_unlock(&dev->mode_config.idr_mutex); - return NULL; + xa_unlock(&dev->mode_config.tiles); + return tg; } EXPORT_SYMBOL(drm_mode_get_tile_group); =20 @@ -3564,16 +3561,13 @@ struct drm_tile_group *drm_mode_create_tile_group(s= truct drm_device *dev, memcpy(tg->group_data, topology, 8); tg->dev =3D dev; =20 - mutex_lock(&dev->mode_config.idr_mutex); - ret =3D idr_alloc(&dev->mode_config.tile_idr, tg, 1, 0, GFP_KERNEL); - if (ret >=3D 0) { - tg->id =3D ret; - } else { + ret =3D xa_alloc(&dev->mode_config.tiles, &tg->id, tg, xa_limit_32b, + GFP_KERNEL); + if (ret < 0) { kfree(tg); tg =3D NULL; } =20 - mutex_unlock(&dev->mode_config.idr_mutex); return tg; } EXPORT_SYMBOL(drm_mode_create_tile_group); diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_c= onfig.c index b4239fd04e9d..c3d1a6d81bc7 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -438,7 +438,7 @@ int drmm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.plane_list); INIT_LIST_HEAD(&dev->mode_config.privobj_list); idr_init_base(&dev->mode_config.object_idr, 1); - idr_init_base(&dev->mode_config.tile_idr, 1); + xa_init_flags(&dev->mode_config.tiles, XA_FLAGS_ALLOC1); ida_init(&dev->mode_config.connector_ida); spin_lock_init(&dev->mode_config.connector_list_lock); =20 @@ -577,7 +577,6 @@ void drm_mode_config_cleanup(struct drm_device *dev) } =20 ida_destroy(&dev->mode_config.connector_ida); - idr_destroy(&dev->mode_config.tile_idr); idr_destroy(&dev->mode_config.object_idr); drm_modeset_lock_fini(&dev->mode_config.connection_mutex); } diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 9e524b51a001..8412013914d9 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -392,8 +392,8 @@ struct drm_mode_config { /** * @idr_mutex: * - * Mutex for KMS ID allocation and management. Protects both @object_idr - * and @tile_idr. + * Mutex for KMS ID allocation and management. Protects the + * objects in @object_idr. */ struct mutex idr_mutex; =20 @@ -406,12 +406,12 @@ struct drm_mode_config { struct idr object_idr; =20 /** - * @tile_idr: + * @tiles: * - * Use this idr for allocating new IDs for tiled sinks like use in some - * high-res DP MST screens. + * Use this for allocating new IDs for tiled sinks like those + * used in some high-res DP MST screens. */ - struct idr tile_idr; + struct xarray tiles; =20 /** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */ struct mutex fb_lock; --=20 2.43.0