Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3762692pxk; Tue, 29 Sep 2020 05:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO/7Wgn4mSed+Jje9zqK24q7lLzffxy/r8GIrlfN7m5klolsmTiK3eLS5a0Wdt5WJ0tvzC X-Received: by 2002:a50:cf0b:: with SMTP id c11mr2945845edk.87.1601383666145; Tue, 29 Sep 2020 05:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601383666; cv=none; d=google.com; s=arc-20160816; b=EQqsrWIcv2+pJE36JnZggnBNiV8a/2oX65Nb/Rr1atbPibrHxmIw8uAx6RbFwrAwFm zO4R99tHfWnRpaMV70Qjk13jZyB6b83/g37GnixiLZj3E28L6Utjvjm7rZhfFoyi3BTE jmY4rI+jqbGwYP6UI3mOjsMRbAnPisW2GVfxFvziXJ65VmrhdVUnbaAYvCIm9Kn4heJ5 MKLFSTP6lRl2H0sGSXXrb6HStMyq81ofpNpoibDCRSL0bvqmqP3NH1YxbgFIv460w8Um 9ko2Dpgf2tyP2eTJcqjGbt4yk6jqL7IP9aVVqCaJ69+PZTFB6ubWMc4Nl/n7/SLW/Lyb sa4A== 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=4p3qNUTAEGluewM2Jwgxsi1xzff1dEAuFWlF3qvJjyk=; b=KBgPvqkscES1H0ybSY5aJwGTfgS5FLPm6+d0Gs+n/vdy+TiVB4vfCTkRs8HJvVwiDp Qww4woA8/VFWM02bigxKjDemnJGvKFrjmQfJMB61KN6JeutLYtEhljhtg059GLuAYAtl n27A23hTGHwaPNhpeF3TYNmwVLy5uRvuhEmHMTCCsDJunDe4vGHCzsUjWzcRLdreadGa J+EemkZbXDp4uFLQdiznDDw7nhqGmPFTfqW8N9GkATg2zE0MJQT05jQ6q5IN3iOO8Lgg 3jsxMCcA2rzGWlWMT40uqo7Usyb2l6X9SsWRG1IIzUEUdWIUsdLRKglap+72BAXnGVC3 /EvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aWdSlcV7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh20si2617417ejb.294.2020.09.29.05.47.22; Tue, 29 Sep 2020 05:47:46 -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=@kernel.org header.s=default header.b=aWdSlcV7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732651AbgI2MoV (ORCPT + 99 others); Tue, 29 Sep 2020 08:44:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:47394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728501AbgI2LIe (ORCPT ); Tue, 29 Sep 2020 07:08:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 72A4B21941; Tue, 29 Sep 2020 11:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377706; bh=7ijBAKzbzL0P/b4iOpJn8EUDsQXKg0GqQ7+MvRna7d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aWdSlcV7wB31/zdCH6bUAEsSWGDZjtYuwcTtPfDVoSkjIGW559hJ2M8cESFgk2DMq C3UDDcEVRtAZQYfDmH2zHyUHbvvFhSzaTZ59sl8rTqI22h20/f50CljiQtAi6lVHfo uGUqTiJsDS/g5pqO6tn0xcNVN4Z6nMcxSS0QyQ0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mohan Kumar , Viswanath L , Takashi Iwai , Sasha Levin Subject: [PATCH 4.9 043/121] ALSA: hda: Clear RIRB status before reading WP Date: Tue, 29 Sep 2020 12:59:47 +0200 Message-Id: <20200929105932.326559547@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105930.172747117@linuxfoundation.org> References: <20200929105930.172747117@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mohan Kumar [ Upstream commit 6d011d5057ff88ee556c000ac6fe0be23bdfcd72 ] RIRB interrupt status getting cleared after the write pointer is read causes a race condition, where last response(s) into RIRB may remain unserviced by IRQ, eventually causing azx_rirb_get_response to fall back to polling mode. Clearing the RIRB interrupt status ahead of write pointer access ensures that this condition is avoided. Signed-off-by: Mohan Kumar Signed-off-by: Viswanath L Link: https://lore.kernel.org/r/1580983853-351-1-git-send-email-viswanathl@nvidia.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/hda/hda_controller.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index bd0e4710d15d7..79043b481d7b6 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1158,16 +1158,23 @@ irqreturn_t azx_interrupt(int irq, void *dev_id) if (snd_hdac_bus_handle_stream_irq(bus, status, stream_update)) active = true; - /* clear rirb int */ status = azx_readb(chip, RIRBSTS); if (status & RIRB_INT_MASK) { + /* + * Clearing the interrupt status here ensures that no + * interrupt gets masked after the RIRB wp is read in + * snd_hdac_bus_update_rirb. This avoids a possible + * race condition where codec response in RIRB may + * remain unserviced by IRQ, eventually falling back + * to polling mode in azx_rirb_get_response. + */ + azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); active = true; if (status & RIRB_INT_RESPONSE) { if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) udelay(80); snd_hdac_bus_update_rirb(bus); } - azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); } } while (active && ++repeat < 10); -- 2.25.1