mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Max Zhen <max.zhen@amd.com>, <ogabbay@kernel.org>,
	<quic_jhugo@quicinc.com>, <dri-devel@lists.freedesktop.org>,
	<mario.limonciello@amd.com>, <karol.wachowski@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <sonal.santan@amd.com>
Subject: Re: [PATCH V1 RESEND] accel/amdxdna: Fix SMU command execution on platforms without interrupt trigger
Date: Wed, 18 Nov 2026 08:50:29 -0800	[thread overview]
Message-ID: <ea436878-c43c-a38a-01bc-6254ddceac08@amd.com> (raw)
In-Reply-To: <20261117223142.179304-1-max.zhen@amd.com>


On 11/17/26 14:31, Max Zhen wrote:
> SMU command execution currently unconditionally manipulates
> SMU_INTR_REG when issuing a command. This works on platforms that
> require an interrupt trigger to start command processing, but it
> causes failures on platforms where commands are executed directly
> through the command and argument registers.
>
> Add a per-device SMU configuration flag indicating whether the
> interrupt mechanism is required. When enabled, wait for the interrupt
> register to become idle before submitting a command and trigger
> execution by writing to SMU_INTR_REG. When disabled, skip the
> interrupt handshake and rely on the command register write to start
> execution.
>
> This allows the common SMU implementation to correctly support both
> interrupt-driven and non-interrupt-driven firmware interfaces.
>
> Signed-off-by: Max Zhen <max.zhen@amd.com>
> ---
>   drivers/accel/amdxdna/aie.h       |  1 +
>   drivers/accel/amdxdna/aie2_pci.c  |  1 +
>   drivers/accel/amdxdna/aie2_pci.h  |  1 +
>   drivers/accel/amdxdna/aie_smu.c   | 20 +++++++++++++++-----
>   drivers/accel/amdxdna/npu1_regs.c |  1 +
>   5 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie.h b/drivers/accel/amdxdna/aie.h
> index 13af4b9b2cf2b..991e45ac7f364 100644
> --- a/drivers/accel/amdxdna/aie.h
> +++ b/drivers/accel/amdxdna/aie.h
> @@ -110,6 +110,7 @@ struct aie_bar_off_pair {
>   
>   struct smu_config {
>   	void __iomem    *smu_regs[SMU_MAX_REGS];
> +	bool		intr_enabled;
>   };
>   
>   struct psp_config {
> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
> index a3866e8933e61..cc53c1fc39443 100644
> --- a/drivers/accel/amdxdna/aie2_pci.c
> +++ b/drivers/accel/amdxdna/aie2_pci.c
> @@ -603,6 +603,7 @@ static int aie2_init(struct amdxdna_dev *xdna)
>   
>   	for (i = 0; i < SMU_MAX_REGS; i++)
>   		smu_conf.smu_regs[i] = tbl[SMU_REG_BAR(ndev, i)] + SMU_REG_OFF(ndev, i);
> +	smu_conf.intr_enabled = ndev->priv->smu_intr_enabled;
>   	ndev->aie.smu_hdl = aiem_smu_create(&xdna->ddev, &smu_conf);
>   	if (!ndev->aie.smu_hdl) {
>   		XDNA_ERR(xdna, "failed to create smu");
> diff --git a/drivers/accel/amdxdna/aie2_pci.h b/drivers/accel/amdxdna/aie2_pci.h
> index 13391275df318..26e3ccdaddd54 100644
> --- a/drivers/accel/amdxdna/aie2_pci.h
> +++ b/drivers/accel/amdxdna/aie2_pci.h
> @@ -190,6 +190,7 @@ struct amdxdna_dev_priv {
>   	struct aie_bar_off_pair		sram_offs[SRAM_MAX_INDEX];
>   	struct aie_bar_off_pair		psp_regs_off[PSP_MAX_REGS];
>   	struct aie_bar_off_pair		smu_regs_off[SMU_MAX_REGS];
> +	bool				smu_intr_enabled;
>   	const struct aie_hw_ops		*hw_ops;
>   };
>   
> diff --git a/drivers/accel/amdxdna/aie_smu.c b/drivers/accel/amdxdna/aie_smu.c
> index 62aea550aabcf..36a5cf88aea75 100644
> --- a/drivers/accel/amdxdna/aie_smu.c
> +++ b/drivers/accel/amdxdna/aie_smu.c
> @@ -26,22 +26,31 @@
>   
>   struct smu_device {
>   	struct drm_device	*ddev;
> -	struct smu_config	conf;
>   	void __iomem		*smu_regs[SMU_MAX_REGS];
> +	bool			intr_enabled;
>   };
>   
>   static int aie_smu_exec(struct smu_device *smu, u32 reg_cmd, u32 reg_arg, u32 *out)
>   {
> -	u32 resp;
> +	u32 resp, intr;
>   	int ret;
>   
> +	if (smu->intr_enabled) {
> +		ret = readx_poll_timeout(readl, SMU_REG(smu, SMU_INTR_REG), intr,
> +					 !(intr & 0x2), AIE_INTERVAL, AIE_TIMEOUT);
> +		if (ret) {
> +			drm_err(smu->ddev, "wait for smu intr idle timed out, 0x%x", intr);
> +			return ret;
> +		}
> +	}
> +
>   	writel(0, SMU_REG(smu, SMU_RESP_REG));
>   	writel(reg_arg, SMU_REG(smu, SMU_ARG_REG));
>   	writel(reg_cmd, SMU_REG(smu, SMU_CMD_REG));
>   
> -	/* Clear and set SMU_INTR_REG to kick off */
> -	writel(0, SMU_REG(smu, SMU_INTR_REG));
> -	writel(1, SMU_REG(smu, SMU_INTR_REG));
> +	/* Set SMU_INTR_REG to kick off */
> +	if (smu->intr_enabled)
> +		writel(1, SMU_REG(smu, SMU_INTR_REG));
>   
>   	ret = readx_poll_timeout(readl, SMU_REG(smu, SMU_RESP_REG), resp,
>   				 resp, AIE_INTERVAL, AIE_TIMEOUT);
> @@ -148,6 +157,7 @@ struct smu_device *aiem_smu_create(struct drm_device *ddev, struct smu_config *c
>   
>   	smu->ddev = ddev;
>   	memcpy(smu->smu_regs, conf->smu_regs, sizeof(smu->smu_regs));
> +	smu->intr_enabled = conf->intr_enabled;
>   
>   	return smu;
>   }
> diff --git a/drivers/accel/amdxdna/npu1_regs.c b/drivers/accel/amdxdna/npu1_regs.c
> index b4a0ede636f0d..0b45375ea1108 100644
> --- a/drivers/accel/amdxdna/npu1_regs.c
> +++ b/drivers/accel/amdxdna/npu1_regs.c
> @@ -124,6 +124,7 @@ static const struct amdxdna_dev_priv npu1_dev_priv = {
>   		DEFINE_BAR_OFFSET(SMU_RESP_REG, NPU1_SMU, MPNPU_PUB_SCRATCH6),
>   		DEFINE_BAR_OFFSET(SMU_OUT_REG,  NPU1_SMU, MPNPU_PUB_SCRATCH7),
>   	},
> +	.smu_intr_enabled = true,
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
>   	.hw_ops		= &(const struct aie_hw_ops) {
>   		.set_dpm = npu1_set_dpm,
>   	},

      reply	other threads:[~2026-11-18 16:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 22:31 Max Zhen
2026-11-18 16:50 ` Lizhi Hou [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=ea436878-c43c-a38a-01bc-6254ddceac08@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 \
    /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®