Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4629151ybi; Tue, 11 Jun 2019 09:42:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhCDpxeFFBKhsVKxiO6niAGZyv/TXBovLm2N3xXHcMNBNKlc+UvcRKdWIuLpgBjDn0GRr7 X-Received: by 2002:a63:d07:: with SMTP id c7mr20674846pgl.394.1560271352495; Tue, 11 Jun 2019 09:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560271352; cv=none; d=google.com; s=arc-20160816; b=h+602TPTSUbq+h0M94E4sFYmEYhFdcIDlMGHxoiwJARaAGkctz7g2lVaVxgN8UHA3J j3QUHd3zqI2aotukc68J2nvmMY1yUwd4/FJYSUj9aesLvOuB9KOUiMQLFNxpKlmEp8Ie AEDQ9PlU98Py/H0oYxdmPnvjwLVfUM7Y3ppUucQ1PbjQxC/2lzkRxsvR6idgMxQORpx0 lArr5PDqKCre8/dB0P+86aM0mHAKnVBCIgAoWE4v+VLnD7vSK+IFg3nuwFskwNi2AO8k 1iRhepbs7t4aXE/lj1IXRZVITKIY1Od31SKbNOv3czxTSlghxq1qTsZefgoE3ryUiqwh vmTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=BkaQ44VYcLgrCEyARS/Ty4P5nJLX6sSZ9QJ2AuozWlU=; b=AcoavAYZduehd+VTI7fkEwcNVqglJE74gWXpPUVNd1XNTuppc8MDU3N4oMAUm9bsBp A1T+nS9juSqOdCrTcFfanTbomog7RWV0+taCgnYiR7rof0DtdpgZUn2QSnFgpOUKt/DG oCY8xUSk9lPxokkdH+F1a+sG0+sJ64YZ8b1NCoMZ4ydj5d9K5M/l8PUiFqGIRKexHm8y 21SUFIc4R1wMtb+7Cc0J7x/v1F1r2/0Q0Z92Brkui7hZCtjuMkexRd11yv0SWCZNRXz2 dwPpgGgF8AUhhwWh6aiAky420A/my55KJGcygDX7NacmVmy0I7gX765u1DodDBFy7a8K JgmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=HM5nMwM3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si13092794pgb.109.2019.06.11.09.42.17; Tue, 11 Jun 2019 09:42:32 -0700 (PDT) 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=fail header.i=@ffwll.ch header.s=google header.b=HM5nMwM3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391758AbfFKPmx (ORCPT + 99 others); Tue, 11 Jun 2019 11:42:53 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41949 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391456AbfFKPmx (ORCPT ); Tue, 11 Jun 2019 11:42:53 -0400 Received: by mail-ed1-f67.google.com with SMTP id p15so20755715eds.8 for ; Tue, 11 Jun 2019 08:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=BkaQ44VYcLgrCEyARS/Ty4P5nJLX6sSZ9QJ2AuozWlU=; b=HM5nMwM3r7lp//mDQTILtcS5qaJnpK6OEbvKzSbx6picx1r0+t+zYSoljicMjGivuL TUrK4HdCNUhn7Nqzdm+DRRDLznnkUdh90mcSkrxrADZes7DbcYnkpZqeEQvOiltv9mSE OxUCXyzydtaBmxpJWU2d+O/+rKvdWxzcsFZNc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=BkaQ44VYcLgrCEyARS/Ty4P5nJLX6sSZ9QJ2AuozWlU=; b=Wy0ajQ6Ac0eZcdVysSwrFHC6MytX9ncQFRntqUxRpKCOJLgxsWLJjrtS0UoTdWn28x qJdwzGIni2n4OZX2/ROgEtZUfntjcYMzpCy2aOAz4j91gEu8PRPd1J3A3iFY85+PLoYH FK+6OX4zb+OUVkTITOM1nVd4dV8d1l8MvSL+eKQ+CrUzfdbuMwWoUojG82jVUv5XWD75 nXPXEtyCdh/5yEcKqWRH7gCs86lr3uC7n707pyloB88MliWvln/1nPX8GDww4gfTO2mz lBb02BSaruF0wCLb6BMauNg0D9TIKUN0umTLl7e2bM7CsB+BmPc7Xi9gO6rS05Z5IP0V fhsg== X-Gm-Message-State: APjAAAWtfBQAed2QkO1dREhjf0ZvDnKu4duqS8TUJqi67bcHEtFWomLG Z8ZEcZVNqHNPVaqgCWZg1IYTUw== X-Received: by 2002:a17:907:2177:: with SMTP id rl23mr32215187ejb.14.1560267770529; Tue, 11 Jun 2019 08:42:50 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id m6sm3813267ede.2.2019.06.11.08.42.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 08:42:49 -0700 (PDT) Date: Tue, 11 Jun 2019 17:42:46 +0200 From: Daniel Vetter To: Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, David Airlie , Daniel Vetter , open list , "open list:VIRTIO GPU DRIVER" Subject: Re: [PATCH] drm/virtio: drop framebuffer dirty tracking code Message-ID: <20190611154246.GG2458@phenom.ffwll.local> Mail-Followup-To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, David Airlie , open list , "open list:VIRTIO GPU DRIVER" References: <20190611125408.29421-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611125408.29421-1-kraxel@redhat.com> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 02:54:07PM +0200, Gerd Hoffmann wrote: > No need to have our own implementation, > atomic helpers can do it for us. > > Signed-off-by: Gerd Hoffmann Nice! I think you got it all, most of the custom code already disappeared with the switch to generic fbdev code. Reviewed-by: Daniel Vetter > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 7 -- > drivers/gpu/drm/virtio/virtgpu_display.c | 20 +-- > drivers/gpu/drm/virtio/virtgpu_fb.c | 150 ----------------------- > drivers/gpu/drm/virtio/Makefile | 2 +- > 4 files changed, 3 insertions(+), 176 deletions(-) > delete mode 100644 drivers/gpu/drm/virtio/virtgpu_fb.c > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h > index 5faccf92aa15..9e2d3062b01d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.h > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h > @@ -142,9 +142,6 @@ struct virtio_gpu_output { > > struct virtio_gpu_framebuffer { > struct drm_framebuffer base; > - int x1, y1, x2, y2; /* dirty rect */ > - spinlock_t dirty_lock; > - uint32_t hw_res_handle; > struct virtio_gpu_fence *fence; > }; > #define to_virtio_gpu_framebuffer(x) \ > @@ -254,10 +251,6 @@ int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv, > struct drm_device *dev, > uint32_t handle, uint64_t *offset_p); > > -/* virtio_fb */ > -int virtio_gpu_surface_dirty(struct virtio_gpu_framebuffer *qfb, > - struct drm_clip_rect *clips, > - unsigned int num_clips); > /* virtio vg */ > int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev); > void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev); > diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c > index 86843a4d6102..ba16e8cb7124 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_display.c > +++ b/drivers/gpu/drm/virtio/virtgpu_display.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > > #define XRES_MIN 32 > #define YRES_MIN 32 > @@ -49,23 +50,10 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { > .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, > }; > > -static int > -virtio_gpu_framebuffer_surface_dirty(struct drm_framebuffer *fb, > - struct drm_file *file_priv, > - unsigned int flags, unsigned int color, > - struct drm_clip_rect *clips, > - unsigned int num_clips) > -{ > - struct virtio_gpu_framebuffer *virtio_gpu_fb > - = to_virtio_gpu_framebuffer(fb); > - > - return virtio_gpu_surface_dirty(virtio_gpu_fb, clips, num_clips); > -} > - > static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = { > .create_handle = drm_gem_fb_create_handle, > .destroy = drm_gem_fb_destroy, > - .dirty = virtio_gpu_framebuffer_surface_dirty, > + .dirty = drm_atomic_helper_dirtyfb, > }; > > int > @@ -85,10 +73,6 @@ virtio_gpu_framebuffer_init(struct drm_device *dev, > vgfb->base.obj[0] = NULL; > return ret; > } > - > - spin_lock_init(&vgfb->dirty_lock); > - vgfb->x1 = vgfb->y1 = INT_MAX; > - vgfb->x2 = vgfb->y2 = 0; > return 0; > } > > diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c > deleted file mode 100644 > index b07584b1c2bf..000000000000 > --- a/drivers/gpu/drm/virtio/virtgpu_fb.c > +++ /dev/null > @@ -1,150 +0,0 @@ > -/* > - * Copyright (C) 2015 Red Hat, Inc. > - * All Rights Reserved. > - * > - * Permission is hereby granted, free of charge, to any person obtaining > - * a copy of this software and associated documentation files (the > - * "Software"), to deal in the Software without restriction, including > - * without limitation the rights to use, copy, modify, merge, publish, > - * distribute, sublicense, and/or sell copies of the Software, and to > - * permit persons to whom the Software is furnished to do so, subject to > - * the following conditions: > - * > - * The above copyright notice and this permission notice (including the > - * next paragraph) shall be included in all copies or substantial > - * portions of the Software. > - * > - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. > - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE > - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION > - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION > - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > - */ > - > -#include > -#include > -#include "virtgpu_drv.h" > - > -static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb, > - bool store, int x, int y, > - int width, int height) > -{ > - struct drm_device *dev = fb->base.dev; > - struct virtio_gpu_device *vgdev = dev->dev_private; > - bool store_for_later = false; > - int bpp = fb->base.format->cpp[0]; > - int x2, y2; > - unsigned long flags; > - struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]); > - > - if ((width <= 0) || > - (x + width > fb->base.width) || > - (y + height > fb->base.height)) { > - DRM_DEBUG("values out of range %dx%d+%d+%d, fb %dx%d\n", > - width, height, x, y, > - fb->base.width, fb->base.height); > - return -EINVAL; > - } > - > - /* > - * Can be called with pretty much any context (console output > - * path). If we are in atomic just store the dirty rect info > - * to send out the update later. > - * > - * Can't test inside spin lock. > - */ > - if (in_atomic() || store) > - store_for_later = true; > - > - x2 = x + width - 1; > - y2 = y + height - 1; > - > - spin_lock_irqsave(&fb->dirty_lock, flags); > - > - if (fb->y1 < y) > - y = fb->y1; > - if (fb->y2 > y2) > - y2 = fb->y2; > - if (fb->x1 < x) > - x = fb->x1; > - if (fb->x2 > x2) > - x2 = fb->x2; > - > - if (store_for_later) { > - fb->x1 = x; > - fb->x2 = x2; > - fb->y1 = y; > - fb->y2 = y2; > - spin_unlock_irqrestore(&fb->dirty_lock, flags); > - return 0; > - } > - > - fb->x1 = fb->y1 = INT_MAX; > - fb->x2 = fb->y2 = 0; > - > - spin_unlock_irqrestore(&fb->dirty_lock, flags); > - > - { > - uint32_t offset; > - uint32_t w = x2 - x + 1; > - uint32_t h = y2 - y + 1; > - > - offset = (y * fb->base.pitches[0]) + x * bpp; > - > - virtio_gpu_cmd_transfer_to_host_2d(vgdev, obj, > - offset, > - cpu_to_le32(w), > - cpu_to_le32(h), > - cpu_to_le32(x), > - cpu_to_le32(y), > - NULL); > - > - } > - virtio_gpu_cmd_resource_flush(vgdev, obj->hw_res_handle, > - x, y, x2 - x + 1, y2 - y + 1); > - return 0; > -} > - > -int virtio_gpu_surface_dirty(struct virtio_gpu_framebuffer *vgfb, > - struct drm_clip_rect *clips, > - unsigned int num_clips) > -{ > - struct virtio_gpu_device *vgdev = vgfb->base.dev->dev_private; > - struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(vgfb->base.obj[0]); > - struct drm_clip_rect norect; > - struct drm_clip_rect *clips_ptr; > - int left, right, top, bottom; > - int i; > - int inc = 1; > - > - if (!num_clips) { > - num_clips = 1; > - clips = &norect; > - norect.x1 = norect.y1 = 0; > - norect.x2 = vgfb->base.width; > - norect.y2 = vgfb->base.height; > - } > - left = clips->x1; > - right = clips->x2; > - top = clips->y1; > - bottom = clips->y2; > - > - /* skip the first clip rect */ > - for (i = 1, clips_ptr = clips + inc; > - i < num_clips; i++, clips_ptr += inc) { > - left = min_t(int, left, (int)clips_ptr->x1); > - right = max_t(int, right, (int)clips_ptr->x2); > - top = min_t(int, top, (int)clips_ptr->y1); > - bottom = max_t(int, bottom, (int)clips_ptr->y2); > - } > - > - if (obj->dumb) > - return virtio_gpu_dirty_update(vgfb, false, left, top, > - right - left, bottom - top); > - > - virtio_gpu_cmd_resource_flush(vgdev, obj->hw_res_handle, > - left, top, right - left, bottom - top); > - return 0; > -} > diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makefile > index 42949a17ff70..458e606a936f 100644 > --- a/drivers/gpu/drm/virtio/Makefile > +++ b/drivers/gpu/drm/virtio/Makefile > @@ -4,7 +4,7 @@ > # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. > > virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \ > - virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ > + virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ > virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ > virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o > > -- > 2.18.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch