From patchwork Fri Aug 23 16:30:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13775566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E416C5321E for ; Fri, 23 Aug 2024 16:32:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1E0D10EC7C; Fri, 23 Aug 2024 16:32:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="P4M28MyX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41C7F10EC7C; Fri, 23 Aug 2024 16:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724430730; x=1755966730; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=h2+229BVJU+UiOo3vj6Wrs8aDgmRzIvkGL4XAcpcLOc=; b=P4M28MyX6/o1cywWTEAZyU1bUnawnZnQF9sptHz+0D+h1r8PJxWkcHqg 9Nd7GM4VZqKrKPDa8K3xsZx/ZS/GeCyphQ6+qv8/Z8HZzQFI2Qe+0etQv DrF4zd8Q5JqwXwuOdU5Qv+BQi+WrU2mcOE6ThZ5OX2YSTUQzdAhZ4veQP Q+2xEJz76Zy7DrSGBo9CNLWqekh9Bs4KcgvAmIfsZiGwf6G2WUsUwQqKK iANqqNOvOw6L82d1B32irPmF/NvxBI5sUpbGCjaaRnr+7FZjauNP6GSxi l/p8mcsiNopO2DcPl5RPpoQHv8rWv5vspwMkb6fHqKp8k99rpSKLO7FwX Q==; X-CSE-ConnectionGUID: PVZc8KaZS02fMgD6tELctQ== X-CSE-MsgGUID: f4+aZXp3RCGHTOAeV8ONMg== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="22431907" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="22431907" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 09:32:10 -0700 X-CSE-ConnectionGUID: UWCzwZ38RUqy84x0YEkY4g== X-CSE-MsgGUID: EyoAYP8VQsCqrQwMTihdSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="85016419" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 23 Aug 2024 09:32:09 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 23 Aug 2024 09:32:08 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 23 Aug 2024 09:32:08 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 23 Aug 2024 09:32:08 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.47) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 23 Aug 2024 09:32:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qImQjT1/bBc9IwpvF0mv756ZiDeo652FWC/F+mT4Gy67mzIpY9T+tJdGs5QFAfMzxw8/HxU4VVMlex+/KM4f1R/e4ySIiAteZn4FKCbi2/Ww2pkxBGFXYsKT7m3Ti49Ia24QjU/NpKzfTdrf4pKKPJwBWcCp3dxbvquDs1FEeJCCLvTNftZUSxXt5HcYSOB0qgkJvWfecOiEzF9bZqJaS2Id9xtSEuEMNWdx5UTEEb38B8hATl+MaMRRTqDW9xSoPsc28o0cOaElc7icxrXDg+cvXU/16vL7k3vm9ftsBrmnsBm2dWcItfUDOOgrRy5Pacy/glFT4YHq5pfVSWrvkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qMryctnD0MU+hbcuBpnw8n1e5n9ng+fjtD4HApMOmus=; b=ZioCxkmgBP8Zp0JMl99YBFE3fHmTFjaSQ/IQM+bcyXsBaEGvsdIlfTD+fTjhJsT4w2jN4xeHa/v+G9IaaObJXs5w9+65jPNYtMQLSGl5kFF/TU/2vsh6RFUdbgqInwUXPNc0nhWn54IXUls4/flKM8GT+XN4QuX9baQDAKOPEEh4uhvcuh/3fUUkImPTolEaSDeat8Bws+MpRjXGBB8PHEIEScnbtG57013dLNcaPv+MXOA+nauepFvyk8O2a7Jrmm1N0TRsIYXemdpbnie7cQBv9QM/V77jWRTtaTqWnwAuZlTBW7+eqZMTpmSU4Nsv+R9bFKvcSWQuRnFWEsCp2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by BL1PR11MB6026.namprd11.prod.outlook.com (2603:10b6:208:391::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 16:32:06 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%4]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 16:32:06 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , , CC: David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simon Ser , Matthew Wilcox , Oded Gabbay , =?utf-8?q?Christian_K=C3=B6nig?= , James Zhu , Pekka Paalanen , Emil Velikov , Alex Deucher , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [PATCH v7 3/3] drm: Expand max DRM device number to full MINORBITS Date: Fri, 23 Aug 2024 18:30:48 +0200 Message-ID: <20240823163048.2676257-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240823163048.2676257-1-michal.winiarski@intel.com> References: <20240823163048.2676257-1-michal.winiarski@intel.com> X-ClientProxiedBy: BE1P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::9) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|BL1PR11MB6026:EE_ X-MS-Office365-Filtering-Correlation-Id: 1358ac04-3482-4876-703c-08dcc391205b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gRGv1O3JO7R5HV9P9/Qckd5M2276g9T?= =?utf-8?q?Gol6ebOvmDHhL+N1RlDMBtLr+Cdz2ZDGFm6aFmUUh92bBw+s2LhCK2qfgdSAOYKrk?= =?utf-8?q?x/r74TAbwBW1Wqp3fHM4E+R5xIpGeAax4rZIlicCt+5zrPkJRXVAGrZYEB84czqFQ?= =?utf-8?q?Ml48RqUTyVqtuewxvj0f9GPEgbP/0UlH4ppp2poFz2yyPUl8XwB+s9AW38tsIlfk1?= =?utf-8?q?b6kNNEgFTvioGBEGNZ0VlI+Q09zO1qrY/4/n7EEB3iRvybzQfQ8cR5nw0DDlyzVH8?= =?utf-8?q?NvARsVy7C7XCs7BX18aH4cSKoTFUMXI4HiDAL9DOkCgOT13i3pukqQHi0zPyTzoLU?= =?utf-8?q?fx8svDoz3NQjmcf2nJf09JivAOGZxHoVXt1FX1NOsxm5qvuJt3y0vE01x9IfaWQJ6?= =?utf-8?q?h2/9HqrYENgbwYn3mjzjkcHUdu+Gth5/lcwsJ0xXkSM9fMdbTLtsMUScSKg4gtN1+?= =?utf-8?q?CfeCQkzYywH2cnm6nA3bUM6JZwlz2BALFUldjgMUBkBo9USPXbK+dz7aisnRU9ndw?= =?utf-8?q?XRVX9bVmIK4WaPE/SrTzRjlI2mHjED+T/90omyHzOQuw+qRA/qnPa469Zi0RUAzG3?= =?utf-8?q?Yf1UhdMXsTmhpK9HCO2HE6TpUr7w5uf764pyPXfJq2CLL/rMOgn/8ry5m9/fGjzf+?= =?utf-8?q?x0BMK5CzAxZOCrAYxidPM31p7DUV94IZjOz1OmGD2aEdCZlAMQvlvO4o8mVJiUZxX?= =?utf-8?q?iUx8bMAeL11xlJ0k2QCzuVVeCpsHaVEaXLI9m/RO/79uUV3SdOv2yUUtjYGo5Py33?= =?utf-8?q?QqGh6/5upXAamN83mmaBoziThmiTOEUD7Eq+KAoYdkoJy9Hk+W0VhZ/sM6Wy5AZIF?= =?utf-8?q?pUtk5WbmWmtAKMECnpu3eAzBOjo+vSqEUYGeoSH4cyfjdmrbWiWq6KRLPS2OMOdRT?= =?utf-8?q?cjfIfGMR3eaOnrk2g3NqAY3XSO9tOgmaAvoaeb0VL1729RzD164zjguAHGblhOYy1?= =?utf-8?q?WN1o3A2lEuOAH4zVR8z06cC5pROGr1efmnw5l3hxFcu1FbUlSRlRSd8b9Xufp5kOz?= =?utf-8?q?7G11FPjl95ZQuGngLBSJRHEIdpSEB8Ah6eRBmzElA2qyBo9yH9mW/LzcRJ+aFDWQ3?= =?utf-8?q?1Rdt0fSPGCNGq9+vP6ozJb0AYxfdxswOH1nINwUJa5wHOER3opvZoQET0tXt88/Jh?= =?utf-8?q?ycMDT/+Pw6Hm+He4HeaijwS5czcAV24Oc7ppbZPtzcICdI2gEc3SegutVdEd6cBr7?= =?utf-8?q?F1lDgIbPuMPg8+Ld4GKsi13K4u82HOKlmUaKS5kaDEA4sWbQ3We3klmlQS5AktPiA?= =?utf-8?q?MOEtCtOV8d4GBA09XxWWUwFUuqIpq5cdAcA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N9RH71eAk7LNsiFMewvRBr0XlVw2?= =?utf-8?q?xGPxYF+zmG9k3RTM17qWBE9NBdN5U7o1RUKE3BBS18m8UsQiJ9M85S84rsnlz4ZtD?= =?utf-8?q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?= =?utf-8?q?JQV2wJBp8Y2FduhpBn9WG7CBdk7q9k4KUvaPw8ppVSlFTgSOCwcqUmN6+drxtd3tY?= =?utf-8?q?IkQKoWfL/E1VHA2rpU7H341Zj9a8vFHGFgdCBitKPneaZQXoguuRuoTllvrNdGsa8?= =?utf-8?q?DTufEIR6kT04L8R8wMwmgnSa253aTfVIsBQP8eoNOsKaNiXgZnnhhEU5iU4GznlMC?= =?utf-8?q?1EwyLAiOAWynuLhI6oWG5ac/letLAmNI3f7TQ6jv+TgoZuskzJ6O4NUWrr+uzxwoQ?= =?utf-8?q?FGcmeb54qOPVRpeQ6pkUrhYOGHcrGJ8aNehk5M/5FZUF+IPDvyw1Wx3siVPgw1cfR?= =?utf-8?q?3G5JlGigr1Kc8g3c4p+OjlaUKssWNFKret7oZCvSS2p4mPE9M9hpBhwvuFzcX7wxe?= =?utf-8?q?qSZael+XVgqRFBsW+YFDJm4y1MUkf3c1K3ZYunrUxC0GgCoXp+JCitsbjpeWQUAGI?= =?utf-8?q?6Dsj3/tws4RPDtjfBJf1fBJ5pli4dNOajLlIs7pCC4fS/LFalGBKwrQWUiHElbMs9?= =?utf-8?q?z0NCb4x5xWpIWQI8YCUfMnU8ZdmSypJRNSjFXc5M6hkHXFbMD5KRqtIPP+m/rqskJ?= =?utf-8?q?7AIFOIZ2skF4DfqQb1flUzQ7yCrbrC8c0g=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 1358ac04-3482-4876-703c-08dcc391205b X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 16:32:06.1711 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MBWYO/Ne8glyRGisTU0h/dcZkQs5SMeMq1DggDDJKOCAov4uslPdhAnVmRhUDY1irc4it0dvAQx9mCGeFJRkNHOW3WqTEHvthlYNXwP+Kyc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6026 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Having a limit of 64 DRM devices is not good enough for modern world where we have multi-GPU servers, SR-IOV virtual functions and virtual devices used for testing. Let's utilize full minor range for DRM devices. To avoid regressing the existing userspace, we're still maintaining the numbering scheme where 0-63 is used for primary, 64-127 is reserved (formerly for control) and 128-191 is used for render. For minors >= 192, we're allocating minors dynamically on a first-come, first-served basis. Acked-by: James Zhu Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/drm_drv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 7e0fa5a2a3182..c734e6a1c4ce2 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data) xa_erase(drm_minor_get_xa(minor->type), minor->index); } +/* + * DRM used to support 64 devices, for backwards compatibility we need to maintain the + * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes, + * and 128-191 are render nodes. + * After reaching the limit, we're allocating minors dynamically - first-come, first-serve. + * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX + * range. + */ #define DRM_MINOR_LIMIT(t) ({ \ typeof(t) _t = (t); \ _t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \ }) +#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1) static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type) { @@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type) r = xa_alloc(drm_minor_get_xa(type), &minor->index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL); + if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER)) + r = xa_alloc(&drm_minors_xa, &minor->index, + NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL); if (r < 0) return r;