From patchwork Mon Jun 4 20:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 137664 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp100596lji; Mon, 4 Jun 2018 13:32:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIHJAC+MSuc+fOoWEMp6qA4ZLYCTzH4X40KOeCI4AO+tmhjULvFqiqXNDKWQEucWuW1XT+4 X-Received: by 2002:a17:902:708c:: with SMTP id z12-v6mr14981953plk.373.1528144324303; Mon, 04 Jun 2018 13:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144324; cv=none; d=google.com; s=arc-20160816; b=j2gwWB2thXVhuTbNWs1PMeoSZWM9MLsieMsQBE14uk9PzGieUYSn8IVmoNgpJHqzat xqQLFskhUN1PKiDBVEVmH54lXXFfBRjZPNaqdB3oqYXL+FN7GEeLUjI9/US7uz4f0hYg p3MJJQT2rHUBBHtVbRfqj/BG4Lcj+XgUmfU8TImdwTXyGqZf4fnJF+9JsBONpHIvlcKz hwZ7xVZoi7obULg7YWTPdPDTqOPvtox/+QRggshIW/cljAI6vEpKlv1WdlA5RkuDIbiT D+yGTs3qxGXkihdvh3FNKlpWCf+19P8q2N43j61jaX/vlrBHzD4R5fXE6yEcK866J86E QKeg== 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:arc-authentication-results; bh=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=jC0lqwgk26ynmmjRbtx4oQkUNyxV4RmB/S1nAPeJfg/Q/Sv4oqH2Bo+kxhWxny5YZv kOVcDPIGgdyD+Dn1GxIGJjLAYxPCyKLaX9KOSEKCmgKOwobPoDWzJiQxKrQhHSj9tKpk HFCvEDLza+Z/uQusnc3aThe08S2HUv5AVGf04+3fchmGca4CT795z8oasLtfo5Rk5LI/ y+oSdIU9mbZjJjpdLFND6LkZEG5GLnGgizyAFGq6nyFk2eLa7eF9Jdzi4s5o9ZTgdEky WVE9iTb/+fDe7zPKrq0DAztfvSfcCFpBRYM7TxCmWllBSZIXN2lzxrsA6QiMgKc+EW0z itvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RtCCBKqV; 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 3-v6si46278041plx.591.2018.06.04.13.32.03; Mon, 04 Jun 2018 13:32:04 -0700 (PDT) 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=RtCCBKqV; 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 S1751552AbeFDUcC (ORCPT + 30 others); Mon, 4 Jun 2018 16:32:02 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35017 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeFDUao (ORCPT ); Mon, 4 Jun 2018 16:30:44 -0400 Received: by mail-pl0-f67.google.com with SMTP id i5-v6so2122plt.2 for ; Mon, 04 Jun 2018 13:30:44 -0700 (PDT) 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=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=RtCCBKqVxKD/oNWUCOmTyNo4EQctVfGsX1P61pqiy1eAoQfr/1VOKxyM5ZPffwsBvs hiIDVmAsDk8mWxIS0NsCi7mUQoCisui9MlMC25hOA+rOxHnvZcPxbZWkpGEZUiA42OyY UopzYSDSgQJ71nrjxXS2+JGsoYenEXH3pFWqQ= 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=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=GMEycybFktZ6AgiNveTWwT8mNSKuTCvzB/Vi1mrD7pVxjG0nDcCq2mRsbcsfNDJp2B f03wvkapn/PleZNdNvjXiAf+GFZFE7F7oVJ3We0oLYSYjZ4L+aha7sf0pRFqD2Dhmf3f +ZBPGq0F+C2KDqunBdZ/2xvAu8n5xLWFxi9OFruSmLgqi2FVpXvmsNJRUBE+q/6NQiqx DKiTTg4JpGiv4lHYhPytH6+6fiRCeBccmMNja6gOzUm+sThdqHbMU9y3tM/5My9j3dH9 G9CPfnPiuCkzpG4El6OaSNFiraqIaKe9UV0qWVMpIEhU+fWqP4FMAwEL7FhkHTqcaQBX FvNQ== X-Gm-Message-State: ALKqPwdWzzWQPj1TADnMMcY0X3VEdlatGjKKXGnm9XTQAOKHJqqE5sTr 85uRH/k2hlR2OsLc+bhjnJPOTQ== X-Received: by 2002:a17:902:422:: with SMTP id 31-v6mr23925215ple.320.1528144244039; Mon, 04 Jun 2018 13:30:44 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id u68-v6sm83058641pfu.32.2018.06.04.13.30.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 13:30:43 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar , Andy Gross Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/4] remoteproc: qcom: mdt_loader: Make the firmware authentication optional Date: Mon, 4 Jun 2018 13:30:35 -0700 Message-Id: <20180604203038.14080-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180604203038.14080-1-bjorn.andersson@linaro.org> References: <20180604203038.14080-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sricharan R qcom_mdt_load function loads the mdt type firmware and initialises the secure memory as well. Make the initialisation only when requested by the caller, so that the function can be used by self-authenticating remoteproc as well. Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson --- Changes since RFC: - None drivers/soc/qcom/mdt_loader.c | 87 ++++++++++++++++++++--------- include/linux/soc/qcom/mdt_loader.h | 4 ++ 2 files changed, 66 insertions(+), 25 deletions(-) -- 2.17.0 diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index dc09d7ac905f..1c488024c698 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -74,23 +74,10 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) } EXPORT_SYMBOL_GPL(qcom_mdt_get_size); -/** - * qcom_mdt_load() - load the firmware which header is loaded as fw - * @dev: device handle to associate resources with - * @fw: firmware object for the mdt file - * @firmware: name of the firmware, for construction of segment file names - * @pas_id: PAS identifier - * @mem_region: allocated memory region to load firmware into - * @mem_phys: physical address of allocated memory region - * @mem_size: size of the allocated memory region - * @reloc_base: adjusted physical address after relocation - * - * Returns 0 on success, negative errno otherwise. - */ -int qcom_mdt_load(struct device *dev, const struct firmware *fw, - const char *firmware, int pas_id, void *mem_region, - phys_addr_t mem_phys, size_t mem_size, - phys_addr_t *reloc_base) +static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base, bool pas_init) { const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; @@ -121,10 +108,12 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, if (!fw_name) return -ENOMEM; - ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); - if (ret) { - dev_err(dev, "invalid firmware metadata\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); + if (ret) { + dev_err(dev, "invalid firmware metadata\n"); + goto out; + } } for (i = 0; i < ehdr->e_phnum; i++) { @@ -144,10 +133,13 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, } if (relocate) { - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); - if (ret) { - dev_err(dev, "unable to setup relocation\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, + max_addr - min_addr); + if (ret) { + dev_err(dev, "unable to setup relocation\n"); + goto out; + } } /* @@ -202,7 +194,52 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, return ret; } + +/** + * qcom_mdt_load() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, true); +} EXPORT_SYMBOL_GPL(qcom_mdt_load); +/** + * qcom_mdt_load_no_init() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, + void *mem_region, phys_addr_t mem_phys, + size_t mem_size, phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, false); +} +EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init); + MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h index 5b98bbdabc25..944b06aefb0f 100644 --- a/include/linux/soc/qcom/mdt_loader.h +++ b/include/linux/soc/qcom/mdt_loader.h @@ -17,4 +17,8 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, phys_addr_t mem_phys, size_t mem_size, phys_addr_t *reloc_base); +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *fw_name, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base); #endif