From patchwork Fri May 21 13:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 12273227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71495C433B4 for ; Fri, 21 May 2021 13:43:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 F10AE61163 for ; Fri, 21 May 2021 13:43:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F10AE61163 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc: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=qrBpIj0mDQcR4d51RREa3d7ecHAycXbXUvcITUDYKLQ=; b=cY8gOcZT9/mN9VK0sb9ZNKC2w3 m7TNrXdgu8xrkI2q5kHGXrCHTvHZlZOfjPuLjIbfDPXcjGGRGJNz7rvG7GDTtPUtaObfsyoIXjOXB 8OEIosyXYUFTkIz2yCQbKdq1EN5Rwbq7THL4KU1bV9qB3Snp8xWrAv8Izl5LjVqcZ4Rk1aukVAcG8 OcATKpFs+nK4OplI/keyj4Ynm0msy1hJ5g5ED40Ghae0lfoXuBVAQqwDLuHFvQIF9BbN/UQhGPlKs TXvO/bh6vLdHbwVjUsn47WzaVIjJ8VMIXBXCcSipaP6N+nYz3zSTM4Vphx6UBYFTZFPo7f+5/wkiG /m4Ue4Bg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Pa-005aRq-L6; Fri, 21 May 2021 13:41:59 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Ok-005Zw0-Bh for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 13:41:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=OrsL3ijuFSJ3ZZgJ9AxoZPMhh9aQmo9XUjzO0XjBs/0=; b=LO5UvFsfbWu13f3sdgNjdIoXBk eEvvjlJTtasc0eKDY4rvacwQBFhw4lV9+jvfuHdO15y+0LzpKJFLFlnLcBdncBjOpeXiZXKrtIM8Y WcMwvW1ShAWfuAhgXv9aWIxf/4FC69omaRKoYi2rkdQf8O7V+e2tMmYXt8O7YE9Rkvs7f4GedfP9u SgS0asC+0Tstl/KAf6ZJGmtmyo2AUcJOFxtvP9OgGFCmtMSeV/BfQ7eoq5o0s6Z8asMEcqVWaEumT WSHK4IZqDykpzE1XwRqseltdBa38HXSP12IQlwOcbuALVI07VsgD9ZR2qyeOgU7PKmNcMs/nq5P+n 68pjZN5Q==; Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lk5Oh-00H9nX-So for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 13:41:05 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 62so10142238wmb.3 for ; Fri, 21 May 2021 06:41:02 -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; bh=OrsL3ijuFSJ3ZZgJ9AxoZPMhh9aQmo9XUjzO0XjBs/0=; b=ISHFNr4RS6qw0pElX+tFiTJdSzm/pDscdwn2Jk0uOFOAW0hvfsBxw+omu/rd/T72DI KHrTvEN7ZYAQAyYGqqI38syyVLaBzqmPoIItwzSCf4Cnnk5qBl8BkZcdebrSjTnrN2Ma SXu+JEMBVcQ9BANF6NGSwXhBG9cXuD/i7jwe9rmfucyUHfCJMoMvARkYhyTtzX/ZNIEA HTjY3jwbaGAbBHMPaG5jPmI9icdbcPFG1baAPT+a1XQ3s3hqIioIamsA3Odqcljy9cpU TLjZrEhh7vIIUasczmsIXV3MROsfxdZDI1G6PDlKSOzEtNiLwroSNLWo/zCSFpODd1Up WqVw== 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; bh=OrsL3ijuFSJ3ZZgJ9AxoZPMhh9aQmo9XUjzO0XjBs/0=; b=hTgh69UPn0F5CK2Q0+DthhncqsdPaIu/cxhf1/UQ1rFOjNTHtFOSudfG+tYy7hF7/5 Ps3PF1NvSExtN0zSGFzHILBmnej45Qwgx7vdErXoLIYpyjF7dbLul7Rr986uZfAokZDu KH34UMOeD0epiSF5q/R18FTnmuYtZihAz98EsCy9EJ5avFfZuD487mJKrA1vv7/bJb8T d0J5wVE1KbDemBN+ttaRhnABrbIEHfa6WgpGwW2XiMtJEexzOctWffuFD6q20K5CsoAk x2XPkZWPXOtHZefDONUseCxwe8Z9/xPSWS/wkMDWC+Wzlmm25NEILbkxs7q/Ur8S8uES PcQw== X-Gm-Message-State: AOAM533+bDn6MO4BNWcTRXwn4BNFv/7hCf2bxyPdoh9EfjIxnub6p+8P 1rTbv/KreSkfd0fdkw8rCi7N3Q== X-Google-Smtp-Source: ABdhPJwYojvyeIOiL145Xr6wOf8/7FX0+5qHz+5IsU9AvaTL+XeekddE0zQe+K/uhzbxmNCjamROjA== X-Received: by 2002:a7b:c252:: with SMTP id b18mr8938970wmj.32.1621604461145; Fri, 21 May 2021 06:41:01 -0700 (PDT) Received: from lmecxl0524.home (2a01cb058b850800205e07f10870202e.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:205e:7f1:870:202e]) by smtp.gmail.com with ESMTPSA id v3sm2161372wrr.19.2021.05.21.06.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 06:41:00 -0700 (PDT) From: Etienne Carriere To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Cristian Marussi , Vincent Guittot , Etienne Carriere Subject: [PATCH v2 1/4] firmware: arm_scmi: fix deps arm-smccc-discovery deps in Kconfig Date: Fri, 21 May 2021 15:40:51 +0200 Message-Id: <20210521134055.24271-1-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_064103_949924_7902CB36 X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ARM_SCMI_PROTOCOL depends one either MAILBOX or HAVE_ARM_SMCCC_DISCOVERY, not MAILBOX only. This change fixes this in Kconfig file and driver private header file. Signed-off-by: Etienne Carriere Reviewed-by: Cristian Marussi --- No change since v1 --- drivers/firmware/Kconfig | 2 +- drivers/firmware/arm_scmi/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index db0ea2d2d75a..a9c613c32282 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -9,7 +9,7 @@ menu "Firmware Drivers" config ARM_SCMI_PROTOCOL tristate "ARM System Control and Management Interface (SCMI) Message Protocol" depends on ARM || ARM64 || COMPILE_TEST - depends on MAILBOX + depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY help ARM System Control and Management Interface (SCMI) protocol is a set of operating system-independent software interfaces that are diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 228bf4a71d23..8685619d38f9 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -331,7 +331,7 @@ struct scmi_desc { }; extern const struct scmi_desc scmi_mailbox_desc; -#ifdef CONFIG_HAVE_ARM_SMCCC +#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY extern const struct scmi_desc scmi_smc_desc; #endif From patchwork Fri May 21 13:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 12273231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E48CDC433B4 for ; Fri, 21 May 2021 13:44:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7590F613CB for ; Fri, 21 May 2021 13:44:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7590F613CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5/RP77s59av80G0v6y+NRp5EEfb/a++rySGBDVGu8TM=; b=UWz6ONR4NXcuucNFxsu7w9r30B 5yYnEtMt0xz/NIgXMW0IMJAV+w+bTLyEA3uBmm3Xa7Sfy48q0hEA7hRM5wdn0nhKsHK0N/Ak/SSEj FHbAc5L6f33f2obyXwob6E/Wr5p1B6/Tk2z7+PwmzY4+Dk9cfrqWfFOycaO4o9uVz4bHmndVUBICz BuPG/SS6SyteupF5HSmbHPyKUysT8GAgdGQ83vFY471w7GxJPbC+WwEgfqoHfRTmqHrDJItMDvQgN 6IgiH5ZZ+woSQkNxq5C8u4uHUtoxOYu2AgUgN0tGpOvn8a74rwp2VLiMvmX4paEdepW5TAsKQuq5i liaZAsxA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Q4-005aq7-2I; Fri, 21 May 2021 13:42:28 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Ol-005Zwj-Ll for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 13:41:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IqnQwk+rzq8B5GCCfhlsvjspQ3NXPy3MftR2FeNfKC8=; b=w4bWmKF6/2NlhujKPLXQ05dIDu R+pzUkkdwvaSDDQGmQ++vV4U7jYhlDbu7NYl/pZYh/lcPSfqf5sTrXXJ2iEwg9S5IbCcZ9bECjeaJ Osy/RFaCNbn6JAGlgC4On69gb2gP90xMbQcqiolLDQIwMIQEH/iS+ZjyHW5quIMhOnK/NKDSjbH/N wksAkHaoy7hFh1TWA0aTzHRs+8alc/GbByXucUop2bxjFQXESNCPEHgSHLS50kmsWfUfDyOkNRxLC kRVpbal5c7Ex/WpGTkm9LndVmwcCV1FaltHJ7YCHqUH5EyJS35m0djadWtjDPJHdbrNmzoPTxUprq ts9KCSRA==; Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lk5Oi-00H9nY-BH for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 13:41:06 +0000 Received: by mail-wm1-x32e.google.com with SMTP id f6-20020a1c1f060000b0290175ca89f698so7423966wmf.5 for ; Fri, 21 May 2021 06:41:02 -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=IqnQwk+rzq8B5GCCfhlsvjspQ3NXPy3MftR2FeNfKC8=; b=z8jWmpn38ibayFo63Kby2WaNoWSM/qz0w50403AYtWu/IBs+VX3HJLuEvxrNM9weXR HQY+SqBtULKHjY7qWMFHjmSD/Z99jQaG8JjSmZl2PK84Y4m6lwTSg6ubUre4STc5fcEq iQNBq1VQoYuPfcNnDPgeB195yiM504N+kcMbjhnWyok+Lg62dQ2bV/fmZuAK75Sx72+f vir+sy+ZYfDqgRxzte5b5UGr/D1aGasXx15vN3i+y0JBKDeprU+R+ZoF1IZbMx9OfR/k +0PgdllHBphufXPXoCUArN/CzU1jQOVAqEaPXCxzjrfZgTtblXJ0KgPf07TF3JAhILqq Iqng== 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=IqnQwk+rzq8B5GCCfhlsvjspQ3NXPy3MftR2FeNfKC8=; b=Ej/0epYmHZY81ciOziC3vui9bWjH4efg1Ud4k8W/8NCOsPjoI3GPSWUsjlZ3Rge87o fVCw6RKCYlzldDq07tYU35XqWI2Zl+JSY57VwjVhekGaE0rB9sIIndYBOYxIDPzVQJe6 rqBpzsHxhOcUdAiXpTU7lNO4oAAkhEDAbKJ4YEnzGiJgkqNg+3j2VaJgZw0DN8JgUhVY nxeNbz5Hh1h6A/UKHNA8UtRQb4Ija1OB/6f/ZDenlQy/tpRoADBZeGNiCO8cBIK5kmkl iLwnPiv4GFO3wMU/gxOnt9g/sOA2RZY1ypf8VZ/+Jw25JAKZkvvXj0t2HKmCR0D8yyq1 yE3A== X-Gm-Message-State: AOAM532jxSBjAR0I/VQXuD1JSFNFYpqV1q3X28nryvI4jlP4Sb5AsmVI J8FHU4S2qwRyJ/8gEKVcyLeyfQ== X-Google-Smtp-Source: ABdhPJzIg08D6kbfQhjH0HA0OR71RkJFpI8omX5oAIN8Zt7uW32KpgKwtjG73aezbrTy37gLyYE70w== X-Received: by 2002:a05:600c:218b:: with SMTP id e11mr9541462wme.12.1621604461758; Fri, 21 May 2021 06:41:01 -0700 (PDT) Received: from lmecxl0524.home (2a01cb058b850800205e07f10870202e.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:205e:7f1:870:202e]) by smtp.gmail.com with ESMTPSA id v3sm2161372wrr.19.2021.05.21.06.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 06:41:01 -0700 (PDT) From: Etienne Carriere To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Cristian Marussi , Vincent Guittot , Etienne Carriere , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v2 2/4] dt-bindings: arm: scmi property mboxes is not mandatory Date: Fri, 21 May 2021 15:40:52 +0200 Message-Id: <20210521134055.24271-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210521134055.24271-1-etienne.carriere@linaro.org> References: <20210521134055.24271-1-etienne.carriere@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_064104_405595_8013E872 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since "arm,scmi-smc" compatible support, mboxes property is not mandated. This change fixes the DT bindings description accordingly. Cc: Rob Herring Cc: devicetree@vger.kernel.org Signed-off-by: Etienne Carriere --- Changes since v1: - New patch is the series. Addresses mboxes propery description. --- Documentation/devicetree/bindings/arm/arm,scmi.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/arm,scmi.txt b/Documentation/devicetree/bindings/arm/arm,scmi.txt index 667d58e0a659..856d041b397e 100644 --- a/Documentation/devicetree/bindings/arm/arm,scmi.txt +++ b/Documentation/devicetree/bindings/arm/arm,scmi.txt @@ -15,10 +15,10 @@ Required properties: The scmi node with the following properties shall be under the /firmware/ node. - compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports -- mboxes: List of phandle and mailbox channel specifiers. It should contain - exactly one or two mailboxes, one for transmitting messages("tx") - and another optional for receiving the notifications("rx") if - supported. +- mboxes: List of phandle and mailbox channel specifiers. When used, it should + contain exactly one or two mailboxes, one for transmitting messages + ("tx") and another optional for receiving the notifications("rx") if + supported. Mandated by compatible "arm,scmi". - shmem : List of phandle pointing to the shared memory(SHM) area as per generic mailbox client binding. - #address-cells : should be '1' if the device has sub-nodes, maps to From patchwork Fri May 21 13:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 12273229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C0E1C433B4 for ; Fri, 21 May 2021 13:43:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 BBD90611AD for ; Fri, 21 May 2021 13:43:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBD90611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d3sePjjCfOhbK91hqUGVL505zGALrzBbEZHXEANwxmw=; b=jZk7YYdVvi5F/b+JgoZuROxyX6 Vjrli0zU5SQUescTqGEX4WCUyp62ViloGuX4rTJvMb1LSwMJmhPt+0NuUty4igpE3HjADZBKJcIuY pLe4HAwBHRLvlzBgaDWrSi8cK5FvrpkhCn+P9RVlB3wQROeOo9orufTm/XCtprFxBiOdWzqaghNtt fBVrQn1+DrcZd/Zg1gLcne4T1v5qfaeVtpLYrBHd/vzFw0VdD40nZIyK3O9v1C2Shlr32o9ALYhD2 VzwjfQsWwrYtp1dTi4UaG4+89thTJnINsSaJC1ZqK8NNiss1FmpR+zcWlNIXGT8SnzeHcXufstrqL tRpAlKMw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Pp-005adz-TR; Fri, 21 May 2021 13:42:14 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Ok-005Zw1-Kt for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 13:41:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gdVy1JGSBoZuqI274R7n9JIUIxcN1AY4e4E1RFGG9Dg=; b=Hj9v9awZteWHa1Ys/0HIR6ZkVe DwhUwqM2A6c/BkDuQv5K3D7roELEUf3V4RkwwKJiMU//S5d2WE1YoD8o8/vijBoIkZ/K0gc7p0zwH eiTGnXyjT5QMGe6f12CK9xBuT2w1yi/SqPqclYR5b1BX5rexCxpyOFvfc7194VN5AJGLViPO5iAAB z7BUguMoGhq3rz50v7oI4N79SdAzb6oIXxrKJLnrLKBAQNBc2dUeRhteOJmzHGhbRzvwebHnAh+x+ bvQLUn7xk95D0uDw3t95izL6drO5QZueO9q6nIvAyO6FIbowVnJm0yyjVihtlN/FxrD2HkmGrnima TN7EMSLA==; Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lk5Oi-00H9nZ-5m for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 13:41:05 +0000 Received: by mail-wr1-x433.google.com with SMTP id z17so21110398wrq.7 for ; Fri, 21 May 2021 06:41:03 -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=gdVy1JGSBoZuqI274R7n9JIUIxcN1AY4e4E1RFGG9Dg=; b=XT+WuJkP7kfD3oFoklO/xy+Oqoj/F309Q26ExLm+Q7Zls8oFptQ8oRbWO1h+PlpRol 6JoO9iVJhh4ij5bY/Nm7cJAXXGdcG9swCZmPEQRF0Z4JgkzDkAXGldbNq7p4QrIsPfLr NI2+dU5dIe/FD9YUM4BpO6noa1uS3P4onCp80vuEHKC/f0rf9NYG6weEf8ieh09zG5kT 1LtO4Ikk1vw4IzLb5MKIZIfTRyVJV9322p9kbGDuFpwWlkygyDDVPZI1XYH3BCX0bxwR 5nV2lMeKlOSi7jy69cDlsuC0jAeOwanGAPTtzghoFCGTuzJBG+UkE8U5BpFjaAAE84PJ Vd4Q== 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=gdVy1JGSBoZuqI274R7n9JIUIxcN1AY4e4E1RFGG9Dg=; b=Hk6ZtugQ6YqRhni9/FAKcY55rL40GVE4iPzSpKuJ1liqBHAEcjk7DdCPGXw8H8AB4S D1dkSmPI1RXOfVE27UsoSE7Piol3xCVtORNE5MwOVj4b12pQvFVzd0Jqo4WBpoHhVW4b /pTc/1PQIEXhmxRiKuASb78ufFrjZ+MaMywfkO/52OVrLxEEatO175Ss9f6U3DFcn0TQ iEnmnY0aBfZQKwVtdY0fb34x7y5hPSbo33giZjk1HVIOj7JQSupP9oF/kSBoEencgZAz xi9+L2X0yjAClamKPGW+Q2CvpzHNRVeODWo7ySz87JEz82JixWtMiFzBHB7RPdjV05L8 aS6A== X-Gm-Message-State: AOAM532lUP3LXnJLjwuoR3uey/KvrIHb/pxRC9oxXgt7vbdpCvHXsEaP 8c3l9cDAmtHweVxqLPOo4KtoFflxcBqtNbmd X-Google-Smtp-Source: ABdhPJw1iRaF7MviWJC5X3zG1neDuyXbBVqQEfM2Fan3gf0S2Tjw7tf9BdEw77gR9IMIPh8EXEjzmw== X-Received: by 2002:adf:ff88:: with SMTP id j8mr9367632wrr.427.1621604462401; Fri, 21 May 2021 06:41:02 -0700 (PDT) Received: from lmecxl0524.home (2a01cb058b850800205e07f10870202e.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:205e:7f1:870:202e]) by smtp.gmail.com with ESMTPSA id v3sm2161372wrr.19.2021.05.21.06.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 06:41:02 -0700 (PDT) From: Etienne Carriere To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Cristian Marussi , Vincent Guittot , Etienne Carriere , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v2 3/4] dt-bindings: arm: OP-TEE as transport channel for SCMI messages Date: Fri, 21 May 2021 15:40:53 +0200 Message-Id: <20210521134055.24271-3-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210521134055.24271-1-etienne.carriere@linaro.org> References: <20210521134055.24271-1-etienne.carriere@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_064104_232457_A994B970 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce compatible "linaro,scmi-optee" for SCMI transport channel based on an OP-TEE service invocation. Cc: Rob Herring Cc: devicetree@vger.kernel.org Signed-off-by: Etienne Carriere --- Changes since v1: - Removed modification regarding mboxes property description. --- Documentation/devicetree/bindings/arm/arm,scmi.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/arm,scmi.txt b/Documentation/devicetree/bindings/arm/arm,scmi.txt index 856d041b397e..ccab2ef6f6ec 100644 --- a/Documentation/devicetree/bindings/arm/arm,scmi.txt +++ b/Documentation/devicetree/bindings/arm/arm,scmi.txt @@ -14,7 +14,8 @@ Required properties: The scmi node with the following properties shall be under the /firmware/ node. -- compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports +- compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports, + or "linaro,scmi-optee" for OP-TEE transport. - mboxes: List of phandle and mailbox channel specifiers. When used, it should contain exactly one or two mailboxes, one for transmitting messages ("tx") and another optional for receiving the notifications("rx") if From patchwork Fri May 21 13:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 12273233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74E2BC433B4 for ; Fri, 21 May 2021 13:44:23 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D96AD61163 for ; Fri, 21 May 2021 13:44:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D96AD61163 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rWPlVVxAl1x8dYUk+vYA9eK6E5NeZVRqF9z5mOeqwSI=; b=D64Fs/PwxGxV8NBiWnxHniDFi3 eAIkYIlhzD36w7qjxkrlZp4pS6GvHW0ipStyuykjy2hzUNlMV3VUbVUAl+c9VkazsUKZb3IsJnt8h wkP/zKf3Nd4Z+RMhaw3ODDlE/frI1qMjRrX4d6FDnPWy0zGb/yqfiRVv2dLL4kpa+ns4jJWIXh/1O ANRfvyf+T3zdN7rJEnML6uV2q+P0ITOlG9fLYUiAye05YDO/hPgnpA8ujUDpKos7zmEb2wsQP53o9 jS91vx+CTFhw/8a1j4QtCYl3/DLqxcC3FCafuYCl8mHZecXUW1sInGeeSZhCiVwhzm+FJxtWiOj3I 0+K7Z9Ug==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5QM-005b37-Px; Fri, 21 May 2021 13:42:47 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk5Om-005Zx8-Rk for linux-arm-kernel@desiato.infradead.org; Fri, 21 May 2021 13:41:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2LTjcOxskARSOaZRb8ECEuyRgDRFo2qSGdcjAWiakTg=; b=eWm20wdTvJF2j97RWtqz9NS6KY sW5O2shQhfIhnNFa0YQie+JKGVgwKu9PQsSQu1D/23TgeR3DS1/7fkJJck4WhfXIEtU7xJMqJORse w59ic30ezqL7iM20MSbElyg5sCVjbh9RlUMglL4NsGE/JdShExTx37LkzIWMjYQCJXOgK/EVM2LgW iQprVM9DUdviGawaojAFHIjvKR/6MI6hcBYBIWgcBR3RrrrtRbaR+HK7IK+0JycrEtE5mFiMcuyqy g0VsUz72W0Dhn7iN981/cpPlvvlo0rEDf3VlTuxO/hkqP7ae9D3ZQIYemzPMrDZXN6VZiPcMFRq6X VfzgqRGw==; Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lk5Oi-00H9na-Aq for linux-arm-kernel@lists.infradead.org; Fri, 21 May 2021 13:41:07 +0000 Received: by mail-wm1-x32f.google.com with SMTP id l11-20020a05600c4f0bb029017a7cd488f5so4546788wmq.0 for ; Fri, 21 May 2021 06:41:04 -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=2LTjcOxskARSOaZRb8ECEuyRgDRFo2qSGdcjAWiakTg=; b=jlH0dmMtYUYIsBATSxxzRGbMexVO4xc55qZw+dhi74BXDRTuNZpcm+nvtnMxTwXY3q O8yNq5FbKlV3od/FnWlUpMVVE6dp80BCFoAuaQjO21dhJDeJdiXvO+4R/RaaROUu39+n X7eXds3vTH8Sk9SpR1LJ9QNj43zeWI+txFF4dIz7u+deRDYknG1HyqqItIPNwPwPh4CF QSD7nMPAwrvWeecF7jZtX4kjeG6XcUZjbAjl5qx2CKBC5G3l8v9ETKj7u+Vd/jsFbeCo pJk7J1QZBTC+2bKLvO807BEiioWVgB4Bm+gY1jdAy8NDapVWYtz+3v3JHs01a/CHIFbr 9Uzw== 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=2LTjcOxskARSOaZRb8ECEuyRgDRFo2qSGdcjAWiakTg=; b=pQ3WHfRyrdGQ2ph5zn9AyYuF7rk0EeDk3hrtYlfOKrFmk2UJPMJ9NksU6Q57l/cDC4 lVQIUETFrCYCHjLxe3yUSUFulDuXblIm/1BAwdSpTAjsvCbzFYj8rCpzZTrSeJeZ8+yL c5TJiUWjJFBqzj0wPAagoLQ+iQq987+cl+17Dg/4rjGq7U5UctGIf8ukH43w3nOjgIi8 84Rji1CdD7EU2mAc2y9ncYey19jmH8mxxFkV0CDj+Msu8cMWVnxMS91QULKDTnyCptRU LtvZ3YwogXvkPm1EYjw7DP08rpDT9ppiC32vrtMQtilJe9Yt+Ug01SnjvL59GRH7hncH 7TeA== X-Gm-Message-State: AOAM533f0tPlxhAtdFKgHUyT6U87wJjEcWDlCOyVawSeX/SPk70cy5LR pRzNvXg+cl6L0G70YbzRUTsxnA== X-Google-Smtp-Source: ABdhPJxd25GM+Dg/bP+Uqg5OvUnWKseempPmpbtVXmiGaQSByrBdMxs4YTgYoiEZPpqQzKW8TXKY3A== X-Received: by 2002:a7b:c85a:: with SMTP id c26mr9397055wml.131.1621604463085; Fri, 21 May 2021 06:41:03 -0700 (PDT) Received: from lmecxl0524.home (2a01cb058b850800205e07f10870202e.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:205e:7f1:870:202e]) by smtp.gmail.com with ESMTPSA id v3sm2161372wrr.19.2021.05.21.06.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 06:41:02 -0700 (PDT) From: Etienne Carriere To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Cristian Marussi , Vincent Guittot , Etienne Carriere Subject: [PATCH v2 4/4] firmware: arm_scmi: add optee transport Date: Fri, 21 May 2021 15:40:54 +0200 Message-Id: <20210521134055.24271-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210521134055.24271-1-etienne.carriere@linaro.org> References: <20210521134055.24271-1-etienne.carriere@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_064104_527940_E8CB84A7 X-CRM114-Status: GOOD ( 32.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new transport channel to the SCMI firmware interface driver for SCMI message exchange based on OP-TEE transport channel that leverage OP-TEE secure threaded context for processing of SCMI messages. The current proposal uses a statically defined physical memory area to be used as shared memory SCMI endpoints. The location is extracted from the FDT upon property "shmem". Entry in OP-TEE threaded context is realized by invoking a service PTA (Pseudo TA) in OP-TEE OS. Each invocation carries a agent numerical identifier for which a message is pending in the shared memory. The OP-TEE service provides means to get the agent identifier value for a given shared memory location. OPTEE transport driver depends on CONFIG_OPTEE and probes from SCMI compatible identifier "linaro,scmi-optee". Signed-off-by: Etienne Carriere --- No change since v1 --- drivers/firmware/Kconfig | 2 +- drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/common.h | 3 + drivers/firmware/arm_scmi/driver.c | 3 + drivers/firmware/arm_scmi/optee_service.c | 529 ++++++++++++++++++++++ 5 files changed, 537 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/arm_scmi/optee_service.c diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index a9c613c32282..7413e89e5628 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -9,7 +9,7 @@ menu "Firmware Drivers" config ARM_SCMI_PROTOCOL tristate "ARM System Control and Management Interface (SCMI) Message Protocol" depends on ARM || ARM64 || COMPILE_TEST - depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY + depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY || OPTEE help ARM System Control and Management Interface (SCMI) protocol is a set of operating system-independent software interfaces that are diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index 6a2ef63306d6..0e09d302a82e 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -4,6 +4,7 @@ scmi-driver-y = driver.o notify.o scmi-transport-y = shmem.o scmi-transport-$(CONFIG_MAILBOX) += mailbox.o scmi-transport-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smc.o +scmi-transport-$(CONFIG_OPTEE) += optee_service.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \ $(scmi-transport-y) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 8685619d38f9..a4db1a1a98e2 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -334,6 +334,9 @@ extern const struct scmi_desc scmi_mailbox_desc; #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY extern const struct scmi_desc scmi_smc_desc; #endif +#ifdef CONFIG_OPTEE +extern const struct scmi_desc scmi_optee_desc; +#endif void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr); void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 66eb3f0e5daf..501a9ec28791 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1570,6 +1570,9 @@ static const struct of_device_id scmi_of_match[] = { { .compatible = "arm,scmi", .data = &scmi_mailbox_desc }, #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc}, +#endif +#ifdef CONFIG_OPTEE + { .compatible = "linaro,scmi-optee", .data = &scmi_optee_desc }, #endif { /* Sentinel */ }, }; diff --git a/drivers/firmware/arm_scmi/optee_service.c b/drivers/firmware/arm_scmi/optee_service.c new file mode 100644 index 000000000000..de3432a4c179 --- /dev/null +++ b/drivers/firmware/arm_scmi/optee_service.c @@ -0,0 +1,529 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019-2021 Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +#define DRIVER_NAME "optee-scmi-agent" + +/* + * PTA_SCMI_CMD_CAPABILITIES - Get channel capabilities + * + * [out] value[0].a: Capability bit mask (PTA_SCMI_CAPS_*) + * [out] value[0].b: Extended capabilities or 0 + */ +#define PTA_SCMI_CMD_CAPABILITIES 0 + +/* + * PTA_SCMI_CMD_PROCESS_SMT_CHANNEL - Process SCMI message in SMT buffer + * + * [in] value[0].a: Channel handle + * + * Shared memory used for SCMI message/response exhange is expected + * already identified and bound to channel handle in both SCMI agent + * and SCMI server (OP-TEE) parts. + * The memory uses SMT header to carry SCMI meta-data (protocol ID and + * protocol message ID). + */ +#define PTA_SCMI_CMD_PROCESS_SMT_CHANNEL 1 + +/* + * PTA_SCMI_CMD_PROCESS_SMT_CHANNEL_MESSAGE - Process SMT/SCMI message + * + * [in] value[0].a: Channel handle + * [in/out] memref[1]: Message/response buffer (SMT and SCMI payload) + * + * Shared memory used for SCMI message/response is a SMT buffer + * referenced by param[1]. It shall be 128 bytes large to fit response + * payload whatever message playload size. + * The memory uses SMT header to carry SCMI meta-data (protocol ID and + * protocol message ID). + */ +#define PTA_SCMI_CMD_PROCESS_SMT_CHANNEL_MESSAGE 2 + +/* + * PTA_SCMI_CMD_GET_CHANNEL_HANDLE - Get handle for an SCMI channel + * + * Get a handle for the SCMI channel. This handle value is to be passed + * as argument to some commands as PTA_SCMI_CMD_PROCESS_*. + * + * [in] value[0].a: Channel identifier or 0 if no assigned ID + * [in] value[0].b: Requested capabilities mask (PTA_SCMI_CAPS_*) + * [out] value[0].a: Returned channel handle + */ +#define PTA_SCMI_CMD_GET_CHANNEL_HANDLE 3 + +/* + * Channel capabilities + */ + +/* Channel supports shared memory using the SMT header protocol */ +#define PTA_SCMI_CAPS_SMT_HEADER BIT(0) + +struct optee_scmi_channel { + /* Channel handle retrieved from OP-TEE */ + u32 channel_hdl; + /* Channel entry protection */ + struct mutex mu; + /* Channel private data */ + u32 tee_session; + struct optee_scmi_agent *agent; + struct scmi_chan_info *cinfo; + struct scmi_shared_mem __iomem *shmem; + /* Channel capabilities */ + u32 caps; + /* Reference in agent's channel list */ + struct list_head link; +}; + +/** + * struct optee_scmi_agent - OP-TEE transport private data + */ +struct optee_scmi_agent { + /* TEE context the agent operates with */ + struct device *dev; + struct tee_context *tee_ctx; + /* Supported channel capabilities (PTA_SCMI_CAPS_*) */ + u32 caps; + /* List all created channels */ + struct list_head channel_list; +}; + +/* There is only 1 SCMI PTA to connect to */ +static struct optee_scmi_agent *agent_private; + +static struct list_head optee_agent_list = LIST_HEAD_INIT(optee_agent_list); +static DEFINE_MUTEX(list_mutex); + +static int open_session(struct optee_scmi_agent *agent, u32 *tee_session) +{ + struct device *dev = agent->dev; + struct tee_client_device *scmi_pta = to_tee_client_device(dev); + struct tee_ioctl_open_session_arg sess_arg; + int ret; + + memset(&sess_arg, 0, sizeof(sess_arg)); + + /* Open a session toward SCMI PTA with REE_KERNEL identity */ + memcpy(sess_arg.uuid, scmi_pta->id.uuid.b, TEE_IOCTL_UUID_LEN); + sess_arg.clnt_login = TEE_IOCTL_LOGIN_REE_KERNEL; + + ret = tee_client_open_session(agent->tee_ctx, &sess_arg, NULL); + if ((ret < 0) || (sess_arg.ret != 0)) { + dev_err(dev, "tee_client_open_session failed, err: %x\n", + sess_arg.ret); + return -EINVAL; + } + + *tee_session = sess_arg.session; + + return 0; +} + +static void close_session(struct optee_scmi_agent *agent, u32 tee_session) +{ + tee_client_close_session(agent->tee_ctx, tee_session); +} + +static int get_capabilities(struct optee_scmi_agent *agent) +{ + int ret; + struct tee_ioctl_invoke_arg inv_arg; + struct tee_param param[1]; + u32 tee_session; + + ret = open_session(agent, &tee_session); + if (ret) + return ret; + + memset(&inv_arg, 0, sizeof(inv_arg)); + memset(¶m, 0, sizeof(param)); + + inv_arg.func = PTA_SCMI_CMD_CAPABILITIES; + inv_arg.session = tee_session; + inv_arg.num_params = 1; + + param[0].attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT; + + ret = tee_client_invoke_func(agent->tee_ctx, &inv_arg, param); + + close_session(agent, tee_session); + + if ((ret < 0) || (inv_arg.ret != 0)) { + dev_err(agent->dev, "Can't get capabilities: %d / %#x\n", + ret, inv_arg.ret); + + return -EOPNOTSUPP; + } + + agent->caps = param[0].u.value.a; + + if (!(agent->caps & PTA_SCMI_CAPS_SMT_HEADER)) { + dev_err(agent->dev, "OP-TEE SCMI PTA doesn't support SMT\n"); + + return -ENODEV; + } + + return 0; +} + +static int get_channel(struct optee_scmi_channel *channel) +{ + struct device *dev = channel->agent->dev; + int ret; + struct tee_ioctl_invoke_arg inv_arg; + struct tee_param param[1]; + unsigned int caps; + + caps = PTA_SCMI_CAPS_SMT_HEADER; + + memset(&inv_arg, 0, sizeof(inv_arg)); + memset(¶m, 0, sizeof(param)); + + inv_arg.func = PTA_SCMI_CMD_GET_CHANNEL_HANDLE; + inv_arg.session = channel->tee_session; + inv_arg.num_params = 1; + + param[0].attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT; + param[0].u.value.a = 0; + param[0].u.value.b = caps; + + ret = tee_client_invoke_func(channel->agent->tee_ctx, &inv_arg, param); + + if (ret || inv_arg.ret) { + dev_err(dev, "Can't get channel with caps %#x: ret=%d, tee-res=%#x\n", + caps, ret, inv_arg.ret); + + return -EOPNOTSUPP; + } + + /* Only channel handler is used, can discard old channel ID value */ + channel->channel_hdl = param[0].u.value.a; + channel->caps = caps; + + return 0; +} + +/* Invocation of the PTA through a regular command invoke */ +static int invoke_process_smt_channel(struct optee_scmi_channel *channel) +{ + int ret; + struct tee_ioctl_invoke_arg inv_arg; + struct tee_param param[1]; + + if (!(channel->caps & PTA_SCMI_CAPS_SMT_HEADER)) + return -EINVAL; + + memset(&inv_arg, 0, sizeof(inv_arg)); + memset(¶m, 0, sizeof(param)); + + inv_arg.func = PTA_SCMI_CMD_PROCESS_SMT_CHANNEL; + inv_arg.session = channel->tee_session; + inv_arg.num_params = 1; + + param[0].attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT; + param[0].u.value.a = channel->channel_hdl; + + ret = tee_client_invoke_func(channel->agent->tee_ctx, &inv_arg, param); + if (ret < 0 || inv_arg.ret) { + dev_err(channel->agent->dev, "Failed on channel handle %u: 0x%x\n", + channel->channel_hdl, inv_arg.ret); + return -EIO; + } + + return 0; +} + +static bool optee_chan_available(struct device *dev, int idx) +{ + struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0); + + if (!np) + return false; + + of_node_put(np); + + return true; +} + +static int optee_chan_setup_shmem(struct scmi_chan_info *cinfo, bool tx, + struct optee_scmi_channel *channel) +{ + struct device *cdev = cinfo->dev; + struct device_node *np; + resource_size_t size; + struct resource res; + int ret; + + np = of_parse_phandle(cdev->of_node, "shmem", 0); + ret = of_address_to_resource(np, 0, &res); + of_node_put(np); + if (ret) { + dev_err(cdev, "failed to get SCMI Tx shared memory\n"); + return ret; + } + + size = resource_size(&res); + + channel->shmem = devm_ioremap(cdev, res.start, size); + if (!channel->shmem) { + dev_err(cdev, "failed to ioremap SCMI Tx shared memory\n"); + return -EADDRNOTAVAIL; + } + + return 0; +} + +static void optee_clear_channel(struct scmi_chan_info *cinfo) +{ + struct optee_scmi_channel *channel = cinfo->transport_info; + + shmem_clear_channel(channel->shmem); +} + +static int optee_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, + bool tx) +{ + struct device *cdev = cinfo->dev; + struct optee_scmi_channel *channel; + int ret, idx = tx ? 0 : 1; + + /* Shall wait for OP-TEE driver to be up and ready */ + if (!agent_private || !agent_private->tee_ctx) + return -EPROBE_DEFER; + + channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL); + if (!channel) + return -ENOMEM; + + ret = optee_chan_setup_shmem(cinfo, tx, channel); + if (ret) + return ret; + + cinfo->transport_info = channel; + channel->cinfo = cinfo; + channel->agent = agent_private; + + ret = open_session(channel->agent, &channel->tee_session); + if (ret) + return ret; + + ret = get_channel(channel); + if (ret) + goto err; + + mutex_init(&channel->mu); + + mutex_lock(&list_mutex); + list_add(&channel->link, &channel->agent->channel_list); + mutex_unlock(&list_mutex); + + return 0; + +err: + close_session(channel->agent, channel->tee_session); + channel->tee_session = 0; + + return ret; +} + +static int optee_chan_free(int id, void *p, void *data) +{ + struct scmi_chan_info *cinfo = p; + struct optee_scmi_channel *channel = cinfo->transport_info; + + mutex_lock(&list_mutex); + list_del(&channel->link); + mutex_unlock(&list_mutex); + + cinfo->transport_info = NULL; + channel->cinfo = NULL; + + scmi_free_channel(cinfo, data, id); + + return 0; +} + +static struct scmi_shared_mem *get_channel_shm(struct optee_scmi_channel *chan, + struct scmi_xfer *xfer) +{ + if (!chan) + return NULL; + + return chan->shmem; +} + +static int optee_send_message(struct scmi_chan_info *cinfo, + struct scmi_xfer *xfer) +{ + struct optee_scmi_channel *channel = cinfo->transport_info; + struct scmi_shared_mem *shmem; + int ret = 0; + + if (!channel && !channel->agent && !channel->agent->tee_ctx) + return -ENODEV; + + shmem = get_channel_shm(channel, xfer); + + mutex_lock(&channel->mu); + shmem_tx_prepare(shmem, xfer); + + ret = invoke_process_smt_channel(channel); + + scmi_rx_callback(cinfo, shmem_read_header(shmem)); + mutex_unlock(&channel->mu); + + return ret; +} + +static void optee_fetch_response(struct scmi_chan_info *cinfo, + struct scmi_xfer *xfer) +{ + struct optee_scmi_channel *channel = cinfo->transport_info; + struct scmi_shared_mem *shmem = get_channel_shm(channel, xfer); + + shmem_fetch_response(shmem, xfer); +} + +static bool optee_poll_done(struct scmi_chan_info *cinfo, + struct scmi_xfer *xfer) +{ + struct optee_scmi_channel *channel = cinfo->transport_info; + struct scmi_shared_mem *shmem = get_channel_shm(channel, xfer); + + return shmem_poll_done(shmem, xfer); +} + +static struct scmi_transport_ops scmi_optee_ops = { + .chan_available = optee_chan_available, + .chan_setup = optee_chan_setup, + .chan_free = optee_chan_free, + .send_message = optee_send_message, + .fetch_response = optee_fetch_response, + .clear_channel = optee_clear_channel, + .poll_done = optee_poll_done, +}; + +const struct scmi_desc scmi_optee_desc = { + .ops = &scmi_optee_ops, + .max_rx_timeout_ms = 30, /* We may increase this if required */ + .max_msg = 8, + .max_msg_size = 128, +}; + +static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data) +{ + return ver->impl_id == TEE_IMPL_ID_OPTEE; +} + +static int optee_scmi_probe(struct device *dev) +{ + struct optee_scmi_agent *agent; + struct tee_context *tee_ctx; + int ret; + + tee_ctx = tee_client_open_context(NULL, optee_ctx_match, NULL, NULL); + if (IS_ERR(tee_ctx)) + return -ENODEV; + + agent = devm_kzalloc(dev, sizeof(*agent), GFP_KERNEL); + if (!agent) { + ret = -ENOMEM; + goto err; + } + + agent->dev = dev; + agent->tee_ctx = tee_ctx; + + ret = get_capabilities(agent); + if (ret) + goto err; + + /* We currently support only 1 OP-TEE device */ + if (WARN_ON(agent_private)) { + ret = -EINVAL; + goto err; + } + agent_private = agent; + + INIT_LIST_HEAD(&agent->channel_list); + + dev_dbg(dev, "OP-TEE SCMI channel probed\n"); + + return 0; + +err: + tee_client_close_context(tee_ctx); + return ret; +} + +static int optee_scmi_remove(struct device *dev) +{ + struct optee_scmi_channel *channel; + struct list_head *elt, *n; + + mutex_lock(&list_mutex); + list_for_each_safe(elt, n, &agent_private->channel_list) { + channel = list_entry(elt, struct optee_scmi_channel, link); + list_del(&channel->link); + } + mutex_unlock(&list_mutex); + + tee_client_close_context(agent_private->tee_ctx); + + agent_private = NULL; + + return 0; +} + +static const struct tee_client_device_id optee_scmi_id_table[] = { + { + UUID_INIT(0xa8cfe406, 0xd4f5, 0x4a2e, + 0x9f, 0x8d, 0xa2, 0x5d, 0xc7, 0x54, 0xc0, 0x99) + }, + { } +}; + +MODULE_DEVICE_TABLE(tee, optee_scmi_id_table); + +static struct tee_client_driver optee_scmi_driver = { + .id_table = optee_scmi_id_table, + .driver = { + .name = DRIVER_NAME, + .bus = &tee_bus_type, + .probe = optee_scmi_probe, + .remove = optee_scmi_remove, + }, +}; + +static int __init optee_scmi_init(void) +{ + return driver_register(&optee_scmi_driver.driver); +} + +static void __exit optee_scmi_exit(void) +{ + driver_unregister(&optee_scmi_driver.driver); +} + +module_init(optee_scmi_init); +module_exit(optee_scmi_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Etienne Carriere "); +MODULE_DESCRIPTION("OP-TEE SCMI transport driver");