From patchwork Mon Apr 9 13:03:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10331303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6517E60236 for ; Mon, 9 Apr 2018 13:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57A5D28A09 for ; Mon, 9 Apr 2018 13:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C89828A24; Mon, 9 Apr 2018 13:04:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E925C28A09 for ; Mon, 9 Apr 2018 13:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbeDINDs (ORCPT ); Mon, 9 Apr 2018 09:03:48 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35067 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbeDINDp (ORCPT ); Mon, 9 Apr 2018 09:03:45 -0400 Received: by mail-pf0-f196.google.com with SMTP id u86so5748933pfd.2; Mon, 09 Apr 2018 06:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VtFvdV4UzYTvg1ZEfvH1DA86rokF+JiO5hrUQyxMaSQ=; b=fPPHif6FD7H3v9JT/7nCPKUBiA64/FP0gZPNGHzTc5UiPfPnjRBb2I8+XvOJTxh0Qe I73VN8t9X+eMe2Rgni26YjNkBMfdi4o31MmSqHa6dg/YLFg3KQJgDYMHHGfydDmhDdND 7hL7+rd9g9/STTOiWob3pNG4qn3xuFipMQufpiA9JAS0314Il4Wsv3SSVFTitQFvoEL4 gMEZqhmdXTxViBI1+GBnvq7x5GwExu3lfGGZF7jHELyj9GHMfX4ogwqR/8DJbZvUBEaH AQHfvLihdpsUvilR+Rmc/fVUzsCaqofe8LbA/KBANrQ74Pznw3mo9ac4K2TgPbX11nV1 IgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VtFvdV4UzYTvg1ZEfvH1DA86rokF+JiO5hrUQyxMaSQ=; b=uD59grS1jwbCzA3kngDxHorvKSIfvYykjKjY5TJX7FLmaEqLVYPHbsw3DyAjM5oJNj X3dyxF8D28E5iRPe+O42fWWvcfeTzSo0Ty5nDrHc1L5zwIkpCWu4BDV320hEk00D8OZt 0RC0mhMF8/zx3uAoLM0tiEI9c+FpEiQlEEIOkR0LtDRhZZRnBn9vXPMRURTMqXbom8ya +78ndvWPiJzWF65vFP+hOgWPcEmSt/jLrKPh9nvKlN8ueNuw2m+Dt4YSz4TwfNAIABIq ra6jrUy8tr5DbZO5BOaXRZp6t8d5lWw3uJd6MMP3Wcp27+82wq/fZIc+F2yIx5Lz2qBh GJLg== X-Gm-Message-State: AElRT7FjUSrQcZjqs+Cr+ru/eRL4Wkck9m+510E/XqRZzYJ8fEIqRW+X s6myDXXBzyHAUsyvTmzeePi72A== X-Google-Smtp-Source: AIpwx486wri9NwmZYHfbp79BtnlTrC/6RkppW9tPoZtjrMIwWwL5tkDrARbqTDnfGJ+wrt/ytQlv9A== X-Received: by 10.99.169.1 with SMTP id u1mr25751806pge.251.1523279025159; Mon, 09 Apr 2018 06:03:45 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:39e9:70fb:21a6:f4d2]) by smtp.gmail.com with ESMTPSA id r20sm1382623pff.165.2018.04.09.06.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 06:03:44 -0700 (PDT) From: Jia-Ju Bai To: T-Bone@parisc-linux.org, perex@perex.cz, tiwai@suse.com Cc: linux-parisc@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 2/2] sound: ad1889: Replace mdelay with usleep_range in snd_ad1889_ac97_ready Date: Mon, 9 Apr 2018 21:03:38 +0800 Message-Id: <1523279018-24017-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP snd_ad1889_ac97_ready() is never called in atomic context. The call chain ending up at snd_ad1889_ac97_ready() is: [1] snd_ad1889_ac97_ready() <- snd_ad1889_ac97_xinit() <- snd_ad1889_ac97_init() <- snd_ad1889_probe() snd_ad1889_probe() is only set as ".probe" in struct pci_driver. This function is not called in atomic context. Despite never getting called from atomic context, snd_ad1889_ac97_ready() calls mdelay for busy wait. This is not necessary and can be replaced with usleep_range to avoid busy waiting. This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- sound/pci/ad1889.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 0bf2c04..a2a8e1d 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -258,7 +258,7 @@ struct snd_ad1889 { while (!(ad1889_readw(chip, AD_AC97_ACIC) & AD_AC97_ACIC_ACRDY) && --retry) - mdelay(1); + usleep_range(1000, 2000); if (!retry) { dev_err(chip->card->dev, "[%s] Link is not ready.\n", __func__);