drm/tinydrm: Remove tinydrm_device
Subsystems (3)
v3 cover drm/tinydrm: Remove tinydrm_device
This patchset is part of the effort to remove tinydrm.ko. It removes struct tinydrm_device and tinydrm.h.
Only one change in this version and that is expanding the driver example.
The drm_dev_unplug() dependency series has been applied together with some patches from the previous version.
I've cc'ed intel-gfx so the Intel CI can verify the parent device ref patch.
Noralf.
Noralf Trønnes (7):
drm/drv: Hold ref on parent device during drm_device lifetime
drm: Add devm_drm_dev_init()
drm/drv: DOC: Add driver example code drm/tinydrm/repaper: Drop using tinydrm_device drm/tinydrm: Drop using tinydrm_device
drm/tinydrm: Remove tinydrm_device
drm/tinydrm: Use drm_dev_enter/exit()
Documentation/driver-model/devres.txt | 3 + Documentation/gpu/tinydrm.rst | 32 +--- Documentation/gpu/todo.rst | 4 - drivers/gpu/drm/drm_drv.c | 176 +++++++++++++++++- drivers/gpu/drm/tinydrm/core/Makefile | 2 +- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 169 ----------------- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 2 + drivers/gpu/drm/tinydrm/hx8357d.c | 49 ++++- drivers/gpu/drm/tinydrm/ili9225.c | 63 ++++++- drivers/gpu/drm/tinydrm/ili9341.c | 49 ++++- drivers/gpu/drm/tinydrm/mi0283qt.c | 49 ++++- drivers/gpu/drm/tinydrm/mipi-dbi.c | 109 ++++++++--- drivers/gpu/drm/tinydrm/repaper.c | 130 +++++++++---- drivers/gpu/drm/tinydrm/st7586.c | 129 ++++++++----- drivers/gpu/drm/tinydrm/st7735r.c | 49 ++++- include/drm/drm_drv.h | 3 + include/drm/tinydrm/mipi-dbi.h | 26 ++- include/drm/tinydrm/tinydrm.h | 42 ----- 18 files changed, 688 insertions(+), 398 deletions(-) delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c delete mode 100644 include/drm/tinydrm/tinydrm.h
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 1/7 drm/drv: Hold ref on parent device during drm_device lifetime
This makes it safe to access drm_device->dev after the parent device has been removed/unplugged.
--- drivers/gpu/drm/drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_drv.c +4 -1
@@ -521,7 +521,7 @@ int drm_dev_init(struct drm_device *dev,BUG_ON (!parent);kref_init (&dev->ref); - dev->dev = parent; + dev->dev =get_device (parent); dev->driver = driver;/* no per-device feature limits by default */
@@ -591,6 +591,7 @@ int drm_dev_init(struct drm_device *dev,drm_minor_free (dev,DRM_MINOR_RENDER );drm_fs_inode_free (dev->anon_inode); err_free: +put_device (dev->dev);mutex_destroy (&dev->master_mutex);mutex_destroy (&dev->ctxlist_mutex);mutex_destroy (&dev->clientlist_mutex);
@@ -626,6 +627,8 @@ void drm_dev_fini(struct drm_device *dev)drm_minor_free (dev,DRM_MINOR_PRIMARY );drm_minor_free (dev,DRM_MINOR_RENDER ); +put_device (dev->dev); +mutex_destroy (&dev->master_mutex);mutex_destroy (&dev->ctxlist_mutex);mutex_destroy (&dev->clientlist_mutex);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 1/7] drm/drv: Hold ref on parent device during drm_device lifetime
Quoted 4 lines · Noralf Trønnes
This makes it safe to access
drm_device->devafter the parent device has been removed/unplugged.Signed-off-by Noralf Trønnes <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/7 drm: Add devm_drm_dev_init()
In reply to Noralf TrønnesThis adds a resource managed (devres) version of drm_dev_init().
v2: Remove devm_drm_dev_register() since we can't touch hw in devm
release functions and drivers want to disable hw on driver module unload (Daniel Vetter, Greg KH)
--- Documentation/driver-model/devres.txt | 3 +++ drivers/gpu/drm/drm_drv.c | 39 +++++++++++++++++++++++++++ include/drm/drm_drv.h | 3 +++ 3 files changed, 45 insertions(+)
Documentation/driver-model/devres.txt +3 -0
@@ -254,6 +254,9 @@ DMA dmam_pool_create() dmam_pool_destroy() +DRM + devm_drm_dev_init() + GPIO devm_gpiod_get() devm_gpiod_get_index()
drivers/gpu/drm/drm_drv.c +39 -0
@@ -601,6 +601,45 @@ int drm_dev_init(struct drm_device *dev, }EXPORT_SYMBOL (drm_dev_init); +static void devm_drm_dev_init_release (void *data) +{ +drm_dev_put (data); +} + +/** +* devm_drm_dev_init - Resource managed drm_dev_init() +* @parent: Parent device object +* @dev: DRM device +* @driver: DRM driver +* +* Managed drm_dev_init(). The DRM device initialized with this function is +* automatically put on driver detach using drm_dev_put(). You must supply a +* &drm_driver.release callback to control the finalization explicitly. +* +* RETURNS: +* 0 on success, or error code on failure. +*/ +int devm_drm_dev_init (struct device *parent, +struct drm_device *dev, +struct drm_driver *driver) +{ +int ret; + +if (WARN_ON (!parent || !driver->release)) +return -EINVAL ; + + ret =drm_dev_init (dev, driver, parent); +if (ret) +return ret; + + ret =devm_add_action (parent, devm_drm_dev_init_release, dev); +if (ret) +devm_drm_dev_init_release (dev); + +return ret; +} +EXPORT_SYMBOL (devm_drm_dev_init); +/** * drm_dev_fini - Finalize a dead DRM device * @dev: DRM device
include/drm/drm_drv.h +3 -0
@@ -718,6 +718,9 @@ extern unsigned int drm_debug;int drm_dev_init (struct drm_device *dev,struct drm_driver *driver,struct device *parent); +int devm_drm_dev_init (struct device *parent, +struct drm_device *dev, +struct drm_driver *driver);void drm_dev_fini (struct drm_device *dev); struct drm_device *drm_dev_alloc(struct drm_driver *driver,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 2/7] drm: Add devm_drm_dev_init()
Quoted 5 lines · Noralf Trønnes
This adds a resource managed (devres) version of
drm_dev_init().v2: Remove
devm_drm_dev_register()since we can't touch hw in devm
release functions and drivers want to disable hw on driver module unload (Daniel Vetter, Greg KH)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 3/7 drm/drv: DOC: Add driver example code
In reply to Noralf TrønnesAdd driver example that shows how devm_drm_dev_init() can be used.
v2: Expand docs (Sam, Daniel)
--- drivers/gpu/drm/drm_drv.c | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+)
drivers/gpu/drm/drm_drv.c +132 -0
@@ -286,6 +286,138 @@ void drm_minor_release(struct drm_minor *minor)* Note that the lifetime rules for &drm_device instance has still a lot of * historical baggage. Hence use the reference counting provided by * drm_dev_get() and drm_dev_put() only carefully. +* +* Display driver example +* ~~~~~~~~~~~~~~~~~~~~~~ +* +* The following example shows a typical structure of a DRM display driver. +* The example focus on the probe() function and the other functions that is +* almost always present and serves as a demonstration of devm_drm_dev_init() +* usage with its accompanying drm_driver->release callback. +* +* .. code-block:: c +* +* struct driver_device { +* struct drm_device drm; +* void *userspace_facing; +* struct clk *pclk; +* }; +* +* static void driver_drm_release(struct drm_device *drm) +* { +* struct driver_device *priv = container_of(...); +* +* drm_mode_config_cleanup(drm); +* drm_dev_fini(drm); +* kfree(priv->userspace_facing); +* kfree(priv); +* } +* +* static struct drm_driver driver_drm_driver = { +* [...] +* .release = driver_drm_release, +* }; +* +* static int driver_probe(struct platform_device *pdev) +* { +* struct driver_device *priv; +* struct drm_device *drm; +* int ret; +* +* [ +* devm_kzalloc() can't be used here because the drm_device +* lifetime can exceed the device lifetime if driver unbind +* happens when userspace still has open file descriptors. +* ] +* priv = kzalloc(sizeof(*priv), GFP_KERNEL); +* if (!priv) +* return -ENOMEM; +* +* drm = &priv->drm; +* +* ret = devm_drm_dev_init(&pdev->dev, drm, &driver_drm_driver); +* if (ret) { +* kfree(drm); +* return ret; +* } +* +* drm_mode_config_init(drm); +* +* priv->userspace_facing = kzalloc(..., GFP_KERNEL); +* if (!priv->userspace_facing) +* return -ENOMEM; +* +* priv->pclk = devm_clk_get(dev, "PCLK"); +* if (IS_ERR(priv->pclk)) +* return PTR_ERR(priv->pclk); +* +* [ Further setup, display pipeline etc ] +* +* platform_set_drvdata(pdev, drm); +* +* drm_mode_config_reset(drm); +* +* ret = drm_dev_register(drm); +* if (ret) +* return ret; +* +* drm_fbdev_generic_setup(drm, 32); +* +* return 0; +* } +* +* [ This function is called before the devm_ resources are released ] +* static int driver_remove(struct platform_device *pdev) +* { +* struct drm_device *drm = platform_get_drvdata(pdev); +* +* drm_dev_unregister(drm); +* drm_atomic_helper_shutdown(drm) +* +* return 0; +* } +* +* [ This function is called on kernel restart and shutdown ] +* static void driver_shutdown(struct platform_device *pdev) +* { +* drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +* } +* +* static int __maybe_unused driver_pm_suspend(struct device *dev) +* { +* return drm_mode_config_helper_suspend(dev_get_drvdata(dev)); +* } +* +* static int __maybe_unused driver_pm_resume(struct device *dev) +* { +* drm_mode_config_helper_resume(dev_get_drvdata(dev)); +* +* return 0; +* } +* +* static const struct dev_pm_ops driver_pm_ops = { +* SET_SYSTEM_SLEEP_PM_OPS(driver_pm_suspend, driver_pm_resume) +* }; +* +* static struct platform_driver driver_driver = { +* .driver = { +* [...] +* .pm = &driver_pm_ops, +* }, +* .probe = driver_probe, +* .remove = driver_remove, +* .shutdown = driver_shutdown, +* }; +* module_platform_driver(driver_driver); +* +* Drivers that want to support device unplugging (USB, DT overlay unload) should +* use drm_dev_unplug() instead of drm_dev_unregister(). The driver must protect +* regions that is accessing device resources to prevent use after they're +* released. This is done using drm_dev_enter() and drm_dev_exit(). There is one +* shortcoming however, drm_dev_unplug() marks the drm_device as unplugged before +* drm_atomic_helper_shutdown() is called. This means that if the disable code +* paths are protected, they will not run on regular driver module unload, +* possibily leaving the hardware enabled. */ /**
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/7] drm/drv: DOC: Add driver example code
Quoted 3 lines · Noralf Trønnes
Add driver example that shows how
devm_drm_dev_init()can be used.v2: Expand docs (Sam, Daniel)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 4/7 drm/tinydrm/repaper: Drop using tinydrm_device
In reply to Noralf TrønnesUse devm_drm_dev_init() and drop using tinydrm_device.
v2: devm_drm_dev_register() was dropped so add a driver release callback.
--- drivers/gpu/drm/tinydrm/repaper.c | 84 ++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 23 deletions(-)
drivers/gpu/drm/tinydrm/repaper.c +61 -23
@@ -30,11 +30,12 @@#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_fb_cma_helper.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_rect.h> #include <drm/drm_vblank.h> -#include <drm/tinydrm/tinydrm.h> +#include <drm/drm_simple_kms_helper.h> #include <drm/tinydrm/tinydrm-helpers.h> #define REPAPER_RID_G2_COG_ID 0x12
@@ -60,7 +61,8 @@ enum repaper_epd_border_byte { };struct repaper_epd { -struct tinydrm_device tinydrm; +struct drm_device drm; +struct drm_simple_display_pipe pipe;struct spi_device *spi;struct gpio_desc *panel_on;
@@ -89,10 +91,9 @@ struct repaper_epd {bool partial; }; -static inline struct repaper_epd * -epd_from_tinydrm (struct tinydrm_device *tdev) +static inline struct repaper_epd *drm_to_epd (struct drm_device *drm) { - return container_of(tdev, struct repaper_epd, tinydrm); + return container_of(drm, struct repaper_epd, drm); } static int repaper_spi_transfer(struct spi_device *spi, u8 header,
@@ -530,8 +531,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) {struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 );struct dma_buf_attachment *import_attach = cma_obj->base.import_attach; -struct tinydrm_device *tdev = fb->dev->dev_private; -struct repaper_epd *epd =epd_from_tinydrm (tdev); +struct repaper_epd *epd =drm_to_epd (fb->dev);struct drm_rect clip;u8 *buf =NULL ;int ret =0 ;
@@ -646,8 +646,7 @@ static void repaper_pipe_enable(struct drm_simple_display_pipe *pipe,struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { - struct tinydrm_device *tdev = pipe_to_tinydrm(pipe); -struct repaper_epd *epd =epd_from_tinydrm (tdev); + struct repaper_epd *epd = drm_to_epd(pipe->crtc.dev);struct spi_device *spi = epd->spi;struct device *dev = &spi->dev;bool dc_ok = false;
@@ -781,8 +780,7 @@ static void repaper_pipe_enable(struct drm_simple_display_pipe *pipe,static void repaper_pipe_disable (struct drm_simple_display_pipe *pipe) { -struct tinydrm_device *tdev =pipe_to_tinydrm (pipe); -struct repaper_epd *epd =epd_from_tinydrm (tdev); +struct repaper_epd *epd =drm_to_epd (pipe->crtc.dev);struct spi_device *spi = epd->spi;unsigned int line;
@@ -856,6 +854,23 @@ static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = { .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, }; +static const struct drm_mode_config_funcs repaper_mode_config_funcs = { + .fb_create = drm_gem_fb_create_with_dirty, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static void repaper_release (struct drm_device *drm) +{ +struct repaper_epd *epd =drm_to_epd (drm); + +DRM_DEBUG_DRIVER ("\n" ); + +drm_mode_config_cleanup (drm); +drm_dev_fini (drm); +kfree (epd); +} +static const uint32_t repaper_formats[] = {DRM_FORMAT_XRGB8888 , };
@@ -894,6 +909,7 @@ static struct drm_driver repaper_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, .fops = &repaper_fops, + .release = repaper_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .name = "repaper", .desc = "Pervasive Displays RePaper e-ink panels",
@@ -926,11 +942,11 @@ static int repaper_probe(struct spi_device *spi)const struct spi_device_id *spi_id;const struct of_device_id *match;struct device *dev = &spi->dev; -struct tinydrm_device *tdev;enum repaper_model model;const char *thermal_zone;struct repaper_epd *epd;size_t line_buffer_size; +struct drm_device *drm;int ret; match =of_match_device (repaper_of_match, dev);
@@ -950,10 +966,21 @@ static int repaper_probe(struct spi_device *spi) } } - epd =devm_kzalloc (dev,sizeof (*epd),GFP_KERNEL ); + epd =kzalloc (sizeof (*epd),GFP_KERNEL );if (!epd)return -ENOMEM ; + drm = &epd->drm; + + ret =devm_drm_dev_init (dev, drm, &repaper_driver); +if (ret) { +kfree (epd); +return ret; + } + +drm_mode_config_init (drm); + drm->mode_config.funcs = &repaper_mode_config_funcs; + epd->spi = spi; epd->panel_on =devm_gpiod_get (dev,"panel-on" ,GPIOD_OUT_LOW );
@@ -1064,26 +1091,36 @@ static int repaper_probe(struct spi_device *spi)if (!epd->current_frame)return -ENOMEM ; - tdev = &epd->tinydrm; - - ret =devm_tinydrm_init (dev, tdev, &repaper_driver); -if (ret) -return ret; - - ret =tinydrm_display_pipe_init (tdev->drm, &tdev->pipe, &repaper_pipe_funcs, + ret =tinydrm_display_pipe_init (drm, &epd->pipe, &repaper_pipe_funcs,DRM_MODE_CONNECTOR_VIRTUAL , repaper_formats,ARRAY_SIZE (repaper_formats), mode,0 );if (ret)return ret; -drm_mode_config_reset (tdev->drm); +drm_mode_config_reset (drm); -spi_set_drvdata (spi, tdev->drm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm);DRM_DEBUG_DRIVER ("SPI speed: %uMHz\n" , spi->max_speed_hz /1000000 ); -return devm_tinydrm_register (tdev); +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int repaper_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void repaper_shutdown (struct spi_device *spi)
@@ -1099,6 +1136,7 @@ static struct spi_driver repaper_spi_driver = { }, .id_table = repaper_id, .probe = repaper_probe, + .remove = repaper_remove, .shutdown = repaper_shutdown, };module_spi_driver (repaper_spi_driver);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 5/7 drm/tinydrm: Drop using tinydrm_device
In reply to Noralf TrønnesUse devm_drm_dev_init() and drop using tinydrm_device.
v2: devm_drm_dev_register() was dropped so add driver release callbacks.
--- drivers/gpu/drm/tinydrm/hx8357d.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9225.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9341.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mi0283qt.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 67 +++++++++++------- drivers/gpu/drm/tinydrm/st7586.c | 105 ++++++++++++++++------------- drivers/gpu/drm/tinydrm/st7735r.c | 40 +++++++++-- include/drm/tinydrm/mipi-dbi.h | 26 ++++--- 8 files changed, 294 insertions(+), 104 deletions(-)
drivers/gpu/drm/tinydrm/hx8357d.c +35 -5
@@ -18,6 +18,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -189,6 +190,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);static struct drm_driver hx8357d_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_PRIME |DRIVER_ATOMIC , .fops = &hx8357d_fops, + .release = mipi_dbi_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .debugfs_init = mipi_dbi_debugfs_init, .name ="hx8357d" ,
@@ -213,15 +215,25 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id);static int hx8357d_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +struct drm_device *drm;struct mipi_dbi *mipi;struct gpio_desc *dc;u32 rotation =0 ;int ret; - mipi =devm_kzalloc (dev,sizeof (*mipi),GFP_KERNEL ); + mipi =kzalloc (sizeof (*mipi),GFP_KERNEL );if (!mipi)return -ENOMEM ; + drm = &mipi->drm; + ret =devm_drm_dev_init (dev, drm, &hx8357d_driver); +if (ret) { +kfree (mipi); +return ret; + } + +drm_mode_config_init (drm); + dc =devm_gpiod_get (dev,"dc" ,GPIOD_OUT_LOW );if (IS_ERR (dc)) {DRM_DEV_ERROR (dev,"Failed to get gpio 'dc'\n" );
@@ -238,14 +250,31 @@ static int hx8357d_probe(struct spi_device *spi)if (ret)return ret; - ret =mipi_dbi_init (&spi->dev, mipi, &hx8357d_pipe_funcs, - &hx8357d_driver, &yx350hv15_mode, rotation); + ret =mipi_dbi_init (mipi, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation);if (ret)return ret; -spi_set_drvdata (spi, mipi->tinydrm.drm); +drm_mode_config_reset (drm); -return devm_tinydrm_register (&mipi->tinydrm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm); + +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int hx8357d_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void hx8357d_shutdown (struct spi_device *spi)
@@ -260,6 +289,7 @@ static struct spi_driver hx8357d_spi_driver = { }, .id_table = hx8357d_id, .probe = hx8357d_probe, + .remove = hx8357d_remove, .shutdown = hx8357d_shutdown, };module_spi_driver (hx8357d_spi_driver);
drivers/gpu/drm/tinydrm/ili9225.c +35 -5
@@ -24,6 +24,7 @@#include <drm/drm_damage_helper.h> #include <drm/drm_drv.h> #include <drm/drm_fb_cma_helper.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -339,6 +340,7 @@ static struct drm_driver ili9225_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, .fops = &ili9225_fops, + .release = mipi_dbi_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .name = "ili9225", .desc = "Ilitek ILI9225",
@@ -362,15 +364,25 @@ MODULE_DEVICE_TABLE(spi, ili9225_id);static int ili9225_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +struct drm_device *drm;struct mipi_dbi *mipi;struct gpio_desc *rs;u32 rotation =0 ;int ret; - mipi =devm_kzalloc (dev,sizeof (*mipi),GFP_KERNEL ); + mipi =kzalloc (sizeof (*mipi),GFP_KERNEL );if (!mipi)return -ENOMEM ; + drm = &mipi->drm; + ret =devm_drm_dev_init (dev, drm, &ili9225_driver); +if (ret) { +kfree (mipi); +return ret; + } + +drm_mode_config_init (drm); + mipi->reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (mipi->reset)) {DRM_DEV_ERROR (dev,"Failed to get gpio 'reset'\n" );
@@ -392,14 +404,31 @@ static int ili9225_probe(struct spi_device *spi)/* override the command function set in mipi_dbi_spi_init() */ mipi->command = ili9225_dbi_command; - ret =mipi_dbi_init (&spi->dev, mipi, &ili9225_pipe_funcs, - &ili9225_driver, &ili9225_mode, rotation); + ret =mipi_dbi_init (mipi, &ili9225_pipe_funcs, &ili9225_mode, rotation);if (ret)return ret; -spi_set_drvdata (spi, mipi->tinydrm.drm); +drm_mode_config_reset (drm); -return devm_tinydrm_register (&mipi->tinydrm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm); + +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int ili9225_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void ili9225_shutdown (struct spi_device *spi)
@@ -415,6 +444,7 @@ static struct spi_driver ili9225_spi_driver = { }, .id_table = ili9225_id, .probe = ili9225_probe, + .remove = ili9225_remove, .shutdown = ili9225_shutdown, };module_spi_driver (ili9225_spi_driver);
drivers/gpu/drm/tinydrm/ili9341.c +35 -5
@@ -17,6 +17,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -145,6 +146,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);static struct drm_driver ili9341_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_PRIME |DRIVER_ATOMIC , .fops = &ili9341_fops, + .release = mipi_dbi_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .debugfs_init = mipi_dbi_debugfs_init, .name ="ili9341" ,
@@ -169,15 +171,25 @@ MODULE_DEVICE_TABLE(spi, ili9341_id);static int ili9341_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +struct drm_device *drm;struct mipi_dbi *mipi;struct gpio_desc *dc;u32 rotation =0 ;int ret; - mipi =devm_kzalloc (dev,sizeof (*mipi),GFP_KERNEL ); + mipi =kzalloc (sizeof (*mipi),GFP_KERNEL );if (!mipi)return -ENOMEM ; + drm = &mipi->drm; + ret =devm_drm_dev_init (dev, drm, &ili9341_driver); +if (ret) { +kfree (mipi); +return ret; + } + +drm_mode_config_init (drm); + mipi->reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (mipi->reset)) {DRM_DEV_ERROR (dev,"Failed to get gpio 'reset'\n" );
@@ -200,14 +212,31 @@ static int ili9341_probe(struct spi_device *spi)if (ret)return ret; - ret =mipi_dbi_init (&spi->dev, mipi, &ili9341_pipe_funcs, - &ili9341_driver, &yx240qv29_mode, rotation); + ret =mipi_dbi_init (mipi, &ili9341_pipe_funcs, &yx240qv29_mode, rotation);if (ret)return ret; -spi_set_drvdata (spi, mipi->tinydrm.drm); +drm_mode_config_reset (drm); -return devm_tinydrm_register (&mipi->tinydrm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm); + +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int ili9341_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void ili9341_shutdown (struct spi_device *spi)
@@ -222,6 +251,7 @@ static struct spi_driver ili9341_spi_driver = { }, .id_table = ili9341_id, .probe = ili9341_probe, + .remove = ili9341_remove, .shutdown = ili9341_shutdown, };module_spi_driver (ili9341_spi_driver);
drivers/gpu/drm/tinydrm/mi0283qt.c +35 -5
@@ -19,6 +19,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h>
@@ -154,6 +155,7 @@ static struct drm_driver mi0283qt_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, .fops = &mi0283qt_fops, + .release = mipi_dbi_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .debugfs_init = mipi_dbi_debugfs_init, .name = "mi0283qt",
@@ -178,15 +180,25 @@ MODULE_DEVICE_TABLE(spi, mi0283qt_id);static int mi0283qt_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +struct drm_device *drm;struct mipi_dbi *mipi;struct gpio_desc *dc;u32 rotation =0 ;int ret; - mipi =devm_kzalloc (dev,sizeof (*mipi),GFP_KERNEL ); + mipi =kzalloc (sizeof (*mipi),GFP_KERNEL );if (!mipi)return -ENOMEM ; + drm = &mipi->drm; + ret =devm_drm_dev_init (dev, drm, &mi0283qt_driver); +if (ret) { +kfree (mipi); +return ret; + } + +drm_mode_config_init (drm); + mipi->reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (mipi->reset)) {DRM_DEV_ERROR (dev,"Failed to get gpio 'reset'\n" );
@@ -213,14 +225,31 @@ static int mi0283qt_probe(struct spi_device *spi)if (ret)return ret; - ret =mipi_dbi_init (&spi->dev, mipi, &mi0283qt_pipe_funcs, - &mi0283qt_driver, &mi0283qt_mode, rotation); + ret =mipi_dbi_init (mipi, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation);if (ret)return ret; -spi_set_drvdata (spi, mipi->tinydrm.drm); +drm_mode_config_reset (drm); -return devm_tinydrm_register (&mipi->tinydrm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm); + +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int mi0283qt_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void mi0283qt_shutdown (struct spi_device *spi)
@@ -253,6 +282,7 @@ static struct spi_driver mi0283qt_spi_driver = { }, .id_table = mi0283qt_id, .probe = mi0283qt_probe, + .remove = mi0283qt_remove, .shutdown = mi0283qt_shutdown, };module_spi_driver (mi0283qt_spi_driver);
drivers/gpu/drm/tinydrm/mipi-dbi.c +42 -25
129 lines not on this page · raw message
drivers/gpu/drm/tinydrm/st7586.c +60 -45
165 lines not on this page · raw message
drivers/gpu/drm/tinydrm/st7735r.c +35 -5
@@ -16,6 +16,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_drv.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/tinydrm/mipi-dbi.h>
@@ -120,6 +121,7 @@ static struct drm_driver st7735r_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, .fops = &st7735r_fops, + .release = mipi_dbi_release,DRM_GEM_CMA_VMAP_DRIVER_OPS , .debugfs_init = mipi_dbi_debugfs_init, .name = "st7735r",
@@ -144,15 +146,25 @@ MODULE_DEVICE_TABLE(spi, st7735r_id);static int st7735r_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +struct drm_device *drm;struct mipi_dbi *mipi;struct gpio_desc *dc;u32 rotation =0 ;int ret; - mipi =devm_kzalloc (dev,sizeof (*mipi),GFP_KERNEL ); + mipi =kzalloc (sizeof (*mipi),GFP_KERNEL );if (!mipi)return -ENOMEM ; + drm = &mipi->drm; + ret =devm_drm_dev_init (dev, drm, &st7735r_driver); +if (ret) { +kfree (mipi); +return ret; + } + +drm_mode_config_init (drm); + mipi->reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (mipi->reset)) {DRM_DEV_ERROR (dev,"Failed to get gpio 'reset'\n" );
@@ -178,14 +190,31 @@ static int st7735r_probe(struct spi_device *spi)/* Cannot read from Adafruit 1.8" display via SPI */ mipi->read_commands =NULL ; - ret =mipi_dbi_init (&spi->dev, mipi, &jd_t18003_t01_pipe_funcs, - &st7735r_driver, &jd_t18003_t01_mode, rotation); + ret =mipi_dbi_init (mipi, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation);if (ret)return ret; -spi_set_drvdata (spi, mipi->tinydrm.drm); +drm_mode_config_reset (drm); -return devm_tinydrm_register (&mipi->tinydrm); + ret =drm_dev_register (drm,0 ); +if (ret) +return ret; + +spi_set_drvdata (spi, drm); + +drm_fbdev_generic_setup (drm,32 ); + +return 0 ; +} + +static int st7735r_remove (struct spi_device *spi) +{ +struct drm_device *drm =spi_get_drvdata (spi); + +drm_dev_unplug (drm); +drm_atomic_helper_shutdown (drm); + +return 0 ; }static void st7735r_shutdown (struct spi_device *spi)
@@ -201,6 +230,7 @@ static struct spi_driver st7735r_spi_driver = { }, .id_table = st7735r_id, .probe = st7735r_probe, + .remove = st7735r_remove, .shutdown = st7735r_shutdown, };module_spi_driver (st7735r_spi_driver);
include/drm/tinydrm/mipi-dbi.h +17 -9
@@ -12,7 +12,9 @@#ifndef __LINUX_MIPI_DBI_H#define __LINUX_MIPI_DBI_H -#include <drm/tinydrm/tinydrm.h> +#include <linux/mutex.h> +#include <drm/drm_device.h> +#include <drm/drm_simple_kms_helper.h> struct drm_rect ;struct spi_device ;
@@ -21,7 +23,6 @@ struct regulator;/** * struct mipi_dbi - MIPI DBI controller -* @tinydrm: tinydrm base * @spi: SPI device * @enabled: Pipeline is enabled * @cmdlock: Command lock
@@ -39,7 +40,16 @@ struct regulator;* @regulator: power regulator (optional) */ struct mipi_dbi { -struct tinydrm_device tinydrm; +/** +* @drm: DRM device +*/ +struct drm_device drm; + +/** +* @pipe: Display pipe structure +*/ +struct drm_simple_display_pipe pipe; +struct spi_device *spi;bool enabled;struct mutex cmdlock;
@@ -58,17 +68,15 @@ struct mipi_dbi {static inline struct mipi_dbi *drm_to_mipi_dbi (struct drm_device *drm) { -struct tinydrm_device *tdev = drm->dev_private; - - return container_of(tdev, struct mipi_dbi, tinydrm); + return container_of(drm, struct mipi_dbi, drm); }int mipi_dbi_spi_init (struct spi_device *spi,struct mipi_dbi *mipi,struct gpio_desc *dc); -int mipi_dbi_init (struct device *dev,struct mipi_dbi *mipi, -const struct drm_simple_display_pipe_funcs *pipe_funcs, -struct drm_driver *driver, +int mipi_dbi_init (struct mipi_dbi *mipi, +const struct drm_simple_display_pipe_funcs *funcs,const struct drm_display_mode *mode,unsigned int rotation); +void mipi_dbi_release (struct drm_device *drm);void mipi_dbi_pipe_update (struct drm_simple_display_pipe *pipe,struct drm_plane_state *old_state); void mipi_dbi_enable_flush(struct mipi_dbi *mipi,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/7] drm/tinydrm: Drop using tinydrm_device
Quoted 5 lines · Noralf Trønnes
Use
devm_drm_dev_init()and drop usingtinydrm_device.v2:
devm_drm_dev_register()was dropped so add driver release callbacks.Signed-off-by Noralf Trønnes <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/tinydrm/hx8357d.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9225.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9341.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mi0283qt.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 67 +++++++++++------- drivers/gpu/drm/tinydrm/st7586.c | 105 ++++++++++++++++------------- drivers/gpu/drm/tinydrm/st7735r.c | 40 +++++++++-- include/drm/tinydrm/mipi-dbi.h | 26 ++++---
Hmm, repaper got its own patch and these are all bundled. Slightly confusing, but at the end of the day it doesn't matter much.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/7] drm/tinydrm: Drop using tinydrm_device
Den 27.02.2019 15.27, skrev Gerd Hoffmann:
Quoted 16 lines · Noralf Trønnes
Quoted 5 lines
Use
devm_drm_dev_init()and drop usingtinydrm_device.v2:
devm_drm_dev_register()was dropped so add driver release callbacks.Signed-off-by Noralf Trønnes <[email protected]>Quoted 9 lines
--- drivers/gpu/drm/tinydrm/hx8357d.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9225.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/ili9341.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mi0283qt.c | 40 +++++++++-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 67 +++++++++++------- drivers/gpu/drm/tinydrm/st7586.c | 105 ++++++++++++++++------------- drivers/gpu/drm/tinydrm/st7735r.c | 40 +++++++++-- include/drm/tinydrm/mipi-dbi.h | 26 ++++---
Quoted 3 lines
Hmm, repaper got its own patch and these are all bundled. Slightly confusing, but at the end of the day it doesn't matter much.
They had to since they all use the mipi-dbi helper which had to be changed. The repaper driver is the only one that didn't use that helper.
thanks,
Noralf.
Quoted 2 lines
Acked-by Gerd Hoffmann <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 6/7 drm/tinydrm: Remove tinydrm_device
In reply to Noralf TrønnesNo more users left so it can go alongside its helpers. Update the tinydrm docs description and remove todo entry.
--- Documentation/gpu/tinydrm.rst | 32 ++-- Documentation/gpu/todo.rst | 4 - drivers/gpu/drm/tinydrm/core/Makefile | 2 +- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 169 ------------------ .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 2 + include/drm/tinydrm/tinydrm.h | 42 ----- 6 files changed, 13 insertions(+), 238 deletions(-) delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c delete mode 100644 include/drm/tinydrm/tinydrm.h
Documentation/gpu/tinydrm.rst +10 -22
@@ -1,27 +1,12 @@ -========================== -drm/tinydrm Driver library -========================== +============================ +drm/tinydrm Tiny DRM drivers +============================ -.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c - :doc: overview +tinydrm is a collection of DRM drivers that are so small they can fit in a +single source file. -Core functionality -================== - -.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c - :doc: core - -.. kernel-doc:: include/drm/tinydrm/tinydrm.h - :internal: - -.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-core.c - :export: - -.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c - :export: - -Additional helpers -================== +Helpers +======= .. kernel-doc:: include/drm/tinydrm/tinydrm-helpers.h :internal:
@@ -29,6 +14,9 @@ Additional helpers .. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c :export: +.. kernel-doc:: drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c + :export: + MIPI DBI Compatible Controllers ===============================
Documentation/gpu/todo.rst +0 -4
@@ -469,10 +469,6 @@ those drivers as simple as possible, so lots of room for refactoring: one of the ideas for having a shared dsi/dbi helper, abstracting away the transport details more. -- Quick aside: The unregister devm stuff is kinda getting the lifetimes of - a drm_device wrong. Doesn't matter, since everyone else gets it wrong - too :-) - Contact: Noralf Trønnes, Daniel Vetter AMD DC Display Driver
drivers/gpu/drm/tinydrm/core/Makefile +1 -1
@@ -1,3 +1,3 @@ -tinydrm-y := tinydrm-core.o tinydrm-pipe.o tinydrm-helpers.o +tinydrm-y := tinydrm-pipe.o tinydrm-helpers.o obj-$(CONFIG_DRM_TINYDRM) += tinydrm.o
drivers/gpu/drm/tinydrm/core/tinydrm-core.c deleted +0 -169
169 lines not on this page · raw message
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +2 -0
@@ -365,3 +365,5 @@ int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,EXPORT_SYMBOL (tinydrm_spi_transfer);#endif /* CONFIG_SPI */ + +MODULE_LICENSE ("GPL" );
include/drm/tinydrm/tinydrm.h deleted +0 -42
42 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 7/7 drm/tinydrm: Use drm_dev_enter/exit()
In reply to Noralf TrønnesThis protects device resources from use after device removal.
There are 3 ways for driver-device unbinding to happen:
- The driver module is unloaded causing the driver to be unregistered. This can't happen as long as there are open file handles because a reference is taken on the module.
- The device is removed (Device Tree overlay unloading). This can happen at any time.
- The driver sysfs unbind file can be used to unbind the driver from the device. This can happen any time.
v2: Since drm_atomic_helper_shutdown() has to be called after
drm_dev_unplug() we don't want do block ->disable after unplug.
--- drivers/gpu/drm/tinydrm/hx8357d.c | 9 ++++-- drivers/gpu/drm/tinydrm/ili9225.c | 23 +++++++++++++-- drivers/gpu/drm/tinydrm/ili9341.c | 9 ++++-- drivers/gpu/drm/tinydrm/mi0283qt.c | 9 ++++-- drivers/gpu/drm/tinydrm/mipi-dbi.c | 42 +++++++++++++++++++++++---- drivers/gpu/drm/tinydrm/repaper.c | 46 ++++++++++++++++++++++-------- drivers/gpu/drm/tinydrm/st7586.c | 24 +++++++++++++--- drivers/gpu/drm/tinydrm/st7735r.c | 9 ++++-- 8 files changed, 139 insertions(+), 32 deletions(-)
drivers/gpu/drm/tinydrm/hx8357d.c +7 -2
@@ -50,13 +50,16 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, {struct mipi_dbi *mipi =drm_to_mipi_dbi (pipe->crtc.dev);u8 addr_mode; -int ret; +int ret, idx; + +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ;DRM_DEBUG_KMS ("\n" ); ret =mipi_dbi_poweron_conditional_reset (mipi);if (ret <0 ) -return ; + goto out_exit;if (ret ==1 ) goto out_enable;
@@ -172,6 +175,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, }mipi_dbi_command (mipi,MIPI_DCS_SET_ADDRESS_MODE , addr_mode);mipi_dbi_enable_flush (mipi, crtc_state, plane_state); +out_exit: +drm_dev_exit (idx); }static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = {
drivers/gpu/drm/tinydrm/ili9225.c +20 -3
@@ -89,13 +89,16 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)bool swap = mipi->swap_bytes;u16 x_start, y_start;u16 x1, x2, y1, y2; -int ret =0 ; +int idx, ret =0 ;bool full;void *tr;if (!mipi->enabled)return ; +if (!drm_dev_enter (fb->dev, &idx)) +return ; + full = width == fb->width && height == fb->height;DRM_DEBUG_KMS ("Flushing [FB:%d] " DRM_RECT_FMT "\n" , fb->base.id,DRM_RECT_ARG (rect));
@@ -158,6 +161,8 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) err_msg:if (ret)dev_err_once (fb->dev->dev,"Failed to update display %d\n" , ret); + +drm_dev_exit (idx); } static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -191,9 +196,12 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, .y1 = 0, .y2 = fb->height, }; -int ret; +int ret, idx;u8 am_id; +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ; +DRM_DEBUG_KMS ("\n" );mipi_dbi_hw_reset (mipi);
@@ -207,7 +215,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, ret =ili9225_command (mipi,ILI9225_POWER_CONTROL_1 ,0x0000 );if (ret) {DRM_DEV_ERROR (dev,"Error sending command %d\n" , ret); -return ; + goto out_exit; }ili9225_command (mipi,ILI9225_POWER_CONTROL_2 ,0x0000 );ili9225_command (mipi,ILI9225_POWER_CONTROL_3 ,0x0000 );
@@ -280,6 +288,8 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe, mipi->enabled = true;ili9225_fb_dirty (fb, &rect); +out_exit: +drm_dev_exit (idx); }static void ili9225_pipe_disable (struct drm_simple_display_pipe *pipe)
@@ -288,6 +298,13 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)DRM_DEBUG_KMS ("\n" ); +/* +* This callback is not protected by drm_dev_enter/exit since we want to +* turn off the display on regular driver unload. It's highly unlikely +* that the underlying SPI controller is gone should this be called after +* unplug. +*/ +if (!mipi->enabled)return ;
drivers/gpu/drm/tinydrm/ili9341.c +7 -2
@@ -56,13 +56,16 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, {struct mipi_dbi *mipi =drm_to_mipi_dbi (pipe->crtc.dev);u8 addr_mode; -int ret; +int ret, idx; + +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ;DRM_DEBUG_KMS ("\n" ); ret =mipi_dbi_poweron_conditional_reset (mipi);if (ret <0 ) -return ; + goto out_exit;if (ret ==1 ) goto out_enable;
@@ -128,6 +131,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, addr_mode |=ILI9341_MADCTL_BGR ;mipi_dbi_command (mipi,MIPI_DCS_SET_ADDRESS_MODE , addr_mode);mipi_dbi_enable_flush (mipi, crtc_state, plane_state); +out_exit: +drm_dev_exit (idx); }static const struct drm_simple_display_pipe_funcs ili9341_pipe_funcs = {
drivers/gpu/drm/tinydrm/mi0283qt.c +7 -2
@@ -58,13 +58,16 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, {struct mipi_dbi *mipi =drm_to_mipi_dbi (pipe->crtc.dev);u8 addr_mode; -int ret; +int ret, idx; + +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ;DRM_DEBUG_KMS ("\n" ); ret =mipi_dbi_poweron_conditional_reset (mipi);if (ret <0 ) -return ; + goto out_exit;if (ret ==1 ) goto out_enable;
@@ -136,6 +139,8 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, addr_mode |=ILI9341_MADCTL_BGR ;mipi_dbi_command (mipi,MIPI_DCS_SET_ADDRESS_MODE , addr_mode);mipi_dbi_enable_flush (mipi, crtc_state, plane_state); +out_exit: +drm_dev_exit (idx); }static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
drivers/gpu/drm/tinydrm/mipi-dbi.c +37 -5
115 lines not on this page · raw message
drivers/gpu/drm/tinydrm/repaper.c +34 -12
119 lines not on this page · raw message
drivers/gpu/drm/tinydrm/st7586.c +20 -4
@@ -119,12 +119,14 @@ static int st7586_buf_copy(void *dst, struct drm_framebuffer *fb,static void st7586_fb_dirty (struct drm_framebuffer *fb,struct drm_rect *rect) {struct mipi_dbi *mipi =drm_to_mipi_dbi (fb->dev); -int start, end; -int ret =0 ; +int start, end, idx, ret =0 ;if (!mipi->enabled)return ; +if (!drm_dev_enter (fb->dev, &idx)) +return ; +/* 3 pixels per byte, so grow clip to nearest multiple of 3 */ rect->x1 =rounddown (rect->x1,3 ); rect->x2 =roundup (rect->x2,3 );
@@ -152,6 +154,8 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) err_msg:if (ret)dev_err_once (fb->dev->dev,"Failed to update display %d\n" , ret); + +drm_dev_exit (idx); } static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -184,14 +188,17 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe, .y1 = 0, .y2 = fb->height, }; -int ret; +int idx, ret;u8 addr_mode; +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ; +DRM_DEBUG_KMS ("\n" ); ret =mipi_dbi_poweron_reset (mipi);if (ret) -return ; + goto out_exit;mipi_dbi_command (mipi,ST7586_AUTO_READ_CTRL ,0x9f );mipi_dbi_command (mipi,ST7586_OTP_RW_CTRL ,0x00 );
@@ -244,12 +251,21 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,st7586_fb_dirty (fb, &rect);mipi_dbi_command (mipi,MIPI_DCS_SET_DISPLAY_ON ); +out_exit: +drm_dev_exit (idx); }static void st7586_pipe_disable (struct drm_simple_display_pipe *pipe) {struct mipi_dbi *mipi =drm_to_mipi_dbi (pipe->crtc.dev); +/* +* This callback is not protected by drm_dev_enter/exit since we want to +* turn off the display on regular driver unload. It's highly unlikely +* that the underlying SPI controller is gone should this be called after +* unplug. +*/ +DRM_DEBUG_KMS ("\n" );if (!mipi->enabled)
drivers/gpu/drm/tinydrm/st7735r.c +7 -2
@@ -44,14 +44,17 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) {struct mipi_dbi *mipi =drm_to_mipi_dbi (pipe->crtc.dev); -int ret; +int ret, idx;u8 addr_mode; +if (!drm_dev_enter (pipe->crtc.dev, &idx)) +return ; +DRM_DEBUG_KMS ("\n" ); ret =mipi_dbi_poweron_reset (mipi);if (ret) -return ; + goto out_exit;msleep (150 );
@@ -102,6 +105,8 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe,msleep (20 );mipi_dbi_enable_flush (mipi, crtc_state, plane_state); +out_exit: +drm_dev_exit (idx); }static const struct drm_simple_display_pipe_funcs jd_t18003_t01_pipe_funcs = {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 7/7] drm/tinydrm: Use drm_dev_enter/exit()
Quoted 11 lines · Noralf Trønnes
This protects device resources from use after device removal.
There are 3 ways for driver-device unbinding to happen:
- The driver module is unloaded causing the driver to be unregistered. This can't happen as long as there are open file handles because a reference is taken on the module.
- The device is removed (Device Tree overlay unloading). This can happen at any time.
- The driver sysfs unbind file can be used to unbind the driver from the device. This can happen any time.
Quoted 4 lines
v2: Since
drm_atomic_helper_shutdown()has to be called afterdrm_dev_unplug() we don't want do block ->disable after unplug.Signed-off-by Noralf Trønnes <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm/tinydrm: Remove tinydrm_device
In reply to Noralf Trønnes== Series Details ==
== Series Details ==
Series: drm/tinydrm: Remove tinydrm_device
URL : https://patchwork.freedesktop.org/series/57197/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 686f06d66ef6 drm/drv: Hold ref on parent device during drm_device lifetime 979fb6bd33a0 drm: Add devm_drm_dev_init() 8691cebfab70 drm/drv: DOC: Add driver example code a7e4739b705b drm/tinydrm/repaper: Drop using tinydrm_device 4b763346fbfd drm/tinydrm: Drop using tinydrm_device 39722f3c2a91 drm/tinydrm: Remove tinydrm_device -:24: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #24: FILE: Documentation/gpu/tinydrm.rst:1: +============================
-:89: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #89:
deleted file mode 100644
total: 0 errors, 2 warnings, 0 checks, 62 lines checked f0ad6397e686 drm/tinydrm: Use drm_dev_enter/exit()
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/tinydrm: Remove tinydrm_device
In reply to Noralf Trønnes== Series Details ==
== Series Details ==
Series: drm/tinydrm: Remove tinydrm_device
URL : https://patchwork.freedesktop.org/series/57197/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5658 -> Patchwork_12297
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57197/revisions/1/mbox/
Known issues
------------
Here are the changes found in Patchwork_12297 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@cs-compute:
- fi-kbl-8809g: NOTRUN -> FAIL [fdo#108094]
* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]
#### Possible fixes ####
* igt@amdgpu/amd_basic@userptr:
- fi-kbl-8809g: DMESG-WARN [fdo#108965] -> PASS
* igt@i915_selftest@live_execlists:
- fi-apl-guc: INCOMPLETE [fdo#103927] / [fdo#109720] -> PASS
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: WARN [fdo#109380] -> PASS
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c:
- fi-kbl-7567u: SKIP [fdo#109271] -> PASS +33
#### Warnings ####
* igt@i915_selftest@live_contexts:
- fi-icl-u2: DMESG-FAIL [fdo#108569] -> INCOMPLETE [fdo#108569]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105998]: https://bugs.freedesktop.org/show_bug.cgi?id=105998
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108094]: https://bugs.freedesktop.org/show_bug.cgi?id=108094
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109294]: https://bugs.freedesktop.org/show_bug.cgi?id=109294
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109380]: https://bugs.freedesktop.org/show_bug.cgi?id=109380
[fdo#109527]: https://bugs.freedesktop.org/show_bug.cgi?id=109527
[fdo#109528]: https://bugs.freedesktop.org/show_bug.cgi?id=109528
[fdo#109530]: https://bugs.freedesktop.org/show_bug.cgi?id=109530
[fdo#109567]: https://bugs.freedesktop.org/show_bug.cgi?id=109567
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
Participating hosts (44 -> 40)
------------------------------
Additional (1): fi-icl-y
Missing (5): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600
Build changes
-------------
* Linux: CI_DRM_5658 -> Patchwork_12297
CI_DRM_5658: dc6f5e9c1239d7a4b77e31cfaca48873692d579f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4854: 06b0830fb948b9b632342cd26100342aa01cbc79 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12297: f0ad6397e686c6adebb480863a1acfc140266b72 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
f0ad6397e686 drm/tinydrm: Use drm_dev_enter/exit() 39722f3c2a91 drm/tinydrm: Remove tinydrm_device4b763346fbfd drm/tinydrm: Drop using tinydrm_device a7e4739b705b drm/tinydrm/repaper: Drop using tinydrm_device 8691cebfab70 drm/drv: DOC: Add driver example code 979fb6bd33a0 drm: Add devm_drm_dev_init()686f06d66ef6 drm/drv: Hold ref on parent device during drm_device lifetime
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12297/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/tinydrm: Remove tinydrm_device
In reply to Noralf Trønnes== Series Details ==
== Series Details ==
Series: drm/tinydrm: Remove tinydrm_device
URL : https://patchwork.freedesktop.org/series/57197/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5658_full -> Patchwork_12297_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_12297_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_schedule@preemptive-hang-bsd2:
- shard-hsw: NOTRUN -> SKIP [fdo#109271] +32
* igt@i915_pm_rpm@i2c:
- shard-iclb: PASS -> DMESG-WARN [fdo#107724] +2
* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-iclb: PASS -> INCOMPLETE [fdo#107713]
* igt@kms_busy@basic-modeset-e:
- shard-snb: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +1
* igt@kms_busy@extended-modeset-hang-newfb-render-a:
- shard-snb: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_cursor_crc@cursor-256x256-suspend:
- shard-apl: PASS -> FAIL [fdo#103191] / [fdo#103232]
* igt@kms_cursor_crc@cursor-512x512-random:
- shard-apl: NOTRUN -> SKIP [fdo#109271] +2
* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-apl: PASS -> DMESG-WARN [fdo#108566]
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy:
- shard-hsw: PASS -> FAIL [fdo#105767]
* igt@kms_flip@flip-vs-expired-vblank:
- shard-iclb: PASS -> FAIL [fdo#105363]
* igt@kms_flip@single-buffer-flip-vs-dpms-off-vs-modeset:
- shard-kbl: PASS -> DMESG-WARN [fdo#103558] / [fdo#105602] +11
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
- shard-glk: PASS -> FAIL [fdo#103167] +1
* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-iclb: PASS -> FAIL [fdo#103167]
* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-apl: PASS -> FAIL [fdo#103166]
* igt@kms_plane_alpha_blend@pipe-a-alpha-7efc:
- shard-hsw: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2
* igt@kms_plane_multiple@atomic-pipe-a-tiling-none:
- shard-iclb: PASS -> FAIL [fdo#103166] +1
* igt@kms_plane_multiple@atomic-pipe-b-tiling-none:
- shard-glk: PASS -> FAIL [fdo#103166]
* igt@kms_setmode@basic:
- shard-kbl: PASS -> FAIL [fdo#99912]
* igt@perf_pmu@busy-check-all-vecs0:
- shard-snb: NOTRUN -> SKIP [fdo#109271] +35
#### Possible fixes ####
* igt@i915_pm_rpm@cursor-dpms:
- shard-iclb: DMESG-WARN [fdo#107724] -> PASS +2
* igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
- shard-apl: FAIL [fdo#106510] / [fdo#108145] -> PASS
* igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy:
- shard-glk: FAIL [fdo#104873] -> PASS
* igt@kms_cursor_legacy@pipe-c-torture-bo:
- shard-hsw: DMESG-WARN [fdo#107122] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-blt:
- shard-apl: FAIL [fdo#103167] -> PASS +1
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: FAIL [fdo#103167] -> PASS +3
* igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-blt:
- shard-iclb: FAIL [fdo#103167] -> PASS +2
* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-apl: FAIL [fdo#108948] -> PASS
* igt@tools_test@tools_test:
- shard-iclb: SKIP [fdo#109352] -> PASS
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#104873]: https://bugs.freedesktop.org/show_bug.cgi?id=104873
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#106510]: https://bugs.freedesktop.org/show_bug.cgi?id=106510
[fdo#107122]: https://bugs.freedesktop.org/show_bug.cgi?id=107122
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109352]: https://bugs.freedesktop.org/show_bug.cgi?id=109352
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
Participating hosts (7 -> 6)
------------------------------
Missing (1): shard-skl
Build changes
-------------
* Linux: CI_DRM_5658 -> Patchwork_12297
CI_DRM_5658: dc6f5e9c1239d7a4b77e31cfaca48873692d579f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4854: 06b0830fb948b9b632342cd26100342aa01cbc79 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12297: f0ad6397e686c6adebb480863a1acfc140266b72 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12297/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Den 25.02.2019 15.42, skrev Noralf Trønnes:
Quoted 14 lines
This patchset is part of the effort to remove tinydrm.ko. It removes struct
tinydrm_deviceandtinydrm.h.Only one change in this version and that is expanding the driver example.
The
drm_dev_unplug()dependency series has been applied together with some patches from the previous version.I've cc'ed intel-gfx so the Intel CI can verify the parent device ref patch.
Noralf.
Quoted 9 lines
Noralf Trønnes (7):
drm/drv: Hold ref on parent device duringdrm_devicelifetime
drm: Adddevm_drm_dev_init()
drm/drv: DOC: Add driver example code drm/tinydrm/repaper: Drop usingtinydrm_devicedrm/tinydrm: Drop usingtinydrm_device
drm/tinydrm: Removetinydrm_device
drm/tinydrm: Use drm_dev_enter/exit()
Series is applied to drm-misc-next, thanks for reviewing!
Noralf.
Quoted 13 lines
Documentation/driver-model/devres.txt | 3 + Documentation/gpu/tinydrm.rst | 32 +--- Documentation/gpu/todo.rst | 4 - drivers/gpu/drm/drm_drv.c | 176 +++++++++++++++++- drivers/gpu/drm/tinydrm/core/Makefile | 2 +- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 169 ----------------- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 2 + drivers/gpu/drm/tinydrm/hx8357d.c | 49 ++++- drivers/gpu/drm/tinydrm/ili9225.c | 63 ++++++- drivers/gpu/drm/tinydrm/ili9341.c | 49 ++++- drivers/gpu/drm/tinydrm/mi0283qt.c | 49 ++++- drivers/gpu/drm/tinydrm/mipi-dbi.c | 109 ++++++++--- drivers/gpu/drm/tinydrm/repaper.c | 130 +++++++++----
Quoted 9 lines
drivers/gpu/drm/tinydrm/st7586.c | 129 ++++++++----- drivers/gpu/drm/tinydrm/st7735r.c | 49 ++++- include/drm/drm_drv.h | 3 + include/drm/tinydrm/mipi-dbi.h | 26 ++- include/drm/tinydrm/tinydrm.h | 42 ----- 18 files changed, 688 insertions(+), 398 deletions(-) delete mode 100644 drivers/gpu/drm/tinydrm/core/tinydrm-core.c delete mode 100644 include/drm/tinydrm/tinydrm.h
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel