<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:15pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div dir="auto" style="direction: ltr; margin: 0px; padding: 0px; font-family: sans-serif; font-size: 11pt; color: black; text-align: left;">
Looks good to me.</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Monday, June 7, 2021 8:52:21 PM<br>
<b>To:</b> dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; Pan, Xinhui <Xinhui.Pan@amd.com>; Das, Nirmoy <Nirmoy.Das@amd.com>; Huang, Ray <Ray.Huang@amd.com><br>
<b>Cc:</b> Thomas Hellström <thomas.hellstrom@linux.intel.com><br>
<b>Subject:</b> Re: [PATCH] drm/ttm: fix deref of bo->ttm without holding the lock v2</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
Am 28.05.21 um 15:06 schrieb Thomas Hellström:<br>
><br>
> On 5/28/21 3:00 PM, Christian König wrote:<br>
>> We need to grab the resv lock first before doing that check.<br>
>><br>
>> v2 (chk): simplify the change for -fixes<br>
>><br>
>> Signed-off-by: Christian König <christian.koenig@amd.com><br>
>> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com><br>
><br>
> Hmm, OK, but this doesn't fix the swapped-bo-not-on-lru and <br>
> unpopulating from swap_notify issues. Are you planning a follow up <br>
> patch for those?<br>
<br>
As discussed in a separate thread this needs to be applied as needed <br>
when the DG1 branch is merged.<br>
<br>
Xinhui, Nirmoy, Rui can anybody give be an rb/ab so that I can push this?<br>
<br>
Thanks,<br>
Christian.<br>
<br>
><br>
> Thanks,<br>
><br>
> Thomas<br>
><br>
>> ---<br>
>> drivers/gpu/drm/ttm/ttm_bo.c | 5 ++++-<br>
>> drivers/gpu/drm/ttm/ttm_device.c | 8 +-------<br>
>> 2 files changed, 5 insertions(+), 8 deletions(-)<br>
>><br>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c<br>
>> index cfd0b9292397..ebcffe794adb 100644<br>
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c<br>
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c<br>
>> @@ -1172,7 +1172,10 @@ int ttm_bo_swapout(struct ttm_buffer_object <br>
>> *bo, struct ttm_operation_ctx *ctx,<br>
>> if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked, NULL))<br>
>> return -EBUSY;<br>
>> - if (!ttm_bo_get_unless_zero(bo)) {<br>
>> + if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) ||<br>
>> + bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||<br>
>> + bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED ||<br>
>> + !ttm_bo_get_unless_zero(bo)) {<br>
>> if (locked)<br>
>> dma_resv_unlock(bo->base.resv);<br>
>> return -EBUSY;<br>
>> diff --git a/drivers/gpu/drm/ttm/ttm_device.c <br>
>> b/drivers/gpu/drm/ttm/ttm_device.c<br>
>> index a1dcf7d55c90..3d9c62b93e29 100644<br>
>> --- a/drivers/gpu/drm/ttm/ttm_device.c<br>
>> +++ b/drivers/gpu/drm/ttm/ttm_device.c<br>
>> @@ -143,14 +143,8 @@ int ttm_device_swapout(struct ttm_device *bdev, <br>
>> struct ttm_operation_ctx *ctx,<br>
>> for (j = 0; j < TTM_MAX_BO_PRIORITY; ++j) {<br>
>> list_for_each_entry(bo, &man->lru[j], lru) {<br>
>> - uint32_t num_pages;<br>
>> + uint32_t num_pages = PFN_UP(bo->base.size);<br>
>> - if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) ||<br>
>> - bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||<br>
>> - bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)<br>
>> - continue;<br>
>> -<br>
>> - num_pages = bo->ttm->num_pages;<br>
>> ret = ttm_bo_swapout(bo, ctx, gfp_flags);<br>
>> /* ttm_bo_swapout has dropped the lru_lock */<br>
>> if (!ret)<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>