From patchwork Fri Feb 5 18:46:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Vehmanen X-Patchwork-Id: 377658 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 7EA30C433DB for ; Fri, 5 Feb 2021 18:51:53 +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 BFE2E64EE8 for ; Fri, 5 Feb 2021 18:51:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFE2E64EE8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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 0B5A7167D; Fri, 5 Feb 2021 19:51:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0B5A7167D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1612551111; bh=gCbA2wlpdl5MmpAC5FpHN6n9MyERepa8tUYMu6UDMJg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WS53C6huAH0t1r5jDQ8XTs2VDYrYPhzWxWaLPM/Z8tO1eW3Zq616Jy1FhQ+9DK5kB 8UCUn1m3R6w3JbMxUw7uf6+9GcKECVxDQlLFMSXGyUOb1eR5EJW6OsfuQkIQEMb6uO AuP+5gcHl20sPhJ/Rx4CreIopTUFUIa74isEhRx4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 949B2F80156; Fri, 5 Feb 2021 19:50:14 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CE85F8023B; Fri, 5 Feb 2021 19:50:13 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C7947F80156 for ; Fri, 5 Feb 2021 19:50:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C7947F80156 IronPort-SDR: oGUbgQLPaDWxvIEGoTQARq/dkcE12eGWWNmDbNj+d7A9BIBRnp4aTeWrdYbP+5BsvpGMyJX+2+ GY6vsP1T1Umw== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="178914208" X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="178914208" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:50:03 -0800 IronPort-SDR: XLaCsOqvAeDR1ES5M8dsmu3tY3b/5hNIwMYhBaEd0VVTJ7Utj238DZjTS1XXOyjXmxVdu2y6Lh jcsV3uY/CCnA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="508632682" Received: from eliteleevi.tm.intel.com ([10.237.54.20]) by orsmga004.jf.intel.com with ESMTP; 05 Feb 2021 10:50:01 -0800 From: Kai Vehmanen To: alsa-devel@alsa-project.org, tiwai@suse.de Subject: [PATCH v2 1/3] ALSA: hda: add link_power op to hdac_bus_ops Date: Fri, 5 Feb 2021 20:46:28 +0200 Message-Id: <20210205184630.1938761-2-kai.vehmanen@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> References: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> MIME-Version: 1.0 Cc: broonie@kernel.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com, Ranjani Sridharan 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" The extended HDA bus (hdac_ext) provides interfaces for more fine-grained control of individual links than what plain HDA provides for. Links can be powered off when they are not used and if all links are released, controller can shut down the command DMA. These interfaces are currently not used by common HDA codec drivers. When a HDA codec is runtime suspended, it calls snd_hdac_codec_link_down(), but there is no link to the HDA extended bus, and on controller side the links are shut down only when all codecs are suspended. This patch adds link_power() to hdac_bus ops. Controllers using the HDA extended core, can use this to plug in snd_hdac_ext_bus_link_power() to implement more fine-grained control of link power. No change is needed for plain HDA controllers nor to existing HDA codec drivers. Co-developed-by: Ranjani Sridharan Signed-off-by: Ranjani Sridharan Signed-off-by: Kai Vehmanen --- include/sound/hdaudio.h | 14 ++++------- include/sound/hdaudio_ext.h | 2 ++ sound/hda/ext/hdac_ext_controller.c | 37 +++++++++++++++++++++++++++++ sound/hda/hdac_bus.c | 23 ++++++++++++++++++ sound/hda/hdac_controller.c | 14 +++++++++++ 5 files changed, 81 insertions(+), 9 deletions(-) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 6eed61e6cf8a..22af68b01426 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -241,6 +241,8 @@ struct hdac_bus_ops { /* get a response from the last command */ int (*get_response)(struct hdac_bus *bus, unsigned int addr, unsigned int *res); + /* notify of codec link power-up/down */ + void (*link_power)(struct hdac_device *hdev, bool enable); }; /* @@ -378,15 +380,8 @@ void snd_hdac_bus_exit(struct hdac_bus *bus); int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr, unsigned int cmd, unsigned int *res); -static inline void snd_hdac_codec_link_up(struct hdac_device *codec) -{ - set_bit(codec->addr, &codec->bus->codec_powered); -} - -static inline void snd_hdac_codec_link_down(struct hdac_device *codec) -{ - clear_bit(codec->addr, &codec->bus->codec_powered); -} +void snd_hdac_codec_link_up(struct hdac_device *codec); +void snd_hdac_codec_link_down(struct hdac_device *codec); int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val); int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, @@ -400,6 +395,7 @@ void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus); void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus); void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus); int snd_hdac_bus_reset_link(struct hdac_bus *bus, bool full_reset); +void snd_hdac_bus_link_power(struct hdac_device *hdev, bool enable); void snd_hdac_bus_update_rirb(struct hdac_bus *bus); int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status, diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h index 7abf74c1c474..a125e3814b58 100644 --- a/include/sound/hdaudio_ext.h +++ b/include/sound/hdaudio_ext.h @@ -131,6 +131,8 @@ void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link); int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link); +void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable); + /* update register macro */ #define snd_hdac_updatel(addr, reg, mask, val) \ writel(((readl(addr + reg) & ~(mask)) | (val)), \ diff --git a/sound/hda/ext/hdac_ext_controller.c b/sound/hda/ext/hdac_ext_controller.c index b0c0ef824d7d..a9bd39b93697 100644 --- a/sound/hda/ext/hdac_ext_controller.c +++ b/sound/hda/ext/hdac_ext_controller.c @@ -332,3 +332,40 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, return ret; } EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_put); + +static void hdac_ext_codec_link_up(struct hdac_device *codec) +{ + const char *devname = dev_name(&codec->dev); + struct hdac_ext_link *hlink = + snd_hdac_ext_bus_get_link(codec->bus, devname); + + if (hlink) + snd_hdac_ext_bus_link_get(codec->bus, hlink); +} + +static void hdac_ext_codec_link_down(struct hdac_device *codec) +{ + const char *devname = dev_name(&codec->dev); + struct hdac_ext_link *hlink = + snd_hdac_ext_bus_get_link(codec->bus, devname); + + if (hlink) + snd_hdac_ext_bus_link_put(codec->bus, hlink); +} + +void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable) +{ + struct hdac_bus *bus = codec->bus; + bool oldstate = test_bit(codec->addr, &bus->codec_powered); + + if (enable == oldstate) + return; + + snd_hdac_bus_link_power(codec, enable); + + if (enable) + hdac_ext_codec_link_up(codec); + else + hdac_ext_codec_link_down(codec); +} +EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power); diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c index 9766f6af8743..71db8592b33d 100644 --- a/sound/hda/hdac_bus.c +++ b/sound/hda/hdac_bus.c @@ -17,6 +17,7 @@ static void snd_hdac_bus_process_unsol_events(struct work_struct *work); static const struct hdac_bus_ops default_ops = { .command = snd_hdac_bus_send_cmd, .get_response = snd_hdac_bus_get_response, + .link_power = snd_hdac_bus_link_power, }; /** @@ -264,3 +265,25 @@ void snd_hdac_aligned_write(unsigned int val, void __iomem *addr, } EXPORT_SYMBOL_GPL(snd_hdac_aligned_write); #endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ + +void snd_hdac_codec_link_up(struct hdac_device *codec) +{ + struct hdac_bus *bus = codec->bus; + + if (bus->ops->link_power) + bus->ops->link_power(codec, true); + else + snd_hdac_bus_link_power(codec, true); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_link_up); + +void snd_hdac_codec_link_down(struct hdac_device *codec) +{ + struct hdac_bus *bus = codec->bus; + + if (bus->ops->link_power) + bus->ops->link_power(codec, false); + else + snd_hdac_bus_link_power(codec, false); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_link_down); diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index b98449fd92f3..062da7a7a586 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -648,3 +648,17 @@ void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus) snd_dma_free_pages(&bus->posbuf); } EXPORT_SYMBOL_GPL(snd_hdac_bus_free_stream_pages); + +/** + * snd_hdac_bus_link_power - power up/down codec link + * @codec: HD-audio device + * @enable: whether to power-up the link + */ +void snd_hdac_bus_link_power(struct hdac_device *codec, bool enable) +{ + if (enable) + set_bit(codec->addr, &codec->bus->codec_powered); + else + clear_bit(codec->addr, &codec->bus->codec_powered); +} +EXPORT_SYMBOL_GPL(snd_hdac_bus_link_power); From patchwork Fri Feb 5 18:46:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Vehmanen X-Patchwork-Id: 377036 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 1A2E0C433E0 for ; Fri, 5 Feb 2021 18:52:09 +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 2CB8C64DA5 for ; Fri, 5 Feb 2021 18:52:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CB8C64DA5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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 7956E1660; Fri, 5 Feb 2021 19:51:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7956E1660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1612551126; bh=fCPEcINiGiC/Snp1RqGxxFOxQNAY78sFdgD+9NfKR1A=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n93DkDuePD0CrKPMBYoa0IbNeFxUvk9XFv6fEhAyHSAuCWaaxbgpUzFzdWL1KRQv3 amP4BwLCp+yDbp2T6IrxCXLWp+2BFlOe0u3rP3MSD4pEovTuSuyjRTvIgEwclB01oj ed9fMAi87trASsXsec+mGPlpjqSsAlwZtGrt/BNo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 052C0F80290; Fri, 5 Feb 2021 19:50:17 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E2BAAF80264; Fri, 5 Feb 2021 19:50:15 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A7DF5F800C0 for ; Fri, 5 Feb 2021 19:50:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A7DF5F800C0 IronPort-SDR: CH3P79WG1W4K8T29ubUyZnmnXCOll938nUX/uq3P86dxjQlSlI7FmKbO5KQVMloTwEuTG8+q56 DWm9P/loKqsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="178914216" X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="178914216" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:50:06 -0800 IronPort-SDR: vElIgUU+wll7Gu0Z7q/Oy3V+Pq02awTrzO83oUcycG6sHTeQyuhRXGALG57ugssYW8NdJ+2oyC ypts9UpWWh+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="508632701" Received: from eliteleevi.tm.intel.com ([10.237.54.20]) by orsmga004.jf.intel.com with ESMTP; 05 Feb 2021 10:50:04 -0800 From: Kai Vehmanen To: alsa-devel@alsa-project.org, tiwai@suse.de Subject: [PATCH v2 2/3] ASoC: SOF: Intel: hda: use hdac_ext fine-grained link management Date: Fri, 5 Feb 2021 20:46:29 +0200 Message-Id: <20210205184630.1938761-3-kai.vehmanen@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> References: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> MIME-Version: 1.0 Cc: broonie@kernel.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com 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" Opt-in to use snd_hdac_ext_bus_link_power() to manage HDA link power up/down events. This allows to reduce power consumption in cases where some HDA codecs are suspended, but other child devices (HDA or non-HDA codecs) remain active and controller itself remains in active state. By using snd_hdac_ext_bus_link_power(), the individual HDA links can be powered off and if all HDA codecs are powered down, the command DMA can also be shut down. Signed-off-by: Kai Vehmanen --- sound/soc/sof/intel/hda-bus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda-bus.c b/sound/soc/sof/intel/hda-bus.c index 789148e5584b..1ac6e79d7e62 100644 --- a/sound/soc/sof/intel/hda-bus.c +++ b/sound/soc/sof/intel/hda-bus.c @@ -19,13 +19,21 @@ #define sof_hda_ext_ops NULL #endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +static const struct hdac_bus_ops bus_core_ops = { + .command = snd_hdac_bus_send_cmd, + .get_response = snd_hdac_bus_get_response, + .link_power = snd_hdac_ext_bus_link_power, +}; +#endif + /* * This can be used for both with/without hda link support. */ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev) { #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) - snd_hdac_ext_bus_init(bus, dev, NULL, sof_hda_ext_ops); + snd_hdac_ext_bus_init(bus, dev, &bus_core_ops, sof_hda_ext_ops); #else /* CONFIG_SND_SOC_SOF_HDA */ memset(bus, 0, sizeof(*bus)); bus->dev = dev; From patchwork Fri Feb 5 18:46:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Vehmanen X-Patchwork-Id: 377657 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 249CAC433E0 for ; Fri, 5 Feb 2021 18:52:42 +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 554D964DA5 for ; Fri, 5 Feb 2021 18:52:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 554D964DA5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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 CA71B1691; Fri, 5 Feb 2021 19:51:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA71B1691 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1612551159; bh=MyiE8AeKXgrp+TVg0WmzdAWrVMKcH6ggl1noBfX7KUI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FJrmO7Xchi8t/znjBq7qMLFsQdSzylS3wasV18ON+sjGfynmrN80YEzli+Dpoi3La Mw/Urkslt4rOE9mtDyaSaTnbPg9rrF44tAa/mAxUfPI+q3h1gaqOM/eeAQRT7MVV9X +X/KFMs87AgaktTWthj9o5T6zmqKjtNnW4NseclU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AFE3CF802C9; Fri, 5 Feb 2021 19:50:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3A864F802CA; Fri, 5 Feb 2021 19:50:19 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E555FF80139 for ; Fri, 5 Feb 2021 19:50:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E555FF80139 IronPort-SDR: yZU3nvl6dihQM4T94OIoF4maD8+FplrzRuEeMNUIhcHq4QpTiEmYoKGU9ZE7mdoZoQ5j1KRCkn oFFMYGRroFNg== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="178914219" X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="178914219" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:50:08 -0800 IronPort-SDR: PyTYflEMgSsTeMMiMA6ZFSHC6bwmKzK3HqTl6H6GFnJI3FfMxIhutgIPb1heeVGFI+PcCzQ1CO 1deiUYsfFHLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="508632710" Received: from eliteleevi.tm.intel.com ([10.237.54.20]) by orsmga004.jf.intel.com with ESMTP; 05 Feb 2021 10:50:07 -0800 From: Kai Vehmanen To: alsa-devel@alsa-project.org, tiwai@suse.de Subject: [PATCH v2 3/3] ASoC: SOF: Intel: hda: release display power at link_power Date: Fri, 5 Feb 2021 20:46:30 +0200 Message-Id: <20210205184630.1938761-4-kai.vehmanen@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> References: <20210205184630.1938761-1-kai.vehmanen@linux.intel.com> MIME-Version: 1.0 Cc: broonie@kernel.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com 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" The i915 display power is requested both by controller (for init and link reset) as well as by codec driver (for codec control). There's an additional constraint that on some platforms frequent changes to display power state may cause visible flicker. To avoid this, the SOF hda controller requests display power whenever it is active and only releases it when runtime suspended. This patch utilizes the new hdac_bus link_power op to plug into HDA link state changes. By monitoring link state changes, we can keep the controller side display power wakeref until the codec driver has completed its work, and only release the wakeref when codec driver is suspended. Signed-off-by: Kai Vehmanen --- sound/soc/sof/intel/hda-bus.c | 25 ++++++++++++++++++++++++- sound/soc/sof/intel/hda.h | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda-bus.c b/sound/soc/sof/intel/hda-bus.c index 1ac6e79d7e62..30025d3c16b6 100644 --- a/sound/soc/sof/intel/hda-bus.c +++ b/sound/soc/sof/intel/hda-bus.c @@ -9,6 +9,7 @@ #include #include +#include #include "../sof-priv.h" #include "hda.h" @@ -20,10 +21,32 @@ #endif #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +static void sof_hda_bus_link_power(struct hdac_device *codec, bool enable) +{ + struct hdac_bus *bus = codec->bus; + bool oldstate = test_bit(codec->addr, &bus->codec_powered); + + snd_hdac_ext_bus_link_power(codec, enable); + + if (enable == oldstate) + return; + + /* + * Both codec driver and controller can hold references to + * display power. To avoid unnecessary power-up/down cycles, + * controller doesn't immediately release its reference. + * + * If the codec driver powers down the link, release + * the controller reference as well. + */ + if (codec->addr == HDA_IDISP_ADDR && !enable) + snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); +} + static const struct hdac_bus_ops bus_core_ops = { .command = snd_hdac_bus_send_cmd, .get_response = snd_hdac_bus_get_response, - .link_power = snd_hdac_ext_bus_link_power, + .link_power = sof_hda_bus_link_power, }; #endif diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index a3b6f3e9121c..1d9b38e6ed40 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -388,7 +388,8 @@ #define SSP_SET_SFRM_SLAVE BIT(24) #define SSP_SET_SLAVE (SSP_SET_SCLK_SLAVE | SSP_SET_SFRM_SLAVE) -#define HDA_IDISP_CODEC(x) ((x) & BIT(2)) +#define HDA_IDISP_ADDR 2 +#define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR)) struct sof_intel_dsp_bdl { __le32 addr_l;