From patchwork Wed Aug 17 23:05:59 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: 12953893 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 4F9BAC00140 for ; Wed, 24 Aug 2022 18:44:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A048C1266; Wed, 24 Aug 2022 18:44:21 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB619AF42A for ; Wed, 17 Aug 2022 23:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660777715; x=1692313715; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=4dBbHORUIDAzW27or2yZeAAFJcQv15mU0vub2lDevaw=; b=HMF6D4x38ZNBiQLe8ahKBrsb0GLEImsuTafE+Ci6F048Gp+F9BJZKWvP n8p9VFKRkcq1pLZ4SASdzoAIn5UvyN6PzZH0JYOqcyT7fJe1lfazA3JX3 5g4cr9VO8fEcm9cRWpbZxJ6P3YHIAw3RKQWrtcQApoPrLDF5/KkeD4IH+ nzvs27nPN/xX2vaS4u1HqiVR7YgsXirvO3src7MNH00w4Hs8VgbcM+bOy GL9SQMKrvrf+AD4pV3ewXKFDp3SAS+/mtASLsMdg+aJvUg5Q95vxeJJC/ c3JLElCDzt2GYku8hTWDro2liLthiHHirKm0bzbHMxo6Y0CRNd3AxvJzc w==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="293897387" X-IronPort-AV: E=Sophos;i="5.93,244,1654585200"; d="scan'208";a="293897387" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 16:08:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,244,1654585200"; d="scan'208";a="640640884" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga001.jf.intel.com with ESMTP; 17 Aug 2022 16:08:33 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 17 Aug 2022 16:08:33 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 17 Aug 2022 16:08:32 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.28 via Frontend Transport; Wed, 17 Aug 2022 16:08:32 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.109) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Wed, 17 Aug 2022 16:08:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nf2RzeTT8h0gSZW0Hf55cgpvcVnXC6lpgSSX0qE7qGHWK9EHK33RV893DcHrJSHMt77cZSgUGPf4TjJENc2VGdDLtBzNeSz/gTTVKdZj2JRxGTCje7x42PMpgzXz5cSj6plbsVYZrtufXWXV56Q+dLKE/LKJSl0y+CWHiL7NP2p92R6MF0jJp9x7JKVtq2GCQWWpZlXbgay/H9mhIWIIzmaOGIXv9yECsJL59eg0hoYLJbrIfcuJfqTixmHbsKQJWo8e+dW79JmFo4W1tUpT3HCBEAweFWSeGyNp0NeX1AkxuJPt/VN02rVMiqUD+wPUWRWAOfNp9XeubmJm7kDkdw== 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=Mc6hN/s5TyNE+n2b4bOMB0W4fgtMdjMzfA9CwOwdNp8=; b=HwdrUQ3sYvFg7CQ5kIbq1CR26szVkp9fOQm21UDAKEWPQDZ+Zrw/IR4kJ6MPJJugFwuOh/BfOxE93Vt9BVsWXtcRj6MYq02k530bBp08pQU5oAb7OBHh4e6krAYwd0elqi6B+id95O8KVoRz+VLXGrKCkTFPC7FM4sS0QtBL+8qBIG8gdOHfCkYNOmzz4bCwtkd6OR/WeIEzB082lrL9Nk7AgpWi3FaWCIldTUKzocKvSyppTO8FfoNSgP3Xf7zz3nmDSoQcy3do7Zd9wkuDUJfg3Me9jlCbO75424G+oVVkVtA3az9Kas/6VbfYFTW0htuTNZMtzzp0JYX5L4tlGQ== 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 MN2PR11MB4190.namprd11.prod.outlook.com (2603:10b6:208:13e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Wed, 17 Aug 2022 23:08:31 +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.5525.010; Wed, 17 Aug 2022 23:08:31 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: Subject: [PATCH 2/3] drm: Expand max DRM device number to full MINORBITS Date: Thu, 18 Aug 2022 01:05:59 +0200 Message-ID: <20220817230600.272790-3-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817230600.272790-1-michal.winiarski@intel.com> References: <20220817230600.272790-1-michal.winiarski@intel.com> X-ClientProxiedBy: AS9PR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:20b:540::10) 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: 53b285fb-a841-472c-7393-08da80a566f7 X-MS-TrafficTypeDiagnostic: MN2PR11MB4190:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s3O7pnhrBc+gqTxODMufAAFEDKq3mh/L5CSZDybmxzxQbAEhVT91Im/dnbkxOCc0vgxFJtuLqYaH3XD+32U3xAMjN7uM+HOSGnsY54/HrK+w5ZYS/XbBZ5io3CScOa6hfxYZuFVVwvFjBfHc/YU0r9/kOGw6n6X7+PaBI+TSg8ncdUP75xt4fnCmDpfFTZa/UMMm6VBPJBoPN0jzOnisagoyLv2dpSQKAoX5YhHn3DkBtgUclCoNbMKZuj2SGRC/JNh+BVgLWuCn/eHjQqLgQt7YOUy54QmZYP2gXEd+euLM1WeWg33iVbNjHwuMlg3vM7ZPyRPjDx5PvWPtHh/SFYxQtxwD+tHZtU9yt1RT9DGA7brLuvGAsjoZ40pCsEyl/R76DyS/cwsAFil7b4oObiGOLTpCzkqqpN5JULL0H8CBk3/jwmo+h37g14nIHdzUd7t5Ozuf+F50or/kX3OPHhmTx3hdeqp8adEREHIwNuhYalLbI//Z3jybWBvG09pJnrBY7eiv8uC10gvZUUuV/bQC9EWN33mRQmf0l5AGL2SB063cXoyo+ONzHdpsbNVuK8iFoYNaaPQqMtQIOAVN/JoC2sOHCfqP8TOFq8NQjCWZOtP5Xiy4O+tko3KJLHQo1/hTrEqzK9sqp5AbH7kfa+givwr9isEVBtgC57vS0z+N0bsVsC2hLFFN4cR9qZfnYNtFwz24hTbpiBGfECFYpw== 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)(39860400002)(136003)(396003)(366004)(346002)(376002)(86362001)(82960400001)(38100700002)(316002)(54906003)(6916009)(2906002)(66476007)(66556008)(66946007)(4326008)(8676002)(8936002)(5660300002)(2616005)(1076003)(186003)(83380400001)(478600001)(6486002)(41300700001)(6666004)(6512007)(6506007)(26005)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0zTbRSdr4W+7oqAkPwGakMOZQoYd?= =?utf-8?q?Yd4fB+v4awXlIc7baL63vej2JwrmasUaPapUotX/rN9A2AQGfR/KTn7F01jL9GXoJ?= =?utf-8?q?6XPPHmSiHp4ZW17/iJbTE/CgQ1hN07yb1KHIIWHEfvyVp4RlcG/MYpBwx3TQ8ir/J?= =?utf-8?q?hq5cklpLAvyWYqfaBXLeq8+7IEyb4JDuxwv0JHZ0QVQkwXFoSmUHhlJ+RqyjaSFqg?= =?utf-8?q?c4LPSDGWVrD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WUMgLzRUnEPXNpKsrOBCJJ3AKbnzRdzwgb65rYfTJQGO2?= =?utf-8?q?cRS2MAoAekDHtX1MDoS5k6A/UfqqWk98TOHICfcE/Y+TrUVG+snNADISJSbgq2LNt?= =?utf-8?q?S0GJHJOikcNGcPHz6opWbpOm/j7Qr4XEIYMG/7Q22PRAi3wpnNcnPgjCPI0FFKOr2?= =?utf-8?q?8IWTBAfXcw6V/ruoKiBSSJI6w4F6x1WPiIo0l+PHtwno9HUQOdibkP5qQvNgwBtIA?= =?utf-8?q?UdhVuatN9jRWy1y99lN2LBVBtLj0XcmuAHEuMokD2jLjg4RI+KP/36itaUrFTtcBz?= =?utf-8?q?N7pi+XW/OvuJlb7C1bJiyd09qqXmAc2kMBrEq0bUvWhn0bb5V6ZwBJyj8OBlFm6J3?= =?utf-8?q?62+b0Dmyh3/myPWE3yO0fJwVfb3bKCgnoBr16sFpLPTiyefnwE4pw3Q+mk8+Xy6/S?= =?utf-8?q?/C3nkRaajHiXmQXQu5Hdxftt9xHsHQO1oA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 53b285fb-a841-472c-7393-08da80a566f7 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 23:08:31.2736 (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: GG9X3rTd2MFT0lnnfGtju9Dke8nVj0R1C49hwObzyxXmgFCxs0bHYQ82GPFJXgNynRHC2zfCmvPULuBvMB0Hh7XejecMbwgOqIo5GC4eRoQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4190 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , David Airlie , Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Even after getting rid of control nodes, we've only bumped max DRM device number from 64 to 128. That's 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 0-127 for primary, 128-255 for render. This numbering scheme is continued for minors > 256 (256-383 for primary, 384-511 for render, and so on). Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/drm_drv.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index d81783f43452..0dab1ef8a98d 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -113,7 +113,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) { struct drm_minor *minor; unsigned long flags; - int r; + int r, start, end; minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); if (!minor) @@ -122,15 +122,19 @@ 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, - 128 * type, - 128 * (type + 1), - GFP_NOWAIT); - spin_unlock_irqrestore(&drm_minor_lock, flags); - idr_preload_end(); + start = 128 * type; + end = 128 * (type + 1); + + do { + idr_preload(GFP_KERNEL); + spin_lock_irqsave(&drm_minor_lock, flags); + r = idr_alloc(&drm_minors_idr, NULL, start, end, GFP_NOWAIT); + spin_unlock_irqrestore(&drm_minor_lock, flags); + idr_preload_end(); + + start += 256; + end += 256; + } while ((r == -ENOSPC) && end <= (1 << MINORBITS)); if (r < 0) return r;