dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: intel-gfx@lists.freedesktop.org,
	laurent.pinchart@ideasonboard.com,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 00/12] drm: Add generic fbdev emulation
Date: Wed, 20 Jun 2018 11:34:37 +0200	[thread overview]
Message-ID: <20180620093437.GF7186@phenom.ffwll.local> (raw)
In-Reply-To: <20180618141739.48151-1-noralf@tronnes.org>

On Mon, Jun 18, 2018 at 04:17:27PM +0200, Noralf Trønnes wrote:
> This patchset adds generic fbdev emulation for drivers that supports GEM
> based dumb buffers which support .gem_prime_vmap and gem_prime_mmap. An
> API is begun to support in-kernel clients in general.
> 
> Notable changes since version 1:
> 
> - Rework client unregister code. I've used reference counting to manage
>   the fact that both the client itself and the driver through
>   drm_dev_unregister() can release the client. The client is now released
>   using drm_client_put() instead of drm_client_free().

I started reviewing the reworked client register/unregister stuff, and it
looks good, except this kref stuff here for clients. I don't understand
why you need this - as long as removal from dev->clientlist is properly
protected by the mutex, I don't see how both the client and the device can
release the client at the same time. Of course this means that both the
device-trigger unregister and the client-triggered unregister must first
grab the mutex, remove the client from the list, and only if that was done
succesfully, clean up the client. If the client is already removed from
the list (i.e. list_empty() is true) then you need to bail out to avoid
double-freeing.

I don't think there's a need to use a kref here. And kref has the tricky
issue that you tempt everyone into constructing references loops between
drm_device and drm_client (which require lots of jumping through hoops in
your v1 to make sure you can break those reference loops).

> - fbdev: Use a shadow buffer for framebuffers that have a dirty
>   callback. This makes the fbdev client truly generic and useable for all
>   drivers. There's a blitting penalty, but this is generic emulation after
>   all. The reason for needing a shadow buffer is that deferred I/O only
>   works with kmalloc/vmalloc buffers and not with shmem buffers
>   (page->lru/mapping).

Yeah I think that's the only feasible option. Everyone who cares more
about fbdev performance can keep their driver-specific code. And for other
drm_client users this shouldn't be a problem, since they know how to use
dirty and flipping between multiple buffers to drive kms as it was
designed. The issue really only exists for fbdev's assumption of a direct
mmap of a dumb framebuffer, encoded into the uapi.

> - Let tinydrm use the full fbdev client

\o/

