Skip to content

Commit 3789785

Browse files
lumagrobclark
authored andcommitted
drm/msm/dpu: simplify DPU's regset32 code
Squash dpu_debugfs_setup_regset32() into dpu_debugfs_create_regset32(). it makes little sense to have separate function to just setup the structure. Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Abhinav Kumar <[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 927e8bc commit 3789785

File tree

3 files changed

+33
-64
lines changed

3 files changed

+33
-64
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
182182

183183
}
184184

185+
/*
186+
* Companion structure for dpu_debugfs_create_regset32.
187+
*/
188+
struct dpu_debugfs_regset32 {
189+
uint32_t offset;
190+
uint32_t blk_len;
191+
struct dpu_kms *dpu_kms;
192+
};
193+
185194
static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data)
186195
{
187196
struct dpu_debugfs_regset32 *regset = s->private;
@@ -229,24 +238,23 @@ static const struct file_operations dpu_fops_regset32 = {
229238
.release = single_release,
230239
};
231240

232-
void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
241+
void dpu_debugfs_create_regset32(const char *name, umode_t mode,
242+
void *parent,
233243
uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms)
234244
{
235-
if (regset) {
236-
regset->offset = offset;
237-
regset->blk_len = length;
238-
regset->dpu_kms = dpu_kms;
239-
}
240-
}
245+
struct dpu_debugfs_regset32 *regset;
241246

242-
void dpu_debugfs_create_regset32(const char *name, umode_t mode,
243-
void *parent, struct dpu_debugfs_regset32 *regset)
244-
{
245-
if (!name || !regset || !regset->dpu_kms || !regset->blk_len)
247+
if (WARN_ON(!name || !dpu_kms || !length))
248+
return;
249+
250+
regset = devm_kzalloc(&dpu_kms->pdev->dev, sizeof(*regset), GFP_KERNEL);
251+
if (!regset)
246252
return;
247253

248254
/* make sure offset is a multiple of 4 */
249-
regset->offset = round_down(regset->offset, 4);
255+
regset->offset = round_down(offset, 4);
256+
regset->blk_len = length;
257+
regset->dpu_kms = dpu_kms;
250258

251259
debugfs_create_file(name, mode, parent, regset, &dpu_fops_regset32);
252260
}

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -160,33 +160,9 @@ struct dpu_global_state
160160
*
161161
* Documentation/filesystems/debugfs.rst
162162
*
163-
* @dpu_debugfs_setup_regset32: Initialize data for dpu_debugfs_create_regset32
164163
* @dpu_debugfs_create_regset32: Create 32-bit register dump file
165-
* @dpu_debugfs_get_root: Get root dentry for DPU_KMS's debugfs node
166164
*/
167165

168-
/**
169-
* Companion structure for dpu_debugfs_create_regset32. Do not initialize the
170-
* members of this structure explicitly; use dpu_debugfs_setup_regset32 instead.
171-
*/
172-
struct dpu_debugfs_regset32 {
173-
uint32_t offset;
174-
uint32_t blk_len;
175-
struct dpu_kms *dpu_kms;
176-
};
177-
178-
/**
179-
* dpu_debugfs_setup_regset32 - Initialize register block definition for debugfs
180-
* This function is meant to initialize dpu_debugfs_regset32 structures for use
181-
* with dpu_debugfs_create_regset32.
182-
* @regset: opaque register definition structure
183-
* @offset: sub-block offset
184-
* @length: sub-block length, in bytes
185-
* @dpu_kms: pointer to dpu kms structure
186-
*/
187-
void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
188-
uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms);
189-
190166
/**
191167
* dpu_debugfs_create_regset32 - Create register read back file for debugfs
192168
*
@@ -195,20 +171,16 @@ void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
195171
* names/offsets do not need to be provided. The 'read' function simply outputs
196172
* sequential register values over a specified range.
197173
*
198-
* Similar to the related debugfs_create_regset32 API, the structure pointed to
199-
* by regset needs to persist for the lifetime of the created file. The calling
200-
* code is responsible for initialization/management of this structure.
201-
*
202-
* The structure pointed to by regset is meant to be opaque. Please use
203-
* dpu_debugfs_setup_regset32 to initialize it.
204-
*
205174
* @name: File name within debugfs
206175
* @mode: File mode within debugfs
207176
* @parent: Parent directory entry within debugfs, can be NULL
208-
* @regset: Pointer to persistent register block definition
177+
* @offset: sub-block offset
178+
* @length: sub-block length, in bytes
179+
* @dpu_kms: pointer to dpu kms structure
209180
*/
210181
void dpu_debugfs_create_regset32(const char *name, umode_t mode,
211-
void *parent, struct dpu_debugfs_regset32 *regset);
182+
void *parent,
183+
uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms);
212184

213185
/**
214186
* dpu_debugfs_get_root - Return root directory entry for KMS's debugfs

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ struct dpu_plane {
108108
bool is_virtual;
109109
struct list_head mplane_list;
110110
struct dpu_mdss_cfg *catalog;
111-
112-
/* debugfs related stuff */
113-
struct dpu_debugfs_regset32 debugfs_src;
114-
struct dpu_debugfs_regset32 debugfs_scaler;
115-
struct dpu_debugfs_regset32 debugfs_csc;
116111
};
117112

118113
static const uint64_t supported_format_modifiers[] = {
@@ -1371,35 +1366,29 @@ static int _dpu_plane_init_debugfs(struct drm_plane *plane)
13711366
debugfs_root, (unsigned long *)&pdpu->pipe_hw->cap->features);
13721367

13731368
/* add register dump support */
1374-
dpu_debugfs_setup_regset32(&pdpu->debugfs_src,
1369+
dpu_debugfs_create_regset32("src_blk", 0400,
1370+
debugfs_root,
13751371
sblk->src_blk.base + cfg->base,
13761372
sblk->src_blk.len,
13771373
kms);
1378-
dpu_debugfs_create_regset32("src_blk", 0400,
1379-
debugfs_root, &pdpu->debugfs_src);
13801374

13811375
if (cfg->features & BIT(DPU_SSPP_SCALER_QSEED3) ||
13821376
cfg->features & BIT(DPU_SSPP_SCALER_QSEED3LITE) ||
13831377
cfg->features & BIT(DPU_SSPP_SCALER_QSEED2) ||
1384-
cfg->features & BIT(DPU_SSPP_SCALER_QSEED4)) {
1385-
dpu_debugfs_setup_regset32(&pdpu->debugfs_scaler,
1378+
cfg->features & BIT(DPU_SSPP_SCALER_QSEED4))
1379+
dpu_debugfs_create_regset32("scaler_blk", 0400,
1380+
debugfs_root,
13861381
sblk->scaler_blk.base + cfg->base,
13871382
sblk->scaler_blk.len,
13881383
kms);
1389-
dpu_debugfs_create_regset32("scaler_blk", 0400,
1390-
debugfs_root,
1391-
&pdpu->debugfs_scaler);
1392-
}
13931384

13941385
if (cfg->features & BIT(DPU_SSPP_CSC) ||
1395-
cfg->features & BIT(DPU_SSPP_CSC_10BIT)) {
1396-
dpu_debugfs_setup_regset32(&pdpu->debugfs_csc,
1386+
cfg->features & BIT(DPU_SSPP_CSC_10BIT))
1387+
dpu_debugfs_create_regset32("csc_blk", 0400,
1388+
debugfs_root,
13971389
sblk->csc_blk.base + cfg->base,
13981390
sblk->csc_blk.len,
13991391
kms);
1400-
dpu_debugfs_create_regset32("csc_blk", 0400,
1401-
debugfs_root, &pdpu->debugfs_csc);
1402-
}
14031392

14041393
debugfs_create_u32("xin_id",
14051394
0400,

0 commit comments

Comments
 (0)