Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2594745pxb; Sun, 17 Oct 2021 19:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFbzFCT+tbJBVG8R58ttTp5iX7P999za2ypSIwZHPM13/ZTQv+2XLH9c1Y9X6rIyTunFfb X-Received: by 2002:a17:906:7017:: with SMTP id n23mr26297851ejj.446.1634525968199; Sun, 17 Oct 2021 19:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634525968; cv=none; d=google.com; s=arc-20160816; b=cezs1RfHS8OwASOEMjrLIDjvSnUTHSYWRf2VcKLlhhd0QGtdxtnrVUOKfZQocD93J8 CXjc+OwsGGKITP4ncszHxBwqdvPKzaUmRkcMM3a/dxHap9mjDNmkaiCjpsYz63NLvHwi dRuaMBfwM/YK/0F3JlNRN0ijjCS7N28jiMebj9QaGo9I5oRPSHGzcDwPNlOIW/ORROvP 32bBJBy8c3skSK5k/Z2F5q7pQZslDCOlBJGTaQO9z949ITkZSAGGC3Z3Cpxq67MjQaH8 vzILtZw2SJe4GiVOgKGmZvqi2gjCz29J8W/abG4QM2NkeEmNOni/SDUTqpU1g4rJwee3 cbQQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=bC5/do6YaE4lPDo0l97sBVrMnwWkBfvui2f3ar33Hc4=; b=Pp5b78WdtIda8hH+ECV8tPLTQJljyYEO6x6ag1/nHEsv0FpsRjAW8fnsCFkGHZjiSX 3u4/3dGZIos0xIJKeOWOb5+ee/qmvvbeoJZ0bAdmZtLULFmiH/GnjH5LxOlAyocaeK7O 7ShM9X7gEIJZDlW8OKIUh0uK7H4pcbNb+6GHHK9foXWGa1WrqucLCD7c1qiem70XhmSs EQGBWUDGe14osXAvxLCWkID1dcLz7CZKd7sJynDy2r9Hi06hlOCIozXc/M4p6of5jHMQ 3xgyT/OWdzYKxqzo+yfqTlRpwQKoJ9lzReRRMpfiVKE4CO7Alwrr+U0FKlLiXipls+PT P3UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eYZpMby4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kx3si20513869ejc.108.2021.10.17.19.59.00; Sun, 17 Oct 2021 19:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20210112 header.b=eYZpMby4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243052AbhJOVJx (ORCPT + 99 others); Fri, 15 Oct 2021 17:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235480AbhJOVJw (ORCPT ); Fri, 15 Oct 2021 17:09:52 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91084C061570 for ; Fri, 15 Oct 2021 14:07:45 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id y15so46899448lfk.7 for ; Fri, 15 Oct 2021 14:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bC5/do6YaE4lPDo0l97sBVrMnwWkBfvui2f3ar33Hc4=; b=eYZpMby4iGA+yh0NGF+8l+PJgizeDoLcmjeHyV4wtpwUUMvIQ3AXzmd7sgsMKFaAEZ HGwEWFsnA97BC5nK+vWjNWmsqMZ1Im1rXEY1pB+nOsZ6WjOO8J5sIu6bld0z5TfTDJp4 nW8LdiaYhaDDgRW3w1oYL3q+CgM6oBiybdB+JAvQLP5CDM1kzoLNiqOdZ5+q9aUqW5Fh LjA+irP2bBP9CUjvT5nVex/k8Ng3w7CGm6lIea3dkjWeVYyIajfpVaz4erDghnSWB9QH 1MWXfqPPPWTdbi+W92psmMlulWP2oV2+G6KaHPsRCyKzXxGhzPE7WaF0VB4CIkc9zhv7 9yUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bC5/do6YaE4lPDo0l97sBVrMnwWkBfvui2f3ar33Hc4=; b=kyIaQy0dw6qu2Y2oXvqgsjxPLdDFRg07Q/IR9NTmB8UFhfBWfyzzBI9/V9pCsKg06d 4OzpcmJqxytw4S4RgXW6dWZLuTpW/r0Nd3rEJ4XTg9Dom/4lFbFYY5cR9qVC2ipi3c5m oXQHbXo07mF2fxHmXoOm975AMCn6nvcJlbFzda2FakVN/IgD89u+kIH+d8zfPDc1izSQ /COlMqdVPuozU1G+DSNoBL0eQKTvIzYF5nK+XDvDON7vrcSAcwwANOUObiQGBozGMKoR PUbgJYzdSgpurnJDzAli6rA6yOVcQ164huj6k1k8Ta5UPQAEbIfWT3YXUamXdz65ccmB VJvA== X-Gm-Message-State: AOAM531hDbILCPf9NOZR5T17JBoH1pTL8+sMrYf15la/k/lRVMXaIl53 W4HbacTvkqDTk3KWresXWA0= X-Received: by 2002:a2e:bc03:: with SMTP id b3mr15169664ljf.54.1634332063982; Fri, 15 Oct 2021 14:07:43 -0700 (PDT) Received: from localhost.localdomain (84-72-105-84.dclient.hispeed.ch. [84.72.105.84]) by smtp.gmail.com with ESMTPSA id a29sm125876ljq.37.2021.10.15.14.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 14:07:43 -0700 (PDT) From: Nicolas Frattaroli To: Nicolas Frattaroli , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Heiko Stuebner Cc: linux-rockchip@lists.infradead.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: rockchip: i2s-tdm: Fix refcount test Date: Fri, 15 Oct 2021 23:07:29 +0200 Message-Id: <20211015210730.308946-1-frattaroli.nicolas@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During development of V5 of the i2s-tdm patch series, I replaced the atomic refcount with a regular integer, as it was only ever accessed within a spinlock. Foolishly, I got the semantics of atomic_dec_and_test wrong, which resulted in a test for 0 actually becoming a test for >0. The result was that setting the audio frequency broke; switching from 44100 Hz audio playback to 96000 Hz audio playback would garble the sound most unpleasantly. Fix this by checking for --refcount == 0, which is what it should have been all along. Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller") Signed-off-by: Nicolas Frattaroli --- sound/soc/rockchip/rockchip_i2s_tdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c index 396277eaa417..5d3abbada72a 100644 --- a/sound/soc/rockchip/rockchip_i2s_tdm.c +++ b/sound/soc/rockchip/rockchip_i2s_tdm.c @@ -408,7 +408,7 @@ static void rockchip_snd_txrxctrl(struct snd_pcm_substream *substream, else rockchip_disable_rde(i2s_tdm->regmap); - if (--i2s_tdm->refcount) { + if (--i2s_tdm->refcount == 0) { rockchip_snd_xfer_clear(i2s_tdm, I2S_CLR_TXC | I2S_CLR_RXC); } -- 2.33.1