From patchwork Wed Jul 26 08:38:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 706632 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp900958wrs; Wed, 26 Jul 2023 11:24:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlHtCIhVepEHoxh+HMA44+cfw8JYTSMAqBQDN3sH7drh6jYnHLOpk2kIwY64cAD3J1BE88Tt X-Received: by 2002:a05:600c:aca:b0:3fc:70:2f76 with SMTP id c10-20020a05600c0aca00b003fc00702f76mr1929612wmr.20.1690395856807; Wed, 26 Jul 2023 11:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690395856; cv=none; d=google.com; s=arc-20160816; b=Qf7ii5RmFRdd/cA7eb7aRHNXuzO7XybvScVzu7wqw8CHmkUldEcbUee5lLxkj4N4xO x/+JJnmVg8nw8S0EdwufHF89Lm9fAsFJ43B00yxv6dDNH9YKIbw8nTuSSTx4xc5LBYzf wQ8DoOV+R9S1m4UaLQEj81EW4X8ENwMnSinC2uDI8tbQ5x4HE+aXS1SW4NqJJ2Ld7NoD PBFE+1b5fJE3JtHHbA8OrYIS3d9D9tVgtT4g8tq5kEqzZZqSo+6VicvOfqARSBxs3dfJ 280HMQapWhB5mAgbvyD6/rVGP6fODPBJZ9aL+YhB09ZBPuB5XX16THhMge5OJdvu+pRe +D3w== 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=gDru27GMsspW5zJ7ZEf7Us+ZGEWS8ervXItHrS4WB3k=; fh=m4nYqZzoK9SCykCyJ/rhitDYsGwNiXM0bHxVQp6NtlE=; b=VcP3Kh6lfbehXPJozfmn6h9lp5PaP/RXdWtc3PuwRk37KklvBlSZyl9hEoLKEIS2Qv us55fc8miWVYKFvqzzjD9yfpdGhE31QvrkSNWR1XWOFL75hFj7+bH/jh5tPm5EbKS1T7 tVUcY4aC23cUTOzLBrGSIOKUF0cjU12vbdFJ9KR6PfzF4BIM+kCyVDymWApTCqcIAmfb TWrxjVGi6CSen2lKvGgHvbKhiEVOOmJ8kM9GOxoYdUM3zYG/kOJgKg9H1egm/R5Og0QD u/rHC2VPz0CtypLWN/6MQJzbqwXevQy4TBtOuYUB5ztzkE4uY2kQ4qeaVy5pkwLefe9l sV2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IjcQ884m; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id i2-20020a05600c354200b003fbdb07786fsi1221131wmq.29.2023.07.26.11.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 11:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IjcQ884m; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 C4C7B8678A; Wed, 26 Jul 2023 20:24:13 +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="IjcQ884m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97AC08679B; Wed, 26 Jul 2023 20:24:11 +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-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (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 9871086778 for ; Wed, 26 Jul 2023 20:24:08 +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-qk1-x72b.google.com with SMTP id af79cd13be357-766fbc5e7c0so1798485a.0 for ; Wed, 26 Jul 2023 11:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690395847; x=1691000647; 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=gDru27GMsspW5zJ7ZEf7Us+ZGEWS8ervXItHrS4WB3k=; b=IjcQ884mIKdSfJZtJ+fKXRcbYpWJVrsTtu9Fm8PcatHZCybNpXf1unLNnMZR+i0bv9 Y5EGUMa0HnI+qnSj6aSKMYDzbyC7vXZjtEH+DGtBP0jzE7igeNcNL+JKaQbpoBEP6+0d DKUp1PyV9Y2d6Pe6gnlxAOb+23oiwrtNgj6EsnULEQE7VSDbAQzpCRD5qHx2yVM1Vkyr uvOOV6I7/nABczvEFEqBiqzaN14NsUxk6fWGGrh5ZfYpVDlDx3QqwX28TORUh0S7JekA i73Mv6qdv6Cck87vKLjksDfM6awzBeQhrADwO7hA2CLRpeh6LMtStV4egvzAULj59y6E W0iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690395847; x=1691000647; 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=gDru27GMsspW5zJ7ZEf7Us+ZGEWS8ervXItHrS4WB3k=; b=JIErJQg40tpt57c476j4a3duWxUGZV8QFJpsvh8F6LbXrUiNPnMDVDuU3XKnbUd8/c Pdctg6nLp1PRJ8r4GL1Ij/9N8kEBEYR0hc5DH4WwGponWjWsZYVK8YhLDYuyECc/SKGn rKNQVsMiIYIhYkK87pkmmXpJNU7XDxk84ItgV+7pxddX/GpKBT9SDLPNNyw+0IvkiIK4 vkAhrNg6DLD5AHmrqp//Nb3x4f07BKGd4kmyjUdr/POqZhg2w7vP484v9qquvdxMcb+y s3my4ni6BNB09yRvHJvl8GaN/P8zzQLs5JCJ/QfWok9JD15JaLdniyZEJQGfVZtfv01+ BRDg== X-Gm-Message-State: ABy/qLZBVmT+qRjr7wbvyakhfvyj2b9tT82TnHZZlKNoQNog4OJyeQfx Eb/ayNAXsMVrzRB52bnTLKhJp3yolFzy+aopyjE= X-Received: by 2002:a17:90a:3988:b0:268:3a31:3e4d with SMTP id z8-20020a17090a398800b002683a313e4dmr1449304pjb.2.1690360790245; Wed, 26 Jul 2023 01:39:50 -0700 (PDT) Received: from laputa.. ([2400:4050:c3e1:100:b3f9:1d29:2d48:cb41]) by smtp.gmail.com with ESMTPSA id 16-20020a17090a191000b00263c6b44dd8sm865986pjg.15.2023.07.26.01.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 01:39:45 -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 v2 09/12] test: dm: add SCMI base protocol test Date: Wed, 26 Jul 2023 17:38:05 +0900 Message-ID: <20230726083808.140780-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726083808.140780-1-takahiro.akashi@linaro.org> References: <20230726083808.140780-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 Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v2 * use helper functions, removing direct uses of ops --- test/dm/scmi.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 881be3171b7c..41d46548f7fd 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,112 @@ 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; + 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)); + + /* version */ + ret = scmi_base_protocol_version(base, &version); + ut_assertok(ret); + ut_asserteq(priv->version, version); + + /* protocol attributes */ + ret = scmi_base_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 = scmi_base_discover_vendor(base, vendor); + ut_assertok(ret); + ut_asserteq_str(priv->vendor, vendor); + + /* message attributes */ + ret = scmi_protocol_message_attrs(base, + SCMI_BASE_DISCOVER_SUB_VENDOR, + &attributes); + ut_assertok(ret); + ut_assertok(attributes); + + /* discover sub vendor */ + ret = scmi_base_discover_sub_vendor(base, vendor); + ut_assertok(ret); + ut_asserteq_str(priv->sub_vendor, vendor); + + /* impl version */ + ret = scmi_base_discover_impl_version(base, &impl_version); + ut_assertok(ret); + ut_asserteq(priv->impl_version, impl_version); + + /* discover agent (my self) */ + ret = scmi_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 = scmi_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 = scmi_base_set_device_permissions(base, agent_id, 0, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = scmi_base_set_device_permissions(base, agent_id, 1, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ + ret = scmi_base_set_device_permissions(base, agent_id, 0, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* set protocol permissions */ + ret = scmi_base_set_protocol_permissions(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = scmi_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 = scmi_base_set_protocol_permissions(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* reset agent configuration */ + ret = scmi_base_reset_agent_configuration(base, agent_id, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = scmi_base_reset_agent_configuration(base, agent_id, + SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = scmi_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;