All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
@ 2022-10-26 15:34 ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: dri-devel, linux-kernel, Danilo Krummrich

Hi,

This patch series converts the driver to use drm managed resources to prevent
potential use-after-free issues on driver unbind/rebind and to get rid of the
usage of deprecated APIs.

Changes in v2:
  - drop patch "drm/arm/hdlcd: crtc: use drmm_crtc_init_with_planes()"

Changes in v3:
  - Fix alternate return paths in srcu read-side critical sections causing a
    stall when unregistering the driver.
  - Fix potential null pointer dereference in hdlcd_crtc_cleanup() introduced
    dropping the patch in v2.
  - Add a patch to remove explicit calls to drm_mode_config_cleanup().

Changes in v4:
  - Remove patches to protect platform device bound resources with
    drm_dev_{enter,exit}, since this would leave the hardware enabled when
    regularly unloading the driver e.g. via rmmod.
    Instead do this in a later series, once we got drm_dev_unplug() in place
    to deal with a regular driver shutdown.

Danilo Krummrich (4):
  drm/arm/hdlcd: use drmm_* to allocate driver structures
  drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
  drm/arm/hdlcd: plane: use drm managed resources
  drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()

 drivers/gpu/drm/arm/hdlcd_crtc.c | 24 +++++++------------
 drivers/gpu/drm/arm/hdlcd_drv.c  | 41 ++++++++++++++++----------------
 drivers/gpu/drm/arm/hdlcd_drv.h  |  2 ++
 3 files changed, 32 insertions(+), 35 deletions(-)


base-commit: e1e7bc481d49c3e3ada11029ce0d9b85a0a539d7
-- 
2.37.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
@ 2022-10-26 15:34 ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: Danilo Krummrich, linux-kernel, dri-devel

Hi,

This patch series converts the driver to use drm managed resources to prevent
potential use-after-free issues on driver unbind/rebind and to get rid of the
usage of deprecated APIs.

Changes in v2:
  - drop patch "drm/arm/hdlcd: crtc: use drmm_crtc_init_with_planes()"

Changes in v3:
  - Fix alternate return paths in srcu read-side critical sections causing a
    stall when unregistering the driver.
  - Fix potential null pointer dereference in hdlcd_crtc_cleanup() introduced
    dropping the patch in v2.
  - Add a patch to remove explicit calls to drm_mode_config_cleanup().

Changes in v4:
  - Remove patches to protect platform device bound resources with
    drm_dev_{enter,exit}, since this would leave the hardware enabled when
    regularly unloading the driver e.g. via rmmod.
    Instead do this in a later series, once we got drm_dev_unplug() in place
    to deal with a regular driver shutdown.

Danilo Krummrich (4):
  drm/arm/hdlcd: use drmm_* to allocate driver structures
  drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
  drm/arm/hdlcd: plane: use drm managed resources
  drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()

 drivers/gpu/drm/arm/hdlcd_crtc.c | 24 +++++++------------
 drivers/gpu/drm/arm/hdlcd_drv.c  | 41 ++++++++++++++++----------------
 drivers/gpu/drm/arm/hdlcd_drv.h  |  2 ++
 3 files changed, 32 insertions(+), 35 deletions(-)


base-commit: e1e7bc481d49c3e3ada11029ce0d9b85a0a539d7
-- 
2.37.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 1/4] drm/arm/hdlcd: use drmm_* to allocate driver structures
  2022-10-26 15:34 ` Danilo Krummrich
@ 2022-10-26 15:34   ` Danilo Krummrich
  -1 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: dri-devel, linux-kernel, Danilo Krummrich

Use drm managed resources to allocate driver structures and get rid of
the deprecated drm_dev_alloc() call and replace it with
devm_drm_dev_alloc().

This also serves as preparation to get rid of drm_device->dev_private
and to fix use-after-free issues on driver unload.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 12 ++++--------
 drivers/gpu/drm/arm/hdlcd_drv.h |  1 +
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index a032003c340c..463381d11cff 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -247,13 +247,11 @@ static int hdlcd_drm_bind(struct device *dev)
 	struct hdlcd_drm_private *hdlcd;
 	int ret;
 
-	hdlcd = devm_kzalloc(dev, sizeof(*hdlcd), GFP_KERNEL);
-	if (!hdlcd)
-		return -ENOMEM;
+	hdlcd = devm_drm_dev_alloc(dev, &hdlcd_driver, typeof(*hdlcd), base);
+	if (IS_ERR(hdlcd))
+		return PTR_ERR(hdlcd);
 
-	drm = drm_dev_alloc(&hdlcd_driver, dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	drm = &hdlcd->base;
 
 	drm->dev_private = hdlcd;
 	dev_set_drvdata(dev, drm);
@@ -319,7 +317,6 @@ static int hdlcd_drm_bind(struct device *dev)
 err_free:
 	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
-	drm_dev_put(drm);
 
 	return ret;
 }
