Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5387C35240 for ; Thu, 30 Jan 2020 08:33:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C4C6B2082E for ; Thu, 30 Jan 2020 08:33:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4C6B2082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=opensynergy.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 768F56F90A; Thu, 30 Jan 2020 08:32:47 +0000 (UTC) X-Greylist: delayed 586 seconds by postgrey-1.36 at gabe; Wed, 29 Jan 2020 15:48:15 UTC Received: from plasma4.jpberlin.de (plasma4.jpberlin.de [80.241.57.33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A0696E3E7 for ; Wed, 29 Jan 2020 15:48:15 +0000 (UTC) Received: from spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) by plasma.jpberlin.de (Postfix) with ESMTP id D8CDABB9B6 for ; Wed, 29 Jan 2020 16:38:29 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from plasma.jpberlin.de ([80.241.56.68]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id oJ5qB9HlIKnF for ; Wed, 29 Jan 2020 16:38:25 +0100 (CET) Received: from webmail.opensynergy.com (unknown [217.66.60.5]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "webmail.opensynergy.com", Issuer "GeoTrust EV RSA CA 2018" (not verified)) (Authenticated sender: opensynergy@jpberlin.de) by plasma.jpberlin.de (Postfix) with ESMTPSA id B3266B960F for ; Wed, 29 Jan 2020 16:38:25 +0100 (CET) Received: from os-lin-mgo.open-synergy.com (10.25.255.1) by MXS01.open-synergy.com (10.25.10.17) with Microsoft SMTP Server (TLS) id 14.3.468.0; Wed, 29 Jan 2020 16:38:26 +0100 From: Mikhail Golubev To: Subject: [PATCH libdrm 2/2] xf86drm: fix subsystem type lookup for virtio mmio-based devices Date: Wed, 29 Jan 2020 16:38:10 +0100 Message-ID: <20200129153810.26876-2-Mikhail.Golubev@opensynergy.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200129153810.26876-1-Mikhail.Golubev@opensynergy.com> References: <20200129153810.26876-1-Mikhail.Golubev@opensynergy.com> MIME-Version: 1.0 X-Originating-IP: [10.25.255.1] X-Mailman-Approved-At: Thu, 30 Jan 2020 08:32:45 +0000 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: Vasyl Vavrychuk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Vasyl Vavrychuk Currently the code assumes that a virtio based device is always located on the PCI bus. Modify the parser to make it check the device's parent directory to determine on which bus it is located. Output for virtio-pci is the PCI bus. Output for virtio-mmio is the Platform bus. Signed-off-by: Vasyl Vavrychuk Signed-off-by: Mikhail Golubev --- xf86drm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index b1479128..1b22efe4 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3005,10 +3005,20 @@ static int drmParseSubsystemType(int maj, int min) { #ifdef __linux__ char path[PATH_MAX + 1] = ""; + char real_path[PATH_MAX + 1] = ""; + int subsystem_type; snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min); + if (!realpath(path, real_path)) + return -errno; + strncpy(path, real_path, PATH_MAX); - return get_subsystem_type(path); + subsystem_type = get_subsystem_type(path); + if (subsystem_type == DRM_BUS_VIRTIO) { + strncat(path, "/..", PATH_MAX); + subsystem_type = get_subsystem_type(path); + } + return subsystem_type; #elif defined(__OpenBSD__) || defined(__DragonFly__) return DRM_BUS_PCI; #else @@ -3710,7 +3720,6 @@ process_device(drmDevicePtr *device, const char *d_name, switch (subsystem_type) { case DRM_BUS_PCI: - case DRM_BUS_VIRTIO: return drmProcessPciDevice(device, node, node_type, maj, min, fetch_deviceinfo, flags); case DRM_BUS_USB: -- 2.23.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel