From patchwork Thu Jan 17 11:19:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 155820 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1839737jaa; Thu, 17 Jan 2019 03:21:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN4XBtR6BmTp8G5eJDQb2FrcQkkyIi8eYidt+GUVyWF/RLDaEbBL4WpUVZquSXPcB1k9zDDO X-Received: by 2002:a17:902:4:: with SMTP id 4mr14670857pla.20.1547724073798; Thu, 17 Jan 2019 03:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547724073; cv=none; d=google.com; s=arc-20160816; b=NhQXuRMTtPyCsD6L2CjutnmzudJ3YTri+Lv3BQOlv0kuVNiEGITm0GjCorzL3dOhml H5YyyDut7aDU8RLRCyJ49ZphD94LpiA7qhKShF++Dj8JwUbb9aoAkhdnxLhFVcBg8OvR D7xgllzVljyt5GR5R4uYDcmwPozqWeJGpsN8yCuPHipsTYLQBiFTHQQyopIaowzvMGmJ YfU+iSC4ReD89KVL5vfEP5QO+JIqNvgXK1UvvE7Eo0ed9BXld4iIfiEZxVhFZgzvd094 qyTN5hU1zQ2VHAwOJ/8dmZoFVunBb/FX0IsulzbGTWFWbVsX/MxPsAwF9AXWPFILfZqZ CpRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=+sXcrPjcyCHqWRfI7rht0LxQWoYLAHwptd1PWWoQ8ik=; b=ST2rBGNiTOAidEAP6QsyHjwCwDDAjg3KoeHJy+3KYLoexKHH0x+gDzXMRD9ny3AcEJ AqxDMan8Ooh0lvffi9As/A36n83WC0oNtJbXwuPK4X2BvhMM42q3NP4s4K5iX8H2MENY +HUPNDS2/0OM8s8qA7fHB1df1YRjhZOf7rJ3i8ks3TpkJWqvXYTOTNU1ZNqQVivjWF2R jLOfrS+gvU84qq8T9lsn8gfoZKf8lazfOLL+ofWPs/hFxlC3fDKoR2hJfe+Ewfx51p8p 73JTv+RDgK8W+vI/4Ujqzx6dKxtrdObeyZFagQPZJQGaqjBLAJopQrBek69zPU+FLLhw t3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NTfOZbb7; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si1428872pls.338.2019.01.17.03.21.13; Thu, 17 Jan 2019 03:21:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NTfOZbb7; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726066AbfAQLVN (ORCPT + 7 others); Thu, 17 Jan 2019 06:21:13 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:47910 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbfAQLVM (ORCPT ); Thu, 17 Jan 2019 06:21:12 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x0HBKkHY069494; Thu, 17 Jan 2019 05:20:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1547724046; bh=+sXcrPjcyCHqWRfI7rht0LxQWoYLAHwptd1PWWoQ8ik=; h=From:To:CC:Subject:Date; b=NTfOZbb7pUkWFChEBndSHSu5jJYZE2yDn+kTWtEkW8pCUy2aZjhxXpIW835sp3Age g7AHnVlBXHB9uwqfdsp/sZqWtYwjUCECl0cBB3AoOmt0AHRWjI1lgZap1JrUojKItF YF5VH1WZ+5jhgMnO0REWwnow/9ed5u4LPfcRByys= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x0HBKktA040464 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Jan 2019 05:20:46 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Thu, 17 Jan 2019 05:20:44 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Thu, 17 Jan 2019 05:20:44 -0600 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x0HBKgC0024893; Thu, 17 Jan 2019 05:20:42 -0600 From: Tomi Valkeinen To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , , Rob Herring , , Laurent Pinchart CC: Tomi Valkeinen Subject: [PATCH] drm: support gpu aliases defined in DT data Date: Thu, 17 Jan 2019 13:19:18 +0200 Message-ID: <20190117111918.31759-1-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The DRM device minor numbers are allocated according to the registration order. This causes confusion in cases where the registration order can change, or when, say, a modesetting capable device is preferred to be card0, and a rendering device is preferred to be card1. This patch adds similar functionality that is used in some other subsystems, where device minor numbers can be defined in DT bindings' aliases node. For example, this sets the DRM device minor number to 1 for the 'dss' device. aliases { gpu1 = &dss; }; The logic on how to pick the minor number is: - if there's a DT gpu alias for the device, use that - else, if there are any gpu aliases, pick a minor number that is higher than any of the aliases. - else, use the full range of possible numbers Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/drm_drv.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index a5fe91b8c3c9..f536a2760293 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -110,6 +110,8 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) struct drm_minor *minor; unsigned long flags; int r; + int min_id, max_id; + bool of_id_found = false; minor = kzalloc(sizeof(*minor), GFP_KERNEL); if (!minor) @@ -118,12 +120,37 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) minor->type = type; minor->dev = dev; + min_id = 64 * type; + max_id = 64 * (type + 1); + + if (dev->dev && dev->dev->of_node) { + int id; + + id = of_alias_get_id(dev->dev->of_node, "gpu"); + + if (id >= 0) { + min_id = 64 * type + id; + max_id = 64 * type + id + 1; + + of_id_found = true; + } + } + + if (!of_id_found) { + int id; + + id = of_alias_get_highest_id("gpu"); + + if (id >= 0) + min_id = id + 1; + } + idr_preload(GFP_KERNEL); spin_lock_irqsave(&drm_minor_lock, flags); r = idr_alloc(&drm_minors_idr, NULL, - 64 * type, - 64 * (type + 1), + min_id, + max_id, GFP_NOWAIT); spin_unlock_irqrestore(&drm_minor_lock, flags); idr_preload_end();