public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 0/8] drm/fb-helper: Use drm_file to get a dumb framebuffer
Date: Sat, 16 Sep 2017 14:37:40 +0200	[thread overview]
Message-ID: <88242a97-9ecc-802b-e72c-e815bce0999f@tronnes.org> (raw)
In-Reply-To: <895f2d61-da88-3a35-f54d-f9b3426d77f9@tronnes.org>


Den 15.09.2017 18.37, skrev Noralf Trønnes:
>
> Den 15.09.2017 00.29, skrev Laurent Pinchart:
>> Hi Noralf,
>>
>> On Wednesday, 13 September 2017 18:19:22 EEST Noralf Trønnes wrote:
>>> Den 13.09.2017 07.09, skrev Laurent Pinchart:
>>>> On Monday, 11 September 2017 17:31:54 EEST Noralf Trønnes wrote:
>>>>> Hi,
>>>>>
>>>>> I want to start out by saying that this patchset is low priority 
>>>>> for me
>>>>> and if no one has interest or time to review this, that is just 
>>>>> fine. I
>>>>> was in the flow and just typed it out.
>>>>>
>>>>> This patchset adds a way for fbdev emulation code to create a
>>>>> framebuffer that is backed by a dumb buffer. drm_fb_helper gets a
>>>>> drm_file to hang the objects on, drm_framebuffer_create_dumb() 
>>>>> creates
>>>>> the framebuffer and drm_fb_helper_fini() destroys it.
>>>>> I have verified that all cma drivers supports dumb buffers, so
>>>>> converting the library should be fine for all.
>>>> Stupid question, what does this give us ? The series makes the call 
>>>> stack
>>>> more complex (up to a point where I'm getting trouble just 
>>>> following it),
>>>> what's the advantage that offsets that ?
>>> The short answer is that it avoids the need for special fbdev
>>> _with_funcs() functions in libraries like cma for framebuffers with the
>>> dirty callback set.
>>>
>>> I'm suprised that you think this more complex, I find it more coherent
>>> when fbdev userspace is doing things more like DRM userspace, like
>>> hanging the objects on a drm_file and cleaning up the objects when 
>>> done.
>> Maybe moving to a new code base gave me the wrong feeling that the 
>> result is
>> more complex. The current implementation is certainly not simple.
>>
>>> The longer and more diffuse answer is that it's annoying me that many
>>> drivers carry the burden of fbdev emulation just to get a console!
>> I totally agree with that. Ideally I'd like to remove 100% of 
>> fbdev-related
>> code from drivers. This includes
>>
>> - initialization and cleanup of fbdev helpers
>> - fbdev restore in last_close()
>> - forwarding of hotplug events to fbdev compatibility layer
>>
>> In practice we'll likely need to keep one initialization function (or a
>> drm_driver flag) to let drivers opt-in to fbdev compatibility, but 
>> the rest
>> should go away. Or maybe we could even enable fbdev compatibility in all
>> drivers unconditionally.
>
> Interesting idea, maybe something like this:
>

I just remembered that Daniel said something about the helpers shouldn't
bleed into the core, which my suggestion does :-/


