public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Subject: Re: [PATCH V3 8/8] soundwire: amd: add pm_prepare callback and pm ops support
Date: Tue, 21 Feb 2023 11:24:41 -0500	[thread overview]
Message-ID: <7d32d552-6ca0-3c40-11ce-c8d727cadc05@linux.intel.com> (raw)
In-Reply-To: <20230220100418.76754-9-Vijendar.Mukunda@amd.com>


> +static int amd_resume_child_device(struct device *dev, void *data)
> +{
> +	int ret;
> +	struct sdw_slave *slave = dev_to_sdw_dev(dev);

style: invert two lines?

> +
> +	if (!slave->probed) {
> +		dev_dbg(dev, "skipping device, no probed driver\n");
> +		return 0;
> +	}
> +	if (!slave->dev_num_sticky) {
> +		dev_dbg(dev, "skipping device, never detected on bus\n");
> +		return 0;
> +	}
> +	if (!pm_runtime_suspended(dev))
> +		return 0;
> +	ret = pm_request_resume(dev);

why not resume unconditionally and let the pm_runtime framework figure
things out?

That's what we did for Intel...

> +	if (ret < 0)
> +		dev_err(dev, "pm_request_resume failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static int __maybe_unused amd_pm_prepare(struct device *dev)
> +{
> +	struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev);
> +	struct sdw_bus *bus = &amd_manager->bus;
> +	int ret;
> +
> +	if (bus->prop.hw_disabled) {
> +		dev_dbg(bus->dev, "SoundWire manager %d is disabled, ignoring\n",
> +			bus->link_id);
> +		return 0;
> +	}
> +	/*
> +	 * When multiple peripheral devices connected over the same link, if SoundWire manager
> +	 * device is not in runtime suspend state, observed that device alerts are missing
> +	 * without pm_prepare on AMD platforms in clockstop mode0.
> +	 */
> +	if (pm_runtime_suspended(dev) && amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) {
> +		ret = pm_request_resume(dev);

same, why not simplify and use:

if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) {
    ret = pm_request_resume(dev);

> +		if (ret < 0) {
> +			dev_err(bus->dev, "pm_request_resume failed: %d\n", ret);
> +			return 0;
> +		}
> +	}
> +	/* To force peripheral devices to system level suspend state, resume the devices
> +	 * from runtime suspend state first. Without that unable to dispatch the alert
> +	 * status to peripheral driver during system level resume as they are in runtime
> +	 * suspend state.
> +	 */
> +	ret = device_for_each_child(bus->dev, NULL, amd_resume_child_device);
> +	if (ret < 0)
> +		dev_err(dev, "amd_resume_child_device failed: %d\n", ret);
> +	return 0;
> +}
> +
> +static int __maybe_unused amd_suspend(struct device *dev)
> +{
> +	struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev);
> +	struct sdw_bus *bus = &amd_manager->bus;
> +	int ret;
> +
> +	if (bus->prop.hw_disabled) {
> +		dev_dbg(bus->dev, "SoundWire manager %d is disabled, ignoring\n",
> +			bus->link_id);
> +		return 0;
> +	}
> +
> +	if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) {
> +		ret = amd_sdw_clock_stop(amd_manager);
> +		if (ret)
> +			return ret;

you could do a return amd_sdw_clock_stop(amd_manager);

> +	} else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) {
> +		/*
> +		 * As per hardware programming sequence on AMD platforms,
> +		 * clock stop should be invoked first before powering-off
> +		 */
> +		ret = amd_sdw_clock_stop(amd_manager);
> +		if (ret)
> +			return ret;
> +		ret = amd_deinit_sdw_manager(amd_manager);
> +		if (ret)
> +			return ret;
> +	}
> +	return 0;
> +}

      reply	other threads:[~2023-02-21 17:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 10:04 [PATCH V3 0/8] Add SoundWire support for AMD platforms Vijendar Mukunda
2023-02-20 10:04 ` [PATCH V3 1/8] soundwire: export sdw_compute_slave_ports() function Vijendar Mukunda
2023-02-20 10:04 ` [PATCH V3 2/8] soundwire: amd: Add support for AMD Manager driver Vijendar Mukunda
2023-02-21 15:57   ` Pierre-Louis Bossart
2023-02-22  7:18     ` Mukunda,Vijendar
2023-02-22  9:31   ` Claudiu.Beznea
2023-02-20 10:04 ` [PATCH V3 3/8] soundwire: amd: register SoundWire manager dai ops Vijendar Mukunda
2023-02-21 15:59   ` Pierre-Louis Bossart
2023-02-21 21:05     ` Mukunda,Vijendar
2023-02-21 23:48       ` Pierre-Louis Bossart
2023-02-22  5:39         ` Mukunda,Vijendar
2023-02-20 10:04 ` [PATCH V3 4/8] soundwire: amd: enable build for AMD SoundWire manager driver Vijendar Mukunda
2023-02-21 16:01   ` Pierre-Louis Bossart
2023-02-20 10:04 ` [PATCH V3 5/8] soundwire: amd: add SoundWire manager interrupt handling Vijendar Mukunda
2023-02-21 16:05   ` Pierre-Louis Bossart
2023-02-22  9:02     ` Mukunda,Vijendar
2023-02-20 10:04 ` [PATCH V3 6/8] soundwire: amd: add runtime pm ops for AMD SoundWire manager driver Vijendar Mukunda
2023-02-21 16:10   ` Pierre-Louis Bossart
2023-02-21 20:50     ` Mukunda,Vijendar
2023-02-20 10:04 ` [PATCH V3 7/8] soundwire: amd: handle SoundWire wake enable interrupt Vijendar Mukunda
2023-02-21 16:13   ` Pierre-Louis Bossart
2023-02-21 20:40     ` Mukunda,Vijendar
2023-02-20 10:04 ` [PATCH V3 8/8] soundwire: amd: add pm_prepare callback and pm ops support Vijendar Mukunda
2023-02-21 16:24   ` Pierre-Louis Bossart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d32d552-6ca0-3c40-11ce-c8d727cadc05@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox