Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.17.
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4 */
  5
  6#ifndef MSM_DISP_SNAPSHOT_H_
  7#define MSM_DISP_SNAPSHOT_H_
  8
  9#include <drm/drm_atomic_helper.h>
 10#include <drm/drm_device.h>
 11#include "../../../drm_crtc_internal.h"
 12#include <drm/drm_print.h>
 13#include <drm/drm_atomic.h>
 14#include <linux/debugfs.h>
 15#include <linux/list.h>
 16#include <linux/delay.h>
 17#include <linux/spinlock.h>
 18#include <linux/ktime.h>
 19#include <linux/debugfs.h>
 20#include <linux/uaccess.h>
 21#include <linux/dma-buf.h>
 22#include <linux/slab.h>
 23#include <linux/list_sort.h>
 24#include <linux/pm.h>
 25#include <linux/pm_runtime.h>
 26#include <linux/kthread.h>
 27#include <linux/devcoredump.h>
 28#include <stdarg.h>
 29#include "msm_kms.h"
 30
 31#define MSM_DISP_SNAPSHOT_MAX_BLKS		10
 32
 33/* debug option to print the registers in logs */
 34#define MSM_DISP_SNAPSHOT_DUMP_IN_CONSOLE 0
 35
 36/* print debug ranges in groups of 4 u32s */
 37#define REG_DUMP_ALIGN		16
 38
 39/**
 40 * struct msm_disp_state - structure to store current dpu state
 41 * @dev: device pointer
 42 * @drm_dev: drm device pointer
 43 * @atomic_state: atomic state duplicated at the time of the error
 44 * @timestamp: timestamp at which the coredump was captured
 45 */
 46struct msm_disp_state {
 47	struct device *dev;
 48	struct drm_device *drm_dev;
 49
 50	struct list_head blocks;
 51
 52	struct drm_atomic_state *atomic_state;
 53
 54	ktime_t timestamp;
 55};
 56
 57/**
 58 * struct msm_disp_state_block - structure to store each hardware block state
 59 * @name: name of the block
 60 * @drm_dev: handle to the linked list head
 61 * @size: size of the register space of this hardware block
 62 * @state: array holding the register dump of this hardware block
 63 * @base_addr: starting address of this hardware block's register space
 64 */
 65struct msm_disp_state_block {
 66	char name[SZ_128];
 67	struct list_head node;
 68	unsigned int size;
 69	u32 *state;
 70	void __iomem *base_addr;
 71};
 72
 73/**
 74 * msm_disp_snapshot_init - initialize display snapshot
 75 * @drm_dev:	drm device handle
 76 *
 77 * Returns:		0 or -ERROR
 78 */
 79int msm_disp_snapshot_init(struct drm_device *drm_dev);
 80
 81/**
 82 * msm_disp_snapshot_destroy - destroy the display snapshot
 83 * @drm_dev:    drm device handle
 84 *
 85 * Returns:	none
 86 */
 87void msm_disp_snapshot_destroy(struct drm_device *drm_dev);
 88
 89/**
 90 * msm_disp_snapshot_state - trigger to dump the display snapshot
 91 * @drm_dev:	handle to drm device
 92
 93 * Returns:	none
 94 */
 95void msm_disp_snapshot_state(struct drm_device *drm_dev);
 96
 97/**
 98 * msm_disp_state_print - print out the current dpu state
 99 * @disp_state:	    handle to drm device
100 * @p:	    handle to drm printer
101 *
102 * Returns:	none
103 */
104void msm_disp_state_print(struct msm_disp_state *disp_state, struct drm_printer *p);
105
106/**
107 * msm_disp_snapshot_capture_state - utility to capture atomic state and hw registers
108 * @disp_state:	    handle to msm_disp_state struct
109
110 * Returns:	none
111 */
112void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state);
113
114/**
115 * msm_disp_state_free - free the memory after the coredump has been read
116 * @data:	    handle to struct msm_disp_state
117
118 * Returns: none
119 */
120void msm_disp_state_free(void *data);
121
122/**
123 * msm_disp_snapshot_add_block - add a hardware block with its register dump
124 * @disp_state:	    handle to struct msm_disp_state
125 * @name:           name of the hardware block
126 * @len:            size of the register space of the hardware block
127 * @base_addr:      starting address of the register space of the hardware block
128 * @fmt:            format in which the block names need to be printed
129 *
130 * Returns: none
131 */
132__printf(4, 5)
133void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len,
134		void __iomem *base_addr, const char *fmt, ...);
135
136#endif /* MSM_DISP_SNAPSHOT_H_ */