From: Thomas Zimmermann Subject: Re: [PATCH 1/2] drm/fb-helper: Remove drm_fb_helper_defio_init() and update docs Date: Mon, 28 Oct 2019 09:13:47 +0100 Message-ID: <5ea7beb9-2584-eddf-1d79-d9b484930d63@suse.de> References: <20191025092759.13069-1-tzimmermann@suse.de> <20191025092759.13069-2-tzimmermann@suse.de> <3db04b4e-4b23-1edb-7df8-893ca9b5709f@tronnes.org> <7016126a-f498-1a4a-4721-c6305a961457@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0600850898==" Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52EF56E42F for ; Mon, 28 Oct 2019 08:13:55 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Daniel Vetter Cc: dri-devel List-Id: dri-devel@lists.freedesktop.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============0600850898== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SuuTqoP69uupw3WLjQ2CREe6Ymf1mtW7C" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --SuuTqoP69uupw3WLjQ2CREe6Ymf1mtW7C Content-Type: multipart/mixed; boundary="xweyJ2HADYZ12BrqAvGUzWXgJ156LgTya"; protected-headers="v1" From: Thomas Zimmermann To: Daniel Vetter Cc: dri-devel Message-ID: <5ea7beb9-2584-eddf-1d79-d9b484930d63@suse.de> Subject: Re: [PATCH 1/2] drm/fb-helper: Remove drm_fb_helper_defio_init() and update docs References: <20191025092759.13069-1-tzimmermann@suse.de> <20191025092759.13069-2-tzimmermann@suse.de> <3db04b4e-4b23-1edb-7df8-893ca9b5709f@tronnes.org> <7016126a-f498-1a4a-4721-c6305a961457@suse.de> In-Reply-To: --xweyJ2HADYZ12BrqAvGUzWXgJ156LgTya Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 25.10.19 um 20:54 schrieb Daniel Vetter: > On Fri, Oct 25, 2019 at 7:26 PM Thomas Zimmermann = wrote: >> >> Hi >> >> Am 25.10.19 um 17:46 schrieb Noralf Tr=C3=B8nnes: >>> >>> >>> Den 25.10.2019 11.27, skrev Thomas Zimmermann: >>>> There are no users of drm_fb_helper_defio_init(), so we can remove >>>> it. The documenation around defio support is a bit misleading and >>>> should mention compatibility issues with SHMEM helpers. Clarify this= =2E >>>> >>>> Signed-off-by: Thomas Zimmermann >>>> --- >>>> drivers/gpu/drm/drm_fb_helper.c | 61 +++++++-----------------------= --- >>>> include/drm/drm_fb_helper.h | 1 - >>>> 2 files changed, 13 insertions(+), 49 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_f= b_helper.c >>>> index b75ae8555baf..8ebeccdeed23 100644 >>>> --- a/drivers/gpu/drm/drm_fb_helper.c >>>> +++ b/drivers/gpu/drm/drm_fb_helper.c >>>> @@ -92,9 +92,12 @@ static DEFINE_MUTEX(kernel_fb_helper_lock); >>>> * >>>> * Drivers that support a dumb buffer with a virtual address and mm= ap support, >>>> * should try out the generic fbdev emulation using drm_fbdev_gener= ic_setup(). >>>> + * It will automatically set up deferred I/O if the driver requires= a shadow >>>> + * buffer. >>>> * >>>> - * Setup fbdev emulation by calling drm_fb_helper_fbdev_setup() and= tear it >>>> - * down by calling drm_fb_helper_fbdev_teardown(). >>>> + * For other drivers, setup fbdev emulation by calling >>>> + * drm_fb_helper_fbdev_setup() and tear it down by calling >>>> + * drm_fb_helper_fbdev_teardown(). >>>> * >>>> * At runtime drivers should restore the fbdev console by using >>>> * drm_fb_helper_lastclose() as their &drm_driver.lastclose callbac= k. >>>> @@ -127,8 +130,10 @@ static DEFINE_MUTEX(kernel_fb_helper_lock); >>>> * always run in process context since the fb_*() function could be= running in >>>> * atomic context. If drm_fb_helper_deferred_io() is used as the de= ferred_io >>>> * callback it will also schedule dirty_work with the damage collec= ted from the >>>> - * mmap page writes. Drivers can use drm_fb_helper_defio_init() to = setup >>>> - * deferred I/O (coupled with drm_fb_helper_fbdev_teardown()). >>>> + * mmap page writes. >>>> + * >>>> + * Deferred I/O is not compatible with SHMEM. Such drivers should r= equest an >>>> + * fbdev shadow buffer and call drm_fbdev_generic_setup() instead. >>>> */ >>>> >>>> static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)= >>>> @@ -679,49 +684,6 @@ void drm_fb_helper_deferred_io(struct fb_info *= info, >>>> } >>>> EXPORT_SYMBOL(drm_fb_helper_deferred_io); >>>> >>>> -/** >>>> - * drm_fb_helper_defio_init - fbdev deferred I/O initialization >>>> - * @fb_helper: driver-allocated fbdev helper >>>> - * >>>> - * This function allocates &fb_deferred_io, sets callback to >>>> - * drm_fb_helper_deferred_io(), delay to 50ms and calls fb_deferred= _io_init(). >>>> - * It should be called from the &drm_fb_helper_funcs->fb_probe call= back. >>>> - * drm_fb_helper_fbdev_teardown() cleans up deferred I/O. >>>> - * >>>> - * NOTE: A copy of &fb_ops is made and assigned to &info->fbops. Th= is is done >>>> - * because fb_deferred_io_cleanup() clears &fbops->fb_mmap and woul= d thereby >>>> - * affect other instances of that &fb_ops. >>>> - * >>>> - * Returns: >>>> - * 0 on success or a negative error code on failure. >>>> - */ >>>> -int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper) >>>> -{ >>>> - struct fb_info *info =3D fb_helper->fbdev; >>>> - struct fb_deferred_io *fbdefio; >>>> - struct fb_ops *fbops; >>>> - >>>> - fbdefio =3D kzalloc(sizeof(*fbdefio), GFP_KERNEL); >>>> - fbops =3D kzalloc(sizeof(*fbops), GFP_KERNEL); >>>> - if (!fbdefio || !fbops) { >>>> - kfree(fbdefio); >>>> - kfree(fbops); >>>> - return -ENOMEM; >>>> - } >>>> - >>>> - info->fbdefio =3D fbdefio; >>>> - fbdefio->delay =3D msecs_to_jiffies(50); >>>> - fbdefio->deferred_io =3D drm_fb_helper_deferred_io; >>>> - >>>> - *fbops =3D *info->fbops; >>>> - info->fbops =3D fbops; >>>> - >>>> - fb_deferred_io_init(info); >>>> - >>>> - return 0; >>>> -} >>>> -EXPORT_SYMBOL(drm_fb_helper_defio_init); >>>> - >>> >>> With this gone you can remove the defio cleanup part from >>> drm_fb_helper_fbdev_teardown() as well. >>> >>> And I see that there's no users left of that function (the same with >>> *_seup()). Would be nice if you just removed them. I made them before= I >>> embarked on the generic fbdev solution. I think it's better to try an= d >>> make the generic emulation usable for "everyone" and avoid the need f= or >>> drivers to have to do their own special stuff. >> >> The last user was vboxvideo, which I converted ~2 weeks ago. I haven't= >> removed them yet, as there's a TODO item to convert drivers over to th= em. >> >> From a quick 'git grep': >> >> Most drivers that uses drm_fb_helper_sys_*() in its fb_ops could >> probably be converted over to generic fbdev. That's hibmc (I have some= >> untested patches for it), msm, omapdrm, tegra, and udl (currently bein= g >> converted). >> >> Only nouveau and gma500 have some form of HW acceleration. >> >> The rest of the drivers (10) uses drm_fb_helper_cfb_*() functions. Are= >> these strictly required, or can they be made available within generic = fbdev? >=20 > Take a pile of digging through a few fb horrors, but this boils down to= : >=20 > *sys* functions operate on an fb that works like normal system memory. >=20 > *cfb* functions operate on void __iomem * instead. Which makes a huge > difference on some architectures, but afaiui neither x86 nor arm care. > On ppc it seems to make a difference sometimes. >=20 > So for shmem we should use *sys* functions, for vram *cfb*. >=20 > And that leads me to realizing that drm_gem_vram_vmap has the totally > wrong type, it should be void __iomem *. There's this fancy is_iomem > parameter for ttm_kmap_obj_virtual that should help you figure out the > right type, but only nouveau bothers to implement this correctly. >=20 > I'm honestly not sure whether we should care. I remember getting an eamil about this from some automated test system. I haven't had time to change it and it's apparently not urgent. If we really want to fix the problem, we'd have to propagage is_iomem through the DRM core; probably touching every vmap callback. OTOH this might not be a bad thing. With is_iomem available in the generic fbdev emulation, it could select between sys and cfb functions and support drivers with cfb-based fbdev as well. Best regards Thomas > -Daniel >=20 >> >> Best regards >> Thomas >> >>> code to avoid the shadow buffering would aid in that as Daniel have >>> talked about. >>> >>> Either way you choose, this patch is: >>> >>> Reviewed-by: Noralf Tr=C3=B8nnes >>> >>>> /** >>>> * drm_fb_helper_sys_read - wrapper around fb_sys_read >>>> * @info: fb_info struct pointer >>>> @@ -2356,7 +2318,10 @@ static const struct drm_client_funcs drm_fbde= v_client_funcs =3D { >>>> * >>>> * Drivers that set the dirty callback on their framebuffer will ge= t a shadow >>>> * fbdev buffer that is blitted onto the real buffer. This is done = in order to >>>> - * make deferred I/O work with all kinds of buffers. >>>> + * make deferred I/O work with all kinds of buffers. A shadow buffe= r can be >>>> + * requested explicitly by setting struct drm_mode_config.prefer_sh= adow or >>>> + * struct drm_mode_config.prefer_shadow_fbdev to true beforehand. T= his is >>>> + * required to use generic fbdev emulation with SHMEM helpers. >>>> * >>>> * This function is safe to call even when there are no connectors = present. >>>> * Setup will be retried on the next hotplug event. >>>> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper= =2Eh >>>> index 8dcc012ccbc8..2338e9f94a03 100644 >>>> --- a/include/drm/drm_fb_helper.h >>>> +++ b/include/drm/drm_fb_helper.h >>>> @@ -235,7 +235,6 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_help= er *fb_helper); >>>> >>>> void drm_fb_helper_deferred_io(struct fb_info *info, >>>> struct list_head *pagelist); >>>> -int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper); >>>> >>>> ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *b= uf, >>>> size_t count, loff_t *ppos); >>>> >>> _______________________________________________ >>> dri-devel mailing list >>> dri-devel@lists.freedesktop.org >>> https://lists.freedesktop.org/mailman/listinfo/dri-devel >>> >> >> -- >> Thomas Zimmermann >> Graphics Driver Developer >> SUSE Software Solutions Germany GmbH >> Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany >> (HRB 36809, AG N=C3=BCrnberg) >> Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer >> >=20 >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany (HRB 36809, AG N=C3=BCrnberg) Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --xweyJ2HADYZ12BrqAvGUzWXgJ156LgTya-- --SuuTqoP69uupw3WLjQ2CREe6Ymf1mtW7C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl22ozsACgkQaA3BHVML eiPEFAgAieu88AJU/RGH7K1dsh4Wx0JqjaAmMFaB7XOnB5GzDANDVStHuVn3xRYm AnitTnvnKVMPU6t/6IeaRFFo2Kbo62nzpl9yIo51VpgIYUFDq++eIjEhHlR9cTwe NhOdZtwURaW4hn0ChiSna0oRjKvCUy0qY72sb2iL6042cJJWuzzIYuOcnYAEMWoq YcIrP6/mZiuUdLMcZrzm+Edx0St5onDGuRNAwwLLwXSj2Q+Vnk8MYd9lCC6N8WRq 52fBkuoXFNe0Q5lZvkWxFNlF5WJR2XdNWhJ3HyuR4520MfRce5AidhHGBL3hnXp+ 2uxYKpObJMVzKVOJORYtrGSQO/Nfeg== =Tqu5 -----END PGP SIGNATURE----- --SuuTqoP69uupw3WLjQ2CREe6Ymf1mtW7C-- --===============0600850898== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVs --===============0600850898==--