Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2136272pxb; Fri, 25 Mar 2022 11:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQCXslPG9j0VFQ+mnD0+iTOMgZovi8HCliieywEQgv2oPNouHlOCkEdHqgSwi8Qk5RX0gt X-Received: by 2002:a05:6a00:23c4:b0:4fb:28fa:fc36 with SMTP id g4-20020a056a0023c400b004fb28fafc36mr575642pfc.76.1648233845351; Fri, 25 Mar 2022 11:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233845; cv=none; d=google.com; s=arc-20160816; b=0UCRHjc5+K62PUC6y3+gLtBbHXWQAghIauthbSv0MkhbfT+09/xqX/7ozn8zrPGJ+9 IRbu48foYctwuvCXquNlOChmPqmshRhnLwZTEM/D3rOpr8R2TT6JI9FBOBTcbU0ynt// M1iUhJSrGAg/SVumTwAKxEBoKkSWJjRj13quOqUmrinMenR8q3Tk7hEoujL3k3cThOfB L3jAUQAW1WNlINbdZvP3mtyfsot5JzMRmjAkQ9ImVJZFllqysCfq6b/BMR2dEcbTFHEm AhpyrnJtQ41+POy87wro3vy41hWqcuac3dBle02kbyBmIMn1eNqI3s6jFp7mehfT0mKC Kg7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q7IcE0OISoT/FjwMpJ0LZ3QA+QXj5YBJCFcw2MWsXqw=; b=IWcrDTJbVrsinq+W8yJYhMxvltSeadGDmBIx12s7ex1DpxRseKcAn7QBTXXy1AnDQf d5KO+4BkRZUtGw8cxmcodc54S0ak/tIL8gX57RQZ+QXIk+oeMVsIz3L0ZhC+QAg9WTAs hYWNgVvPr0eq3c1V3hWGAnUfJ6MWh4QfRou/2k1VNaDo/280dcLKTE04h3VSOhAkUqa1 jbLHArbTQvPObAvMZD0DmXj99+lVfqS4PVOgSVJ6jJkT5gK+dcfoUbJkpKboj1xEEQ6a hWn0r+jUaYYjylzDCb9zuxr8yJOeF417KZ3J8g3SiVDVyqBX6DhdX4Wn9Rmz4+FJ3aSX PKZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q+Yb5tKZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g14-20020a63e60e000000b00382773de76csi3304003pgh.9.2022.03.25.11.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:44:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q+Yb5tKZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5B171A488C; Fri, 25 Mar 2022 11:00:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376590AbiCYPWu (ORCPT + 99 others); Fri, 25 Mar 2022 11:22:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376446AbiCYPUi (ORCPT ); Fri, 25 Mar 2022 11:20:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A804F6AA4F; Fri, 25 Mar 2022 08:15:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9516760A73; Fri, 25 Mar 2022 15:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF79C340E9; Fri, 25 Mar 2022 15:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648221322; bh=JCOVLHohscIa00QIH1ZFiQHu3Zt5Fac47pp88wkyeaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+Yb5tKZ/d8auFr16Wm8UGSNLTEIkNatJm42Tm+Z4fypcZZfdNqbKoqBvzCUOQUW9 9qihtDoTSNuH4cqWPBwUOEVdmLdiu5XOZyd3hqw1qFbPLyqsO2yumKC7ghasjdaSOo JAk4NqEikHP1Vd57FhNSLZBtXnoJ0D6qCIQrb9sM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giacomo Guiduzzi , Paolo Valente , Takashi Iwai Subject: [PATCH 5.15 20/37] ALSA: pci: fix reading of swapped values from pcmreg in AC97 codec Date: Fri, 25 Mar 2022 16:14:21 +0100 Message-Id: <20220325150420.511520783@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150419.931802116@linuxfoundation.org> References: <20220325150419.931802116@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Giacomo Guiduzzi commit 17aaf0193392cb3451bf0ac75ba396ec4cbded6e upstream. Tests 72 and 78 for ALSA in kselftest fail due to reading inconsistent values from some devices on a VirtualBox Virtual Machine using the snd_intel8x0 driver for the AC'97 Audio Controller device. Taking for example test number 72, this is what the test reports: "Surround Playback Volume.0 expected 1 but read 0, is_volatile 0" "Surround Playback Volume.1 expected 0 but read 1, is_volatile 0" These errors repeat for each value from 0 to 31. Taking a look at these error messages it is possible to notice that the written values are read back swapped. When the write is performed, these values are initially stored in an array used to sanity-check them and write them in the pcmreg array. To write them, the two one-byte values are packed together in a two-byte variable through bitwise operations: the first value is shifted left by one byte and the second value is stored in the right byte through a bitwise OR. When reading the values back, right shifts are performed to retrieve the previously stored bytes. These shifts are executed in the wrong order, thus reporting the values swapped as shown above. This patch fixes this mistake by reversing the read operations' order. Signed-off-by: Giacomo Guiduzzi Signed-off-by: Paolo Valente Cc: Link: https://lore.kernel.org/r/20220322200653.15862-1-guiduzzi.giacomo@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/ac97/ac97_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -938,8 +938,8 @@ static int snd_ac97_ad18xx_pcm_get_volum int codec = kcontrol->private_value & 3; mutex_lock(&ac97->page_mutex); - ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); - ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); + ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); + ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); mutex_unlock(&ac97->page_mutex); return 0; }