From patchwork Thu Jul 30 18:09:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 247283 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2656511ilg; Thu, 30 Jul 2020 11:37:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6y5KchbwP+jKaNVA2reAqUJ2MsDFjXkSuU3ynsEnrO0MCZxvXHQMeJACFg3Vq4zpQPpKr X-Received: by 2002:a17:906:e24f:: with SMTP id gq15mr461241ejb.46.1596134232361; Thu, 30 Jul 2020 11:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596134232; cv=none; d=google.com; s=arc-20160816; b=UKnSFGG5nAOwQS1HczecczR0p9WumqljsKbN5mT17nucmv6MJrca67wqyHHDg5JeaR WvSEphuroUOogm71y4mps9nP2vwqK7hnSP6mfB6L/F+/4CBxPa5pReNEghQMzhVJ5nJK MN20csb8hzuiKaFdLlv9u9pdgtDEkOnWDePKCE8tgpAI8U6kDlZ1RZFszVBi1Va14dWB /59UsqfYGsFBhZmzOWHJT0mO5Q8KSXFdUPZojGhG/T/PDMglEW4IvjbkVObvGxlsNu9g DIuG326qX7vyP/24NhogDDtv4QXRx2Vbv4SJnq5pAM4YxBGnZ0euuRb2TSssKqoOgYnT qlxw== 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=VvWvGlViwIY2rqBckjqlWHsl+zF0MoF8E4pXqNJBP5lcw1NK++xJxaoM9y/PKwrlC6 QUJNt8hS+uiNmSWlJHZXbfpR2Z5+se7KhKYO5XRDM2oe/AyuzJYMRj/v01jfC/WyP2QJ IHO/eMUJaAUUzPm3XWzrHNq2Kvzb68uNF+V4vCi+nQCJrlSayRQZk54isuS6+gMrJTqR SgxXJm05qzwjjLfE48fB0800cj7TjocIbErWUAIs0kaopcCV2pYRwLRtczd2X4fzh97H m/CGoh6MKBGjzUGv5CufrPm5lk/larfm9b38lTlS7Z6p+4NgIZoEcFUZJxP2AoX6HX1m G9fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Tdb+LJUY; 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 s18si3774690ejd.164.2020.07.30.11.37.12; Thu, 30 Jul 2020 11:37:12 -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=Tdb+LJUY; 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 S1730279AbgG3ShM (ORCPT + 6 others); Thu, 30 Jul 2020 14:37:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:57094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730199AbgG3ShH (ORCPT ); Thu, 30 Jul 2020 14:37:07 -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 E86ED2072A; Thu, 30 Jul 2020 18:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596134226; bh=UT+Vo3HFrZsD3uYH4LrsM9/ehPOpm9/+3nfx46Us6CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tdb+LJUYepgJ398frVtT+uOikIQZwPxBbAoR57SyyPqdJKVaDhwDBGxO64JTpz9fl 44QWL/c6hFzEOC7l2KLdw4xNDlE7oC0jlO6LGDnl3B20S7VtXm8ww1BzsZQXB/cAqA B5J1LQMCd8og7JeJnOI3cOllCQtipN1/TUavkre4= From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Dave Martin Cc: linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH 1/6] selftests: arm64: Test case for enumeration of SVE vector lengths Date: Thu, 30 Jul 2020 19:09:15 +0100 Message-Id: <20200730180920.23527-2-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200730180920.23527-1-broonie@kernel.org> References: <20200730180920.23527-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(); +}