From patchwork Fri Aug 11 13:30:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 109868 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp917633qge; Fri, 11 Aug 2017 06:30:57 -0700 (PDT) X-Received: by 10.99.100.134 with SMTP id y128mr15328784pgb.365.1502458257723; Fri, 11 Aug 2017 06:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502458257; cv=none; d=google.com; s=arc-20160816; b=v7um1f8PaTWjAwV6hYjeuv1J9iTIVEAZS6BLAEne5NULpkVJxWAbjWsNmJKN0d/8q9 Y7hUtb1AIngCCUPbDIjwCcr1sGWCoQD9NS9mU3gKTV9ckhO6jTH/Ln/wWMZtW827iMGb Rc+nD9DeAaga8nkVgTHp0ARsEMtd090TAIGjyX6TG5wDgvdmV2fydrH+7hdqXeabgGFG UqjOltRVBzdBAGritSKEPkadm03PZAWEtBxIIEDLMaMliQOytuAOF5mHVHhh5Mm96N0v Tfx/ViFvA+nZeBThCoZc4OudoV50C4wrpB58hE0fI+O9JhsUSTWhynFuC2lORVvCVkd6 nETQ== 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:arc-authentication-results; bh=1nkLDcfG0kx1foZzpaYMqvvL5sr6RvbRQLtD50oC8go=; b=rnExUtH0sX+QfmKxc19n/WVwYXuJ24qFk0OaWq1VMr2r5G8dKDbqRCUEioO10sV8Ot Vepn7ykLYPm8XFLdK4ftiwskXk7vvpn0CcCKQcciBGonKWDY5EMUl7ab6+J5DTZZoo5y fuVpc7C51a+Xt7OJJ0oLFOQDpiqeDdNmdn/gWrYMEG4JBn4+Db7OObW8TFnwMmvaD7wV KOmCgma9/lLkh1o6RsUfJpVzU75XQGGdNkm8lHdDpDgw/+rvsCSKGTdw8bC6yYIUgHoo NKjckrwYCSU8ana6VNxT0QNNldnCJA7r5IK+UVIfgSAfw+BhOy+IK2rFm77pwK3D37Nm iclA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si514594pgt.73.2017.08.11.06.30.57; Fri, 11 Aug 2017 06:30:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753321AbdHKNaZ (ORCPT + 25 others); Fri, 11 Aug 2017 09:30:25 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44568 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753215AbdHKNaW (ORCPT ); Fri, 11 Aug 2017 09:30:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3DABA15AD; Fri, 11 Aug 2017 06:30:22 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B93AF3F540; Fri, 11 Aug 2017 06:30:20 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Arnd Bergmann , Andy Gross , Jens Wiklander Subject: [PATCH 1/3] firmware: of: populate /firmware/ node during init Date: Fri, 11 Aug 2017 14:30:35 +0100 Message-Id: <1502458237-1683-2-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> References: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since "/firmware" does not have its own "compatible" property as it's just collection of nodes representing firmware interface, it's sub-nodes are not populated during system initialization. Currently different firmware drivers search the /firmware/ node and populate the sub-node devices selectively. Instead we can populate the /firmware/ node during init to avoid more drivers continuing to populate the devices selectively. This patch adds initcall to achieve the same. Cc: Arnd Bergmann Cc: Rob Herring Signed-off-by: Sudeep Holla --- drivers/firmware/Makefile | 1 + drivers/firmware/of.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 drivers/firmware/of.c -- 2.7.4 diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 91d3ff62c653..d9a6fce43613 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o +obj-$(CONFIG_OF) += of.o obj-$(CONFIG_QCOM_SCM) += qcom_scm.o obj-$(CONFIG_QCOM_SCM_64) += qcom_scm-64.o obj-$(CONFIG_QCOM_SCM_32) += qcom_scm-32.o diff --git a/drivers/firmware/of.c b/drivers/firmware/of.c new file mode 100644 index 000000000000..149b9660fb44 --- /dev/null +++ b/drivers/firmware/of.c @@ -0,0 +1,34 @@ +/* + * Populates the nodes under /firmware/ device tree node + * + * Copyright (C) 2017 ARM Ltd. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Released under the GPLv2 only. + * SPDX-License-Identifier: GPL-2.0 + */ + +#include +#include +#include + +static int __init firmware_of_init(void) +{ + struct device_node *fw_np; + int ret; + + fw_np = of_find_node_by_name(NULL, "firmware"); + + if (!fw_np) + return 0; + + ret = of_platform_populate(fw_np, NULL, NULL, NULL); + + of_node_put(fw_np); + + return ret; +} +arch_initcall_sync(firmware_of_init); From patchwork Fri Aug 11 13:30:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 109869 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp918017qge; Fri, 11 Aug 2017 06:31:13 -0700 (PDT) X-Received: by 10.99.170.3 with SMTP id e3mr14976641pgf.411.1502458272968; Fri, 11 Aug 2017 06:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502458272; cv=none; d=google.com; s=arc-20160816; b=Mssr1X2Cza3mBCuNEImGWCfzXVGF7ngsGol8FhIka4FMjdYOWu5jWsJ1WLFt8jIJ5S MVXgBCkcJQ89w3dVQqRUpIuZiLcYHt+HH7dBPfwEE7HVlDynVH1mC+UYX5m+QHqejguX TutWwW3PeWCwFH1+1SReA7FuVZsDmOv7U89kvNcnmSDNPjzcm4CnNj7a+M9dXcrfFcgq rZWxw/A5OeGewirWPEapQWonFaT5WnLr4EzCmobGMNSMPKc8s+AlPGdAMCgQeqvEXYNY OjVgJlrgfbsrmILCo/zqWlhH6zEBOcaLEsl/luv2IFbbr/SrlvN+kNGd0sM8onvbQeI+ tmWg== 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:arc-authentication-results; bh=Zsp/tIAGHQQvB95cionTv4HkQrpw9LHJRAIEPy26O20=; b=RUxwgrLPppTEdCz8Pavfyhs47u1mcT+g220APp7sd6pX7RBFOkuwP5Du+Z5OW6e/5f a+DJStyBzOCNgZJT3rsohTSiikDMkuurqpmncED4P6IkKxa6JCUH+Xcxl+NZVZuNLass I/aBhqKlk5iY3dUZP7W1gjcrg186Rld2+7QzFkbXekVVNPvgKxubq92cX0duvOpfr89X XBRMwZRqMNErOilyXe4wKmtrhwQhjooaEFDOP8UVkofnHRDslWFVebMlj/6LE9qQ4Lmj IcEtppOw4IlcVnLG9SflJaZw75HnvMrRhQ2EYOk4/KrjITSwUTTf3OuRRKZW734CSW3E jpxw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si575757plk.617.2017.08.11.06.31.12; Fri, 11 Aug 2017 06:31:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753401AbdHKNbJ (ORCPT + 25 others); Fri, 11 Aug 2017 09:31:09 -0400 Received: from foss.arm.com ([217.140.101.70]:44576 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbdHKNaY (ORCPT ); Fri, 11 Aug 2017 09:30:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2DF8313D5; Fri, 11 Aug 2017 06:30:24 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7BDF83F540; Fri, 11 Aug 2017 06:30:22 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Arnd Bergmann , Andy Gross , Jens Wiklander , David Brown Subject: [PATCH 2/3] firmware: qcom_scm: drop redandant of_platform_populate Date: Fri, 11 Aug 2017 14:30:36 +0100 Message-Id: <1502458237-1683-3-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> References: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that firmware_of_init takes care of populating all the devices under the /firmware/ node, this patch removes the redandant call to of_platform_populate here. Cc: Andy Gross Cc: David Brown Signed-off-by: Sudeep Holla --- drivers/firmware/qcom_scm.c | 24 ------------------------ 1 file changed, 24 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index bb16510d75ba..a11e06e5cdb0 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -440,30 +440,6 @@ static struct platform_driver qcom_scm_driver = { static int __init qcom_scm_init(void) { - struct device_node *np, *fw_np; - int ret; - - fw_np = of_find_node_by_name(NULL, "firmware"); - - if (!fw_np) - return -ENODEV; - - np = of_find_matching_node(fw_np, qcom_scm_dt_match); - - if (!np) { - of_node_put(fw_np); - return -ENODEV; - } - - of_node_put(np); - - ret = of_platform_populate(fw_np, qcom_scm_dt_match, NULL, NULL); - - of_node_put(fw_np); - - if (ret) - return ret; - return platform_driver_register(&qcom_scm_driver); } subsys_initcall(qcom_scm_init); From patchwork Fri Aug 11 13:30:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 109867 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp917369qge; Fri, 11 Aug 2017 06:30:46 -0700 (PDT) X-Received: by 10.99.9.2 with SMTP id 2mr15532226pgj.84.1502458246428; Fri, 11 Aug 2017 06:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502458246; cv=none; d=google.com; s=arc-20160816; b=MuPVSCzZXAVr96PxeJAZ8qAg5YXclszxXBTiXi3anCFvEqdPU7hIUqSqEbVgfwjE6x DVmzWywD4adwpUH1zno49tHrhZcI3smo4YDmgfsPLGjCYB9oMRWcAMnMpD1SyshT+4DW IecstvLwDCiBN5C/WurODl28XRncGy3e6mQvIF5+0et+KfJ6pciqz0bWX2QfUZZ6dmyn MnBvpSf6TmL2LOKRy2O0Pg3RVXDcVkiZ1Ma+6WG3XtvVGpUAlJfFnYVGiS9+KgwELte9 Ri12vCMoPi1cvfMputurW6LFJg6B+TAimBrj1KN/fBKXK1bfGl/1p37bgreSTKDqZFzG lnEg== 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:arc-authentication-results; bh=dRQUWEwXkShJUVvlfNia/JG/AjFY+73d9BtuqVw+Vwc=; b=SsIJCvNZUOLu+3Nx7QDRKcBL5lqED1IIfbAsPf5ZS+UfhZuZ3+jodGJt29lWMt+Aw7 fViQrsJAd0AGCGt5l/fO1G1y8rnQtoVjvEMUc28R4vs33VNjId4nGpOXLvElKOtBw7D+ SgoxKOd0as/u5QQFtlX3aNrPtV0HjUfNgfbkXbiMm7msgmyPwKTpTK73+A+J4oeS8MGn aaFsGH7gJiOs5A7BrPM38DZiCMktxkYJmMN8LjalG9b3Q2Y20EpTpRBx88f9V0UEomQ4 D1mR7O4IcBRTNgZkSpzODhK+xqOIire+08haSCd10S7tji/POGRqxRYqG4VEKKxbV1nl myvw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si527177pfa.168.2017.08.11.06.30.46; Fri, 11 Aug 2017 06:30:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352AbdHKNal (ORCPT + 25 others); Fri, 11 Aug 2017 09:30:41 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44584 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090AbdHKNa0 (ORCPT ); Fri, 11 Aug 2017 09:30:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E434015AD; Fri, 11 Aug 2017 06:30:25 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6BE6E3F540; Fri, 11 Aug 2017 06:30:24 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Arnd Bergmann , Andy Gross , Jens Wiklander Subject: [PATCH 3/3] drivers: tee: rework optee_driver_{init, exit} to use platform device Date: Fri, 11 Aug 2017 14:30:37 +0100 Message-Id: <1502458237-1683-4-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> References: <1502458237-1683-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that firmware_of_init takes care of populating all the devices under the /firmware/ node, this patch reworks/removes custom optee_driver_{init,exit} in favour of module_platform_driver. Cc: Jens Wiklander Signed-off-by: Sudeep Holla --- drivers/tee/optee/core.c | 74 ++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 49 deletions(-) -- 2.7.4 diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 58169e519422..6c368508e835 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -445,8 +445,9 @@ static optee_invoke_fn *get_invoke_func(struct device_node *np) return ERR_PTR(-EINVAL); } -static struct optee *optee_probe(struct device_node *np) +static int optee_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; optee_invoke_fn *invoke_fn; struct tee_shm_pool *pool; struct optee *optee = NULL; @@ -457,21 +458,21 @@ static struct optee *optee_probe(struct device_node *np) invoke_fn = get_invoke_func(np); if (IS_ERR(invoke_fn)) - return (void *)invoke_fn; + return PTR_ERR(invoke_fn); if (!optee_msg_api_uid_is_optee_api(invoke_fn)) { pr_warn("api uid mismatch\n"); - return ERR_PTR(-EINVAL); + return -EINVAL; } if (!optee_msg_api_revision_is_compatible(invoke_fn)) { pr_warn("api revision mismatch\n"); - return ERR_PTR(-EINVAL); + return -EINVAL; } if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps)) { pr_warn("capabilities mismatch\n"); - return ERR_PTR(-EINVAL); + return -EINVAL; } /* @@ -479,11 +480,11 @@ static struct optee *optee_probe(struct device_node *np) * doesn't have any reserved memory we can use we can't continue. */ if (!(sec_caps & OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM)) - return ERR_PTR(-EINVAL); + return -EINVAL; pool = optee_config_shm_memremap(invoke_fn, &memremaped_shm); if (IS_ERR(pool)) - return (void *)pool; + return PTR_ERR(pool); optee = kzalloc(sizeof(*optee), GFP_KERNEL); if (!optee) { @@ -523,9 +524,10 @@ static struct optee *optee_probe(struct device_node *np) optee->pool = pool; optee_enable_shm_cache(optee); + platform_set_drvdata(pdev, optee); pr_info("initialized driver\n"); - return optee; + return 0; err: if (optee) { /* @@ -541,11 +543,12 @@ static struct optee *optee_probe(struct device_node *np) tee_shm_pool_free(pool); if (memremaped_shm) memunmap(memremaped_shm); - return ERR_PTR(rc); + return rc; } -static void optee_remove(struct optee *optee) +static int optee_remove(struct platform_device *pdev) { + struct optee *optee = platform_get_drvdata(pdev); /* * Ask OP-TEE to free all cached shared memory objects to decrease * reference counters and also avoid wild pointers in secure world @@ -568,52 +571,25 @@ static void optee_remove(struct optee *optee) mutex_destroy(&optee->call_queue.mutex); kfree(optee); + return 0; } static const struct of_device_id optee_match[] = { { .compatible = "linaro,optee-tz" }, {}, }; +MODULE_DEVICE_TABLE(of, optee_match); + +static struct platform_driver optee_platdrv = { + .driver = { + .name = "optee", + .of_match_table = of_match_ptr(optee_match), + }, + .probe = optee_probe, + .remove = optee_remove, +}; -static struct optee *optee_svc; - -static int __init optee_driver_init(void) -{ - struct device_node *fw_np; - struct device_node *np; - struct optee *optee; - - /* Node is supposed to be below /firmware */ - fw_np = of_find_node_by_name(NULL, "firmware"); - if (!fw_np) - return -ENODEV; - - np = of_find_matching_node(fw_np, optee_match); - of_node_put(fw_np); - if (!np) - return -ENODEV; - - optee = optee_probe(np); - of_node_put(np); - - if (IS_ERR(optee)) - return PTR_ERR(optee); - - optee_svc = optee; - - return 0; -} -module_init(optee_driver_init); - -static void __exit optee_driver_exit(void) -{ - struct optee *optee = optee_svc; - - optee_svc = NULL; - if (optee) - optee_remove(optee); -} -module_exit(optee_driver_exit); +module_platform_driver(optee_platdrv); MODULE_AUTHOR("Linaro"); MODULE_DESCRIPTION("OP-TEE driver");