Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3656739rwo; Mon, 24 Jul 2023 14:41:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwU7vjQdg1+X1NDwlRs/IzYxQEDDSdLAMa2cF03LOrlimj2wX6QpkM5Y8C7HiYEUMVSMtk X-Received: by 2002:a17:907:b0a:b0:993:fa99:d7e2 with SMTP id h10-20020a1709070b0a00b00993fa99d7e2mr9844935ejl.21.1690234912142; Mon, 24 Jul 2023 14:41:52 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a170906268200b00997e1a4b954si7025885ejc.25.2023.07.24.14.41.27; Mon, 24 Jul 2023 14:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AVEw9OEH; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjGXVPj (ORCPT + 99 others); Mon, 24 Jul 2023 17:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjGXVPf (ORCPT ); Mon, 24 Jul 2023 17:15:35 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FC9198E for ; Mon, 24 Jul 2023 14:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690233328; x=1721769328; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=kUXpil+EcubVXuJnN+4CExkCdaMO2sx5fW3H8oEPG/A=; b=AVEw9OEHuI/xuFQj101j6Mda+VG7dPWGgrJK7X1JJ2LlRM440OjF/sAc k7905RXE9zUOGSlZXysFHrXryZXZrsVsR5lIg4IWN+YiYoZ6ERw8QrDR9 R86H9Bf/cU7cfEWO0BoSYz5rBVsFST/Gc19C3lIgLgL+6qUiH4M5BKkg7 +y7AK1U5wv4VFL2FikC7J6uULcVlrdNYLBNROv0SEQXsS9Dh4l4Yf3vlW Oi6DTVNfdd94YKINVYz7RWf2pdyc2lSZOrfAZEaa/HaWgym/u9c53elXi jrjMFXCcBV0xWqNG8iLS+Px/dF1Acss/acYJO/Kmjv53lXYjMwHmjQdgL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="347830108" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="347830108" 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=20Winiarski?= To: , , CC: David Airlie , Daniel Vetter , "Maarten Lankhorst" , Maxime Ripard , Thomas Zimmermann , Simon Ser , Matthew Wilcox , Oded Gabbay , =?UTF-8?q?Christian=20K=C3=B6nig?= , James Zhu , Pekka Paalanen , Emil Velikov , =?UTF-8?q?Micha=C5=82=20Winiarski?= 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> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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)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klhU1UrWHRiNU1ERFZibXF3Wm94eDB3ZG14?= =?utf-8?B?UHVSQ1VPVVVueTNBTUIvZk1aMmFoTWVFZXYrVW9odFhURW8rWm9xNGNwbHho?= =?utf-8?B?Y2NTb1JydHBnb0tKSU44V0F5OUh0ZEFjaGZFcGZjVS8wNEFvUjlNVGZqY0Np?= =?utf-8?B?OXF0THdybDV0QTcxaVZNeTIzNTVISnhaekZ3OWFvM3F2UjdUVk8wMGFEaEty?= =?utf-8?B?dXZxR2NaR0RDVEI1eXJLVnhnQjU4S2tMcTVFZXh0VEhHSmkwdnFFVHVrTi9Y?= =?utf-8?B?SjFHTjh4WWt2clBOTTVaR2pJZGNmNytjODJJVHZYQTNIU1hHQUJCbnYydm85?= =?utf-8?B?Vm5xRnM5OGNRaFhWbFd2dDVDaUxQdW1vbURURmw1QjRrRnB1RlN5RDFFdzZD?= =?utf-8?B?L3d4NUdTZmFoM3h1dlFPZUNxWTdlbXpRbEJodEpXVENuYldtczM5OXczUnFQ?= =?utf-8?B?RWc9PQ==?= 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.41.0