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 3DA1FEB64D9 for ; Mon, 3 Jul 2023 00:57:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1376E865B7; Mon, 3 Jul 2023 02:57:19 +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="NIxRaWoU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FCCE86377; Mon, 3 Jul 2023 02:57:17 +0200 (CEST) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 38E5B86377 for ; Mon, 3 Jul 2023 02:57:14 +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-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2610f4d2294so805953a91.0 for ; Sun, 02 Jul 2023 17:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688345832; x=1690937832; 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=cJDLqVFQO29rd62/Z7rgN6DcB+7W+NI+uD0L+Zphii8=; b=NIxRaWoUxZ7eKzdjQPl2Gz1XMDtELAtQsUkceiEOd9D8K//iPcSeAkFzpxeJAmWOfj EScaPrxTJ+ymbrTobm3wvlTrMUavA1b2dM2+2GZIEh+kGYbv6umFg767FiC6vR63KAIY RC1F6d23lMC9mSLiyU2Tt5e0LPM1+ld3KdVyZhMhDrzfT3zT79IjIYLSJsXUC6MAQSOJ 8Fx3SeO418qDvr183VZT5V14kXWB0FytU1/9eqiCYXKLtYKiBUtgsNBB1zkr07c/cK8d uuZ4LK6wwS/mnb/Tlr8MYrPZvFb6AfsKoNRfWti5CFgYxLUlFsjpBzGIJjLhCdRzSs91 vmLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688345832; x=1690937832; 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=cJDLqVFQO29rd62/Z7rgN6DcB+7W+NI+uD0L+Zphii8=; b=Ph2zfG0bJFelXhSiJ/34+jMf0s3M61BBh4lwSY4mq6QIDNXKaL3JUUufC9IPFNUHxL kJEduWztgz1pfuZxdY1IZYtOZT68OV8nHIN0V2zzfRDLv+6gYk9jd5Ao8KxBiLwVO/zo njvxIvhKOPzRdg1B3TO/KZUGc/EIhcC5XtcTBoncJDNBHPs5Ph81Fq4APz5eVuOwgjDP ahfFKMhKB/NXDYzWx9Nm8lu15CNMh8+UIMu4NQY+Qa047Ifv2F9fJvK83xhRE5LOhORj 5gm8FlpnG30jJWs8/xZevEoypxkXhNv7CikFuW7NrUKI1sVZutc0bywk4rRw3CgMqDAS H9MA== X-Gm-Message-State: ABy/qLav5+sZgd1ghBDi3+zsMl8AG44B78ztY0LQp1e5YzxgTpQwUHSL m2miVZ7qbiNtxb3FOykzHGl5Ew== X-Google-Smtp-Source: APBJJlEFLsptiKu/RW3XYKy2VxPCkJTDIW1hIEqy+rFXEdu6ODMZzrVFoOH/x6V9CCG32wqZg+KY7A== X-Received: by 2002:a17:902:b210:b0:1b1:9272:55e2 with SMTP id t16-20020a170902b21000b001b1927255e2mr9100296plr.3.1688345832471; Sun, 02 Jul 2023 17:57:12 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:b349:4abf:f4cb:7486]) by smtp.gmail.com with ESMTPSA id p24-20020a170902a41800b001b39ffff838sm5902678plq.25.2023.07.02.17.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 17:57:11 -0700 (PDT) Date: Mon, 3 Jul 2023 09:57:09 +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 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. -Takahiro Akashi > > + ut_assertok(ret); > > + ut_asserteq(priv->version, version); > > + > > + /* protocol attributes */ > > + ret = (*ops->protocol_attrs)(base, &num_agents, &num_protocols); > > + ut_assertok(ret); > > + ut_asserteq(priv->num_agents, num_agents); > > + ut_asserteq(priv->num_protocols, num_protocols); > > + > > + /* discover vendor */ > > + ret = (*ops->base_discover_vendor)(base, vendor); > > + ut_assertok(ret); > > + ut_asserteq_str(priv->vendor, vendor); > > + > > + /* message attributes */ > > + ret = (*ops->protocol_message_attrs)(base, > > + SCMI_BASE_DISCOVER_SUB_VENDOR, > > + &attributes); > > + ut_assertok(ret); > > + ut_assertok(attributes); > > + > > + /* discover sub vendor */ > > + ret = (*ops->base_discover_sub_vendor)(base, vendor); > > + ut_assertok(ret); > > + ut_asserteq_str(priv->sub_vendor, vendor); > > + > > + /* impl version */ > > + ret = (*ops->base_discover_impl_version)(base, &impl_version); > > + ut_assertok(ret); > > + ut_asserteq(priv->impl_version, impl_version); > > + > > + /* discover agent (my self) */ > > + ret = (*ops->base_discover_agent)(base, 0xffffffff, > > + &agent_id, agent_name); > > + ut_assertok(ret); > > + ut_asserteq(priv->agent_id, agent_id); > > + ut_asserteq_str(priv->agent_name, agent_name); > > + > > + /* discover protocols */ > > + ret = (*ops->base_discover_list_protocols)(base, &protocols); > > + ut_asserteq(num_protocols, ret); > > + ut_asserteq_mem(priv->protocols, protocols, sizeof(u8) * num_protocols); > > + free(protocols); > > + > > + /* > > + * NOTE: Sandbox SCMI driver handles device-0 only. It supports setting > > + * access and protocol permissions, but doesn't allow unsetting them nor > > + * resetting the configurations. > > + */ > > + /* set device permissions */ > > + ret = (*ops->base_set_device_permissions)(base, agent_id, 0, > > + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); > > + ut_assertok(ret); /* SCMI_SUCCESS */ > > + ret = (*ops->base_set_device_permissions)(base, agent_id, 1, > > + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); > > + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ > > + ret = (*ops->base_set_device_permissions)(base, agent_id, 0, 0); > > + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ > > + > > + /* set protocol permissions */ > > + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 0, > > + SCMI_PROTOCOL_ID_CLOCK, > > + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); > > + ut_assertok(ret); /* SCMI_SUCCESS */ > > + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 1, > > + SCMI_PROTOCOL_ID_CLOCK, > > + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); > > + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ > > + ret = (*ops->base_set_protocol_permissions)(base, agent_id, 0, > > + SCMI_PROTOCOL_ID_CLOCK, 0); > > + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ > > + > > + /* reset agent configuration */ > > + ret = (*ops->base_reset_agent_configuration)(base, agent_id, 0); > > + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ > > + ret = (*ops->base_reset_agent_configuration)(base, agent_id, > > + SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS); > > + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ > > + ret = (*ops->base_reset_agent_configuration)(base, agent_id, 0); > > + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ > > + > > + return 0; > > +} > > + > > +DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT); > > + > > static int dm_test_scmi_clocks(struct unit_test_state *uts) > > { > > struct sandbox_scmi_agent *agent; > > -- > > 2.41.0 > > > > Regards, > Simon