From: Daniel Vetter <daniel@ffwll.ch>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
"open list:VIRTIO GPU DRIVER"
<virtualization@lists.linux-foundation.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/virtio: drop quirks handling
Date: Tue, 8 Sep 2020 10:57:21 +0200 [thread overview]
Message-ID: <20200908085721.GJ2352366@phenom.ffwll.local> (raw)
In-Reply-To: <20200908064741.1010-1-kraxel@redhat.com>
On Tue, Sep 08, 2020 at 08:47:41AM +0200, Gerd Hoffmann wrote:
> These days dma ops can be overridden per device, and the virtio core
"can be overridden" or "are"? The comment above vring_use_dma_api()
suggests that's not yet done. If that's wrong then I think updating the
comment would be really good.
-Daniel
> uses that to handle the dma quirks transparently for the rest of the
> kernel. So we can drop the virtio_has_dma_quirk() checks, just use
> the dma api unconditionally and depend on the virtio core having setup
> dma_ops as needed.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_object.c | 19 ++++++-------------
> drivers/gpu/drm/virtio/virtgpu_vq.c | 16 ++++++----------
> 2 files changed, 12 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
> index 729f98ad7c02..9c35ce64ff9e 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -141,7 +141,6 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
> struct virtio_gpu_mem_entry **ents,
> unsigned int *nents)
> {
> - bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
> struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
> struct scatterlist *sg;
> int si, ret;
> @@ -162,15 +161,11 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
> return -EINVAL;
> }
>
> - if (use_dma_api) {
> - shmem->mapped = dma_map_sg(vgdev->vdev->dev.parent,
> - shmem->pages->sgl,
> - shmem->pages->nents,
> - DMA_TO_DEVICE);
> - *nents = shmem->mapped;
> - } else {
> - *nents = shmem->pages->nents;
> - }
> + shmem->mapped = dma_map_sg(vgdev->vdev->dev.parent,
> + shmem->pages->sgl,
> + shmem->pages->nents,
> + DMA_TO_DEVICE);
> + *nents = shmem->mapped;
>
> *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> GFP_KERNEL);
> @@ -180,9 +175,7 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
> }
>
> for_each_sg(shmem->pages->sgl, sg, *nents, si) {
> - (*ents)[si].addr = cpu_to_le64(use_dma_api
> - ? sg_dma_address(sg)
> - : sg_phys(sg));
> + (*ents)[si].addr = cpu_to_le64(sg_dma_address(sg));
> (*ents)[si].length = cpu_to_le32(sg->length);
> (*ents)[si].padding = 0;
> }
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index c93c2db35aaf..1c1d2834547d 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -599,13 +599,11 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
> struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
> struct virtio_gpu_transfer_to_host_2d *cmd_p;
> struct virtio_gpu_vbuffer *vbuf;
> - bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
> struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
>
> - if (use_dma_api)
> - dma_sync_sg_for_device(vgdev->vdev->dev.parent,
> - shmem->pages->sgl, shmem->pages->nents,
> - DMA_TO_DEVICE);
> + dma_sync_sg_for_device(vgdev->vdev->dev.parent,
> + shmem->pages->sgl, shmem->pages->nents,
> + DMA_TO_DEVICE);
>
> cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
> memset(cmd_p, 0, sizeof(*cmd_p));
> @@ -1015,13 +1013,11 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
> struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
> struct virtio_gpu_transfer_host_3d *cmd_p;
> struct virtio_gpu_vbuffer *vbuf;
> - bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
> struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
>
> - if (use_dma_api)
> - dma_sync_sg_for_device(vgdev->vdev->dev.parent,
> - shmem->pages->sgl, shmem->pages->nents,
> - DMA_TO_DEVICE);
> + dma_sync_sg_for_device(vgdev->vdev->dev.parent,
> + shmem->pages->sgl, shmem->pages->nents,
> + DMA_TO_DEVICE);
>
> cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
> memset(cmd_p, 0, sizeof(*cmd_p));
> --
> 2.27.0
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2020-09-08 8:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 6:47 Gerd Hoffmann
2020-09-08 8:57 ` Daniel Vetter [this message]
2020-09-08 10:04 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200908085721.GJ2352366@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®