Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp365479ybl; Wed, 11 Dec 2019 00:44:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxsdBJ9YYcHYygNEXq9OBAZo6O+n49gCL2QoaKFA2d0cuJGsl2niZy41rAPbvENMUklTYvI X-Received: by 2002:a05:6808:b18:: with SMTP id s24mr1788263oij.31.1576053866861; Wed, 11 Dec 2019 00:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576053866; cv=none; d=google.com; s=arc-20160816; b=XXlzzFRsVOFi1gmPFcAOrJQGZGT62Po5LBDMoD+4gnNGwIAB0j7W8k17Rv3sqBZPWK jBspfXPRktrkVLJCsKgBxlU4Ew4GryFD+cnEsIgbNNBnhgUm+dplz1jKK5meAE3oFbVr IxTXlAKaRztblqBOfEbxkdYcNoVvCoGxxcbTy2Vypy7ZcNmS5I8xKYNBZUjLJDjcw3Nv /AhPpEcBjpNMA8r9I58xwSaZCkZkxPgmWrIny3h3vnYr5TIHPaM/1No7c0REVUvo88L5 ScVvPfVgr1xki3wpndZBrXI0XN9nWr5DNOiOWORhOLJyvK72L+cKU0yvJXMRlzCkXXKn LtXQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=KtoovQXBmt77VoBhVg39A0Jd/NXJUkCNUGS6KQcNFkc=; b=bL/HtWoEDNvaRX8tt9SwisUwugpSNSVx71OPq7uwJdkHYpgEenB5B5D0aIB2MUiXD8 M5d8nshDG69zvZ60vjMbWPAF/3kVTm6qZ1kEr9p7Nd4WGEtY4ec5beH4l7b6f3Ax/Xtg CryQioTkQ/JDIyuY91HzCpBejfTer2QSnIQn/e/dkcUmfKjXOnhvHsZYJWsRaVEOVfvt /a74OxxGH8dZv1mCVfJAiK67eFdTczkgE7tokV6wjJXXQOrn2MFrCmn1ooaQ3UC7u6pR X6C5C2G26UXjASTFP+zxQ+cXS+NZzXen/DQNu6a6rSER/S/clPzI+H2fOObEEPNDWWzf vq2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GFSYfH/e"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d62si781851oib.144.2019.12.11.00.44.15; Wed, 11 Dec 2019 00:44:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GFSYfH/e"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728434AbfLKIm1 (ORCPT + 99 others); Wed, 11 Dec 2019 03:42:27 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:38749 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727253AbfLKIm0 (ORCPT ); Wed, 11 Dec 2019 03:42:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576053745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KtoovQXBmt77VoBhVg39A0Jd/NXJUkCNUGS6KQcNFkc=; b=GFSYfH/esJg01S8a5WewPmnQh8H/uJvU+a0pF+ozyaWIzI/z9lbpFDZmZBkUjyHWXnuG5h 0d/52Os8AdLiRRBAi6UIdaIP/asGNVw/e0MMGYcgE3r2VtjUvZ91fSkazTNdbw8Iia4rW/ iNUwwXs98vL1JufKW1AKuGWNLyOrl+k= 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-51-2Jw60vDsMoSH9xfXdMSoEA-1; Wed, 11 Dec 2019 03:42:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94B3F800D5B; Wed, 11 Dec 2019 08:42:20 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75C0610013A1; Wed, 11 Dec 2019 08:42:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AAD5617536; Wed, 11 Dec 2019 09:42:16 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: gurchetansingh@chromium.org, 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 3/3] virtio-gpu: use damage info for display updates. Date: Wed, 11 Dec 2019 09:42:16 +0100 Message-Id: <20191211084216.25405-4-kraxel@redhat.com> In-Reply-To: <20191211084216.25405-1-kraxel@redhat.com> References: <20191211084216.25405-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 2Jw60vDsMoSH9xfXdMSoEA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_plane.c | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virti= o/virtgpu_plane.c index 2e0d14e005db..1a0fbbb91ec7 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -24,6 +24,7 @@ */ =20 #include +#include #include #include =20 @@ -103,22 +104,26 @@ static int virtio_gpu_plane_atomic_check(struct drm_p= lane *plane, } =20 static void virtio_gpu_update_dumb_bo(struct virtio_gpu_device *vgdev, -=09=09=09=09 struct virtio_gpu_object *bo, -=09=09=09=09 struct drm_plane_state *state) +=09=09=09=09 struct drm_plane_state *state, +=09=09=09=09 struct drm_rect *rect) { +=09struct virtio_gpu_object *bo =3D +=09=09gem_to_virtio_gpu_obj(state->fb->obj[0]); =09struct virtio_gpu_object_array *objs; +=09uint32_t w =3D rect->x2 - rect->x1; +=09uint32_t h =3D rect->y2 - rect->y1; +=09uint32_t x =3D rect->x1 + (state->src_x >> 16); +=09uint32_t y =3D rect->y1 + (state->src_y >> 16); +=09uint32_t off =3D x * state->fb->format->cpp[0] + +=09=09y * state->fb->pitches[0]; =20 =09objs =3D virtio_gpu_array_alloc(1); =09if (!objs) =09=09return; =09virtio_gpu_array_add_obj(objs, &bo->base.base); -=09virtio_gpu_cmd_transfer_to_host_2d -=09=09(vgdev, 0, -=09=09 state->src_w >> 16, -=09=09 state->src_h >> 16, -=09=09 state->src_x >> 16, -=09=09 state->src_y >> 16, -=09=09 objs, NULL); + +=09virtio_gpu_cmd_transfer_to_host_2d(vgdev, off, w, h, x, y, +=09=09=09=09=09 objs, NULL); } =20 static void virtio_gpu_primary_plane_update(struct drm_plane *plane, @@ -127,8 +132,8 @@ static void virtio_gpu_primary_plane_update(struct drm_= plane *plane, =09struct drm_device *dev =3D plane->dev; =09struct virtio_gpu_device *vgdev =3D dev->dev_private; =09struct virtio_gpu_output *output =3D NULL; -=09struct virtio_gpu_framebuffer *vgfb; =09struct virtio_gpu_object *bo; +=09struct drm_rect rect; =20 =09if (plane->state->crtc) =09=09output =3D drm_crtc_to_virtio_gpu_output(plane->state->crtc); @@ -146,12 +151,14 @@ static void virtio_gpu_primary_plane_update(struct dr= m_plane *plane, =09=09return; =09} =20 +=09if (!drm_atomic_helper_damage_merged(old_state, plane->state, &rect)) +=09=09return; + =09virtio_gpu_disable_notify(vgdev); =20 -=09vgfb =3D to_virtio_gpu_framebuffer(plane->state->fb); -=09bo =3D gem_to_virtio_gpu_obj(vgfb->base.obj[0]); +=09bo =3D gem_to_virtio_gpu_obj(plane->state->fb->obj[0]); =09if (bo->dumb) -=09=09virtio_gpu_update_dumb_bo(vgdev, bo, plane->state); +=09=09virtio_gpu_update_dumb_bo(vgdev, plane->state, &rect); =20 =09if (plane->state->fb !=3D old_state->fb) { =09=09DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n", @@ -171,10 +178,10 @@ static void virtio_gpu_primary_plane_update(struct dr= m_plane *plane, =09} =20 =09virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle, -=09=09=09=09 plane->state->src_x >> 16, -=09=09=09=09 plane->state->src_y >> 16, -=09=09=09=09 plane->state->src_w >> 16, -=09=09=09=09 plane->state->src_h >> 16); +=09=09=09=09 (plane->state->src_x >> 16) + rect.x1, +=09=09=09=09 (plane->state->src_y >> 16) + rect.y1, +=09=09=09=09 rect.x2 - rect.x1, +=09=09=09=09 rect.y2 - rect.y1); =20 =09virtio_gpu_enable_notify(vgdev); } --=20 2.18.1