From patchwork Tue Oct 23 16:35:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10653435 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 A094713A9 for ; Tue, 23 Oct 2018 16:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9208D2A022 for ; Tue, 23 Oct 2018 16:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 866692A093; Tue, 23 Oct 2018 16:37:04 +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 377E32A022 for ; Tue, 23 Oct 2018 16:37:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A21516E1F5; Tue, 23 Oct 2018 16:37:02 +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 120986E1F2 for ; Tue, 23 Oct 2018 16:36:57 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id w5-v6so2455520wrt.2 for ; Tue, 23 Oct 2018 09:36:56 -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=wpMoi/vRdK64ev0PuEnrCHbnffyl/o2qSLYqqcLwGig=; b=kczck3DAkkz55tqEr+0CzNstH4iqg+KBa8LXD39gdLG2R4sUmDSyxFjXjsrkSMiLvf BXOwCY1E1xI9/ChHZ/Bwde4hAOTTrhmsiP+3ZD38AtffhhMrf2ymyZidrGPFB/icNsas ZfX9QViViDz28GcZKGuTvpjT2LHhcNPYO294M8QpTB2+GLSMMWnbX6xsoulao45FVZjy Ri3wGQJ9eB4D/jxsVua+HDCz7T0Hz+Fr0ArKbQtPGqb9sWjLrpuwqjOToAbP915lPvs4 HKZLXJlZW0rkYC3klR8d40ZJhO26jCw7sLVf1Yd2KfxbGgcMRgxU2OGmHf4oNPLv+GMH QSjg== X-Gm-Message-State: AGRZ1gJPkM1I9wmQzOw+ztvWtAjkrv8LwoP7Jeb3WwG4n39dESr1ScfL wbz+LYUOc3NFpr/wShV9nwGZZajA X-Google-Smtp-Source: AJdET5di1tJZboKrH2PdtbrASN4iLjV//H68gYffP+t2iTNfKxcDGh9F6g/rdLOKB785yRmGoXfgTg== X-Received: by 2002:adf:f581:: with SMTP id f1-v6mr8277598wro.297.1540312615465; Tue, 23 Oct 2018 09:36:55 -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 q77-v6sm3246732wmd.33.2018.10.23.09.36.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 09:36:54 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/virtio: document drm_dev_set_unique workaround Date: Tue, 23 Oct 2018 17:35:50 +0100 Message-Id: <20181023163550.15211-3-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023163550.15211-1-emil.l.velikov@gmail.com> References: <20181023163550.15211-1-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 any 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. Cc: Daniel Vetter Cc: Gerd Hoffmann Cc: Hans de Goede Cc: Laszlo Ersek Signed-off-by: Emil Velikov Reviewed-by: Laszlo Ersek --- 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..54f12b862231 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 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 will 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)