From patchwork Mon Jul 24 21:14:27 2023 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: 13325333 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 D0D94C001B0 for ; Mon, 24 Jul 2023 21:15:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9884E10E35E; Mon, 24 Jul 2023 21:15:38 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A4B610E360; Mon, 24 Jul 2023 21:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690233329; x=1721769329; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=kUXpil+EcubVXuJnN+4CExkCdaMO2sx5fW3H8oEPG/A=; b=HggiBl6W7RI474Eama9ikkHxfBjzMXG5gc6oN337k1czNFXvCwe55Q7K pvKgMcrMO9o3pvrOS8DjxPeldGx7rhVEovFt7QYsAi6w9lgR9LQFAN8+d 9/OiAtETMmIDVbUnootwm0T6xBxhzagBceiKfg0AJPboBNHCAfhCBcVlV ace1engj3mHbzPxgPvWojErACVBebNTsiY2GiApEPQCUC02IdCZoszaiJ mcigu3tiLCBrQ4gVE3993rBsVZMqXM3QkdJSqLEgF9nY7w6vIW7Cvn0pA UKvxPRime1XmTVQ/C8qmo+87LahOum1Clr/Gl3wZWIb7QNNWwhXGSQJhh g==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="347830106" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="347830106" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 14:15:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="719815891" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="719815891" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga007.jf.intel.com with ESMTP; 24 Jul 2023 14:15:27 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 24 Jul 2023 14:15:27 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Mon, 24 Jul 2023 14:15:26 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Mon, 24 Jul 2023 14:15:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C5vkG8uxR9l2NCCCrcOo2PLyPQC9NtAL3CKo17athrqfKtUddWTcUqcQzblVUQcAHgFcrCNfnpRvyEjCwgHfHwpvbwPte9aX1+c8V73zYCzWS3KibupQc4pMfE/b2itSIb34e9D8akUpewlSJxS+kRNJg7TrdUkkbHIzBX7zYn8f2Fn+nUYlEWwBqH/4e4+AfB/hVH9k3xLn7Q4dWXZt1ZhgclAxjR7xJ9zXC/PIZUPHCrnOUvzIj8wZThWNaWs3VDZFJIbpquEaJqxc7hMohyEExlZ/9toZpQn044msyMinssrCP3ic5GTwvZXqsc5ib9qI/9cmwLAac18TooQvfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=UsXm8Qul64IFOWsASHDJgaS6S9yTtKU6nE/rDRuoU5Q=; b=ip8eAQvF6CulTgx9rmhTwj1YThwLItRqQ4hIgRQuG7Ut8o3OJTycvqX9uxbuGneGDKDTHE2+dIjn6BBGPlHHpWl7luKN2m6b4TrYjxJuv7j73k5wDYzOHhIfY4Igly47wLoPzN+aaFmVKVV78+uAGJLrwC6Jy9PfdKpEEV88bweSOJvB+AYSsI/0dmxcw00xxzjBQLlW5OkcWTYBj4Hw8HqiF/d4OBN9QRQQQimtrZP4Lnh/bOICbmJxPBTBMOf86csJ1eCDlTPHsMPizgjMdVg/fVLrjtNRcSS1VNP6EnL68HCUY/SByRdcKpqvBsqipE8ljYP30xF1lbO+6PDsQQ== 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 MW5PR11MB5809.namprd11.prod.outlook.com (2603:10b6:303:197::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 21:15:24 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::1127:c109:d888:f6d1]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::1127:c109:d888:f6d1%5]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 21:15:24 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Subject: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS Date: Mon, 24 Jul 2023 23:14:27 +0200 Message-ID: <20230724211428.3831636-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724211428.3831636-1-michal.winiarski@intel.com> References: <20230724211428.3831636-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR2P281CA0137.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::12) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|MW5PR11MB5809:EE_ X-MS-Office365-Filtering-Correlation-Id: f78ade33-7299-44fe-f1c3-08db8c8b18ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iRa+9irpUpOX/LmxBviGnEDfzDmiAhALFjmHBZ16RdY5EC4giqdt6ByjdsPk1J2F0VeGfJLcLljfzijTf15dCyuT/0J635javhLQ6y7vFhe/1GR/ZMzj/Vz9rmvp/gUKriqclpdEb6jPQ6tRQ+qCE4FAHOcdDnHICwF3y3GIEt5ojxIFKmuKEYOwvvzCiiCJI92jBUWlwVyzmI4gkuLE1UJPc3MGwirVHlzxjgbWJblQHRBTHUpUhZAefGt+/IgcbuvMrr+hIHVSalU3iwaZRSaj3PM3HjuGCw8YnqzAEieWpgnRR2MfDv2iziZLdhSGxSemrpdIsRHfdPOf4W0dMc8D66edAWVPSUqEAIBpYliOSXXUmrZHtFj2QVy1vbbYIYkJsZzqLziHix7d+181rWPAxKGFPEoep7zf2F5BQhPSUgYjUg4L6KGgiM96IkmSwpMnr+o/FJhDNgtjlcVzycn9y77SJqFEcwg3vg6bw77iPLV1hB9KjP2vpmSsOm8lQBlHIxm3yvwVU4/aE5jlVKBpxyFhn6HcPuRCHheYWwaAfq43dlC9Dj8jRbdcDU68 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:(13230028)(136003)(346002)(376002)(39860400002)(396003)(366004)(451199021)(83380400001)(38100700002)(36756003)(82960400001)(86362001)(54906003)(2906002)(186003)(6506007)(1076003)(26005)(6512007)(6486002)(8936002)(5660300002)(8676002)(7416002)(478600001)(316002)(41300700001)(66476007)(66946007)(66556008)(4326008)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?rZTz3pugEQ6+ef4Mlj0OIvj3/K5O?= =?utf-8?q?zM3Wqzt19Qv2TztAxTwbEil8vaSY1SpWbxp3FEK5UJgT1DZ+hBG/QNMbZYLDjTf9E?= =?utf-8?q?sMDzgp/jhEz1ejUgwV1RnowABHHGV89obLki44MdHph8vIwNmDukpbQ5iVOaNqTSu?= =?utf-8?q?5NQFbBFu/zDPpUTxS4TvyAZnmng1ojnHccALBt4YKxq4Y/BgS4I8vLJZXeSUBQa9N?= =?utf-8?q?qwZ/SGxfExyj7qcDHX8mVKh8Ohl1m7IbBVIV1+B0Rn+aK7wdhcO2eMWqqlcOOuz46?= =?utf-8?q?IJg1fKfDATE9BH8JWToE+BwI8mZZIuzWphIufC0WuoJkeHE0WbtUwfRr6D+6f2gVW?= =?utf-8?q?dU4BhtiLJhDO8aFnd23lktjYwNYFJ8CoxV6JvE4FVl5IC9uwzNS+ty0MtEEsUlo9F?= =?utf-8?q?OIE5GFWpm6qM20T8FCPuIVspt8bRnqM07vMXa5kYncBWKC6pj+E+7KpdfBM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R9MTfjc?= =?utf-8?q?Ci9qtLwrl5tA71iVMy2355HJxZzFw9ao3qvR7TVO00aDhKruvqGcZGDCTB5yrKVxg?= =?utf-8?q?B58KkLq5EextTHGJi0vqETukN/XJ1GN8xYkvrPNM5ZGjIdcf7+c82ITvXA3HSXGAB?= =?utf-8?q?Bnv2vo9VnqFs98cQhXVlWvt5CiLPumomDTFl5B4kFpuFSyD1Ew6C/wx5GSfah3xuv?= =?utf-8?q?QOeCqY7emzQlBhtJWTCnbWms399w3RqPEg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: f78ade33-7299-44fe-f1c3-08db8c8b18ca X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 21:15:24.8348 (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: vCui1SnYORZj/kKIzR6zWfUC9rQJc9o+2IS1269RfITFmxYuoFcmqISGkwlpCui5JWdbNTzhEotWVVyUECTqYkXrF3PLWPLMv0/LKSyBT9I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR11MB5809 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: , Cc: Pekka Paalanen , David Airlie , Oded Gabbay , Maxime Ripard , Emil Velikov , Matthew Wilcox , Thomas Zimmermann , =?utf-8?q?Micha=C5=82_Winiarski?= , James Zhu , =?utf-8?q?Christian_K=C3=B6nig?= 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. 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 34b60196c443..c2c6e80e6b31 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;