From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AFBCC07E96 for ; Tue, 6 Jul 2021 17:50:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F2A261C66 for ; Tue, 6 Jul 2021 17:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbhGFRxB (ORCPT ); Tue, 6 Jul 2021 13:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbhGFRxB (ORCPT ); Tue, 6 Jul 2021 13:53:01 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3960AC061574 for ; Tue, 6 Jul 2021 10:50:21 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id nd37so35507845ejc.3 for ; Tue, 06 Jul 2021 10:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6DuWZClbtqSNRCL74r09dT/s/L0004bm2wkFZOdkvpw=; b=ZK5ph7qgcPxnERLJlXiaKwif1UGvAh0MNRyOUwu1anV3qdewHWs7RJ3fNaIC25N/eG VdPmq3DIY/QQbUTWx027eaOcuuwyDfEYrzkBpkUlTlnFgRgTy4yjpFYJUcksvve3frt4 vmHo+Yb/TyQaXZYUfwNGSFUqJRGQeCexQh+rNcA4LZFZR3sK+Khuk7W5exjgrb8QuSuf NZbOIDiL/H/S7FwP80p3QyEEw81k6CnKxSVVqPevZ8OjHWnaa1BS0lZJpBOA/KEl3AKk I+O1ZbZXR+5aSWrFeGFM6Jcl9iJGm17EHYvA3SQmCPkaF5K+HU8aQjnvb6g7cER7cewK 0jDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6DuWZClbtqSNRCL74r09dT/s/L0004bm2wkFZOdkvpw=; b=WNaiabA5Qa+cUp/YKoUjfVJiV8cVtSBh2APt/MRfzqel/hUZEQ1GDRlsEOMbhCxO8o vO9OAjnYBvTssvl1IdHRRcaYX5nigqkOUHpmpyho3DWjBnRyq/FLRD5fUdJ2TyAgMLbV VMW9yeiETwkwIeoylc59qp1HT/f9FGcXDk49J00enuDbEpRZM0nU5UfYAO2UJ5IZQoAQ pH0k0pV7qyqf5zoIlauJW8/s4n9nYCcfe7Dv3w0CuYbN4KJnK6lR/1bVfjIhkZFRqgM5 oQtUOP5KsNsA5fAqcHFvALofvJfV6qc/LUCcn9jfb6gBhDQnWs4TRpDZP+ZcAIWZ5pJq Yx3w== X-Gm-Message-State: AOAM530Te9mdFRrNuaHfIeaZz1HNCUzP/BljYZ8FB1U14iPRooFFB5Ql 7qA2S6hbZqUtoXC489ZPKiC5Kyy8jx4YakEfi90= X-Google-Smtp-Source: ABdhPJz9S+/08teCkrSYtov5TVXHjlhnkYqXtiynqti4U2t6y6GyLIbc6CDS+kdJpadP1XHXIbp3FuZ6ZiufSdFBQEs= X-Received: by 2002:a17:906:5d12:: with SMTP id g18mr19803542ejt.186.1625593819751; Tue, 06 Jul 2021 10:50:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Max Filippov Date: Tue, 6 Jul 2021 10:50:08 -0700 Message-ID: Subject: Re: ALSA: intel8x0: div by zero in snd_intel8x0_update() To: Takashi Iwai Cc: Sergey Senozhatsky , alsa-devel@alsa-project.org, Leon Romanovsky , Takashi Iwai , LKML , "Gustavo A. R. Silva" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Sun, May 16, 2021 at 2:50 AM Takashi Iwai wrote: > > On Sun, 16 May 2021 10:31:41 +0200, > Sergey Senozhatsky wrote: > > > > On (21/05/16 17:30), Sergey Senozhatsky wrote: > > > On (21/05/14 20:16), Sergey Senozhatsky wrote: > > > > > --- a/sound/pci/intel8x0.c > > > > > +++ b/sound/pci/intel8x0.c > > > > > @@ -691,6 +691,9 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich > > > > > int status, civ, i, step; > > > > > int ack = 0; > > > > > > > > > > + if (!ichdev->substream || ichdev->suspended) > > > > > + return; > > > > > + > > > > > spin_lock_irqsave(&chip->reg_lock, flags); > > > > > status = igetbyte(chip, port + ichdev->roff_sr); > > > > > civ = igetbyte(chip, port + ICH_REG_OFF_CIV); > > > > > > This does the problem for me. > > > > ^^^ does fix > > OK, thanks for confirmation. So this looks like some spurious > interrupt with the unexpected hardware bits. > > However, the suggested check doesn't seem covering enough, and it > might still hit if the suspend/resume happens before the device is > opened but not set up (and such a spurious irq is triggered). > > Below is more comprehensive fix. Let me know if this works, too. > > > thanks, > > Takashi > > -- 8< -- > Subject: [PATCH] ALSA: intel8x0: Don't update period unless prepared > > The interrupt handler of intel8x0 calls snd_intel8x0_update() whenever > the hardware sets the corresponding status bit for each stream. This > works fine for most cases as long as the hardware behaves properly. > But when the hardware gives a wrong bit set, this leads to a NULL > dereference Oops, and reportedly, this seems what happened on a VM. > > For fixing the crash, this patch adds a internal flag indicating that > the stream is ready to be updated, and check it (as well as the flag > being in suspended) to ignore such spurious update. > > Cc: > Reported-by: Sergey Senozhatsky > Signed-off-by: Takashi Iwai > --- > sound/pci/intel8x0.c | 7 +++++++ > 1 file changed, 7 insertions(+) linux v5.13 booting on qemu-system-xtensa virt board gets stuck inside snd_intel8x0_probe -> intel8x0_measure_ac97_clock with this patch. Prior to it it boots successfully for me. I'm curious if this issue has been reported yet. What I see is an IRQ flood, at some point snd_intel8x0_interrupt and timer ISR are called in loop and execution never returns to the interrupted function intel8x0_measure_ac97_clock. Any idea what it could be? -- Thanks. -- Max From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91C17C07E96 for ; Tue, 6 Jul 2021 17:51:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEE5361C63 for ; Tue, 6 Jul 2021 17:51:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEE5361C63 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 897D783D; Tue, 6 Jul 2021 19:50:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 897D783D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1625593885; bh=VwsATNVOM7Ven+7TY5jGecho0jxA13IO2s3QTWCUtwY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MSv+g1Ck3tYQxTBLRWqQLiGLoHChKgY4TStOydSUU6r55BYwvA6a8havEPe2arj5b k5Td1hpEoW+KwxIamuxSL7ei8l04zfZFbtbXXzwno152rwhl6TXYIffXxY9RwFsiL2 9AHgp8PDhlzgMYqltxLBc4sRVsLaC8xNEDrzlEDo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 25408F80246; Tue, 6 Jul 2021 19:50:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3FE96F80249; Tue, 6 Jul 2021 19:50:33 +0200 (CEST) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 099E9F80134 for ; Tue, 6 Jul 2021 19:50:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 099E9F80134 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZK5ph7qg" Received: by mail-ej1-x629.google.com with SMTP id hr1so32122429ejc.1 for ; Tue, 06 Jul 2021 10:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6DuWZClbtqSNRCL74r09dT/s/L0004bm2wkFZOdkvpw=; b=ZK5ph7qgcPxnERLJlXiaKwif1UGvAh0MNRyOUwu1anV3qdewHWs7RJ3fNaIC25N/eG VdPmq3DIY/QQbUTWx027eaOcuuwyDfEYrzkBpkUlTlnFgRgTy4yjpFYJUcksvve3frt4 vmHo+Yb/TyQaXZYUfwNGSFUqJRGQeCexQh+rNcA4LZFZR3sK+Khuk7W5exjgrb8QuSuf NZbOIDiL/H/S7FwP80p3QyEEw81k6CnKxSVVqPevZ8OjHWnaa1BS0lZJpBOA/KEl3AKk I+O1ZbZXR+5aSWrFeGFM6Jcl9iJGm17EHYvA3SQmCPkaF5K+HU8aQjnvb6g7cER7cewK 0jDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6DuWZClbtqSNRCL74r09dT/s/L0004bm2wkFZOdkvpw=; b=n9mdQv8G4fXugIUEabN4MWql/u4s/rYPE35W07VuWvgg+OYa5EfcZWakWKJT36dBbN n1qlp+eThe8rv4D+rf0O8waLcytYQVz3JI/u10NAYD0liFI9TIjkkk5ZrNYmV4x6q8CD C6hLu/yOWiu3GnqF2l+kHnOPHiJcnErsUIAzvh9t+FXZ3M/2tHn22Xd/0AhM/eD1OOaD /3OLLFkuQna2RB3wcKm+QodrWDOQ72Esal3ZGfa/K4ME0WAy3Jx4vRmtJ2GANVI0BZ5x NZlfXSqNiPC4nn9GJjKu1s2CNarzOeSmejmPAAEeNcWaOl73DEqtt3T0M3ldt7Au0WW1 LZlw== X-Gm-Message-State: AOAM531RcDTj11vchGGRTb43w1938sSyh9qaNJFCpWWgbDAmgMptp6cu 2q9DrVROHbhuU42WPx2GDPxF3O34CfrZJCmvEUA= X-Google-Smtp-Source: ABdhPJz9S+/08teCkrSYtov5TVXHjlhnkYqXtiynqti4U2t6y6GyLIbc6CDS+kdJpadP1XHXIbp3FuZ6ZiufSdFBQEs= X-Received: by 2002:a17:906:5d12:: with SMTP id g18mr19803542ejt.186.1625593819751; Tue, 06 Jul 2021 10:50:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Max Filippov Date: Tue, 6 Jul 2021 10:50:08 -0700 Message-ID: Subject: Re: ALSA: intel8x0: div by zero in snd_intel8x0_update() To: Takashi Iwai Content-Type: text/plain; charset="UTF-8" Cc: alsa-devel@alsa-project.org, Leon Romanovsky , LKML , "Gustavo A. R. Silva" , Takashi Iwai , Sergey Senozhatsky X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hello, On Sun, May 16, 2021 at 2:50 AM Takashi Iwai wrote: > > On Sun, 16 May 2021 10:31:41 +0200, > Sergey Senozhatsky wrote: > > > > On (21/05/16 17:30), Sergey Senozhatsky wrote: > > > On (21/05/14 20:16), Sergey Senozhatsky wrote: > > > > > --- a/sound/pci/intel8x0.c > > > > > +++ b/sound/pci/intel8x0.c > > > > > @@ -691,6 +691,9 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich > > > > > int status, civ, i, step; > > > > > int ack = 0; > > > > > > > > > > + if (!ichdev->substream || ichdev->suspended) > > > > > + return; > > > > > + > > > > > spin_lock_irqsave(&chip->reg_lock, flags); > > > > > status = igetbyte(chip, port + ichdev->roff_sr); > > > > > civ = igetbyte(chip, port + ICH_REG_OFF_CIV); > > > > > > This does the problem for me. > > > > ^^^ does fix > > OK, thanks for confirmation. So this looks like some spurious > interrupt with the unexpected hardware bits. > > However, the suggested check doesn't seem covering enough, and it > might still hit if the suspend/resume happens before the device is > opened but not set up (and such a spurious irq is triggered). > > Below is more comprehensive fix. Let me know if this works, too. > > > thanks, > > Takashi > > -- 8< -- > Subject: [PATCH] ALSA: intel8x0: Don't update period unless prepared > > The interrupt handler of intel8x0 calls snd_intel8x0_update() whenever > the hardware sets the corresponding status bit for each stream. This > works fine for most cases as long as the hardware behaves properly. > But when the hardware gives a wrong bit set, this leads to a NULL > dereference Oops, and reportedly, this seems what happened on a VM. > > For fixing the crash, this patch adds a internal flag indicating that > the stream is ready to be updated, and check it (as well as the flag > being in suspended) to ignore such spurious update. > > Cc: > Reported-by: Sergey Senozhatsky > Signed-off-by: Takashi Iwai > --- > sound/pci/intel8x0.c | 7 +++++++ > 1 file changed, 7 insertions(+) linux v5.13 booting on qemu-system-xtensa virt board gets stuck inside snd_intel8x0_probe -> intel8x0_measure_ac97_clock with this patch. Prior to it it boots successfully for me. I'm curious if this issue has been reported yet. What I see is an IRQ flood, at some point snd_intel8x0_interrupt and timer ISR are called in loop and execution never returns to the interrupted function intel8x0_measure_ac97_clock. Any idea what it could be? -- Thanks. -- Max