lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cc6ab93b-c964-8bf8-db60-ac20aa0a3006@microchip.com>
Date:   Tue, 28 Feb 2023 10:30:50 +0000
From:   <Claudiu.Beznea@...rochip.com>
To:     <Vijendar.Mukunda@....com>, <vkoul@...nel.org>
CC:     <alsa-devel@...a-project.org>,
        <pierre-louis.bossart@...ux.intel.com>,
        <Basavaraj.Hiregoudar@....com>, <Sunil-kumar.Dommati@....com>,
        <Mario.Limonciello@....com>, <amadeuszx.slawinski@...ux.intel.com>,
        <Mastan.Katragadda@....com>, <Arungopal.kondaveeti@....com>,
        <yung-chuan.liao@...ux.intel.com>, <sanyog.r.kale@...el.com>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V4 6/8] soundwire: amd: add runtime pm ops for AMD
 SoundWire manager driver

On 27.02.2023 17:47, Vijendar Mukunda wrote:
> Add support for runtime pm ops for AMD SoundWire manager driver.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@....com>
> Signed-off-by: Mastan Katragadda <Mastan.Katragadda@....com>
> ---
>  drivers/soundwire/amd_manager.c   | 161 ++++++++++++++++++++++++++++++
>  drivers/soundwire/amd_manager.h   |   3 +
>  include/linux/soundwire/sdw_amd.h |  17 ++++
>  3 files changed, 181 insertions(+)
> 
> diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
> index 7bb2300f16b3..12345077c395 100644
> --- a/drivers/soundwire/amd_manager.c
> +++ b/drivers/soundwire/amd_manager.c
> @@ -14,6 +14,7 @@
>  #include <linux/slab.h>
>  #include <linux/soundwire/sdw.h>
>  #include <linux/soundwire/sdw_registers.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/wait.h>
>  #include <sound/pcm_params.h>
>  #include <sound/soc.h>
> @@ -178,6 +179,12 @@ static void amd_disable_sdw_interrupts(struct amd_sdw_manager *amd_manager)
>         acp_reg_writel(0x00, amd_manager->mmio + ACP_SW_ERROR_INTR_MASK);
>  }
> 
> +static int amd_deinit_sdw_manager(struct amd_sdw_manager *amd_manager)
> +{
> +       amd_disable_sdw_interrupts(amd_manager);
> +       return amd_disable_sdw_manager(amd_manager);
> +}
> +
>  static void amd_sdw_set_frameshape(struct amd_sdw_manager *amd_manager)
>  {
>         u32 frame_size;
> @@ -957,6 +964,12 @@ static void amd_sdw_probe_work(struct work_struct *work)
>                         return;
>                 amd_sdw_set_frameshape(amd_manager);
>         }
> +       /* Enable runtime PM */
> +       pm_runtime_set_autosuspend_delay(amd_manager->dev, AMD_SDW_MASTER_SUSPEND_DELAY_MS);
> +       pm_runtime_use_autosuspend(amd_manager->dev);
> +       pm_runtime_mark_last_busy(amd_manager->dev);
> +       pm_runtime_set_active(amd_manager->dev);
> +       pm_runtime_enable(amd_manager->dev);
>  }
> 
>  static int amd_sdw_manager_probe(struct platform_device *pdev)
> @@ -1040,17 +1053,165 @@ static int amd_sdw_manager_remove(struct platform_device *pdev)
>  {
>         struct amd_sdw_manager *amd_manager = dev_get_drvdata(&pdev->dev);
> 
> +       pm_runtime_disable(&pdev->dev);
>         cancel_work_sync(&amd_manager->probe_work);
>         amd_disable_sdw_interrupts(amd_manager);
>         sdw_bus_master_delete(&amd_manager->bus);
>         return amd_disable_sdw_manager(amd_manager);
>  }
> 
> +static int amd_sdw_clock_stop(struct amd_sdw_manager *amd_manager)
> +{
> +       u32 val;
> +       u32 retry_count = 0;
> +       int ret;
> +
> +       ret = sdw_bus_prep_clk_stop(&amd_manager->bus);
> +       if (ret < 0 && ret != -ENODATA) {
> +               dev_err(amd_manager->dev, "prepare clock stop failed %d", ret);
> +               return 0;
> +       }
> +       ret = sdw_bus_clk_stop(&amd_manager->bus);
> +       if (ret < 0 && ret != -ENODATA) {
> +               dev_err(amd_manager->dev, "bus clock stop failed %d", ret);
> +               return 0;
> +       }
> +
> +       do {
> +               val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL);
> +               if (val & AMD_SDW_CLK_STOP_DONE) {
> +                       amd_manager->clk_stopped = true;
> +                       break;
> +               }
> +               usleep_range(10, 20);
> +       } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT);

Could these do { } while () be replaced by read_poll_timeout() ?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