Skip to content

Commit 5987121

Browse files
committed
drm/msm/disp: Export helper for capturing snapshot
We'll re-use this for debugfs. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 857548c commit 5987121

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

drivers/gpu/drm/msm/disp/msm_disp_snapshot.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,42 @@ static ssize_t __maybe_unused disp_devcoredump_read(char *buffer, loff_t offset,
2828
return count - iter.remain;
2929
}
3030

31-
static void _msm_disp_snapshot_work(struct kthread_work *work)
31+
struct msm_disp_state *
32+
msm_disp_snapshot_state_sync(struct msm_kms *kms)
3233
{
33-
struct msm_kms *kms = container_of(work, struct msm_kms, dump_work);
3434
struct drm_device *drm_dev = kms->dev;
3535
struct msm_disp_state *disp_state;
36-
struct drm_printer p;
36+
37+
WARN_ON(!mutex_is_locked(&kms->dump_mutex));
3738

3839
disp_state = kzalloc(sizeof(struct msm_disp_state), GFP_KERNEL);
3940
if (!disp_state)
40-
return;
41+
return ERR_PTR(-ENOMEM);
4142

4243
disp_state->dev = drm_dev->dev;
4344
disp_state->drm_dev = drm_dev;
4445

4546
INIT_LIST_HEAD(&disp_state->blocks);
4647

47-
/* Serialize dumping here */
48-
mutex_lock(&kms->dump_mutex);
49-
5048
msm_disp_snapshot_capture_state(disp_state);
5149

50+
return disp_state;
51+
}
52+
53+
static void _msm_disp_snapshot_work(struct kthread_work *work)
54+
{
55+
struct msm_kms *kms = container_of(work, struct msm_kms, dump_work);
56+
struct msm_disp_state *disp_state;
57+
struct drm_printer p;
58+
59+
/* Serialize dumping here */
60+
mutex_lock(&kms->dump_mutex);
61+
disp_state = msm_disp_snapshot_state_sync(kms);
5262
mutex_unlock(&kms->dump_mutex);
5363

64+
if (IS_ERR(disp_state))
65+
return;
66+
5467
if (MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE) {
5568
p = drm_info_printer(disp_state->drm_dev->dev);
5669
msm_disp_state_print(disp_state, &p);

drivers/gpu/drm/msm/disp/msm_disp_snapshot.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ int msm_disp_snapshot_init(struct drm_device *drm_dev);
8484
*/
8585
void msm_disp_snapshot_destroy(struct drm_device *drm_dev);
8686

87+
/**
88+
* msm_disp_snapshot_state_sync - synchronously snapshot display state
89+
* @kms: the kms object
90+
*
91+
* Returns state or error
92+
*
93+
* Must be called with &kms->dump_mutex held
94+
*/
95+
struct msm_disp_state *msm_disp_snapshot_state_sync(struct msm_kms *kms);
96+
8797
/**
8898
* msm_disp_snapshot_state - trigger to dump the display snapshot
8999
* @drm_dev: handle to drm device

0 commit comments

Comments
 (0)