From patchwork Mon Jun 25 17:36:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10487091 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 444486038C for ; Mon, 25 Jun 2018 17:38:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23CCF27F54 for ; Mon, 25 Jun 2018 17:38:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1355E22362; Mon, 25 Jun 2018 17:38:49 +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=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham 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 BD9D222362 for ; Mon, 25 Jun 2018 17:38:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46751891FD; Mon, 25 Jun 2018 17:38:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 64ECC6E369 for ; Mon, 25 Jun 2018 17:38:34 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id w10-v6so14524029wrk.9 for ; Mon, 25 Jun 2018 10:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ML62dmXC/++FRzjRefwJYKGwkAI7I80HlPWbo+ICmGQ=; b=Jltad5jDueKsdsgfqRqH+rcM5Y5X1rIWszhOrodVTgETKnNbqx9WzujExQxCSq0xI6 h/pVT79xLl3zFNvDO2LCNt7FDoMtIDZWtKgszVLU/oz54+DDqWMzXhDtBiRwIYkeC74F 1r76+Gg6yAENbvv7pgU5tmgCXcSE9xZaJrpQgi/lkutzWx2b5RIA6qQBNSDyRr+DzxIy tr2W5Eal8/vW6Q1ny8nTRAyvnJjpKArPYmXIwITmlgyrotjezEDNn3dYp/WTwwPy/0T1 T59xmd9C2OJQIf4IsIi6TmEa+/IGntPqpfmZ92wa5wYv70m2AgjUAVd1ly3u1T0gYugX bmhw== X-Gm-Message-State: APt69E2lU9zejTaTVsE0hZ/ID+u8beoHkbsGBbNxFteNqwLLySSgCHws qLwPxRVhl+aC27LEcnvfFxJFSw== X-Google-Smtp-Source: AAOMgpfoCskRsEpzpVFVhTExuFhtI8ArQSpjlfnVLe6CbQ4+eniSgoxEO2UO0wmnupRA03NOatBFjw== X-Received: by 2002:adf:b86b:: with SMTP id u40-v6mr10891317wrf.162.1529948312909; Mon, 25 Jun 2018 10:38:32 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id p8-v6sm6581019wrq.70.2018.06.25.10.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 10:38:31 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 06/10] xf86drm: Add drmDevice support for virtio_gpu Date: Mon, 25 Jun 2018 18:36:22 +0100 Message-Id: <20180625173626.8046-6-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180625173626.8046-1-emil.l.velikov@gmail.com> References: <20180625173626.8046-1-emil.l.velikov@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emil.l.velikov@gmail.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov The GPU almost exclusively lives on the PCI bus, so we expose it as a normal PCI one. This allows any existing drmDevice users to work without any changes. One could wonder why a separate typeset is not introduced, alike say host1x. Unlike host1x the PCI/platform distinction for virtio provides no extra information. Plus needed we can add the separate set at a later stage. Here are a couple of 'features' that virtio seems to be missing: - provides extra information on top the plaform devices - supports a range of GPU devices - is considered hardware description (DT) Signed-off-by: Emil Velikov --- xf86drm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xf86drm.c b/xf86drm.c index 8ccd528f..b847ea26 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2954,6 +2954,9 @@ sysfs_uevent_get(const char *path, const char *fmt, ...) } #endif +/* Little white lie to avoid major rework of the existing code */ +#define DRM_BUS_VIRTIO 0x10 + static int drmParseSubsystemType(int maj, int min) { #ifdef __linux__ @@ -2983,6 +2986,9 @@ static int drmParseSubsystemType(int maj, int min) if (strncmp(name, "/host1x", 7) == 0) return DRM_BUS_HOST1X; + if (strncmp(name, "/virtio", 7) == 0) + return DRM_BUS_VIRTIO; + return -EINVAL; #elif defined(__OpenBSD__) return DRM_BUS_PCI; @@ -2996,7 +3002,7 @@ static char * get_real_pci_path(int maj, int min) { char path[PATH_MAX + 1]; - char *real_path = malloc(PATH_MAX); + char *term, *real_path = malloc(PATH_MAX); if (!real_path) return NULL; @@ -3007,6 +3013,10 @@ get_real_pci_path(int maj, int min) return NULL; } + term = strrchr(real_path, '/'); + if (term && strncmp(term, "/virtio", 7) == 0) + *term = 0; + return real_path; } @@ -3744,6 +3754,7 @@ 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: