Skip to content

Commit d7c66b5

Browse files
author
Chun-Kuang Hu
committed
drm/mediatek: Use cmdq_pkt_create() and cmdq_pkt_destroy()
Use cmdq_pkt_create() and cmdq_pkt_destroy() common function instead of implementing drm version. Signed-off-by: Chun-Kuang Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
1 parent 3998260 commit d7c66b5

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

drivers/gpu/drm/mediatek/mtk_crtc.c

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -113,52 +113,14 @@ static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
113113
}
114114
}
115115

116-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
117-
static int mtk_drm_cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *pkt,
118-
size_t size)
119-
{
120-
struct device *dev;
121-
dma_addr_t dma_addr;
122-
123-
pkt->va_base = kzalloc(size, GFP_KERNEL);
124-
if (!pkt->va_base)
125-
return -ENOMEM;
126-
127-
pkt->buf_size = size;
128-
pkt->cl = (void *)client;
129-
130-
dev = client->chan->mbox->dev;
131-
dma_addr = dma_map_single(dev, pkt->va_base, pkt->buf_size,
132-
DMA_TO_DEVICE);
133-
if (dma_mapping_error(dev, dma_addr)) {
134-
dev_err(dev, "dma map failed, size=%u\n", (u32)(u64)size);
135-
kfree(pkt->va_base);
136-
return -ENOMEM;
137-
}
138-
139-
pkt->pa_base = dma_addr;
140-
141-
return 0;
142-
}
143-
144-
static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt)
145-
{
146-
struct cmdq_client *client = (struct cmdq_client *)pkt->cl;
147-
148-
dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_size,
149-
DMA_TO_DEVICE);
150-
kfree(pkt->va_base);
151-
}
152-
#endif
153-
154116
static void mtk_crtc_destroy(struct drm_crtc *crtc)
155117
{
156118
struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
157119
int i;
158120

159121
mtk_mutex_put(mtk_crtc->mutex);
160122
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
161-
mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle);
123+
cmdq_pkt_destroy(&mtk_crtc->cmdq_client, &mtk_crtc->cmdq_handle);
162124

163125
if (mtk_crtc->cmdq_client.chan) {
164126
mbox_free_channel(mtk_crtc->cmdq_client.chan);
@@ -1094,9 +1056,9 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
10941056
mbox_free_channel(mtk_crtc->cmdq_client.chan);
10951057
mtk_crtc->cmdq_client.chan = NULL;
10961058
} else {
1097-
ret = mtk_drm_cmdq_pkt_create(&mtk_crtc->cmdq_client,
1098-
&mtk_crtc->cmdq_handle,
1099-
PAGE_SIZE);
1059+
ret = cmdq_pkt_create(&mtk_crtc->cmdq_client,
1060+
&mtk_crtc->cmdq_handle,
1061+
PAGE_SIZE);
11001062
if (ret) {
11011063
dev_dbg(dev, "mtk_crtc %d failed to create cmdq packet\n",
11021064
drm_crtc_index(&mtk_crtc->base));

0 commit comments

Comments
 (0)