>  struct drm_device {
> +     struct drm_fb_helper *fbdev;
>  };
>
>  void drm_lastclose(struct drm_device * dev)
>  {
>      DRM_DEBUG("\n");
>
>      if (dev->driver->lastclose)
>          dev->driver->lastclose(dev);
> +    else if (dev->fbdev)
> +        drm_fb_helper_restore_fbdev_mode_unlocked(dev->fbdev);
>      DRM_DEBUG("driver lastclose completed\n");
>
>      if (drm_core_check_feature(dev, DRIVER_LEGACY))
>          drm_legacy_dev_reinit(dev);
>  }
>
>  void drm_kms_helper_hotplug_event(struct drm_device *dev)
>  {
>      /* send a uevent + call fbdev */
>      drm_sysfs_hotplug_event(dev);
>      if (dev->mode_config.funcs->output_poll_changed)
>          dev->mode_config.funcs->output_poll_changed(dev);
> +    else if (dev->fbdev)
> +        drm_fb_helper_hotplug_event(dev->fbdev);
>  }
>
>  void drm_dev_unregister(struct drm_device *dev)
>  {
>     struct drm_map_list *r_list, *list_temp;
>
> +    if (dev->fbdev)
> +        drm_fb_helper_unregister_fbi(dev->fbdev);
> +
>      drm_lastclose(dev);
>  ...
>  }
>
>  static void drm_dev_release(struct kref *ref)
>  {
>      struct drm_device *dev = container_of(ref, struct drm_device, ref);
>
> +    drm_fb_helper_simple_fini(dev);
> +
>      if (dev->driver->release) {
>          dev->driver->release(dev);
>      } else {
>          drm_dev_fini(dev);
>          kfree(dev);
>      }
>  }
>
> int driver_probe()
> {
>     ret = drm_fb_helper_simple_init(dev, ...);
>     if (ret)
>         DRM_WARN("Oh well fbdev init failed, but don't let that stop 
> us\n");
> }
>
> I've slightly adjusted some code I have in the pipeline:
>
> /**
>  * drm_fb_helper_simple_init - Simple fbdev emulation init
>  * @dev: DRM device
>  * @bpp_sel: bpp value to use for the framebuffer configuration
>  * @max_conn: max connector count
>  * @funcs: pointer to structure of functions associated with this helper
>  *
>  * Simple fbdev emulation initialization. This function allocates a
>  * &drm_fb_helper structure and calls:
>  * drm_fb_helper_prepare(), drm_fb_helper_init(),
>  * drm_fb_helper_single_add_all_connectors() and
>  * drm_fb_helper_initial_config().
>  *
>  * fbdev deferred I/O users should use drm_fb_helper_defio_init().
>  *
>  * Returns:
>  * Zero on success, negative error code on failure.
>  */
> int drm_fb_helper_simple_init(struct drm_device *dev, int bpp_sel, int 
> max_conn,
>                   const struct drm_fb_helper_funcs *funcs)
> {
>     struct drm_fb_helper *fb_helper;
>     int ret;
>
>     fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
>     if (!fb_helper)
>         return -ENOMEM;
>
>     drm_fb_helper_prepare(dev, fb_helper, funcs);
>
>     ret = drm_fb_helper_init(dev, fb_helper, max_conn);
>     if (ret < 0) {
>         DRM_DEV_ERROR(dev->dev, "Failed to initialize fb helper.\n");
>         goto err_drm_fb_helper_free;
>     }
>
>     ret = drm_fb_helper_single_add_all_connectors(fb_helper);
>     if (ret < 0) {
>         DRM_DEV_ERROR(dev->dev, "Failed to add connectors.\n");
>         goto err_drm_fb_helper_fini;
>
>     }
>
>     ret = drm_fb_helper_initial_config(fb_helper, bpp_sel);
>     if (ret < 0) {
>         DRM_DEV_ERROR(dev->dev, "Failed to set initial hw config.\n");
>         goto err_drm_fb_helper_fini;
>     }
>
>     dev->fbdev = fb_helper;
>
>     return 0;
>
> err_drm_fb_helper_fini:
>     drm_fb_helper_fini(fb_helper);
> err_drm_fb_helper_free:
>     kfree(fb_helper);
>
>     return ret;
> }
> EXPORT_SYMBOL_GPL(drm_fb_helper_simple_init);
>
> /**
>  * drm_fb_helper_simple_fini - Simple fbdev cleanup
>  * @dev: DRM device
>  *
>  * Simple fbdev emulation cleanup. This function unregisters fbdev if 
> it is not
>  * done, cleans up deferred IO if necessary, removes framebuffer, 
> finalizes
>  * @fb_helper and frees the structure.
>  */
> void drm_fb_helper_simple_fini(struct drm_device *dev)
> {
>     struct drm_fb_helper *fb_helper = dev->fbdev;
>     struct fb_ops *fbops = NULL;
>     struct fb_info *info;
>
>     if (!fb_helper)
>         return;
>
>     info = fb_helper->fbdev;
>
>     /* Make sure it hasn't been unregistered already */
>     if (info && info->dev)
>         drm_fb_helper_unregister_fbi(fb_helper);
>
>     if (info && info->fbdefio) {
>         fb_deferred_io_cleanup(info);
>         kfree(info->fbdefio);
>         info->fbdefio = NULL;
>         fbops = info->fbops;
>     }
>
>     drm_fb_helper_fini(fb_helper);
>     kfree(fbops);
>
>     if (fb_helper->fb)
>         drm_framebuffer_remove(fb_helper->fb);
>
>     kfree(fb_helper);
> }
> EXPORT_SYMBOL_GPL(drm_fb_helper_simple_fini);
>
> <snip>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-09-16 12:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-11 14:31 [PATCH 0/8] drm/fb-helper: Use drm_file to get a dumb framebuffer Noralf Trønnes
2017-09-11 14:31 ` [PATCH 1/8] drm: provide management functions for drm_file Noralf Trønnes
2017-09-11 14:31 ` [PATCH 2/8] drm/framebuffer: Add drm_framebuffer_create_dumb() Noralf Trønnes
2017-09-11 14:31 ` [PATCH 3/8] drm/auth: Export drm_dropmaster_ioctl() Noralf Trønnes
2017-09-11 14:31 ` [PATCH 4/8] drm/fb-helper: Allocate a drm_file Noralf Trønnes
2017-09-17  1:40   ` [lkp-robot] [drm/fb] a583bc678d: WARNING:at_kernel/workqueue.c:#flush_workqueue kernel test robot
2017-09-11 14:31 ` [PATCH 5/8] drm/fb-cma-helper: Use drm_framebuffer_create_dumb() Noralf Trønnes
2017-09-11 14:32 ` [PATCH 6/8] drm/fb-cma-helper: Drop unnecessary fbdev buffer offset Noralf Trønnes
2017-09-11 14:32 ` [PATCH 7/8] drm/tinydrm: Use drm_fbdev_cma_init() Noralf Trønnes
2017-09-11 14:32 ` [PATCH 8/8] drm/fb-cma-helper: Remove drm_fbdev_cma_init_with_funcs() Noralf Trønnes
2017-09-11 14:51 ` ✓ Fi.CI.BAT: success for drm/fb-helper: Use drm_file to get a dumb framebuffer Patchwork
2017-09-11 18:39 ` ✓ Fi.CI.IGT: " Patchwork
2017-09-13  5:09 ` [PATCH 0/8] " Laurent Pinchart
2017-09-13 15:19   ` Noralf Trønnes
2017-09-14 22:29     ` Laurent Pinchart
2017-09-15 16:37       ` Noralf Trønnes
2017-09-16 12:37         ` Noralf Trønnes [this message]
2017-09-16 14:45           ` 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=88242a97-9ecc-802b-e72c-e815bce0999f@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    /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