From patchwork Mon Dec 4 15:02:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 10090589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E8C060327 for ; Mon, 4 Dec 2017 15:02:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B37A288DF for ; Mon, 4 Dec 2017 15:02:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0010428B01; Mon, 4 Dec 2017 15:02:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BFA28288DF for ; Mon, 4 Dec 2017 15:02:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE5686E37A; Mon, 4 Dec 2017 15:02:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BAFE89FC5; Mon, 4 Dec 2017 15:02:47 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2017 07:02:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.45,359,1508828400"; d="scan'208"; a="1251705796" Received: from delly.ld.intel.com ([10.103.238.204]) by fmsmga002.fm.intel.com with ESMTP; 04 Dec 2017 07:02:46 -0800 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Subject: [PATCH v6 1/5] drm: add card symlink in render sysfs directory Date: Mon, 4 Dec 2017 15:02:34 +0000 Message-Id: <20171204150238.28011-2-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171204150238.28011-1-lionel.g.landwerlin@intel.com> References: <20171204150238.28011-1-lionel.g.landwerlin@intel.com> Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In i915 we would like to expose information about the GPU topology which would be useful mostly to applications making use of the device computational capability (not so much the display part). At the moment we already store information like frequency, etc... into the card directory (/sys/class/drm/card0). It seems natural to add the additional data there too. Unfortunately it's not obvious how to go from the render node back to the sysfs card directory. From the major/minor number it's possible to figure out what device associated with the render node. For example with this render node : $ ls -l /dev/dri/renderD128 crw-rw----+ 1 root video 226, 128 Oct 24 16:17 /dev/dri/renderD128 You can rebuild a part to access the associated drm device in : $ ls -l /sys/dev/char/226\:128/device/drm/ total 0 drwxr-xr-x 9 root root 0 Nov 27 16:52 card0 lrwxrwxrwx 1 root root 0 Nov 27 16:52 controlD64 -> card0 drwxr-xr-x 3 root root 0 Nov 27 16:50 renderD128 Right now, most devices have usually only one card. But in order to be future proof, we would like to associate the render node with the card so that you can get access to the card with the following path : /sys/dev/char/226\:128/card/ Signed-off-by: Lionel Landwerlin Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 9acc1e157813..a26c0e86778e 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -779,6 +779,14 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) if (drm_core_check_feature(dev, DRIVER_MODESET)) drm_modeset_register_all(dev); + if (drm_core_check_feature(dev, DRIVER_RENDER)) { + ret = sysfs_create_link(&dev->render->kdev->kobj, + &dev->primary->kdev->kobj, + "card"); + if (ret) + goto err_minors; + } + ret = 0; DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", @@ -835,6 +843,9 @@ void drm_dev_unregister(struct drm_device *dev) list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) drm_legacy_rmmap(dev, r_list->map); + if (drm_core_check_feature(dev, DRIVER_RENDER)) + sysfs_remove_link(&dev->render->kdev->kobj, "card"); + remove_compat_control_link(dev); drm_minor_unregister(dev, DRM_MINOR_PRIMARY); drm_minor_unregister(dev, DRM_MINOR_RENDER);