From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Simon Glass <sjg@chromium.org>
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
Date: Mon, 3 Jul 2023 09:57:09 +0900 [thread overview]
Message-ID: <ZKIc5ftvN4yst_xl@laputa> (raw)
In-Reply-To: <CAPnjgZ2nsF2MFnn+D3HA6-HVsv-TqBL+CTKKgWA6ONtz0m8Xuw@mail.gmail.com>
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
> <takahiro.akashi@linaro.org> 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 <takahiro.akashi@linaro.org>
> > ---
> > 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 <clk.h>
> > #include <dm.h>
> > #include <reset.h>
> > +#include <scmi_agent.h>
> > +#include <scmi_agent-uclass.h>
> > +#include <scmi_protocols.h>
> > #include <asm/scmi_test.h>
> > #include <dm/device-internal.h>
> > #include <dm/test.h>
> > @@ -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
next prev parent reply other threads:[~2023-07-03 0:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 0:48 [PATCH 00/10] firmware: scmi: add SCMI base protocol support AKASHI Takahiro
2023-06-28 0:48 ` [PATCH 01/10] firmware: scmi: implement SCMI base protocol AKASHI Takahiro
2023-06-29 19:09 ` Simon Glass
2023-07-03 0:37 ` AKASHI Takahiro
2023-06-28 0:48 ` [PATCH 02/10] firmware: scmi: framework for installing additional protocols AKASHI Takahiro
2023-06-28 0:48 ` [PATCH 03/10] firmware: scmi: install base protocol to SCMI agent AKASHI Takahiro
2023-06-28 0:48 ` [PATCH 04/10] sandbox: remove SCMI base node definition from test.dts AKASHI Takahiro
2023-06-29 19:10 ` Simon Glass
2023-06-28 0:48 ` [PATCH 05/10] firmware: scmi: fake base protocol commands on sandbox AKASHI Takahiro
2023-06-29 19:09 ` Simon Glass
2023-06-28 0:48 ` [PATCH 06/10] test: dm: simplify SCMI unit test " AKASHI Takahiro
2023-06-29 19:09 ` Simon Glass
2023-06-28 0:48 ` [PATCH 07/10] test: dm: add SCMI base protocol test AKASHI Takahiro
2023-06-29 19:09 ` Simon Glass
2023-07-03 0:57 ` AKASHI Takahiro [this message]
2023-07-03 13:30 ` Simon Glass
2023-07-04 2:35 ` AKASHI Takahiro
2023-07-07 17:35 ` Simon Glass
2023-07-10 2:04 ` AKASHI Takahiro
2023-07-10 19:45 ` Simon Glass
2023-07-11 1:02 ` AKASHI Takahiro
[not found] ` <CAPnjgZ3HyYBRU0nQmauC1KBd-krOOJAORmbSRUki=KUHc+=TMw@mail.gmail.com>
2023-07-14 0:41 ` AKASHI Takahiro
2023-07-15 23:40 ` Simon Glass
2023-06-28 0:48 ` [PATCH 08/10] cmd: add scmi command for SCMI firmware AKASHI Takahiro
2023-06-29 19:10 ` Simon Glass
2023-07-03 0:55 ` AKASHI Takahiro
2023-07-03 13:30 ` Simon Glass
2023-07-04 1:26 ` AKASHI Takahiro
2023-07-07 17:35 ` Simon Glass
2023-07-10 1:46 ` AKASHI Takahiro
2023-06-28 0:48 ` [PATCH 09/10] doc: cmd: add documentation for scmi AKASHI Takahiro
2023-06-29 19:10 ` Simon Glass
2023-07-03 1:19 ` AKASHI Takahiro
2023-07-03 13:30 ` Simon Glass
2023-07-04 2:05 ` AKASHI Takahiro
2023-07-07 17:35 ` Simon Glass
2023-06-28 0:48 ` [PATCH 10/10] test: dm: add scmi command test AKASHI Takahiro
2023-06-29 19:10 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZKIc5ftvN4yst_xl@laputa \
--to=takahiro.akashi@linaro.org \
--cc=etienne.carriere@st.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox