From patchwork Wed Feb 22 09:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 60451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp481320wrd; Wed, 22 Feb 2023 01:55:43 -0800 (PST) X-Google-Smtp-Source: AK7set/D8aWyGxllhdUFSI1HdVfebc1JGXrWUPPnRMzN/kO1deBBTc+v7LqHMns+QQaWPFcTsgbv X-Received: by 2002:a17:903:78c:b0:19a:8316:6b4a with SMTP id kn12-20020a170903078c00b0019a83166b4amr6930212plb.26.1677059743398; Wed, 22 Feb 2023 01:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677059743; cv=none; d=google.com; s=arc-20160816; b=a3fEdOn6YZHX50LGQ5nTIgrEEw7fsxMWqDL2eQgTRc3GdEe6+aAVKmnVP7Oy/uag7o bnKSqNiR6eJ9luPWagvThoFAm8w1zuq58BQUYUIMhxGFZatAQP9JBJoHSqRLRvttrrZ9 KyqMVhDDG4KL29gW7JiqlgulKt/gYuZpp3tAQXGN4AlXrDirMucUPBEgCDSuSjdJJQ3C bH9ImCVE1VV6Nmb1lNKUyDKRKX0GOs5Mj0yNfGfNV226r1pvQMLv8uAtD2MK4XS8Sd+n hcnKiofxqKAF4/vxpU9AQxfboh/egj/NvHP6pjscAZzZZlNzxdlTDJBMatoKEozB12st Ol5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VVJyKjrhaqRZ0w/StQGRkSFgwa0DYFt5USJ+Q9kZUu0=; b=YNKWLqmcWfOzsSDDUc3yKxi8FtTTfrlXh3Awaz5tuofkAjAQvEjRacoX4jKmx6VQiG 5M1IhYdicjUuxK12UsfNCD2KXawYALfWcfX7mmit2jYQJcLeRGg3LfNa2YLRIq/hlmiy A9frfBgJBLEHZSczgEvAbVL5lRNVGejc9yvLJmV9BnvoN6MJ3qDTtNOvAhTppj2AQY2H n0VdVtRNAsFc0mryJ9s9OmmzB+pmFmGXWNigjF7WtXLvek0Plm9hLNdpMcH4fZxR4ija 3HQWmrPElQ1wtUrZzXY9UxMoVv1Q/MEivyB2UURrgbHWdcIYYmKxz5KKVhKaHYWkoXun l1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ihCuNPi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902d48600b0019647978087si17830514plg.364.2023.02.22.01.55.30; Wed, 22 Feb 2023 01:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ihCuNPi0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbjBVJsY (ORCPT + 99 others); Wed, 22 Feb 2023 04:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232110AbjBVJsA (ORCPT ); Wed, 22 Feb 2023 04:48:00 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F933866E for ; Wed, 22 Feb 2023 01:46:11 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 627B866021D5; Wed, 22 Feb 2023 09:43:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1677058985; bh=t0WQRQY93wT7Ed+artLK4huBmFp5RCO/YHHv1kqN5ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihCuNPi0WgxnIHJEEL+kMrFdWXEi9a4xwIiBOZoekKc0R1UMCAscg4QF16nCCkfw5 bEwK2qBpTo/xZzWahGFe2Xt2JHnkzsnbqyD/NTM5Q8N92XPpPxcilEv95/gLSuoE1G l19rMU234gvbymd2bprEeJBPS8kIETCZds1t72eG/hFBT6D/6m8ko9BByk7IKTUKrM ZWcZRuOm8BPL1g5+JgHVh8C2aAW3tXGpXc+nW7xkRWTRsVMwF1CDkQzc2wBmR7KmaT Ov8Tc888vKvh7sS3KQBmOWpZkn2pjn8LQETcdxJtj/40vzb3FoCWGlXjOD04banzzD iYLlSU5XpaEnA== From: AngeloGioacchino Del Regno To: matthias.bgg@gmail.com Cc: jason-jh.lin@mediatek.com, chunkuang.hu@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, AngeloGioacchino Del Regno , Chen-Yu Tsai Subject: [PATCH v2 9/9] soc: mediatek: Cleanup ifdefs for IS_REACHABLE(CONFIG_MTK_CMDQ) Date: Wed, 22 Feb 2023 10:42:53 +0100 Message-Id: <20230222094253.23678-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230222094253.23678-1-angelogioacchino.delregno@collabora.com> References: <20230222094253.23678-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758524597474399662?= X-GMAIL-MSGID: =?utf-8?q?1758524597474399662?= 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 Reviewed-by: Chen-Yu Tsai --- drivers/soc/mediatek/mtk-mmsys.c | 22 +++++++++------------- drivers/soc/mediatek/mtk-mutex.c | 15 +++------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index 0f0fa27e17a5..8da5c8d26ed0 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -131,21 +131,18 @@ struct mtk_mmsys { static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val, struct cmdq_pkt *cmdq_pkt) { + int ret; u32 tmp; -#if IS_REACHABLE(CONFIG_MTK_CMDQ) - if (cmdq_pkt) { - if (mmsys->cmdq_base.size == 0) { - pr_err("mmsys lose gce property, failed to update mmsys bits with cmdq"); + if (mmsys->cmdq_base.size && cmdq_pkt) { + ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys, + mmsys->cmdq_base.offset + offset, val, + mask); + if (ret) + pr_debug("CMDQ unavailable: using CPU write\n"); + else return; - } - cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys, - mmsys->cmdq_base.offset + offset, val, - mask); - return; } -#endif - tmp = readl_relaxed(mmsys->regs + offset); tmp = (tmp & ~mask) | (val & mask); writel_relaxed(tmp, mmsys->regs + offset); @@ -332,11 +329,10 @@ static int mtk_mmsys_probe(struct platform_device *pdev) } } -#if IS_REACHABLE(CONFIG_MTK_CMDQ) + /* CMDQ is optional */ ret = cmdq_dev_get_client_reg(dev, &mmsys->cmdq_base, 0); if (ret) dev_dbg(dev, "No mediatek,gce-client-reg!\n"); -#endif platform_set_drvdata(pdev, mmsys); diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c index b106f3d23e0d..b92cffec7be7 100644 --- a/drivers/soc/mediatek/mtk-mutex.c +++ b/drivers/soc/mediatek/mtk-mutex.c @@ -871,23 +871,18 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt) { struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, mutex[mutex->id]); -#if IS_REACHABLE(CONFIG_MTK_CMDQ) struct cmdq_pkt *cmdq_pkt = (struct cmdq_pkt *)pkt; WARN_ON(&mtx->mutex[mutex->id] != mutex); if (!mtx->cmdq_reg.size) { dev_err(mtx->dev, "mediatek,gce-client-reg hasn't been set"); - return -EINVAL; + return -ENODEV; } cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys, mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 1); return 0; -#else - dev_err(mtx->dev, "Not support for enable MUTEX by CMDQ"); - return -ENODEV; -#endif } EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq); @@ -1000,10 +995,7 @@ static int mtk_mutex_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mtk_mutex_ctx *mtx; struct resource *regs; - int i; -#if IS_REACHABLE(CONFIG_MTK_CMDQ) - int ret; -#endif + int i, ret; mtx = devm_kzalloc(dev, sizeof(*mtx), GFP_KERNEL); if (!mtx) @@ -1030,11 +1022,10 @@ static int mtk_mutex_probe(struct platform_device *pdev) } mtx->addr = regs->start; -#if IS_REACHABLE(CONFIG_MTK_CMDQ) + /* CMDQ is optional */ ret = cmdq_dev_get_client_reg(dev, &mtx->cmdq_reg, 0); if (ret) dev_dbg(dev, "No mediatek,gce-client-reg!\n"); -#endif platform_set_drvdata(pdev, mtx);