From patchwork Wed Oct 24 14:42:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10654743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B47C814BB for ; Wed, 24 Oct 2018 14:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A12D29F35 for ; Wed, 24 Oct 2018 14:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E5DD2AA5F; Wed, 24 Oct 2018 14:44:08 +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 1AF3D29F35 for ; Wed, 24 Oct 2018 14:44:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75ACB6E17C; Wed, 24 Oct 2018 14:44:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAB386E17C for ; Wed, 24 Oct 2018 14:44:03 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id n5-v6so2114982wrw.12 for ; Wed, 24 Oct 2018 07:44:03 -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:mime-version:content-transfer-encoding; bh=lsOiNeK825sCT6Z201kfvxEsqrZOAawi7yWr0gz85tg=; b=SU5b0bk5r6u4g25VFjQtvh3UGYooEBGNbuxtB7cp+3DOng82TGZuWPLH4/kxw89qa4 M7qJKB0Ho52TungJZABvIKkjtbJK9dc3tlztrDjObdIwGOWcL+rGTmsOY1YjHD6OVGC2 EzA4GT9VdhqwQImwH/7oGQmDGLjBQhyZdEzZ3qkQHj016fF8JzOoj3cVeQuVElYpUAEc ta64zsf0O++r+Fc4FX5TVfURNyqcDpsgou1TmG24K6GoLyuR8ORmFds7hwHtbJqrD8iF thQU8GLycfnCTyT/uC+jPSBkDLQM/bD+6tUYqGkMz1YJ48mwoVa3D2KXpZlYIRNwixkB zmng== X-Gm-Message-State: AGRZ1gKRdFi3xzBEH9gEMlNK9rp28oG73t59fLTHypUDBgKOyqYzOP2T W/9ZXYP+RiWP2xp0jwUZSJMB9s03 X-Google-Smtp-Source: AJdET5d+czLqnZtrtFnww50kAbRJ2vn2mIu4syld5/hMhR6mwtpehzGbNmizHFjFxOaVqmwJQtHeRg== X-Received: by 2002:adf:be08:: with SMTP id n8-v6mr11304wrh.267.1540392242140; Wed, 24 Oct 2018 07:44:02 -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 z13sm5146546wrw.15.2018.10.24.07.44.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 07:44:01 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/virtio: document drm_dev_set_unique workaround Date: Wed, 24 Oct 2018 15:42:52 +0100 Message-Id: <20181024144252.16518-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023163550.15211-3-emil.l.velikov@gmail.com> References: <20181023163550.15211-3-emil.l.velikov@gmail.com> MIME-Version: 1.0 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: Daniel Vetter , emil.l.velikov@gmail.com, Gerd Hoffmann , Laszlo Ersek , Hans de Goede Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov A while back we removed it, yet that lead to regressions. At some later point, I've attempted to remove it again without fully grasping the unique (pun intended) situation that virtio is in. Add a bulky comment to document why the call should stay as-is, for the next person who's around. As a Tl;Dr: virtio sits on top of struct virtio_device, which confuses dev_is_pci(), wrong info gets sent to userspace and X doesn't start. Driver needs to explicitly call drm_dev_set_unique() to keep it working. v2: Fix handful of typos (Laszlo) Cc: Daniel Vetter Cc: Gerd Hoffmann Cc: Hans de Goede Cc: Laszlo Ersek Signed-off-by: Emil Velikov Reviewed-by: Laszlo Ersek Reviewed-by: Gerd Hoffmann --- Thanks for the quick feedback and corrections Laszlo. They're spot-on and I've addressed them all here. Sending it out for posterity-sake. Modulo any objections I'll merge this via drm-misc. --- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index 757ca28ab93e..0887e0b64b9c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c +++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c @@ -53,6 +53,37 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) 0, "virtiodrmfb"); + /* + * Normally the drm_dev_set_unique() call is done by core DRM. + * The following comment covers, why virtio cannot rely on it. + * + * Unlike the other virtual GPU drivers, virtio abstracts the + * underlying bus type by using struct virtio_device. + * + * Hence the dev_is_pci() check, used in core DRM, will fail + * and the unique returned will be the virtio_device "virtio0", + * while a "pci:..." one is required. + * + * A few other ideas were considered: + * - Extend the dev_is_pci() check [in drm_set_busid] to + * consider virtio. + * Seems like a bigger hack than what we have already. + * + * - Point drm_device::dev to the parent of the virtio_device + * Semantic changes: + * * Using the wrong device for i2c, framebuffer_alloc and + * prime import. + * Visual changes: + * * Helpers such as DRM_DEV_ERROR, dev_info, drm_printer, + * will print the wrong information. + * + * We could address the latter issues, by introducing + * drm_device::bus_dev, ... which would be used solely for this. + * + * So for the moment keep things as-is, with a bulky comment + * for the next person who feels like removing this + * drm_dev_set_unique() quirk. + */ snprintf(unique, sizeof(unique), "pci:%s", pname); ret = drm_dev_set_unique(dev, unique); if (ret)