Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp936087lqs; Fri, 14 Jun 2024 09:41:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJ5nUQbzv+JOYezKz8/xjKn0SaQVE1pXm6/Xdikobx/R4iOnsVPXs0X1emn98WAQBICfgK1cUMB2g9od1mvgaaYvSKWnJCUmhbZMXzbw== X-Google-Smtp-Source: AGHT+IGq85j+VO8S7aR/gz/vR/Fa2oLI8UlpYWSmpf2MwyHLk8QXnGdedPe2IUmNJO5jedh/4Ob5 X-Received: by 2002:a05:6830:2b13:b0:6fa:1312:49ed with SMTP id 46e09a7af769-6fb9387f9e1mr4772639a34.20.1718383260747; Fri, 14 Jun 2024 09:41:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718383260; cv=pass; d=google.com; s=arc-20160816; b=G1+CuOw3a/MZFZDA9VagVdoK6ZvTCorAZCZvJCPA8odKAmVXCD1cggVy9G1DqTZ2MV Whaa5Rre7CKzy2hhcBY79AOyMGC3sM3i6x+eNL1qnHxB3OiKRN6Y77cJfEzgfHTa4yPV 1NUc/OHNu5aeWEA5Vqw02HJnvroPvHJ7xCcYLrg7vbuxp66ySAqDxcyj+5dEvAZ75gwC OA6VeYpg1w9K+gXZXgREXaUVbl5faBH4K4hIXQgphCuOFwFZvdSI7U+zK3dABUG36DG1 Lg6f/B6MLPKuDoTLXjoUKCee41CF3BjuC+/PRrte8QyF8gVZzupF8TD23FDDaLZokVIQ 7eeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=PpFNYhrplH7cTosF3iGhjaFXXIaH1NnpkqEuhGN9q5o=; fh=TR0vb0Gcscr737pbHuJc3fKuvMb0/aI+j9AKwv6MbnQ=; b=MHNNTZ7DZYg338tzI/K470vqueQiOgdk8QhwMCDhTkP1YySa0V4oou21Hhy/cHSf7l 1KhK+KKkvOgmUD/9n+Srnz3KoLYW2eUSU4xAv2DpuZlP70a5AwiHbUVa0+j72ryjaHft yI3Afy2AU93eOWzWdZ6UdmiHj1ERA4cN0j/i8yoYEQqjNpHgpt0S6qpHkf8QVJV3d2R+ qhXbix8oQKlG1K8MhTHfakWfDRSRH3dTZhQIK7PDv87u9M2IITJsvr92X/X7HPKJIlku 1MsWUaVSJ7+SeWyzvMiLfkv0Fru7EoNILKbI/JnaIhecWe4XBV31xJLf/4pd27Wix0ab btYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CByp6SDw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5a175b5si41053746d6.29.2024.06.14.09.41.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 09:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CByp6SDw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3E2391C228D3 for ; Fri, 14 Jun 2024 16:41:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E769D18FC65; Fri, 14 Jun 2024 16:40:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CByp6SDw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1350A16DEB8; Fri, 14 Jun 2024 16:40:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718383254; cv=none; b=nRaO97TxJHEwaLQuNvqKX5TXRMQt3EYCWHLz+4rI3I0aWL08JNsLC2qcKIZCYRmuFIQB561Z75kL6hibuxhSoHZRVT/jkhX5iIdDW41GnlycZRZfOaNqpbTuhR3PjgT68QMybX5mvanGnuVLm7aQT7MqK0O2IRFT25K0jJC4xkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718383254; c=relaxed/simple; bh=Wu1djpYKdLoUSz8UIyrvQsOHyXiBbARCLMnJhRaWGQ8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=a6LcSbwrOTSKlGyjMbz6JFFH4PmulzKowF21wTxo4HD6Txhp653mBGmg2e3WAvD+meT1A7MfvCQJO6/bc8itMUqq8cdVJamP4unRt+j1xRwAdp8UsEvfH/5AUUrLIo6G072Yo395qgi8fyZSTJSmgTMudDr4MVp3p9ulIU653Zk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CByp6SDw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F315DC4AF1A; Fri, 14 Jun 2024 16:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718383253; bh=Wu1djpYKdLoUSz8UIyrvQsOHyXiBbARCLMnJhRaWGQ8=; h=From:Date:Subject:To:Cc:From; b=CByp6SDwcRrSnLPgzqPkbj3Q5x0nDwCEmcde2ATFtf7nAXNgq9IY4T8LsxVuI0JxE lfGayROCIu6t3s1Sc+gWuMIsCKEGsbETBR457FnwpNwh4X2l52wb6ruJLkOoO+LNaD 5TTs8XQ0Y/SuvxK50aqqcFTJmFz6WTAUcJ3+4etVofD9lCQfxJeybGz0L2KJNhftgJ X99l6MPGfUaOz936WmoAhBZmQHwa2htZz+nF7L2mSJhk8WkOG3a+ZbJ5XgZ2vF0VLX MgUNdS2IHf+W9SYKivJlGVxTS5JP0dw8kKU2IacYFErs7fYrst0NYp+OjVPUelAuhp NaVVGj7tJRyDw== From: Mark Brown Date: Fri, 14 Jun 2024 17:40:37 +0100 Subject: [PATCH] kselftest/alsa: Fix validation of writes to volatile controls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240614-alsa-selftest-volatile-v1-1-3874f02964b1@kernel.org> X-B4-Tracking: v=1; b=H4sIAIRybGYC/x3MQQqAIBBG4avErBswi5CuEi2kfmtAKhyJILp70 vJbvPeQIgmUhuqhhEtUjr2gqSuaN7+vYFmKyRrbmb7p2Ef1rIghQzNfR/RZInjpQwsH62bjqMR nQpD7H4/T+37DiyxgaAAAAA== To: Jaroslav Kysela , Takashi Iwai , Shuah Khan Cc: linux-sound@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.14-dev-0bd45 X-Developer-Signature: v=1; a=openpgp-sha256; l=2856; i=broonie@kernel.org; h=from:subject:message-id; bh=Wu1djpYKdLoUSz8UIyrvQsOHyXiBbARCLMnJhRaWGQ8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmbHKSVrfFkQw5bt3HgitV4OiUAdlDIjjXDGHii CyAzVGbs82JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZmxykgAKCRAk1otyXVSH 0KY/B/4nN+zWeNS7MpBmJVkNOSoRCwH+6McZ4FSrF9xCEn8qpq7Hpk6BCk7dgXJEmZgLKsYJlqQ QRzS1r6sEHQQ5Utf7bSLHFtq38QEAIQE/zgXaAUfTsl3LQaOMmnyMQ1C3cnZyOXM/iCAQWOtO6v kVtVRGsP9ANqZklxkZssJk87+ISLRoYIvsl7r/Z00PvBFP16fEBVNa73vKkgZ+410ZE5kEGUpWT buWB3b8cuR9ANfFKd8vGym3odpBx/AgkjidppVbOF47r/60hnWSOx+/5R7NNQYLs5cTSduO0Gos q4HOoVfmvIrcGiGasHmpz57gBtkP+G1jvP0JbnnVXeRGvj3I X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB When validating writes to controls we check that whatever value we wrote actually appears in the control. For volatile controls we cannot assume that this will be the case, the value may be changed at any time including between our write and read. Handle this by moving the check for volatile controls that we currently do for events to a separate block and just verifying that whatever value we read is valid for the control. Signed-off-by: Mark Brown --- tools/testing/selftests/alsa/mixer-test.c | 45 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c index 1c04e5f638a0..dd74f8cc7ece 100644 --- a/tools/testing/selftests/alsa/mixer-test.c +++ b/tools/testing/selftests/alsa/mixer-test.c @@ -625,6 +625,21 @@ static int write_and_verify(struct ctl_data *ctl, return err; } + /* + * We can't verify any specific value for volatile controls + * but we should still check that whatever we read is a valid + * vale for the control. + */ + if (snd_ctl_elem_info_is_volatile(ctl->info)) { + if (!ctl_value_valid(ctl, read_val)) { + ksft_print_msg("Volatile control %s has invalid value\n", + ctl->name); + return -EINVAL; + } + + return 0; + } + /* * Check for an event if the value changed, or confirm that * there was none if it didn't. We rely on the kernel @@ -632,22 +647,20 @@ static int write_and_verify(struct ctl_data *ctl, * write, this is currently true, should that ever change this * will most likely break and need updating. */ - if (!snd_ctl_elem_info_is_volatile(ctl->info)) { - err = wait_for_event(ctl, 0); - if (snd_ctl_elem_value_compare(initial_val, read_val)) { - if (err < 1) { - ksft_print_msg("No event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_missing++; - } - } else { - if (err != 0) { - ksft_print_msg("Spurious event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_spurious++; - } + err = wait_for_event(ctl, 0); + if (snd_ctl_elem_value_compare(initial_val, read_val)) { + if (err < 1) { + ksft_print_msg("No event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_missing++; + } + } else { + if (err != 0) { + ksft_print_msg("Spurious event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_spurious++; } } --- base-commit: 83a7eefedc9b56fe7bfeff13b6c7356688ffa670 change-id: 20240614-alsa-selftest-volatile-d6f3e8e28c08 Best regards, -- Mark Brown