Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4551371rwn; Sun, 11 Sep 2022 15:07:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR61vlnLHveMKafFeT2vzHqUhr09Yaq9hN49vCRnRPPKVgMQY2BYRuPz78a1Pwsqbm0xwc6q X-Received: by 2002:a05:6a00:a04:b0:534:d8a6:40ce with SMTP id p4-20020a056a000a0400b00534d8a640cemr24915548pfh.15.1662934034725; Sun, 11 Sep 2022 15:07:14 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020a170902ce0200b0016ee96226a9si7704561plg.391.2022.09.11.15.07.03; Sun, 11 Sep 2022 15:07:14 -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=lDpbpLm6; 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 S229708AbiIKVRd (ORCPT + 99 others); Sun, 11 Sep 2022 17:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiIKVRa (ORCPT ); Sun, 11 Sep 2022 17:17:30 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B8F26AE7 for ; Sun, 11 Sep 2022 14:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662931049; x=1694467049; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jywupnv9VhdgAsr31Sg4CcaOa3sOFttqYpz4TqJ9Xco=; b=lDpbpLm6WQu2qL1ZOsBZdjnW0P1Gthl1pYi5SndrR2EjG+wD5NeVItLm uGVkXn0RhWdIr+hs9HfDJYnDXoVPujhJZW6VNMJj82Vy2tHBGV/Nmnj3r WZBImf7EHbth+bXFdyrF69rDQ/Z4BQNTCTSQ63wOw2A65jCODvOSIEigW sfcPxG+aE3/JyLq6HEXlG8AFPcwXCpmxLbdPy0UvwjIdpoD7l3z4AuPFX rBy7/kqGg7QYMrPvYnKsvj+QugI+eu9MAHaj/AKH3rlWc2BUykknIxIGD 3+xsfh4y5hR0fpD42K+KOf8QNgHtBoSrjrLFrFPdKlC3d1OzDou9vJEM+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="299092203" X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="299092203" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2022 14:17:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="615853524" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP; 11 Sep 2022 14:17:29 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) 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; Sun, 11 Sep 2022 14:17:29 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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; Sun, 11 Sep 2022 14:17:29 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) 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.2375.31; Sun, 11 Sep 2022 14:17:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P3IJnw05UvyF6b1z7rlNFjV86DGMVGF6bCKzQscip6CFuhlJ3O0bT7uQIa7nsveZuFSg0xqK6ZMaX2tTJaoBj07rwpV6O6BvnvXX54r0dV5pLxnaScCezO5eL7orOo13++8B0KlwMxADg2BRykrhKAHNzEia8HCUyB+wNq+sOLGf0NkD+43iI2rB4Do1rXPQYnFhxw2N1Twe9dyYE7dhDSqcRarfDWZRh+brvHobngs/7rzD1Ejhu+QFOzZh84f4GJEKYiK0I7cw4iA76p6v+j0DYoxbMb1HRi/qinq+UR16dt0L/6+YnT0v5CU/stmfqRIctLJbuat+cQk0wQDUPw== 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=nWTLd9MTRbWNzjDin6e2/uKyO3adhW5rfCcTQM9KbY8=; b=dFqlCUVC/jztsAQWiLFKtnCjt9ymLW6tMT4bBY+aW+jOSO5rb7HqSZl1LwiKJFHvPdmTJEjawVSGQNHW+2Zm800/EeOIx15dm3feGafElM8E4b1TeeOlbQo0SX3NDdD8yYL999zKHXfAyeWM93vDFktnJFsUwW5hZ25OSB3ZDSLKDnkCTOAyfv1vuIJeXuwD66+caJ2gTR0YktkAMvtLdpf9Ki86/LM78NPbbAQ2vSLEg9FS8sV8WnT0fZTAhovWMu8KXFI4f2u36z1UxCgID3VU9xFydsa4/N2ejorSoBFDzn8r1AIT0DzpmEGcnwjirwxHottiaUwZj8KhXplKzQ== 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 DM4PR11MB6065.namprd11.prod.outlook.com (2603:10b6:8:60::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.20; Sun, 11 Sep 2022 21:17:18 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::5145:64b6:db32:b424]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::5145:64b6:db32:b424%5]) with mapi id 15.20.5612.022; Sun, 11 Sep 2022 21:17:18 +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 , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v5 2/3] drm: Expand max DRM device number to full MINORBITS Date: Sun, 11 Sep 2022 23:14:42 +0200 Message-ID: <20220911211443.581481-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911211443.581481-1-michal.winiarski@intel.com> References: <20220911211443.581481-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AM6P191CA0083.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::24) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|DM4PR11MB6065:EE_ X-MS-Office365-Filtering-Correlation-Id: 9324ec8c-1bae-4626-ea4d-08da943b01e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ynywRp5uHUFGYNil3RpV8p5+x20/mOjQ2lEOIZDZMHFIUwKTrF25d88QvP7HvH18d8jMV1mH5784QFTyCdi2KpuctFRXFS0nJaTHr9HHs6ZW4JbKqTkaTqgqdrnmp+lux8wOGL9LJApRpPd7YxeZ0JxeSN/HfiSJjPYiIGBD1PNVPj+ZSdfcP49UoQmi1eBpkhOUh6jezgByviYyk/mzjjrgJXNZjCgI6EF04CzoOuXt6ZSo8nsU2XzFyxUl7QSzD88SO2qfuhB4bkQTiztgqdCvdd6I0LXRciXqUT3Dc6FWYq/gKYpaWc5RJYeSy8c3d0Oi/Kn4Cm5bAoE6cFKUUbYSL1djNb3WFI00Iall+/ON4dImHUgdIFSvlNzvrAlEeUOvu1a7Rau4My0I5GzKeybjLoLLwc6U1UZFgqfnEMVpNhikopyBPWfkskXA0hy0WIx9ePArxduCds4Bhyk00x7WJLNWGiv4Xi7EShn8hbu3ThawnhChqPtsm3tLLWcB/pel47SgW+i8DUDp3fvziebIQ9pm3UwRw/yEil91wAPCn/x3mc7N658rueDWBl7emvlA3WrQdPqiPxGqUC/7S80ZVfTyvwCax8vVwBS4FA4W7dkbVq36IfMxBTqjUuL+xawBbHhXuLMYox8kEx32o6Bs3BAq63mpHl12MlOi7RLGwJLTUYWhz6d6615jLIO21Pck8FhhFYkDxqg7K8nOA== 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)(346002)(366004)(396003)(136003)(376002)(39860400002)(186003)(6512007)(26005)(41300700001)(6506007)(83380400001)(6486002)(1076003)(478600001)(2616005)(6666004)(316002)(4326008)(8936002)(8676002)(7416002)(2906002)(82960400001)(5660300002)(38100700002)(86362001)(66556008)(66476007)(54906003)(66946007)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QUpNa0lqTDAwNVQzVnFwZmlxclBoZ1ZiZmhQc2ZqdDhMTDFKWjJtNXBTclNY?= =?utf-8?B?K1NtUG1ZQ0tpN1hENWd0WTVVSFE1RXAwSEpLWDhIaE50NEdDUDBseWlkZFJa?= =?utf-8?B?aUY2cUZ6RDIzbldFS0EyK0d6dzhIWTROMzhvRG9MemNPWVlLL2RVQXJqcEV3?= =?utf-8?B?TUkvSWlnK0F1R2JrUTE2VjVpMlBkbkdtNy9CQlJKcU5QaktHVldqcVN4Q3R0?= =?utf-8?B?by9Xb2tyQkx6VDZYZTlUR21BT0wzeUVDR2xad0oxZlRUdmUrWmNjUkhzOFN4?= =?utf-8?B?bitCbko2K0hJVG5FRWF0OE8veUxvT3hwcVF1Yzhsd2h2dEhFTklUQ3YzUFRl?= =?utf-8?B?NGlEdjAyMysrL0FBQndrQVNxZW5SdVF2MXVIcUxkU3Vwb0JNYWtjUGkybnZa?= =?utf-8?B?c0ZjNFczZUpSTWd6YmpQUUdBYU1wakNoUkZjTkplSkh6M2FNaGp3Q1RqUjRt?= =?utf-8?B?N2JSQVE3LzFERG50cXJWTmdTd3RCU1M3WVpjQWkxRDNIZG92UmsyZE1XMEJp?= =?utf-8?B?VU5KVzhPM01La1Z2NWtGMEhaZXNuenN6UTFsVVFnWmdjc0ZVREY3NjE3K2Fr?= =?utf-8?B?MWxqMFZ6UFRZRVVpVVFTczlwZmMyS3M3eGxpYXRjYzM0K2NyZUJHMTlPZ2JH?= =?utf-8?B?THlBVXhlUThwMGZxYUVJSG12Mm9VUi9IcVFYN1NtNlo4RGJuQ3lyalVvWDk5?= =?utf-8?B?MkRZR2lPK0dyeXdJYnVIVzk5YXFuT0dwS1BLREJVbGNXdmNnZ0FJTjN4NUQ0?= =?utf-8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=?utf-8?B?SVp0dE9iVVdyRWlOajhyT1JZV2Qxb04xOU1KMktBdGRrN21xOCtTQ2VxbXVh?= =?utf-8?B?MDRVT1F4YlBvUklXUmNmWWU4OHZybTlWWG9mS2FRb25SNFplZm1iQ0xXRy83?= =?utf-8?B?SloyVjZKNlBNQ2x5cUY0RWVpQ1NGMExVVm1UWkh4OEFMWUtYdXZJWldEWWF2?= =?utf-8?B?UmFUTVRTN0dXbEhCUklIMEFOd0NnaTA4K3Vzbjg5VXBBSlpsb0FSK09reEZ2?= =?utf-8?B?eUhLc0tObnRaSFZ1U3o0THRXNW9idHpXc2NjSTB2bzVPTEVUU3BrcEp4VWpR?= =?utf-8?B?WGNEck13M29qblBjOXFQbWV3bC8zcndEQ21IaXZ1ZVRKWnN5WWpMTmNCQk9v?= =?utf-8?B?R1dhYTRPWFdmWUoxR2NPNndVY0RRRmYxMGpBVHQ4ZGFtZlBnbUc1eVppWjZ2?= =?utf-8?B?UGhvcWx4YmE2YTVWYWFqRlFZVHV0Y05BNzN1TW90Wkh2bi9CSThvb0wxVTZh?= =?utf-8?B?UGc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9324ec8c-1bae-4626-ea4d-08da943b01e4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2022 21:17:18.3044 (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: /p+2gu7tO/gOmcWpzcjrAwBNZfIAcozEUB179dWLw3BQOB66jRj54/pF9AGHXKXFBe41OXc3amiAS9Htu4CP1WGnOX4Bd/Bst1y8/5wcn10= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6065 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 61d24cdcd0f8..3718bd6bbef6 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -106,7 +106,8 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data) xa_erase(&drm_minors_xa, minor->index); } -#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); }) +#define DRM_LEGACY_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); }) +#define DRM_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1) static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { @@ -120,7 +121,15 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) minor->type = type; minor->dev = dev; - r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL); + /* + * 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, &minor->index, NULL, DRM_LEGACY_MINOR_LIMIT(type), GFP_KERNEL); + if (r == -EBUSY) + r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_MINOR_LIMIT, GFP_KERNEL); if (r < 0) return r; -- 2.37.3