From: Lizhi Hou <lizhi.hou@amd.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
<ogabbay@kernel.org>, <quic_jhugo@quicinc.com>,
<dri-devel@lists.freedesktop.org>,
<maciej.falkowski@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <max.zhen@amd.com>,
<sonal.santan@amd.com>
Subject: Re: [PATCH V1] accel/amdxdna: Hold mm structure across iommu_sva_unbind_device()
Date: Fri, 30 Jan 2026 13:10:31 -0800 [thread overview]
Message-ID: <61d54b62-9582-a945-be83-57e651c8691d@amd.com> (raw)
In-Reply-To: <bfcf20f8-1390-4add-bf83-1d3087ac05c9@amd.com>
Applied to drm-misc-next-fixes
On 1/30/26 11:39, Mario Limonciello wrote:
> On 1/27/26 6:23 PM, Lizhi Hou wrote:
>> Some tests trigger a crash in iommu_sva_unbind_device() due to
>> accessing iommu_mm after the associated mm structure has been
>> freed.
>>
>> Fix this by taking an explicit reference to the mm structure
>> after successfully binding the device, and releasing it only
>> after the device is unbound. This ensures the mm remains valid
>> for the entire SVA bind/unbind lifetime.
>>
>> Fixes: be462c97b7df ("accel/amdxdna: Add hardware context")
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>> drivers/accel/amdxdna/amdxdna_pci_drv.c | 3 +++
>> drivers/accel/amdxdna/amdxdna_pci_drv.h | 1 +
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> b/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> index 45f5c12fc67f..fdefd9ec2066 100644
>> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> @@ -82,6 +82,8 @@ static int amdxdna_drm_open(struct drm_device
>> *ddev, struct drm_file *filp)
>> ret = -ENODEV;
>> goto unbind_sva;
>> }
>> + client->mm = current->mm;
>> + mmgrab(client->mm);
>> init_srcu_struct(&client->hwctx_srcu);
>> xa_init_flags(&client->hwctx_xa, XA_FLAGS_ALLOC);
>> mutex_init(&client->mm_lock);
>> @@ -116,6 +118,7 @@ static void amdxdna_client_cleanup(struct
>> amdxdna_client *client)
>> drm_gem_object_put(to_gobj(client->dev_heap));
>> iommu_sva_unbind_device(client->sva);
>> + mmdrop(client->mm);
>> kfree(client);
>> }
>> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.h
>> b/drivers/accel/amdxdna/amdxdna_pci_drv.h
>> index 6580cb5ec7e2..f08406b8fdf9 100644
>> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.h
>> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.h
>> @@ -130,6 +130,7 @@ struct amdxdna_client {
>> struct iommu_sva *sva;
>> int pasid;
>> + struct mm_struct *mm;
>> };
>> #define amdxdna_for_each_hwctx(client, hwctx_id, entry) \
>
prev parent reply other threads:[~2026-01-30 21:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 0:23 Lizhi Hou
2026-01-30 19:39 ` Mario Limonciello
2026-01-30 21:10 ` 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=61d54b62-9582-a945-be83-57e651c8691d@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.falkowski@linux.intel.com \
--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®