From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 752B3EB64DC for ; Mon, 10 Jul 2023 02:04:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD73384667; Mon, 10 Jul 2023 04:04:21 +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="bAyTe3jp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DFEDF85F9F; Mon, 10 Jul 2023 04:04:20 +0200 (CEST) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 1595E800D2 for ; Mon, 10 Jul 2023 04:04: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=takahiro.akashi@linaro.org Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-780c89d1998so36946339f.1 for ; Sun, 09 Jul 2023 19:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688954656; x=1691546656; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=Zaxk+12zVlTu6TX9CG9uZwKHCya1cpjDcK/DmtOcp/g=; b=bAyTe3jpI4yMRkLOfpxkyMEe6kmrQoNIhEd83GRM53g86mwdU5d/mDPmo3WptEQ5xF O7mzZt+2fcO89sT3v7HG+TKLxqkcl70bCoz9o7VpPZ4u74IbVLuCzzWxwPn6B1Fqo9gC O9KDGAW/OqESbhmOa2t2vVC75ETEELYeyb16WDCovEJkspO2jZqp7UEjisHSytX8J36G N74+OucDf9l/zwEwbruQLXkBW8PdeT8rLxa96GaVhVM5zHiy/5moenN4vVnYZ5rkQK+2 nQEmgRMRq/EVy5x9wr3uu5hc1CVDxo2Y/ZGo81c7Cq85t1Zu0zTJkFSsiEEGdNTnjFs4 HZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688954656; x=1691546656; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zaxk+12zVlTu6TX9CG9uZwKHCya1cpjDcK/DmtOcp/g=; b=Kf8zOO6uQtCpwqf/embSIZFJPqh0nH+DHi6uljjBGjUd7js1zWU3UoEslj1kN4urQV Li/5ZxHoseqsKfVO/qMQxAjXUR8Yg+smhZ4RSXQyN3zJrIpTOp7yohDVLi64BfExD8JD SQSQAIwqvoLdH0KCt00Y7bGOUEZVBqY6mqybVoFOLmd1HXhbsB5qZ8M2Rh8+VwGQyeBd 9+4qJpRAy5yqErClbde/UMpMXtmGEdK9kqYl8sEuVf0xeQ4L0vgKwQB1r3LjP/HZn+NB El6UTf15hgxkXicY/prCzekO/xYOJuS09TQTIHzNaze82T1lGdevqPcYRkcAwuIDehM2 laAg== X-Gm-Message-State: ABy/qLZhIiWmSI/HNt+QLfrY6jVla95WWNzMEn0FRsx9inWGacydeF5h p8TkyoFa5RS0+BEv0NvUCDX6rQ== X-Google-Smtp-Source: APBJJlHEzGoxZTD6FU7VbrCC3I+RrDatv/9CajYEuZuRqsqI8R3l1UZV5ZrDfAqNHG0vHtoFZ7kzSQ== X-Received: by 2002:a05:6e02:c70:b0:345:cee8:da2f with SMTP id f16-20020a056e020c7000b00345cee8da2fmr9883983ilj.0.1688954656575; Sun, 09 Jul 2023 19:04:16 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:dcbb:ee54:813e:ed94]) by smtp.gmail.com with ESMTPSA id o19-20020a637e53000000b0051b8172fa68sm6265176pgn.38.2023.07.09.19.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 19:04:16 -0700 (PDT) Date: Mon, 10 Jul 2023 11:04:12 +0900 From: AKASHI Takahiro To: Simon Glass Cc: trini@konsulko.com, etienne.carriere@st.com, u-boot@lists.denx.de Subject: Re: [PATCH 07/10] test: dm: add SCMI base protocol test Message-ID: Mail-Followup-To: AKASHI Takahiro , Simon Glass , trini@konsulko.com, etienne.carriere@st.com, u-boot@lists.denx.de References: <20230628004841.21774-1-takahiro.akashi@linaro.org> <20230628004841.21774-8-takahiro.akashi@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Fri, Jul 07, 2023 at 11:35:49AM -0600, Simon Glass wrote: > Hi, > > On Tue, 4 Jul 2023 at 03:35, AKASHI Takahiro wrote: > > > > Hi Simon, > > > > On Mon, Jul 03, 2023 at 02:30:57PM +0100, Simon Glass wrote: > > > Hi, > > > > > > On Mon, 3 Jul 2023 at 01:57, AKASHI Takahiro wrote: > > > > > > > > On Thu, Jun 29, 2023 at 08:09:58PM +0100, Simon Glass wrote: > > > > > Hi AKASHI, > > > > > > > > > > On Wed, 28 Jun 2023 at 01:49, AKASHI Takahiro > > > > > wrote: > > > > > > > > > > > > Added is a new unit test for SCMI base protocol, which will exercise all > > > > > > the commands provided by the protocol, except SCMI_BASE_NOTIFY_ERRORS. > > > > > > $ ut dm scmi_base > > > > > > It is assumed that test.dtb is used as sandbox's device tree. > > > > > > > > > > > > Signed-off-by: AKASHI Takahiro > > > > > > --- > > > > > > test/dm/scmi.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > 1 file changed, 112 insertions(+) > > > > > > > > > > > > diff --git a/test/dm/scmi.c b/test/dm/scmi.c > > > > > > index 881be3171b7c..563017bb63e0 100644 > > > > > > --- a/test/dm/scmi.c > > > > > > +++ b/test/dm/scmi.c > > > > > > @@ -16,6 +16,9 @@ > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > +#include > > > > > > +#include > > > > > > +#include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > @@ -95,6 +98,115 @@ static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts) > > > > > > } > > > > > > DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT); > > > > > > > > > > > > +static int dm_test_scmi_base(struct unit_test_state *uts) > > > > > > +{ > > > > > > + struct udevice *agent_dev, *base; > > > > > > + struct scmi_agent_priv *priv; > > > > > > + const struct scmi_base_ops *ops; > > > > > > + u32 version, num_agents, num_protocols, impl_version; > > > > > > + u32 attributes, agent_id; > > > > > > + char vendor[SCMI_BASE_NAME_LENGTH_MAX], > > > > > > + agent_name[SCMI_BASE_NAME_LENGTH_MAX]; > > > > > > + u8 *protocols; > > > > > > + int ret; > > > > > > + > > > > > > + /* preparation */ > > > > > > + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", > > > > > > + &agent_dev)); > > > > > > + ut_assertnonnull(agent_dev); > > > > > > + ut_assertnonnull(priv = dev_get_uclass_plat(agent_dev)); > > > > > > + ut_assertnonnull(base = scmi_get_protocol(agent_dev, > > > > > > + SCMI_PROTOCOL_ID_BASE)); > > > > > > + ut_assertnonnull(ops = dev_get_driver_ops(base)); > > > > > > + > > > > > > + /* version */ > > > > > > + ret = (*ops->protocol_version)(base, &version); > > > > > > > > > > Can you add uclass helpers to call each of the methods? That is how it > > > > > is commonly done. You should not be calling ops->xxx directly here. > > > > > > > > Yes, I will add inline functions instead. > > > > > > I don't mean inline...see all the other uclasses which define a > > > > Okay, I will *real* functions. > > > > > function which is implemented in the uclass. It is confusing when one > > > uclass does something different. People might copy this style and then > > > the code base diverges. Did you not notice this when looking around > > > the source tree? > > > > But one concern came up in my mind. > > Contrary to ordinary "device controllers", there exists only a single > > implementation of driver for each of "udevice"'s associated with SCMI > > protocols including the base protocol. > > > > So if I follow your suggestion, the code (base.c) might look like: > > === > > static int __scmi_base_discover_vendor(struct udevice *dev, u8 *vendor) > > { > > ... > > } > > > > struct scmi_base_ops scmi_base_ops = { > > > > .base_discover_vendor = __scmi_base_discover_vendor, > > > > } > > > > int scmi_base_discover_vendor(struct udevice *dev, u8 *vendor) > > { > > struct scmi_base_ops *ops; > > > > ops = scmi_base_dev_ops(dev); > > > > return ops->base_discover_vendor(dev, vendor); > > } > > === > > > > We will have to have similar definitions for every operation in ops. > > It looks quite weird to me as there are always pairs of functions, > > like __scmi_base_discover_vendor() and scmi_base_discover_vendor(). > > Yes I understand that you only have one driver at present. Is there > not a sandbox driver? No. Please remember that SCMI protocol drivers on U-Boot are nothing but stubs that makes a call to SCMI servers, supporting common communication channel interfaces for different transports (either OP-TEE, SMCCC or mailbox). Sandbox driver, if is properly named, is also implemented as a sort of transport layer, where a invocation is replaced with a function call which mimicks one of specific commands in SCMI protocol on behalf of a real SCMI server. In this sense, there will exist only a single driver under the current form of framework forever. > > > > > We can avoid this redundant code easily by eliminating "ops" abstraction. > > But as far as I remember, you insist that every driver that complies > > to U-Boot driver model should have a "ops". > > > > What do you make of this? > > Well there are some exceptions, but yes that is the idea. Operations > should be in a 'ops' struct and documented and implemented in a > consistent way. Is it your choice that I should keep "ops" structure in this specific implementation? -Takahiro Akashi > Regards, > Simon