From patchwork Tue Oct 23 16:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10653431 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 DB17913A9 for ; Tue, 23 Oct 2018 16:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8FF42A022 for ; Tue, 23 Oct 2018 16:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA6522A093; Tue, 23 Oct 2018 16:36:56 +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 3CA002A022 for ; Tue, 23 Oct 2018 16:36:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5602F6E1E1; Tue, 23 Oct 2018 16:36:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id C258C6E1E1 for ; Tue, 23 Oct 2018 16:36:53 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id r10-v6so1544881wrv.6 for ; Tue, 23 Oct 2018 09:36:53 -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:mime-version :content-transfer-encoding; bh=NS2RuACUdH0+aqxyXDrXj5nzkviHFSP97IM4/E0Mq+4=; b=m5WN1jGBwcB/t3j2AAz1T8plJL2svTpASmpfkZ/zo/M0CUR/QktOgFR+h5PFLh5Ywl JZnE0mm4dYYdNIzSRpxtVaHwX4SDx065rw6s8gTfpqO79XCKI8BUFhSPMLGvw4Wx/c8P 5DufKMp8IWP3BdwsDLZ9HmNFbbrWHUb8nGvumHJpUgCShaT83H/k5xe2JrqaX1r1H1tI u4i8QfrMIuaEEYlfhj8dbsCiDpOkVVL+nLzIWapYUY1mIzdx4VCW/n4hDiC+ujk6V9+l fmz1I3w7x+IPdd7PMCJiPiXbSxYAPWxtpa1ZRyRyx2RMWLGtlsvLoi4SW9Qt/HDMPFqy oo6Q== X-Gm-Message-State: ABuFfoh0sj6cdBk5f3OQKwUTEffhAMWUkg8lnenjbj5A5CfZsefA/nvF CK7OxXb39u4HShmG9/yB4fv4zj9c X-Google-Smtp-Source: ACcGV62M4eM3lr/+PQgjWASyD03qOq7gCAC1cMsDag9WL6ZiJBmgRpiMyvtui5p/ICsPK7ZB8rxOhg== X-Received: by 2002:a5d:628c:: with SMTP id k12-v6mr48724622wru.83.1540312612173; Tue, 23 Oct 2018 09:36:52 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 09:36:50 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/vgem: Fix vgem_init to get drm device available. Date: Tue, 23 Oct 2018 17:35:48 +0100 Message-Id: <20181023163550.15211-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.19.1 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Deepak Sharma Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook. v2: rebase, address checkpatch typo and line over 80 characters Cc: Daniel Vetter Signed-off-by: Deepak Sharma Reviewed-by: Sean Paul Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/vgem/vgem_drv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index ec6af8b920da..f1f7ab9dcdbf 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -471,31 +471,31 @@ static int __init vgem_init(void) if (!vgem_device) return -ENOMEM; - ret = drm_dev_init(&vgem_device->drm, &vgem_driver, NULL); - if (ret) - goto out_free; - vgem_device->platform = platform_device_register_simple("vgem", -1, NULL, 0); if (IS_ERR(vgem_device->platform)) { ret = PTR_ERR(vgem_device->platform); - goto out_fini; + goto out_free; } dma_coerce_mask_and_coherent(&vgem_device->platform->dev, DMA_BIT_MASK(64)); + ret = drm_dev_init(&vgem_device->drm, &vgem_driver, + &vgem_device->platform->dev); + if (ret) + goto out_unregister; /* Final step: expose the device/driver to userspace */ ret = drm_dev_register(&vgem_device->drm, 0); if (ret) - goto out_unregister; + goto out_fini; return 0; -out_unregister: - platform_device_unregister(vgem_device->platform); out_fini: drm_dev_fini(&vgem_device->drm); +out_unregister: + platform_device_unregister(vgem_device->platform); out_free: kfree(vgem_device); return ret; From patchwork Tue Oct 23 16:35:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10653433 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 7BFF013A9 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D9D72A022 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 618682A093; Tue, 23 Oct 2018 16:37:01 +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 1D4642A022 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 229D76E1F2; Tue, 23 Oct 2018 16:37:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 597826E1F2 for ; Tue, 23 Oct 2018 16:36:55 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id b203-v6so2517870wme.5 for ; Tue, 23 Oct 2018 09:36:55 -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=0Pmb/LbDWqIGQ5zF9ufu7GVmTP04nHxYPaOgCFK6DLI=; b=CTKvVk89APVWl1+IpHAc3zBKnqbFmVif1aPKa67zVQNXd2NiaZiabqgG892GFeAAdv ZZN+KRy8TyHU+XeP6/VTcirBdrQo6MGQeewyMh0GwnaacTZrpM77HYH/ekJTDSwumMgx Beplb1xHe9HqhOWuWMMYaFPBOGEUp7WGAmcY/wCi0i6o0m0CIcSba3sj6kvlxiqLxra+ 0Tree/uGpO52Hw5/csppFdBzwJj1Q0ApZxrjSfkx/t4uIDitYHs9RN6RlfzOcWiW/0Tt E206nzoEUHf03gHRPkQz0mzX26D+y+5TFaT1fxo+BiYU2FtkOpApKktwak4pPs+iHGI3 vYgw== X-Gm-Message-State: ABuFfogbyAkVNb7vN2Jw0c7ThZYyjDSiVRmh5Aq4Ng+kCbacQxj17EaN K6MEND5URj0xFcnVGWKNlKAohMEw X-Google-Smtp-Source: AJdET5fWL0C/ps5qej+LqctoOhKcyWy+WfP7LGVRUaUe3X1tpoz6d4pguQGGoJGK/pktHRSZCXAsag== X-Received: by 2002:a1c:9901:: with SMTP id b1-v6mr20335485wme.15.1540312613753; Tue, 23 Oct 2018 09:36:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 09:36:52 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm: BUG_ON if passing NULL parent to drm_dev_init Date: Tue, 23 Oct 2018 17:35:49 +0100 Message-Id: <20181023163550.15211-2-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: Deepak Sharma , Daniel Vetter , emil.l.velikov@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Previous commit removed the only reason why we were allowing NULL as a parent device. With that resolved, we can enforce nobody else does that mistake. With that we can drop the ugly drm_dev_set_unique workaround. v2: rebase, silence checkpatch "== NULL" warning Cc: Daniel Vetter Cc: Deepak Sharma Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 36e8e9cbec52..aa1cef794f9a 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -476,8 +476,6 @@ static void drm_fs_inode_free(struct inode *inode) * The initial ref-count of the object is 1. Use drm_dev_get() and * drm_dev_put() to take and drop further ref-counts. * - * Note that for purely virtual devices @parent can be NULL. - * * Drivers that do not want to allocate their own device struct * embedding &struct drm_device can call drm_dev_alloc() instead. For drivers * that do embed &struct drm_device it must be placed first in the overall @@ -502,6 +500,8 @@ int drm_dev_init(struct drm_device *dev, return -ENODEV; } + BUG_ON(!parent); + kref_init(&dev->ref); dev->dev = parent; dev->driver = driver; @@ -556,9 +556,7 @@ int drm_dev_init(struct drm_device *dev, } } - /* Use the parent device name as DRM device unique identifier, but fall - * back to the driver name for virtual devices like vgem. */ - ret = drm_dev_set_unique(dev, parent ? dev_name(parent) : driver->name); + ret = drm_dev_set_unique(dev, dev_name(parent)); if (ret) goto err_setunique; 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)