Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3715257pxk; Mon, 7 Sep 2020 23:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhF/EBCjrXaBv7s7OlJSZ0Ipbn3PciEp3v3H2VCrbFeBK5xm4KVmw7KhmqW4fP/x5SkJ3h X-Received: by 2002:a50:9b5e:: with SMTP id a30mr25063744edj.49.1599547808338; Mon, 07 Sep 2020 23:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599547808; cv=none; d=google.com; s=arc-20160816; b=pKRPLqBaE12qsZ2aYVH0DNKF3muCFitMYDAgCPOCFdFH9U6Nvbz9hHSN5FCrDQzfqT GDy4FbNVJe+lUnJuDvzkRGLRjWHk9lo0tfb57w28lLL9fsMe3RMEfpRCIc9JNHdrDUzr jDDsfLc9icw6kEjMkTkY7AnvGQyopSoJTwG9W/8YYNiH7gL5UJ+tgViC6/3vaxv/ccSM LqKQYB1uTjFLtn9qj1kEEO9HJO7RUsOvw88zVWX+DHKAECjkm2nZ0RFm7eE50o1pnNVv OvS1g8/iOnkp6FVMZkxbt9qlmMrGZSaxEelXv4elqB+V4RQ79wCuIKpJ3/84WFBFvh5T Lsfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ckw515ta8REsEdxquaA8IU0vybCs7EFBcYj3MOI/Ego=; b=HZQeFQykeZ4bJIU2OILzQWW6DW0gV7g2kDfz6QaMl+bPqZAbIP31ZzwtvV9fV/Ea/i gDs2KyAOiPvYNGwr7RRQn6FgD1pehCdclqsKnVHPf3bIAj/Ib6p3gIv/HeDinBDVW9kM ULP0yhLOsU9zEPbOQqLqeiGxJbeOH60jDz/BekdH572Ibpp2HCwpN6D6U+Sw2j1+9pxa ws26s2OdPp+AfczcrnPnHw0QMA4BIOjtWeYAwWJr5SaXhw4S6ccjYd0vBwzerBdixKMC sSb0rW8eZ7cpRGIVsf3pbdfUTECVl/DfTdpKsfUBK1TOgyA2Frqz8wAFvq7Pepsb/hYW HZQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1NxVGll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si13085562edj.244.2020.09.07.23.49.46; Mon, 07 Sep 2020 23:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1NxVGll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729100AbgIHGsE (ORCPT + 99 others); Tue, 8 Sep 2020 02:48:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35233 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728998AbgIHGsC (ORCPT ); Tue, 8 Sep 2020 02:48:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599547677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Ckw515ta8REsEdxquaA8IU0vybCs7EFBcYj3MOI/Ego=; b=X1NxVGllFYDfOVGn6tLuon1i0uaGRN1BwKaWIP0xnNdCs1fqdZhIK6mrWGw7ay8vVs3lpE ZXy6ZnF3//QoQbFNUMXFHIsBAJi9WSqLoBhbPDxBt+78m3rxIuKAYXu0l5buxnQ2h6xh/M r2N9TmISvsbZGZgLfqxHlLkqeJuwJGU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-d1ZJMMipORavez-AKH4mzQ-1; Tue, 08 Sep 2020 02:47:53 -0400 X-MC-Unique: d1ZJMMipORavez-AKH4mzQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7355418BE160; Tue, 8 Sep 2020 06:47:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36B727BD8; Tue, 8 Sep 2020 06:47:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B0F2C9D78; Tue, 8 Sep 2020 08:47:47 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , David Airlie , Daniel Vetter , virtualization@lists.linux-foundation.org (open list:VIRTIO GPU DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/virtio: drop quirks handling Date: Tue, 8 Sep 2020 08:47:41 +0200 Message-Id: <20200908064741.1010-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These days dma ops can be overridden per device, and the virtio core 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 --- 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