From patchwork Wed Apr 29 09:43:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Mengdong" X-Patchwork-Id: 6294301 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 945119F326 for ; Wed, 29 Apr 2015 09:33:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9D2020361 for ; Wed, 29 Apr 2015 09:33:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 97A2E20364 for ; Wed, 29 Apr 2015 09:33:02 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B5B1A2604F7; Wed, 29 Apr 2015 11:33:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 38FE42604D0; Wed, 29 Apr 2015 11:32:36 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 17E902604BD; Wed, 29 Apr 2015 11:32:35 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id CB3D62604AF for ; Wed, 29 Apr 2015 11:32:27 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 29 Apr 2015 02:32:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,670,1422950400"; d="scan'208";a="717650729" Received: from amanda-hsw-pc.sh.intel.com ([10.239.159.28]) by fmsmga002.fm.intel.com with ESMTP; 29 Apr 2015 02:32:25 -0700 From: mengdong.lin@intel.com To: alsa-devel@alsa-project.org, tiwai@suse.de Date: Wed, 29 Apr 2015 17:43:12 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: Mengdong Lin Subject: [alsa-devel] [PATCH v3 1/5] ALSA: hda - implement a refcount for i915 power well switch X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin This is to check the refcount of audio driver and reduce calling to i915. Signed-off-by: Mengdong Lin diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c index 52a85d8..b648928 100644 --- a/sound/pci/hda/hda_i915.c +++ b/sound/pci/hda/hda_i915.c @@ -42,10 +42,15 @@ int hda_display_power(struct hda_intel *hda, bool enable) dev_dbg(&hda->chip.pci->dev, "display power %s\n", enable ? "enable" : "disable"); - if (enable) - acomp->ops->get_power(acomp->dev); - else - acomp->ops->put_power(acomp->dev); + + if (enable) { + if (!hda->i915_power_refcount++) + acomp->ops->get_power(acomp->dev); + } else { + WARN_ON(!hda->i915_power_refcount); + if (!--hda->i915_power_refcount) + acomp->ops->put_power(acomp->dev); + } return 0; } @@ -183,6 +188,11 @@ out_err: int hda_i915_exit(struct hda_intel *hda) { struct device *dev = &hda->chip.pci->dev; + struct i915_audio_component *acomp = &hda->audio_component; + + WARN_ON(hda->i915_power_refcount); + if (hda->i915_power_refcount > 0 && acomp->ops) + acomp->ops->put_power(acomp->dev); component_master_del(dev, &hda_component_master_ops); diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h index 2069898..dc1d3ff 100644 --- a/sound/pci/hda/hda_intel.h +++ b/sound/pci/hda/hda_intel.h @@ -46,6 +46,7 @@ struct hda_intel { /* i915 component interface */ struct i915_audio_component audio_component; + int i915_power_refcount; }; #ifdef CONFIG_SND_HDA_I915