Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / gma500 / blitter.c
blobcb2504a4a15f9e3519c9c2ac45764559518b3344
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2014, Patrik Jakobsson
4 * All Rights Reserved.
6 * Authors: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
7 */
9 #include "psb_drv.h"
11 #include "blitter.h"
12 #include "psb_reg.h"
14 /* Wait for the blitter to be completely idle */
15 int gma_blt_wait_idle(struct drm_psb_private *dev_priv)
17 unsigned long stop = jiffies + HZ;
18 int busy = 1;
20 /* NOP for Cedarview */
21 if (IS_CDV(dev_priv->dev))
22 return 0;
24 /* First do a quick check */
25 if ((PSB_RSGX32(PSB_CR_2D_SOCIF) == _PSB_C2_SOCIF_EMPTY) &&
26 ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) & _PSB_C2B_STATUS_BUSY) == 0))
27 return 0;
29 do {
30 busy = (PSB_RSGX32(PSB_CR_2D_SOCIF) != _PSB_C2_SOCIF_EMPTY);
31 } while (busy && !time_after_eq(jiffies, stop));
33 if (busy)
34 return -EBUSY;
36 do {
37 busy = ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) &
38 _PSB_C2B_STATUS_BUSY) != 0);
39 } while (busy && !time_after_eq(jiffies, stop));
41 /* If still busy, we probably have a hang */
42 return (busy) ? -EBUSY : 0;