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 02/19] accel/amdxdna: Remove mmap for doorbell
Date: Mon, 12 Oct 2026 13:37:06 -0700 [thread overview]
Message-ID: <2224aae6-dcc4-22e3-21ca-3a4a1b5c57ee@amd.com> (raw)
In-Reply-To: <20261009225343.3079074-3-yidong.zhang@amd.com>
On 10/9/26 15:53, David Zhang wrote:
> Make kernel submission the default, so mapping the doorbell back to user
> space is not needed:
> - Remove .mmap handler and use standard drm_gem_mmap.
> - Set hwctx->doorbell_offset to AMDXDNA_INVALID_DOORBELL_OFFSET on
> context creation so userspace does not receive a valid-looking BAR
> offset.
>
> Signed-off-by: David Zhang <yidong.zhang@amd.com>
> ---
> drivers/accel/amdxdna/aie4_ctx.c | 20 +--------------
> drivers/accel/amdxdna/aie4_pci.c | 33 -------------------------
> drivers/accel/amdxdna/aie4_pci.h | 1 -
> drivers/accel/amdxdna/amdxdna_pci_drv.c | 17 +------------
> drivers/accel/amdxdna/amdxdna_pci_drv.h | 1 -
> 5 files changed, 2 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie4_ctx.c b/drivers/accel/amdxdna/aie4_ctx.c
> index 8408b0d2696f..8157f2a6fd10 100644
> --- a/drivers/accel/amdxdna/aie4_ctx.c
> +++ b/drivers/accel/amdxdna/aie4_ctx.c
> @@ -158,7 +158,7 @@ static int aie4_hwctx_create(struct amdxdna_hwctx *hwctx)
> }
>
> priv->hw_ctx_id = resp.hw_context_id;
> - hwctx->doorbell_offset = resp.doorbell_offset;
> + hwctx->doorbell_offset = AMDXDNA_INVALID_DOORBELL_OFFSET;
>
> return 0;
> }
> @@ -313,21 +313,3 @@ int aie4_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq, u32 timeout)
>
> return ret <= 0 ? ret : 0;
> }
> -
> -int aie4_hwctx_valid_doorbell(struct amdxdna_client *client, u32 vm_pgoff)
> -{
> - struct amdxdna_hwctx *hwctx;
> - unsigned long hwctx_id;
> - int idx;
> -
> - idx = srcu_read_lock(&client->hwctx_srcu);
> - amdxdna_for_each_hwctx(client, hwctx_id, hwctx) {
> - if (vm_pgoff == (hwctx->doorbell_offset >> PAGE_SHIFT)) {
> - srcu_read_unlock(&client->hwctx_srcu, idx);
> - return 1;
> - }
> - }
> - srcu_read_unlock(&client->hwctx_srcu, idx);
> -
> - return 0;
> -}
> diff --git a/drivers/accel/amdxdna/aie4_pci.c b/drivers/accel/amdxdna/aie4_pci.c
> index e99ad35870ef..f81c43a1f884 100644
> --- a/drivers/accel/amdxdna/aie4_pci.c
> +++ b/drivers/accel/amdxdna/aie4_pci.c
> @@ -524,38 +524,6 @@ static int aie4m_pcidev_init(struct amdxdna_dev *xdna)
> return 0;
> }
>
> -static int aie4_doorbell_mmap(struct amdxdna_client *client, struct vm_area_struct *vma)
> -{
> - struct amdxdna_dev *xdna = client->xdna;
> - struct pci_dev *pdev = to_pci_dev(xdna->ddev.dev);
> - const struct amdxdna_dev_priv *npriv = xdna->dev_info->dev_priv;
> - phys_addr_t res_start;
> - unsigned long pfn;
> - int ret;
> -
> - if (!aie4_hwctx_valid_doorbell(client, vma->vm_pgoff)) {
> - XDNA_ERR(xdna, "Invalid doorbell page offset 0x%lx", vma->vm_pgoff);
> - return -EINVAL;
> - }
> -
> - if (vma_pages(vma) != 1) {
> - XDNA_ERR(xdna, "can only map one page, got %ld", vma_pages(vma));
> - return -EINVAL;
> - }
> -
> - res_start = pci_resource_start(pdev, xdna->dev_info->doorbell_bar) + npriv->doorbell_off;
> - pfn = PHYS_PFN(res_start) + vma->vm_pgoff;
> - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> - vm_flags_set(vma, VM_IO | VM_DONTEXPAND | VM_DONTDUMP);
> - ret = io_remap_pfn_range(vma, vma->vm_start,
> - pfn,
> - PAGE_SIZE,
> - vma->vm_page_prot);
> -
> - XDNA_DBG(xdna, "doorbell ret %d", ret);
> - return ret;
> -}
> -
> static int aie4_get_info(struct amdxdna_client *client, struct amdxdna_drm_get_info *args)
> {
> struct amdxdna_dev *xdna = client->xdna;
> @@ -667,7 +635,6 @@ const struct amdxdna_dev_ops aie4_vf_ops = {
> .fini = aie4_vf_fini,
> .hwctx_init = aie4_hwctx_init,
> .hwctx_fini = aie4_hwctx_fini,
> - .mmap = aie4_doorbell_mmap,
> .cmd_wait = aie4_cmd_wait,
> .get_aie_info = aie4_get_info,
> };
> diff --git a/drivers/accel/amdxdna/aie4_pci.h b/drivers/accel/amdxdna/aie4_pci.h
> index 3fd5eace3ed7..c6219544dc0f 100644
> --- a/drivers/accel/amdxdna/aie4_pci.h
> +++ b/drivers/accel/amdxdna/aie4_pci.h
> @@ -69,7 +69,6 @@ int aie4_attach_work_buffer(struct amdxdna_dev_hdl *ndev);
> int aie4_hwctx_init(struct amdxdna_hwctx *hwctx);
> void aie4_hwctx_fini(struct amdxdna_hwctx *hwctx);
> int aie4_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq, u32 timeout);
> -int aie4_hwctx_valid_doorbell(struct amdxdna_client *client, u32 vm_pgoff);
>
> /* aie4_sriov.c */
> #if IS_ENABLED(CONFIG_PCI_IOV)
> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c
> index d9e2e71d3e05..3140af69e29c 100644
> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
> @@ -250,21 +250,6 @@ static int amdxdna_drm_set_state_ioctl(struct drm_device *dev, void *data, struc
> return ret;
> }
>
> -static int amdxdna_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
> -{
> - struct drm_file *drm_filp = filp->private_data;
> - struct amdxdna_client *client = drm_filp->driver_priv;
> - struct amdxdna_dev *xdna = client->xdna;
> -
> - if (likely(vma->vm_pgoff >= DRM_FILE_PAGE_OFFSET_START))
> - return drm_gem_mmap(filp, vma);
> -
> - if (!xdna->dev_info->ops->mmap)
> - return -EOPNOTSUPP;
> -
> - return xdna->dev_info->ops->mmap(client, vma);
> -}
> -
> static const struct drm_ioctl_desc amdxdna_drm_ioctls[] = {
> /* Context */
> DRM_IOCTL_DEF_DRV(AMDXDNA_CREATE_HWCTX, amdxdna_drm_create_hwctx_ioctl, 0),
> @@ -323,7 +308,7 @@ static const struct file_operations amdxdna_fops = {
> .poll = drm_poll,
> .read = drm_read,
> .llseek = noop_llseek,
> - .mmap = amdxdna_drm_gem_mmap,
> + .mmap = drm_gem_mmap,
> .show_fdinfo = drm_show_fdinfo,
> .fop_flags = FOP_UNSIGNED_OFFSET,
> };
> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.h b/drivers/accel/amdxdna/amdxdna_pci_drv.h
> index a997d27a504d..84c8973e9197 100644
> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.h
> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.h
> @@ -57,7 +57,6 @@ struct amdxdna_dev_ops {
> int (*resume)(struct amdxdna_dev *xdna);
> int (*suspend)(struct amdxdna_dev *xdna);
> int (*sriov_configure)(struct amdxdna_dev *xdna, int num_vfs);
> - int (*mmap)(struct amdxdna_client *client, struct vm_area_struct *vma);
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
> int (*hwctx_init)(struct amdxdna_hwctx *hwctx);
> void (*hwctx_fini)(struct amdxdna_hwctx *hwctx);
> int (*hwctx_config)(struct amdxdna_hwctx *hwctx, u32 type, u64 value, void *buf, u32 size);
next prev parent reply other threads:[~2026-10-12 20:37 UTC|newest]
Thread overview: 27+ 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 [this message]
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-09 22:53 ` [PATCH V4 10/19] accel/amdxdna: Refactor AIE4 hardware initialization sequence David Zhang
2026-10-09 22:53 ` [PATCH V4 11/19] accel/amdxdna: Decouple AIE4 doorbell and MSI-X notify transport hooks David Zhang
2026-10-09 22:53 ` [PATCH V4 12/19] accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout David Zhang
2026-10-09 22:53 ` [PATCH V4 13/19] accel/amdxdna: Prepare for AIE4 command submission David Zhang
2026-10-09 22:53 ` [PATCH V4 14/19] accel/amdxdna: Move HMM invalidate wait into common GEM code David Zhang
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=2224aae6-dcc4-22e3-21ca-3a4a1b5c57ee@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®