From patchwork Tue Oct 1 02:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1991303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XHj7D4nghz1xtg for ; Tue, 1 Oct 2024 12:48:40 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1svSwC-0004qi-Hm; Tue, 01 Oct 2024 02:48:32 +0000 Received: from mail-pl1-f173.google.com ([209.85.214.173]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1svSwA-0004oJ-Ck for kernel-team@lists.ubuntu.com; Tue, 01 Oct 2024 02:48:30 +0000 Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20b84bfbdfcso11051925ad.0 for ; Mon, 30 Sep 2024 19:48:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727750908; x=1728355708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CsjBQrLM2bu1QWLzrzKW41XSnjnxDcRUEHz2rcwFPzg=; b=HtQcr/dgNs4GdUvySAloBdJ+BlPnfJv3dRHKkUe/OwJDH+vVnhUqcLRsHdy2uUiAsv SRyVp7r2BC8c0ZdNAJSq1l5BU10GFZlKbYOFXcZrSdLX42l8VSZog7WPpw+RxsKAK9q7 R21qP+ku85RmqKkaNWqgNXCstqCKm72107fU3yR+s7BLXc8Y+w65Llj5/GwcmfM4aOXG OsRH7RNkFpC/W1Gj06oRbQGweEMe/NIB4aM7WAjymhODeDe3BThENt0Xb6gV+FuOK0Ls CrpER8FT3/WJSGbL2FwK8ybfmrC1f7H2eE1/T4CN+C+HIprylSk0aSVWcpSQHwCAIMsV Mtmg== X-Gm-Message-State: AOJu0YzZ8Q9geX857kfOpPh4mGbmxF6kmPTVt+tuGbTpvrDvcBma8egC reozSHn8PTb1c3L/RUBBPQYxs25mTZeFoBoAs3Z0xuXY0lDNJ3Z6ZKIg0A== X-Google-Smtp-Source: AGHT+IFqSYySJLezABc2W0CUMDddfHB9GB2h+EnbW8PeOmoQa4w7SCYUMXDL+cDdfsYPbk1g8PWUyA== X-Received: by 2002:a17:902:f688:b0:206:892c:b758 with SMTP id d9443c01a7336-20ba9ed2162mr26833835ad.13.1727750907778; Mon, 30 Sep 2024 19:48:27 -0700 (PDT) Received: from yewun.. (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2c668asm7277802a12.45.2024.09.30.19.48.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 19:48:27 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/3][SRU][Unstable][Oracular] drm: Expand max DRM device number to full MINORBITS Date: Tue, 1 Oct 2024 10:48:16 +0800 Message-ID: <20241001024816.111283-4-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001024816.111283-1-vicamo.yang@canonical.com> References: <20241001024816.111283-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.173; envelope-from=vicamo@gmail.com; helo=mail-pl1-f173.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Michał Winiarski BugLink: https://bugs.launchpad.net/bugs/2078773 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 Link: https://patchwork.freedesktop.org/patch/msgid/20240823163048.2676257-4-michal.winiarski@intel.com Acked-by: James Zhu Acked-by: Christian König Signed-off-by: Christian König (cherry picked from commit 071d583e01c88272f6ff216d4f867f8f35e94d7d) Signed-off-by: You-Sheng Yang --- 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 7e0fa5a2a3182..c734e6a1c4ce2 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;