Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp907850pxp; Wed, 16 Mar 2022 20:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVDNjk7wxeH3jY2M8BCbUxXrZw3HBRkFLFP3vGa7YZr33HFenMRtApWycwSHS/rLd150y9 X-Received: by 2002:a17:902:8bc2:b0:149:1ce6:c28c with SMTP id r2-20020a1709028bc200b001491ce6c28cmr2797207plo.164.1647489299789; Wed, 16 Mar 2022 20:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647489299; cv=none; d=google.com; s=arc-20160816; b=qfb3kcg05uUPwSEFfAawx/KPxYNiej6O6XckXtUIsBnhWdbCBqy/5K03gND3hO3K7+ NjfBTgUDT7JwUhvG08M3SZqAnt1JAE+DQw1Cw9OE5VmOouUxsj6QAatAuz7Ik2JielVP HD+NxcaHWqGOHxHHoJkWbuiQr0lafPbz2f7ullMLImnZZDKLpaGgbb6Mo0Gh/X2GzBRz N9QBBco0KlxxcA1Q7iPQhTVNwxxku/TVUo2JuUozAMtc6tsEyGvCwmf5B/pUiDoPkhws AJ0ceABWhyh1pP1TKeJzW65jFIHnmh5k+0AmqaBV0/L3gemc0dVSwulCHpNroQmmzVxW nHRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=dD6lRWIxL7jvhgcQHNqVQsnX2Uuzmd/ZhjtFjdilgUE=; b=UKdvPdZvUnIt4DE7LF4To1w9gYOJ39pA4lsbCYmNhO/67ir3uoSYeNHEPPqmWt21k/ nrhjZSB4tx9NK49CV7lNZGE2Wlzfo5AqHh+5BUpl0VXSUk/oRvZ2zFkXgagG2U9prxAE xNNHR49YhJ+DxTp2GryxBCW5TDF6XrhZSChvq1NO3aOSFBGL3/OlCgIHRD9yfCIW9D2i HjbPM7qykM8qzToYRIhk4LoM2uh6zpYMVZa4skshU26vba8FR5JEr2k5CQGZsgrX5khU 7VAX5LXFmacuyyMv+GLtke3/Q+xRlpsQOIx8BvlozFKxjGbq1OYTqV9X8IlXDRwbiXOV I8kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FzGGcxvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t3-20020a056a00138300b004f79a9f25ffsi4012665pfg.121.2022.03.16.20.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FzGGcxvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 70ECC63501; Wed, 16 Mar 2022 20:41:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352540AbiCQBK0 (ORCPT + 99 others); Wed, 16 Mar 2022 21:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242548AbiCQBKY (ORCPT ); Wed, 16 Mar 2022 21:10:24 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 814B71D0FE for ; Wed, 16 Mar 2022 18:09:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id D9F171F448D6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647479348; bh=FxghuLF6sBTGTVTBe9x2sblWdZvZVCLqJRlt5cOFOLY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FzGGcxvitUUwRBDmQRUySL1ki5h49AEbAWoQeF8EBdVKTFmU/g8MT9DYqFvo90q3g ml8DhY6v+Gg/TCAwIuuvHpk3xT3zqoi8X657n7O0eGIUX2p+kPIlm5F0YwTKUNpS3o GDO9azTbZ2DRcrSBVnOVgWvWN6Y2EFFjsYIGW3rWfgRWLPv87Gp4LRSqnpzt8wj7dH 8G0dzuxanND32r7emgrJzMQEqrQfenK+DcT6DhcZdfWBQ8k2MIbEMOBSc/xlYDumGX +G9Kmxb1LtNs3c1hrbHa7mRJur+oijanmbUOe0bKlKwNTY1aWAuQx6jqx1qOk27hLS jI+FqxFZv1q0g== Message-ID: Date: Thu, 17 Mar 2022 04:09:03 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v2 4/8] drm/virtio: Improve DMA API usage for shmem BOs Content-Language: en-US To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gustavo Padovan , Daniel Stone , virtualization@lists.linux-foundation.org, Dmitry Osipenko References: <20220314224253.236359-1-dmitry.osipenko@collabora.com> <20220314224253.236359-5-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: <20220314224253.236359-5-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/15/22 01:42, Dmitry Osipenko wrote: > DRM API requires the DRM's driver to be backed with the device that can > be used for generic DMA operations. The VirtIO-GPU device can't perform > DMA operations if it uses PCI transport because PCI device driver creates > a virtual VirtIO-GPU device that isn't associated with the PCI. Use PCI's > GPU device for the DRM's device instead of the VirtIO-GPU device and drop > DMA-related hacks from the VirtIO-GPU driver. > > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/virtio/virtgpu_drv.c | 22 +++++++--- > drivers/gpu/drm/virtio/virtgpu_drv.h | 5 +-- > drivers/gpu/drm/virtio/virtgpu_kms.c | 7 ++-- > drivers/gpu/drm/virtio/virtgpu_object.c | 56 +++++-------------------- > drivers/gpu/drm/virtio/virtgpu_vq.c | 13 +++--- > 5 files changed, 37 insertions(+), 66 deletions(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c > index 5f25a8d15464..8449dad3e65c 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c > @@ -46,9 +46,9 @@ static int virtio_gpu_modeset = -1; > MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); > module_param_named(modeset, virtio_gpu_modeset, int, 0400); > > -static int virtio_gpu_pci_quirk(struct drm_device *dev, struct virtio_device *vdev) > +static int virtio_gpu_pci_quirk(struct drm_device *dev) Somehow I missed that virtio_gpu_pci_quirk() contains comment telling about why dev.parent isn't used for the DRM's device. /* * 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. */ There is no I2C, nor prime import support and framebuffer_alloc hasn't been used for years now. I guess prime import actually will want the real device and not the virtio_device if GEM importing will be ever supported by VirtIO-GPU driver. Apparently this comment was outdated a long time ago and the "visual changes" aren't too important, the messages now says "virtio-pci 0000:00:02.0" instead of "virtio_gpu virtio0". I'll remove the comment and drm_dev_set_unique() quirk in v3.