From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D3C6481DD; Wed, 5 Mar 2025 17:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741197262; cv=none; b=jlrXVvYqOhMII2eJG48k8UEmAu4JeYiDUZ13XHe1Cgbx7k6+71cfujgt/S9ytIPpzMdi4Iqn3e/vd0+cMLBljIhy5jpneroi4FfOJsA8H9AOk0KIO8bV4bzkyKNNR6KjlGwHHqgOpy2ZP+WcJQt+w5N+DOVfutehTEYKcKRZjxI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741197262; c=relaxed/simple; bh=sXqw6DldVzYdPB3r3XrdNLoRe0hWHnY8LvoAofpWwmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dyzZnvDBDEgp34Vt6fQ4JFJWeS9k8FT4HVxJFrIr6vgxfYnlcWnBl0nKX6Bb0iBu46Nk+bGsUTcmDdUccZCY4bwnlF4vZE9lhWZDIwv3cQgbsVnVe/i5y7RMp8hN9h5ynJvhFbiYb2me7zUAP1L9CFhH08Aqk/A87/WneX3KwV8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kZZm9AIb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kZZm9AIb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A107C4CED1; Wed, 5 Mar 2025 17:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741197262; bh=sXqw6DldVzYdPB3r3XrdNLoRe0hWHnY8LvoAofpWwmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZZm9AIb7daFH0dUIKa4eot5shmO5j+Jl1wsCsTaymApIIzTNfXdXMgk21nqX5DT3 DCB/gZfrrUwXF/MgQwUdoN73X+Cw7jj/MBm72Cgrs0vxDrBvXUTgDRM/bwmEm+w+Et An0BgjDfGOGjU/+kO4PoJ5IWLdvqXwzeXWJ9eRkI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Hildenbrand , Alistair Popple , Danilo Krummrich , Sasha Levin Subject: [PATCH 6.1 068/176] nouveau/svm: fix missing folio unlock + put after make_device_exclusive_range() Date: Wed, 5 Mar 2025 18:47:17 +0100 Message-ID: <20250305174508.187112142@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305174505.437358097@linuxfoundation.org> References: <20250305174505.437358097@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand [ Upstream commit b3fefbb30a1691533cb905006b69b2a474660744 ] In case we have to retry the loop, we are missing to unlock+put the folio. In that case, we will keep failing make_device_exclusive_range() because we cannot grab the folio lock, and even return from the function with the folio locked and referenced, effectively never succeeding the make_device_exclusive_range(). While at it, convert the other unlock+put to use a folio as well. This was found by code inspection. Fixes: 8f187163eb89 ("nouveau/svm: implement atomic SVM access") Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple Tested-by: Alistair Popple Signed-off-by: Danilo Krummrich Link: https://patchwork.freedesktop.org/patch/msgid/20250124181524.3584236-2-david@redhat.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_svm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index be6674fb1af71..d0bff13ac758d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -592,6 +592,7 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm, unsigned long timeout = jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT); struct mm_struct *mm = svmm->notifier.mm; + struct folio *folio; struct page *page; unsigned long start = args->p.addr; unsigned long notifier_seq; @@ -618,12 +619,16 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm, ret = -EINVAL; goto out; } + folio = page_folio(page); mutex_lock(&svmm->mutex); if (!mmu_interval_read_retry(¬ifier->notifier, notifier_seq)) break; mutex_unlock(&svmm->mutex); + + folio_unlock(folio); + folio_put(folio); } /* Map the page on the GPU. */ @@ -639,8 +644,8 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm, ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args, size, NULL); mutex_unlock(&svmm->mutex); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); out: mmu_interval_notifier_remove(¬ifier->notifier); -- 2.39.5