From patchwork Tue Sep 26 06:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 726380 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp2779903wrm; Mon, 25 Sep 2023 23:58:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaNXCg0kkxn7CECvagUvYQAUTRZ04Prx+JEB9Mx3Dr54Cgutu4TTwIsOZPxt3DwgjDBOsH X-Received: by 2002:a1c:7710:0:b0:3fe:1f93:8cf4 with SMTP id t16-20020a1c7710000000b003fe1f938cf4mr8119573wmi.8.1695711509385; Mon, 25 Sep 2023 23:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695711509; cv=none; d=google.com; s=arc-20160816; b=g0rVfN09cwAiIB2F8Az0oZ8uS/6aZAgW+74xYkSNrsTD2VXo3wIMZpUbSHSqrRqu91 +nSE3B5UmrEY0hV0cwD8Vee//Mf+CbynD/otDgM3wA0d2FKFyCas/rkFei3hb3ry1Eif k4XRmvR5AasCXc9KA8lypXs4Z60ZT+vYQFWAxoDYC0A+75hhDYwCahkG4cEEhXRLfGCB f/nqO3IOtISR9J7pLiWkqzZGsV6K4I1gQ9OBFLLHBRPTgj1hsBemH9ecvrg5qrISzPrS t5fKPqiJbUlJKgQIj7aRm6q/b7ZUzqy/CLFTRwiUgLM7Y0Ckhb6M3q49fbJvRDlCx7Oa H/+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5WXeaDc5fixDobj9hHcc7iI7eRYEh2B18lEtPO1VmOU=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=a0UsAXqmcBSGr/cYxpZ3UrziYbzDsrPt3zU02YAJnrZBoTlZHl/MpYUc/AVj+siCl/ sF3pe5V9/Oae+ZyAElSY13nZk5lvPwR1VbRyNnIGeFYZvrg9S9GKb87XuYXFrpodWOZD XcjfnyRmRmDwck7J4UCRylkmlRIsstYqOAezwvbogRA7Px5KOtxp7j85qc5XIKhrQ2aa Jd8MkEpTT0vSt7UoElgeiww5oqcITQtAmbqt8pq5ZJ5sMo1wBzlD3ohvf/vF9JzMIPnP hmKxemn7nnJW6ApaU3YI4kdgwbg1YpY133lq4Fg6w7J1zSsuNNcpaA2N8T50eG3bZIwZ aTXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kbiyq2+b; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id iv13-20020a05600c548d00b00402fe7642f4si6496093wmb.223.2023.09.25.23.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kbiyq2+b; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E31B686C32; Tue, 26 Sep 2023 08:58:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Kbiyq2+b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2790286C32; Tue, 26 Sep 2023 08:58:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D257B86B95 for ; Tue, 26 Sep 2023 08:58:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-690d935dbc2so1879797b3a.1 for ; Mon, 25 Sep 2023 23:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695711494; x=1696316294; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5WXeaDc5fixDobj9hHcc7iI7eRYEh2B18lEtPO1VmOU=; b=Kbiyq2+by/O7XdDhen/Gs1UdMQNFOKLTIiKFSa6oBSmXIG0yTVThYAbLbcpxz30ZH5 LaEMaAZe8huN8xTi2rIVUvLv1e19ULroMWQ9XylvJSkWQFNh97jr0Gp0Xop4xmyaK5o2 YWHcN3YHrfg9HjlxyKU8vuo6x6HjczJu8G/9L82ZMEiNPxyTpnJdOzNz7oTmG6bCL3GV wUSYuHt+Pjx+U4Poq5xloA2QOe/OevV7lCK/3a3aKFsLY/YsxdB/SdnJucNFYFP6McEg N3SxEqGjlxnZU53X9wrcQZ13s/nfhME15CoHgl9RKaqC0o3g3FNBe0rvm+Rt1BBEThd2 6Rng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695711494; x=1696316294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5WXeaDc5fixDobj9hHcc7iI7eRYEh2B18lEtPO1VmOU=; b=KwEmvLUbVoq/S5Ldci6nX7CIQS7/MceqXYy3ltZOMuv7Z5d5e0LXeaT6jgS6Vab0pv GPZN4PtVX86VOZCB6CocPWCQaVOBYty2vmmup38s49QoX+gIfhxC1ZrSFpMztKZewU6l IlrchSPBcQmWd74XEgD5xxbW5yWmI5gKOffbVp44yFwZ45LJsZtA8rwEpEavgq+gVfmv SB0jlZWT9RUk4H3I65cODqStZ9O0DCNjaKfa3JG8wsP28yNxa9Dfi94gEsTrI9aas8B0 Qa247bq/72Vv7zScrKIeBAVJ83vhv38/j6KW2WSQQEJzNmtuJ45spvRTA7+ATEIDDlFn RRbA== X-Gm-Message-State: AOJu0YzcLxK6kJ6AfeHJc4COqwr4RJJscVqQY0uxbXOjBebeEAxvtmVk VrCvYTeeFr7peAyLyj7UULxKwg== X-Received: by 2002:a05:6a21:6d86:b0:15d:6fd3:8e74 with SMTP id wl6-20020a056a216d8600b0015d6fd38e74mr11942934pzb.3.1695711494049; Mon, 25 Sep 2023 23:58:14 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:6585:aea6:5002:a825]) by smtp.gmail.com with ESMTPSA id s2-20020a639242000000b0057825bd3448sm8758874pgn.51.2023.09.25.23.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:58:13 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v5 02/16] firmware: scmi: use a protocol's own channel if assigned Date: Tue, 26 Sep 2023 15:57:36 +0900 Message-Id: <20230926065750.734440-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926065750.734440-1-takahiro.akashi@linaro.org> References: <20230926065750.734440-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean SCMI specification allows any protocol to have its own channel for the transport. While the current SCMI driver may assign its channel from a device tree, the core function, devm_scmi_process_msg(), doesn't use a protocol's channel, but always use an agent's channel. With this commit, devm_scmi_process_msg() tries to find and use a protocol's channel. If it doesn't exist, use an agent's. Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere --- v5 * new commit (fixing a potential bug) --- drivers/firmware/scmi/mailbox_agent.c | 5 +++-- drivers/firmware/scmi/optee_agent.c | 5 +++-- drivers/firmware/scmi/scmi_agent-uclass.c | 7 ++++--- drivers/firmware/scmi/smccc_agent.c | 5 +++-- include/scmi_agent-uclass.h | 8 +++++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/scmi/mailbox_agent.c b/drivers/firmware/scmi/mailbox_agent.c index 8277c1860606..7ad3e8da9f08 100644 --- a/drivers/firmware/scmi/mailbox_agent.c +++ b/drivers/firmware/scmi/mailbox_agent.c @@ -94,13 +94,14 @@ static int setup_channel(struct udevice *dev, struct scmi_mbox_channel *chan) } static int scmi_mbox_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_mbox_channel *base_chan = dev_get_plat(dev); struct scmi_mbox_channel *chan; int ret; - if (!dev_read_prop(dev, "shmem", NULL)) { + if (!dev_read_prop(protocol, "shmem", NULL)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -112,7 +113,7 @@ static int scmi_mbox_get_channel(struct udevice *dev, return -ENOMEM; /* Setup a dedicated channel for the protocol */ - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/drivers/firmware/scmi/optee_agent.c b/drivers/firmware/scmi/optee_agent.c index db927fb21405..e3e462774045 100644 --- a/drivers/firmware/scmi/optee_agent.c +++ b/drivers/firmware/scmi/optee_agent.c @@ -324,6 +324,7 @@ static int setup_channel(struct udevice *dev, struct scmi_optee_channel *chan) } static int scmi_optee_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_optee_channel *base_chan = dev_get_plat(dev); @@ -331,7 +332,7 @@ static int scmi_optee_get_channel(struct udevice *dev, u32 channel_id; int ret; - if (dev_read_u32(dev, "linaro,optee-channel-id", &channel_id)) { + if (dev_read_u32(protocol, "linaro,optee-channel-id", &channel_id)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -343,7 +344,7 @@ static int scmi_optee_get_channel(struct udevice *dev, if (!chan) return -ENOMEM; - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index ec58ccd2bc5d..a28692f39f4d 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -144,13 +144,14 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) * On return, @channel will be set. * Return 0 on success and a negative errno on failure */ -static int scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) +static int scmi_of_get_channel(struct udevice *dev, struct udevice *protocol, + struct scmi_channel **channel) { const struct scmi_agent_ops *ops; ops = transport_dev_ops(dev); if (ops->of_get_channel) - return ops->of_get_channel(dev, channel); + return ops->of_get_channel(dev, protocol, channel); else return -EPROTONOSUPPORT; } @@ -166,7 +167,7 @@ int devm_scmi_of_get_channel(struct udevice *dev) return -ENODEV; priv = dev_get_parent_priv(protocol); - ret = scmi_of_get_channel(protocol->parent, &priv->channel); + ret = scmi_of_get_channel(protocol->parent, protocol, &priv->channel); if (ret == -EPROTONOSUPPORT) { /* Drivers without a get_channel operator don't need a channel ref */ priv->channel = NULL; diff --git a/drivers/firmware/scmi/smccc_agent.c b/drivers/firmware/scmi/smccc_agent.c index 6a52cd75d67b..972c6addde21 100644 --- a/drivers/firmware/scmi/smccc_agent.c +++ b/drivers/firmware/scmi/smccc_agent.c @@ -81,6 +81,7 @@ static int setup_channel(struct udevice *dev, struct scmi_smccc_channel *chan) } static int scmi_smccc_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_smccc_channel *base_chan = dev_get_plat(dev); @@ -88,7 +89,7 @@ static int scmi_smccc_get_channel(struct udevice *dev, u32 func_id; int ret; - if (dev_read_u32(dev, "arm,smc-id", &func_id)) { + if (dev_read_u32(protocol, "arm,smc-id", &func_id)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -100,7 +101,7 @@ static int scmi_smccc_get_channel(struct udevice *dev, if (!chan) return -ENOMEM; - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index b1c93532c0ea..eee46c880a56 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -16,16 +16,18 @@ struct scmi_agent_ops { /* * of_get_channel - Get SCMI channel from SCMI agent device tree node * - * @dev: SCMI protocol device using the transport + * @dev: SCMI agent device using the transport + * @protocol: SCMI protocol device using the transport * @channel: Output reference to SCMI channel upon success * Return 0 upon success and a negative errno on failure */ - int (*of_get_channel)(struct udevice *dev, struct scmi_channel **channel); + int (*of_get_channel)(struct udevice *dev, struct udevice *protocol, + struct scmi_channel **channel); /* * process_msg - Request transport to get the SCMI message processed * - * @dev: SCMI protocol device using the transport + * @dev: SCMI agent device using the transport * @msg: SCMI message to be transmitted */ int (*process_msg)(struct udevice *dev, struct scmi_channel *channel,