Cheers, Daniel
> 
> Noralf.
> 
> Changes since version 1:
> - Make it possible to embed struct drm_client_dev and drop the private
>   pointer
> - Use kref reference counting to control client release since both the
>   client and the driver can release.
> - Add comment about using dma-buf as a possibility with some rework
> - Move buffer NULL check to drm_client_framebuffer_delete()
> - Move client name to struct drm_client_dev
> - Move up drm_dev_get/put calls to make them more visible
> - Move drm_client_dev.list definition to later patch that makes use of it
> 
> - Embed drm_client at the beginning of drm_fb_helper to avoid a fragile
>   transitional kfree hack in drm_client_release()
> - Set owner in drm_fbdev_fb_ops
> - Add kerneldoc to drm_fb_helper_generic_probe()
> 
> - Remove unused functions
> - Change name drm_client_funcs.lastclose -> .restore
> - Change name drm_client_funcs.remove -> .unregister
> - Rework unregister code
> 
> - tinydrm: Use drm_fbdev_generic_setup() and remove
>   drm_fb_cma_fbdev_init_with_funcs()
> 
> David Herrmann (1):
>   drm: provide management functions for drm_file
> 
> Noralf Trønnes (11):
>   drm/file: Don't set master on in-kernel clients
>   drm: Make ioctls available for in-kernel clients
>   drm: Begin an API for in-kernel clients
>   drm/fb-helper: Add generic fbdev emulation .fb_probe function
>   drm/pl111: Set .gem_prime_vmap and .gem_prime_mmap
>   drm/cma-helper: Use the generic fbdev emulation
>   drm/client: Add client callbacks
>   drm/debugfs: Add internal client debugfs file
>   drm/fb-helper: Finish the generic fbdev emulation
>   drm/tinydrm: Use drm_fbdev_generic_setup()
>   drm/cma-helper: Remove drm_fb_cma_fbdev_init_with_funcs()
> 
>  Documentation/gpu/drm-client.rst            |  12 +
>  Documentation/gpu/index.rst                 |   1 +
>  drivers/gpu/drm/Makefile                    |   2 +-
>  drivers/gpu/drm/drm_client.c                | 435 ++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_crtc_internal.h         |  19 +-
>  drivers/gpu/drm/drm_debugfs.c               |   7 +
>  drivers/gpu/drm/drm_drv.c                   |   8 +
>  drivers/gpu/drm/drm_dumb_buffers.c          |  33 ++-
>  drivers/gpu/drm/drm_fb_cma_helper.c         | 380 +++---------------------
>  drivers/gpu/drm/drm_fb_helper.c             | 330 ++++++++++++++++++++-
>  drivers/gpu/drm/drm_file.c                  | 304 ++++++++++---------
>  drivers/gpu/drm/drm_framebuffer.c           |  42 ++-
>  drivers/gpu/drm/drm_internal.h              |   2 +
>  drivers/gpu/drm/drm_ioctl.c                 |   4 +-
>  drivers/gpu/drm/drm_probe_helper.c          |   3 +
>  drivers/gpu/drm/pl111/pl111_drv.c           |   2 +
>  drivers/gpu/drm/tinydrm/core/tinydrm-core.c |   3 +-
>  drivers/gpu/drm/tinydrm/ili9225.c           |   1 -
>  drivers/gpu/drm/tinydrm/mi0283qt.c          |   1 -
>  drivers/gpu/drm/tinydrm/st7586.c            |   1 -
>  drivers/gpu/drm/tinydrm/st7735r.c           |   1 -
>  include/drm/drm_client.h                    | 156 ++++++++++
>  include/drm/drm_device.h                    |  21 ++
>  include/drm/drm_fb_cma_helper.h             |   6 -
>  include/drm/drm_fb_helper.h                 |  38 +++
>  25 files changed, 1298 insertions(+), 514 deletions(-)
>  create mode 100644 Documentation/gpu/drm-client.rst
>  create mode 100644 drivers/gpu/drm/drm_client.c
>  create mode 100644 include/drm/drm_client.h
> 
> -- 
> 2.15.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-06-20  9:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 14:17 [PATCH v2 00/12] drm: Add generic fbdev emulation Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 01/12] drm: provide management functions for drm_file Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 02/12] drm/file: Don't set master on in-kernel clients Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 03/12] drm: Make ioctls available for " Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 04/12] drm: Begin an API " Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 05/12] drm/fb-helper: Add generic fbdev emulation .fb_probe function Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 06/12] drm/pl111: Set .gem_prime_vmap and .gem_prime_mmap Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 07/12] drm/cma-helper: Use the generic fbdev emulation Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 08/12] drm/client: Add client callbacks Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 09/12] drm/debugfs: Add internal client debugfs file Noralf Trønnes
2018-06-20  9:23   ` [Intel-gfx] " Daniel Vetter
2018-06-18 14:17 ` [PATCH v2 10/12] drm/fb-helper: Finish the generic fbdev emulation Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 11/12] drm/tinydrm: Use drm_fbdev_generic_setup() Noralf Trønnes
2018-06-18 14:17 ` [PATCH v2 12/12] drm/cma-helper: Remove drm_fb_cma_fbdev_init_with_funcs() Noralf Trønnes
2018-06-20  9:34 ` Daniel Vetter [this message]
2018-06-20 13:52   ` [Intel-gfx] [PATCH v2 00/12] drm: Add generic fbdev emulation Noralf Trønnes
2018-06-20 15:28     ` Noralf Trønnes
2018-06-21  7:14       ` Daniel Vetter
2018-06-21 17:19         ` Noralf Trønnes
2018-06-26 13:41           ` [Intel-gfx] " Noralf Trønnes
2018-06-26 13:42             ` Daniel Vetter
2018-06-25 14:28 ` Noralf Trønnes

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=20180620093437.GF7186@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=noralf@tronnes.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