From: Mastan Katragadda <mastan.katragadda@amd.com>
To: "broonie@kernel.org" <broonie@kernel.org>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"Hiregoudar, Basavaraj" <Basavaraj.Hiregoudar@amd.com>,
"Dommati, Sunil-kumar" <Sunil-kumar.Dommati@amd.com>,
"Mukunda, Vijendar" <Vijendar.Mukunda@amd.com>,
"kondaveeti, Arungopal" <Arungopal.kondaveeti@amd.com>,
"Reddy, V sujith kumar" <Vsujithkumar.Reddy@amd.com>,
"Prasad, Prasad" <venkataprasad.potturu@amd.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Ajye Huang <ajye_huang@compal.corp-partner.google.com>,
Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>,
Paul Olaru <paul.olaru@nxp.com>,
"moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS"
<sound-open-firmware@alsa-project.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] ASoC: SOF: amd: refactor PSP smn_read
Date: Wed, 12 Jul 2023 16:38:46 +0530 [thread overview]
Message-ID: <f3b7d7fd-2ce4-a579-0570-d55b04950140@amd.com> (raw)
In-Reply-To: <20230630070544.2167421-2-Mastan.Katragadda@amd.com>
On 30/06/23 12:35, Mastan Katragadda wrote:
> Use the read_poll_timeout marco for PSP smn_read calls.
This patch has not been merged.
>
> Signed-off-by: Mastan Katragadda <Mastan.Katragadda@amd.com>
> ---
> sound/soc/sof/amd/acp.c | 34 +++++++++++++++-------------------
> sound/soc/sof/amd/acp.h | 4 ++--
> 2 files changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
> index afb505461ea1..c450931ae77e 100644
> --- a/sound/soc/sof/amd/acp.c
> +++ b/sound/soc/sof/amd/acp.c
> @@ -28,12 +28,14 @@ static int smn_write(struct pci_dev *dev, u32 smn_addr, u32 data)
> return 0;
> }
>
> -static int smn_read(struct pci_dev *dev, u32 smn_addr, u32 *data)
> +static int smn_read(struct pci_dev *dev, u32 smn_addr)
> {
> + u32 data = 0;
> +
> pci_write_config_dword(dev, 0x60, smn_addr);
> - pci_read_config_dword(dev, 0x64, data);
> + pci_read_config_dword(dev, 0x64, &data);
>
> - return 0;
> + return data;
> }
>
> static void init_dma_descriptor(struct acp_dev_data *adata)
> @@ -150,15 +152,13 @@ int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr,
> static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
> {
> struct snd_sof_dev *sdev = adata->dev;
> - int timeout;
> + int ret;
> u32 data;
>
> - for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
> - msleep(20);
> - smn_read(adata->smn_dev, MP0_C2PMSG_114_REG, &data);
> - if (data & MBOX_READY_MASK)
> - return 0;
> - }
> + ret = read_poll_timeout(smn_read, data, data & MBOX_READY_MASK, MBOX_DELAY_US,
> + ACP_PSP_TIMEOUT_US, false, adata->smn_dev, MP0_C2PMSG_114_REG);
> + if (!ret)
> + return 0;
>
> dev_err(sdev->dev, "PSP error status %x\n", data & MBOX_STATUS_MASK);
>
> @@ -177,23 +177,19 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
> static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
> {
> struct snd_sof_dev *sdev = adata->dev;
> - int ret, timeout;
> + int ret;
> u32 data;
>
> if (!cmd)
> return -EINVAL;
>
> /* Get a non-zero Doorbell value from PSP */
> - for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
> - msleep(MBOX_DELAY);
> - smn_read(adata->smn_dev, MP0_C2PMSG_73_REG, &data);
> - if (data)
> - break;
> - }
> + ret = read_poll_timeout(smn_read, data, data, MBOX_DELAY_US, ACP_PSP_TIMEOUT_US, false,
> + adata->smn_dev, MP0_C2PMSG_73_REG);
>
> - if (!timeout) {
> + if (ret) {
> dev_err(sdev->dev, "Failed to get Doorbell from MBOX %x\n", MP0_C2PMSG_73_REG);
> - return -EINVAL;
> + return ret;
> }
>
> /* Check if PSP is ready for new command */
> diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h
> index dc624f727aa3..c3659dbc3745 100644
> --- a/sound/soc/sof/amd/acp.h
> +++ b/sound/soc/sof/amd/acp.h
> @@ -61,12 +61,12 @@
> #define HOST_BRIDGE_CZN 0x1630
> #define HOST_BRIDGE_RMB 0x14B5
> #define ACP_SHA_STAT 0x8000
> -#define ACP_PSP_TIMEOUT_COUNTER 5
> +#define ACP_PSP_TIMEOUT_US 1000000
> #define ACP_EXT_INTR_ERROR_STAT 0x20000000
> #define MP0_C2PMSG_114_REG 0x3810AC8
> #define MP0_C2PMSG_73_REG 0x3810A24
> #define MBOX_ACP_SHA_DMA_COMMAND 0x70000
> -#define MBOX_DELAY 1000
> +#define MBOX_DELAY_US 1000
> #define MBOX_READY_MASK 0x80000000
> #define MBOX_STATUS_MASK 0xFFFF
>
next prev parent reply other threads:[~2023-07-12 11:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 7:05 [PATCH 1/2] ASoC: SOF: amd: add revision check for sending sha dma completion command Mastan Katragadda
2023-06-30 7:05 ` [PATCH 2/2] ASoC: SOF: amd: refactor PSP smn_read Mastan Katragadda
2023-07-12 11:08 ` Mastan Katragadda [this message]
2023-07-12 11:40 ` Mark Brown
2023-06-30 17:07 ` (subset) [PATCH 1/2] ASoC: SOF: amd: add revision check for sending sha dma completion command Mark Brown
2023-07-03 15:28 ` Mukunda,Vijendar
2023-07-03 16:10 ` Mark Brown
2023-07-12 3:33 ` Mastan Katragadda
2023-07-12 11:04 ` Mark Brown
2023-07-12 11:47 ` Mark Brown
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=f3b7d7fd-2ce4-a579-0570-d55b04950140@amd.com \
--to=mastan.katragadda@amd.com \
--cc=AjitKumar.Pandey@amd.com \
--cc=Arungopal.kondaveeti@amd.com \
--cc=Basavaraj.Hiregoudar@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=Vsujithkumar.Reddy@amd.com \
--cc=ajye_huang@compal.corp-partner.google.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.olaru@nxp.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=venkataprasad.potturu@amd.com \
--cc=yung-chuan.liao@linux.intel.com \
/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
all inboxes | Powered by JetHome®