diff options
Diffstat (limited to 'drivers/video/tegra/dc/ext')
-rw-r--r-- | drivers/video/tegra/dc/ext/dev.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/video/tegra/dc/ext/dev.c b/drivers/video/tegra/dc/ext/dev.c index ca4ca5370633..a0d0949f27a7 100644 --- a/drivers/video/tegra/dc/ext/dev.c +++ b/drivers/video/tegra/dc/ext/dev.c @@ -301,16 +301,25 @@ static int lock_windows_for_flip(struct tegra_dc_ext_user *user, struct tegra_dc_ext_flip *args) { struct tegra_dc_ext *ext = user->ext; + u8 idx_mask = 0; int i; for (i = 0; i < DC_N_WINDOWS; i++) { int index = args->win[i].index; - struct tegra_dc_ext_win *win; if (index < 0) continue; - win = &ext->win[index]; + idx_mask |= BIT(index); + } + + for (i = 0; i < DC_N_WINDOWS; i++) { + struct tegra_dc_ext_win *win; + + if (!(idx_mask & BIT(i))) + continue; + + win = &ext->win[i]; mutex_lock(&win->lock); @@ -322,12 +331,10 @@ static int lock_windows_for_flip(struct tegra_dc_ext_user *user, fail_unlock: do { - int index = args->win[i].index; - - if (index < 0) + if (!(idx_mask & BIT(i))) continue; - mutex_unlock(&ext->win[index].lock); + mutex_unlock(&ext->win[i].lock); } while (i--); return -EACCES; @@ -337,6 +344,7 @@ static void unlock_windows_for_flip(struct tegra_dc_ext_user *user, struct tegra_dc_ext_flip *args) { struct tegra_dc_ext *ext = user->ext; + u8 idx_mask = 0; int i; for (i = 0; i < DC_N_WINDOWS; i++) { @@ -345,7 +353,14 @@ static void unlock_windows_for_flip(struct tegra_dc_ext_user *user, if (index < 0) continue; - mutex_unlock(&ext->win[index].lock); + idx_mask |= BIT(index); + } + + for (i = DC_N_WINDOWS - 1; i >= 0; i--) { + if (!(idx_mask & BIT(i))) + continue; + + mutex_unlock(&ext->win[i].lock); } } |