From patchwork Tue Sep 6 20:16:27 2022 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: 12968149 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 C1BEEC38145 for ; Tue, 6 Sep 2022 20:17:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4AA3F10EA82; Tue, 6 Sep 2022 20:17:15 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C56A10EA82; Tue, 6 Sep 2022 20:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662495428; x=1694031428; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sbKfQTg+CFMo3FiMihv9YnajB9h+ql7gf2rY835FJg0=; b=MeX+pEnh9lQ9R52/38dMgFRVVOzYhoZC2CeVAMMoen+8AqRfzLALhoyi Ia3tLdlweayygU9E6ABp+UgyxBUVMAbwM0/nuJDwyHBDaMLtU/olIyRKJ aCC2TE2xB9siadpVsN02vo6qD+J8h4vFuYfeiSIMVHbgW2NgBcYP1dCJO 9L4swSKiKSIeBtXXx/WvcvhyPKWe2rIqjJbSKTKKAJkCjkmiXr1GPPjpB COijN/StCQse5jQJMkw193IMGlCjhVhCEmtPcLGSqHRJ02i27Ou7yYm4T C8JhcgW5GVpUKvdrtHQmjIWJTmWH2MXA3+y9I2lqv4RcR8x+bEPLV6/KQ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="297479848" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="297479848" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 13:17:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="610076379" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga007.jf.intel.com with ESMTP; 06 Sep 2022 13:17:07 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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.2375.31; Tue, 6 Sep 2022 13:17:07 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 6 Sep 2022 13:17:06 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.109) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 6 Sep 2022 13:17:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCBn+AoGF39gpxOtZ+N+GJD+X8I6PVRd9Pn/O+ZnXQyA5zI0aw9olIepRRaU/p83+L8e+RNLWjvWoRWztbG2nVwb5690QppOxy1/xLFe1vaPR2kHOJ8aP0YjGz1PApM2VIbqYC7W5+n8pxWHaJVuRQSixkeAPOaYFu4WNVJHXbkUyAkb+wZKMOgV0j2O0RBo6iRnGvbY7s6FtjTYa40/22Dbhe9qPe5eQdxF/aUotFfbucu2951SX9tjoMhRWrhMPHY9sRNbxHkwdIxVPMTTebF9vUctTKkMuooZ9109LpatSkW8zXdkVh/f5nla9xvwxjKlu1JirMbfIJnDpKll/w== 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=Os1VZYkjqlvvGr86DKSKUwsxFEaQ4MP+zgd8BGaa3do=; b=Li0RRzu+GxP4onMcHgj8vwXs6Q2STyi704tsBQQ5VeExu7GWaa17cP96Hqr76hRH1OMEx+IMdDj7QeFVF1a52icOrTya44rVpYUEMdz/kWUK9Z413Fsd3VJZrArCOxXtB+wb5Hb4FKrHjzKlOXD/agYGumkbcpvofeAoHpo9VZYQBGPmCR91YhY62JIenuftsuX5or15IjcS4lDjru9EQm2h9165U+rUUmwMpE0EoqQXgK0ueIXdJaSqaUQHm+fMtRHjSdtrrVN6dAG7N5/yGIz3bG1d2Dwa0Mv1nnBZxPUywj73O0T9sNSOMHBXGZj55zlYBmnggKNYD7f1two9lw== 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 CH0PR11MB5396.namprd11.prod.outlook.com (2603:10b6:610:bb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Tue, 6 Sep 2022 20:17:04 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%9]) with mapi id 15.20.5588.018; Tue, 6 Sep 2022 20:17:04 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Date: Tue, 6 Sep 2022 22:16:27 +0200 Message-ID: <20220906201629.419160-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906201629.419160-1-michal.winiarski@intel.com> References: <20220906201629.419160-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR3P281CA0121.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::8) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 972bfaa2-37df-47e1-f1a7-08da9044c383 X-MS-TrafficTypeDiagnostic: CH0PR11MB5396:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DzWShhHTdeEcSa0Mk1C7uSM7/xek/XtdBqlXCis+miUwV7LCCl9e8qKUmzbhs35+2+nuLgJImUSy+iIu7KwRnC64e4l+SKC04P2JSI3KzEnl1whgefOGfjkDMeMtm3bgi4VcC04j5S9JXNuyTJiHm/bUCAzaB3uJtj3Ib9Qq7TU3SwX/EuZx7glm5mm06iNoikeUBCy7o0SZuATT+RNQjTTDJQ+otuq3+q/wXg1RAPCltBurU1YEHMSN6F1pNc1WW3YQJFTbQrxGO8f8WcgipqCQmr21v8fz5DK6E1d/K69QmIWhq8py8xV3INM0JyWkf05z9Zg+Mg8tGpVEprJS3/sxbrl+OxdWrlcMP7blsLzayzhfbmGdF5WRRKuZsjbFpxomd65k2mSCDFB+Y3zW2+AXb1cATPay2WBhzhxpBYWyVVqOu52UH5gU7XxRwDtchm0GrWNDW9jHtr21rjqDMi5cuW++Ppod/4wXbUc5JA0hCBxIvPFNWSaqct2ExqLB63tv9iYv0pWtR8yi9W5YJ1C/8uXrJMRP9oD8FgUed4LZ3rkzJLMdFnwnzGlusn0prnKzBunmIH/MxHDrGkx23uCeRxxxDIvnuY7ssFtgmQxHGboZK0zXHjSNiC7eDW9qbjA3jezkHTcZmWSksmoL21R+UGWgr6owgNZqt2R5LGYDqqjH+Xq/MjQZ4it6bhFw1Q9bmGSnzOzRJQ+2sHRo7g== 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:(13230016)(376002)(396003)(346002)(136003)(39860400002)(366004)(316002)(54906003)(86362001)(82960400001)(36756003)(2906002)(38100700002)(5660300002)(8936002)(7416002)(66946007)(4326008)(66476007)(83380400001)(8676002)(6512007)(6486002)(2616005)(6666004)(186003)(1076003)(6506007)(478600001)(66556008)(41300700001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?36MmrgVcreRfL1saizwK2D5qcDaV?= =?utf-8?q?t0Z38VC/HYxHtkRbet4wuFIzElXEgXF2aUFptut7BuSlnwXEf0BUzF9w3pnb4seD2?= =?utf-8?q?08VI4PXCjkTdTFpUGiMnfz3TylFCSWNeOeMdR6rr7N46tuA06pt6t8rkGUkL4zvJI?= =?utf-8?q?yDEdOVG6GOUBRKXFVsn50boUfZ3IiD8G4ioSmTYm2O3cOi/Ly9Hkd5Bn5KiTEPeOH?= =?utf-8?q?CUXRRGW/pAZl1jnrVosru+dnuMK5a7S4NiXvzETijbaXRVq3Hlpj98XqEVHx58yCp?= =?utf-8?q?yiN1fD9HywdD2wD72hewLTuYsWUloV5EYXVULuVdmV01PG6+OxysLu7nuV0jW0Cmh?= =?utf-8?q?Won498npNBJBQkt9IFyHvWX0insK7ybqMTt/JYO958Sx20nWNBSCbqCIwdFJcLtCU?= =?utf-8?q?vW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cDjdJUPGftaMp9cb53arHEItqd5ceZ0Op5z6AJMZXP/4xWeKTzQclFUR?= =?utf-8?q?G5CjWC6jxwQn+Bwi+cXP0qwOzNMWmLaV6eSPa0RiTHezkaTONcEv/E0I+n7PgWi+J?= =?utf-8?q?v25rnH+NLyWK+3UtYLBM4FNsNWUExiB4gtFQTDpNQqrwh7Kgat7JyTJOXNRpxUdEY?= =?utf-8?q?nMRFj7vUqGw+CC5ogBMbCqbtsMSOfnp+kWVOoJKY2BnnvQvb8w6xKiFdKgS1ctmxg?= =?utf-8?q?9WRe6A+4nsinq8CNE96E7EGqlR9Y+1EMuQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 972bfaa2-37df-47e1-f1a7-08da9044c383 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 20:17:04.1069 (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: hAUHbuah5dWnGGWtMWAW6MdOQWAoOLnppcnpXoNG7XIr+jTWXZjZtjkzMmZDg0XTWRWbttP4OWLzsY4Fm6ksVMdYpzrNwBVs5RDckeOgwLY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5396 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v4 1/3] drm: Use XArray instead of IDR for minors X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , Daniel Vetter , David Airlie , Simon Ser , Maxime Ripard , Matthew Wilcox , Thomas Zimmermann Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" IDR is deprecated, and since XArray manages its own state with internal locking, it simplifies the locking on DRM side. Additionally, don't use the IRQ-safe variant, since operating on drm minor is not done in IRQ context. Signed-off-by: Michał Winiarski Suggested-by: Matthew Wilcox --- drivers/gpu/drm/drm_drv.c | 49 ++++++++++++++------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8214a0b1ab7f..41799e4d0432 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -53,8 +54,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"); MODULE_DESCRIPTION("DRM shared core routines"); MODULE_LICENSE("GPL and additional rights"); -static DEFINE_SPINLOCK(drm_minor_lock); -static struct idr drm_minors_idr; +static DEFINE_XARRAY_ALLOC(drm_minors_xa); /* * If the drm core fails to init for whatever reason, @@ -98,21 +98,18 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev, static void drm_minor_alloc_release(struct drm_device *dev, void *data) { struct drm_minor *minor = data; - unsigned long flags; WARN_ON(dev != minor->dev); put_device(minor->kdev); - spin_lock_irqsave(&drm_minor_lock, flags); - idr_remove(&drm_minors_idr, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); + xa_release(&drm_minors_xa, minor->index); } static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; - unsigned long flags; + u32 id; int r; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); @@ -122,20 +119,12 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) minor->type = type; minor->dev = dev; - idr_preload(GFP_KERNEL); - spin_lock_irqsave(&drm_minor_lock, flags); - r = idr_alloc(&drm_minors_idr, - NULL, - 64 * type, - 64 * (type + 1), - GFP_NOWAIT); - spin_unlock_irqrestore(&drm_minor_lock, flags); - idr_preload_end(); - + r = xa_alloc(&drm_minors_xa, &id, NULL, + XA_LIMIT(64 * type, 64 * (type + 1) - 1), GFP_KERNEL); if (r < 0) return r; - minor->index = r; + minor->index = id; r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor); if (r) @@ -152,7 +141,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) static int drm_minor_register(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; - unsigned long flags; + void *entry; int ret; DRM_DEBUG("\n"); @@ -172,9 +161,12 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type) goto err_debugfs; /* replace NULL with @minor so lookups will succeed from now on */ - spin_lock_irqsave(&drm_minor_lock, flags); - idr_replace(&drm_minors_idr, minor, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); + entry = xa_store(&drm_minors_xa, minor->index, &minor, GFP_KERNEL); + if (xa_is_err(entry)) { + ret = xa_err(entry); + goto err_debugfs; + } + WARN_ON(entry); DRM_DEBUG("new minor registered %d\n", minor->index); return 0; @@ -187,16 +179,13 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type) static void drm_minor_unregister(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; - unsigned long flags; minor = *drm_minor_get_slot(dev, type); if (!minor || !device_is_registered(minor->kdev)) return; /* replace @minor with NULL so lookups will fail from now on */ - spin_lock_irqsave(&drm_minor_lock, flags); - idr_replace(&drm_minors_idr, NULL, minor->index); - spin_unlock_irqrestore(&drm_minor_lock, flags); + xa_erase(&drm_minors_xa, minor->index); device_del(minor->kdev); dev_set_drvdata(minor->kdev, NULL); /* safety belt */ @@ -215,13 +204,10 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type) struct drm_minor *drm_minor_acquire(unsigned int minor_id) { struct drm_minor *minor; - unsigned long flags; - spin_lock_irqsave(&drm_minor_lock, flags); - minor = idr_find(&drm_minors_idr, minor_id); + minor = xa_load(&drm_minors_xa, minor_id); if (minor) drm_dev_get(minor->dev); - spin_unlock_irqrestore(&drm_minor_lock, flags); if (!minor) { return ERR_PTR(-ENODEV); @@ -1037,7 +1023,7 @@ static void drm_core_exit(void) unregister_chrdev(DRM_MAJOR, "drm"); debugfs_remove(drm_debugfs_root); drm_sysfs_destroy(); - idr_destroy(&drm_minors_idr); + xa_destroy(&drm_minors_xa); drm_connector_ida_destroy(); } @@ -1046,7 +1032,6 @@ static int __init drm_core_init(void) int ret; drm_connector_ida_init(); - idr_init(&drm_minors_idr); drm_memcpy_init_early(); ret = drm_sysfs_init(); From patchwork Tue Sep 6 20:16:28 2022 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: 12968151 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 49A93C54EE9 for ; Tue, 6 Sep 2022 20:17:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71B5E10EA8B; Tue, 6 Sep 2022 20:17:30 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CDDF10EA84; Tue, 6 Sep 2022 20:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662495432; x=1694031432; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=iK6yPR25uATbMq3cTWOhf01aAfkZS5uJ1mbTY5RiIY8=; b=Grx9gtgc1zAA4ESiFtY4wfa/2zqXFjxok9tQunwpq/9clQwFdJQMFyt5 g2fVX8J+BGjdebhQ1SdeG+k2vUU4ivG+HVSLlnZUb8BUUnHnnLOmo1HHf TBDsbA4QAAjVeSwxQKMTpe0LsYZTJwoaGVke3ukibUoysb6qyoRKH3fux ih8IDT8+67w9v7f2NEpokaswXQ74nViUKtfJw8cmZghq8G+OReLFnnZqS OpPbEzL+Xs6uxBUKffxeQmfV8HOQj3jU96J5FiABGN07R7zmevBtUJV+m lE+lzmK9YNEg1AEJqH9u3ENCkBMNJLWdjGlcan4t9E0KjDEE0RSydnyij Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="297479864" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="297479864" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 13:17:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="644310318" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 06 Sep 2022 13:17:11 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Sep 2022 13:17:11 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 6 Sep 2022 13:17:11 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) 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.2375.31; Tue, 6 Sep 2022 13:17:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vmr4KAVsCQF0K86gc1O8Kp5BovAJhu3VQBcRnc2YGqS8gX23ASLCztSW9vPJyBIub+lAqVzLuWFc90iyxd4Gfa2wzjUsXb6ZLIBQUmZxndTbn5TnROxNOBKHJpvXmOViISl7GK9rWb4Bb9PT0aNdLEuHDm+5KfQqLqWMbHvsZyYuohLYlD3+7rvAfLLdJjwDOadITYCts6CJBWrtGN7BR2NJrVisGS3ZAHsN500cfEplFbXYdGBoRaF+B+uD9Vm7HPldYGXvYeUH/wL6rf4UoWsiYX2hRNdPIeHMnQQgviStkdDjPuGKBGx8ErFH4tEGCewy7M1BEeZJlK4dnG6xVQ== 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=jNpp4W7B+QMMucoL1cm/W+GrHno4Qa9i5upw4eTjxa8=; b=Q/eUAxI6E2qniOTe/SnFVmG7k2xxNJGJA5DCKBTpnQzNg0P+1PtWK90QQvwxmGGxBo2WhUXZidbVXoJNHGRJQBkAl68AGptASpgvdfA0O+9VS3aW51azWREum9wK8sulVPWEokJ3wpPaJsjEZJSfpvAZu25FnjfMmt1/6mCn/N6I2jIPKrcvMR8WGKH9mtyKBzvkC9tqOr0eAQbRdFVhCm8K5tWG8GkoiJjKj9PzpUffkQe9kCLPyUUfLPkrgUbfM/VAgiLd0Zg5Yfo6pP9n9iV1yt1CYt8V8Uad9Obgy40qgbf3ykeFginuc8k6VImL4i4EtDnbjgktNQY4sIwuGw== 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 CH0PR11MB5396.namprd11.prod.outlook.com (2603:10b6:610:bb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Tue, 6 Sep 2022 20:17:08 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%9]) with mapi id 15.20.5588.018; Tue, 6 Sep 2022 20:17:08 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Date: Tue, 6 Sep 2022 22:16:28 +0200 Message-ID: <20220906201629.419160-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906201629.419160-1-michal.winiarski@intel.com> References: <20220906201629.419160-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR3P281CA0104.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::20) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7766d86-eaa8-4c91-e8d8-08da9044c664 X-MS-TrafficTypeDiagnostic: CH0PR11MB5396:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PZmdh0lMpwED6tUD/c7qwyqcCcy+Ur6edetyEtXCGWB68Gf5jhyow1qQD4s8noEO0V7papYtL5wjfVi/Sbk+C9v/X78j5BnVbBLSvDqAz35iyU3wpgNTl/Iarl1SN1Tz0OWkzt+YbQzz1OeombVQ2n3N0rmvA2R6qwvAHc9eFy77jvY78/n0OdGNRQHqUFR27ZLaHjxIcw2/Qay7bOy0eCD1iSN9pnqlF7pL7vAgMJ8WDGJlbM+2yvmwFyLoB6vGmcBKfybf6Um/4GcL/jVVsfJeEV+lBguXd9pKkAY8ZpZb9skLyd7IVg6lWDsNGtqNN8GgyUGwQpK0GHpTqrnpa01bYKwDgzz+KJqDSv5jYRbk8lp+7a5PDPQALH52HpwRrxH5pSCDFZIRP4BsiakpAQOSQCnMSydhmGyQl2fL3jctqXEzHvLLVqIprn7Mumv/VkDyRJLiuNmLDqs0/keLVT+h9Hyuubooj+1l7NG/I4ijUcMmhZQF0bkZuGhH23st4QxRXUIyYhq44ZW0+iUyGP2HeaIWYitfH6H/rOpehPASSioxybnPFTGqUlSQkHoYMHVo2jEF6wk7uQzHFt8iFi5ihmEKAoRUeUY7w7CFIN2bDO2om8fPuePOKwoJz0cpOoRBDdTCX1MNc5/588ClsavsPqIvR/O9wwBn3U0th0yxp1bB36JW5TaDAJw/eq/N+OiellFuip0hFCv/nNGBBg== 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:(13230016)(376002)(396003)(346002)(136003)(39860400002)(366004)(316002)(54906003)(86362001)(82960400001)(36756003)(2906002)(38100700002)(5660300002)(8936002)(7416002)(66946007)(4326008)(66476007)(83380400001)(8676002)(6512007)(6486002)(2616005)(6666004)(186003)(1076003)(6506007)(478600001)(66556008)(41300700001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0aIT6gKAfWeGsHKA6n8eqkj/YbzS?= =?utf-8?q?5o6cHpyNtZqXxAC6wmfFA5PsZGNlBrpkp7Zojo+byfGxYUgn21hjxYEUlJzElrre5?= =?utf-8?q?O3QnOIk6PJuOTmrP78urdw+VNq5Qaku1N3LMW4k/1L3+pjljDRC0PY3kyt9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yrd?= =?utf-8?q?ZbRWwyiXGH9lC7Vg/MXRaBLsEQ0J+Zsj4uBMjqN4XbTTukd/WpF1zuXXOZJA8CJtm?= =?utf-8?q?Kt9Umi1R4rNS4h0k/oNgKZGFMIuMcast3cycnuda+nhdis7cVSM/JisM/5IDq29Jf?= =?utf-8?q?7CjkA9fSh8gIkDnD6DHLRfybIsAt1OzZOPtcO37G1oK13JRRziWzDZCpVuPyo9YaO?= =?utf-8?q?nSSdeEvN4aXtFOeRGdTl4bxJNo1ZQDLAcfeDtDyVYLV+bs5lFXlXe48ZPifX1PESE?= =?utf-8?q?JzzKmBOtgRWvw4g1M+3Rawm4TyfWXLAPl75Bamj+crNh9l2pRftUaPEv0ycINNXNE?= =?utf-8?q?stbCHsS8MCyNNECrzvcJz3ErdQyUOSclfz5RpN7kYy6s6JdAurNjnVIYd01WtC1mR?= =?utf-8?q?PKYfxra1L2YZiRGh/tv5eSnzqXv7XGpXA7pCk/BFcDcgeNE+Nm+qFw0vq7yolCMZj?= =?utf-8?q?dxCrF3YZMeYTxDa6VMl+VHUHTNSPgH1v4QHs1TxUISsKzdXCf2jPsDg0g44sMP1md?= =?utf-8?q?oOvK9ABCqh+OfVu5QrT+5SnVljV7JDYbFg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b7766d86-eaa8-4c91-e8d8-08da9044c664 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 20:17:08.8274 (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: CdEI5dOPnaXmGTrjwQEVdOH7gZHr58tqC7wdmp+9uRVzmb5dZe1ZMuckcl+nb2H5z8pMJO73TlD6ZDdqvXqK4UwcjIUvAymhs7kO/gaQK0M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5396 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v4 2/3] drm: Expand max DRM device number to full MINORBITS X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , Daniel Vetter , David Airlie , Simon Ser , Maxime Ripard , Matthew Wilcox , Thomas Zimmermann Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 41799e4d0432..2c6e0b8d3b7a 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -119,8 +119,17 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) minor->type = type; minor->dev = dev; + /* + * 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. + */ r = xa_alloc(&drm_minors_xa, &id, NULL, XA_LIMIT(64 * type, 64 * (type + 1) - 1), GFP_KERNEL); + if (r == -EBUSY) + r = xa_alloc(&drm_minors_xa, &id, NULL, + XA_LIMIT(192, (1 << MINORBITS) - 1), GFP_KERNEL); if (r < 0) return r; From patchwork Tue Sep 6 20:16:29 2022 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: 12968150 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 7D466ECAAA1 for ; Tue, 6 Sep 2022 20:17:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40B9D10EA88; Tue, 6 Sep 2022 20:17:29 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id A253010EA86; Tue, 6 Sep 2022 20:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662495442; x=1694031442; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+1+LnVzmjZLuT4xn8PzW65yv0ZishEmy63sB8z50MY0=; b=UMM6WUnJuRqfKZ3iBcfL/InLeeCLcmM08dhS+gd899OQ8OTTmtLJJb6b bnOYeeuPwa7OD+Zp2rJw9bSBufBR2ehod2rlcDwt7Bnid9B/BbsZYey3T rzcyxTpDmPPefWj3ZuUpeSlX5hkFXDcqTNWmVT2c4NV01roDCmOUANeFl 3eWvDMnfgQ1ig7V6Lb4EB0e8T2Yks3+iNY+nwb8eKX0r8iJrfzP46071s GZm87tkPAKhQPQsgS6ECeiXifwLvYtLOFWWsPmRt0+zM4oWGrW6nYyreM 9tecBDA2wfbKmxRaId5NYCKOg1MitDe91AMYWz5J/3uvurKydBFtEEn2y g==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="295429566" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="295429566" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 13:17:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="610076412" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga007.jf.intel.com with ESMTP; 06 Sep 2022 13:17:17 -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.2375.31; Tue, 6 Sep 2022 13:17:16 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) 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.2375.31; Tue, 6 Sep 2022 13:17:15 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 6 Sep 2022 13:17:15 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.105) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 6 Sep 2022 13:17:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h28KfABK1wl87sz/eXyI0U27Y7T4blx98FD2vHxYu4/SkdgFzvqcXAWjH2JhAogpZO0OkOVoi2uSyrfJe3rssJevi2djdyml/y+jeKFkR87bMoRGPSFFIW0THXZQhtuCPzDYnZlPHUUuqUpdPtH1u92T0XjIWtvCPdd0Cqv7kd7NBQCzieRh8wuXCaMUEBAUPtBwEhMSfM0emdVpnJLgrWF8qArKCfvwLHYnaqdO7EEzWBhlcIk+Won9SxGt/+F/pmy3vlgdgpEO75JaXZaWwxowSiitEe/NKrNoXvK8Oabe51TEtE+Xb+PPzGxbfxDBmX8g09VCndXhOrQIX5aC8g== 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=Ve6QdgVn2HhUmYWGm9Qgx+/p/gLZiytkBQP39Am1k4c=; b=m2huJ1jpOg1CQ5V0MJc2jkR8Xp03L3Od7xJ1ng1zK7I+Lhsq2cW/JjYnhdCUF9AEkEjQX8Sea5UnZL0nZaV0dE1xqxLQ91BOyGINwcy/DuvHHQWcSIi7aZrFvcAm1MtB0lt+vBeMTWLRdNYvQ4FkjXW3BoP7KpBkw7H71+AwcCMGCEbPIsMld44g/pDU33rvlE94haIVPWgv1whIDfQrUWLvISLuGCXc68gDmiqvoDbuGj/cXXmHHdkZujsLRODEv3SovhaQIuayAvd6GXsWtwyUIOcyLCm0YzKPuRzZy7usJFxS17W4F/+ZnmfGsTuiJv+jtW2WAz7NACz9+yHQPA== 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 CH0PR11MB5396.namprd11.prod.outlook.com (2603:10b6:610:bb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Tue, 6 Sep 2022 20:17:13 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%9]) with mapi id 15.20.5588.018; Tue, 6 Sep 2022 20:17:13 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Date: Tue, 6 Sep 2022 22:16:29 +0200 Message-ID: <20220906201629.419160-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906201629.419160-1-michal.winiarski@intel.com> References: <20220906201629.419160-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR3P281CA0138.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::17) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 601a84de-af16-4228-777e-08da9044c924 X-MS-TrafficTypeDiagnostic: CH0PR11MB5396:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HEOJ0k4NMriI/VrGLW1ONpsqKrYFto2gy3nsFbOHPosO6kuMgUfKMIwzPiOSTFc0HAbggyGUwmUAZMhqFnfXVIify6cGkOy8yYruC6lXb9WvzTadR57HlZDXcplDLxREstsXOGPesUkkeVGYhJbIkk1LbwwLWvA7mlWTxf84wk22+1yB8vfaH1lsHNiFRUNauWemiNq9jeHl5TwW2Yxz1X/++BNcWtYy8ECJ0sv1CBGJLs6rOTtbtJ2pFc3gzKD9WMdVnROCtZsaAxYaVpB4jk0XMn9kNS2t0l72ahNbX3AugN+xpLLpwEGAYtYlTsisIoVYr5ybHJA9XHPrWrv7XbKfXpw3U38cHqd76QN20lhzwD6+XEx9Rqd5LLL2a5WN0RCd6zZT4pvoR+YxNNP8NWzRIFxqvCKsYPtOYjArr+JWDSzqBzecVfrFngbVDDtOdS2GueXuz8G95l4t2iUFO8a7r13FNymJjUhpc/oi/+I5P4YhIH/DlVaQg0DX3cnOgjN8NA4AFYfeiIezAuhXq/SipDYRoD0IQVZ9PE4+aB19NOm78ViprnUOE3cgIAaiFmRQ4H/KfaLvgPVrKeJbru66n+LAUpDXQPKvos2VJ4wcF/YwyDqiX1qvKYqRt8kZShgch5V+WXJFA3vMvym5EJhkb6+P9XFE+lrUIH+pC7rf1VJkUuSYua6/HOwi1tavM+w1yNehPmkGgAAmHJbEPQ== 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:(13230016)(376002)(396003)(346002)(136003)(39860400002)(366004)(316002)(54906003)(86362001)(82960400001)(36756003)(2906002)(38100700002)(5660300002)(8936002)(7416002)(66946007)(4326008)(66476007)(83380400001)(8676002)(6512007)(6486002)(2616005)(6666004)(186003)(1076003)(6506007)(478600001)(66556008)(41300700001)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?m20jQ4cHtQ4CYDJR2Jfx8m28gNpN?= =?utf-8?q?oAN11IDcm6G2XplRFPD7HdFiUVGyx+x1XKzNO8hSUnwZ544M4f5qzrVQ4KJTtmY9P?= =?utf-8?q?r7PjsVOQelwD0f08EQhzTB2o190QtH24xcgRdIfjt4nKID5H7LNq4eyAAIBGRK+Fm?= =?utf-8?q?mS4NXpdEOvftubo/u6emlTnbKcSqtGQmqRDi8TTxJu+ITjm1/x9WJwHG0OBDQN2er?= =?utf-8?q?z8mD2vm4CegS+FQ2lFNK5swg43NwBulkK9JNNUYXk2dz76poeXQmTDb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5Db6z6hyHUCUtJYB?= =?utf-8?q?IvzvJmp7w5zgXYLxjLloGuaZEzt8WkYl0+uY0wSVGti3GTSud1CVLdaVC8OLLOLNT?= =?utf-8?q?XOQgate0sBHjsDFSiRR9e/rMDXnDPWWEUqbDSGMRJgTKJGzTDQHOqH6Q69c9sjWoZ?= =?utf-8?q?FHahtk0VDz3X/0L2toYkNKu4hiTOQ7XzlUf1GLLsDArrKB3e8SSBhuxb6ZRXs7KyN?= =?utf-8?q?ji8rDyGQ1fIvect7jdaShOgpwSr06jcAMqAAJNkYTQBpwp2Bnfjvu7dW7CuzGvWAi?= =?utf-8?q?B7dAq+ctlbjAwzDQUXYHBp/UR32WPI/IqDJRLQALfAhA/OyzHr6QM+TOp+w3myY5Q?= =?utf-8?q?Sk7XyCt3er4tgJ/AaMylSeQsHw3S67gXQ7157pTyp4P/vVMFmQK1uqMYO/lz4q5Sx?= =?utf-8?q?bGmNBMB6M5AHexEVrQXK5jFVrx1yUXrx7Q=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 601a84de-af16-4228-777e-08da9044c924 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 20:17:13.4694 (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: JhQHx25MuAlcJFKmjRr5eI3U5mvbxxd51BP1j+li5JQ/Hb7Q+LF+Ehk1lUCxZIBjI1svX24lBsDidYYODMpBa6PD6c9bJ3yeHb1vdRgJUQU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5396 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v4 3/3] drm: Introduce skip_legacy_minors modparam X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , Daniel Vetter , David Airlie , Simon Ser , Maxime Ripard , Matthew Wilcox , Thomas Zimmermann Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" While there is support for >64 DRM devices on kernel side, existing userspace may still have some hardcoded assumptions and it's possible that it will require changes to be able to use more than 64 devices. Add a modparam to simplify testing and development of >64 devices support on userspace side by allocating minors from the >=192 range (without the need of having >64 physical devices connected). Signed-off-by: Michał Winiarski --- drivers/gpu/drm/drm_drv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 2c6e0b8d3b7a..11c691543fec 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -56,6 +56,11 @@ MODULE_LICENSE("GPL and additional rights"); static DEFINE_XARRAY_ALLOC(drm_minors_xa); +static bool skip_legacy_minors; +module_param_unsafe(skip_legacy_minors, bool, 0400); +MODULE_PARM_DESC(skip_legacy_minors, + "Don't allocate minors in 0-192 range. This can be used for testing userspace support for >64 drm devices (default: false)"); + /* * If the drm core fails to init for whatever reason, * we should prevent any drivers from registering with it. @@ -110,7 +115,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; u32 id; - int r; + int r = -EBUSY; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); if (!minor) @@ -125,8 +130,9 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) * and 128-191 are render nodes. * After reaching the limit, we're allocating minors dynamically - first-come, first-serve. */ - r = xa_alloc(&drm_minors_xa, &id, NULL, - XA_LIMIT(64 * type, 64 * (type + 1) - 1), GFP_KERNEL); + if (!skip_legacy_minors) + r = xa_alloc(&drm_minors_xa, &id, NULL, + XA_LIMIT(64 * type, 64 * (type + 1) - 1), GFP_KERNEL); if (r == -EBUSY) r = xa_alloc(&drm_minors_xa, &id, NULL, XA_LIMIT(192, (1 << MINORBITS) - 1), GFP_KERNEL);