From patchwork Sun Sep 11 21:14:41 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: 12973071 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 302D7ECAAD3 for ; Sun, 11 Sep 2022 21:17:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1832110E532; Sun, 11 Sep 2022 21:17:36 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DFB310E532; Sun, 11 Sep 2022 21:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662931050; x=1694467050; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=bPLXSt1pm/aLYOUXA2rtyWyj09IwpOs2VhXPRdNLwRU=; b=YwM7Oeg8UnKWg5KjNf1OPrAEQqzL4leZoHUINYUwmzQ1b2D8z0OHjhaK N20ghdqjQBQpm4ibSLcpm/Fb/3xlCfPrsLC9o9lEhCwGmWgyzmwbA0vgI R7HcrLvkDCTQaMg73hAvy1flvICI8b6dNu8wJFxn8P1matRLWABgalPPK DGPZMLOinHIXoPyNWSEotROQ2AotGKmpyMeEK+wRAQFemE4k1VyORFplr qSY8CssF6Bw69o0z/Kh3bBlyAm7ThiQE276mYnB5O3EGd2DwzJ0K792Zb otzRPph9criN35fquQLqHlHFCaIA0IxxMWlhMs+VMTYcEIeRMDlYpsZdG g==; X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="277487732" X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="277487732" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2022 14:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="791356686" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 11 Sep 2022 14:17:29 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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 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; Sun, 11 Sep 2022 14:17:28 -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:28 -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=N9meTzF2RFyc2cElWbSRkdvdoS04F9Tz8/hY6u//PVpKTvhVcptcztgSMDZWtrQ2IujLr3hdRg/LNZUZAVt2AurHn1pw1puFiSRC3ejf9UONoT0hned+y9N41HSrrga5cGg2nPDwU2jluLHZL2cE1N4e2vmF8fcwgftgu5mnyq9wYOyEsrfeIx7v8nR76/tlbjCRdqriY0u4zQv2SjCZI4XEeuOaXPxHFks+WXHipbEUoPpQNxkQUm0ti1fDqJzOdGVtBFkqnKeT4H5aRtfdnJ70eHXfbll7HGrHCheeEiP6+X+dWvZ35Pcnn+OfZ8IcvIKicfBqPOJj2tb/C/iiFg== 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=fx9UFjBAsMM9Poo6R8mBv0u71VD2XvTy4QafzcE70Nw=; b=Q6FwgBAhnByyHSygiEIYjUhdHpc9PhlBleGSkTVng24YAhRcEpe6x86l/7doDCCmPRH8SnV9aFogul+W56c4+Lgq6AgoohVMdmYjtvkAmIyKGN+mF4ncKijoILdtuBBsVTziT3e9F7zaUGQkPf3XssmVWwFIWqBioriBKexj1ehXOwyWEMfxnCkPn9EYRg0m+n233W8em27fEJdySuy0QkydQ5uwzVyCSJtKD/hu2gWQ4RkUNemz4XDdDOjDZAeR91REpprD6VnAYRoeks8Hnxt32CAGiAfcTTXUOKFgMJNA/MiK88NqNh3cweE8J+3wOvy2GTLJOTQQhuf2H9TzyA== 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:13 +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:13 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Date: Sun, 11 Sep 2022 23:14:41 +0200 Message-ID: <20220911211443.581481-2-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> X-ClientProxiedBy: FR3P281CA0004.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::23) 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: 76301df8-9415-4a71-e135-08da943aff27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uzU4OoR4SYOTaN4e2IqfIyLFufuPnOT3b+WiCvArtt2QAvJnQp2T8nbs7Ac3331CA9ioGtwGMPuH71V5G0CRAfMNWbJHKJEfNnb7qZvERvPjOlvBvWQ897vHEvnJ/mobpiUCxWJHwnRett+TuHpYoF/oN0naumocEww9JU2D+MZO/8h4elsa5SD9kM5q2AfHNI0YbnDzdnsdy0L3nStG1xRyJRtPG/OvrXFU6QgfggTagsgdY39LUdZs9qpUE5QVemTdeNl7ad7XeZcJcPh9a4tNAlEnbPVEhzNSC5DF9tpUJkoCLzka1L1SG/UJ+cWO6ClcCVE9Hv+K8ld/k/dNvxSQFHOdOwSYfVPBNTYtgt3VWXyMMqPH0S1vmGII9xdMuovN+oLw9kvG0ndijvNOV48Y/GwCKKz1Mhkd6Sjb0xGuvq5XdcAnhwffSyF9h4HrF8unhdNlD59HLttpM2uraM60DbiiQ8eq5ujcqltIP36+bvDQWbuwPz77MSgONyudqAugMQcC9Ey9AJXE11VwQ3bXPYZSUAPKfIYm2Vlt9jJweahq8+wSEoPoJCtnDVVwiRqnFERV7nJ1e7daEXTZLnJBQl3ArXGbO0m98vaJ2wlBFX5zYf9rEKrebo8wSwCzRGiSDm7HjY1YRQ/u3bbc1xynW7M73EnPx6tc5aYfj8IzJJOS0dS+nRiPiGS9uXYrdYoKX77GV4Hqli4sKIlFnQ== 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?q?CmyWcjKl8opITjCbhRfzvVIkkDqy?= =?utf-8?q?gc7nX/UmqTKTTuFlRLDuJnPrlGC6W85/Jg6ywHz/nMP6RuJOFUYYalBvlsXsRhMvQ?= =?utf-8?q?9ImlIT0Spn7u1JMLmdF+ZJhul0q9hspyP4zyokTgpf5xp1OPUWPqyD12E8OXAM1ql?= =?utf-8?q?E9Khk2Ad17XOwH+OLqOZIADDDjAn+IXLROuweJPWH2NnKVXkaa6nBFay3pSw6ZHM0?= =?utf-8?q?mfnyEYWpSHoYz5EF/hMsQ5qVMQZyjkRckn+jWGnQ2Ncbrqx21qB9R+E8V1sgwHHQ3?= =?utf-8?q?Vun7nW7bv2+RvK9jDbSpJ4x93VwVkoJRf3yVyt/iV0amuhC/F1TcSqz6Xs3IjqivP?= =?utf-8?q?I80W3NiumY8iKrEYNvecXV0Sp9ENobz30SUeoIrY6xRKDiL3+wXq2Hz4AFcAQ3GaW?= =?utf-8?q?6obT0XP/yR5STlKhmyk5EergmEHkGIgwldV9lOqaQtxCMKo/4HRf0ymDb8erAX9QU?= =?utf-8?q?FAs69QVVTwusAfffZA/wo6bswo3F4bfqFoB5ojMLNX7xrMkDIzI/uTXbifTFjXqA3?= =?utf-8?q?HavDOB+1uF3Km1/lDZ10UwRIuy/JnL+SrhJifyKL1vsi4ZdauJhnq5H5YgRv9GOxY?= =?utf-8?q?MfJ7TYSFffX8Br/qrpCoQG0i3Jg4wpplJgynV9pW21ansISKA56zx+veV4Zj5aL/V?= =?utf-8?q?ktNRupyKN+gUW6DYbwc85etIUhQbjMdBP5SqoMSa+c2f4KV/8TQCSysJv7n57qAz1?= =?utf-8?q?kYMWE/ZwH96GlH7dCy582bTO1lZ2Sow8KnR7BZLz+XGhDbIwXmkD18OA4W1xL43DF?= =?utf-8?q?26Xlpurj2wGSI0SbKNoMH2CW8QFeZ9zqH0bQnbZz2qWMHLt7gsAEEwwf0AWLnToBU?= =?utf-8?q?EyDEPOzLNuMUhB4Sa3hMy3rYeqWVkcJxEin8a5+6ssQ6kdrjkj1Q3pxGqenMD9lbr?= =?utf-8?q?VtM2LNhEMg+AyPmPoCQ0gWCHzZ3on7xAjU+KBmCDGz5yF8xfsqNtMz5yAm2Q/WGXv?= =?utf-8?q?Q0EmeTSrbSWFAH5PSQBUYeAzUMw8wJagLvCi550OJxLgj7QQBj34icdUjlt/tJ8aH?= =?utf-8?q?zsGp1NY0eKFr9ynjfO0EcdGa0nnMs6WY0Zb0lClb5gnca1g70PXxBvsa8eOdrwVvA?= =?utf-8?q?KO5F7WdBdakZgXS6Z09bvMj5y1aTCgMqSYymzF9nFj7LEsLTylEAtklM0Y1zZplhP?= =?utf-8?q?7KnBjL8WjpixQeD9/qdcgVJ1LMJzlhFriRXsDGtnExkDqo9HZE0Z2Es1mP0bqQbQb?= =?utf-8?q?MKVMNKrVecf+S6tUC+aDddEk7Lq9uq7eYbTXheRTRumjlr+jXZ+HefW4dseT0aQ5Z?= =?utf-8?q?GeSfJyTV/XoBl4e/5pNEmAov+oPKMdxEVva7H4VgCgC3qzbommrsS4ESVVvrK5Wj6?= =?utf-8?q?VP7SXyzlwctu/2wMW23loigeHcqlOFSTi3+5SkyFCC7C8orurHWktOs2sdVhKLpZa?= =?utf-8?q?DPsy9HgBQViIRAOk/oaOFGKFmQTwJU2eOJUnmR4XvCrxrEslU3LH1zYQmW70fyyUY?= =?utf-8?q?ddhIc/AY0gxvcnglg1a5gsBdHah/ONg8SAX15zR2k8lBfE66ShXpto64eb7VkYbKX?= =?utf-8?q?Qd8oeF07t3eOUysXO/j6nB1zz+JMfN69pw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 76301df8-9415-4a71-e135-08da943aff27 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:13.7101 (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: cEtUsDVqkIZHemli3VY03qJdtjUYkl2ANR4l4s7jLZATOWb/ZIY5b/mF2hzNRCmXPqGda8IJfAsuiokC0sLS03lfDp9Juc1jUwyRyQfleWY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6065 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v5 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 Reviewed-by: Jeffrey Hugo --- drivers/gpu/drm/drm_drv.c | 51 ++++++++++++++------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8214a0b1ab7f..61d24cdcd0f8 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,19 @@ 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_erase(&drm_minors_xa, minor->index); } +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); }) + static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; - unsigned long flags; int r; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); @@ -122,21 +120,10 @@ 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, &minor->index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL); if (r < 0) return r; - minor->index = r; - r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor); if (r) return r; @@ -152,7 +139,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 +159,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_cmpxchg(&drm_minors_xa, minor->index, NULL, &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 +177,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_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL); device_del(minor->kdev); dev_set_drvdata(minor->kdev, NULL); /* safety belt */ @@ -215,13 +202,12 @@ 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); + xa_lock(&drm_minors_xa); + minor = xa_load(&drm_minors_xa, minor_id); if (minor) drm_dev_get(minor->dev); - spin_unlock_irqrestore(&drm_minor_lock, flags); + xa_unlock(&drm_minors_xa); 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); + WARN_ON(!xa_empty(&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 Sun Sep 11 21:14:42 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: 12973073 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 57161ECAAD3 for ; Sun, 11 Sep 2022 21:17:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE3E110E537; Sun, 11 Sep 2022 21:17:36 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36D5110E531; Sun, 11 Sep 2022 21:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662931050; x=1694467050; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jywupnv9VhdgAsr31Sg4CcaOa3sOFttqYpz4TqJ9Xco=; b=it3kGXNw7dNQGS7I0STprwc/NFJtwcMFz5r6B2HgHU0ZmaO+6zlHZFeN L0ZxJznKGLOURkw+EBf5Pc2imfoTw1revHLMgaxv0H4GGTWhni0rx1A2O Z6d8yb2/0J9EMfChXARBPEgiAE/Q5kNUNGN9rk6T2RqYPZJ+5Ih9HOj3f hRIa0q6mmXmtoj6JptlRmoo2FHzaYrLa8/VLTUOHf6508EkrUlzo8FuzY ABmrYh1jp+QVm+H6gGQHfPbWzxho2/0Xo+TaEQ8hcFaoCGR3VuichuVS+ 2P3lW4llyS7zZf+J9ClYdVjwdFjmYMTGt/B0MkdeiWyqmxIQAuUBlDuGR A==; X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="277487731" X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="277487731" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.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_Winiarski?= To: , , 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> 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?q?AJMkIjL005T3VqpfiqrPhgVbfhPs?= =?utf-8?q?fjt8LL1JZ2m5pSrSX+SmPmYCKi7XD5gtY5UHQ5Ep0HJKX8HhNt4GCP0lyiddRZiF6?= =?utf-8?q?qFzD23nWEKA2+Gzw8HY4N38oDoLzcOYYK/dUArjpEwMI/Iig+AuGbkQ16V5i2PdnG?= =?utf-8?q?m7/BBRJqNPjKGVWjqSxCtto/WokrBLzT6Xe9TGmAOL3yECGlZwJ1fTTve+ZccRHs8?= =?utf-8?q?Sxn+BnJ6+HITnEEat8O/yLoOxpqQuc8lwhvtHENITCv3PTe4iDv023++/AABwkASq?= =?utf-8?q?enRuQv1uHqLdSupoBMakcPi2nvZsFc4W3eJRMgzbjPQGAaMpjChRFcNJeJHz3aMhj?= =?utf-8?q?wCTjR4m7bRAQ7/1DDntqrVNgSwtBSS7YZcAi1D3HdovRk2dMW0BiUNJW8O3MKkVv5?= =?utf-8?q?kF0HZesnzszQ1lUQgZgcsFUDF7617+ak1lj0VzPTYEUiUQSs9pfc2Ks7xliatcc34?= =?utf-8?q?+creBG19OgbGLyAUxeQ8p0fqaEIHmv2oUR/HqQX7Sm6Z8DbnCyrjUoX992DYGiO+G?= =?utf-8?q?rywIbuHW99aqnOGpKPKDBUlcWvcggAIN3x5D4mPngatWoqVvjKNA2LctcjtLmVh9C?= =?utf-8?q?K6Zotk5V4alxSfYOeJS5GJNCRdukX9j4RxNlvxIy6ZVYEdKa8Q9rMIcskb4VAtPG1?= =?utf-8?q?jkjdmYdUReNosEYbyV+NyAiAQYppnk49WKa9ohM8MP7QzRdN8jWPkGLKQGIbSQZdn?= =?utf-8?q?3dP1Jtl9gnOfiYzNyLooRthH+MTQBeHh5IPMmwaKzcU/r73W3+MQ71UjOMDo62+kY?= =?utf-8?q?H13pvPv/LsNLooZXpWNAjg94fhWrAFs0hBKbTCL4jA23CondpprnVcAaDFsNeYC4g?= =?utf-8?q?Fj+d22pmEqUsjgQ2zhHg/w2VC63QTt2myf63Eigt/imO9fdtYVYBlC7DD4kiCIDjB?= =?utf-8?q?3uakK/DaEHvqfHYX2hVp6KVskxT3nIJh8xS3kqVmbsAKZUMYE2ds073SaHLj7DbZY?= =?utf-8?q?ZtaegDQjZprktef/kmHMvrbIbILVRxKX9vBPbkjj455hlt5qg1mLU1xlMP67XoGbl?= =?utf-8?q?FIw9pJ0HB4XKAQsJgSGfpCAkRpLeb/smU6soxuRcvTP5hMd+2y6nU/mSXO9MJLc03?= =?utf-8?q?FjTrM6uYRmv+S5UKHsgVG2AAYZ7+F8BRrv7ujSo3Tijgnj/rUBrehIGDKzZh3Q9Y2?= =?utf-8?q?G+js+8EgsQlxcNBd8iHzM03zDRjY8qyrjkjEE9RcfJU7dfiFaFj40pVS6So5pdIZt?= =?utf-8?q?tObUWrEiNj8rORYWd1oN19MJ2KAtdk7mq8+SCeqmua04UOQxbPoRIWRcfYe88vrm9?= =?utf-8?q?VXofKaQonR4ZefmbCLWG/7JZ2V6J6PMClyqF4EeiCSF0LUVmTZHx8ALYKXuvIZWDY?= =?utf-8?q?avRaTMTS7GWlHBRIH0ANwCgi08+usn89UpAJZloAR+OkxFvyHKsKNntZHVuSz4LtW?= =?utf-8?q?5obtzWsccI0vo5OLETSpkpJxUjQXcDrMw3ojnPc9qPmewl/3rwDCmHivueTJZsyYj?= =?utf-8?q?LNcBBOoGWaa4OXWfYJ1GcO6wUcDQFf10jATt8damfPgmG5yZiZ6vPhoqlxba6a5Va?= =?utf-8?q?ajFQYTutcNA73uMotZHvn/BI8ooL1U6aPg=3D=3D?= 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 Subject: [Intel-gfx] [PATCH v5 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 | 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; From patchwork Sun Sep 11 21:14:43 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: 12973072 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 7BEA5C6FA86 for ; Sun, 11 Sep 2022 21:17:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED19810E536; Sun, 11 Sep 2022 21:17:35 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD5F910E531; Sun, 11 Sep 2022 21:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662931050; x=1694467050; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Eni6pit1misnqHqlJtjektfnPpxUovniHQMbrNEZkCI=; b=N9BxYJGCDHslRznkl9fgaPH/9TsMfsmAprW0Hoe/Fp9RhJDptA0VTJPM B1E+UhvSkUXI+bsph7tRM4+3HFW50s1WRjbwDW2vPuCDooMQxjfNKrQA6 psDMT6chGkRJ8PQMsp/xxJKihsOBH+LiqXG6C2hgF3/Oi8NUcScIHTJhI YhOPRlR4VBg3HnO33QL90GhtglT87lArNZ3HQKmBgd9tI8aOFWe/yBYlT uztqqjarrirUkEPi763dh+GRlFo2SIOBe8EXhYM8NFeOc1/cGnctbZ7Ym NE0XlkBDlPNtRIY2lSlR4azuI7S+QBkncfU1cgld5u9EwyqB8yvTwswY9 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="277487733" X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="277487733" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2022 14:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,307,1654585200"; d="scan'208";a="791356689" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 11 Sep 2022 14:17:30 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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:30 -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; 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:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exgtPUFVWCBaRTKnXWxN3Z0W7nCfMxdlxnYATJ/5H/2zNr1p/U0qn04P2GZ61tuo5HbHp3DyV7jczwhaMT83GQoxCEZ0o3yTPvqgxEWnzBc7Ay87jVHIAGqNh+XnojUMNun53xRqwj3y3+aYf/8NsTdvFGMFnXeVd+z624BOVnmS35jjiO3ysrvTv3Y4h0vvYb4TpeLTU3Q2mgKfByh2FfhdE0eMcbDFuuvt8u9lqaTaD5mWITdGlz6NZum/BY9USmlfsJGROLwWrtTuaMyVw4kRTIIGCtU0OiRTZqEfMecM3PXIS2p2d3mhvTfC+tIon1uUZEwocHt2/a2w+so9Ow== 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=BURZsTUp8t4+hgi3/wRuiapcI4tA1G2tUY+fOYCxK7w=; b=fvASL/vE52tLMvfVGpi41mAO8Ly4w5BrNAo1lW8FW2FG1U8T7p2uYmkqWQPCWM7LLR8IXcNlvXYizafFD55Kg2ZMQiPRXnY+khwchFJKeA7Su9uD5UtbrF7TD3lTlCvJHN8sSvsDcYgtU9gAmtWmXDC787amtpqyeVbG6E5myQ3vj7LPzp1KyPIFrjUaozgGx9JF6HFRLHhK1BAUu9LFG8clKgSoREoib6qKMvIwnNvsHH4QFx7F3fBdl0GxzQze0lZlwlVVU3KLDaGdvkjEjGxTNxNXXCb3WG9Au9kl6eUnecj3OdEw53tsTUqyuS8h2yfr0B7uVbzyAP8s5CGULg== 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:23 +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:23 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , Date: Sun, 11 Sep 2022 23:14:43 +0200 Message-ID: <20220911211443.581481-4-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> X-ClientProxiedBy: FR3P281CA0111.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::14) 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: 10a2f41a-644d-4cb3-4a88-08da943b04a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ufxRGNyPea//rp/OTtiLb2TfdPosKT8gGX7yeSKabRKJD9V/ishLR12w1sBck2FqpWefKddwbHEzDYrty7HN4beOUd38gMkae3HlTIlxICnawSJHnfVSB6MpoWsOzqWjTGbjs7xQKRDBLBuKH2k2vqMfHA2EDtelks+myVtn2zalDQNDrRuDwhFIbFVODqvuGDHEBXVA4VLtWZsbOMXfiilGNeOy7wg35jWE4Dr2f9slfsf02J6/9yc5o8DKjuYe/o+6weqy/rP5Z0SyFqPfXq9kKtC6FPtgtogAfKWTrTSWZn8MkxXY2XxJlGh1IUaX2u6dCoygX6546Os5vKPfKyxLej1tLwJ7q1ttC6IIBs/sAhrDCkmx/Zgw0F2B+tlG69Pp4X/7bEr/Lq+DXCD9gx5bO5TILxDorU2boa3hiQNM6O1OKAfj+Zq+2+bsPDJwyG8QRwJhtva+9YX4Pxxc+6yhLoChemwAxl3ywgscZ2GgtNuXcVpuwQfaouAl6yhCIsAAd4wNTgxoItOm6JSdzOOqjQmlUdXsdp0mUwMwUJW/b3iUcw8ibc/+smt4JOYyelOUSDQ5yVYijCaPTUuomfCp2alDsEgKMJdG3UGk3yb7uYRQ6PzOircekW21P34uxXu8Fp4nwz8dH26OXe3fzKfeMyOh+xtSqa60Iep1o6IbvGHLjEzpTRisabhA9qNrprN95qyovBQVmf30cqzYg== 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?q?lVnjA2doM7EavXUv1PYDkwe3mest?= =?utf-8?q?aQAbmT31+rpCpSTgHX1VjrITZv/uK4QQEleWfDGtmcGS0glsGFKjZGAcJFtaABv5u?= =?utf-8?q?2ZuVut/R2H/ObZJlSzTyIgVmR5USeIAnLyA0uNbLJnZdYOK5h/62Y2vdh2Kk0cyRD?= =?utf-8?q?ZlI6p5jq1QbhqfUaIJyo9Z9VjJZkqy8vrSfjA4aKi0I+vt8Hk874ifEQ59OzvmSJG?= =?utf-8?q?oIbgVr6Ed9d3Ul5uQ/vbBwqS6HamnrBLqyVwSa1S8qJOJm8dJKtY8MwC/UKVFPf4E?= =?utf-8?q?YskM1PgCFKB3wZrOZQpd49CBKZbs7yvnyirm2Dvsg8XmzNlcysuSyeietHHhc/aJA?= =?utf-8?q?d5x+9LFFic9lYrXTKPegFtK+aJop+B9yGAa5OtmEpZehgs8E+FSXUWE0p0snRphbL?= =?utf-8?q?tjvh5n3okoaV9rRyCDWxX/jMVsVR1FbBNY4hsSd4wP/olBFhjT1d43aEslTlt66cu?= =?utf-8?q?nk0MvvfxlzEboSZ5z7JN4EHQW6PQrkv8bKSuFtIuJGZBZgTIWvlCqtQXK9ceoozp5?= =?utf-8?q?6S36oDuFwvSHwAwbEXzZVZMEB5EDROHT/dA9koV94qX2kFQW6FOwjxQfWsXx/27pW?= =?utf-8?q?jB866bZKp4qw0dUKkDaYRryl7Pc/uypJVsSV4EiiV6EoYvPJrvGKnrmsLUwNsQK+d?= =?utf-8?q?ywE5x7VHTd/dj+ZaVJMjVqHhUMJ99tehBKCYIrs442Jexhccmv7kPjFU70X67u0LG?= =?utf-8?q?BYVICkrloynE13SzmStiZoX0EOal7CR8EG1kocgUyo0GCLNIOrgWZ2LTQwuuPrV89?= =?utf-8?q?LnfKLgJ+H6wNKtU4BrDS5Ii4X2hh/bKb3xuXSzTLAFPQ6RedqP5sRQIT6C1jEYjyk?= =?utf-8?q?Q/T6AE6tWVBl1d/lF9/ay6OVY77AfguZmYQbpNzQYuzw7l+l2dSorhVOt3CuNN6om?= =?utf-8?q?AXIvHParvvHpX3pqREv3Eea+tvsdEnQfFF9jBzRIMSv7QBj+TzDgJ3Jal+JIC7GTO?= =?utf-8?q?SlkzpDR+tK0lANEoJ5BKnQSgeSWv6tItkdYvR1AUAjCMmacyMxdvOsnr68WIktEDH?= =?utf-8?q?XIdfHzbTQeWd/csg4byUCR3Q9x7mEJEbJ6KohSCm/uFdAyvcfdXLZB2e2N9JCYFut?= =?utf-8?q?X+3H65HPtFc/8dn+k5LFCdEvdCYyE3kcspq+PnWW3/kNp9va4GH2j+ecmgZw7qYwy?= =?utf-8?q?/q/e3YS7H4VJN2bThJa2chppidPb729L+crD558qDx5MakAJZlxMlyVEvI3olHDha?= =?utf-8?q?dai2J32HfE+rufnsa8Zm3jA6NvhVLmEJQ5hpJ14Hk2ywHLIG0um0r3+0HCb7fQ2kV?= =?utf-8?q?FLsTTc56ldQR6itCCGzZYzOMiDP28s9X8R4lrmuaN2W6Q2Q/R4VEUdl2ciwLhD8EO?= =?utf-8?q?TxZ/aLEXyBt4leNwDA/uXM2BjWZYO9+L27qv6a7OblkaHcV7hPnTQrO8GdzX/2tqC?= =?utf-8?q?FInAFAi9q9s6Pk8DlQvRQACWfexXrF8XFW0Ae9vKKQ85XtCGc9XM/eLPiZowFpq0H?= =?utf-8?q?VU6JbobnEdkRtRw/Phl84UZNcu2PnMenErskKxofSWpJT0m8CZM7O69b6/NMh4jOX?= =?utf-8?q?wKXv4O/tfGnxJ4hpZNTMTJSDwd1ZSxaywA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 10a2f41a-644d-4cb3-4a88-08da943b04a9 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:22.9468 (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: tOXhJsMdUogiZMFfGmOlcPou/Nen73LTq+OSbEpGcWyP7Mgl9a2J/VUa3K6yPt0zGkWU6XcLjtrMt/x9Ral/DRrW76k7VTjbebrB4mXUPYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6065 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v5 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 3718bd6bbef6..368408997fed 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. @@ -112,7 +117,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data) static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; - int r; + int r = -EBUSY; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); if (!minor) @@ -127,7 +132,8 @@ 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, &minor->index, NULL, DRM_LEGACY_MINOR_LIMIT(type), GFP_KERNEL); + if (!skip_legacy_minors) + 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)