From patchwork Sat Oct 3 13:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 11815223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24EC7618 for ; Sat, 3 Oct 2020 13:10:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C60D220829 for ; Sat, 3 Oct 2020 13:10:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p4FxmOCl"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WpTYoa9S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C60D220829 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=jeKRgEAoWxm3XjwGuu7vW3VHiqGsO6S3kPlJpvX2sz8=; b=p4FxmOClB8lfympBAslKePdJ8T Aozcr8pgR5o2Vny3+q+JJiEhG6aGQ/Mw1V8F28fEUdJWJSKMyP4vMJBO+5sfgT9/hpt4n5S7Gw2CW iNqKY+AgP8fFg4yfWhMtZgsK7hPa+zS6vl3ffvTNZ/9P/RcOe7bQLbcO6MhAB74ufnCZ3Ij/Hudxh TO+ilRZSpWXoBXUvMibxgfiGNPZg713Ntuyt8sBHE3GL70GHuTv3j2t9C2BFsDT5DnKlAMAzTie5A icK1LKhSeUwVH7ZV6H7MoLvrwq0kceVRN+oLvObFS2y4s82Hf7psXm7N5Yiet1ed527QeIxZBXFT9 hxuGWrsA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kOhIh-0008S9-4v; Sat, 03 Oct 2020 13:10:11 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kOhIf-0008RZ-4Z for linux-mediatek@lists.infradead.org; Sat, 03 Oct 2020 13:10:09 +0000 Received: by mail-pf1-x441.google.com with SMTP id e10so2846765pfj.1 for ; Sat, 03 Oct 2020 06:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Wqfp6uDLd1Ek6c5nY5LcdFjEx+sOBJtiN1rh9srmovY=; b=WpTYoa9SyELCp3OGJgRtON2R34el+7p1DgN7M0FVF28nSLfbSLXCrJVl8qH+IJYvxA Ylhrfg6qNrok0XQkytQcaMZGTpgIWBAOYKD2qCCHoMOhnK68P70Arg+ZX151HJk2UaSF i8xTvdkyigOE0Qt1T/S0BwY2hMQUy6/Wi+D94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Wqfp6uDLd1Ek6c5nY5LcdFjEx+sOBJtiN1rh9srmovY=; b=nmbymA9NpVhI0RbusZjorUgelsVE+nDXa828Y2BUnn/CSvWakcnvBxmRNRmqZZN5qs ZGAAN4TMxumQpuS1oD4pYFlk1MY5ThwLhkjP/K7q93r5LnR08c07g546H7d37/HXO0mJ q8WP+H+S4lz0vmkkNDMagqJa0HHN47qFkr7gu38jNLWr3QGMtpZbaw7pYM+U2G9n56+z jGeNxgBQ1Ewhp2rHT49z7G0jJhSjvFdI3F+vkYY+jWnaNy82C7uMU0hsWpXaTVamMfxT tI0ZbsepSa3pWiJ3tmzwhD78/B2KyuKrHYPinRCLqAYXEQIWHsR+frNtqxcvVhjbaJW2 EAoA== X-Gm-Message-State: AOAM5326n+cVQtbDicQqtr3IHQW8+kYnQGXdp0lJ0IoquoFrzd6tzTe+ g+n/dYGPC1rt6g/VTZkvjAi+Rw== X-Google-Smtp-Source: ABdhPJydOa1l3ngWaWpt5IC7SXDSQpLwq34xTwJ/r3w6gvVxbWCZ4nuiwiKrnmHTE9bYsSp+jpnDWA== X-Received: by 2002:a63:6746:: with SMTP id b67mr5891562pgc.301.1601730604943; Sat, 03 Oct 2020 06:10:04 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:eeb1:d7ff:fe57:b7e5]) by smtp.gmail.com with ESMTPSA id d1sm5812763pfn.220.2020.10.03.06.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Oct 2020 06:10:04 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Sakari Ailus , Tomasz Figa Subject: [PATCH] media: mtk-vcodec: fix builds when remoteproc is disabled Date: Sat, 3 Oct 2020 22:09:47 +0900 Message-Id: <20201003130947.555637-1-acourbot@chromium.org> X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201003_091009_210524_8E339057 X-CRM114-Status: GOOD ( 20.69 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Verkuil , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org The addition of MT8183 support added a dependency on the SCP remoteproc module. However the initial patch used the "select" Kconfig directive, which may result in the SCP module to not be compiled if remoteproc was disabled. In such a case, mtk-vcodec would try to link against non-existent SCP symbols. "select" was clearly misused here as explained in kconfig-language.txt. Replace this by a "depends" directive on at least one of the VPU and SCP modules, to allow the driver to be compiled as long as one of these is enabled, and adapt the code to support this new scenario. Also adapt the Kconfig text to explain the extra requirements for MT8173 and MT8183. Reported-by: Sakari Ailus Signed-off-by: Alexandre Courbot Acked-by: Randy Dunlap # build-tested --- drivers/media/platform/Kconfig | 11 +-- .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 72 ++++++++++++------- 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index a3cb104956d5..e559d9c529b6 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -253,14 +253,17 @@ config VIDEO_MEDIATEK_VCODEC depends on MTK_IOMMU || COMPILE_TEST depends on VIDEO_DEV && VIDEO_V4L2 depends on ARCH_MEDIATEK || COMPILE_TEST + depends on VIDEO_MEDIATEK_VPU || MTK_SCP select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV - select VIDEO_MEDIATEK_VPU - select MTK_SCP help Mediatek video codec driver provides HW capability to - encode and decode in a range of video formats - This driver rely on VPU driver to communicate with VPU. + encode and decode in a range of video formats on MT8173 + and MT8183. + + Note that support for support for MT8173 requires + VIDEO_MEDIATEK_VPU to also be selected. Support for + MT8183 depends on MTK_SCP. To compile this driver as modules, choose M here: the modules will be called mtk-vcodec-dec and mtk-vcodec-enc. diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c index 6c2a2568d844..23a80027a8fb 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c @@ -13,6 +13,7 @@ struct mtk_vcodec_fw_ops { mtk_vcodec_ipi_handler handler, const char *name, void *priv); int (*ipi_send)(struct mtk_vcodec_fw *fw, int id, void *buf, unsigned int len, unsigned int wait); + void (*release)(struct mtk_vcodec_fw *fw); }; struct mtk_vcodec_fw { @@ -22,6 +23,8 @@ struct mtk_vcodec_fw { struct mtk_scp *scp; }; +#if IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VPU) + static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw) { return vpu_load_firmware(fw->pdev); @@ -64,6 +67,27 @@ static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf, return vpu_ipi_send(fw->pdev, id, buf, len); } +static void mtk_vcodec_vpu_release(struct mtk_vcodec_fw *fw) +{ + put_device(&fw->pdev->dev); +} + +static void mtk_vcodec_vpu_reset_handler(void *priv) +{ + struct mtk_vcodec_dev *dev = priv; + struct mtk_vcodec_ctx *ctx; + + mtk_v4l2_err("Watchdog timeout!!"); + + mutex_lock(&dev->dev_mutex); + list_for_each_entry(ctx, &dev->ctx_list, list) { + ctx->state = MTK_STATE_ABORT; + mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ABORT", + ctx->id); + } + mutex_unlock(&dev->dev_mutex); +} + static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = { .load_firmware = mtk_vcodec_vpu_load_firmware, .get_vdec_capa = mtk_vcodec_vpu_get_vdec_capa, @@ -71,8 +95,13 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = { .map_dm_addr = mtk_vcodec_vpu_map_dm_addr, .ipi_register = mtk_vcodec_vpu_set_ipi_register, .ipi_send = mtk_vcodec_vpu_ipi_send, + .release = mtk_vcodec_vpu_release, }; +#endif /* IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VPU) */ + +#if IS_ENABLED(CONFIG_MTK_SCP) + static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw) { return rproc_boot(scp_get_rproc(fw->scp)); @@ -107,6 +136,11 @@ static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf, return scp_ipi_send(fw->scp, id, buf, len, wait); } +static void mtk_vcodec_scp_release(struct mtk_vcodec_fw *fw) +{ + scp_put(fw->scp); +} + static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = { .load_firmware = mtk_vcodec_scp_load_firmware, .get_vdec_capa = mtk_vcodec_scp_get_vdec_capa, @@ -114,23 +148,10 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = { .map_dm_addr = mtk_vcodec_vpu_scp_dm_addr, .ipi_register = mtk_vcodec_scp_set_ipi_register, .ipi_send = mtk_vcodec_scp_ipi_send, + .release = mtk_vcodec_scp_release, }; -static void mtk_vcodec_reset_handler(void *priv) -{ - struct mtk_vcodec_dev *dev = priv; - struct mtk_vcodec_ctx *ctx; - - mtk_v4l2_err("Watchdog timeout!!"); - - mutex_lock(&dev->dev_mutex); - list_for_each_entry(ctx, &dev->ctx_list, list) { - ctx->state = MTK_STATE_ABORT; - mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ABORT", - ctx->id); - } - mutex_unlock(&dev->dev_mutex); -} +#endif /* IS_ENABLED(CONFIG_MTK_SCP) */ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, enum mtk_vcodec_fw_type type, @@ -143,16 +164,22 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, switch (type) { case VPU: +#if IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VPU) ops = &mtk_vcodec_vpu_msg; fw_pdev = vpu_get_plat_device(dev->plat_dev); if (!fw_pdev) { mtk_v4l2_err("firmware device is not ready"); return ERR_PTR(-EINVAL); } - vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler, + vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_vpu_reset_handler, dev, rst_id); break; +#else + mtk_v4l2_err("no VPU support in this kernel"); + return ERR_PTR(-ENODEV); +#endif case SCP: +#if IS_ENABLED(CONFIG_MTK_SCP) ops = &mtk_vcodec_rproc_msg; scp = scp_get(dev->plat_dev); if (!scp) { @@ -160,6 +187,10 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, return ERR_PTR(-EPROBE_DEFER); } break; +#else + mtk_v4l2_err("no SCP support in this kernel"); + return ERR_PTR(-ENODEV); +#endif default: mtk_v4l2_err("invalid vcodec fw type"); return ERR_PTR(-EINVAL); @@ -180,14 +211,7 @@ EXPORT_SYMBOL_GPL(mtk_vcodec_fw_select); void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw) { - switch (fw->type) { - case VPU: - put_device(&fw->pdev->dev); - break; - case SCP: - scp_put(fw->scp); - break; - } + fw->ops->release(fw); } EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release);