<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月6日 14:51,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/5/2025 8:15 AM, 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="">Introduce new interface amdgpu_xcp_drm_dev_free() to free a specific<br class="">drm_device crreated by amdgpu_xcp_drm_dev_alloc(), which will be used<br class="">to do error recovery.<br class=""><br class="">Signed-off-by: Jiang Liu <<a href="mailto:gerry@linux.alibaba.com" class="">gerry@linux.alibaba.com</a>><br class="">---<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c     | 11 +++-<br class="">drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h     |  1 +<br class="">drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c | 70 +++++++++++++++++----<br class="">drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h |  1 +<br class="">4 files changed, 70 insertions(+), 13 deletions(-)<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..401fbaa0b6b8 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="">@@ -359,6 +359,8 @@ 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="">@@ -376,12 +378,19 @@ 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>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>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>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><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>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=""><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..cd06a4a232be 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="">diff --git a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br class="">index faed84172dd4..9058d71b4756 100644<br class="">--- a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br class="">+++ b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c<br class="">@@ -45,18 +45,26 @@ static const struct drm_driver amdgpu_xcp_driver = {<br class=""><br class="">static int8_t pdev_num;<br class="">static struct xcp_device *xcp_dev[MAX_XCP_PLATFORM_DEVICE];<br class="">+static struct mutex xcp_mutex;<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="">I think this needs to be static DEFINE_MUTEX(xcp_mutex).</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="">int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)<br class="">{<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>struct platform_device *pdev;<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>struct xcp_device *pxcp_dev;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>char dev_name[20];<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span>int ret;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>int ret, index;<br class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>mutex_lock(&xcp_mutex);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>ret = -ENODEV;<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="">Preference would be do this inside the below if() to associate the error</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 the condition.</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>if (pdev_num >= MAX_XCP_PLATFORM_DEVICE)<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return -ENODEV;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto out_unlock;<br class=""><br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", pdev_num);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>for (index = 0; index < MAX_XCP_PLATFORM_DEVICE; index++) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (!xcp_dev[index])<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="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>}<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", index);<br class=""><span class="Apple-tab-span" style="white-space: pre;">      </span>pdev = platform_device_register_simple(dev_name, -1, NULL, 0);<br class=""><span class="Apple-tab-span" style="white-space: pre;">       </span>if (IS_ERR(pdev))<br class=""><span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return PTR_ERR(pdev);<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="">Seems mutex is left locked here.</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>Will fixed in next version:)</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="">@@ -72,10 +80,11 @@ int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto out_devres;<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>xcp_dev[pdev_num] = pxcp_dev;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>xcp_dev[pdev_num]->pdev = pdev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>xcp_dev[index] = pxcp_dev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>xcp_dev[index]->pdev = pdev;<br class=""><span class="Apple-tab-span" style="white-space: pre;">      </span>*ddev = &pxcp_dev->drm;<br class=""><span class="Apple-tab-span" style="white-space: pre;">       </span>pdev_num++;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>mutex_unlock(&xcp_mutex);<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">   </span>return 0;<br class=""><br class="">@@ -83,21 +92,58 @@ int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>devres_release_group(&pdev->dev, NULL);<br class="">out_unregister:<br class=""><span class="Apple-tab-span" style="white-space: pre;">   </span>platform_device_unregister(pdev);<br class="">+out_unlock:<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>mutex_unlock(&xcp_mutex);<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">   </span>return ret;<br class="">}<br class="">EXPORT_SYMBOL(amdgpu_xcp_drm_dev_alloc);<br class=""><br class="">-void amdgpu_xcp_drv_release(void)<br class="">+static void amdgpu_xcp_drm_dev_destroy(int index)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>struct platform_device *pdev;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>pdev = xcp_dev[index]->pdev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>devres_release_group(&pdev->dev, NULL);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>platform_device_unregister(pdev);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span>xcp_dev[index] = NULL;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>pdev_num--;<br class="">+}<br class="">+<br class="">+void amdgpu_xcp_drm_dev_free(struct drm_device *ddev)<br class="">{<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>for (--pdev_num; pdev_num >= 0; --pdev_num) {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span>struct platform_device *pdev = xcp_dev[pdev_num]->pdev;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>int index;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>struct xcp_device *pxcp_dev;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>if (ddev == NULL)<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><span class="Apple-tab-span" style="white-space: pre;">  </span>devres_release_group(&pdev->dev, NULL);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-tab-span" style="white-space: pre;">  </span>platform_device_unregister(pdev);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>xcp_dev[pdev_num] = NULL;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span>pxcp_dev = container_of(ddev, struct xcp_device, drm);<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>mutex_lock(&xcp_mutex);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>for (index = 0; index < MAX_XCP_PLATFORM_DEVICE; index++) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (xcp_dev[index] == pxcp_dev) {<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>amdgpu_xcp_drm_dev_destroy(index);<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="">+<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="">+<span class="Apple-tab-span" style="white-space: pre;">   </span>mutex_unlock(&xcp_mutex);<br class="">+}<br class="">+EXPORT_SYMBOL(amdgpu_xcp_drm_dev_free);<br class="">+<br class="">+void amdgpu_xcp_drv_release(void)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span>int index;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>mutex_lock(&xcp_mutex);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>for (index = 0; index < MAX_XCP_PLATFORM_DEVICE; index++) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (xcp_dev[index]) {<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>WARN_ON(xcp_dev[index]);<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="">Why is this WARN check needed? There is already a if() check for valid</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="">index.</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="">Also, would suggest to separate out amdgpu_xcp.c from xcp_drv.c. xcp_drv</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="">introducing a new interface may be kept in a separate patch.</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>With new implementation, all xcp devices should have already be removed when amdgpu_xcp_drv_release() gets called,</div>So hope to verify whether it works as expected.</div><div><br class=""></div><div>Thanks!<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=""><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="">+<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>amdgpu_xcp_drm_dev_destroy(index);<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="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>pdev_num = 0;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span>WARN_ON(pdev_num != 0);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>mutex_unlock(&xcp_mutex);<br class="">}<br class="">EXPORT_SYMBOL(amdgpu_xcp_drv_release);<br class=""><br class="">diff --git a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h<br class="">index c1c4b679bf95..580a1602c8e3 100644<br class="">--- a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h<br class="">+++ b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h<br class="">@@ -25,5 +25,6 @@<br class="">#define _AMDGPU_XCP_DRV_H_<br class=""><br class="">int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev);<br class="">+void amdgpu_xcp_drm_dev_free(struct drm_device *ddev);<br class="">void amdgpu_xcp_drv_release(void);<br class="">#endif /* _AMDGPU_XCP_DRV_H_ */</blockquote></div></blockquote></div><br class=""></body></html>