From patchwork Wed Jun 28 00:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 697206 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4080341wrm; Tue, 27 Jun 2023 17:50:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZG1ekK43WfsJCz06SJbnm/monw/UpRSeLNp5EKqHgof/mZI9TG/ueSF8L8PlI7Vv4B7qQ X-Received: by 2002:a05:651c:8f:b0:2b6:a17b:a120 with SMTP id 15-20020a05651c008f00b002b6a17ba120mr5279868ljq.22.1687913454655; Tue, 27 Jun 2023 17:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687913454; cv=none; d=google.com; s=arc-20160816; b=mJz27QkOih+GK7KnaTkpVhu0FRZL1o4SBKOaoNhrjpWjWsZrRWyZr4PnuiubFIdds8 c0/fcifzGmqfEV55KpCmcuKwVo+9NVy5iYbRCHMLK6z2XjtSeKevBREzBPKe3eifyup1 MDCwH2GDavFMBxUaei5XRIZDoECTIlR477yzdPPt1IpBU0EDbY3MRa5002DlPhAfN1Ta yyXGE+RdJUSyyswpb2SUwKwXwzdVIWL3DKw32jVhTMkr2yoZSH6ifka0GUmJy1J6LSUK YepVPNsBH3FOjnL0j+4Y5ngndl7rx+rfgHpd3juKaI3IREfhaJwgYjV6DGfDzCD5bW9O 5PYQ== 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=pKCXa0bvYCeAMaYJ3owgW37S0bA1lyBOiC4o9u7xct3X6CzY2P5qxOXjzLN+3M3fhO c6kmOEjlGNUgcIEw9E2SAXvRXvSknVOMXkHM18mcs8eEzmQ5x+VIg99ESwyAYIgArxwP kWO6PUD0Wkj/ez6NJ35gVxm33I/bVVvTNdRVZLuCYU2dU5kL1VC9JcEesh92v2XrnSEC OTYlz58F4/mvcpLoBgFiAF+qn6mX+52mZ8SSR/yZapOEz9Qj7My8F3MAQGgHY1VHCy77 PT2hqspk0DCDPfKYEgEzxYJbJNCTdJcVlbneiFddHKdM4fb5ih32GWUZzkkkgJGGvRs1 3zCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rr4ZChYZ; 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 x26-20020a2e9dda000000b002b69b37c0a3si2330429ljj.295.2023.06.27.17.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:50:54 -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=Rr4ZChYZ; 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 76C8D8662B; Wed, 28 Jun 2023 02:50:36 +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="Rr4ZChYZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47BF78662A; Wed, 28 Jun 2023 02:50:09 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (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 B0EE286618 for ; Wed, 28 Jun 2023 02:49:46 +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-pl1-x634.google.com with SMTP id d9443c01a7336-1b8053aece3so4739525ad.1 for ; Tue, 27 Jun 2023 17:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687913385; x=1690505385; 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; b=Rr4ZChYZKnIixvFPz+5U5JtC12raCodOUWQavn8e6rQyqs++Pf/PBBt0K9VIcFF23s 2ctrOzX5pJtMVcuZsSmLW3XuGBg43gUeigmXY0sozzafYZ1I7WB/VGmDJbV2VR2KFGQJ lYlLpG5gyFCrxBM0yI5FGGpR7Jea36kaJayjcj0A2tBvBhmOh17WvsW+hkuESiz+UPXM 9DaiYcJUheXhhxRJi06UxL3l/6qGonQ/5fKrimWH2HTKhlTR79AIyhf47CLZK9PVhV6i dk0VjqtEmlRMONFxsVzi1WB43+fk8X7glyPZWvKQvIKpeOiurMV4NhnsOPb0Qxe6KJsY e+hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687913385; x=1690505385; 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=y1sDemrPnZo1ZNJDDmR5Eyix8Xrx1ojgu+L7WRiAdqM=; b=RyYYJprn6cN1iYmDHXH48rLfMU76LQYvhhhpkscYeJr/0WSMrslFStvOxU3U6CArFk 6bH1yYT6XamA26ba7KvtVcsQKlYmqRp+F4GESMlDL/sHt3i5S42pfmC4tbuKX/CExoAV 9nDMXej4QW+9vodp63DdGF1J9CfeU3Yj3nteZKtOCgU8m2MkQeW2ciPvYFogkto/iq+f IAGhdgXsphYevh63mbuhh3pw6Ms+c+ROfjPP5URJgr6+Y6gLq5RhtBG6xQgLI6KjnOHQ zvr3f1ud2j1Gkv8wkeHpXt1yqMFlZBbZhmfwk9u4QtRdpp43f/OrcJiFd78Y6/hWsEaC hjxw== X-Gm-Message-State: AC+VfDy66g6KHH5AGVFo5wzvBdO7FQJ+bsH0oMo6wPDcI+XPcT+zEjbr dLT3MhgfXGD4g9nfRg/V4qP7Kw== X-Received: by 2002:a17:903:338d:b0:1b8:17e8:5482 with SMTP id kb13-20020a170903338d00b001b817e85482mr4459709plb.1.1687913385019; Tue, 27 Jun 2023 17:49:45 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:58b2:60ed:38ea:8b1f]) by smtp.gmail.com with ESMTPSA id u13-20020a170903124d00b001b3fb2f0296sm6517278plh.120.2023.06.27.17.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 17:49:44 -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 07/10] test: dm: add SCMI base protocol test Date: Wed, 28 Jun 2023 09:48:38 +0900 Message-ID: <20230628004841.21774-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628004841.21774-1-takahiro.akashi@linaro.org> References: <20230628004841.21774-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 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); + 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;