From patchwork Wed Aug 19 11:48:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 247949 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp389028ils; Wed, 19 Aug 2020 04:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr5xdcfNLCQwCQxzndt8JnJE/pFMU/ANa9iEcUt7RHJ1miYzmelQ0+YycYsfnum3vjNhzl X-Received: by 2002:aa7:cdd0:: with SMTP id h16mr24330511edw.116.1597837900271; Wed, 19 Aug 2020 04:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597837900; cv=none; d=google.com; s=arc-20160816; b=ikGjHZ+WESYjt0ke2Y2Sa8JH/LGzY9CINmbW3tMznui44c96iaJpbJxQXceLKqNk+u H9Z8vQHJtnztin9iG4c4wIHtwpJkWDJsoV9lnUQ/m/XcECgtWrABcWh3p3udb5eMSqoh 5J7GMOq5qyxCDQXPRPDDikhZqEEzYGpCnNJyzNNEBw1v6uTuTnAgWkqO0N2XzibaOYJJ fLQ0oRDt6hNDw7SGor7HkqEs0xtEEMbZPOs584AS8XEdLK6QavojiM34ncSnMFToIGk6 rc5uS0IJnkjcD6fo4d1+8noKyJH52korRadlePj9ZAoZasi6x/XI0gttCVFswZVYTmuG 4mfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dXLC7Y9Ict7hsGVfn1XyMyTiYvOn/Rnmae+8ciAdMPg=; b=TJZ23HFJ0vcM5Gz9VZApemuP4WWJQz243TS77hSTtQ8hbCYbo0ez7gdyQ5Ybf5T3j2 n7o5jiRbFTQqL3whTcl+iGVNn1lpDQSZQ+/xuXP/OrpXV0Er0Z9KRqepPhFD0zi1iuT+ rtEP20cQApGViOE5twkqWNRkLIivlMZBihR8bp2bZhDwHS18IoH6LYXPZ48mulGUUV/2 8c8nipLaR6R+lkLYJGJ63JV/cj6QzkaHWK7KOe+Y4GAM7qWmYorGbmXqN4FxXrXYjHWo RXiSo0jGAOrT04HAIz7npQT3T/8nioPb9RjOGiHHG6HVBZVTC2pZlDLvfbpSgqhp2U0D MCxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Psew0zq8; spf=pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kselftest-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch17si14983563ejb.627.2020.08.19.04.51.40; Wed, 19 Aug 2020 04:51:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Psew0zq8; spf=pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kselftest-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728427AbgHSLv1 (ORCPT + 6 others); Wed, 19 Aug 2020 07:51:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728226AbgHSLus (ORCPT ); Wed, 19 Aug 2020 07:50:48 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09DB92072D; Wed, 19 Aug 2020 11:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597837848; bh=UT+Vo3HFrZsD3uYH4LrsM9/ehPOpm9/+3nfx46Us6CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Psew0zq8PtTaioqog9tb/B1bUXu7dz65j5VCyDmWjhYSspyHqbDy2l1/KE8u+z56+ o4m3dqvrWptzgxbO5U8b7KuQOc3RTgiPykdo+M/HeC3jAg7JKfPLS/7elfjFYY0kuV Jw6a5kgFQiCS6z1s9MO+jkzBlAniVtStbPS2tDE4= From: Mark Brown To: Will Deacon , Catalin Marinas , Shuah Khan , Dave Martin Cc: linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v2 1/6] selftests: arm64: Test case for enumeration of SVE vector lengths Date: Wed, 19 Aug 2020 12:48:32 +0100 Message-Id: <20200819114837.51466-2-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200819114837.51466-1-broonie@kernel.org> References: <20200819114837.51466-1-broonie@kernel.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add a test case that verifies that we can enumerate the SVE vector lengths on systems where we detect SVE, and that those SVE vector lengths are valid. This program was written by Dave Martin and adapted to kselftest by me. Signed-off-by: Mark Brown --- .../selftests/arm64/fp/sve-probe-vls.c | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/testing/selftests/arm64/fp/sve-probe-vls.c -- 2.20.1 diff --git a/tools/testing/selftests/arm64/fp/sve-probe-vls.c b/tools/testing/selftests/arm64/fp/sve-probe-vls.c new file mode 100644 index 000000000000..b29cbc642c57 --- /dev/null +++ b/tools/testing/selftests/arm64/fp/sve-probe-vls.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2015-2020 ARM Limited. + * Original author: Dave Martin + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../kselftest.h" + +int main(int argc, char **argv) +{ + unsigned int vq; + int vl; + static unsigned int vqs[SVE_VQ_MAX]; + unsigned int nvqs = 0; + + ksft_print_header(); + ksft_set_plan(2); + + if (!(getauxval(AT_HWCAP) & HWCAP_SVE)) + ksft_exit_skip("SVE not available"); + + /* + * Enumerate up to SVE_VQ_MAX vector lengths + */ + for (vq = SVE_VQ_MAX; vq > 0; --vq) { + vl = prctl(PR_SVE_SET_VL, vq * 16); + if (vl == -1) + ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n", + strerror(errno), errno); + + vl &= PR_SVE_VL_LEN_MASK; + + if (!sve_vl_valid(vl)) + ksft_exit_fail_msg("VL %d invalid\n", vl); + vq = sve_vq_from_vl(vl); + + if (!(nvqs < SVE_VQ_MAX)) + ksft_exit_fail_msg("Too many VLs %u >= SVE_VQ_MAX\n", + nvqs); + vqs[nvqs++] = vq; + } + ksft_test_result_pass("Enumerated %d vector lengths\n", nvqs); + ksft_test_result_pass("All vector lengths valid\n"); + + /* Print out the vector lengths in ascending order: */ + while (nvqs--) + ksft_print_msg("%u\n", 16 * vqs[nvqs]); + + ksft_exit_pass(); +}