From patchwork Wed Jan 23 10:39:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 156350 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp566601jaa; Wed, 23 Jan 2019 02:40:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN7jOC4x5GTlyx2eVcwhIaq+6JCKJE+Ya1iTwsp5qvzmUJqBEuNnsyPcPWUOkWETkrgJOeS1 X-Received: by 2002:a17:902:47aa:: with SMTP id r39mr1668315pld.219.1548240028680; Wed, 23 Jan 2019 02:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548240028; cv=none; d=google.com; s=arc-20160816; b=HGz4tbDsqgtQVxdrTyNIrrcoxs1Codq5yS4N3DsIallqFr1sFYP5eKUL4nvi1DBNes jcRiSM4DhYhdsiV7eLoqU8eWasnlOAnQ2MUrfhcO49Z0yR6uW5BIzfFwhm9K7siMD5f9 Pgc8Wd9Z8EfRBZ579ywnemfPZ7gDJsNstHyd6vwBZ9QyGv+RPZ4ZQoQbaAyM/TkgEz/R SNqmFxkj5goF92XJP+2vAtz8YqRL0om7SNMjusSabW1vBBuB8uvnwR6UGeJsUoXvpRGB IZF96yD/3BzRKYsbA2wLcw0Z0eRhgHDpPQfahkXdhRCH1Hn1EK40vjGg0uY+qC79sJxG iJvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3zHqWWuy6QdexbPT1WjzShm6eV44aO+EPNO+slMK+F4=; b=USCgQYm7kINA6HVpqJV3P+eqdk3qj1RZQeyLCQQNwGKg2rMddZZ++hok8wnt7u6aQ2 sUnPugGjHaIz6YX5EqwANkfxHhy/3BrOnEixG9nhANUUzkOJ7kzPgIRbdAlaAzbj5qgO qbzmfS8YM/OkVsTcdwN7QB5LQgMxsja8tzXnk293HNXzlEgo6vsiJHBjxvyiZw70LL90 7KqpvZUwS0FQbLsmDYp+r4coiQ22Jh4w3imiwNcxkSZdt2OK42vGglRcvFKKpSQdMuDx d60rugE8iaG6rKCVuaQ+IzKPQLpIpNdlzuhJMQUPiymo+4im9S1TSwxdhdcP/rar6TN9 Zx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U97/VS8B"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si602609plk.9.2019.01.23.02.40.28; Wed, 23 Jan 2019 02:40:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U97/VS8B"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727448AbfAWKk1 (ORCPT + 31 others); Wed, 23 Jan 2019 05:40:27 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34821 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727416AbfAWKkZ (ORCPT ); Wed, 23 Jan 2019 05:40:25 -0500 Received: by mail-wr1-f65.google.com with SMTP id 96so1831051wrb.2 for ; Wed, 23 Jan 2019 02:40:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3zHqWWuy6QdexbPT1WjzShm6eV44aO+EPNO+slMK+F4=; b=U97/VS8BPPEXIvimWdZBzJb95FgDVep4KB90tpWx6CfjmRapHheIkX/OvvVmCJbSLY 7N8jE7t9ZVGN9z7rVoMnXPk/IT/RaudN/rvhuinP16iGjotwoKLItKyA3QEcI4ODqDUE heze4eIc0tO+64BuREn9eDtSZ4xBqctXgsUzQ= 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:in-reply-to :references; bh=3zHqWWuy6QdexbPT1WjzShm6eV44aO+EPNO+slMK+F4=; b=ZtoaDhGbMYQCBPDhkyCJ3NItQjKuFtOh2PiADACitrduNIyi/Itq2EKVi542MFkjpt T7jEgBTfxpRG1Iv54p5yzojxINfgHBcMm2vZUYK3xzisrjOcGEZgk4U3AQ/z3VwTO1LB vt+RViIViEhbsRVfgLCWv4twaaFkBYKc7lKFA1LETs5NXNU1t7OvklMG73MhyGfc5jxi e09uOCl4QadCLlp+UWmp3C+bj2Y1E5phpcUk7mRc3Ii3Q7K7GAp+307NYjd3/ExbPSxq Pupiplzr4TixuVPe5PIIDAA5WqC3Ta9scwm6Q1gwnlM7kG5/Ba0Mk949gVU1rrN17e8R xvjg== X-Gm-Message-State: AJcUukeCxbQZCotMk2woymb/4n0vEHdddT9SNF3t6qGTMS8/EHqoLRnJ tpw+xyJyY6eFB3rPt1t619N7QngRY+s= X-Received: by 2002:a5d:4d87:: with SMTP id b7mr1969997wru.316.1548240022510; Wed, 23 Jan 2019 02:40:22 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id b18sm84525211wrw.83.2019.01.23.02.40.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 02:40:22 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Malathi Gottam , Stanimir Varbanov Subject: [PATCH v2 1/4] venus: firmware: check fw size against DT memory region size Date: Wed, 23 Jan 2019 12:39:46 +0200 Message-Id: <20190123103949.13496-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190123103949.13496-1-stanimir.varbanov@linaro.org> References: <20190123103949.13496-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By historical reasons we defined firmware memory size to be 6MB even that the firmware size for all supported Venus versions is 5MBs. Correct that by compare the required firmware size returned from mdt loader and the one provided by DT reserved memory region. We proceed further if the required firmware size is smaller than provided by DT memory region. Reviewed-by: Alexandre Courbot Tested-by: Alexandre Courbot Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/firmware.c | 53 +++++++++++--------- 2 files changed, 31 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 6382cea29185..79c7e816c706 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -134,6 +134,7 @@ struct venus_core { struct video_firmware { struct device *dev; struct iommu_domain *iommu_domain; + size_t mapped_mem_size; } fw; struct mutex lock; struct list_head instances; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index c29acfd70c1b..6cfa8021721e 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -35,14 +35,15 @@ static void venus_reset_cpu(struct venus_core *core) { + u32 fw_size = core->fw.mapped_mem_size; void __iomem *base = core->base; writel(0, base + WRAPPER_FW_START_ADDR); - writel(VENUS_FW_MEM_SIZE, base + WRAPPER_FW_END_ADDR); + writel(fw_size, base + WRAPPER_FW_END_ADDR); writel(0, base + WRAPPER_CPA_START_ADDR); - writel(VENUS_FW_MEM_SIZE, base + WRAPPER_CPA_END_ADDR); - writel(VENUS_FW_MEM_SIZE, base + WRAPPER_NONPIX_START_ADDR); - writel(VENUS_FW_MEM_SIZE, base + WRAPPER_NONPIX_END_ADDR); + writel(fw_size, base + WRAPPER_CPA_END_ADDR); + writel(fw_size, base + WRAPPER_NONPIX_START_ADDR); + writel(fw_size, base + WRAPPER_NONPIX_END_ADDR); writel(0x0, base + WRAPPER_CPU_CGC_DIS); writel(0x0, base + WRAPPER_CPU_CLOCK_CONFIG); @@ -74,6 +75,9 @@ static int venus_load_fw(struct venus_core *core, const char *fwname, void *mem_va; int ret; + *mem_phys = 0; + *mem_size = 0; + dev = core->dev; node = of_parse_phandle(dev->of_node, "memory-region", 0); if (!node) { @@ -85,28 +89,30 @@ static int venus_load_fw(struct venus_core *core, const char *fwname, if (ret) return ret; + ret = request_firmware(&mdt, fwname, dev); + if (ret < 0) + return ret; + + fw_size = qcom_mdt_get_size(mdt); + if (fw_size < 0) { + ret = fw_size; + goto err_release_fw; + } + *mem_phys = r.start; *mem_size = resource_size(&r); - if (*mem_size < VENUS_FW_MEM_SIZE) - return -EINVAL; + if (*mem_size < fw_size || fw_size > VENUS_FW_MEM_SIZE) { + ret = -EINVAL; + goto err_release_fw; + } mem_va = memremap(r.start, *mem_size, MEMREMAP_WC); if (!mem_va) { dev_err(dev, "unable to map memory region: %pa+%zx\n", &r.start, *mem_size); - return -ENOMEM; - } - - ret = request_firmware(&mdt, fwname, dev); - if (ret < 0) - goto err_unmap; - - fw_size = qcom_mdt_get_size(mdt); - if (fw_size < 0) { - ret = fw_size; - release_firmware(mdt); - goto err_unmap; + ret = -ENOMEM; + goto err_release_fw; } if (core->use_tz) @@ -116,10 +122,9 @@ static int venus_load_fw(struct venus_core *core, const char *fwname, ret = qcom_mdt_load_no_init(dev, mdt, fwname, VENUS_PAS_ID, mem_va, *mem_phys, *mem_size, NULL); - release_firmware(mdt); - -err_unmap: memunmap(mem_va); +err_release_fw: + release_firmware(mdt); return ret; } @@ -135,6 +140,7 @@ static int venus_boot_no_tz(struct venus_core *core, phys_addr_t mem_phys, return -EPROBE_DEFER; iommu = core->fw.iommu_domain; + core->fw.mapped_mem_size = mem_size; ret = iommu_map(iommu, VENUS_FW_START_ADDR, mem_phys, mem_size, IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); @@ -150,6 +156,7 @@ static int venus_boot_no_tz(struct venus_core *core, phys_addr_t mem_phys, static int venus_shutdown_no_tz(struct venus_core *core) { + const size_t mapped = core->fw.mapped_mem_size; struct iommu_domain *iommu; size_t unmapped; u32 reg; @@ -166,8 +173,8 @@ static int venus_shutdown_no_tz(struct venus_core *core) iommu = core->fw.iommu_domain; - unmapped = iommu_unmap(iommu, VENUS_FW_START_ADDR, VENUS_FW_MEM_SIZE); - if (unmapped != VENUS_FW_MEM_SIZE) + unmapped = iommu_unmap(iommu, VENUS_FW_START_ADDR, mapped); + if (unmapped != mapped) dev_err(dev, "failed to unmap firmware\n"); return 0; From patchwork Wed Jan 23 10:39:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 156352 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp566664jaa; Wed, 23 Jan 2019 02:40:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN4trBs46pUe71Az5M83/dwZe9XQLHV8CbAjj1tUDdCKO5zGKX6pugc8jPnbLcBzekoND2pa X-Received: by 2002:a63:2c0e:: with SMTP id s14mr1544773pgs.132.1548240032262; Wed, 23 Jan 2019 02:40:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548240032; cv=none; d=google.com; s=arc-20160816; b=fCg2fF9R9gDq389IBySSsFT9kld2ezQ/96nyPVoUKTbQwz68XtMRz5zI8omVlJtqph 5PwSP/Mk8+JnKOSRBy1y9aV4Ejpy4H9ELeoWes+6IhtMQB2P6tZcORM16VO/j8hJPqp/ gxEBqRZBB5gwNkFWcePOhLB6A6xiiCpbAE3ydRiukp514hJArARtyUfIXCFU41DWBsx2 SFd8zlRbLqJxTO+DuyPy1rsa/gHoM+yo+2TBz1rcPmocGUki4YWO/Hn3jTUSSpjLELPn CfijwXvMChZRvmST5uOIofdDiDDTFrcHUhPETlGoHpNXbiN9GpeItQtqCt9II2wX5Fjq BjHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tLwvGwMa/nYthJwEagIIh9pYKQ7nxE//zSavTLSwxqs=; b=wJSRiuB33DXhKKfXG6bQLMmjzbP6NAJ6W/yH2pUSue8FnEWnc2KEEz64qiuZvoodDE XwGy+BiSvQXAXzXVL0TOMbE8Qxd/aoLmsQaMMJf8JKhy+BO8i+LJDJPlxZ75UDWH425t byiZ/cIwHflvY+jm7AomNNXzObjhEOyBrcWkz9Tjg/rNWvkuqQWg+wXEkLnDDJDsVVto x4GbfE09JlW/bD9VtC9PwPoyUKXmvFz807KoPJ+Nepdw61ZVLxMh1EHKqPf+6qNz8qEu 5Czj1iAGdwgYkintUfXfDn8ZJSosdveS9trjMDisUH0AAYaBogr0wh9cVgBUzid2KBgR BbUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PgciD2XA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si16706835pfh.229.2019.01.23.02.40.31; Wed, 23 Jan 2019 02:40:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PgciD2XA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbfAWKk3 (ORCPT + 31 others); Wed, 23 Jan 2019 05:40:29 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34590 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbfAWKk1 (ORCPT ); Wed, 23 Jan 2019 05:40:27 -0500 Received: by mail-wm1-f65.google.com with SMTP id y185so10633326wmd.1 for ; Wed, 23 Jan 2019 02:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tLwvGwMa/nYthJwEagIIh9pYKQ7nxE//zSavTLSwxqs=; b=PgciD2XAnjoYAVFI0Ezfvd+lZ3hiJQlILmgi4f860imXajRKr5UvZnsojJ8Hhu7hG1 pDI/Bt1cYQb8VHiO5GP81jmUP7dsPpeQUiQO3SYpoGRceLBZNYxYlgc8+6rAcDGwcRat 03Rs7jwJiivf39ncCd/zSjlctWXHug5AsfVds= 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:in-reply-to :references; bh=tLwvGwMa/nYthJwEagIIh9pYKQ7nxE//zSavTLSwxqs=; b=CpW8NeKRJC6zJZBYxvWnpLl4XmDLQS0eylSadm8BSReh+NG5EoAO5Aiou7Yk/4DVyS s0kKQ7Lm7V+9MYIXaigTn+9rU5yebRKwuP5jUSOfauPCTuJSp8d3oi6l1oTaRf9w75+E bgYjzJobRJ66zvprGwi9I69Hx7hXYUDtZO532/wfxSVY81Bu7s18kd30xxmX8SsxtMi3 h/U4v536tnG2gOBgHaKSdI5J/8YyItLPNePduV4txumnAYwQkbxAFY23tLyjRU+Y2Eqb rTaQAoZKGNuCNyPZ79xumFec4WHguDMA7gP36zl+9qqvE7USatzWaRdfTBB06iapYL2A V20w== X-Gm-Message-State: AJcUukckX5QEJ1neGAkJYXN1FJgmtUFL4cmDkv7CME4t9kXJqltvzGpm H5chNgVvH58CGsxpV+LJuQrywA== X-Received: by 2002:a1c:2314:: with SMTP id j20mr2162162wmj.142.1548240025471; Wed, 23 Jan 2019 02:40:25 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id b18sm84525211wrw.83.2019.01.23.02.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 02:40:25 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Malathi Gottam , Stanimir Varbanov Subject: [PATCH v2 3/4] venus: core: correct frequency table for sdm845 Date: Wed, 23 Jan 2019 12:39:48 +0200 Message-Id: <20190123103949.13496-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190123103949.13496-1-stanimir.varbanov@linaro.org> References: <20190123103949.13496-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This corrects clock frequency table rates to be in sync with video clock controller frequency table. Reviewed-by: Alexandre Courbot Tested-by: Alexandre Courbot Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index d95185ea32c3..739366744e0f 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -465,10 +465,12 @@ static const struct venus_resources msm8996_res = { }; static const struct freq_tbl sdm845_freq_table[] = { - { 1944000, 380000000 }, /* 4k UHD @ 60 */ - { 972000, 320000000 }, /* 4k UHD @ 30 */ - { 489600, 200000000 }, /* 1080p @ 60 */ - { 244800, 100000000 }, /* 1080p @ 30 */ + { 3110400, 533000000 }, /* 4096x2160@90 */ + { 2073600, 444000000 }, /* 4096x2160@60 */ + { 1944000, 404000000 }, /* 3840x2160@60 */ + { 972000, 330000000 }, /* 3840x2160@30 */ + { 489600, 200000000 }, /* 1920x1080@60 */ + { 244800, 100000000 }, /* 1920x1080@30 */ }; static const struct venus_resources sdm845_res = {