All of 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 5/9] drm/fb-helper: Add generic fbdev emulation .fb_probe function
Date: Thu, 24 May 2018 12:16:09 +0200	[thread overview]
Message-ID: <20180524101609.GL3438@phenom.ffwll.local> (raw)
In-Reply-To: <20180524091605.GH3438@phenom.ffwll.local>

On Thu, May 24, 2018 at 11:16:05AM +0200, Daniel Vetter wrote:
> On Wed, May 23, 2018 at 04:34:07PM +0200, Noralf Trønnes wrote:
> > +int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
> > +				struct drm_fb_helper_surface_size *sizes)
> > +{
> > +	struct drm_client_dev *client = fb_helper->client;
> > +	struct drm_client_buffer *buffer;
> > +	struct drm_framebuffer *fb;
> > +	struct fb_info *fbi;
> > +	u32 format;
> > +	int ret;
> > +
> > +	DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d)\n",
> > +		      sizes->surface_width, sizes->surface_height,
> > +		      sizes->surface_bpp);
> > +
> > +	format = drm_mode_legacy_fb_format(sizes->surface_bpp, sizes->surface_depth);
> > +	buffer = drm_client_framebuffer_create(client, sizes->surface_width,
> > +					       sizes->surface_height, format);
> > +	if (IS_ERR(buffer))
> > +		return PTR_ERR(buffer);
> > +
> > +	fb_helper->buffer = buffer;
> > +	fb_helper->fb = buffer->fb;
> > +	fb = buffer->fb;
> > +
> > +	fbi = drm_fb_helper_alloc_fbi(fb_helper);
> > +	if (IS_ERR(fbi)) {
> > +		ret = PTR_ERR(fbi);
> > +		goto err_free_buffer;
> > +	}
> > +
> > +	fbi->par = fb_helper;
> > +	fbi->fbops = &drm_fbdev_fb_ops;
> > +	fbi->screen_size = fb->height * fb->pitches[0];
> > +	fbi->fix.smem_len = fbi->screen_size;
> > +	fbi->screen_buffer = buffer->vaddr;
> > +	strcpy(fbi->fix.id, "DRM emulated");
> > +
> > +	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
> > +	drm_fb_helper_fill_var(fbi, fb_helper, sizes->fb_width, sizes->fb_height);
> > +
> > +	if (fb->funcs->dirty) {
> > +		struct fb_ops *fbops;
> > +
> > +		/*
> > +		 * fb_deferred_io_cleanup() clears &fbops->fb_mmap so a per
> > +		 * instance version is necessary.
> > +		 */
> > +		fbops = kzalloc(sizeof(*fbops), GFP_KERNEL);
> > +		if (!fbops) {
> > +			ret = -ENOMEM;
> > +			goto err_fb_info_destroy;
> > +		}
> > +
> > +		*fbops = *fbi->fbops;
> > +		fbi->fbops = fbops;
> > +
> > +		fbi->fbdefio = &drm_fbdev_defio;
> > +
> > +		/* TODO: Remove this when tinydrm is converted to vmalloc buffers. */
> > +		fbi->fix.smem_start = page_to_phys(virt_to_page(buffer->vaddr));
> > +
> > +		fb_deferred_io_init(fbi);
> > +
> > +		/* TODO: Remove this when tinydrm is converted to vmalloc buffers. */
> > +		fbi->fbops->fb_mmap = drm_fbdev_cma_deferred_io_mmap;
> > +	}
> 
> Ugh. Yeah defio and generic allocator through dumb buffers don't mix well.
> The only true generic solution for this would be to give userspace (and
> only userspace, for fbcon we can intercept everything) a staging buffer,
> and then upload things using the dirty callback.
> 
> But that introduces another copy step, so isn't cool.
> 
> I think a check for is_vmalloc_addr and if that's false, not doing any of
> the defio mmap setup would be good. Until we have a better idea. And yes
> that would need to be done after tinydrm is moved over.

Looking at the cma conversion patch, this stuff here is actually required.
Or we'll break cma. I think your TODO comments need to be adjusted to
reflect that.

There's also the problem of how to handle the wc vs cached memory issue,
we might need more flags for that.
-Daniel
-- 
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

  reply	other threads:[~2018-05-24 10:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 14:34 [PATCH 0/9] drm: Add generic fbdev emulation Noralf Trønnes
2018-05-23 14:34 ` [PATCH 1/9] drm: provide management functions for drm_file Noralf Trønnes
2018-05-23 14:34 ` [PATCH 2/9] drm/file: Don't set master on in-kernel clients Noralf Trønnes
2018-05-23 14:34 ` [PATCH 3/9] drm: Make ioctls available for " Noralf Trønnes
2018-05-24  8:22   ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 4/9] drm: Begin an API " Noralf Trønnes
2018-05-23 21:45   ` Thomas Hellstrom
2018-05-24  8:32     ` Daniel Vetter
2018-05-24  9:25       ` Thomas Hellstrom
2018-05-24 10:14         ` Daniel Vetter
2018-05-24 16:51           ` Thomas Hellstrom
2018-05-24  8:42   ` Daniel Vetter
2018-05-28 13:26     ` Noralf Trønnes
2018-05-29  7:53       ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 5/9] drm/fb-helper: Add generic fbdev emulation .fb_probe function Noralf Trønnes
2018-05-24  9:16   ` Daniel Vetter
2018-05-24 10:16     ` Daniel Vetter [this message]
2018-05-25 12:42     ` Noralf Trønnes
2018-05-29  7:54       ` Daniel Vetter
2018-12-28 20:38         ` Daniel Vetter
2019-01-03 17:06           ` Noralf Trønnes
2019-01-07 10:14             ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 6/9] drm/pl111: Set .gem_prime_vmap and .gem_prime_mmap Noralf Trønnes
2018-05-30 19:04   ` Eric Anholt
2018-05-23 14:34 ` [PATCH 7/9] drm/cma-helper: Use the generic fbdev emulation Noralf Trønnes
2018-05-24 10:16   ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 8/9] drm/client: Add client callbacks Noralf Trønnes
2018-05-24  9:52   ` Daniel Vetter
2018-05-23 14:34 ` [PATCH 9/9] drm/fb-helper: Finish the generic fbdev emulation Noralf Trønnes
2018-05-24  9:57   ` Daniel Vetter
2018-05-23 15:20 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Add " Patchwork
2018-05-23 15:38 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-23 17:31 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-05-24 10:17 ` [PATCH 0/9] " Daniel Vetter

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=20180524101609.GL3438@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.