@@ -344,7 +341,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 	drm_mode_config_cleanup(drm);
 	drm->dev_private = NULL;
 	dev_set_drvdata(dev, NULL);
-	drm_dev_put(drm);
 }
 
 static const struct component_master_ops hdlcd_master_ops = {
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h
index 909c39c28487..3892b36767ac 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.h
+++ b/drivers/gpu/drm/arm/hdlcd_drv.h
@@ -7,6 +7,7 @@
 #define __HDLCD_DRV_H__
 
 struct hdlcd_drm_private {
+	struct drm_device		base;
 	void __iomem			*mmio;
 	struct clk			*clk;
 	struct drm_crtc			crtc;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 1/4] drm/arm/hdlcd: use drmm_* to allocate driver structures
@ 2022-10-26 15:34   ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: Danilo Krummrich, linux-kernel, dri-devel

Use drm managed resources to allocate driver structures and get rid of
the deprecated drm_dev_alloc() call and replace it with
devm_drm_dev_alloc().

This also serves as preparation to get rid of drm_device->dev_private
and to fix use-after-free issues on driver unload.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 12 ++++--------
 drivers/gpu/drm/arm/hdlcd_drv.h |  1 +
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index a032003c340c..463381d11cff 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -247,13 +247,11 @@ static int hdlcd_drm_bind(struct device *dev)
 	struct hdlcd_drm_private *hdlcd;
 	int ret;
 
-	hdlcd = devm_kzalloc(dev, sizeof(*hdlcd), GFP_KERNEL);
-	if (!hdlcd)
-		return -ENOMEM;
+	hdlcd = devm_drm_dev_alloc(dev, &hdlcd_driver, typeof(*hdlcd), base);
+	if (IS_ERR(hdlcd))
+		return PTR_ERR(hdlcd);
 
-	drm = drm_dev_alloc(&hdlcd_driver, dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	drm = &hdlcd->base;
 
 	drm->dev_private = hdlcd;
 	dev_set_drvdata(dev, drm);
@@ -319,7 +317,6 @@ static int hdlcd_drm_bind(struct device *dev)
 err_free:
 	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
-	drm_dev_put(drm);
 
 	return ret;
 }
@@ -344,7 +341,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 	drm_mode_config_cleanup(drm);
 	drm->dev_private = NULL;
 	dev_set_drvdata(dev, NULL);
-	drm_dev_put(drm);
 }
 
 static const struct component_master_ops hdlcd_master_ops = {
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h
index 909c39c28487..3892b36767ac 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.h
+++ b/drivers/gpu/drm/arm/hdlcd_drv.h
@@ -7,6 +7,7 @@
 #define __HDLCD_DRV_H__
 
 struct hdlcd_drm_private {
+	struct drm_device		base;
 	void __iomem			*mmio;
 	struct clk			*clk;
 	struct drm_crtc			crtc;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 2/4] drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
  2022-10-26 15:34 ` Danilo Krummrich
@ 2022-10-26 15:34   ` Danilo Krummrich
  -1 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: dri-devel, linux-kernel, Danilo Krummrich

Using drm_device->dev_private is deprecated. Since we've switched to
devm_drm_dev_alloc(), struct drm_device is now embedded in struct
hdlcd_drm_private, hence we can use container_of() to get the struct
drm_device instance instead.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c |  6 +++---
 drivers/gpu/drm/arm/hdlcd_drv.c  | 10 ++++------
 drivers/gpu/drm/arm/hdlcd_drv.h  |  1 +
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 7030339fa232..2055b1abcec3 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -275,7 +275,7 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
 	dest_h = drm_rect_height(&new_plane_state->dst);
 	scanout_start = drm_fb_dma_get_gem_addr(fb, new_plane_state, 0);
 
-	hdlcd = plane->dev->dev_private;
+	hdlcd = drm_to_hdlcd_priv(plane->dev);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, fb->pitches[0]);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, dest_h - 1);
@@ -298,7 +298,7 @@ static const struct drm_plane_funcs hdlcd_plane_funcs = {
 
 static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *plane = NULL;
 	u32 formats[ARRAY_SIZE(supported_formats)], i;
 	int ret;
@@ -325,7 +325,7 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 
 int hdlcd_setup_crtc(struct drm_device *drm)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *primary;
 	int ret;
 
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 463381d11cff..120c87934a91 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -98,7 +98,7 @@ static void hdlcd_irq_uninstall(struct hdlcd_drm_private *hdlcd)
 
 static int hdlcd_load(struct drm_device *drm, unsigned long flags)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct resource *res;
 	u32 version;
@@ -190,7 +190,7 @@ static int hdlcd_show_underrun_count(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 
 	seq_printf(m, "underrun : %d\n", atomic_read(&hdlcd->buffer_underrun_count));
 	seq_printf(m, "dma_end  : %d\n", atomic_read(&hdlcd->dma_end_count));
@@ -203,7 +203,7 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	unsigned long clkrate = clk_get_rate(hdlcd->clk);
 	unsigned long mode_clock = hdlcd->crtc.mode.crtc_clock * 1000;
 
@@ -253,7 +253,6 @@ static int hdlcd_drm_bind(struct device *dev)
 
 	drm = &hdlcd->base;
 
-	drm->dev_private = hdlcd;
 	dev_set_drvdata(dev, drm);
 
 	hdlcd_setup_mode_config(drm);
@@ -324,7 +323,7 @@ static int hdlcd_drm_bind(struct device *dev)
 static void hdlcd_drm_unbind(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 
 	drm_dev_unregister(drm);
 	drm_kms_helper_poll_fini(drm);
@@ -339,7 +338,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 		pm_runtime_disable(dev);
 	of_reserved_mem_device_release(dev);
 	drm_mode_config_cleanup(drm);
-	drm->dev_private = NULL;
 	dev_set_drvdata(dev, NULL);
 }
 
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h
index 3892b36767ac..f1c1da2ac2db 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.h
+++ b/drivers/gpu/drm/arm/hdlcd_drv.h
@@ -21,6 +21,7 @@ struct hdlcd_drm_private {
 #endif
 };
 
+#define drm_to_hdlcd_priv(x)	container_of(x, struct hdlcd_drm_private, base)
 #define crtc_to_hdlcd_priv(x)	container_of(x, struct hdlcd_drm_private, crtc)
 
 static inline void hdlcd_write(struct hdlcd_drm_private *hdlcd,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 2/4] drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
@ 2022-10-26 15:34   ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: Danilo Krummrich, linux-kernel, dri-devel

Using drm_device->dev_private is deprecated. Since we've switched to
devm_drm_dev_alloc(), struct drm_device is now embedded in struct
hdlcd_drm_private, hence we can use container_of() to get the struct
drm_device instance instead.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c |  6 +++---
 drivers/gpu/drm/arm/hdlcd_drv.c  | 10 ++++------
 drivers/gpu/drm/arm/hdlcd_drv.h  |  1 +
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 7030339fa232..2055b1abcec3 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -275,7 +275,7 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
 	dest_h = drm_rect_height(&new_plane_state->dst);
 	scanout_start = drm_fb_dma_get_gem_addr(fb, new_plane_state, 0);
 
-	hdlcd = plane->dev->dev_private;
+	hdlcd = drm_to_hdlcd_priv(plane->dev);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, fb->pitches[0]);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, dest_h - 1);
@@ -298,7 +298,7 @@ static const struct drm_plane_funcs hdlcd_plane_funcs = {
 
 static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *plane = NULL;
 	u32 formats[ARRAY_SIZE(supported_formats)], i;
 	int ret;
@@ -325,7 +325,7 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 
 int hdlcd_setup_crtc(struct drm_device *drm)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *primary;
 	int ret;
 
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 463381d11cff..120c87934a91 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -98,7 +98,7 @@ static void hdlcd_irq_uninstall(struct hdlcd_drm_private *hdlcd)
 
 static int hdlcd_load(struct drm_device *drm, unsigned long flags)
 {
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct resource *res;
 	u32 version;
@@ -190,7 +190,7 @@ static int hdlcd_show_underrun_count(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 
 	seq_printf(m, "underrun : %d\n", atomic_read(&hdlcd->buffer_underrun_count));
 	seq_printf(m, "dma_end  : %d\n", atomic_read(&hdlcd->dma_end_count));
@@ -203,7 +203,7 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	unsigned long clkrate = clk_get_rate(hdlcd->clk);
 	unsigned long mode_clock = hdlcd->crtc.mode.crtc_clock * 1000;
 
@@ -253,7 +253,6 @@ static int hdlcd_drm_bind(struct device *dev)
 
 	drm = &hdlcd->base;
 
-	drm->dev_private = hdlcd;
 	dev_set_drvdata(dev, drm);
 
 	hdlcd_setup_mode_config(drm);
@@ -324,7 +323,7 @@ static int hdlcd_drm_bind(struct device *dev)
 static void hdlcd_drm_unbind(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct hdlcd_drm_private *hdlcd = drm->dev_private;
+	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 
 	drm_dev_unregister(drm);
 	drm_kms_helper_poll_fini(drm);
@@ -339,7 +338,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 		pm_runtime_disable(dev);
 	of_reserved_mem_device_release(dev);
 	drm_mode_config_cleanup(drm);
-	drm->dev_private = NULL;
 	dev_set_drvdata(dev, NULL);
 }
 
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.h b/drivers/gpu/drm/arm/hdlcd_drv.h
index 3892b36767ac..f1c1da2ac2db 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.h
+++ b/drivers/gpu/drm/arm/hdlcd_drv.h
@@ -21,6 +21,7 @@ struct hdlcd_drm_private {
 #endif
 };
 
+#define drm_to_hdlcd_priv(x)	container_of(x, struct hdlcd_drm_private, base)
 #define crtc_to_hdlcd_priv(x)	container_of(x, struct hdlcd_drm_private, crtc)
 
 static inline void hdlcd_write(struct hdlcd_drm_private *hdlcd,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 3/4] drm/arm/hdlcd: plane: use drm managed resources
  2022-10-26 15:34 ` Danilo Krummrich
@ 2022-10-26 15:34   ` Danilo Krummrich
  -1 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: dri-devel, linux-kernel, Danilo Krummrich

Use drm managed resource allocation (drmm_universal_plane_alloc()) in
order to get rid of the explicit destroy hook in struct drm_plane_funcs.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 2055b1abcec3..1de0f7b23766 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -290,7 +290,6 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = {
 static const struct drm_plane_funcs hdlcd_plane_funcs = {
 	.update_plane		= drm_atomic_helper_update_plane,
 	.disable_plane		= drm_atomic_helper_disable_plane,
-	.destroy		= drm_plane_cleanup,
 	.reset			= drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
@@ -301,21 +300,16 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *plane = NULL;
 	u32 formats[ARRAY_SIZE(supported_formats)], i;
-	int ret;
-
-	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++)
 		formats[i] = supported_formats[i].fourcc;
 
-	ret = drm_universal_plane_init(drm, plane, 0xff, &hdlcd_plane_funcs,
-				       formats, ARRAY_SIZE(formats),
-				       NULL,
-				       DRM_PLANE_TYPE_PRIMARY, NULL);
-	if (ret)
-		return ERR_PTR(ret);
+	plane = drmm_universal_plane_alloc(drm, struct drm_plane, dev, 0xff,
+					   &hdlcd_plane_funcs,
+					   formats, ARRAY_SIZE(formats),
+					   NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (IS_ERR(plane))
+		return plane;
 
 	drm_plane_helper_add(plane, &hdlcd_plane_helper_funcs);
 	hdlcd->plane = plane;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 3/4] drm/arm/hdlcd: plane: use drm managed resources
@ 2022-10-26 15:34   ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: Danilo Krummrich, linux-kernel, dri-devel

Use drm managed resource allocation (drmm_universal_plane_alloc()) in
order to get rid of the explicit destroy hook in struct drm_plane_funcs.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 2055b1abcec3..1de0f7b23766 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -290,7 +290,6 @@ static const struct drm_plane_helper_funcs hdlcd_plane_helper_funcs = {
 static const struct drm_plane_funcs hdlcd_plane_funcs = {
 	.update_plane		= drm_atomic_helper_update_plane,
 	.disable_plane		= drm_atomic_helper_disable_plane,
-	.destroy		= drm_plane_cleanup,
 	.reset			= drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
@@ -301,21 +300,16 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
 	struct hdlcd_drm_private *hdlcd = drm_to_hdlcd_priv(drm);
 	struct drm_plane *plane = NULL;
 	u32 formats[ARRAY_SIZE(supported_formats)], i;
-	int ret;
-
-	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++)
 		formats[i] = supported_formats[i].fourcc;
 
-	ret = drm_universal_plane_init(drm, plane, 0xff, &hdlcd_plane_funcs,
-				       formats, ARRAY_SIZE(formats),
-				       NULL,
-				       DRM_PLANE_TYPE_PRIMARY, NULL);
-	if (ret)
-		return ERR_PTR(ret);
+	plane = drmm_universal_plane_alloc(drm, struct drm_plane, dev, 0xff,
+					   &hdlcd_plane_funcs,
+					   formats, ARRAY_SIZE(formats),
+					   NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (IS_ERR(plane))
+		return plane;
 
 	drm_plane_helper_add(plane, &hdlcd_plane_helper_funcs);
 	hdlcd->plane = plane;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 4/4] drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()
  2022-10-26 15:34 ` Danilo Krummrich
@ 2022-10-26 15:34   ` Danilo Krummrich
  -1 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: dri-devel, linux-kernel, Danilo Krummrich

drm_mode_config_init() simply calls drmm_mode_config_init(), hence
cleanup is automatically handled through registering
drm_mode_config_cleanup() with drmm_add_action_or_reset().

While at it, get rid of the deprecated drm_mode_config_init() and
replace it with drmm_mode_config_init() directly.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 120c87934a91..49c977cdae40 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -175,14 +175,21 @@ static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void hdlcd_setup_mode_config(struct drm_device *drm)
+static int hdlcd_setup_mode_config(struct drm_device *drm)
 {
-	drm_mode_config_init(drm);
+	int ret;
+
+	ret = drmm_mode_config_init(drm);
+	if (ret)
+		return ret;
+
 	drm->mode_config.min_width = 0;
 	drm->mode_config.min_height = 0;
 	drm->mode_config.max_width = HDLCD_MAX_XRES;
 	drm->mode_config.max_height = HDLCD_MAX_YRES;
 	drm->mode_config.funcs = &hdlcd_mode_config_funcs;
+
+	return 0;
 }
 
 #ifdef CONFIG_DEBUG_FS
@@ -255,7 +262,10 @@ static int hdlcd_drm_bind(struct device *dev)
 
 	dev_set_drvdata(dev, drm);
 
-	hdlcd_setup_mode_config(drm);
+	ret = hdlcd_setup_mode_config(drm);
+	if (ret)
+		goto err_free;
+
 	ret = hdlcd_load(drm, 0);
 	if (ret)
 		goto err_free;
@@ -314,9 +324,7 @@ static int hdlcd_drm_bind(struct device *dev)
 	hdlcd_irq_uninstall(hdlcd);
 	of_reserved_mem_device_release(drm->dev);
 err_free:
-	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
-
 	return ret;
 }
 
@@ -337,7 +345,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 	if (pm_runtime_enabled(dev))
 		pm_runtime_disable(dev);
 	of_reserved_mem_device_release(dev);
-	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
 }
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH drm-misc-next v4 4/4] drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()
@ 2022-10-26 15:34   ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-10-26 15:34 UTC (permalink / raw)
  To: daniel, airlied, tzimmermann, mripard, liviu.dudau, brian.starkey
  Cc: Danilo Krummrich, linux-kernel, dri-devel

drm_mode_config_init() simply calls drmm_mode_config_init(), hence
cleanup is automatically handled through registering
drm_mode_config_cleanup() with drmm_add_action_or_reset().

While at it, get rid of the deprecated drm_mode_config_init() and
replace it with drmm_mode_config_init() directly.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 120c87934a91..49c977cdae40 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -175,14 +175,21 @@ static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void hdlcd_setup_mode_config(struct drm_device *drm)
+static int hdlcd_setup_mode_config(struct drm_device *drm)
 {
-	drm_mode_config_init(drm);
+	int ret;
+
+	ret = drmm_mode_config_init(drm);
+	if (ret)
+		return ret;
+
 	drm->mode_config.min_width = 0;
 	drm->mode_config.min_height = 0;
 	drm->mode_config.max_width = HDLCD_MAX_XRES;
 	drm->mode_config.max_height = HDLCD_MAX_YRES;
 	drm->mode_config.funcs = &hdlcd_mode_config_funcs;
+
+	return 0;
 }
 
 #ifdef CONFIG_DEBUG_FS
@@ -255,7 +262,10 @@ static int hdlcd_drm_bind(struct device *dev)
 
 	dev_set_drvdata(dev, drm);
 
-	hdlcd_setup_mode_config(drm);
+	ret = hdlcd_setup_mode_config(drm);
+	if (ret)
+		goto err_free;
+
 	ret = hdlcd_load(drm, 0);
 	if (ret)
 		goto err_free;
@@ -314,9 +324,7 @@ static int hdlcd_drm_bind(struct device *dev)
 	hdlcd_irq_uninstall(hdlcd);
 	of_reserved_mem_device_release(drm->dev);
 err_free:
-	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
-
 	return ret;
 }
 
@@ -337,7 +345,6 @@ static void hdlcd_drm_unbind(struct device *dev)
 	if (pm_runtime_enabled(dev))
 		pm_runtime_disable(dev);
 	of_reserved_mem_device_release(dev);
-	drm_mode_config_cleanup(drm);
 	dev_set_drvdata(dev, NULL);
 }
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
  2022-10-26 15:34 ` Danilo Krummrich
@ 2022-11-04 18:20   ` Liviu Dudau
  -1 siblings, 0 replies; 16+ messages in thread
From: Liviu Dudau @ 2022-11-04 18:20 UTC (permalink / raw)
  To: Danilo Krummrich; +Cc: airlied, linux-kernel, dri-devel, tzimmermann

On Wed, Oct 26, 2022 at 05:34:27PM +0200, Danilo Krummrich wrote:
> Hi,

Hi Danilo,

> 
> This patch series converts the driver to use drm managed resources to prevent
> potential use-after-free issues on driver unbind/rebind and to get rid of the
> usage of deprecated APIs.
> 
> Changes in v2:
>   - drop patch "drm/arm/hdlcd: crtc: use drmm_crtc_init_with_planes()"
> 
> Changes in v3:
>   - Fix alternate return paths in srcu read-side critical sections causing a
>     stall when unregistering the driver.
>   - Fix potential null pointer dereference in hdlcd_crtc_cleanup() introduced
>     dropping the patch in v2.
>   - Add a patch to remove explicit calls to drm_mode_config_cleanup().
> 
> Changes in v4:
>   - Remove patches to protect platform device bound resources with
>     drm_dev_{enter,exit}, since this would leave the hardware enabled when
>     regularly unloading the driver e.g. via rmmod.
>     Instead do this in a later series, once we got drm_dev_unplug() in place
>     to deal with a regular driver shutdown.

This series is in a much better shape compared to the existing status quo. rmmod
works without any issue and I can re-insmod the driver again.

The only issue that I'm seeing that is not critical is that at reboot/shutdown time
I'm getting an "Unexpected global fault, this could be serious" from the smmu:

[ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
[ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
[ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
[ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
[ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
[ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
[ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
[ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
[ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
[ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
[ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
[ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
[ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
[ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
[ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
[ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
[ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
[ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
[ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
[ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
[ 6893.594616] reboot: Power down


The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
this is something you'll keep in mind in the later series when you do drm_dev_unplug().

With that, for the whole series:

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

Thanks for the patience and going through the series iterations with me.

I can pull this series into drm-misc-next on Monday if you don't have any other plans.

Best regards,
Liviu

> 
> Danilo Krummrich (4):
>   drm/arm/hdlcd: use drmm_* to allocate driver structures
>   drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
>   drm/arm/hdlcd: plane: use drm managed resources
>   drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()
> 
>  drivers/gpu/drm/arm/hdlcd_crtc.c | 24 +++++++------------
>  drivers/gpu/drm/arm/hdlcd_drv.c  | 41 ++++++++++++++++----------------
>  drivers/gpu/drm/arm/hdlcd_drv.h  |  2 ++
>  3 files changed, 32 insertions(+), 35 deletions(-)
> 
> 
> base-commit: e1e7bc481d49c3e3ada11029ce0d9b85a0a539d7
> -- 
> 2.37.3
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
@ 2022-11-04 18:20   ` Liviu Dudau
  0 siblings, 0 replies; 16+ messages in thread
From: Liviu Dudau @ 2022-11-04 18:20 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: daniel, airlied, tzimmermann, mripard, brian.starkey, dri-devel,
	linux-kernel

On Wed, Oct 26, 2022 at 05:34:27PM +0200, Danilo Krummrich wrote:
> Hi,

Hi Danilo,

> 
> This patch series converts the driver to use drm managed resources to prevent
> potential use-after-free issues on driver unbind/rebind and to get rid of the
> usage of deprecated APIs.
> 
> Changes in v2:
>   - drop patch "drm/arm/hdlcd: crtc: use drmm_crtc_init_with_planes()"
> 
> Changes in v3:
>   - Fix alternate return paths in srcu read-side critical sections causing a
>     stall when unregistering the driver.
>   - Fix potential null pointer dereference in hdlcd_crtc_cleanup() introduced
>     dropping the patch in v2.
>   - Add a patch to remove explicit calls to drm_mode_config_cleanup().
> 
> Changes in v4:
>   - Remove patches to protect platform device bound resources with
>     drm_dev_{enter,exit}, since this would leave the hardware enabled when
>     regularly unloading the driver e.g. via rmmod.
>     Instead do this in a later series, once we got drm_dev_unplug() in place
>     to deal with a regular driver shutdown.

This series is in a much better shape compared to the existing status quo. rmmod
works without any issue and I can re-insmod the driver again.

The only issue that I'm seeing that is not critical is that at reboot/shutdown time
I'm getting an "Unexpected global fault, this could be serious" from the smmu:

[ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
[ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
[ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
[ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
[ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
[ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
[ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
[ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
[ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
[ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
[ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
[ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
[ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
[ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
[ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
[ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
[ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
[ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
[ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
[ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
[ 6893.594616] reboot: Power down


The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
this is something you'll keep in mind in the later series when you do drm_dev_unplug().

With that, for the whole series:

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

Thanks for the patience and going through the series iterations with me.

I can pull this series into drm-misc-next on Monday if you don't have any other plans.

Best regards,
Liviu

> 
> Danilo Krummrich (4):
>   drm/arm/hdlcd: use drmm_* to allocate driver structures
>   drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv()
>   drm/arm/hdlcd: plane: use drm managed resources
>   drm/arm/hdlcd: remove calls to drm_mode_config_cleanup()
> 
>  drivers/gpu/drm/arm/hdlcd_crtc.c | 24 +++++++------------
>  drivers/gpu/drm/arm/hdlcd_drv.c  | 41 ++++++++++++++++----------------
>  drivers/gpu/drm/arm/hdlcd_drv.h  |  2 ++
>  3 files changed, 32 insertions(+), 35 deletions(-)
> 
> 
> base-commit: e1e7bc481d49c3e3ada11029ce0d9b85a0a539d7
> -- 
> 2.37.3
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
  2022-11-04 18:20   ` Liviu Dudau
@ 2022-11-08 19:57     ` Danilo Krummrich
  -1 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-11-08 19:57 UTC (permalink / raw)
  To: Liviu Dudau; +Cc: airlied, linux-kernel, dri-devel, tzimmermann

Hi Liviu,

> The only issue that I'm seeing that is not critical is that at reboot/shutdown time
> I'm getting an "Unexpected global fault, this could be serious" from the smmu:
> 
> [ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
> [ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
> [ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
> [ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
> [ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
> [ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
> [ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
> [ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
> [ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
> [ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
> [ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
> [ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
> [ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
> [ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
> [ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
> [ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
> [ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
> [ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
> [ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
> [ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
> [ 6893.594616] reboot: Power down
> 
> 
> The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
> this is something you'll keep in mind in the later series when you do drm_dev_unplug().

Yes, I'd expect this to be related to the missing protection of platform 
device bound resources.

> 
> With that, for the whole series:
> 
> Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> 
> Thanks for the patience and going through the series iterations with me.
> 
> I can pull this series into drm-misc-next on Monday if you don't have any other plans.
Thanks, I saw you already applied the series.

Have you had a look on the same series for malidp?

- Danilo

> 
> Best regards,
> Liviu


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
@ 2022-11-08 19:57     ` Danilo Krummrich
  0 siblings, 0 replies; 16+ messages in thread
From: Danilo Krummrich @ 2022-11-08 19:57 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: daniel, airlied, tzimmermann, mripard, brian.starkey, dri-devel,
	linux-kernel

Hi Liviu,

> The only issue that I'm seeing that is not critical is that at reboot/shutdown time
> I'm getting an "Unexpected global fault, this could be serious" from the smmu:
> 
> [ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
> [ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
> [ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
> [ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
> [ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
> [ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
> [ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
> [ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
> [ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
> [ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
> [ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
> [ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
> [ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
> [ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
> [ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
> [ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
> [ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
> [ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
> [ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
> [ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
> [ 6893.594616] reboot: Power down
> 
> 
> The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
> this is something you'll keep in mind in the later series when you do drm_dev_unplug().

Yes, I'd expect this to be related to the missing protection of platform 
device bound resources.

> 
> With that, for the whole series:
> 
> Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> 
> Thanks for the patience and going through the series iterations with me.
> 
> I can pull this series into drm-misc-next on Monday if you don't have any other plans.
Thanks, I saw you already applied the series.

Have you had a look on the same series for malidp?

- Danilo

> 
> Best regards,
> Liviu


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
  2022-11-08 19:57     ` Danilo Krummrich
@ 2022-11-09 13:49       ` Liviu Dudau
  -1 siblings, 0 replies; 16+ messages in thread
From: Liviu Dudau @ 2022-11-09 13:49 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: daniel, airlied, tzimmermann, mripard, brian.starkey, dri-devel,
	linux-kernel

On Tue, Nov 08, 2022 at 08:57:55PM +0100, Danilo Krummrich wrote:
> Hi Liviu,

Hi,

> 
> > The only issue that I'm seeing that is not critical is that at reboot/shutdown time
> > I'm getting an "Unexpected global fault, this could be serious" from the smmu:
> > 
> > [ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
> > [ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
> > [ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
> > [ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
> > [ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
> > [ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
> > [ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
> > [ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
> > [ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
> > [ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
> > [ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
> > [ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
> > [ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
> > [ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
> > [ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
> > [ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
> > [ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
> > [ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
> > [ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
> > [ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
> > [ 6893.594616] reboot: Power down
> > 
> > 
> > The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
> > this is something you'll keep in mind in the later series when you do drm_dev_unplug().
> 
> Yes, I'd expect this to be related to the missing protection of platform
> device bound resources.
> 
> > 
> > With that, for the whole series:
> > 
> > Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> > 
> > Thanks for the patience and going through the series iterations with me.
> > 
> > I can pull this series into drm-misc-next on Monday if you don't have any other plans.
> Thanks, I saw you already applied the series.
> 
> Have you had a look on the same series for malidp?

Yes, I've looked at the code and it looks reasonable, I just wanted to run it once
through the minimum of tests that I use, which involves switching some FPGA images
around. Hope to do that today or tomorrow.

Best regards,
Liviu

> 
> - Danilo
> 
> > 
> > Best regards,
> > Liviu
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources
@ 2022-11-09 13:49       ` Liviu Dudau
  0 siblings, 0 replies; 16+ messages in thread
From: Liviu Dudau @ 2022-11-09 13:49 UTC (permalink / raw)
  To: Danilo Krummrich; +Cc: airlied, linux-kernel, dri-devel, tzimmermann

On Tue, Nov 08, 2022 at 08:57:55PM +0100, Danilo Krummrich wrote:
> Hi Liviu,

Hi,

> 
> > The only issue that I'm seeing that is not critical is that at reboot/shutdown time
> > I'm getting an "Unexpected global fault, this could be serious" from the smmu:
> > 
> > [ 6893.467910] arm-smmu 7fb30000.iommu: disabling translation
> > [ 6893.473550] ohci-platform 7ffb0000.usb: Removing from iommu group 1
> > [ 6893.479909] ehci-platform 7ffc0000.usb: Removing from iommu group 1
> > [ 6893.486931] arm-smmu 7fb10000.iommu: disabling translation
> > [ 6893.492521] hdlcd 7ff50000.hdlcd: Removing from iommu group 3
> > [ 6893.492650] arm-smmu 7fb10000.iommu: Unexpected global fault, this could be serious
> > [ 6893.505959] arm-smmu 7fb10000.iommu:         GFSR 0x80000001, GFSYNR0 0x00000000, GFSYNR1 0x00000000, GFSYNR2 0x00000000
> > [ 6893.516511] arm-smmu 7fb00000.iommu: disabling translation
> > [ 6893.522195] dma-pl330 7ff00000.dma-controller: Removing from iommu group 2
> > [ 6893.529607] arm-smmu 2b500000.iommu: disabling translation
> > [ 6893.535221] pcieport 0000:00:00.0: Removing from iommu group 0
> > [ 6893.541135] pci 0000:01:00.0: Removing from iommu group 0
> > [ 6893.546604] pcieport 0000:02:01.0: Removing from iommu group 0
> > [ 6893.552511] pcieport 0000:02:02.0: Removing from iommu group 0
> > [ 6893.558418] pcieport 0000:02:03.0: Removing from iommu group 0
> > [ 6893.564329] pcieport 0000:02:0c.0: Removing from iommu group 0
> > [ 6893.570393] pcieport 0000:02:10.0: Removing from iommu group 0
> > [ 6893.576314] pcieport 0000:02:1f.0: Removing from iommu group 0
> > [ 6893.582214] sata_sil24 0000:03:00.0: Removing from iommu group 0
> > [ 6893.588270] sky2 0000:08:00.0: Removing from iommu group 0
> > [ 6893.594616] reboot: Power down
> > 
> > 
> > The reboot/shutdown succeeds, so I'm not too worried about it for now, but hope that
> > this is something you'll keep in mind in the later series when you do drm_dev_unplug().
> 
> Yes, I'd expect this to be related to the missing protection of platform
> device bound resources.
> 
> > 
> > With that, for the whole series:
> > 
> > Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> > 
> > Thanks for the patience and going through the series iterations with me.
> > 
> > I can pull this series into drm-misc-next on Monday if you don't have any other plans.
> Thanks, I saw you already applied the series.
> 
> Have you had a look on the same series for malidp?

Yes, I've looked at the code and it looks reasonable, I just wanted to run it once
through the minimum of tests that I use, which involves switching some FPGA images
around. Hope to do that today or tomorrow.

Best regards,
Liviu

> 
> - Danilo
> 
> > 
> > Best regards,
> > Liviu
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-11-09 13:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 15:34 [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources Danilo Krummrich
2022-10-26 15:34 ` Danilo Krummrich
2022-10-26 15:34 ` [PATCH drm-misc-next v4 1/4] drm/arm/hdlcd: use drmm_* to allocate driver structures Danilo Krummrich
2022-10-26 15:34   ` Danilo Krummrich
2022-10-26 15:34 ` [PATCH drm-misc-next v4 2/4] drm/arm/hdlcd: replace drm->dev_private with drm_to_hdlcd_priv() Danilo Krummrich
2022-10-26 15:34   ` Danilo Krummrich
2022-10-26 15:34 ` [PATCH drm-misc-next v4 3/4] drm/arm/hdlcd: plane: use drm managed resources Danilo Krummrich
2022-10-26 15:34   ` Danilo Krummrich
2022-10-26 15:34 ` [PATCH drm-misc-next v4 4/4] drm/arm/hdlcd: remove calls to drm_mode_config_cleanup() Danilo Krummrich
2022-10-26 15:34   ` Danilo Krummrich
2022-11-04 18:20 ` [PATCH drm-misc-next v4 0/4] drm/arm/hdlcd: use drm managed resources Liviu Dudau
2022-11-04 18:20   ` Liviu Dudau
2022-11-08 19:57   ` Danilo Krummrich
2022-11-08 19:57     ` Danilo Krummrich
2022-11-09 13:49     ` Liviu Dudau
2022-11-09 13:49       ` Liviu Dudau

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.