Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc / drm: mediatek: cmdq: Remove timeout handler in helper function

For each client driver, its timeout handler need to dump hardware register
or its state machine information, and their way to detect timeout are
also different, so remove timeout handler in helper function and
let client driver implement its own timeout handler.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/20201102000438.29225-1-chunkuang.hu@kernel.org
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

authored by

Chun-Kuang Hu and committed by
Matthias Brugger
a69dcdfc a49d5e7a

+3 -51
+1 -2
drivers/gpu/drm/mediatek/mtk_drm_crtc.c
··· 824 824 #if IS_REACHABLE(CONFIG_MTK_CMDQ) 825 825 mtk_crtc->cmdq_client = 826 826 cmdq_mbox_create(mtk_crtc->mmsys_dev, 827 - drm_crtc_index(&mtk_crtc->base), 828 - 2000); 827 + drm_crtc_index(&mtk_crtc->base)); 829 828 if (IS_ERR(mtk_crtc->cmdq_client)) { 830 829 dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n", 831 830 drm_crtc_index(&mtk_crtc->base));
+1 -40
drivers/soc/mediatek/mtk-cmdq-helper.c
··· 70 70 } 71 71 EXPORT_SYMBOL(cmdq_dev_get_client_reg); 72 72 73 - static void cmdq_client_timeout(struct timer_list *t) 74 - { 75 - struct cmdq_client *client = from_timer(client, t, timer); 76 - 77 - dev_err(client->client.dev, "cmdq timeout!\n"); 78 - } 79 - 80 - struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, u32 timeout) 73 + struct cmdq_client *cmdq_mbox_create(struct device *dev, int index) 81 74 { 82 75 struct cmdq_client *client; 83 76 ··· 78 85 if (!client) 79 86 return (struct cmdq_client *)-ENOMEM; 80 87 81 - client->timeout_ms = timeout; 82 - if (timeout != CMDQ_NO_TIMEOUT) { 83 - spin_lock_init(&client->lock); 84 - timer_setup(&client->timer, cmdq_client_timeout, 0); 85 - } 86 - client->pkt_cnt = 0; 87 88 client->client.dev = dev; 88 89 client->client.tx_block = false; 89 90 client->client.knows_txdone = true; ··· 99 112 100 113 void cmdq_mbox_destroy(struct cmdq_client *client) 101 114 { 102 - if (client->timeout_ms != CMDQ_NO_TIMEOUT) { 103 - spin_lock(&client->lock); 104 - del_timer_sync(&client->timer); 105 - spin_unlock(&client->lock); 106 - } 107 115 mbox_free_channel(client->chan); 108 116 kfree(client); 109 117 } ··· 431 449 struct cmdq_task_cb *cb = &pkt->cb; 432 450 struct cmdq_client *client = (struct cmdq_client *)pkt->cl; 433 451 434 - if (client->timeout_ms != CMDQ_NO_TIMEOUT) { 435 - unsigned long flags = 0; 436 - 437 - spin_lock_irqsave(&client->lock, flags); 438 - if (--client->pkt_cnt == 0) 439 - del_timer(&client->timer); 440 - else 441 - mod_timer(&client->timer, jiffies + 442 - msecs_to_jiffies(client->timeout_ms)); 443 - spin_unlock_irqrestore(&client->lock, flags); 444 - } 445 - 446 452 dma_sync_single_for_cpu(client->chan->mbox->dev, pkt->pa_base, 447 453 pkt->cmd_buf_size, DMA_TO_DEVICE); 448 454 if (cb->cb) { ··· 443 473 void *data) 444 474 { 445 475 int err; 446 - unsigned long flags = 0; 447 476 struct cmdq_client *client = (struct cmdq_client *)pkt->cl; 448 477 449 478 pkt->cb.cb = cb; ··· 452 483 453 484 dma_sync_single_for_device(client->chan->mbox->dev, pkt->pa_base, 454 485 pkt->cmd_buf_size, DMA_TO_DEVICE); 455 - 456 - if (client->timeout_ms != CMDQ_NO_TIMEOUT) { 457 - spin_lock_irqsave(&client->lock, flags); 458 - if (client->pkt_cnt++ == 0) 459 - mod_timer(&client->timer, jiffies + 460 - msecs_to_jiffies(client->timeout_ms)); 461 - spin_unlock_irqrestore(&client->lock, flags); 462 - } 463 486 464 487 err = mbox_send_message(client->chan, pkt); 465 488 if (err < 0)
+1 -9
include/linux/soc/mediatek/mtk-cmdq.h
··· 11 11 #include <linux/mailbox/mtk-cmdq-mailbox.h> 12 12 #include <linux/timer.h> 13 13 14 - #define CMDQ_NO_TIMEOUT 0xffffffffu 15 14 #define CMDQ_ADDR_HIGH(addr) ((u32)(((addr) >> 16) & GENMASK(31, 0))) 16 15 #define CMDQ_ADDR_LOW(addr) ((u16)(addr) | BIT(1)) 17 16 ··· 23 24 }; 24 25 25 26 struct cmdq_client { 26 - spinlock_t lock; 27 - u32 pkt_cnt; 28 27 struct mbox_client client; 29 28 struct mbox_chan *chan; 30 - struct timer_list timer; 31 - u32 timeout_ms; /* in unit of microsecond */ 32 29 }; 33 30 34 31 /** ··· 46 51 * cmdq_mbox_create() - create CMDQ mailbox client and channel 47 52 * @dev: device of CMDQ mailbox client 48 53 * @index: index of CMDQ mailbox channel 49 - * @timeout: timeout of a pkt execution by GCE, in unit of microsecond, set 50 - * CMDQ_NO_TIMEOUT if a timer is not used. 51 54 * 52 55 * Return: CMDQ mailbox client pointer 53 56 */ 54 - struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, 55 - u32 timeout); 57 + struct cmdq_client *cmdq_mbox_create(struct device *dev, int index); 56 58 57 59 /** 58 60 * cmdq_mbox_destroy() - destroy CMDQ mailbox client and channel