<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">2025年1月8日 17:54,Lazar, Lijo <<a href="mailto:lijo.lazar@amd.com" class="">lijo.lazar@amd.com</a>> 写道:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On 1/8/2025 2:26 PM, Jiang Liu wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">If some GPU device failed to probe, `rmmod amdgpu` will trigger a use<br class="">after free bug related to amdgpu_driver_release_kms() as:<br class="">2024-12-26 16:17:45 [16002.085540] BUG: kernel NULL pointer dereference, address: 0000000000000000<br class="">2024-12-26 16:17:45 [16002.093792] #PF: supervisor read access in kernel mode<br class="">2024-12-26 16:17:45 [16002.099993] #PF: error_code(0x0000) - not-present page<br class="">2024-12-26 16:17:45 [16002.106188] PGD 0 P4D 0<br class="">2024-12-26 16:17:45 [16002.109464] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI<br class="">2024-12-26 16:17:45 [16002.115372] CPU: 2 PID: 14375 Comm: rmmod Kdump: loaded Tainted: G W E 6.10.0+ #2<br class="">2024-12-26 16:17:45 [16002.125577] Hardware name: Alibaba Alibaba Cloud ECS/Alibaba Cloud ECS, BIOS 3.0.ES.AL.P.087.05 04/07/2024<br class="">2024-12-26 16:17:45 [16002.136858] RIP: 0010:drm_sched_fini+0x3f/0xe0 [gpu_sched]<br class="">2024-12-26 16:17:45 [16002.143463] Code: 60 c6 87 be 00 00 00 01 e8 ce e0 90 d8 48 8d bb 80 00 00 00 e8 c2 e0 90 d8 8b 43 20 85 c0 74 51 45 31 e4 48 8b<br class="">43 28 4d 63 ec <4a> 8b 2c e8 48 89 ef e8 f5 0e 59 d9 48 8b 45 10 48 8d 55 10 48 39<br class="">2024-12-26 16:17:45 [16002.164992] RSP: 0018:ffffb570dbbb7da8 EFLAGS: 00010246<br class="">2024-12-26 16:17:45 [16002.171316] RAX: 0000000000000000 RBX: ffff96b0fdadc878 RCX: 0000000000000000<br class="">2024-12-26 16:17:46 [16002.179784] RDX: 000fffffffe00000 RSI: 0000000000000000 RDI: ffff96b0fdadc8f8<br class="">2024-12-26 16:17:46 [16002.188252] RBP: ffff96b0fdadc800 R08: ffff97abbd035040 R09: ffffffff9ac52540<br class="">2024-12-26 16:17:46 [16002.196722] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000<br class="">2024-12-26 16:17:46 [16002.205179] R13: 0000000000000000 R14: ffff96b0fdadfc00 R15: 0000000000000000<br class="">2024-12-26 16:17:46 [16002.213648] FS: 00007f2737000740(0000) GS:ffff97abbd100000(0000) knlGS:0000000000000000<br class="">2024-12-26 16:17:46 [16002.223189] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br class="">2024-12-26 16:17:46 [16002.230103] CR2: 0000000000000000 CR3: 000000011be3a005 CR4: 0000000000f70ef0<br class="">2024-12-26 16:17:46 [16002.238581] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br class="">2024-12-26 16:17:46 [16002.247053] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400<br class="">e024se+0x3c/0x90 [amdxcp]<br class="">2024-12-26 16:17:46 [16002.337645] __do_sys_delete_module.constprop.0+0x176/0x310<br class="">2024-12-26 16:17:46 [16002.344324] do_syscall_64+0x5d/0x170<br class="">2024-12-26 16:17:46 [16002.348858] entry_SYSCALL_64_after_hwframe+0x76/0x7e<br class="">2024-12-26 16:17:46 [16002.354956] RIP: 0033:0x7f2736a620cb-12-26<br class=""><br class="">Fix it by removing xcp drm devices when failed to probe GPU devices.<br class=""><br class="">Signed-off-by: Jiang Liu <<a href="mailto:gerry@linux.alibaba.com" class="">gerry@linux.alibaba.com</a>><br class="">Tested-by: Shuo Liu <<a href="mailto:shuox.liu@linux.alibaba.com" class="">shuox.liu@linux.alibaba.com</a>><br class="">Reviewed-by: Lijo Lazar <<a href="mailto:lijo.lazar@amd.com" class="">lijo.lazar@amd.com</a>><br class="">---<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 +<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 47 +++++++++++++++++++---<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h | 4 +-<br class="">5 files changed, 47 insertions(+), 9 deletions(-)<br class=""><br class="">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br class="">index 5ff53a3b9851..510074a9074e 100644<br class="">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br class="">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br class="">@@ -6682,7 +6682,7 @@ void amdgpu_device_halt(struct amdgpu_device *adev)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct pci_dev *pdev = adev->pdev;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *ddev = adev_to_drm(adev);<br class=""><br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_dev_unplug(adev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_dev_deregister(adev);<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>drm_dev_unplug(ddev);<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_irq_disable_all(adev);<br class="">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br class="">index 62de668e9ff8..41d1b06be600 100644<br class="">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br class="">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br class="">@@ -2435,7 +2435,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *dev = pci_get_drvdata(pdev);<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct amdgpu_device *adev = drm_to_adev(dev);<br class=""><br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_dev_unplug(adev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_dev_deregister(adev);<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_gmc_prepare_nps_mode_change(adev);<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>drm_dev_unplug(dev);<br class=""><br class="">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br class="">index d2a046736edd..be9147eb8308 100644<br class="">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br class="">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br class="">@@ -1508,6 +1508,7 @@ void amdgpu_driver_release_kms(struct drm_device *dev)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct amdgpu_device *adev = drm_to_adev(dev);<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_device_fini_sw(adev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_mgr_fini(adev);<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Suggest to move this inside fini_sw()</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>pci_set_drvdata(adev->pdev, NULL);<br class="">}<br class=""><br class="">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c<br class="">index e209b5e101df..62dd5287808b 100644<br class="">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c<br class="">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c<br class="">@@ -283,6 +283,33 @@ static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;<br class="">}<br class=""><br class="">+static void amdgpu_xcp_dev_free(struct amdgpu_device *adev)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *p_ddev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>int i;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!adev->xcp_mgr)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>for (i = 1; i < MAX_XCP; i++) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!adev->xcp_mgr->xcp[i].ddev)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>break;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>// Restore and free the original drm_device.<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev = adev->xcp_mgr->xcp[i].ddev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->render->dev = adev->xcp_mgr->xcp[i].rdev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->primary->dev = adev->xcp_mgr->xcp[i].pdev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->driver = adev->xcp_mgr->xcp[i].driver;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->vma_offset_manager = adev->xcp_mgr->xcp[i].vma_offset_manager;<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Now that there are more calls, this doesn't make sense here. What about</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">moving the redirection along with register() (I guess it matters from</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">that point onwards) and undoing it (restore back saved values) along</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">with deregister()? With that, there won't be a need to have registered</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">flag. You may only need to check if xcp rdev/pdev is not NULL.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div>Good point, this makes code more clear.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_drm_dev_free(p_ddev);<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>adev->xcp_mgr->xcp[i].ddev = NULL;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>adev->xcp_mgr->xcp->ddev = NULL;<br class="">+}<br class="">+<br class="">+<br class="">int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>int init_num_xcps,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>struct amdgpu_xcp_mgr_funcs *xcp_funcs)<br class="">@@ -310,6 +337,13 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>return amdgpu_xcp_dev_alloc(adev);<br class="">}<br class=""><br class="">+void amdgpu_xcp_mgr_fini(struct amdgpu_device *adev)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>amdgpu_xcp_dev_free(adev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>kfree(adev->xcp_mgr);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>adev->xcp_mgr = NULL;<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Thanks for adding this.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Thanks,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Lijo</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+}<br class="">+<br class="">int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> enum AMDGPU_XCP_IP_BLOCK ip, int instance)<br class="">{<br class="">@@ -359,12 +393,14 @@ int amdgpu_xcp_dev_register(struct amdgpu_device *adev,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>ret = drm_dev_register(adev->xcp_mgr->xcp[i].ddev, ent->driver_data);<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (ret)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return ret;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>adev->xcp_mgr->xcp[i].registered = true;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;<br class="">}<br class=""><br class="">-void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev)<br class="">+void amdgpu_xcp_dev_deregister(struct amdgpu_device *adev)<br class="">{<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *p_ddev;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>int i;<br class="">@@ -377,11 +413,10 @@ void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev)<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>break;<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev = adev->xcp_mgr->xcp[i].ddev;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>drm_dev_unplug(p_ddev);<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->render->dev = adev->xcp_mgr->xcp[i].rdev;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->primary->dev = adev->xcp_mgr->xcp[i].pdev;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->driver = adev->xcp_mgr->xcp[i].driver;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>p_ddev->vma_offset_manager = adev->xcp_mgr->xcp[i].vma_offset_manager;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (adev->xcp_mgr->xcp[i].registered) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>drm_dev_unplug(p_ddev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>adev->xcp_mgr->xcp[i].registered = false;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">}<br class=""><br class="">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h<br class="">index b63f53242c57..be22d4398463 100644<br class="">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h<br class="">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h<br class="">@@ -101,6 +101,7 @@ struct amdgpu_xcp {<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>uint8_t id;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>uint8_t mem_id;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>bool valid;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>bool registered;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>atomic_t<span class="Apple-tab-span" style="white-space: pre;"> </span>ref_cnt;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *ddev;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct drm_device *rdev;<br class="">@@ -155,6 +156,7 @@ int amdgpu_xcp_resume(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id);<br class=""><br class="">int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>int init_xcps, struct amdgpu_xcp_mgr_funcs *xcp_funcs);<br class="">+void amdgpu_xcp_mgr_fini(struct amdgpu_device *adev);<br class="">int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode);<br class="">int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags);<br class="">int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode);<br class="">@@ -168,7 +170,7 @@ int amdgpu_xcp_get_inst_details(struct amdgpu_xcp *xcp,<br class=""><br class="">int amdgpu_xcp_dev_register(struct amdgpu_device *adev,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>const struct pci_device_id *ent);<br class="">-void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev);<br class="">+void amdgpu_xcp_dev_deregister(struct amdgpu_device *adev);<br class="">int amdgpu_xcp_open_device(struct amdgpu_device *adev,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> struct amdgpu_fpriv *fpriv,<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> struct drm_file *file_priv);</blockquote></div></blockquote></div><br class=""></body></html>