Skip to content

Commit b34884b

Browse files
AngeloGioacchino Del Regnombgg
authored andcommitted
soc: mediatek: Cleanup ifdefs for IS_REACHABLE(CONFIG_MTK_CMDQ)
Now that the mtk-cmdq.h header contains inline functions for cases in which the driver is not enabled (either module or built-in), we can safely go on with cleaning up ifdefs for CMDQ handling. This also shows in a clearer manner that writing through CMDQ HW is optional and used only for performance purposes when/where wanted, needed and/or required. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matthias Brugger <[email protected]>
1 parent eb0d862 commit b34884b

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

drivers/soc/mediatek/mtk-mmsys.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,18 @@ struct mtk_mmsys {
131131
static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val,
132132
struct cmdq_pkt *cmdq_pkt)
133133
{
134+
int ret;
134135
u32 tmp;
135136

136-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
137-
if (cmdq_pkt) {
138-
if (mmsys->cmdq_base.size == 0) {
139-
pr_err("mmsys lose gce property, failed to update mmsys bits with cmdq");
137+
if (mmsys->cmdq_base.size && cmdq_pkt) {
138+
ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
139+
mmsys->cmdq_base.offset + offset, val,
140+
mask);
141+
if (ret)
142+
pr_debug("CMDQ unavailable: using CPU write\n");
143+
else
140144
return;
141-
}
142-
cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
143-
mmsys->cmdq_base.offset + offset, val,
144-
mask);
145-
return;
146145
}
147-
#endif
148-
149146
tmp = readl_relaxed(mmsys->regs + offset);
150147
tmp = (tmp & ~mask) | (val & mask);
151148
writel_relaxed(tmp, mmsys->regs + offset);
@@ -376,11 +373,10 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
376373
}
377374
}
378375

379-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
376+
/* CMDQ is optional */
380377
ret = cmdq_dev_get_client_reg(dev, &mmsys->cmdq_base, 0);
381378
if (ret)
382379
dev_dbg(dev, "No mediatek,gce-client-reg!\n");
383-
#endif
384380

385381
platform_set_drvdata(pdev, mmsys);
386382

drivers/soc/mediatek/mtk-mutex.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -871,23 +871,18 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt)
871871
{
872872
struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
873873
mutex[mutex->id]);
874-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
875874
struct cmdq_pkt *cmdq_pkt = (struct cmdq_pkt *)pkt;
876875

877876
WARN_ON(&mtx->mutex[mutex->id] != mutex);
878877

879878
if (!mtx->cmdq_reg.size) {
880879
dev_err(mtx->dev, "mediatek,gce-client-reg hasn't been set");
881-
return -EINVAL;
880+
return -ENODEV;
882881
}
883882

884883
cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys,
885884
mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 1);
886885
return 0;
887-
#else
888-
dev_err(mtx->dev, "Not support for enable MUTEX by CMDQ");
889-
return -ENODEV;
890-
#endif
891886
}
892887
EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);
893888

@@ -1000,10 +995,7 @@ static int mtk_mutex_probe(struct platform_device *pdev)
1000995
struct device *dev = &pdev->dev;
1001996
struct mtk_mutex_ctx *mtx;
1002997
struct resource *regs;
1003-
int i;
1004-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
1005-
int ret;
1006-
#endif
998+
int i, ret;
1007999

10081000
mtx = devm_kzalloc(dev, sizeof(*mtx), GFP_KERNEL);
10091001
if (!mtx)
@@ -1030,11 +1022,10 @@ static int mtk_mutex_probe(struct platform_device *pdev)
10301022
}
10311023
mtx->addr = regs->start;
10321024

1033-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
1025+
/* CMDQ is optional */
10341026
ret = cmdq_dev_get_client_reg(dev, &mtx->cmdq_reg, 0);
10351027
if (ret)
10361028
dev_dbg(dev, "No mediatek,gce-client-reg!\n");
1037-
#endif
10381029

10391030
platform_set_drvdata(pdev, mtx);
10401031

0 commit comments

Comments
 (0)