From patchwork Sat May 30 15:30:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6513231 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C50FF9F1CC for ; Sat, 30 May 2015 15:27:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B21CE2085D for ; Sat, 30 May 2015 15:27:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 49BA12085C for ; Sat, 30 May 2015 15:27:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0514F6E467; Sat, 30 May 2015 08:27:02 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 822D96E467 for ; Sat, 30 May 2015 08:27:00 -0700 (PDT) Received: by wgez8 with SMTP id z8so83474263wge.0 for ; Sat, 30 May 2015 08:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=geETdsDkOQpa9GCCS1LLkgerPq0YldfDVQ4aM0DC9rk=; b=bDAV84REhfGl+8iMDJYuAz+kMLKpBMjB9HZczo1QSDVlxrm4excfignORvEvuJ7lBb 9VZWkUJZOBOF7jFgstwfxD8ferYxg0kRomZZ7aGWKw9JTV5ZJnvZXVnl4Sv8HsoyICf9 dh4/S1kjoUiZfWJ2uibMoVWl/oTWRYXDtosnAZ0eFr+RAeHw6aAxbzlrS7qUp8TJph33 PiRoV+8WJd3+HkYVluTmQLM7zuaNG8YS38MoDhwoH0lXasGqbr8zMjrTkB/P9fAYfp3q BaBjR1BoNqJb8LBlinCodsuWjSlQYGXozrhsm69NoRG0Z41HTsWQGZJk7UBRUVCVpbJs 7lvg== X-Received: by 10.180.106.137 with SMTP id gu9mr5675678wib.54.1432999619518; Sat, 30 May 2015 08:26:59 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by mx.google.com with ESMTPSA id n3sm8597288wix.1.2015.05.30.08.26.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 May 2015 08:26:58 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] Revert "Add device enumeration interface (v4)" Date: Sat, 30 May 2015 16:30:54 +0100 Message-Id: <1432999854-6333-1-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.3.5 MIME-Version: 1.0 Cc: Alex Deucher , Frank Min , emil.l.velikov@gmail.com, =?UTF-8?q?Christian=20K=C3=B6nig?= 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit fde4969176822fe54197b6baa78f8b0ef900baba. The commit adds an API that does not seem flexible enough to be used in current open-source projects. Additionally it adds a hidden dependency of libudev, which when used in mesa caused grief when combined with Steam('s runtime). Let's revert this for now and add a tweaked API later on that can be used in mesa/xserver. Cc: Frank Min Cc: Christian König Cc: Alex Deucher Cc: Jammy Zhou --- Makefile.am | 7 ++--- xf86drm.c | 100 ------------------------------------------------------------ xf86drm.h | 19 ------------ 3 files changed, 2 insertions(+), 124 deletions(-) diff --git a/Makefile.am b/Makefile.am index ffd334a..13df80c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,15 +95,12 @@ SUBDIRS = \ libdrm_la_LTLIBRARIES = libdrm.la libdrm_ladir = $(libdir) libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined -libdrm_la_LIBADD = \ - @CLOCK_LIB@ \ - @LIBUDEV_LIBS@ +libdrm_la_LIBADD = @CLOCK_LIB@ libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm AM_CFLAGS = \ $(WARN_CFLAGS) \ - $(VALGRIND_CFLAGS) \ - $(LIBUDEV_CFLAGS) + $(VALGRIND_CFLAGS) libdrm_la_SOURCES = $(LIBDRM_FILES) diff --git a/xf86drm.c b/xf86drm.c index 49da9c7..2c17d11 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -63,7 +63,6 @@ #include "xf86drm.h" #include "libdrm_macros.h" -#include "libudev.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #define DRM_MAJOR 145 @@ -2816,102 +2815,3 @@ char *drmGetRenderDeviceNameFromFd(int fd) { return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); } - -/** -* Enumerate the GPU devices on the system -* -* \param devs device array set to return the device information -* (if NULL, the number of device is returned) -* \param vendor the vendor ID for GPU devices to list -* (optional, if not specified, all GPU devices are returned) -* -* \return the number of GPU devices -*/ -int drmGetPciDevices(drmPciDevicePtr devSet, uint16_t vendorId) -{ - struct udev *udev = NULL; - struct udev_enumerate *udev_enumerate; - struct udev_list_entry *list_entry; - struct udev_device *device; - int drmDevCount = 0; - int vendor = 0; - int devid = 0; - int subvendor = 0; - int subdevid = 0; - int revid = 0xff; - int domain = 0; - int bus = 0; - int dev = 0; - int func = 0; - char config[64] = {0}; - char node[128] = {'\0'}; - char slot[] = "0000:00:00.0"; - const char *info = NULL; - int fd = 0; - int ret = 0; - - udev = udev_new(); - if (udev == NULL) { - fprintf(stderr, "no context\n"); - return -EINVAL; - } - udev_enumerate = udev_enumerate_new(udev); - if (udev_enumerate == NULL) - return -EINVAL; - udev_enumerate_add_match_subsystem(udev_enumerate, "drm"); - udev_enumerate_add_match_property(udev_enumerate, "DEVTYPE", "drm_minor"); - - udev_enumerate_scan_devices(udev_enumerate); - - udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) { - device = udev_device_new_from_syspath(udev_enumerate_get_udev(udev_enumerate), - udev_list_entry_get_name(list_entry)); - if (device != NULL) { - info = udev_device_get_property_value(device, "MINOR"); - if (!strcmp(info, "0")) { - strcpy(node, udev_device_get_syspath(device)); - info = strstr(node, "/drm"); - strncpy(slot, info - strlen(slot), strlen(slot)); - if (sscanf(slot, "%4x:%2x:%2x.%1x", &domain, &bus, &dev, &func) != 4) { - domain = 0; - bus = 0; - dev = 0; - func = 0; - } - strcpy(node + strlen(node), "/device/config"); - - fd = open(node, O_RDONLY); - if (fd >= 0) { - ret = read(fd, config, 64); - if (ret == 64) { - vendor = config[0] + (config[1] << 8); - devid = config[2] + (config[3] << 8); - revid = config[8]; - subdevid = config[44] + (config[45] << 8); - } - close(fd); - } - - if((vendorId == 0) || (vendorId == vendor)) { - if(devSet != NULL) { - devSet[drmDevCount].domain = domain; - devSet[drmDevCount].bus = bus; - devSet[drmDevCount].dev = dev; - devSet[drmDevCount].func = func; - devSet[drmDevCount].vendor_id = vendor; - devSet[drmDevCount].device_id = devid; - devSet[drmDevCount].subdevice_id = subdevid; - devSet[drmDevCount].subvendor_id = subvendor; - devSet[drmDevCount].revision_id = revid; - } - drmDevCount++; - } - } - } - udev_device_unref(device); - } - udev_enumerate_unref(udev_enumerate); - udev_unref(udev); - - return drmDevCount; -} diff --git a/xf86drm.h b/xf86drm.h index 2610934..40c55c9 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -342,24 +342,6 @@ typedef struct _drmSetVersion { int drm_dd_minor; } drmSetVersion, *drmSetVersionPtr; -/** - * Structure to a general pci gpu device - * - * \sa drmGetDevices() - * -*/ -typedef struct _drmPciDevice { - uint16_t domain; - uint8_t bus; - uint8_t dev; - uint8_t func; - uint16_t vendor_id; - uint16_t device_id; - uint16_t subvendor_id; - uint16_t subdevice_id; - uint8_t revision_id; -} drmPciDevice, *drmPciDevicePtr; - #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock) #define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */ @@ -570,7 +552,6 @@ do { register unsigned int __old __asm("o0"); \ /* General user-level programmer's API: unprivileged */ extern int drmAvailable(void); extern int drmOpen(const char *name, const char *busid); -extern int drmGetPciDevices(drmPciDevicePtr devSet, uint16_t vendorId); #define DRM_NODE_PRIMARY 0 #define DRM_NODE_CONTROL 1