Skip to content

Commit 563c9d4

Browse files
author
Chun-Kuang Hu
committed
drm/mediatek: Remove the pointer of struct cmdq_client
In mailbox rx_callback, it pass struct mbox_client to callback function, but it could not map back to mtk_drm_crtc instance because struct cmdq_client use a pointer to struct mbox_client: struct cmdq_client { struct mbox_client client; struct mbox_chan *chan; }; struct mtk_drm_crtc { /* client instance data */ struct cmdq_client *cmdq_client; }; so remove the pointer of struct cmdq_client and let mtk_drm_crtc instance define cmdq_client as: struct mtk_drm_crtc { /* client instance data */ struct cmdq_client cmdq_client; }; and in rx_callback function, use struct mbox_client to get struct mtk_drm_crtc. Signed-off-by: Chun-Kuang Hu <[email protected]> Signed-off-by: jason-jh.lin <[email protected]>
1 parent 1ee07a6 commit 563c9d4

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct mtk_drm_crtc {
5252
bool pending_async_planes;
5353

5454
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
55-
struct cmdq_client *cmdq_client;
55+
struct cmdq_client cmdq_client;
5656
u32 cmdq_event;
5757
#endif
5858

@@ -472,19 +472,19 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
472472
mtk_mutex_release(mtk_crtc->mutex);
473473
}
474474
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
475-
if (mtk_crtc->cmdq_client) {
476-
mbox_flush(mtk_crtc->cmdq_client->chan, 2000);
477-
cmdq_handle = cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE);
475+
if (mtk_crtc->cmdq_client.chan) {
476+
mbox_flush(mtk_crtc->cmdq_client.chan, 2000);
477+
cmdq_handle = cmdq_pkt_create(&mtk_crtc->cmdq_client, PAGE_SIZE);
478478
cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event);
479479
cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false);
480480
mtk_crtc_ddp_config(crtc, cmdq_handle);
481481
cmdq_pkt_finalize(cmdq_handle);
482-
dma_sync_single_for_device(mtk_crtc->cmdq_client->chan->mbox->dev,
482+
dma_sync_single_for_device(mtk_crtc->cmdq_client.chan->mbox->dev,
483483
cmdq_handle->pa_base,
484484
cmdq_handle->cmd_buf_size,
485485
DMA_TO_DEVICE);
486-
mbox_send_message(mtk_crtc->cmdq_client->chan, cmdq_handle);
487-
mbox_client_txdone(mtk_crtc->cmdq_client->chan, 0);
486+
mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle);
487+
mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
488488
}
489489
#endif
490490
mtk_crtc->config_updating = false;
@@ -498,7 +498,7 @@ static void mtk_crtc_ddp_irq(void *data)
498498
struct mtk_drm_private *priv = crtc->dev->dev_private;
499499

500500
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
501-
if (!priv->data->shadow_register && !mtk_crtc->cmdq_client)
501+
if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan)
502502
#else
503503
if (!priv->data->shadow_register)
504504
#endif
@@ -838,26 +838,29 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
838838
mutex_init(&mtk_crtc->hw_lock);
839839

840840
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
841-
mtk_crtc->cmdq_client =
842-
cmdq_mbox_create(mtk_crtc->mmsys_dev,
843-
drm_crtc_index(&mtk_crtc->base));
844-
if (IS_ERR(mtk_crtc->cmdq_client)) {
841+
mtk_crtc->cmdq_client.client.dev = mtk_crtc->mmsys_dev;
842+
mtk_crtc->cmdq_client.client.tx_block = false;
843+
mtk_crtc->cmdq_client.client.knows_txdone = true;
844+
mtk_crtc->cmdq_client.client.rx_callback = ddp_cmdq_cb;
845+
mtk_crtc->cmdq_client.chan =
846+
mbox_request_channel(&mtk_crtc->cmdq_client.client,
847+
drm_crtc_index(&mtk_crtc->base));
848+
if (IS_ERR(mtk_crtc->cmdq_client.chan)) {
845849
dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n",
846850
drm_crtc_index(&mtk_crtc->base));
847-
mtk_crtc->cmdq_client = NULL;
851+
mtk_crtc->cmdq_client.chan = NULL;
848852
}
849853

850-
if (mtk_crtc->cmdq_client) {
851-
mtk_crtc->cmdq_client->client.rx_callback = ddp_cmdq_cb;
854+
if (mtk_crtc->cmdq_client.chan) {
852855
ret = of_property_read_u32_index(priv->mutex_node,
853856
"mediatek,gce-events",
854857
drm_crtc_index(&mtk_crtc->base),
855858
&mtk_crtc->cmdq_event);
856859
if (ret) {
857860
dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n",
858861
drm_crtc_index(&mtk_crtc->base));
859-
cmdq_mbox_destroy(mtk_crtc->cmdq_client);
860-
mtk_crtc->cmdq_client = NULL;
862+
mbox_free_channel(mtk_crtc->cmdq_client.chan);
863+
mtk_crtc->cmdq_client.chan = NULL;
861864
}
862865
}
863866
#endif

0 commit comments

Comments
 (0)