From patchwork Wed Oct 11 10:06:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731919 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315437wrv; Wed, 11 Oct 2023 03:08:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBsyEaqoZ0Zo/yH7iq6GouNcv0Z2DiAlWcuftoMtcPIK+AQTwdR3woMiS2Ob6zgfvdrJ78 X-Received: by 2002:a7b:cd85:0:b0:404:7670:90b8 with SMTP id y5-20020a7bcd85000000b00404767090b8mr19144052wmj.27.1697018895074; Wed, 11 Oct 2023 03:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018895; cv=none; d=google.com; s=arc-20160816; b=m1ugD+vO/0A9QSZ5huLW17hDd6gpMIraTlytIDI9lYWpN+u8Oyl8CkveRZQdNpCOPB TI6nxopS9pGCq2IGCunCSI9m4Jl2b/FroUMuPEM89Aorg35lSH2XCbvv4vL6fXVSTO+h NcSw8oblyd1woWQiZlL+/G1Nel0mCvHMoy1y8u7T+7ZBYqzS0QAqSRgC/keKR2t4e5yc u39SjN5hV0dDiWJNfIEv8bjsr+0bKCp2CAUsos7ouIGShfW59D5uC7M5h80yWv7JvFQY FgmLiM9J0m/1pCGcL9KSSrtUtQAJ8/sPwO0QRl+Hk6a6bWQfdFB5zR9Zr248Xu8vcjEE yuPg== 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=XMyS9Mv1/6J9CH/5Zv0yLlNhoVLQLPUWRVvbnhVVa8VzBwL+XjZzvwwi0M/Cafeone J0vYljvf1wFL0X3T7lw5rK27IwUyMJHJ4DInySbUKE48NyL5hMFObVf+o5n1r1S/eVmb lazztM6OlPNhD9NKUomSqVXQvmcAFM4x2ql4IHXOHCXCLwvKgO1bRynZkZNDk3YQjjWt tTPMnmm1MmkMYqZHGSLMarTqVMuiOwFVRh6c5ic17stQeBsIx+rciLAiuXue/IGMJbQ2 DIanZ0sNjFAQpV581Z6oiy2oAwr29xY3Gp8iVndx6EXlQAzyza9jw162eCq7Z/2vkGtI arQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pjq50QDA; 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 p7-20020a05600c2e8700b00401fbd5c687si7367252wmn.206.2023.10.11.03.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:08:15 -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=Pjq50QDA; 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 CF51F86D3D; Wed, 11 Oct 2023 12:07:43 +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="Pjq50QDA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F7BD80834; Wed, 11 Oct 2023 12:07:42 +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-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 BF55F86CFD for ; Wed, 11 Oct 2023 12:07:30 +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-oo1-xc2d.google.com with SMTP id 006d021491bc7-57bf04841ccso1417466eaf.0 for ; Wed, 11 Oct 2023 03:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018849; x=1697623649; 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; b=Pjq50QDAXcu9bsk1NPSEvC6N0Jydr9C55BFhNAHXEM0nAkcFvf2z3o1NvA555Xqji/ XvWkkwAYGEVzcDgNxcNwYT8hgV78kAmS9Qq85ZGGYw2wvHpTDm99H+ErYHAPR+Vpzxrt n+OYiOCdYFSor/bOLXenU+jDWniTPV773cTtI7WW4joSEAXwX5PjrKHTDqtyNYS1xk+y NfZ8UXyEfjXEOPrpYmtyNWO40PyVwBhUxZDw6xNc1QpJyKcoSn4I78AVbqwPu7s7FIGC PsiLgDaemxAGss0F4l7d9neQTeAi5jBVlwvn6EDo+Lm/kAz9gttYkna0B7/eBzsxOxLx 8ttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018849; x=1697623649; 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; b=cxqzr1oI4eWKVxIBNhhK/gqROuftOujatWoQ497nTbFtPevPDLitZ/1KPmTx1tEcMP YP4yb1/yerPY2b7swThtMVhMzcck12af9q+iWw+RFu+rXRixBkibEmhT0Y8geq7xXIc7 uw/evRH/URG96ZOhWKGRns766ANgUtfliihPteh/Upk60NBGQoxVvxO5NjHy5jzqY5oX 7m77mNTdZ90SOeWRBoAP7WIcYSH0VwhROQqIfFsXbOL1GPWlxQm/Dr84t08CXXHJyf9d fQxEIl2YEJWINmlmyRJuAr0VWuzGCE4RLPtmfzaz6+B+jIr0N+0M8kH0hJhNKKNwIZFt lyJQ== X-Gm-Message-State: AOJu0YzTOYQM2QIuwinnahH0ELawSOx7r8PvoxXguJMob7PXs/8H5utw 3EWnZAxS7gGmJ17ZB6HXSzvdZYx4sJRflQSFLYl2VQ== X-Received: by 2002:a05:6359:203:b0:15b:73a6:3ce8 with SMTP id ej3-20020a056359020300b0015b73a63ce8mr18098753rwb.2.1697018848911; Wed, 11 Oct 2023 03:07:28 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:28 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 02/14] firmware: scmi: use a protocol's own channel if assigned Date: Wed, 11 Oct 2023 19:06:55 +0900 Message-Id: <20231011100707.1007417-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Reviewed-by: Simon Glass --- 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,