drm/msm: improve register snapshotting
v2 cover drm/msm: improve register snapshotting
Rework MSM coredump support: add DSI PHY registers, simplify snapshotting code.
Changes since v1:
- Readd mutex serializing register snapshot calls
- Add DSI PHY register dumping support
----------------------------------------------------------------
Dmitry Baryshkov (4):
drm/msm: pass dump state as a function argument drm/msm: make msm_disp_state transient data struct drm/msm: get rid of msm_iomap_size drm/msm/dsi: add DSI PHY registers to snapshot data
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 90 +++++++---------------- 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 | 5 +- drivers/gpu/drm/msm/dsi/dsi.h | 5 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 11 +-- drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 31 +++++++- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 4 + drivers/gpu/drm/msm/msm_drv.c | 27 +++---- drivers/gpu/drm/msm/msm_drv.h | 6 +- drivers/gpu/drm/msm/msm_kms.h | 8 +- 13 files changed, 97 insertions(+), 142 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/4 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
PATCH v2 2/4 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 | 90 ++++++------------- 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 | 6 +- 4 files changed, 37 insertions(+), 77 deletions(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +27 -63
@@ -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,52 +28,47 @@ 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 *kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -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; +INIT_LIST_HEAD (&disp_state->blocks); -mutex_lock (&disp_state->mutex); +/* Serialize dumping here */ +mutex_lock (&kms->dump_mutex);msm_disp_snapshot_capture_state (disp_state); +mutex_unlock (&kms->dump_mutex); +if (MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE ) { p =drm_info_printer (disp_state->drm_dev->dev);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. +* If COREDUMP is disabled, the stub will call the free function. +* If there is a codedump pending for the device, the dev_coredumpm() +* will also free new coredump state. */ -#ifdef CONFIG_DEV_COREDUMP 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 +77,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 +94,13 @@ 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); +mutex_init (&kms->dump_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 +109,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 +117,9 @@ 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); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker); -mutex_destroy (&disp_state->mutex); +mutex_destroy (&kms->dump_mutex); }
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 +4 -2
@@ -156,8 +156,10 @@ 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; +struct mutex dump_mutex;/* * For async commit, where ->flush_commit() and later happens
Signature · 1 line
2.30.2
Re: [Freedreno] [PATCH v2 2/4] drm/msm: make msm_disp_state transient data struct
Hi Dmitry
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.
Can you please check my previous comment on coredump_pending?
https://lore.kernel.org/dri-devel/[email protected]/T/#u
That helps to serialize read/write of coredump.
Rest of the changes on this one look fine to me.
Quoted 281 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 90 ++++++------------- 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 | 6 +- 4 files changed, 37 insertions(+), 77 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 +18
-23struct drm_print_iterator iter;@@ -29,52 +28,47 @@ 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 *kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -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; +INIT_LIST_HEAD (&disp_state->blocks); -mutex_lock (&disp_state->mutex); +/* Serialize dumping here */ +mutex_lock (&kms->dump_mutex);msm_disp_snapshot_capture_state (disp_state); +mutex_unlock (&kms->dump_mutex); +if (MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE ) { p =drm_info_printer (disp_state->drm_dev->dev);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. +* If COREDUMP is disabled, the stub will call the free function. +* If there is a codedump pending for the device, the dev_coredumpm() +* will also free new coredump state. */ -#ifdef CONFIG_DEV_COREDUMP 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;drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18if (!drm_dev) {DRM_ERROR ("invalid params\n" );@@ -83,30 +77,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 +4
-13if (!drm_dev) {@@ -117,22 +94,13 @@ 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); +mutex_init (&kms->dump_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 +109,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 +3
-6DRM_ERROR ("invalid params\n" );@@ -150,12 +117,9 @@ 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); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker); -mutex_destroy (&disp_state->mutex); +mutex_destroy (&kms->dump_mutex);}
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 +4
-2@@ -156,8 +156,10 @@ 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; +struct mutex dump_mutex;/* * For async commit, where ->flush_commit() and later happens
Re: [Freedreno] [PATCH v2 2/4] drm/msm: make msm_disp_state transient data struct
Quoted 9 lines · On Tue, 27 Apr 2021 at 22:19, <[email protected]> wrote:
Hi Dmitry
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.
Quoted 5 lines
Can you please check my previous comment on
coredump_pending?https://lore.kernel.org/dri-devel/[email protected]/T/#u
That helps to serialize read/write of coredump.
Regarding the serialization of read/write. As the disp_state becomes the transient object, the need for such serialization vanishes:
- Before the snapshot is complete, the object is not linked outside
of msm_disp_snapshot functions.
- When the snapshot is complete, it becomes linked from the codedump
subsystem. After this it is only read by the coredump, nobody will write to it.
- Next snapshot will allocate a new disp_state structure.
- If dev_coredumpm is called when the previous snapshot is still
referenced (the device exists), the new snapshot is silently freed.
Thus there is no need to sync the read/write operations. They are now naturally serialized.
Quoted 285 lines
Rest of the changes on this one look fine to me.
Quoted 282 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 90 ++++++------------- 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 | 6 +- 4 files changed, 37 insertions(+), 77 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 +18
-23@@ -29,52 +28,47 @@ 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 *kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -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; +INIT_LIST_HEAD (&disp_state->blocks); -mutex_lock (&disp_state->mutex); +/* Serialize dumping here */ +mutex_lock (&kms->dump_mutex);msm_disp_snapshot_capture_state (disp_state); +mutex_unlock (&kms->dump_mutex); +if (MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE ) { p =drm_info_printer (disp_state->drm_dev->dev);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. +* If COREDUMP is disabled, the stub will call the free function. +* If there is a codedump pending for the device, the dev_coredumpm() +* will also free new coredump state. */ -#ifdef CONFIG_DEV_COREDUMP 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");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18@@ -83,30 +77,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 +4
-13@@ -117,22 +94,13 @@ 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); +mutex_init (&kms->dump_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 +109,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 +3
-6@@ -150,12 +117,9 @@ 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); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker); -mutex_destroy (&disp_state->mutex); +mutex_destroy (&kms->dump_mutex);}
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;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 +4
-2@@ -156,8 +156,10 @@ 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; +struct mutex dump_mutex;/* * 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
[email protected]
Reviewed-byRe: [Freedreno] [PATCH v2 2/4] drm/msm: make msm_disp_state transient data struct
Quoted 27 lines · Dmitry Baryshkov
Quoted 9 lines · On Tue, 27 Apr 2021 at 22:19, <[email protected]> wrote:
Hi Dmitry
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.Quoted 5 lines
Can you please check my previous comment on
coredump_pending?https://lore.kernel.org/dri-devel/[email protected]/T/#u
That helps to serialize read/write of coredump.
Regarding the serialization of read/write. As the
disp_statebecomes the transient object, the need for such serialization vanishes:
- Before the snapshot is complete, the object is not linked outside
ofmsm_disp_snapshotfunctions.
- When the snapshot is complete, it becomes linked from the codedump
subsystem. After this it is only read by the coredump, nobody will write to it.
- Next snapshot will allocate a newdisp_statestructure.
- Ifdev_coredumpmis called when the previous snapshot is still
referenced (the device exists), the new snapshot is silently freed.
Quoted 2 lines
Thus there is no need to sync the read/write operations. They are now naturally serialized.
Alright, just make sure to validate the robustness of this using the method mentioned earlier. Apart from that,
Quoted 284 lines
Quoted 284 lines
Rest of the changes on this one look fine to me.
Quoted 280 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 90 ++++++------------- 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 | 6 +- 4 files changed, 37 insertions(+), 77 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 +18
-23@@ -29,52 +28,47 @@ 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 *kms = container_of(work, struct msm_kms, dump_work); +struct drm_device *drm_dev = kms->dev;struct msm_disp_state *disp_state; +struct drm_printer p; - disp_state = data; - -msm_disp_state_free (disp_state); + disp_state =kzalloc (sizeof (struct msm_disp_state ),GFP_KERNEL ); +if (!disp_state) +return ; - disp_state->coredump_pending = false; -} -#endif /* CONFIG_DEV_COREDUMP */ + disp_state->dev = drm_dev->dev; + disp_state->drm_dev = drm_dev; -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; +INIT_LIST_HEAD (&disp_state->blocks); -mutex_lock (&disp_state->mutex); +/* Serialize dumping here */ +mutex_lock (&kms->dump_mutex);msm_disp_snapshot_capture_state (disp_state); +mutex_unlock (&kms->dump_mutex); +if (MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE ) { p =drm_info_printer (disp_state->drm_dev->dev);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. +* If COREDUMP is disabled, the stub will call the free function. +* If there is a codedump pending for the device, the dev_coredumpm() +* will also free new coredump state. */ -#ifdef CONFIG_DEV_COREDUMP 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");drivers/gpu/drm/msm/disp/msm_disp_snapshot.c +1
-18@@ -83,30 +77,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 +4
-13@@ -117,22 +94,13 @@ 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); +mutex_init (&kms->dump_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 +109,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 +3
-6@@ -150,12 +117,9 @@ 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); +if (kms->dump_worker) +kthread_destroy_worker (kms->dump_worker); -mutex_destroy (&disp_state->mutex); +mutex_destroy (&kms->dump_mutex);}
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;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 +4
-2@@ -156,8 +156,10 @@ 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; +struct mutex dump_mutex;
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/msm/msm_kms.h struct msm_kms { · line 165
Quoted 2 lines
drivers/gpu/drm/msm/msm_kms.h +0
-0/* * For async commit, where ->flush_commit() and later happens
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/4 drm/msm: get rid of msm_iomap_size
In reply to Dmitry BaryshkovInstead of looping throught the resources each time to get the DSI CTRL area size, get it at the ioremap time.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++-- drivers/gpu/drm/msm/msm_drv.c | 27 +++++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 3 ++- 3 files changed, 14 insertions(+), 21 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +3 -2
@@ -102,6 +102,7 @@ struct msm_dsi_host {int id;void __iomem *ctrl_base; +phys_addr_t ctrl_size;struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX ];struct clk *bus_clks[DSI_BUS_CLK_MAX ];
@@ -1839,7 +1840,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) goto fail; } - msm_host->ctrl_base =msm_ioremap (pdev,"dsi_ctrl" ,"DSI CTRL" ); + msm_host->ctrl_base =msm_ioremap_size (pdev,"dsi_ctrl" ,"DSI CTRL" , &msm_host->ctrl_size);if (IS_ERR (msm_host->ctrl_base)) {pr_err ("%s: unable to map Dsi ctrl base\n" , __func__); ret =PTR_ERR (msm_host->ctrl_base);
@@ -2494,7 +2495,7 @@ void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_hopm_runtime_get_sync (&msm_host->pdev->dev); -msm_disp_snapshot_add_block (disp_state,msm_iomap_size (msm_host->pdev,"dsi_ctrl" ), +msm_disp_snapshot_add_block (disp_state, msm_host->ctrl_size, msm_host->ctrl_base,"dsi%d_ctrl" , msm_host->id);pm_runtime_put_sync (&msm_host->pdev->dev);
drivers/gpu/drm/msm/msm_drv.c +9 -18
@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize) {struct resource *res;unsigned long size;
@@ -153,37 +153,28 @@ static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *nameif (reglog)printk (KERN_DEBUG "IO:region %s %p %08lx\n" , dbgname, ptr, size); +if (psize) + *psize = size; +return ptr; }void __iomem *msm_ioremap (struct platform_device *pdev,const char *name,const char *dbgname) { -return _msm_ioremap (pdev, name, dbgname, false); +return _msm_ioremap (pdev, name, dbgname, false,NULL ); }void __iomem *msm_ioremap_quiet (struct platform_device *pdev,const char *name,const char *dbgname) { -return _msm_ioremap (pdev, name, dbgname, true); +return _msm_ioremap (pdev, name, dbgname, true,NULL ); } -unsigned long msm_iomap_size (struct platform_device *pdev,const char *name) +void __iomem *msm_ioremap_size (struct platform_device *pdev,const char *name, +const char *dbgname,phys_addr_t *psize) { -struct resource *res; - -if (name) - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); -else - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - -if (!res) { -dev_dbg (&pdev->dev,"failed to get memory resource: %s\n" , - name); -return 0 ; - } - -return resource_size (res); +return _msm_ioremap (pdev, name, dbgname, false, psize); }void msm_writel (u32 data,void __iomem *addr)
drivers/gpu/drm/msm/msm_drv.h +2 -1
@@ -450,9 +450,10 @@ struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, const char *name);void __iomem *msm_ioremap (struct platform_device *pdev,const char *name,const char *dbgname); +void __iomem *msm_ioremap_size (struct platform_device *pdev,const char *name, +const char *dbgname,phys_addr_t *size);void __iomem *msm_ioremap_quiet (struct platform_device *pdev,const char *name,const char *dbgname); -unsigned long msm_iomap_size (struct platform_device *pdev,const char *name);void msm_writel (u32 data,void __iomem *addr);u32 msm_readl (const void __iomem *addr);void msm_rmw (void __iomem *addr,u32 mask,u32 or);
Signature · 1 line
2.30.2
Re: [Freedreno] [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Hi Dmitry
Quoted 4 lines · Dmitry Baryshkov
Instead of looping throught the resources each time to get the DSI CTRL area size, get it at the ioremap time.
Signed-off-by Dmitry Baryshkov <[email protected]>
We will have to call into the individual modules anyway everytime we take a snapshot as only they have access to the required clocks and the base address.
So even though there is nothing wrong with this change, it still adds a size member which can be avoided because we have to call into the module anyway.
Any strong preference to store the size as opposed to just getting it when we take the snapshot?
Quoted 123 lines
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++-- drivers/gpu/drm/msm/msm_drv.c | 27 +++++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 3 ++- 3 files changed, 14 insertions(+), 21 deletions(-)drivers/gpu/drm/msm/dsi/dsi_host.c +2
-1@@ -102,6 +102,7 @@ struct msm_dsi_host {int id;void __iomem *ctrl_base; +phys_addr_t ctrl_size;struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX ];struct clk *bus_clks[DSI_BUS_CLK_MAX ];@@ -1839,7 +1840,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) goto fail; } - msm_host->ctrl_base =msm_ioremap (pdev,"dsi_ctrl" ,"DSI CTRL" ); + msm_host->ctrl_base =msm_ioremap_size (pdev,"dsi_ctrl" ,"DSI CTRL" , &msm_host->ctrl_size);if (IS_ERR (msm_host->ctrl_base)) {pr_err ("%s: unable to map Dsi ctrl base\n" , __func__);drivers/gpu/drm/msm/dsi/dsi_host.c +1
-1ret =PTR_ERR (msm_host->ctrl_base);@@ -2494,7 +2495,7 @@ void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_hopm_runtime_get_sync (&msm_host->pdev->dev); -msm_disp_snapshot_add_block (disp_state,msm_iomap_size (msm_host->pdev,"dsi_ctrl" ), +msm_disp_snapshot_add_block (disp_state, msm_host->ctrl_size, msm_host->ctrl_base,"dsi%d_ctrl" , msm_host->id);drivers/gpu/drm/msm/dsi/dsi_host.c +0
-0pm_runtime_put_sync (&msm_host->pdev->dev);drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize) {drivers/gpu/drm/msm/msm_drv.c +0
-0struct resource *res;unsigned long size;@@ -153,37 +153,28 @@ static void __iomem *_msm_ioremap(struct
platform_device*pdev, const char *namedrivers/gpu/drm/msm/msm_drv.c +3
-0if (reglog)printk (KERN_DEBUG "IO:region %s %p %08lx\n" , dbgname, ptr, size); +if (psize) + *psize = size; +return ptr; } void __iomem *msm_ioremap(struct platform_device *pdev, const char*name,
drivers/gpu/drm/msm/msm_drv.c +1
-1const char *dbgname) { -return _msm_ioremap (pdev, name, dbgname, false); +return _msm_ioremap (pdev, name, dbgname, false,NULL ); } void __iomem *msm_ioremap_quiet(struct platform_device *pdev, constchar *name,
drivers/gpu/drm/msm/msm_drv.c +1
-2const char *dbgname) { -return _msm_ioremap (pdev, name, dbgname, true); +return _msm_ioremap (pdev, name, dbgname, true,NULL ); } -unsigned long msm_iomap_size(struct platform_device *pdev, const char*name)
+void__iomem*msm_ioremap_size(structplatform_device*pdev, const char *name,drivers/gpu/drm/msm/msm_drv.c +2
-14+ const char *dbgname, phys_addr_t *psize) { -struct resource *res; - -if (name) - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); -else - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - -if (!res) { -dev_dbg (&pdev->dev,"failed to get memory resource: %s\n" , - name); -return 0 ; - } - -return resource_size (res); + return _msm_ioremap(pdev, name, dbgname, false, psize); }void msm_writel (u32 data,void __iomem *addr)drivers/gpu/drm/msm/msm_drv.h +2
-1@@ -450,9 +450,10 @@ struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, const char *name);void __iomem *msm_ioremap (struct platform_device *pdev,const char *name,const char *dbgname); +void __iomem *msm_ioremap_size (struct platform_device *pdev,const char *name, +const char *dbgname,phys_addr_t *size);void __iomem *msm_ioremap_quiet (struct platform_device *pdev,const char *name,const char *dbgname); -unsigned long msm_iomap_size(struct platform_device *pdev, const char
Quoted 4 lines
*name);
voidmsm_writel(u32 data, void __iomem *addr); u32msm_readl(const void __iomem *addr); voidmsm_rmw(void __iomem *addr, u32 mask, u32 or);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Freedreno] [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Quoted 12 lines · On Tue, 27 Apr 2021 at 22:30, <[email protected]> wrote:
Hi Dmitry
Quoted 4 lines · Dmitry Baryshkov
Instead of looping throught the resources each time to get the DSI CTRL area size, get it at the ioremap time.
Signed-off-by Dmitry Baryshkov <[email protected]>We will have to call into the individual modules anyway everytime we take a snapshot as only they have access to the required clocks and the base address.
Quoted 7 lines
So even though there is nothing wrong with this change, it still adds a size member
which can be avoided because we have to call into the module anyway.Any strong preference to store the size as opposed to just getting it when we take
the snapshot?
Locality. We ioremap the resource from one piece of code and then we get it's length from a completely different piece of code. If we ever change e.g. the ioremap'ed resource name, we'd have to also update snapshot users.
With this patch these changes are done in a transparent way. Whichever we do with the regions in future, there is always a valid base + size combo.
Quoted 130 lines
Quoted 130 lines
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++-- drivers/gpu/drm/msm/msm_drv.c | 27 +++++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 3 ++- 3 files changed, 14 insertions(+), 21 deletions(-)drivers/gpu/drm/msm/dsi/dsi_host.c +2
-1@@ -102,6 +102,7 @@ struct msm_dsi_host {int id;void __iomem *ctrl_base; +phys_addr_t ctrl_size;struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX ];struct clk *bus_clks[DSI_BUS_CLK_MAX ];@@ -1839,7 +1840,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) goto fail; } - msm_host->ctrl_base =msm_ioremap (pdev,"dsi_ctrl" ,"DSI CTRL" ); + msm_host->ctrl_base =msm_ioremap_size (pdev,"dsi_ctrl" ,"DSI CTRL" , &msm_host->ctrl_size);if (IS_ERR (msm_host->ctrl_base)) {pr_err ("%s: unable to map Dsi ctrl base\n" , __func__);ret = PTR_ERR(msm_host->ctrl_base);drivers/gpu/drm/msm/dsi/dsi_host.c +1
-1@@ -2494,7 +2495,7 @@ void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_hopm_runtime_get_sync (&msm_host->pdev->dev); -msm_disp_snapshot_add_block (disp_state,msm_iomap_size (msm_host->pdev,"dsi_ctrl" ), +msm_disp_snapshot_add_block (disp_state, msm_host->ctrl_size, msm_host->ctrl_base,"dsi%d_ctrl" , msm_host->id);pm_runtime_put_sync(&msm_host->pdev->dev);drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize) {struct resource *res; unsigned long size;drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -153,37 +153,28 @@ static void __iomem *_msm_ioremap(struct
platform_device*pdev, const char *nameif (reglog) printk(KERN_DEBUG "IO:region %s %p %08lx\n", dbgname, ptr, size);drivers/gpu/drm/msm/msm_drv.c +3
-0+if (psize) + *psize = size; +return ptr; } void __iomem *msm_ioremap(struct platform_device *pdev, const char*name,
const char *dbgname)
{drivers/gpu/drm/msm/msm_drv.c +1
-1-return _msm_ioremap (pdev, name, dbgname, false); +return _msm_ioremap (pdev, name, dbgname, false,NULL ); } void __iomem *msm_ioremap_quiet(struct platform_device *pdev, constchar *name,
const char *dbgname)
{drivers/gpu/drm/msm/msm_drv.c +1
-2-return _msm_ioremap (pdev, name, dbgname, true); +return _msm_ioremap (pdev, name, dbgname, true,NULL ); } -unsigned long msm_iomap_size(struct platform_device *pdev, const char*name)
+void__iomem*msm_ioremap_size(structplatform_device*pdev, const char *name,drivers/gpu/drm/msm/msm_drv.c +2
-14+ const char *dbgname, phys_addr_t *psize) { -struct resource *res; - -if (name) - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); -else - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - -if (!res) { -dev_dbg (&pdev->dev,"failed to get memory resource: %s\n" , - name); -return 0 ; - } - -return resource_size (res); + return _msm_ioremap(pdev, name, dbgname, false, psize); }void msm_writel (u32 data,void __iomem *addr)drivers/gpu/drm/msm/msm_drv.h +2
-1@@ -450,9 +450,10 @@ struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, const char *name);void __iomem *msm_ioremap (struct platform_device *pdev,const char *name,const char *dbgname); +void __iomem *msm_ioremap_size (struct platform_device *pdev,const char *name, +const char *dbgname,phys_addr_t *size);void __iomem *msm_ioremap_quiet (struct platform_device *pdev,const char *name,const char *dbgname); -unsigned long msm_iomap_size(struct platform_device *pdev, const char*name);
voidmsm_writel(u32 data, void __iomem *addr); u32msm_readl(const void __iomem *addr); voidmsm_rmw(void __iomem *addr, u32 mask, u32 or);
Signature · 2 lines
With best wishes Dmitry
[email protected]
Reviewed-byRe: [Freedreno] [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Quoted 21 lines · Dmitry Baryshkov
Quoted 12 lines · On Tue, 27 Apr 2021 at 22:30, <[email protected]> wrote:
Hi Dmitry
Quoted 4 lines · Dmitry Baryshkov
Instead of looping throught the resources each time to get the DSI CTRL area size, get it at the ioremap time.
Signed-off-by Dmitry Baryshkov <[email protected]>We will have to call into the individual modules anyway everytime we take a snapshot as only they have access to the required clocks and the base address.
Quoted 7 lines
So even though there is nothing wrong with this change, it still adds a size member
which can be avoided because we have to call into the module anyway.Any strong preference to store the size as opposed to just getting it when we take
the snapshot?
Quoted 8 lines
Locality. We ioremap the resource from one piece of code and then we get it's length from a completely different piece of code. If we ever change e.g. the ioremap'ed resource name, we'd have to also update snapshot users.
With this patch these changes are done in a transparent way. Whichever we do with the regions in future, there is always a valid base + size combo.
Alright, no further concerns from my side on this:
Quoted 122 lines
Quoted 122 lines
Quoted 122 lines
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++-- drivers/gpu/drm/msm/msm_drv.c | 27 +++++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 3 ++- 3 files changed, 14 insertions(+), 21 deletions(-)drivers/gpu/drm/msm/dsi/dsi_host.c +2
-1@@ -102,6 +102,7 @@ struct msm_dsi_host {int id;void __iomem *ctrl_base; +phys_addr_t ctrl_size;struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX ];struct clk *bus_clks[DSI_BUS_CLK_MAX ];@@ -1839,7 +1840,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) goto fail; } - msm_host->ctrl_base =msm_ioremap (pdev,"dsi_ctrl" ,"DSI CTRL" ); + msm_host->ctrl_base =msm_ioremap_size (pdev,"dsi_ctrl" ,"DSI CTRL" , &msm_host->ctrl_size);if (IS_ERR (msm_host->ctrl_base)) {pr_err ("%s: unable to map Dsi ctrl base\n" , __func__);ret = PTR_ERR(msm_host->ctrl_base);drivers/gpu/drm/msm/dsi/dsi_host.c +1
-1@@ -2494,7 +2495,7 @@ void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_hopm_runtime_get_sync (&msm_host->pdev->dev); -msm_disp_snapshot_add_block (disp_state,msm_iomap_size (msm_host->pdev,"dsi_ctrl" ), +msm_disp_snapshot_add_block (disp_state, msm_host->ctrl_size, msm_host->ctrl_base,"dsi%d_ctrl" , msm_host->id);pm_runtime_put_sync(&msm_host->pdev->dev);drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize) {struct resource *res; unsigned long size;drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -153,37 +153,28 @@ static void __iomem *_msm_ioremap(struct
platform_device*pdev, const char *nameif (reglog) printk(KERN_DEBUG "IO:region %s %p %08lx\n", dbgname, ptr, size);drivers/gpu/drm/msm/msm_drv.c +3
-0+if (psize) + *psize = size; +return ptr; } void __iomem *msm_ioremap(struct platform_device *pdev, const char*name,
const char *dbgname)
{drivers/gpu/drm/msm/msm_drv.c +1
-1-return _msm_ioremap (pdev, name, dbgname, false); +return _msm_ioremap (pdev, name, dbgname, false,NULL ); } void __iomem *msm_ioremap_quiet(struct platform_device *pdev, constchar *name,
const char *dbgname)
{drivers/gpu/drm/msm/msm_drv.c +1
-2-return _msm_ioremap (pdev, name, dbgname, true); +return _msm_ioremap (pdev, name, dbgname, true,NULL ); } -unsigned long msm_iomap_size(struct platform_device *pdev, const char*name)
+void__iomem*msm_ioremap_size(structplatform_device*pdev, const char *name,drivers/gpu/drm/msm/msm_drv.c +2
-14+ const char *dbgname, phys_addr_t *psize) { -struct resource *res; - -if (name) - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); -else - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - -if (!res) { -dev_dbg (&pdev->dev,"failed to get memory resource: %s\n" , - name); -return 0 ; - } - -return resource_size (res); + return _msm_ioremap(pdev, name, dbgname, false, psize); }void msm_writel (u32 data,void __iomem *addr)drivers/gpu/drm/msm/msm_drv.h +2
-0@@ -450,9 +450,10 @@ struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, const char *name);void __iomem *msm_ioremap (struct platform_device *pdev,const char *name,const char *dbgname); +void __iomem *msm_ioremap_size (struct platform_device *pdev,const char *name, +const char *dbgname,phys_addr_t *size);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.h +0
-1void __iomem *msm_ioremap_quiet (struct platform_device *pdev,const char *name,const char *dbgname); -unsigned long msm_iomap_size(struct platform_device *pdev, const char*name);
voidmsm_writel(u32 data, void __iomem *addr); u32msm_readl(const void __iomem *addr); voidmsm_rmw(void __iomem *addr, u32 mask, u32 or);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
In reply to Dmitry BaryshkovOn Mon 26 Apr 19:18 CDT 2021, Dmitry Baryshkov wrote:
[..]
drivers/gpu/drm/msm/msm_drv.c struct clk *msm_clk_get(struct platform_device *pdev, const char *name) · line 127
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize)
size_t sounds like a better fit for psize...
Regards,
Bjorn
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Quoted 9 lines · Bjorn Andersson
On Mon 26 Apr 19:18 CDT 2021, Dmitry Baryshkov wrote:
[..]Quoted 7 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }
Quoted 5 lines
drivers/gpu/drm/msm/msm_drv.c struct clk *msm_clk_get(struct platform_device *pdev, const char *name) · line 127
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize)
size_tsounds like a better fit for psize...
I was trying to select between size_t and phys_addr_t, settling on the latter one because it is used for resource size.
Signature · 6 lines
With best wishes Dmitry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Quoted 15 lines · Dmitry Baryshkov
Quoted 13 lines · Bjorn Andersson
On Mon 26 Apr 19:18 CDT 2021, Dmitry Baryshkov wrote:
[..]drivers/gpu/drm/msm/msm_drv.c struct clk *msm_clk_get(struct platform_device *pdev, const char *name) · line 126
Quoted 9 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize)
size_tsounds like a better fit for psize...
Quoted 3 lines
I was trying to select between
size_tandphys_addr_t, settling on the latter one because it is used for resource size.
I always thought resource_size_t was an alias for size_t, now I know :)
That said, I still think that size_t (in line with resource_size_t) gives a better hint about what the parameter represents...
Regards,
Bjorn
Re: [PATCH v2 3/4] drm/msm: get rid of msm_iomap_size
Quoted 17 lines · Bjorn Andersson
Quoted 15 lines · Dmitry Baryshkov
Quoted 13 lines · Bjorn Andersson
On Mon 26 Apr 19:18 CDT 2021, Dmitry Baryshkov wrote:
[..]drivers/gpu/drm/msm/msm_drv.c struct clk *msm_clk_get(struct platform_device *pdev, const char *name) · line 126
Quoted 9 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -124,7 +124,7 @@ struct clk *msm_clk_get(struct platform_device *pdev, const char *name) }static void __iomem *_msm_ioremap (struct platform_device *pdev,const char *name, -const char *dbgname,bool quiet) +const char *dbgname,bool quiet,phys_addr_t *psize)
size_tsounds like a better fit for psize...
Quoted 8 lines
Quoted 3 lines
I was trying to select between
size_tandphys_addr_t, settling on the latter one because it is used for resource size.I always thought
resource_size_twas an alias forsize_t, now I know :)That said, I still think that
size_t(in line withresource_size_t) gives a better hint about what the parameter represents...
Indeed, I'll change that in the next version.
Quoted 4 lines
Regards,
Bjorn
Signature · 2 lines
With best wishes Dmitry
PATCH v2 4/4 drm/msm/dsi: add DSI PHY registers to snapshot data
In reply to Dmitry BaryshkovAdd DSI PHY registers to the msm state snapshots to be able to check their contents.
--- drivers/gpu/drm/msm/dsi/dsi.c | 1 + drivers/gpu/drm/msm/dsi/dsi.h | 1 + drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 31 +++++++++++++++++++++++---- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 4 ++++ 4 files changed, 33 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +1 -0
@@ -269,5 +269,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,void msm_dsi_snapshot (struct msm_disp_state *disp_state,struct msm_dsi *msm_dsi) {msm_dsi_host_snapshot (disp_state, msm_dsi->host); +msm_dsi_phy_snapshot (disp_state, msm_dsi->phy); }
drivers/gpu/drm/msm/dsi/dsi.h +1 -0
@@ -176,6 +176,7 @@ int msm_dsi_phy_get_clk_provider(struct msm_dsi_phy *phy, struct clk **byte_clk_provider, struct clk **pixel_clk_provider);void msm_dsi_phy_pll_save_state (struct msm_dsi_phy *phy);int msm_dsi_phy_pll_restore_state (struct msm_dsi_phy *phy); +void msm_dsi_phy_snapshot (struct msm_disp_state *disp_state,struct msm_dsi_phy *phy);#endif /* __DSI_CONNECTOR_H__ */
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +27 -4
@@ -658,14 +658,14 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) phy->regulator_ldo_mode =of_property_read_bool (dev->of_node,"qcom,dsi-phy-regulator-ldo-mode" ); - phy->base =msm_ioremap (pdev,"dsi_phy" ,"DSI_PHY" ); + phy->base =msm_ioremap_size (pdev,"dsi_phy" ,"DSI_PHY" , &phy->base_size);if (IS_ERR (phy->base)) {DRM_DEV_ERROR (dev,"%s: failed to map phy base\n" , __func__); ret = -ENOMEM ; goto fail; } - phy->pll_base =msm_ioremap (pdev,"dsi_pll" ,"DSI_PLL" ); + phy->pll_base =msm_ioremap_size (pdev,"dsi_pll" ,"DSI_PLL" , &phy->pll_size);if (IS_ERR (phy->pll_base)) {DRM_DEV_ERROR (&pdev->dev,"%s: failed to map pll base\n" , __func__); ret = -ENOMEM ;
@@ -673,7 +673,7 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) }if (phy->cfg->has_phy_lane) { - phy->lane_base =msm_ioremap (pdev,"dsi_phy_lane" ,"DSI_PHY_LANE" ); + phy->lane_base =msm_ioremap_size (pdev,"dsi_phy_lane" ,"DSI_PHY_LANE" , &phy->lane_size);if (IS_ERR (phy->lane_base)) {DRM_DEV_ERROR (&pdev->dev,"%s: failed to map phy lane base\n" , __func__); ret = -ENOMEM ;
@@ -682,7 +682,7 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) }if (phy->cfg->has_phy_regulator) { - phy->reg_base =msm_ioremap (pdev,"dsi_phy_regulator" ,"DSI_PHY_REG" ); + phy->reg_base =msm_ioremap_size (pdev,"dsi_phy_regulator" ,"DSI_PHY_REG" , &phy->reg_size);if (IS_ERR (phy->reg_base)) {DRM_DEV_ERROR (&pdev->dev,"%s: failed to map phy regulator base\n" , __func__); ret = -ENOMEM ;
@@ -868,3 +868,26 @@ int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy)return 0 ; } + +void msm_dsi_phy_snapshot (struct msm_disp_state *disp_state,struct msm_dsi_phy *phy) +{ +msm_disp_snapshot_add_block (disp_state, + phy->base_size, phy->base, +"dsi%d_phy" , phy->id); + +/* Do not try accessing PLL registers if it is switched off */ +if (phy->pll_on) +msm_disp_snapshot_add_block (disp_state, + phy->pll_size, phy->pll_base, +"dsi%d_pll" , phy->id); + +if (phy->lane_base) +msm_disp_snapshot_add_block (disp_state, + phy->lane_size, phy->lane_base, +"dsi%d_lane" , phy->id); + +if (phy->reg_base) +msm_disp_snapshot_add_block (disp_state, + phy->reg_size, phy->reg_base, +"dsi%d_reg" , phy->id); +}
drivers/gpu/drm/msm/dsi/phy/dsi_phy.h +4 -0
@@ -85,6 +85,10 @@ struct msm_dsi_phy {void __iomem *pll_base;void __iomem *reg_base;void __iomem *lane_base; +phys_addr_t base_size; +phys_addr_t pll_size; +phys_addr_t reg_size; +phys_addr_t lane_size;int id;struct clk *ahb_clk;
Signature · 1 line
2.30.2
Re: [PATCH v2 4/4] drm/msm/dsi: add DSI PHY registers to snapshot data
Quoted 4 lines · Dmitry Baryshkov
Add DSI PHY registers to the msm state snapshots to be able to check their contents.
Signed-off-by Dmitry Baryshkov <[email protected]>
Quoted 129 lines
--- drivers/gpu/drm/msm/dsi/dsi.c | 1 + drivers/gpu/drm/msm/dsi/dsi.h | 1 + drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 31 +++++++++++++++++++++++---- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 4 ++++ 4 files changed, 33 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/dsi/dsi.c +1
-0@@ -269,5 +269,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,struct drm_device *dev, void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi) { msm_dsi_host_snapshot(disp_state, msm_dsi->host); +msm_dsi_phy_snapshot (disp_state, msm_dsi->phy);}
drivers/gpu/drm/msm/dsi/dsi.h +1
-0@@ -176,6 +176,7 @@ int msm_dsi_phy_get_clk_provider(struct msm_dsi_phy *phy, struct clk **byte_clk_provider, struct clk **pixel_clk_provider);void msm_dsi_phy_pll_save_state (struct msm_dsi_phy *phy);int msm_dsi_phy_pll_restore_state (struct msm_dsi_phy *phy); +void msm_dsi_phy_snapshot (struct msm_disp_state *disp_state,struct msm_dsi_phy *phy);#endif /*
__DSI_CONNECTOR_H__*/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +2
-2@@ -658,14 +658,14 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) phy->regulator_ldo_mode = of_property_read_bool(dev->of_node,"qcom,dsi-phy-regulator-ldo-mode" ); - phy->base =msm_ioremap (pdev,"dsi_phy" ,"DSI_PHY" ); + phy->base =msm_ioremap_size (pdev,"dsi_phy" ,"DSI_PHY" , &phy->base_size);if (IS_ERR (phy->base)) {DRM_DEV_ERROR (dev,"%s: failed to map phy base\n" , __func__); ret = -ENOMEM ; goto fail; } - phy->pll_base =msm_ioremap (pdev,"dsi_pll" ,"DSI_PLL" ); + phy->pll_base =msm_ioremap_size (pdev,"dsi_pll" ,"DSI_PLL" , &phy->pll_size);drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +1
-1if (IS_ERR (phy->pll_base)) {DRM_DEV_ERROR (&pdev->dev,"%s: failed to map pll base\n" , __func__); ret = -ENOMEM ;@@ -673,7 +673,7 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) }if (phy->cfg->has_phy_lane) { - phy->lane_base =msm_ioremap (pdev,"dsi_phy_lane" ,"DSI_PHY_LANE" ); + phy->lane_base =msm_ioremap_size (pdev,"dsi_phy_lane" ,"DSI_PHY_LANE" , &phy->lane_size);if (IS_ERR (phy->lane_base)) {DRM_DEV_ERROR(&pdev->dev, "%s: failed to map phy lane base\n",
__func__);drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +1
-1ret = -ENOMEM ;@@ -682,7 +682,7 @@ static int dsi_phy_driver_probe(struct platform_device *pdev) }if (phy->cfg->has_phy_regulator) { - phy->reg_base =msm_ioremap (pdev,"dsi_phy_regulator" , "DSI_PHY_REG"); + phy->reg_base =msm_ioremap_size (pdev,"dsi_phy_regulator" ,"DSI_PHY_REG" , &phy->reg_size);drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +0
-0if (IS_ERR (phy->reg_base)) { DRM_DEV_ERROR(&pdev->dev, "%s: failed to map phy regulatorbase\n",
__func__);drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +2
-0ret = -ENOMEM ;@@ -868,3 +868,26 @@ int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy)return 0 ; } + +void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct
msm_dsi_phy*phy)drivers/gpu/drm/msm/dsi/phy/dsi_phy.c +21
-0+{ +msm_disp_snapshot_add_block (disp_state, + phy->base_size, phy->base, +"dsi%d_phy" , phy->id); + +/* Do not try accessing PLL registers if it is switched off */ +if (phy->pll_on) +msm_disp_snapshot_add_block (disp_state, + phy->pll_size, phy->pll_base, +"dsi%d_pll" , phy->id); + +if (phy->lane_base) +msm_disp_snapshot_add_block (disp_state, + phy->lane_size, phy->lane_base, +"dsi%d_lane" , phy->id); + +if (phy->reg_base) +msm_disp_snapshot_add_block (disp_state, + phy->reg_size, phy->reg_base, +"dsi%d_reg" , phy->id); +}drivers/gpu/drm/msm/dsi/phy/dsi_phy.h +4
-0@@ -85,6 +85,10 @@ struct msm_dsi_phy {void __iomem *pll_base;void __iomem *reg_base;void __iomem *lane_base; +phys_addr_t base_size; +phys_addr_t pll_size; +phys_addr_t reg_size; +phys_addr_t lane_size;int id;struct clk *ahb_clk;
Quoted 8 lines · Dmitry Baryshkov
Rework MSM coredump support: add DSI PHY registers, simplify snapshotting code.
Changes since v1:
- Readd mutex serializing register snapshot calls- Add DSI PHY register dumping support
Need to mention the dependency here , got missed from the prev patchset
Quoted 24 lines
----------------------------------------------------------------
Dmitry Baryshkov (4):
drm/msm: pass dump state as a function argument drm/msm: makemsm_disp_statetransient data struct drm/msm: get rid ofmsm_iomap_sizedrm/msm/dsi: add DSI PHY registers to snapshot datadrivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +- drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 90 +++++++---------------- 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 | 5 +- drivers/gpu/drm/msm/dsi/dsi.h | 5 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 11 +-- drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 31 +++++++- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 4 + drivers/gpu/drm/msm/msm_drv.c | 27 +++---- drivers/gpu/drm/msm/msm_drv.h | 6 +- drivers/gpu/drm/msm/msm_kms.h | 8 +- 13 files changed, 97 insertions(+), 142 deletions(-)
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel