drm/msm: rework display snapshotting
cover drm/msm: rework display snapshotting
Rework display subsystem snapshotting by making msm_disp_state transient data struct. This simplifies handling of data.
Dependencies:
https://lore.kernel.org/linux-arm-msm/[email protected]/
----------------------------------------------------------------
Dmitry Baryshkov (2):
drm/msm: pass dump state as a function argument drm/msm: make msm_disp_state transient data struct
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 +++++------------------ drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 21 +----- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 22 ++---- drivers/gpu/drm/msm/dp/dp_display.c | 4 +- drivers/gpu/drm/msm/dsi/dsi.c | 4 +- drivers/gpu/drm/msm/dsi/dsi.h | 4 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +- drivers/gpu/drm/msm/msm_drv.h | 3 +- drivers/gpu/drm/msm/msm_kms.h | 7 +- 10 files changed, 41 insertions(+), 122 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 drm/msm: pass dump state as a function argument
Instead of always getting the disp_state from drm device, pass it as an argument.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +---- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 8 -------- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 17 +++-------------- drivers/gpu/drm/msm/dp/dp_display.c | 4 +--- drivers/gpu/drm/msm/dsi/dsi.c | 4 ++-- drivers/gpu/drm/msm/dsi/dsi.h | 4 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +----- drivers/gpu/drm/msm/msm_drv.h | 3 ++- drivers/gpu/drm/msm/msm_kms.h | 2 +- 9 files changed, 13 insertions(+), 40 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1 -4
@@ -799,15 +799,12 @@ static void dpu_irq_uninstall(struct msm_kms *kms)dpu_core_irq_uninstall (dpu_kms); } -static void dpu_kms_mdp_snapshot (struct msm_kms *kms) +static void dpu_kms_mdp_snapshot (struct msm_disp_state *disp_state,struct msm_kms *kms) {int i;struct dpu_kms *dpu_kms;struct dpu_mdss_cfg *cat;struct dpu_hw_mdp *top; -struct msm_disp_state *disp_state; - - disp_state = kms->disp_state; dpu_kms =to_dpu_kms (kms);
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0 -8
@@ -104,14 +104,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev);*/ void msm_disp_snapshot_state (struct drm_device *drm_dev); -/** -* msm_disp_state_get - get the handle to msm_disp_state struct from the drm device -* @drm: handle to drm device - -* Returns: handle to the msm_disp_state struct -*/ -struct msm_disp_state *msm_disp_state_get (struct drm_device *drm); -/** * msm_disp_state_print - print out the current dpu state * @disp_state: handle to drm device
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +3 -14
@@ -69,17 +69,6 @@ static void msm_disp_state_print_regs(u32 **reg, u32 len, void __iomem *base_add } } -struct msm_disp_state *msm_disp_state_get (struct drm_device *drm) -{ -struct msm_drm_private *priv; -struct msm_kms *kms; - - priv = drm->dev_private; - kms = priv->kms; - -return kms->disp_state; -} -void msm_disp_state_print (struct msm_disp_state *state,struct drm_printer *p) {struct msm_disp_state_block *block, *tmp;
@@ -138,17 +127,17 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) kms = priv->kms;if (priv->dp) -msm_dp_snapshot (priv->dp); +msm_dp_snapshot (disp_state, priv->dp);for (i =0 ; i <ARRAY_SIZE (priv->dsi); i++) {if (!priv->dsi[i])continue ; -msm_dsi_snapshot (priv->dsi[i]); +msm_dsi_snapshot (disp_state, priv->dsi[i]); }if (kms->funcs->snapshot) - kms->funcs->snapshot (kms); + kms->funcs->snapshot (disp_state, kms);msm_disp_capture_atomic_state (disp_state); }
drivers/gpu/drm/msm/dp/dp_display.c +1 -3
@@ -1009,15 +1009,13 @@ int dp_display_get_test_bpp(struct msm_dp *dp) dp_display->link->test_video.test_bit_depth); } -void msm_dp_snapshot (struct msm_dp *dp) +void msm_dp_snapshot (struct msm_disp_state *disp_state,struct msm_dp *dp) {struct dp_display_private *dp_display;struct drm_device *drm; -struct msm_disp_state *disp_state; dp_display = container_of(dp, struct dp_display_private, dp_display); drm = dp->drm_dev; - disp_state =msm_disp_state_get (drm);/* * if we are reading registers we need the link clocks to be on
drivers/gpu/drm/msm/dsi/dsi.c +2 -2
@@ -266,8 +266,8 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,return ret; } -void msm_dsi_snapshot (struct msm_dsi *msm_dsi) +void msm_dsi_snapshot (struct msm_disp_state *disp_state,struct msm_dsi *msm_dsi) { -msm_dsi_host_snapshot (msm_dsi->host); +msm_dsi_host_snapshot (disp_state, msm_dsi->host); }
drivers/gpu/drm/msm/dsi/dsi.h +2 -2
@@ -91,7 +91,7 @@ static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)return msm_dsi->panel || msm_dsi->external_bridge; } -void msm_dsi_snapshot (struct msm_dsi *msm_dsi); +void msm_dsi_snapshot (struct msm_disp_state *disp_state,struct msm_dsi *msm_dsi);struct drm_encoder *msm_dsi_get_encoder (struct msm_dsi *msm_dsi);
@@ -149,7 +149,7 @@ int dsi_clk_init_v2(struct msm_dsi_host *msm_host);int dsi_clk_init_6g_v2 (struct msm_dsi_host *msm_host);int dsi_calc_clk_rate_v2 (struct msm_dsi_host *msm_host,bool is_dual_dsi);int dsi_calc_clk_rate_6g (struct msm_dsi_host *msm_host,bool is_dual_dsi); -void msm_dsi_host_snapshot (struct mipi_dsi_host *host); +void msm_dsi_host_snapshot (struct msm_disp_state *disp_state,struct mipi_dsi_host *host);/* dsi phy */ struct msm_dsi_phy ;struct msm_dsi_phy_shared_timings {
drivers/gpu/drm/msm/dsi/dsi_host.c +1 -5
@@ -2488,13 +2488,9 @@ struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host)return of_drm_find_bridge (msm_host->device_node); } -void msm_dsi_host_snapshot (struct mipi_dsi_host *host) +void msm_dsi_host_snapshot (struct msm_disp_state *disp_state,struct mipi_dsi_host *host) {struct msm_dsi_host *msm_host =to_msm_dsi_host (host); -struct drm_device *dev = msm_host->dev; -struct msm_disp_state *disp_state; - - disp_state =msm_disp_state_get (dev);pm_runtime_get_sync (&msm_host->pdev->dev);
drivers/gpu/drm/msm/msm_drv.h +2 -1
@@ -367,7 +367,8 @@ void msm_dp_display_mode_set(struct msm_dp *dp, struct drm_encoder *encoder,struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode);void msm_dp_irq_postinstall (struct msm_dp *dp_display); -void msm_dp_snapshot (struct msm_dp *dp_display); +struct msm_disp_state ; +void msm_dp_snapshot (struct msm_disp_state *disp_state,struct msm_dp *dp_display);void msm_dp_debugfs_init (struct msm_dp *dp_display,struct drm_minor *minor);
drivers/gpu/drm/msm/msm_kms.h +1 -1
@@ -124,7 +124,7 @@ struct msm_kms_funcs {void (*destroy)(struct msm_kms *kms);/* snapshot: */ -void (*snapshot)(struct msm_kms *kms); +void (*snapshot)(struct msm_disp_state *disp_state,struct msm_kms *kms);#ifdef CONFIG_DEBUG_FS /* debugfs: */
Signature · 1 line
2.30.2
Re: [PATCH 1/2] drm/msm: pass dump state as a function argument
Quoted 4 lines · Dmitry Baryshkov
Instead of always getting the
disp_statefrom drm device, pass it as an argument.Signed-off-by Dmitry Baryshkov <[email protected]>
This certainly reduces some amount of code, I am onboard with this, hence:
Quoted 225 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +---- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 8 -------- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 17 +++-------------- drivers/gpu/drm/msm/dp/dp_display.c | 4 +--- drivers/gpu/drm/msm/dsi/dsi.c | 4 ++-- drivers/gpu/drm/msm/dsi/dsi.h | 4 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +----- drivers/gpu/drm/msm/msm_drv.h | 3 ++- drivers/gpu/drm/msm/msm_kms.h | 2 +- 9 files changed, 13 insertions(+), 40 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1
-4@@ -799,15 +799,12 @@ static void dpu_irq_uninstall(struct msm_kms *kms)dpu_core_irq_uninstall (dpu_kms); } -static void dpu_kms_mdp_snapshot (struct msm_kms *kms) +static void dpu_kms_mdp_snapshot (struct msm_disp_state *disp_state,struct msm_kms *kms) {int i;struct dpu_kms *dpu_kms;struct dpu_mdss_cfg *cat;struct dpu_hw_mdp *top; -struct msm_disp_state *disp_state; - - disp_state = kms->disp_state;drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0
-0dpu_kms =to_dpu_kms (kms);drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-2@@ -104,14 +104,6 @@ void msm_disp_snapshot_destroy(struct drm_device*drm_dev); */ void msm_disp_snapshot_state (struct drm_device *drm_dev); -/** -* msm_disp_state_get - get the handle to msm_disp_state struct from the drm device
- * @drm: handle to drm devicedrivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-5- -* Returns: handle to the msm_disp_state struct -*/ -struct msm_disp_state *msm_disp_state_get (struct drm_device *drm); -/** * msm_disp_state_print - print out the current dpu state * @disp_state: handle to drm device drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +0
-0@@ -69,17 +69,6 @@ static void msm_disp_state_print_regs(u32 **reg,u32 len, void
__iomem*base_adddrivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +0
-11} } -struct msm_disp_state *msm_disp_state_get (struct drm_device *drm) -{ -struct msm_drm_private *priv; -struct msm_kms *kms; - - priv = drm->dev_private; - kms = priv->kms; - -return kms->disp_state; -} - void msm_disp_state_print(struct msm_disp_state *state, struct
drm_printer*p)
{drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +3
-3struct msm_disp_state_block *block, *tmp;@@ -138,17 +127,17 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) kms = priv->kms;if (priv->dp) -msm_dp_snapshot (priv->dp); +msm_dp_snapshot (disp_state, priv->dp);for (i =0 ; i <ARRAY_SIZE (priv->dsi); i++) {if (!priv->dsi[i])continue ; -msm_dsi_snapshot (priv->dsi[i]); +msm_dsi_snapshot (disp_state, priv->dsi[i]); }if (kms->funcs->snapshot) - kms->funcs->snapshot (kms); + kms->funcs->snapshot (disp_state, kms);msm_disp_capture_atomic_state (disp_state);}
drivers/gpu/drm/msm/dp/dp_display.c +1
-3@@ -1009,15 +1009,13 @@ int dp_display_get_test_bpp(struct msm_dp *dp) dp_display->link->test_video.test_bit_depth); } -void msm_dp_snapshot (struct msm_dp *dp) +void msm_dp_snapshot (struct msm_disp_state *disp_state,struct msm_dp *dp) {struct dp_display_private *dp_display;struct drm_device *drm; -struct msm_disp_state *disp_state; dp_display = container_of(dp, struct dp_display_private, dp_display); drm = dp->drm_dev; - disp_state =msm_disp_state_get (drm);/* drivers/gpu/drm/msm/dp/dp_display.c +0
-0* if we are reading registers we need the link clocks to be on drivers/gpu/drm/msm/dsi/dsi.c +2
-2@@ -266,8 +266,8 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,struct drm_device *dev, return ret; } -void msm_dsi_snapshot (struct msm_dsi *msm_dsi) +void msm_dsi_snapshot (struct msm_disp_state *disp_state,struct msm_dsi *msm_dsi) { -msm_dsi_host_snapshot (msm_dsi->host); +msm_dsi_host_snapshot (disp_state, msm_dsi->host);}
drivers/gpu/drm/msm/dsi/dsi.h +1
-1@@ -91,7 +91,7 @@ static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)return msm_dsi->panel || msm_dsi->external_bridge; } -void msm_dsi_snapshot (struct msm_dsi *msm_dsi); +void msm_dsi_snapshot (struct msm_disp_state *disp_state,struct msm_dsi *msm_dsi);struct
drm_encoder*msm_dsi_get_encoder(structmsm_dsi*msm_dsi);drivers/gpu/drm/msm/dsi/dsi.h +1
-1@@ -149,7 +149,7 @@ int dsi_clk_init_v2(struct msm_dsi_host *msm_host);int dsi_clk_init_6g_v2 (struct msm_dsi_host *msm_host);int dsi_calc_clk_rate_v2 (struct msm_dsi_host *msm_host,bool is_dual_dsi);int dsi_calc_clk_rate_6g (struct msm_dsi_host *msm_host,bool is_dual_dsi); -void msm_dsi_host_snapshot (struct mipi_dsi_host *host); +void msm_dsi_host_snapshot (struct msm_disp_state *disp_state,struct mipi_dsi_host *host);/* dsi phy */
structmsm_dsi_phy;
structmsm_dsi_phy_shared_timings{drivers/gpu/drm/msm/dsi/dsi_host.c +1
-5@@ -2488,13 +2488,9 @@ struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host)return of_drm_find_bridge (msm_host->device_node); } -void msm_dsi_host_snapshot (struct mipi_dsi_host *host) +void msm_dsi_host_snapshot (struct msm_disp_state *disp_state,struct mipi_dsi_host *host) {struct msm_dsi_host *msm_host =to_msm_dsi_host (host); -struct drm_device *dev = msm_host->dev; -struct msm_disp_state *disp_state; - - disp_state =msm_disp_state_get (dev);drivers/gpu/drm/msm/dsi/dsi_host.c +0
-0pm_runtime_get_sync (&msm_host->pdev->dev);drivers/gpu/drm/msm/msm_drv.h +2
-1@@ -367,7 +367,8 @@ void msm_dp_display_mode_set(struct msm_dp *dp,struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode);void msm_dp_irq_postinstall (struct msm_dp *dp_display); -void msm_dp_snapshot (struct msm_dp *dp_display); +struct msm_disp_state ; +void msm_dp_snapshot (struct msm_disp_state *disp_state,struct msm_dp *dp_display);void msm_dp_debugfs_init(struct
msm_dp*dp_display, structdrm_minor
*minor);drivers/gpu/drm/msm/msm_kms.h +1
-1@@ -124,7 +124,7 @@ struct msm_kms_funcs {void (*destroy)(struct msm_kms *kms);/* snapshot: */ -void (*snapshot)(struct msm_kms *kms); +void (*snapshot)(struct msm_disp_state *disp_state,struct msm_kms *kms);#ifdef CONFIG_DEBUG_FS /* debugfs: */
PATCH 2/2 drm/msm: make msm_disp_state transient data struct
In reply to Dmitry BaryshkovInstead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make msm_disp_state transient struct. Allocate one when snapshotting happens and free it after coredump data is read by userspace.
--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 ++++--------------- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +-- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +- 4 files changed, 28 insertions(+), 82 deletions(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +19 -68
@@ -7,8 +7,7 @@#include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset,size_t count,void *data,size_t datalen) {struct drm_print_iterator iter;
@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer, loff_t offset,return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = msm_kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); -struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -mutex_lock (&disp_state->mutex); +INIT_LIST_HEAD (&disp_state->blocks);msm_disp_snapshot_capture_state (disp_state);
@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work)msm_disp_state_print (disp_state, &p); } -/* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP +/* If COREDUMP is disabled, the stub will call the free function. */ dev_coredumpm (disp_state->dev,THIS_MODULE , disp_state,0 ,GFP_KERNEL , - disp_devcoredump_read, disp_devcoredump_free); - disp_state->coredump_pending = true; -#else -msm_disp_state_free (disp_state); -#endif - -mutex_unlock (&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free); }void msm_disp_snapshot_state (struct drm_device *drm_dev) {struct msm_drm_private *priv;struct msm_kms *kms; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR ("invalid params\n" );
@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (!disp_state) { -DRM_ERROR ("invalid params\n" ); -return ; - } - -/* -* if there is a coredump pending return immediately till dump -* if read by userspace or timeout happens -*/ -if (disp_state->coredump_pending) { -DRM_DEBUG ("coredump is pending read\n" ); -return ; - } -kthread_queue_work (disp_state->dump_worker, - &disp_state->dump_work); +kthread_queue_work (kms->dump_worker, &kms->dump_work); }int msm_disp_snapshot_init (struct drm_device *drm_dev) {struct msm_drm_private *priv; -struct msm_disp_state *disp_state;struct msm_kms *kms;if (!drm_dev) {
@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state =devm_kzalloc (drm_dev->dev,sizeof (struct msm_disp_state ),GFP_KERNEL ); - -mutex_init (&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - -INIT_LIST_HEAD (&disp_state->blocks); - - disp_state->dump_worker =kthread_create_worker (0 ,"%s" ,"disp_snapshot" ); -if (IS_ERR (disp_state->dump_worker)) + kms->dump_worker =kthread_create_worker (0 ,"%s" ,"disp_snapshot" ); +if (IS_ERR (kms->dump_worker))DRM_ERROR ("failed to create disp state task\n" ); -kthread_init_work (&disp_state->dump_work, _msm_disp_snapshot_work); - - kms->disp_state = disp_state; +kthread_init_work (&kms->dump_work, _msm_disp_snapshot_work);return 0 ; }
@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) {struct msm_kms *kms;struct msm_drm_private *priv; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR ("invalid params\n" );
@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (disp_state->dump_worker) -kthread_destroy_worker (disp_state->dump_worker); - -list_del (&disp_state->blocks); -mutex_destroy (&disp_state->mutex); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker); }
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +2 -11
@@ -41,26 +41,17 @@* struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer -* @mutex: mutex to serialize access to serialze dumps, debugfs access -* @coredump_pending: coredump is pending read from userspace * @atomic_state: atomic state duplicated at the time of the error -* @dump_worker: kworker thread which runs the dump work -* @dump_work: kwork which dumps the registers and drm state * @timestamp: timestamp at which the coredump was captured */ struct msm_disp_state {struct device *dev;struct drm_device *drm_dev; -struct mutex mutex; - -bool coredump_pending;struct list_head blocks;struct drm_atomic_state *atomic_state; -struct kthread_worker *dump_worker; -struct kthread_work dump_work;ktime_t timestamp; };
@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state);/** * msm_disp_state_free - free the memory after the coredump has been read -* @disp_state: handle to struct msm_disp_state +* @data: handle to struct msm_disp_state * Returns: none */ -void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data);/** * msm_disp_snapshot_add_block - add a hardware block with its register dump
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +4 -1
@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state)msm_disp_capture_atomic_state (disp_state); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { +struct msm_disp_state *disp_state = data;struct msm_disp_state_block *block, *tmp;if (disp_state->atomic_state) {
@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state)kfree (block->state);kfree (block); } + +kfree (disp_state); } void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len,
drivers/gpu/drm/msm/msm_kms.h +3 -2
@@ -156,8 +156,9 @@ struct msm_kms {/* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace; -/* handle to disp snapshot state */ -struct msm_disp_state *disp_state; +/* disp snapshot support */ +struct kthread_worker *dump_worker; +struct kthread_work dump_work;/* * For async commit, where ->flush_commit() and later happens
Signature · 6 lines
2.30.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/msm: make msm_disp_state transient data struct
Quoted 4 lines · Dmitry Baryshkov
Instead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make
msm_disp_statetransient struct. Allocate one when snapshotting happens and free it after coredump data is read by userspace.
the purpose of the mutex is that when there are two coredumps being triggered by two consecutive errors, we want to make sure that till one coredump is completely read and/or processed, we do not allow triggering of another one as we want to capture the accurate hardware/software state.
So moving disp_state out of kms might be okay and just allocated it when actually capturing the state but we will need the mutex and some sort of pending flag in my opinion.
Quoted 64 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 ++++--------------- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +-- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +- 4 files changed, 28 insertions(+), 82 deletions(-)drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-2@@ -7,8 +7,7 @@#include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset,size_t count,void *data,size_t datalen) {drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +10
-13struct drm_print_iterator iter;@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer,loff_t offset, return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = msm_kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); -struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -mutex_lock (&disp_state->mutex); +INIT_LIST_HEAD (&disp_state->blocks);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +0
-0msm_disp_snapshot_capture_state (disp_state);
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c static void _msm_disp_snapshot_work(struct · line 55
Quoted 10 lines
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-5@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work) msm_disp_state_print(disp_state, &p); } -/* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP +/* If COREDUMP is disabled, the stub will call the free function. */
This is a good cleanup, I just checked that the free() is called even if the config is not enabled
Quoted 200 lines
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-8dev_coredumpm (disp_state->dev,THIS_MODULE , disp_state,0 ,GFP_KERNEL , - disp_devcoredump_read, disp_devcoredump_free); - disp_state->coredump_pending = true; -#else -msm_disp_state_free (disp_state); -#endif - -mutex_unlock (&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free); }void msm_disp_snapshot_state (struct drm_device *drm_dev) {struct msm_drm_private *priv;struct msm_kms *kms; -struct msm_disp_state *disp_state;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18if (!drm_dev) {DRM_ERROR ("invalid params\n" );@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (!disp_state) { -DRM_ERROR ("invalid params\n" ); -return ; - } - -/* -* if there is a coredump pending return immediately till dump -* if read by userspace or timeout happens -*/ -if (disp_state->coredump_pending) { -DRM_DEBUG ("coredump is pending read\n" ); -return ; - } -kthread_queue_work (disp_state->dump_worker, - &disp_state->dump_work); +kthread_queue_work (kms->dump_worker, &kms->dump_work); }int msm_disp_snapshot_init (struct drm_device *drm_dev) {struct msm_drm_private *priv; -struct msm_disp_state *disp_state;struct msm_kms *kms;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +3
-14if (!drm_dev) {@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state =devm_kzalloc (drm_dev->dev,sizeof (struct msm_disp_state), GFP_KERNEL); - -mutex_init (&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - -INIT_LIST_HEAD (&disp_state->blocks); - - disp_state->dump_worker =kthread_create_worker (0 ,"%s" , "disp_snapshot"); -if (IS_ERR (disp_state->dump_worker)) + kms->dump_worker =kthread_create_worker (0 ,"%s" ,"disp_snapshot" ); +if (IS_ERR (kms->dump_worker))DRM_ERROR ("failed to create disp state task\n" ); -kthread_init_work (&disp_state->dump_work, _msm_disp_snapshot_work); - - kms->disp_state = disp_state; +kthread_init_work (&kms->dump_work, _msm_disp_snapshot_work);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +0
-1return 0 ; }@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) {struct msm_kms *kms;struct msm_drm_private *priv; -struct msm_disp_state *disp_state;if (!drm_dev) {drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-7DRM_ERROR ("invalid params\n" );@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (disp_state->dump_worker) -kthread_destroy_worker (disp_state->dump_worker); - -list_del (&disp_state->blocks); -mutex_destroy (&disp_state->mutex); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker);}
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-9@@ -41,26 +41,17 @@* struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer -* @mutex: mutex to serialize access to serialze dumps, debugfs access -* @coredump_pending: coredump is pending read from userspace * @atomic_state: atomic state duplicated at the time of the error -* @dump_worker: kworker thread which runs the dump work -* @dump_work: kwork which dumps the registers and drm state * @timestamp: timestamp at which the coredump was captured */ struct msm_disp_state {struct device *dev;struct drm_device *drm_dev; -struct mutex mutex; - -bool coredump_pending;struct list_head blocks;struct drm_atomic_state *atomic_state; -struct kthread_worker *dump_worker; -struct kthread_work dump_work;ktime_t timestamp; };@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state);/** * msm_disp_state_free - free the memory after the coredump has been read
- * @disp_state: handle to structmsm_disp_state
+ * @data: handle to structmsm_disp_state* Returns: none
*/drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +1
-1-void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data);/** * msm_disp_snapshot_add_block - add a hardware block with its register dump
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-1@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state)msm_disp_capture_atomic_state (disp_state ); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { +struct msm_disp_state *disp_state = data;struct msm_disp_state_block *block, *tmp;drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-0if (disp_state->atomic_state) {@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state)kfree (block->state);kfree (block); } + +kfree (disp_state); }void msm_disp_snapshot_add_block(struct
msm_disp_state*disp_state,
u32 len,drivers/gpu/drm/msm/msm_kms.h +3
-2@@ -156,8 +156,9 @@ struct msm_kms {/* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace; -/* handle to disp snapshot state */ -struct msm_disp_state *disp_state; +/* disp snapshot support */ +struct kthread_worker *dump_worker; +struct kthread_work dump_work;/* * For async commit, where ->flush_commit() and later happens
Re: [PATCH 2/2] drm/msm: make msm_disp_state transient data struct
Quoted 6 lines · On 26/04/2021 23:50, [email protected] wrote:
Quoted 4 lines · Dmitry Baryshkov
Instead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make
msm_disp_statetransient struct. Allocate one when snapshotting happens and free it after coredump data is read by userspace.
Quoted 7 lines
the purpose of the mutex is that when there are two coredumps being triggered by two consecutive errors, we want to make sure that till one coredump is completely read and/or processed, we do not allow triggering of another one as we want to capture the accurate hardware/software state.
So moving
disp_stateout of kms might be okay and just allocated it when actually capturing the state but we will need the mutex and some sort of pending flag in my opinion.
I'll return the mutex to the kms struct, so that we won't start another snapshot untill previous one is complete.
Concerning the pending flag, I think it is also handled by the coredump code: dev_coredumpm() will not create another device if there is one already associated with the device being dumped. I should probably mention this in the commit message.
If you agree with this, I'll send v2 then (also adding plls dumping).
Quoted 272 lines
Quoted 65 lines
Signed-off-by Dmitry Baryshkov <[email protected]>---
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 ++++--------------- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +--.../gpu/drm/msm/disp/msm_disp_snapshot_util.c| 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +-4 files changed, 28 insertions(+), 82 deletions(-)drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-2@@ -7,8 +7,7 @@ #include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset, size_t count, void *data, size_t datalen) {struct
drm_print_iteratoriter;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +10
-13@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer, loff_t offset, return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); + struct drm_device *drm_dev = msm_kms->dev; struct msm_disp_state *disp_state; + struct drm_printer p; - disp_state = data; - - msm_disp_state_free(disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state = kzalloc(sizeof(struct msm_disp_state), GFP_KERNEL); + if (!disp_state) + return; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); - struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; - mutex_lock(&disp_state->mutex); + INIT_LIST_HEAD(&disp_state->blocks);
msm_disp_snapshot_capture_state(disp_state);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c static void _msm_disp_snapshot_work(struct · line 55
Quoted 10 lines
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-5@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work) msm_disp_state_print(disp_state, &p); } - /* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP + /* If COREDUMP is disabled, the stub will call the free function. */This is a good cleanup, I just checked that the
free()is called even if the config is not enabledQuoted 196 lines
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-8dev_coredumpm(disp_state->dev, THIS_MODULE, disp_state, 0, GFP_KERNEL, - disp_devcoredump_read, disp_devcoredump_free); - disp_state->coredump_pending = true; -#else - msm_disp_state_free(disp_state); -#endif - - mutex_unlock(&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free); } void msm_disp_snapshot_state(struct drm_device *drm_dev) { struct msm_drm_private *priv; struct msm_kms *kms; - struct msm_disp_state *disp_state; if (!drm_dev) {
DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - - if (!disp_state) { - DRM_ERROR("invalid params\n"); - return; - } - - /* - * if there is a coredump pending return immediately till dump - * if read by userspace or timeout happens - */ - if (disp_state->coredump_pending) { - DRM_DEBUG("coredump is pending read\n"); - return; - } - kthread_queue_work(disp_state->dump_worker, - &disp_state->dump_work); + kthread_queue_work(kms->dump_worker, &kms->dump_work); } int msm_disp_snapshot_init(struct drm_device *drm_dev) { struct msm_drm_private *priv; - struct msm_disp_state *disp_state; struct msm_kms *kms;if (!drm_dev) {
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +3
-14@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = devm_kzalloc(drm_dev->dev, sizeof(struct msm_disp_state), GFP_KERNEL); - - mutex_init(&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - - INIT_LIST_HEAD(&disp_state->blocks); - - disp_state->dump_worker = kthread_create_worker(0, "%s", "disp_snapshot"); - if (IS_ERR(disp_state->dump_worker)) + kms->dump_worker = kthread_create_worker(0, "%s", "disp_snapshot"); + if (IS_ERR(kms->dump_worker)) DRM_ERROR("failed to create disp state task\n"); - kthread_init_work(&disp_state->dump_work, _msm_disp_snapshot_work); - - kms->disp_state = disp_state; + kthread_init_work(&kms->dump_work, _msm_disp_snapshot_work);return 0;
}drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +0
-1@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) { struct msm_kms *kms; struct msm_drm_private *priv; - struct msm_disp_state *disp_state; if (!drm_dev) {
DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-7@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - - if (disp_state->dump_worker) - kthread_destroy_worker(disp_state->dump_worker); - - list_del(&disp_state->blocks); - mutex_destroy(&disp_state->mutex); + if (kms->dump_worker) + kthread_destroy_worker(kms->dump_worker);}
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +2
-11@@ -41,26 +41,17 @@* struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer -* @mutex: mutex to serialize access to serialze dumps, debugfs access -* @coredump_pending: coredump is pending read from userspace * @atomic_state: atomic state duplicated at the time of the error -* @dump_worker: kworker thread which runs the dump work -* @dump_work: kwork which dumps the registers and drm state * @timestamp: timestamp at which the coredump was captured */ struct msm_disp_state { struct device *dev; struct drm_device *drm_dev; - struct mutex mutex; - - bool coredump_pending; struct list_head blocks; struct drm_atomic_state *atomic_state; - struct kthread_worker *dump_worker; - struct kthread_work dump_work; ktime_t timestamp; };@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state); /*** msm_disp_state_free - free the memory after the coredump has been read -* @disp_state: handle to struct msm_disp_state +* @data: handle to struct msm_disp_state * Returns: none */ -void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data); /***
msm_disp_snapshot_add_block- add a hardware block with its register dumpdrivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-1@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) msm_disp_capture_atomic_state(disp_state); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { + struct msm_disp_state *disp_state = data; struct msm_disp_state_block *block, *tmp;if (
disp_state->atomic_state) {drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-0@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state) kfree(block->state); kfree(block); } + + kfree(disp_state); }void msm_disp_snapshot_add_block(struct
msm_disp_state*disp_state, u32 len,drivers/gpu/drm/msm/msm_kms.h +3
-2@@ -156,8 +156,9 @@ struct msm_kms { /* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace; - /* handle to disp snapshot state */ - struct msm_disp_state *disp_state; + /* disp snapshot support */ + struct kthread_worker *dump_worker; + struct kthread_work dump_work; /** For async commit, where ->flush_commit() and later happens
Signature · 2 lines
With best wishes Dmitry
Re: [Freedreno] [PATCH 2/2] drm/msm: make msm_disp_state transient data struct
Quoted 12 lines · Dmitry Baryshkov
Quoted 11 lines · On 26/04/2021 23:50, [email protected] wrote:
Quoted 4 lines · Dmitry Baryshkov
Instead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make
msm_disp_statetransient struct. Allocate one when snapshotting happens and free it after coredump data is read by userspace.the purpose of the mutex is that when there are two coredumps being triggered by two consecutive errors, we want to make sure that till one coredump is completely read and/or processed, we do not allow triggering of another one as we want to capture the accurate hardware/software state.
Quoted 5 lines
Quoted 2 lines
So moving
disp_stateout of kms might be okay and just allocated it when actually capturing the state but we will need the mutex and some sort of pending flag in my opinion.I'll return the mutex to the kms struct, so that we won't start another snapshot untill previous one is complete.
I think mutex should remain as part of snapshot so that they go together. Since this mutex is not used by any other module, I thought its better to keep it there.
Quoted 5 lines
Concerning the pending flag, I think it is also handled by the coredump code:
dev_coredumpm()will not create another device if there is one already associated with the device being dumped. I should probably mention this in the commit message.
Thats a good point, I checked that now as well but I still think we need this flag because it also makes sure devcoredump is taken and read together within our driver itself instead of relying on the devcoredump. Its not a strong preference.
But if you would like to go ahead with this, might have to retest its robustness. With the older logic how i verified this was that I relaxed the underrun cnt check in this patch ( https://patchwork.freedesktop.org/patch/429112/?series=89181&rev=1 ) here and simulated an error:
@@ -1336,6 +1337,11 @@ static void dpu_encoder_underrun_callback(struct drm_encoder *drm_enc,
DPU_ATRACE_BEGIN("encoder_underrun_callback"); atomic_inc(&phy_enc->underrun_cnt);
+
+ /* trigger dump only on the first underrun */
+ if (atomic_read(&phy_enc->underrun_cnt) == 1)
+ msm_disp_snapshot_state(drm_enc->dev);
+
And verified that across various underrun interrupts, the devcoredump is stable.
Quoted 2 lines
If you agree with this, I'll send v2 then (also adding plls dumping).
Looking fwd to seeing the pll dumping, that will be a great addition to this.
Quoted 271 lines
Quoted 271 lines
Quoted 78 lines
Signed-off-by Dmitry Baryshkov <[email protected]>---
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87
++++---------------
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +--.../gpu/drm/msm/disp/msm_disp_snapshot_util.c| 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +-4 files changed, 28 insertions(+), 82 deletions(-)drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-2@@ -7,8 +7,7 @@ #include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset, size_t count, void *data, size_t datalen) {struct
drm_print_iteratoriter;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +10
-13@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer, loff_t offset, return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); + struct drm_device *drm_dev = msm_kms->dev; struct msm_disp_state *disp_state; + struct drm_printer p; - disp_state = data; - - msm_disp_state_free(disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state = kzalloc(sizeof(struct msm_disp_state), GFP_KERNEL); + if (!disp_state) + return; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); - struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; - mutex_lock(&disp_state->mutex); + INIT_LIST_HEAD(&disp_state->blocks);
msm_disp_snapshot_capture_state(disp_state);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-5@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work) msm_disp_state_print(disp_state, &p); } - /* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP + /* If COREDUMP is disabled, the stub will call the freeQuoted 1 line
function. */
This is a good cleanup, I just checked that the
free()is called even if the config is not enabledQuoted 191 lines
dev_coredumpm(disp_state->dev,
THIS_MODULE,disp_state, 0,GFP_KERNEL, -disp_devcoredump_read,disp_devcoredump_free);
-disp_state->coredump_pending= true;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-5-#else - msm_disp_state_free(disp_state); -#endif - - mutex_unlock(&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free);}
void
msm_disp_snapshot_state(struct drm_device *drm_dev){
structmsm_drm_private*priv;
structmsm_kms*kms;
- structmsm_disp_state*disp_state;if (!drm_dev) {
DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - - if (!disp_state) { - DRM_ERROR("invalid params\n"); - return; - } - - /* - * if there is a coredump pending return immediately till dump - * if read by userspace or timeout happens - */ - if (disp_state->coredump_pending) { - DRM_DEBUG("coredump is pending read\n"); - return; - } - kthread_queue_work(disp_state->dump_worker, - &disp_state->dump_work); + kthread_queue_work(kms->dump_worker, &kms->dump_work); } int msm_disp_snapshot_init(struct drm_device *drm_dev) { struct msm_drm_private *priv; - struct msm_disp_state *disp_state; struct msm_kms *kms;if (!drm_dev) {
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-12@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = devm_kzalloc(drm_dev->dev, sizeof(struct msm_disp_state), GFP_KERNEL); - - mutex_init(&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - - INIT_LIST_HEAD(&disp_state->blocks); - - disp_state->dump_worker = kthread_create_worker(0, "%s", "disp_snapshot"); - if (IS_ERR(disp_state->dump_worker)) + kms->dump_worker = kthread_create_worker(0, "%s","disp_snapshot" ); + if (IS_ERR(kms->dump_worker)) DRM_ERROR("failed to create disp state task\n"); - kthread_init_work(&disp_state->dump_work,
_msm_disp_snapshot_work);
-
-kms->disp_state=disp_state;
+kthread_init_work(&kms->dump_work, _msm_disp_snapshot_work);return 0;
}drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +0
-1@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) { struct msm_kms *kms; struct msm_drm_private *priv; - struct msm_disp_state *disp_state; if (!drm_dev) {
DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-7@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - - if (disp_state->dump_worker) - kthread_destroy_worker(disp_state->dump_worker); - - list_del(&disp_state->blocks); - mutex_destroy(&disp_state->mutex); + if (kms->dump_worker) + kthread_destroy_worker(kms->dump_worker);}
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-1@@ -41,26 +41,17 @@ * struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer - * @mutex: mutex to serialize access to serialze dumps, debugfsaccess
- * @coredump_pending: coredump is pending read from userspace
* @atomic_state: atomic state duplicated at the time of the error
- * @dump_worker: kworker thread which runs the dump work
- * @dump_work: kwork which dumps the registers and drm state
* @timestamp: timestamp at which the coredump was captured */
structmsm_disp_state{
struct device *dev;
structdrm_device*drm_dev;
- struct mutex mutex;
-
- boolcoredump_pending;struct
list_headblocks;struct
drm_atomic_state*atomic_state;- struct
kthread_worker*dump_worker;
- structkthread_workdump_work;
ktime_ttimestamp;
};drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +2
-2@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state); /*** msm_disp_state_free - free the memory after the coredump has been read -* @disp_state: handle to struct msm_disp_state +* @data: handle to struct msm_disp_state * Returns: none */ -void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data); /***
msm_disp_snapshot_add_block- add a hardware block with its register dumpdrivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-1@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) msm_disp_capture_atomic_state(disp_state); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { + struct msm_disp_state *disp_state = data; struct msm_disp_state_block *block, *tmp;if (
disp_state->atomic_state) {drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-0@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state) kfree(block->state); kfree(block); } + + kfree(disp_state); }void msm_disp_snapshot_add_block(struct
msm_disp_state*disp_state, u32 len,drivers/gpu/drm/msm/msm_kms.h +0
-0@@ -156,8 +156,9 @@ struct msm_kms { /* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace;
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/msm/msm_kms.h struct msm_kms { · line 164
Quoted 8 lines
drivers/gpu/drm/msm/msm_kms.h +3
-2- /* handle to disp snapshot state */ - struct msm_disp_state *disp_state; + /* disp snapshot support */ + struct kthread_worker *dump_worker; + struct kthread_work dump_work; /** For async commit, where ->flush_commit() and later happens
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Freedreno] [PATCH 2/2] drm/msm: make msm_disp_state transient data struct
Quoted 23 lines · On Tue, 27 Apr 2021 at 01:03, <[email protected]> wrote:
Quoted 21 lines · Dmitry Baryshkov
Quoted 19 lines · On 26/04/2021 23:50, [email protected] wrote:
Quoted 5 lines · Dmitry Baryshkov
Instead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make
msm_disp_statetransient struct. Allocate one when snapshotting happens
and free it after coredump data is read by userspace.the purpose of the mutex is that when there are two coredumps being triggered
by two consecutive errors, we want to make sure that till one coredump is completely
read and/or processed, we do not allow triggering of another one as we want to capture
the accurate hardware/software state.So moving
disp_stateout of kms might be okay and just allocated it when actually capturing the state
but we will need the mutex and some sort of pending flag in my opinion.
Quoted 6 lines
Quoted 2 lines
I'll return the mutex to the kms struct, so that we won't start another snapshot untill previous one is complete.
I think mutex should remain as part of snapshot so that they go together. Since this mutex is not used
by any other module, I thought its better to keep it there.
I don't think so: we will serialize access to the snapshot, but not dumping between snapshots. Note, that your code also serializes writing to snapshot, not reading from it.
With disp_state being allocated on demand we do not have to protect its contents (since it is not available before registration using dev_codedumpm).
I thought that you wanted to be sure that one snapshot is fully captured before next error triggers the next snapshot. And for this we'd need 'global' mutex (in kms).
Quoted 29 lines
Quoted 4 lines
Concerning the pending flag, I think it is also handled by the coredump code:
dev_coredumpm()will not create another device if there is one already associated with the device being dumped. I should probably mention this in the commit message.Thats a good point, I checked that now as well but I still think we need this flag because
it also makes sure devcoredump is taken and read together within our driver itself instead of relying
on the devcoredump. Its not a strong preference.But if you would like to go ahead with this, might have to retest its robustness.
With the older logic how i verified this was that I relaxed the underrun cnt check in this patch
( https://patchwork.freedesktop.org/patch/429112/?series=89181&rev=1 ) here and simulated an error:(quoted diff) +5
-0@@ -1336,6 +1337,11 @@ static void dpu_encoder_underrun_callback(struct drm_encoder *drm_enc, DPU_ATRACE_BEGIN("encoder_underrun_callback"); atomic_inc(&phy_enc->underrun_cnt); + + /* trigger dump only on the first underrun */ + if (atomic_read(&phy_enc->underrun_cnt) == 1) + msm_disp_snapshot_state(drm_enc->dev); +
Quoted 2 lines
And verified that across various underrun interrupts, the devcoredump is stable.
I'll try testing it this way, thank you for the pointer!
Quoted 290 lines
Quoted 3 lines
If you agree with this, I'll send v2 then (also adding plls dumping).
Looking fwd to seeing the pll dumping, that will be a great addition to this.
Quoted 285 lines
Quoted 285 lines
Quoted 78 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 ++++--------------- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +-- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +- 4 files changed, 28 insertions(+), 82 deletions(-)drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-2@@ -7,8 +7,7 @@#include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset,size_t count,void *data,size_t datalen) {struct drm_print_iterator iter;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +11
-18@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer, loff_t offset, return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = msm_kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); -struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -mutex_lock (&disp_state->mutex); +INIT_LIST_HEAD (&disp_state->blocks);msm_disp_snapshot_capture_state (disp_state);@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work) msm_disp_state_print(disp_state, &p); } -/* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP +/* If COREDUMP is disabled, the stub will call the free Quoted 1 line
function. */
This is a good cleanup, I just checked that the
free()is called even if the config is not enabledQuoted 204 lines
dev_coredumpm(disp_state->dev, THIS_MODULE, disp_state, 0,
GFP_KERNEL,drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-26- disp_devcoredump_read, disp_devcoredump_free); - disp_state->coredump_pending = true; -#else -msm_disp_state_free (disp_state); -#endif - -mutex_unlock (&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free); }void msm_disp_snapshot_state (struct drm_device *drm_dev) {struct msm_drm_private *priv;struct msm_kms *kms; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR ("invalid params\n" );@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (!disp_state) { -DRM_ERROR ("invalid params\n" ); -return ; - } - -/* -* if there is a coredump pending return immediately till dump -* if read by userspace or timeout happens -*/ -if (disp_state->coredump_pending) { -DRM_DEBUG ("coredump is pending read\n" ); -return ; - } -kthread_queue_work (disp_state->dump_worker, - &disp_state->dump_work); +kthread_queue_work (kms->dump_worker, &kms->dump_work); }int msm_disp_snapshot_init (struct drm_device *drm_dev) {struct msm_drm_private *priv; -struct msm_disp_state *disp_state;struct msm_kms *kms;if (!drm_dev) {drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-12@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state =devm_kzalloc (drm_dev->dev,sizeof (struct msm_disp_state), GFP_KERNEL); - -mutex_init (&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - -INIT_LIST_HEAD (&disp_state->blocks); - - disp_state->dump_worker =kthread_create_worker (0 ,"%s" , "disp_snapshot"); -if (IS_ERR (disp_state->dump_worker)) + kms->dump_worker =kthread_create_worker (0 ,"%s" ,"disp_snapshot" ); +if (IS_ERR (kms->dump_worker))DRM_ERROR ("failed to create disp state task\n" ); - kthread_init_work(&disp_state->dump_work,
_msm_disp_snapshot_work);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-3- - kms->disp_state = disp_state; +kthread_init_work (&kms->dump_work, _msm_disp_snapshot_work);return 0 ; }@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) {struct msm_kms *kms;struct msm_drm_private *priv; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-7@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (disp_state->dump_worker) -kthread_destroy_worker (disp_state->dump_worker); - -list_del (&disp_state->blocks); -mutex_destroy (&disp_state->mutex); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker);}
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-1@@ -41,26 +41,17 @@* struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer -* @mutex: mutex to serialize access to serialze dumps, debugfs access
- * @coredump_pending: coredump is pending read from userspace
* @atomic_state: atomic state duplicated at the time of the error
- * @dump_worker: kworker thread which runs the dump work
- * @dump_work: kwork which dumps the registers and drm state
* @timestamp: timestamp at which the coredump was captured */struct msm_disp_state { struct device *dev; struct drm_device *drm_dev;drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-5-struct mutex mutex; - -bool coredump_pending;struct list_head blocks;struct drm_atomic_state *atomic_state; -struct kthread_worker *dump_worker; -struct kthread_work dump_work;ktime_t timestamp; };@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state);/** * msm_disp_state_free - free the memory after the coredump has been read
- * @disp_state: handle to structmsm_disp_state
+ * @data: handle to structmsm_disp_state* Returns: none
*/drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +1
-1-void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data);/** * msm_disp_snapshot_add_block - add a hardware block with its register dump
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-1@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state)msm_disp_capture_atomic_state (disp_state ); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { +struct msm_disp_state *disp_state = data;struct msm_disp_state_block *block, *tmp;if (disp_state->atomic_state) {drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-0@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state)kfree (block->state);kfree (block); } + +kfree (disp_state); }void msm_disp_snapshot_add_block(struct
msm_disp_state*disp_state,
u32 len,drivers/gpu/drm/msm/msm_kms.h +3
-2@@ -156,8 +156,9 @@ struct msm_kms {/* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace; -/* handle to disp snapshot state */ -struct msm_disp_state *disp_state; +/* disp snapshot support */ +struct kthread_worker *dump_worker; +struct kthread_work dump_work;/* * For async commit, where ->flush_commit() and later happens
Signature · 6 lines
With best wishes Dmitry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Freedreno] [PATCH 2/2] drm/msm: make msm_disp_state transient data struct
Quoted 31 lines · Dmitry Baryshkov
Quoted 23 lines · On Tue, 27 Apr 2021 at 01:03, <[email protected]> wrote:
Quoted 21 lines · Dmitry Baryshkov
Quoted 19 lines · On 26/04/2021 23:50, [email protected] wrote:
Quoted 5 lines · Dmitry Baryshkov
Instead of allocating snapshotting structure at the driver probe time and later handling concurrent access, actual state, etc, make
msm_disp_statetransient struct. Allocate one when snapshotting happens
and free it after coredump data is read by userspace.the purpose of the mutex is that when there are two coredumps being triggered
by two consecutive errors, we want to make sure that till one coredump is completely
read and/or processed, we do not allow triggering of another one as we want to capture
the accurate hardware/software state.So moving
disp_stateout of kms might be okay and just allocated it when actually capturing the state
but we will need the mutex and some sort of pending flag in my opinion.Quoted 6 lines
Quoted 2 lines
I'll return the mutex to the kms struct, so that we won't start another snapshot untill previous one is complete.
I think mutex should remain as part of snapshot so that they go together. Since this mutex is not used
by any other module, I thought its better to keep it there.
Quoted 9 lines
I don't think so: we will serialize access to the snapshot, but not dumping between snapshots. Note, that your code also serializes writing to snapshot, not reading from it.
Withdisp_statebeing allocated on demand we do not have to protect its contents (since it is not available before registration usingdev_codedumpm).
I thought that you wanted to be sure that one snapshot is fully captured before next error triggers the next snapshot. And for this we'd need 'global' mutex (in kms).
True, the intention of the mutex is to serialize access to snapshot. the coredump_pending flag is the one which will serialize the write and read because its set to false only in the free() method of the coredump.
I was referring to the pending flag when I meant that it will serialize read/write.
Regarding the mutex, well, if you word it that way that it protects one snapshot from being overwritten by the other and hence we need a 'global' mutex in kms, it convinced me :)
The only reason it was within the disp_state itself was because its not used outside the module but I am okay with moving it to kms if Rob is okay with that.
Quoted 318 lines
Quoted 31 lines
Quoted 5 lines
Concerning the pending flag, I think it is also handled by the coredump code:
dev_coredumpm()will not create another device if there is one already associated with the device being dumped. I should probably mention this in the commit message.Thats a good point, I checked that now as well but I still think we need this flag because
it also makes sure devcoredump is taken and read together within our driver itself instead of relying
on the devcoredump. Its not a strong preference.But if you would like to go ahead with this, might have to retest its robustness.
With the older logic how i verified this was that I relaxed the underrun cnt check in this patch
( https://patchwork.freedesktop.org/patch/429112/?series=89181&rev=1 ) here and simulated an error:(quoted diff) +0
-0@@ -1336,6 +1337,11 @@ static voiddpu_encoder_underrun_callback(struct
drm_encoder*drm_enc,DPU_ATRACE_BEGIN("encoder_underrun_callback"); atomic_inc(&phy_enc->underrun_cnt);(quoted diff) +5
-0+ + /* trigger dump only on the first underrun */ + if (atomic_read(&phy_enc->underrun_cnt) == 1) + msm_disp_snapshot_state(drm_enc->dev); +Quoted 2 lines
And verified that across various underrun interrupts, the devcoredump is stable.
I'll try testing it this way, thank you for the pointer!
Quoted 282 lines
Quoted 3 lines
If you agree with this, I'll send v2 then (also adding plls dumping).
Looking fwd to seeing the pll dumping, that will be a great addition to this.
Quoted 277 lines
Quoted 277 lines
Quoted 78 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 87 ++++--------------- drivers/gpu/drm/msm/disp/msm_disp_snapshot.h | 13 +-- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 5 +- drivers/gpu/drm/msm/msm_kms.h | 5 +- 4 files changed, 28 insertions(+), 82 deletions(-)drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-2@@ -7,8 +7,7 @@#include "msm_disp_snapshot.h" -#ifdef CONFIG_DEV_COREDUMP -static ssize_t disp_devcoredump_read (char *buffer,loff_t offset, +static ssize_t __maybe_unused disp_devcoredump_read (char *buffer,loff_t offset,size_t count,void *data,size_t datalen) {struct drm_print_iterator iter;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +11
-18@@ -29,24 +28,21 @@ static ssize_t disp_devcoredump_read(char *buffer, loff_t offset, return count - iter.remain; } -static void disp_devcoredump_free (void *data) +static void _msm_disp_snapshot_work (struct kthread_work *work) { + struct msm_kms *msm_kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = msm_kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); - - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; -static void _msm_disp_snapshot_work (struct kthread_work *work) -{ - struct msm_disp_state *disp_state = container_of(work, struct msm_disp_state, dump_work); -struct drm_printer p; + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -mutex_lock (&disp_state->mutex); +INIT_LIST_HEAD (&disp_state->blocks);msm_disp_snapshot_capture_state (disp_state);@@ -55,26 +51,15 @@ static void _msm_disp_snapshot_work(struct kthread_work *work) msm_disp_state_print(disp_state, &p); } -/* -* if devcoredump is not defined free the state immediately -* otherwise it will be freed in the free handler. -*/ -#ifdef CONFIG_DEV_COREDUMP +/* If COREDUMP is disabled, the stub will call the free Quoted 1 line
function. */
This is a good cleanup, I just checked that the
free()is called even if the config is not enabledQuoted 196 lines
dev_coredumpm(disp_state->dev, THIS_MODULE, disp_state, 0,
GFP_KERNEL,drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-26- disp_devcoredump_read, disp_devcoredump_free); - disp_state->coredump_pending = true; -#else -msm_disp_state_free (disp_state); -#endif - -mutex_unlock (&disp_state->mutex); + disp_devcoredump_read, msm_disp_state_free); }void msm_disp_snapshot_state (struct drm_device *drm_dev) {struct msm_drm_private *priv;struct msm_kms *kms; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR ("invalid params\n" );@@ -83,30 +68,13 @@ void msm_disp_snapshot_state(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (!disp_state) { -DRM_ERROR ("invalid params\n" ); -return ; - } - -/* -* if there is a coredump pending return immediately till dump -* if read by userspace or timeout happens -*/ -if (disp_state->coredump_pending) { -DRM_DEBUG ("coredump is pending read\n" ); -return ; - } -kthread_queue_work (disp_state->dump_worker, - &disp_state->dump_work); +kthread_queue_work (kms->dump_worker, &kms->dump_work); }int msm_disp_snapshot_init (struct drm_device *drm_dev) {struct msm_drm_private *priv; -struct msm_disp_state *disp_state;struct msm_kms *kms;if (!drm_dev) {drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-12@@ -117,22 +85,11 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state =devm_kzalloc (drm_dev->dev,sizeof (struct msm_disp_state), GFP_KERNEL); - -mutex_init (&disp_state->mutex); - - disp_state->dev = drm_dev->dev; - disp_state->drm_dev = drm_dev; - -INIT_LIST_HEAD (&disp_state->blocks); - - disp_state->dump_worker =kthread_create_worker (0 ,"%s" , "disp_snapshot"); -if (IS_ERR (disp_state->dump_worker)) + kms->dump_worker =kthread_create_worker (0 ,"%s" ,"disp_snapshot" ); +if (IS_ERR (kms->dump_worker))DRM_ERROR ("failed to create disp state task\n" ); - kthread_init_work(&disp_state->dump_work,
_msm_disp_snapshot_work);drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-3- - kms->disp_state = disp_state; +kthread_init_work (&kms->dump_work, _msm_disp_snapshot_work);return 0 ; }@@ -141,7 +98,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) {struct msm_kms *kms;struct msm_drm_private *priv; -struct msm_disp_state *disp_state;if (!drm_dev) {DRM_ERROR("invalid params\n");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +2
-7@@ -150,12 +106,7 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev) priv = drm_dev->dev_private; kms = priv->kms; - disp_state = kms->disp_state; - -if (disp_state->dump_worker) -kthread_destroy_worker (disp_state->dump_worker); - -list_del (&disp_state->blocks); -mutex_destroy (&disp_state->mutex); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker);}
drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-1@@ -41,26 +41,17 @@* struct msm_disp_state - structure to store current dpu state * @dev: device pointer * @drm_dev: drm device pointer -* @mutex: mutex to serialize access to serialze dumps, debugfs access
- * @coredump_pending: coredump is pending read from userspace
* @atomic_state: atomic state duplicated at the time of the error
- * @dump_worker: kworker thread which runs the dump work
- * @dump_work: kwork which dumps the registers and drm state
* @timestamp: timestamp at which the coredump was captured */struct msm_disp_state { struct device *dev; struct drm_device *drm_dev;drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +0
-5-struct mutex mutex; - -bool coredump_pending;struct list_head blocks;struct drm_atomic_state *atomic_state; -struct kthread_worker *dump_worker; -struct kthread_work dump_work;ktime_t timestamp; };@@ -123,11 +114,11 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state);/** * msm_disp_state_free - free the memory after the coredump has been read
- * @disp_state: handle to structmsm_disp_state
+ * @data: handle to structmsm_disp_state* Returns: none
*/drivers/gpu/drm/msm/disp/msm_disp_snapshot.h +1
-1-void msm_disp_state_free (struct msm_disp_state *disp_state); +void msm_disp_state_free (void *data);/** * msm_disp_snapshot_add_block - add a hardware block with its register dump
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-1@@ -142,8 +142,9 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state)msm_disp_capture_atomic_state (disp_state ); } -void msm_disp_state_free (struct msm_disp_state *disp_state) +void msm_disp_state_free (void *data) { +struct msm_disp_state *disp_state = data;struct msm_disp_state_block *block, *tmp;if (disp_state->atomic_state) {drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2
-0@@ -156,6 +157,8 @@ void msm_disp_state_free(struct msm_disp_state *disp_state)kfree (block->state);kfree (block); } + +kfree (disp_state); }void msm_disp_snapshot_add_block(struct
msm_disp_state*disp_state,
u32 len,drivers/gpu/drm/msm/msm_kms.h +0
-0@@ -156,8 +156,9 @@ struct msm_kms {/* mapper-id used to request GEM buffer mapped for scanout: */ struct msm_gem_address_space *aspace;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/msm/msm_kms.h struct msm_kms { · line 164
Quoted 8 lines
drivers/gpu/drm/msm/msm_kms.h +3
-2-/* handle to disp snapshot state */ -struct msm_disp_state *disp_state; +/* disp snapshot support */ +struct kthread_worker *dump_worker; +struct kthread_work dump_work;/* * For async commit, where ->flush_commit() and later happens
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel