Skip to content

Commit 4f3ec1e

Browse files
committed
drm/msm/dpu: make dpu_format_populate_addrs return void
The function msm_framebuffer_iova() can not fail, it always returns a valid address. Drop the useless checks (that were already performed at the time) and make dpu_format_populate_addrs() return void. Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/612247/ Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-11-617e1ecc4b7a@linaro.org
1 parent b05093f commit 4f3ec1e

4 files changed

Lines changed: 21 additions & 71 deletions

File tree

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,7 @@ static void dpu_encoder_phys_wb_prepare_wb_job(struct dpu_encoder_phys *phys_enc
588588
return;
589589
}
590590

591-
ret = dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
592-
if (ret) {
593-
DPU_DEBUG("failed to populate layout %d\n", ret);
594-
return;
595-
}
591+
dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
596592

597593
wb_cfg->dest.width = job->fb->width;
598594
wb_cfg->dest.height = job->fb->height;

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

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -277,25 +277,15 @@ int dpu_format_populate_plane_sizes(
277277
return _dpu_format_populate_plane_sizes_linear(fmt, fb, layout);
278278
}
279279

280-
static int _dpu_format_populate_addrs_ubwc(
281-
struct msm_gem_address_space *aspace,
282-
struct drm_framebuffer *fb,
283-
struct dpu_hw_fmt_layout *layout)
280+
static void _dpu_format_populate_addrs_ubwc(struct msm_gem_address_space *aspace,
281+
struct drm_framebuffer *fb,
282+
struct dpu_hw_fmt_layout *layout)
284283
{
285284
const struct msm_format *fmt;
286285
uint32_t base_addr = 0;
287286
bool meta;
288287

289-
if (!fb || !layout) {
290-
DRM_ERROR("invalid pointers\n");
291-
return -EINVAL;
292-
}
293-
294288
base_addr = msm_framebuffer_iova(fb, aspace, 0);
295-
if (!base_addr) {
296-
DRM_ERROR("failed to retrieve base addr\n");
297-
return -EFAULT;
298-
}
299289

300290
fmt = msm_framebuffer_format(fb);
301291
meta = MSM_FORMAT_IS_UBWC(fmt);
@@ -330,7 +320,7 @@ static int _dpu_format_populate_addrs_ubwc(
330320
+ layout->plane_size[2] + layout->plane_size[3];
331321

332322
if (!meta)
333-
return 0;
323+
return;
334324

335325
/* configure Y metadata plane */
336326
layout->plane_addr[2] = base_addr;
@@ -361,60 +351,36 @@ static int _dpu_format_populate_addrs_ubwc(
361351
layout->plane_addr[1] = 0;
362352

363353
if (!meta)
364-
return 0;
354+
return;
365355

366356
layout->plane_addr[2] = base_addr;
367357
layout->plane_addr[3] = 0;
368358
}
369-
return 0;
370359
}
371360

372-
static int _dpu_format_populate_addrs_linear(
373-
struct msm_gem_address_space *aspace,
374-
struct drm_framebuffer *fb,
375-
struct dpu_hw_fmt_layout *layout)
361+
static void _dpu_format_populate_addrs_linear(struct msm_gem_address_space *aspace,
362+
struct drm_framebuffer *fb,
363+
struct dpu_hw_fmt_layout *layout)
376364
{
377365
unsigned int i;
378366

379367
/* Populate addresses for simple formats here */
380-
for (i = 0; i < layout->num_planes; ++i) {
368+
for (i = 0; i < layout->num_planes; ++i)
381369
layout->plane_addr[i] = msm_framebuffer_iova(fb, aspace, i);
382-
if (!layout->plane_addr[i]) {
383-
DRM_ERROR("failed to retrieve base addr\n");
384-
return -EFAULT;
385-
}
386-
}
387-
388-
return 0;
389370
}
390371

391-
int dpu_format_populate_addrs(
392-
struct msm_gem_address_space *aspace,
393-
struct drm_framebuffer *fb,
394-
struct dpu_hw_fmt_layout *layout)
372+
void dpu_format_populate_addrs(struct msm_gem_address_space *aspace,
373+
struct drm_framebuffer *fb,
374+
struct dpu_hw_fmt_layout *layout)
395375
{
396376
const struct msm_format *fmt;
397-
int ret;
398-
399-
if (!fb || !layout) {
400-
DRM_ERROR("invalid arguments\n");
401-
return -EINVAL;
402-
}
403-
404-
if ((fb->width > DPU_MAX_IMG_WIDTH) ||
405-
(fb->height > DPU_MAX_IMG_HEIGHT)) {
406-
DRM_ERROR("image dimensions outside max range\n");
407-
return -ERANGE;
408-
}
409377

410378
fmt = msm_framebuffer_format(fb);
411379

412380
/* Populate the addresses given the fb */
413381
if (MSM_FORMAT_IS_UBWC(fmt) ||
414382
MSM_FORMAT_IS_TILE(fmt))
415-
ret = _dpu_format_populate_addrs_ubwc(aspace, fb, layout);
383+
_dpu_format_populate_addrs_ubwc(aspace, fb, layout);
416384
else
417-
ret = _dpu_format_populate_addrs_linear(aspace, fb, layout);
418-
419-
return ret;
385+
_dpu_format_populate_addrs_linear(aspace, fb, layout);
420386
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
3737
* @aspace: address space pointer
3838
* @fb: framebuffer pointer
3939
* @fmtl: format layout structure to populate
40-
*
41-
* Return: error code on failure, -EAGAIN if success but the addresses
42-
* are the same as before or 0 if new addresses were populated
4340
*/
44-
int dpu_format_populate_addrs(
45-
struct msm_gem_address_space *aspace,
46-
struct drm_framebuffer *fb,
47-
struct dpu_hw_fmt_layout *fmtl);
41+
void dpu_format_populate_addrs(struct msm_gem_address_space *aspace,
42+
struct drm_framebuffer *fb,
43+
struct dpu_hw_fmt_layout *layout);
4844

4945
int dpu_format_populate_plane_sizes(
5046
struct drm_framebuffer *fb,

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -684,17 +684,9 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane,
684684
return ret;
685685
}
686686

687-
/* validate framebuffer layout before commit */
688-
ret = dpu_format_populate_addrs(pstate->aspace,
689-
new_state->fb,
690-
&pstate->layout);
691-
if (ret) {
692-
DPU_ERROR_PLANE(pdpu, "failed to get format layout, %d\n", ret);
693-
if (pstate->aspace)
694-
msm_framebuffer_cleanup(new_state->fb, pstate->aspace,
695-
pstate->needs_dirtyfb);
696-
return ret;
697-
}
687+
dpu_format_populate_addrs(pstate->aspace,
688+
new_state->fb,
689+
&pstate->layout);
698690

699691
return 0;
700692
}

0 commit comments

Comments
 (0)