mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: David Zhang <yidong.zhang@amd.com>, <quic_jhugo@quicinc.com>,
	<karol.wachowski@linux.intel.com>, <max.zhen@amd.com>,
	<ogabbay@kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linux-kernel@vger.kernel.org>
Cc: <sonal.santan@amd.com>, <mario.limonciello@amd.com>
Subject: Re: [PATCH V4 10/19] accel/amdxdna: Refactor AIE4 hardware initialization sequence
Date: Tue, 13 Oct 2026 11:33:41 -0700	[thread overview]
Message-ID: <77c7e02e-9cf8-efa1-0734-b702ec36c85c@amd.com> (raw)
In-Reply-To: <20261009225343.3079074-11-yidong.zhang@amd.com>


On 10/9/26 15:53, David Zhang wrote:
> Reorganize AIE4 hardware initialization into distinct phases, next to
> the existing aie4_config_fw():
> - aie4_query_fw(): Query NPU and CERT firmware versions.
> - aie4_setup_aie(): Query AIE version, metadata, initialize DPM frequency
>    table, and initialize partitions.
>
> Update aie4_pf_hw_start(), aie4_vf_hw_start(), and aie4_classic_hw_start()
> to use these phases and unify error unwinding labels. As part of this,
> aie4_pf_hw_start() now also calls aie4_query_fw(), which it previously
> did not do.
>
> Signed-off-by: David Zhang <yidong.zhang@amd.com>
> ---
>   drivers/accel/amdxdna/aie4_pci.c | 79 +++++++++++++++++++-------------
>   1 file changed, 46 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie4_pci.c b/drivers/accel/amdxdna/aie4_pci.c
> index 446ab2f47c7d..ffe78c0c4e8b 100644
> --- a/drivers/accel/amdxdna/aie4_pci.c
> +++ b/drivers/accel/amdxdna/aie4_pci.c
> @@ -50,7 +50,7 @@ static int aie4_fw_is_alive(struct amdxdna_dev *xdna)
>   {
>   	const struct amdxdna_dev_priv *npriv = xdna->dev_info->dev_priv;
>   	struct amdxdna_dev_hdl *ndev = xdna->dev_handle;
> -	u32 __iomem *src;
> +	void __iomem *src;
>   	u32 fw_is_valid;
>   	int ret;
>   
> @@ -280,7 +280,8 @@ static void aie4_partition_fini(struct amdxdna_dev_hdl *ndev)
>   		XDNA_ERR(xdna, "partition fini failed: %d", ret);
>   }
>   
> -static int aie4_query(struct amdxdna_dev_hdl *ndev)
> +/* Verify CERT protocol compatibility before starting hardware. */
> +static int aie4_query_fw(struct amdxdna_dev_hdl *ndev)
>   {
>   	struct amdxdna_dev *xdna = ndev->aie.xdna;
>   	int ret;
> @@ -293,25 +294,6 @@ static int aie4_query(struct amdxdna_dev_hdl *ndev)
>   	if (ret)
>   		return ret;
>   
> -	ret = aie4_query_aie_version(ndev, &ndev->aie.version);
> -	if (ret)
> -		return ret;
> -
> -	ret = aie4_query_aie_metadata(ndev, &ndev->aie.metadata);
> -	if (ret)
> -		return ret;
> -
> -	ndev->total_col = min_t(u32, AIE4_TOTAL_COLUMN, ndev->aie.metadata.cols);
> -
> -	ret = aie4_init_dpm_freq_table(ndev);
> -	if (ret) {
> -		if (ret == -ETIME)
> -			return ret;
> -		/* if query dpm from fw failed, using default value */
> -		if (ndev->priv->hw_ops && ndev->priv->hw_ops->set_dpm)
> -			(void)ndev->priv->hw_ops->set_dpm(&ndev->aie, 0);
> -	}
> -
>   	return 0;
>   }
>   
> @@ -340,6 +322,32 @@ static int aie4_config_fw(struct amdxdna_dev_hdl *ndev)
>   	return 0;
>   }
>   
> +static int aie4_setup_aie(struct amdxdna_dev_hdl *ndev)
> +{
> +	int ret;
> +
> +	ret = aie4_query_aie_version(ndev, &ndev->aie.version);
> +	if (ret)
> +		return ret;
> +
> +	ret = aie4_query_aie_metadata(ndev, &ndev->aie.metadata);
> +	if (ret)
> +		return ret;
> +
> +	ndev->total_col = min_t(u32, AIE4_TOTAL_COLUMN, ndev->aie.metadata.cols);
> +
> +	ret = aie4_init_dpm_freq_table(ndev);
> +	if (ret) {
> +		if (ret == -ETIME)
> +			return ret;
> +		/* if query dpm from fw failed, using default value */
> +		if (ndev->priv->hw_ops && ndev->priv->hw_ops->set_dpm)
> +			(void)ndev->priv->hw_ops->set_dpm(&ndev->aie, 0);
> +	}
> +
> +	return aie4_partition_init(ndev);
> +}
> +
>   static int aie4_pf_hw_start(struct amdxdna_dev_hdl *ndev)
>   {
>   	int ret;
> @@ -352,6 +360,10 @@ static int aie4_pf_hw_start(struct amdxdna_dev_hdl *ndev)
>   	if (ret)
>   		goto stop_fw;
>   
> +	ret = aie4_query_fw(ndev);
> +	if (ret)
> +		goto mbox_fini;
> +
>   	ret = aie4_config_fw(ndev);
>   	if (ret)
>   		goto mbox_fini;
> @@ -389,13 +401,13 @@ static int aie4_vf_hw_start(struct amdxdna_dev_hdl *ndev)
>   	if (ret)
>   		return ret;
>   
> -	ret = aie4_query(ndev);
> +	ret = aie4_query_fw(ndev);
>   	if (ret)
> -		goto mailbox_fini;
> +		goto mbox_fini;
>   
> -	ret = aie4_partition_init(ndev);
> +	ret = aie4_setup_aie(ndev);
>   	if (ret)
> -		goto mailbox_fini;
> +		goto mbox_fini;
>   
>   	ret = aie4_restore_power_mode(ndev);
>   	if (ret)
> @@ -405,7 +417,7 @@ static int aie4_vf_hw_start(struct amdxdna_dev_hdl *ndev)
>   
>   partition_fini:
>   	aie4_partition_fini(ndev);
> -mailbox_fini:
> +mbox_fini:
>   	aie4_mailbox_fini(ndev);
>   	return ret;
>   }
> @@ -432,17 +444,17 @@ static int aie4_classic_hw_start(struct amdxdna_dev_hdl *ndev)
>   	if (ret)
>   		goto stop_fw;
>   
> -	ret = aie4_query(ndev);
> +	ret = aie4_query_fw(ndev);
>   	if (ret)
> -		goto mailbox_fini;
> +		goto mbox_fini;
>   
>   	ret = aie4_config_fw(ndev);
>   	if (ret)
> -		goto mailbox_fini;
> +		goto mbox_fini;
>   
> -	ret = aie4_partition_init(ndev);
> +	ret = aie4_setup_aie(ndev);
>   	if (ret)
> -		goto mailbox_fini;
> +		goto mbox_fini;
>   
>   	ret = aie4_restore_power_mode(ndev);
>   	if (ret)
> @@ -452,10 +464,11 @@ static int aie4_classic_hw_start(struct amdxdna_dev_hdl *ndev)
>   
>   partition_fini:
>   	aie4_partition_fini(ndev);
> -mailbox_fini:
> +mbox_fini:
>   	aie4_mailbox_fini(ndev);
>   stop_fw:
>   	aie4_fw_stop(ndev);
> +
>   	return ret;
>   }
>   
> @@ -529,8 +542,8 @@ static int aie4_prepare_firmware(struct amdxdna_dev_hdl *ndev,
>   				 void __iomem *tbl[PCI_NUM_RESOURCES])
>   {
>   	struct amdxdna_dev *xdna = ndev->aie.xdna;
> +	struct smu_config smu_conf = {};
>   	struct psp_config psp_conf;
> -	struct smu_config smu_conf;
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
>   	int i;
>   
>   	psp_conf.fw_size = npufw->size;

  reply	other threads:[~2026-10-13 18:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 22:53 [PATCH V4 00/19] accel/amdxdna: Kernel submission and PM for AIE4 David Zhang
2026-10-09 22:53 ` [PATCH V4 01/19] accel/amdxdna: Rename NPU3 firmware files David Zhang
2026-10-09 22:53 ` [PATCH V4 02/19] accel/amdxdna: Remove mmap for doorbell David Zhang
2026-10-12 20:37   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 03/19] accel/amdxdna: Add CERT firmware version support David Zhang
2026-10-12 20:39   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 04/19] accel/amdxdna: Support firmware 6.0 David Zhang
2026-10-12 20:41   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 05/19] accel/amdxdna: Add NPU3 classic device support David Zhang
2026-10-12 20:41   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 06/19] accel/amdxdna: Add AIE version query to aie4_get_info David Zhang
2026-10-12 20:55   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 07/19] accel/amdxdna: Add get and set power_mode for AIE4 David Zhang
2026-10-12 21:29   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 08/19] accel/amdxdna: Add clock, DPM frequency, and resource info queries " David Zhang
2026-10-12 22:58   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 09/19] accel/amdxdna: Add context switch hysteresis with debugfs control David Zhang
2026-10-13 18:29   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 10/19] accel/amdxdna: Refactor AIE4 hardware initialization sequence David Zhang
2026-10-13 18:33   ` Lizhi Hou [this message]
2026-10-09 22:53 ` [PATCH V4 11/19] accel/amdxdna: Decouple AIE4 doorbell and MSI-X notify transport hooks David Zhang
2026-10-13 18:38   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 12/19] accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout David Zhang
2026-10-13 18:41   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 13/19] accel/amdxdna: Prepare for AIE4 command submission David Zhang
2026-10-13 18:42   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 14/19] accel/amdxdna: Move HMM invalidate wait into common GEM code David Zhang
2026-10-13 18:45   ` Lizhi Hou
2026-10-09 22:53 ` [PATCH V4 15/19] accel/amdxdna: Make populate_range common for AIE2 and AIE4 David Zhang
2026-10-09 22:53 ` [PATCH V4 16/19] accel/amdxdna: Implement AIE4 command packet building and submission David Zhang
2026-10-09 22:53 ` [PATCH V4 17/19] accel/amdxdna: Enable AIE4 firmware logging to DRAM David Zhang
2026-10-09 22:53 ` [PATCH V4 18/19] accel/amdxdna: Implement AIE4 suspend and resume David Zhang
2026-10-09 22:53 ` [PATCH V4 19/19] accel/amdxdna: Implement runtime suspend and resume support David Zhang

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=77c7e02e-9cf8-efa1-0734-b702ec36c85c@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karol.wachowski@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=max.zhen@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=quic_jhugo@quicinc.com \
    --cc=sonal.santan@amd.com \
    --cc=yidong.zhang@amd.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®