lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <13f77cd8-ed57-3593-ab21-dafce91ee85e@collabora.com>
Date:   Wed, 16 Mar 2022 16:52:12 +0300
From:   Dmitry Osipenko <dmitry.osipenko@...labora.com>
To:     Robin Murphy <robin.murphy@....com>,
        David Airlie <airlied@...ux.ie>,
        Gerd Hoffmann <kraxel@...hat.com>,
        Gurchetan Singh <gurchetansingh@...omium.org>,
        Chia-I Wu <olvaffe@...il.com>, Daniel Vetter <daniel@...ll.ch>,
        Daniel Almeida <daniel.almeida@...labora.com>,
        Gert Wollny <gert.wollny@...labora.com>,
        Tomeu Vizoso <tomeu.vizoso@...labora.com>,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Rob Herring <robh@...nel.org>,
        Steven Price <steven.price@....com>,
        Alyssa Rosenzweig <alyssa.rosenzweig@...labora.com>
Cc:     linux-kernel@...r.kernel.org,
        virtualization@...ts.linux-foundation.org,
        Gustavo Padovan <gustavo.padovan@...labora.com>,
        dri-devel@...ts.freedesktop.org, Dmitry Osipenko <digetx@...il.com>
Subject: Re: [PATCH v2 4/8] drm/virtio: Improve DMA API usage for shmem BOs


On 3/16/22 15:41, Robin Murphy wrote:
> On 2022-03-14 22: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 <dmitry.osipenko@...labora.com>
>> ---
>>   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)
>>   {
>> -    struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
>> +    struct pci_dev *pdev = to_pci_dev(dev->dev);
>>       const char *pname = dev_name(&pdev->dev);
>>       bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
>>       char unique[20];
>> @@ -101,6 +101,7 @@ static int virtio_gpu_pci_quirk(struct drm_device
>> *dev, struct virtio_device *vd
>>   static int virtio_gpu_probe(struct virtio_device *vdev)
>>   {
>>       struct drm_device *dev;
>> +    struct device *dma_dev;
>>       int ret;
>>         if (drm_firmware_drivers_only() && virtio_gpu_modeset == -1)
>> @@ -109,18 +110,29 @@ static int virtio_gpu_probe(struct virtio_device
>> *vdev)
>>       if (virtio_gpu_modeset == 0)
>>           return -EINVAL;
>>   -    dev = drm_dev_alloc(&driver, &vdev->dev);
>> +    /*
>> +     * If GPU's parent is a PCI device, then we will use this PCI device
>> +     * for the DRM's driver device because GPU won't have PCI's IOMMU
>> DMA
>> +     * ops in this case since GPU device is sitting on a separate
>> (from PCI)
>> +     * virtio-bus.
>> +     */
>> +    if (!strcmp(vdev->dev.parent->bus->name, "pci"))
> 
> Nit: dev_is_pci() ?

Yes, thank you.

> However, what about other VirtIO transports? Wouldn't virtio-mmio with
> F_ACCESS_PLATFORM be in a similar situation?

I couldn't find anyone using virtio-mmio for the GPU, both Qemu and
crosvm support only PCI transport for GPU.

But I'm now looking at virtio_mmio_probe() and see that virtio-mmio
devices actually should be in the exactly same position as PCI devices.
So you should be right and we need to use vdev->dev.parent for the DRM
device universally. I'll improve it in the v3, thank you again.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