We cleaned up RM reserve api's enough to get rid of most of its unwanted checks and release handlers. To improve further the readability of the function, merging down the individual HW type allocators into one function. Signed-off-by: Jeykumar Sankaran <jsanka@xxxxxxxxxxxxxx> --- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 73 +++++++++++----------------------- 1 file changed, 24 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c index f794d13..5304597 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c @@ -22,15 +22,6 @@ #include "dpu_trace.h" /** - * struct dpu_rm_requirements - Reservation requirements parameter bundle - * @hw_res: Hardware resources required as reported by the encoders - */ -struct dpu_rm_requirements { - struct dpu_encoder_hw_resources hw_res; -}; - - -/** * struct dpu_rm_hw_blk - hardware block tracking list member * @list: List head for list of all hardware blocks tracking items * @in_use: True, if the hw block is assigned to a display pipeline. @@ -427,41 +418,6 @@ static int _dpu_rm_reserve_intfs( return 0; } -static int _dpu_rm_make_reservation( - struct dpu_rm *rm, - struct dpu_crtc_state *dpu_cstate, - struct dpu_rm_requirements *reqs) -{ - int ret; - - ret = _dpu_rm_reserve_lms(rm, dpu_cstate); - if (ret) { - DPU_ERROR("unable to find appropriate mixers\n"); - return ret; - } - - ret = _dpu_rm_reserve_ctls(rm, dpu_cstate); - if (ret) { - DPU_ERROR("unable to find appropriate CTL\n"); - return ret; - } - - ret = _dpu_rm_reserve_intfs(rm, dpu_cstate, &reqs->hw_res); - if (ret) { - DPU_ERROR("unable to find appropriate INTF\n"); - return ret; - } - - return ret; -} - -static void _dpu_rm_populate_requirements( - struct drm_encoder *enc, - struct dpu_rm_requirements *reqs) -{ - dpu_encoder_get_hw_resources(enc, &reqs->hw_res); -} - static int _dpu_rm_release_hw(struct dpu_rm *rm, enum dpu_hw_blk_type type, int id) { @@ -535,7 +491,7 @@ int dpu_rm_reserve( struct drm_encoder *enc, struct drm_crtc_state *crtc_state) { - struct dpu_rm_requirements reqs; + struct dpu_encoder_hw_resources hw_res; struct dpu_crtc_state *dpu_cstate = to_dpu_crtc_state(crtc_state); int ret; @@ -548,14 +504,33 @@ int dpu_rm_reserve( mutex_lock(&rm->rm_lock); - _dpu_rm_populate_requirements(enc, &reqs); + dpu_encoder_get_hw_resources(enc, &hw_res); - ret = _dpu_rm_make_reservation(rm, dpu_cstate, &reqs); + ret = _dpu_rm_reserve_lms(rm, dpu_cstate); if (ret) { - DPU_ERROR("failed to reserve hw resources: %d\n", ret); - _dpu_rm_release_reservation(rm, dpu_cstate); + DPU_ERROR("unable to find appropriate mixers\n"); + goto cleanup_on_fail; } + ret = _dpu_rm_reserve_ctls(rm, dpu_cstate); + if (ret) { + DPU_ERROR("unable to find appropriate CTL\n"); + goto cleanup_on_fail; + } + + ret = _dpu_rm_reserve_intfs(rm, dpu_cstate, &hw_res); + if (ret) { + DPU_ERROR("unable to find appropriate INTF\n"); + goto cleanup_on_fail; + } + + mutex_unlock(&rm->rm_lock); + + return ret; + +cleanup_on_fail: + _dpu_rm_release_reservation(rm, dpu_cstate); + mutex_unlock(&rm->rm_lock); return ret; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel