From nobody Sat Oct 4 00:26:57 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 7BA2C2857E0 for ; Thu, 21 Aug 2025 14:54:46 +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=1755788088; cv=none; b=oiLFNktjVhBsM6lcGJQyYX/0WlPBppued+mRBvbBY93e6a8p6ZZdv5NMVjt5AbqPooLLq4SFxktZn+kqMOsnM5OVijygOe4vXP+fCZ18vQPkHvzZZPZzFxT3nOVZrpy9epsbKsuIVk3v28sKHjHD0qPsul5K7c036k5pv0Z3v9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788088; c=relaxed/simple; bh=/X1xxQ+EMY/ULKOUkmEau6aFRyMLAPAHbu1P+G0vnsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eOQaCcYWD+OQlbzgzflUuABH8q943t4F4lFXGGQhRIOZ0wMjbwdysMSy84CuPHOQVWl3FApiFsGru2nY7WgOmwsKPtAWYM6VFws5aPWLcsGqg1KICpDP1WvLKLzaOmZz7QA59AFCmSChADwDGUcCAk8Bk7BIZf3SiSF3TxdVhq8= 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=FeIwAwFb; 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="FeIwAwFb" 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 57LEUrGE004115; Thu, 21 Aug 2025 14:54:34 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=1K0QQ apToE39cNs2MkPWJnRiSNR/HxdHTzYC8iViLtk=; b=FeIwAwFbK2+g+b46BYBXN eoMIzaQG2cq3NK7vOztAbC+QHc/IdKpN5TMZu621ZeG6wYVUjR7yUcBgC1r1Vbfz 9TapTOsgR+xAHksNSqGAOaxIQbju94hGGWgPr3E9Hfy4d3T3VGQaxhoYhV9JXKe5 ujIjeds7ZYccQt+Nx2VcjoufXJFOZeSwWmdARRGesy7R3M1yZTAGtFx87vXnODS5 dAxL8Mi7u7NNVj459qbA3Ov0ob6XiN7JXBYFz98MwPYHDFuL4Kb0vcOYkZFAmWQ3 1foYQNF2Nj0oGV7DyFH95B8g5bOScXruD0dINdnXPn+ZAs30UPwv76mJkq6KOzVb w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tquss9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:33 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LDav88020689; Thu, 21 Aug 2025 14:54:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:33 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOe9011459; Thu, 21 Aug 2025 14:54:32 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-2; Thu, 21 Aug 2025 14:54:32 +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 v2 1/6] drm: Convert aux_idr to XArray Date: Thu, 21 Aug 2025 14:54:24 +0000 Message-ID: <20250821145429.305526-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfX0BUZlYxeegxP B69p7iqP2QM/M/5XZ31MJYi6cXWSFtpJRAeJ+0u79/JkXXrVkJRhAHVZi9TUxxQrXbjbxguQl7W Tl2pX7qJF6usjT2P9jGtRolJw7APOK19l+hG6LM6GJqhN1LbMIUaNwZG6fFheJUflfyp0WjrF8S p1EQIqlDE/hCzYJBX5rxSFeR5xs32xRsWmntlKiNjpGyDo81OAUzIjfxa56L9xNbCjcTywV4Hz0 eXaM2lk9paZuFpYuG/zRmBbIzh8DPboU39qyqyKuKH4+LjtsEFel4oQ7vn9zcBPKRk+qv+vHo/n tDVtT2TWCbGlQbTZuSoJto0cvTc0mWr8lYeWGH6Il5n1Jv5W5N6QvNffoIE4G+7VYsaan9wFEJa jD+vGjubWZRcOsMHbE5aYCh2PJIODEEcNpzAhyI7YzugXHG5aiQ= X-Proofpoint-ORIG-GUID: nhVFLOmAlmY05OT13hilfLbFnVmcXLI7 X-Proofpoint-GUID: nhVFLOmAlmY05OT13hilfLbFnVmcXLI7 X-Authority-Analysis: v=2.4 cv=K/p73yWI c=1 sm=1 tr=0 ts=68a73329 b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=bhnSk7d9TMSBOys-tl0A:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 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..2a29d4b2cda0 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, aux_dev, + XA_LIMIT(0, DRM_AUX_MINORS - 1), 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 00:26:57 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 92FCD2E2F0E for ; Thu, 21 Aug 2025 14:54:47 +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=1755788089; cv=none; b=MoBkg1syQFhkrkkr+Pugc2YJ9cp/xw2BBmYhJFrMPnoGqYP1SZGJLgGsCwWCJMCxqAFmEhK8xuM7AhyOqhEkpVbNZQ5cRBx1i5mPFWV0UKcv2SJ1Su6iLF/MY/MAVoEC3jt6p7nYLvabB3mPQECIiMfestn98HJDT3VgEVT8nqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788089; c=relaxed/simple; bh=V5wwopeV5CYXb1MI1P38eWPYEwxvYCnzcCxsZdKtrHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t/fWDKPL4ZYDvhbAfjlpOVlr/eUzYX65Qz9FBJt0TQRLsSPDAL3QUiSpnGUHiVLNSPNsK9/6bmiht04qZ8Arp7Cy/XwdDHzBzC/QI0c5O/O+Q/bg8z5HTg/UgJ+pR1ZUkyCZbBetdwuIh0q6UzDl+FRA6g2tZlHSAnx8ZBtDKd0= 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=d0VkGgXb; 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="d0VkGgXb" 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 57LEUrXK004090; Thu, 21 Aug 2025 14:54:34 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=eOyaW kVCVs+cuUTdiLvAPrVXJ78haYYosiMCV5aRvhQ=; b=d0VkGgXb+qdqL/kL3l/vF agIaG/9iWHVKWzUJq2LDS5vrH8CncqkRFBB9qau2ChbORpuOd4wpeATZrc5te88B uW5igdX2XVRog9V5TjLB8hPL4zpaI3k9OFenxaqb1OjH9ehkDJiAMOFN32S6GPwg PJ1q3anFdXU+FLUGUv8s4EnA++WflrNP83dFPFOpaQfUROdjEpSX+gIwOk8j1ORl TaRMyZnBeLtF2pZw2GCeX8D3j1Db9wGAIEq5v37RXs7eBU4n4q6WW4oMuv7aOo6L lma1uPLmdqb38VoNM6jcL60JuSNg1jzmPs1+lQwRCA9WCTwFyQsDNtLBO73oucG+ A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tqussa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:34 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LDjYvd020547; Thu, 21 Aug 2025 14:54:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:33 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOeB011459; Thu, 21 Aug 2025 14:54:33 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-3; Thu, 21 Aug 2025 14:54:33 +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 v2 2/6] drm: Convert object_name_idr to XArray Date: Thu, 21 Aug 2025 14:54:25 +0000 Message-ID: <20250821145429.305526-3-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfX9t14RMCL1NU3 YjOa8F4FPJhA0tPFEbd5+mdl+G4m/dtqE2quqo/9gKUr2d9LWcpimtUYTN0fcqip37vLEPwPsDU vjLMkAp09WGG0ZiyXazwRu8QtME9DWo2nfxZWJPRzPWfMsmWOoG5b4wJU8DLDT4FxWH8JwYrzYk YzG73ZXnxoWgNzXRXSkjq9Y413fLR8zUUZetTHgldcurx3r1u1d6T0vGyOmhCr/3wbe7ZhwetiK 40ZAh2F8bIHvWbh3ZFpPXQkxdHADLVxYD9VZ4MmuHdzjwhcucABS7+GCruN9NCMnJ6z0rLQzbqc +XCXqW0X0ZhvVbrOvLUYV+eQMTdVN8S24B1ItEa2Lg917huFjR6MmZW7VsE1z2We4agtfOxXH/5 DKDBkiABUre2ZaQ6yKfRd3vrwAyXPbMF9gRiM4op4NYhXfFJEu0= X-Proofpoint-ORIG-GUID: Ybo6BrDYI5387itABCHRy_ALeV3sM6hw X-Proofpoint-GUID: Ybo6BrDYI5387itABCHRy_ALeV3sM6hw X-Authority-Analysis: v=2.4 cv=K/p73yWI c=1 sm=1 tr=0 ts=68a7332a b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=DK_Tli1e-HrAiUtdIdsA:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 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 365cf337529f..3e57e3da5115 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -122,27 +122,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 6a44351e58b7..cef0c5935798 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -97,7 +97,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); @@ -269,7 +269,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; } } @@ -927,11 +927,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; @@ -967,7 +966,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 a33aedd5e9ec..6a28a9b134dd 100644 --- a/include/drm/drm_device.h +++ b/include/drm/drm_device.h @@ -325,8 +325,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 00:26:57 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 764482E0926 for ; Thu, 21 Aug 2025 14:54:47 +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=1755788089; cv=none; b=HsttQue/Io2IwcqW2h11GNiVBLtQb1WU0YyPoe50uGypIYdGJsK1ZqfBE1tuswZTpAj1OYeqNQmADDEPeDH7KhwfW6+MQSMB5WmgmdxvVoCtu5yTVNiTDyVEQRGd3amDVc38nL20TTnRW4QvpeaaJe5vvGaHJNyYJTKdgfdZrSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788089; c=relaxed/simple; bh=EPbU+rimOYWZTJEopbqpP23rBtGvH5phhiJrqUrkEHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=efSQIapU+0gf/fbnBqB3jjjsey6AiPXG7mIsOD8Hzws3Y3y5Bv4VGmOaPmoMR7UcqYYRdKrjUUwJH7rRw9wGV0ngvwJicEBXuXa0kELdEVrswWgsATXuB72txn//sQ2AtfuodKTWdXre0D6WJVao6XuFW4fNQaLb7w6/VzqXT1c= 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=F+TplOo4; 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="F+TplOo4" 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 57LEh4vi031119; Thu, 21 Aug 2025 14:54:34 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=N6Gbu R9LSSRc3N1wU5xRX5lAGkr/RfOrMSDT6LkHoCQ=; b=F+TplOo4EU7DhAbLThzJf tJVNd29WKOBRmgV6oOoHL/17QYOl8pxd2LvdHKRfCV+DYGYWVUgjUoaXyu6wJNXt n01EWfGAukiVThvAt0/eclx2Ibi9dRHNpmnYGKOjT9ZJEONS3UOP00j2a3SoC8aH dnvdUtrX+dsBBPXzT/P1oenxWWeJOeVWjpSCqjTEsc4st8i6lOhpdowMV5IQD/5b 2GbRvzJwaUzGDZHtSsqJ7uLRnUvjLNZLz6XLDftPfzR4xrrSMqxmX/xi6cIn3XKf tTrVX84X2e3bSdG8gxVjFY+2J7I1exzG0BDzl9BRXpC+Yc4vOKRpa3NiF0sOysif g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tsukef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:34 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LD9KP8020792; Thu, 21 Aug 2025 14:54:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:34 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOeD011459; Thu, 21 Aug 2025 14:54:33 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-4; Thu, 21 Aug 2025 14:54:33 +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 v2 3/6] drm: Convert syncobj_idr to XArray Date: Thu, 21 Aug 2025 14:54:26 +0000 Message-ID: <20250821145429.305526-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-GUID: TKq9kdl9qpybQSI7_o8POUORkkBZf-Lr X-Authority-Analysis: v=2.4 cv=S6eAAIsP c=1 sm=1 tr=0 ts=68a7332a b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=2SHY49DYBmSurWS0lVIA:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 X-Proofpoint-ORIG-GUID: TKq9kdl9qpybQSI7_o8POUORkkBZf-Lr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfX1LiotBPpK+lk O07FHF9l2ZTbKXcGW7kC4XQcX4DiLerfU/J2tJ1wyfztwNfnaZEm/JWC3yPUpXzKJSUkyDXqkvF 4cLInObwvqjWjamGAXOu2ouaGypJtptwrJsazTte1/7KzDIgxhYnLXpLuYH43eO1TR0qBgEg34e psu8hU59/hr2SrXCUE0NW98fc3az5uwWjasLpHaV1t1IXcxfX0+jAfPtatelCJJZnavIZGtNa0+ LbCn715S5X6c2VnNvzu9nasBL1i/TsZjoyzwYq136YgkJq+qeAi6HVvL4zE+haWJkwQTR00fiwc Psl5wtUjaS7SU86kEsvm4wNG47yAjEMOrF6PmqTCgPN85nDAVuUQJh5eb78WBtX3QPIzCIJOfWV o/RaY9L1gtfn2Y8XdrB5eNhWhAlx7Y4pTROKtLJcglE7bU9aGCg= 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 e1b0fa4000cd..091f43cf11ba 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -250,14 +250,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; } @@ -598,23 +596,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 @@ -638,9 +629,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; @@ -726,16 +715,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; @@ -814,17 +797,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 /** @@ -838,9 +811,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 115763799625..ee5a16338c86 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -309,10 +309,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 00:26:57 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 E10B5214204 for ; Thu, 21 Aug 2025 14:54:46 +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=1755788088; cv=none; b=RIJ00SG6ao72lvd6VS41MI5E8C5hjUNahNRQZSMVYQxoWPujRd2dH5kJ53PWa9Cej1Objga+C1JPc3R7bJx6VADB1G5aOEzwqemzTnnbA7FjKseldB3oyzvrWbSTceELsaU+F0bjUzfoI3ImbQFWz4oFrV7lcCGoL7WJw9BnY9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788088; c=relaxed/simple; bh=h45ucrnhxS5+jV2uUGzcUVj+DBB1Ow09VgonFjZfrcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VH585ga0fjemhb7O9TvYdivgq7rSX088Si7jNGGUkL8od64WFIpt0zgJkkK8oGtyvrVzw6zxNZhFkVMWCxnQgKhSuaDLYtzRHiuHkUNk6ZfC0hDQiHxgyvd5ydoeR1GavBSPph8GhqszR1yRfNOcb/dHp9jJ3iSiK1EQhw0CtFU= 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=ake7V/Gk; 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="ake7V/Gk" 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 57LEBt6t019360; Thu, 21 Aug 2025 14:54:36 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=ZB4H0 brEDhy/BTQoDbDq/GzCpRwIb20+sslpqu7YiDg=; b=ake7V/GkRhm4O2LwVbpRM lsrT7Ap+zM/ZcGlMciNaJPOfom+bbzsJAs24if26PSo+OIfWK9GNeuoFXu2wpPdq uKqpi9sVjecAELqa+zcWq9fl3QN0fZk8J5IcyM4RhuKeadvqEGz8xdOJa4caUlmb tOcKtLNFVROnoGO1ZlD2todhQNjn6EkSryObl27Cuhey19w2ZPZJhgD2oNPlhhxL AKzTNlVjhUfKFDfr06gdOqn/Aj2JAdx9X9ZuO7L9xK7EHeTmxCOI2qMziwaSqrOH Ko87whtYmtK4NG4NMiWIzT9FVQsZ/T7knvLTDpnLHkVTv/s5tKbzUVinB+EsydMP w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tr3nme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:36 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LDtTHD020788; Thu, 21 Aug 2025 14:54:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:34 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOeF011459; Thu, 21 Aug 2025 14:54:33 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-5; Thu, 21 Aug 2025 14:54:33 +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 v2 4/6] drm: Convert magic_map to XArray Date: Thu, 21 Aug 2025 14:54:27 +0000 Message-ID: <20250821145429.305526-5-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-GUID: 8s0toXwNDUjgdIaF8e2CvN7hfbf-lqqa X-Authority-Analysis: v=2.4 cv=FY1uBJ+6 c=1 sm=1 tr=0 ts=68a7332c b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=9b9-1ReQUuPN9d1JgaQA:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 X-Proofpoint-ORIG-GUID: 8s0toXwNDUjgdIaF8e2CvN7hfbf-lqqa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfX4DrbzftxXuKQ 71VL8IShCarOARFd60PZLKcF6iQvSw0tj3tRZ45jjXSLq+OGzeop2vSlwW7BakoCmPZWHoDWFge 5YYKgTDGvrlSkmCaxMGaFcFUlBvOrSypRO0b7UBlUkD7zdP4H+kjKdO/zAdcMXIqayFlCHXc7l4 qRODkLRJokOnewH+TO/zYttViOvbd1XbjqLJcvA8B3o56RVKs7ebHfwlpFufmXA9rTCZbYGaOXA IXsn+0xXgYK7yKmgU7MtMEoHhrArP5pwHXq/81Gc11RTN98mq4bkHlGbDqSba8K4SHmB9UBWE/U EyA/YE/W1hIZB2nR1+3QVyvRXVVemr5BXJiy5JQ5y/hWIgD5RwCW90lKyQHHnnHU/f+JgANJ4Hf N4REk1w0gr04AjyXK+C/nhdwB/h6/FjkOKLSAu1ZjVrrZM3994M= 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 a2556d16bed6..66a672384367 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -98,16 +98,15 @@ int drm_getmagic(struct drm_device *dev, void *data, st= ruct drm_file *file_priv) =20 guard(mutex)(&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; =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 guard(mutex)(&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); } =20 return file ? 0 : -EINVAL; @@ -137,7 +136,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 */ @@ -342,7 +341,7 @@ void drm_master_release(struct drm_file *file_priv) guard(mutex)(&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; @@ -408,7 +407,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 00:26:57 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 77A702E2652 for ; Thu, 21 Aug 2025 14:54:47 +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=1755788089; cv=none; b=DAn5p6kb7TKfJG3WMJ/2iLw29dN0J11/k8orVjBDw/IVFIRGyGXAoudLn0/wlAh4JvyL7YIO2bLbooyedDz1VL8qFyynDASske0vaoRvLz6ujTAjJxl0iD7bRkXjA4gCcLvkJf1MSp5FADjt7K/rMHt9NPSO5djxlx2azGFjeDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788089; c=relaxed/simple; bh=h7JdKhOe933PbAKngVF4dRm7Uh/bu6hNfnoCwZ90GkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iAIS+/+wBejoeKz+Jd6iN6FPOwO/vChEi3gb+aLZ4ptnSIXMGAIUjqTiRbIjeLHESSPWMWBVdhtz6lEWxvlGPqZr8Vic5RjqeG6G+cOvRN+GZIiE3zreJHf4k9nRxnTVMDkL0ae5ys+gnEDRXmZJHU6Z3CIBdAS4SkRzEY8IBt0= 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=VOYYY5lO; 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="VOYYY5lO" 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 57LEUrXL004090; Thu, 21 Aug 2025 14:54:35 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=BMnpx XgUHGsxM7kBH8YixGmnCtr9CWBuqMGXVXPyNeY=; b=VOYYY5lO8c+zKI1j6wNDo gCiR1iHBdGLFtOM2DWXoQb9R5wg89JoaGVmE3mCxzENxht9VXNAMas4h4KhWRrlT 7aZP9GzupHZgzCpcpaBHh6XuTxa4dch6zPWoDmA1Nnc+i2IqwS8QJsuGacsOclqL zNUAQAQkyhSNfw5SbEaTMYRbfJiscxroRqW7QWQIFdVPmQwI2CrxNRRTBRoSYgRD HAE+guXxJhehsgMd0A41SqmQbEaXwF2c+Nm5vo1lqXWFsxeJyHYHWDgvyTOdI7qu F/InJKjSQo21UX7qdsOCCO7R6w5HyHHCm2HRtQmiolPgvuznPcb+c9jxDjKolklo w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tqussb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:35 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LDVS01020525; Thu, 21 Aug 2025 14:54:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:34 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOeH011459; Thu, 21 Aug 2025 14:54:34 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-6; Thu, 21 Aug 2025 14:54:34 +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 v2 5/6] drm: Convert lessee_idr to XArray Date: Thu, 21 Aug 2025 14:54:28 +0000 Message-ID: <20250821145429.305526-6-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfX9owCNJQE6d3g sf2ZtQxeELncd7FDgKQjj86GH/4NVgtH3hUGrGdHFwnlPMmj8ka8qeChYTNn5f9j7zLTTvrPR9D VHgd/UlY1d5/L1C0a+toRU2PQp2VQHKdX+XJzklTa0I55VCIru3zVf3heHi/IP2ZaCVogUv2Z1O Eit5KvbDDHHrtxfbFeHfstNLoM9QNtpkAWXbytrc//IVpie83x+hti46gYkOXqQGbZxk0cJifwD v44KZ5LKQ/t8h5lK/0xQjtFLNoEpsWsrlZRCosD8Z9w4NToXlPghA0UepU37ZUDDbmUui2jWgMD WJmwkb3MhTnfQi0AoqrqdNj8bBQGswXSfqwOhb8lVjOtuUL2NF/l8q1Y/pnxCXraezcgN+WtFuV RVCJoyxcyqr45IlSaFXnrVrEIEFLHXvLr4v0IyPE5sYdK8LdX2c= X-Proofpoint-ORIG-GUID: pWku5Ns7W8Llo39Ov7QYxkUSvUtms5e9 X-Proofpoint-GUID: pWku5Ns7W8Llo39Ov7QYxkUSvUtms5e9 X-Authority-Analysis: v=2.4 cv=K/p73yWI c=1 sm=1 tr=0 ts=68a7332b b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=8R3Qa1oyU1R4MiRUWy8A:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 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 66a672384367..0605a649b27f 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -142,8 +142,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; } @@ -408,7 +407,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 00:26:57 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 8DE4F2D8398 for ; Thu, 21 Aug 2025 14:54:46 +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=1755788088; cv=none; b=dBN7tegRaS8ccFTPqHtPHknbUjyW1I6v0g/gku/Ubjc4oZ/6vivPWgLUWNGADQCju5x0tyf+dTDFmzGdlmpuXRcIsSHoJNtZNoGXG0NuLOtHuktPloNCvtjcNqnO5QN88BfyMrimrdkit7fIIuOa4R9KUYtO9QLkGksYcz8MFiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755788088; c=relaxed/simple; bh=LHoOk1R0I/aotAQ/hwjk0mtC527HC+UTcT9bFpcFVCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3ZAILd7UN+DT5ztyqwbuU2Hy7M4WyX14piwEB/zt2eLE6hzKGNn0qhgnsH7GQIlmondsHDrUq0yncKGE/lQEgKZBPZmrL+j+UTUyFv+OjW4/j4BiHyDqgIpHQCjaQw0iADivPpvrbU0TWaynbw/dMxzBYqmQUpiZjEHL/oB8gI= 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=qA9JbZDF; 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="qA9JbZDF" 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 57LEUrVx004114; Thu, 21 Aug 2025 14:54:35 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=lJQR2 s5bFPpJRdaGreBdaLP1uehipPklXjIX0NvKcUM=; b=qA9JbZDFaxtUcitSUs4O+ 4QUnvwlloAB3KAVIi1kaS+M8M3EmINl/4XiXzVkMvPgtx0Z0Dj27ADvwT6J2TipV EQGa/2YB6XenFDpIn09vheBDcHJMGJw+kYBCw6iz3qPXEy54ICGOHFUUyjKLEtEz 3Y8UrDrR++HpKQC8CRrLAKZiWs2rTc4qiIUM8p5E85jM9M1VHR6G93BSooFjIzpu 7mWg4Jpla9JvLOinSX0XM7suRItRWM7VEGut7GewFMqindvPprNUaJ62/Fpm3wUc axmWYB25uI5MF1FpzP0L5ZBF/NXhqf7WvgDS3OMWprqNIwn+9PRyy/oXlhfKlv+j g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48n0tqussd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:35 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 57LENd3t020541; Thu, 21 Aug 2025 14:54:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 48nj6g5s9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Aug 2025 14:54:35 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 57LEpOeJ011459; Thu, 21 Aug 2025 14:54:34 GMT Received: from sidhakum-ubuntu.osdevelopmeniad.oraclevcn.com (sidhakum-ubuntu.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 48nj6g5s7m-7; Thu, 21 Aug 2025 14:54:34 +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 v2 6/6] drm: Convert tile_idr to XArray Date: Thu, 21 Aug 2025 14:54:29 +0000 Message-ID: <20250821145429.305526-7-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821145429.305526-1-sidhartha.kumar@oracle.com> References: <20250821145429.305526-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-21_03,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2508210121 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE5MDE5NyBTYWx0ZWRfXw2za5PaxncGA vFmd5jqHnHfqlEL5KiIl71moeADqTdsYcW0Ka8LKaQat22ldMY3Dz+0HFfUN3SYt+nOQ5w7LPvV zpTNMG2ZZzB4DK+32WAuYjcQbTMRvnDdzhaLU9idsVWIzshWUs6IkfLzZ3+ZbZfUJnDDciawNNg E1REBXoHHWKMJRAz68bwXxyeT9/wfpxdYn1SigTzWiEBQ5f2lxAZMl6upFpiESaSIMkEX0v9JwS OM+RDULYOjOKRPNHQRDPJjBa08RleMzWg2dN1QcHNU8PSh+VOomc7diydyUIDVYVwOk/2Lotbum OWPgrOsKa5HFLvC7INWRxQ+UtCXw2+mN7RhRs7gPB6nROVf48V4J3yw9BS/4O5bCzslLKP9hCwW AZ6aDVmUEbSAc4J/LJNi2gJQq9LsEUK+W/cwEcZsVR12OXVftek= X-Proofpoint-ORIG-GUID: qKSCdOefhPm1ICh8l5-rj5uZHRoWk9zf X-Proofpoint-GUID: qKSCdOefhPm1ICh8l5-rj5uZHRoWk9zf X-Authority-Analysis: v=2.4 cv=K/p73yWI c=1 sm=1 tr=0 ts=68a7332b b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=2OwXVqhp2XgA:10 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=EcGSMKKx8drgTz_rwpoA:9 a=1CNFftbPRP8L7MoqJWF3:22 cc=ntf awl=host:12069 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 272d6254ea47..6a64e20d730a 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -3531,9 +3531,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 @@ -3565,19 +3563,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 @@ -3606,16 +3603,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 25f376869b3a..680b97ab58ec 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -439,7 +439,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 @@ -578,7 +578,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 2e848b816218..9e3914119587 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -393,8 +393,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 @@ -407,12 +407,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