1caab277bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
214be3200SRob Clark /*
314be3200SRob Clark * Copyright (c) 2014, The Linux Foundation. All rights reserved.
414be3200SRob Clark * Copyright (C) 2013 Red Hat
514be3200SRob Clark * Author: Rob Clark <robdclark@gmail.com>
614be3200SRob Clark */
714be3200SRob Clark
8feea39a8SSam Ravnborg #include <drm/drm_fourcc.h>
9e9eafcb5SSam Ravnborg #include <drm/drm_util.h>
1014be3200SRob Clark
1114be3200SRob Clark #include "mdp5_kms.h"
1214be3200SRob Clark #include "mdp5_smp.h"
1314be3200SRob Clark
1414be3200SRob Clark
1514be3200SRob Clark struct mdp5_smp {
1614be3200SRob Clark struct drm_device *dev;
1714be3200SRob Clark
1814be3200SRob Clark uint8_t reserved[MAX_CLIENTS]; /* fixed MMBs allocation per client */
1914be3200SRob Clark
2014be3200SRob Clark int blk_cnt;
2114be3200SRob Clark int blk_size;
2214be3200SRob Clark
2314be3200SRob Clark /* register cache */
2414be3200SRob Clark u32 alloc_w[22];
2514be3200SRob Clark u32 alloc_r[22];
2614be3200SRob Clark u32 pipe_reqprio_fifo_wm0[SSPP_MAX];
2714be3200SRob Clark u32 pipe_reqprio_fifo_wm1[SSPP_MAX];
2814be3200SRob Clark u32 pipe_reqprio_fifo_wm2[SSPP_MAX];
2914be3200SRob Clark };
3014be3200SRob Clark
3114be3200SRob Clark static inline
get_kms(struct mdp5_smp * smp)3214be3200SRob Clark struct mdp5_kms *get_kms(struct mdp5_smp *smp)
3314be3200SRob Clark {
3414be3200SRob Clark struct msm_drm_private *priv = smp->dev->dev_private;
3514be3200SRob Clark
3614be3200SRob Clark return to_mdp5_kms(to_mdp_kms(priv->kms));
3714be3200SRob Clark }
3814be3200SRob Clark
pipe2client(enum mdp5_pipe pipe,int plane)3914be3200SRob Clark static inline u32 pipe2client(enum mdp5_pipe pipe, int plane)
4014be3200SRob Clark {
4114be3200SRob Clark #define CID_UNUSED 0
4214be3200SRob Clark
4314be3200SRob Clark if (WARN_ON(plane >= pipe2nclients(pipe)))
4414be3200SRob Clark return CID_UNUSED;
4514be3200SRob Clark
4614be3200SRob Clark /*
4714be3200SRob Clark * Note on SMP clients:
4814be3200SRob Clark * For ViG pipes, fetch Y/Cr/Cb-components clients are always
4914be3200SRob Clark * consecutive, and in that order.
5014be3200SRob Clark *
5114be3200SRob Clark * e.g.:
5214be3200SRob Clark * if mdp5_cfg->smp.clients[SSPP_VIG0] = N,
5314be3200SRob Clark * Y plane's client ID is N
5414be3200SRob Clark * Cr plane's client ID is N + 1
5514be3200SRob Clark * Cb plane's client ID is N + 2
5614be3200SRob Clark */
5714be3200SRob Clark
5814be3200SRob Clark return mdp5_cfg->smp.clients[pipe] + plane;
5914be3200SRob Clark }
6014be3200SRob Clark
6114be3200SRob Clark /* allocate blocks for the specified request: */
smp_request_block(struct mdp5_smp * smp,struct mdp5_smp_state * state,u32 cid,int nblks)6214be3200SRob Clark static int smp_request_block(struct mdp5_smp *smp,
6314be3200SRob Clark struct mdp5_smp_state *state,
6414be3200SRob Clark u32 cid, int nblks)
6514be3200SRob Clark {
6614be3200SRob Clark void *cs = state->client_state[cid];
6714be3200SRob Clark int i, avail, cnt = smp->blk_cnt;
6814be3200SRob Clark uint8_t reserved;
6914be3200SRob Clark
7014be3200SRob Clark /* we shouldn't be requesting blocks for an in-use client: */
7116b323ddSYury Norov WARN_ON(!bitmap_empty(cs, cnt));
7214be3200SRob Clark
7314be3200SRob Clark reserved = smp->reserved[cid];
7414be3200SRob Clark
7514be3200SRob Clark if (reserved) {
7614be3200SRob Clark nblks = max(0, nblks - reserved);
7714be3200SRob Clark DBG("%d MMBs allocated (%d reserved)", nblks, reserved);
7814be3200SRob Clark }
7914be3200SRob Clark
8014be3200SRob Clark avail = cnt - bitmap_weight(state->state, cnt);
8114be3200SRob Clark if (nblks > avail) {
826a41da17SMamta Shukla DRM_DEV_ERROR(smp->dev->dev, "out of blks (req=%d > avail=%d)\n",
8314be3200SRob Clark nblks, avail);
8414be3200SRob Clark return -ENOSPC;
8514be3200SRob Clark }
8614be3200SRob Clark
8714be3200SRob Clark for (i = 0; i < nblks; i++) {
8814be3200SRob Clark int blk = find_first_zero_bit(state->state, cnt);
8914be3200SRob Clark set_bit(blk, cs);
9014be3200SRob Clark set_bit(blk, state->state);
9114be3200SRob Clark }
9214be3200SRob Clark
9314be3200SRob Clark return 0;
9414be3200SRob Clark }
9514be3200SRob Clark
set_fifo_thresholds(struct mdp5_smp * smp,enum mdp5_pipe pipe,int nblks)9614be3200SRob Clark static void set_fifo_thresholds(struct mdp5_smp *smp,
9714be3200SRob Clark enum mdp5_pipe pipe, int nblks)
9814be3200SRob Clark {
9914be3200SRob Clark u32 smp_entries_per_blk = smp->blk_size / (128 / BITS_PER_BYTE);
10014be3200SRob Clark u32 val;
10114be3200SRob Clark
10214be3200SRob Clark /* 1/4 of SMP pool that is being fetched */
10314be3200SRob Clark val = (nblks * smp_entries_per_blk) / 4;
10414be3200SRob Clark
10514be3200SRob Clark smp->pipe_reqprio_fifo_wm0[pipe] = val * 1;
10614be3200SRob Clark smp->pipe_reqprio_fifo_wm1[pipe] = val * 2;
10714be3200SRob Clark smp->pipe_reqprio_fifo_wm2[pipe] = val * 3;
10814be3200SRob Clark }
10914be3200SRob Clark
11014be3200SRob Clark /*
11114be3200SRob Clark * NOTE: looks like if horizontal decimation is used (if we supported that)
11214be3200SRob Clark * then the width used to calculate SMP block requirements is the post-
11314be3200SRob Clark * decimated width. Ie. SMP buffering sits downstream of decimation (which
11414be3200SRob Clark * presumably happens during the dma from scanout buffer).
11514be3200SRob Clark */
mdp5_smp_calculate(struct mdp5_smp * smp,const struct mdp_format * format,u32 width,bool hdecim)11614be3200SRob Clark uint32_t mdp5_smp_calculate(struct mdp5_smp *smp,
11714be3200SRob Clark const struct mdp_format *format,
11814be3200SRob Clark u32 width, bool hdecim)
11914be3200SRob Clark {
12005c452c1SMaxime Ripard const struct drm_format_info *info = drm_format_info(format->base.pixel_format);
12114be3200SRob Clark struct mdp5_kms *mdp5_kms = get_kms(smp);
12214be3200SRob Clark int rev = mdp5_cfg_get_hw_rev(mdp5_kms->cfg);
12314be3200SRob Clark int i, hsub, nplanes, nlines;
12414be3200SRob Clark uint32_t blkcfg = 0;
12514be3200SRob Clark
12605c452c1SMaxime Ripard nplanes = info->num_planes;
127f3e9632cSMaxime Ripard hsub = info->hsub;
12814be3200SRob Clark
12914be3200SRob Clark /* different if BWC (compressed framebuffer?) enabled: */
13014be3200SRob Clark nlines = 2;
13114be3200SRob Clark
13214be3200SRob Clark /* Newer MDPs have split/packing logic, which fetches sub-sampled
13314be3200SRob Clark * U and V components (splits them from Y if necessary) and packs
13414be3200SRob Clark * them together, writes to SMP using a single client.
13514be3200SRob Clark */
13614be3200SRob Clark if ((rev > 0) && (format->chroma_sample > CHROMA_FULL)) {
13714be3200SRob Clark nplanes = 2;
13814be3200SRob Clark
13914be3200SRob Clark /* if decimation is enabled, HW decimates less on the
14014be3200SRob Clark * sub sampled chroma components
14114be3200SRob Clark */
14214be3200SRob Clark if (hdecim && (hsub > 1))
14314be3200SRob Clark hsub = 1;
14414be3200SRob Clark }
14514be3200SRob Clark
14614be3200SRob Clark for (i = 0; i < nplanes; i++) {
14714be3200SRob Clark int n, fetch_stride, cpp;
14814be3200SRob Clark
149b0f986b4SMaxime Ripard cpp = info->cpp[i];
15014be3200SRob Clark fetch_stride = width * cpp / (i ? hsub : 1);
15114be3200SRob Clark
15214be3200SRob Clark n = DIV_ROUND_UP(fetch_stride * nlines, smp->blk_size);
15314be3200SRob Clark
15414be3200SRob Clark /* for hw rev v1.00 */
15514be3200SRob Clark if (rev == 0)
15614be3200SRob Clark n = roundup_pow_of_two(n);
15714be3200SRob Clark
15814be3200SRob Clark blkcfg |= (n << (8 * i));
15914be3200SRob Clark }
16014be3200SRob Clark
16114be3200SRob Clark return blkcfg;
16214be3200SRob Clark }
16314be3200SRob Clark
mdp5_smp_assign(struct mdp5_smp * smp,struct mdp5_smp_state * state,enum mdp5_pipe pipe,uint32_t blkcfg)16414be3200SRob Clark int mdp5_smp_assign(struct mdp5_smp *smp, struct mdp5_smp_state *state,
16514be3200SRob Clark enum mdp5_pipe pipe, uint32_t blkcfg)
16614be3200SRob Clark {
16714be3200SRob Clark struct mdp5_kms *mdp5_kms = get_kms(smp);
16814be3200SRob Clark struct drm_device *dev = mdp5_kms->dev;
16914be3200SRob Clark int i, ret;
17014be3200SRob Clark
17114be3200SRob Clark for (i = 0; i < pipe2nclients(pipe); i++) {
17214be3200SRob Clark u32 cid = pipe2client(pipe, i);
17314be3200SRob Clark int n = blkcfg & 0xff;
17414be3200SRob Clark
17514be3200SRob Clark if (!n)
17614be3200SRob Clark continue;
17714be3200SRob Clark
17814be3200SRob Clark DBG("%s[%d]: request %d SMP blocks", pipe2name(pipe), i, n);
17914be3200SRob Clark ret = smp_request_block(smp, state, cid, n);
18014be3200SRob Clark if (ret) {
1816a41da17SMamta Shukla DRM_DEV_ERROR(dev->dev, "Cannot allocate %d SMP blocks: %d\n",
18214be3200SRob Clark n, ret);
18314be3200SRob Clark return ret;
18414be3200SRob Clark }
18514be3200SRob Clark
18614be3200SRob Clark blkcfg >>= 8;
18714be3200SRob Clark }
18814be3200SRob Clark
18914be3200SRob Clark state->assigned |= (1 << pipe);
19014be3200SRob Clark
19114be3200SRob Clark return 0;
19214be3200SRob Clark }
19314be3200SRob Clark
19414be3200SRob Clark /* Release SMP blocks for all clients of the pipe */
mdp5_smp_release(struct mdp5_smp * smp,struct mdp5_smp_state * state,enum mdp5_pipe pipe)19514be3200SRob Clark void mdp5_smp_release(struct mdp5_smp *smp, struct mdp5_smp_state *state,
19614be3200SRob Clark enum mdp5_pipe pipe)
19714be3200SRob Clark {
19814be3200SRob Clark int i;
19914be3200SRob Clark int cnt = smp->blk_cnt;
20014be3200SRob Clark
20114be3200SRob Clark for (i = 0; i < pipe2nclients(pipe); i++) {
20214be3200SRob Clark u32 cid = pipe2client(pipe, i);
20314be3200SRob Clark void *cs = state->client_state[cid];
20414be3200SRob Clark
20514be3200SRob Clark /* update global state: */
20614be3200SRob Clark bitmap_andnot(state->state, state->state, cs, cnt);
20714be3200SRob Clark
20814be3200SRob Clark /* clear client's state */
20914be3200SRob Clark bitmap_zero(cs, cnt);
21014be3200SRob Clark }
21114be3200SRob Clark
21214be3200SRob Clark state->released |= (1 << pipe);
21314be3200SRob Clark }
21414be3200SRob Clark
21514be3200SRob Clark /* NOTE: SMP_ALLOC_* regs are *not* double buffered, so release has to
21614be3200SRob Clark * happen after scanout completes.
21714be3200SRob Clark */
update_smp_state(struct mdp5_smp * smp,u32 cid,mdp5_smp_state_t * assigned)21814be3200SRob Clark static unsigned update_smp_state(struct mdp5_smp *smp,
21914be3200SRob Clark u32 cid, mdp5_smp_state_t *assigned)
22014be3200SRob Clark {
22114be3200SRob Clark int cnt = smp->blk_cnt;
22214be3200SRob Clark unsigned nblks = 0;
22314be3200SRob Clark u32 blk, val;
22414be3200SRob Clark
22514be3200SRob Clark for_each_set_bit(blk, *assigned, cnt) {
22614be3200SRob Clark int idx = blk / 3;
22714be3200SRob Clark int fld = blk % 3;
22814be3200SRob Clark
22914be3200SRob Clark val = smp->alloc_w[idx];
23014be3200SRob Clark
23114be3200SRob Clark switch (fld) {
23214be3200SRob Clark case 0:
23314be3200SRob Clark val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT0__MASK;
23414be3200SRob Clark val |= MDP5_SMP_ALLOC_W_REG_CLIENT0(cid);
23514be3200SRob Clark break;
23614be3200SRob Clark case 1:
23714be3200SRob Clark val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT1__MASK;
23814be3200SRob Clark val |= MDP5_SMP_ALLOC_W_REG_CLIENT1(cid);
23914be3200SRob Clark break;
24014be3200SRob Clark case 2:
24114be3200SRob Clark val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT2__MASK;
24214be3200SRob Clark val |= MDP5_SMP_ALLOC_W_REG_CLIENT2(cid);
24314be3200SRob Clark break;
24414be3200SRob Clark }
24514be3200SRob Clark
24614be3200SRob Clark smp->alloc_w[idx] = val;
24714be3200SRob Clark smp->alloc_r[idx] = val;
24814be3200SRob Clark
24914be3200SRob Clark nblks++;
25014be3200SRob Clark }
25114be3200SRob Clark
25214be3200SRob Clark return nblks;
25314be3200SRob Clark }
25414be3200SRob Clark
write_smp_alloc_regs(struct mdp5_smp * smp)25514be3200SRob Clark static void write_smp_alloc_regs(struct mdp5_smp *smp)
25614be3200SRob Clark {
25714be3200SRob Clark struct mdp5_kms *mdp5_kms = get_kms(smp);
25814be3200SRob Clark int i, num_regs;
25914be3200SRob Clark
26014be3200SRob Clark num_regs = smp->blk_cnt / 3 + 1;
26114be3200SRob Clark
26214be3200SRob Clark for (i = 0; i < num_regs; i++) {
26314be3200SRob Clark mdp5_write(mdp5_kms, REG_MDP5_SMP_ALLOC_W_REG(i),
26414be3200SRob Clark smp->alloc_w[i]);
26514be3200SRob Clark mdp5_write(mdp5_kms, REG_MDP5_SMP_ALLOC_R_REG(i),
26614be3200SRob Clark smp->alloc_r[i]);
26714be3200SRob Clark }
26814be3200SRob Clark }
26914be3200SRob Clark
write_smp_fifo_regs(struct mdp5_smp * smp)27014be3200SRob Clark static void write_smp_fifo_regs(struct mdp5_smp *smp)
27114be3200SRob Clark {
27214be3200SRob Clark struct mdp5_kms *mdp5_kms = get_kms(smp);
27314be3200SRob Clark int i;
27414be3200SRob Clark
27514be3200SRob Clark for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
27614be3200SRob Clark struct mdp5_hw_pipe *hwpipe = mdp5_kms->hwpipes[i];
27714be3200SRob Clark enum mdp5_pipe pipe = hwpipe->pipe;
27814be3200SRob Clark
27914be3200SRob Clark mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_0(pipe),
28014be3200SRob Clark smp->pipe_reqprio_fifo_wm0[pipe]);
28114be3200SRob Clark mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_1(pipe),
28214be3200SRob Clark smp->pipe_reqprio_fifo_wm1[pipe]);
28314be3200SRob Clark mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_2(pipe),
28414be3200SRob Clark smp->pipe_reqprio_fifo_wm2[pipe]);
28514be3200SRob Clark }
28614be3200SRob Clark }
28714be3200SRob Clark
mdp5_smp_prepare_commit(struct mdp5_smp * smp,struct mdp5_smp_state * state)28814be3200SRob Clark void mdp5_smp_prepare_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state)
28914be3200SRob Clark {
29014be3200SRob Clark enum mdp5_pipe pipe;
29114be3200SRob Clark
29214be3200SRob Clark for_each_set_bit(pipe, &state->assigned, sizeof(state->assigned) * 8) {
29314be3200SRob Clark unsigned i, nblks = 0;
29414be3200SRob Clark
29514be3200SRob Clark for (i = 0; i < pipe2nclients(pipe); i++) {
29614be3200SRob Clark u32 cid = pipe2client(pipe, i);
29714be3200SRob Clark void *cs = state->client_state[cid];
29814be3200SRob Clark
29914be3200SRob Clark nblks += update_smp_state(smp, cid, cs);
30014be3200SRob Clark
30114be3200SRob Clark DBG("assign %s:%u, %u blks",
30214be3200SRob Clark pipe2name(pipe), i, nblks);
30314be3200SRob Clark }
30414be3200SRob Clark
30514be3200SRob Clark set_fifo_thresholds(smp, pipe, nblks);
30614be3200SRob Clark }
30714be3200SRob Clark
30814be3200SRob Clark write_smp_alloc_regs(smp);
30914be3200SRob Clark write_smp_fifo_regs(smp);
31014be3200SRob Clark
31114be3200SRob Clark state->assigned = 0;
31214be3200SRob Clark }
31314be3200SRob Clark
mdp5_smp_complete_commit(struct mdp5_smp * smp,struct mdp5_smp_state * state)31414be3200SRob Clark void mdp5_smp_complete_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state)
31514be3200SRob Clark {
31614be3200SRob Clark enum mdp5_pipe pipe;
31714be3200SRob Clark
31814be3200SRob Clark for_each_set_bit(pipe, &state->released, sizeof(state->released) * 8) {
31914be3200SRob Clark DBG("release %s", pipe2name(pipe));
32014be3200SRob Clark set_fifo_thresholds(smp, pipe, 0);
32114be3200SRob Clark }
32214be3200SRob Clark
32314be3200SRob Clark write_smp_fifo_regs(smp);
32414be3200SRob Clark
32514be3200SRob Clark state->released = 0;
32614be3200SRob Clark }
32714be3200SRob Clark
mdp5_smp_dump(struct mdp5_smp * smp,struct drm_printer * p)32814be3200SRob Clark void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)
32914be3200SRob Clark {
33014be3200SRob Clark struct mdp5_kms *mdp5_kms = get_kms(smp);
33114be3200SRob Clark struct mdp5_hw_pipe_state *hwpstate;
33214be3200SRob Clark struct mdp5_smp_state *state;
3337907a0d7SArchit Taneja struct mdp5_global_state *global_state;
33414be3200SRob Clark int total = 0, i, j;
33514be3200SRob Clark
33614be3200SRob Clark drm_printf(p, "name\tinuse\tplane\n");
33714be3200SRob Clark drm_printf(p, "----\t-----\t-----\n");
33814be3200SRob Clark
33914be3200SRob Clark if (drm_can_sleep())
3407907a0d7SArchit Taneja drm_modeset_lock(&mdp5_kms->glob_state_lock, NULL);
3417907a0d7SArchit Taneja
3427907a0d7SArchit Taneja global_state = mdp5_get_existing_global_state(mdp5_kms);
34314be3200SRob Clark
34414be3200SRob Clark /* grab these *after* we hold the state_lock */
3457907a0d7SArchit Taneja hwpstate = &global_state->hwpipe;
3467907a0d7SArchit Taneja state = &global_state->smp;
34714be3200SRob Clark
34814be3200SRob Clark for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
34914be3200SRob Clark struct mdp5_hw_pipe *hwpipe = mdp5_kms->hwpipes[i];
35014be3200SRob Clark struct drm_plane *plane = hwpstate->hwpipe_to_plane[hwpipe->idx];
35114be3200SRob Clark enum mdp5_pipe pipe = hwpipe->pipe;
35214be3200SRob Clark for (j = 0; j < pipe2nclients(pipe); j++) {
35314be3200SRob Clark u32 cid = pipe2client(pipe, j);
35414be3200SRob Clark void *cs = state->client_state[cid];
35514be3200SRob Clark int inuse = bitmap_weight(cs, smp->blk_cnt);
35614be3200SRob Clark
35714be3200SRob Clark drm_printf(p, "%s:%d\t%d\t%s\n",
35814be3200SRob Clark pipe2name(pipe), j, inuse,
359*614773a4SSherry Yang plane ? plane->name : "(null)");
36014be3200SRob Clark
36114be3200SRob Clark total += inuse;
36214be3200SRob Clark }
36314be3200SRob Clark }
36414be3200SRob Clark
36514be3200SRob Clark drm_printf(p, "TOTAL:\t%d\t(of %d)\n", total, smp->blk_cnt);
36614be3200SRob Clark drm_printf(p, "AVAIL:\t%d\n", smp->blk_cnt -
36714be3200SRob Clark bitmap_weight(state->state, smp->blk_cnt));
36814be3200SRob Clark
36914be3200SRob Clark if (drm_can_sleep())
3707907a0d7SArchit Taneja drm_modeset_unlock(&mdp5_kms->glob_state_lock);
37114be3200SRob Clark }
37214be3200SRob Clark
mdp5_smp_destroy(struct mdp5_smp * smp)37314be3200SRob Clark void mdp5_smp_destroy(struct mdp5_smp *smp)
37414be3200SRob Clark {
37514be3200SRob Clark kfree(smp);
37614be3200SRob Clark }
37714be3200SRob Clark
mdp5_smp_init(struct mdp5_kms * mdp5_kms,const struct mdp5_smp_block * cfg)37814be3200SRob Clark struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_block *cfg)
37914be3200SRob Clark {
3807907a0d7SArchit Taneja struct mdp5_smp_state *state;
3817907a0d7SArchit Taneja struct mdp5_global_state *global_state;
38214be3200SRob Clark struct mdp5_smp *smp = NULL;
38314be3200SRob Clark int ret;
38414be3200SRob Clark
38514be3200SRob Clark smp = kzalloc(sizeof(*smp), GFP_KERNEL);
38614be3200SRob Clark if (unlikely(!smp)) {
38714be3200SRob Clark ret = -ENOMEM;
38814be3200SRob Clark goto fail;
38914be3200SRob Clark }
39014be3200SRob Clark
39114be3200SRob Clark smp->dev = mdp5_kms->dev;
39214be3200SRob Clark smp->blk_cnt = cfg->mmb_count;
39314be3200SRob Clark smp->blk_size = cfg->mmb_size;
39414be3200SRob Clark
3957907a0d7SArchit Taneja global_state = mdp5_get_existing_global_state(mdp5_kms);
3967907a0d7SArchit Taneja state = &global_state->smp;
3977907a0d7SArchit Taneja
39814be3200SRob Clark /* statically tied MMBs cannot be re-allocated: */
39914be3200SRob Clark bitmap_copy(state->state, cfg->reserved_state, smp->blk_cnt);
40014be3200SRob Clark memcpy(smp->reserved, cfg->reserved, sizeof(smp->reserved));
40114be3200SRob Clark
40214be3200SRob Clark return smp;
40314be3200SRob Clark fail:
40414be3200SRob Clark if (smp)
40514be3200SRob Clark mdp5_smp_destroy(smp);
40614be3200SRob Clark
40714be3200SRob Clark return ERR_PTR(ret);
40814be3200SRob Clark }
409