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 9510A256C77; Thu, 17 Apr 2025 18:24:24 +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=1744914264; cv=none; b=SVBOZJBr3wteNOSN+zow5seVqpf4Ix+Q3SoEEdSUjLwvc+eTkqvcoVQag9FTXqvjvd9pEQPLIxzbKnSOL8kwPquMslYfdo7UKi8/4HVhWxBZp5vWRE0zwE+7en5h/q3KJxW/iYsfXtnFQBW6btdUn8BYuBEsibmRYX7ismJlD1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744914264; c=relaxed/simple; bh=l6cM5aegzrWbE5XLIoF6lZBeyk92a4YKW1e8uMEzEdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J6xP5Ps+/hynd0PBRgQ7MXocpDVakQHEwOO0yA3b0ZbT5ptqVCG9lY/FQbfbrULqRghRIpzDZNJ1uOEC8KP8LRptpasu6viPVzAE1I0dr4ODN0GdUgb19ep+/wUguvIiH77+lJBWDQygsR13nDrVFE/Y1CGWCEHS2Pf2TyaPQ8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=b3t+jOwP; 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="b3t+jOwP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05817C4CEE4; Thu, 17 Apr 2025 18:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744914264; bh=l6cM5aegzrWbE5XLIoF6lZBeyk92a4YKW1e8uMEzEdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b3t+jOwPz3qVo4IIwaZNYmjtCpoSTn9+UHPI4m04o0QtkdD1qrFA4YqANsIYLIc01 nQ34qUzQg6FSigrx9I8Yw8ojIF6BU9iMTVt3JBB6aeJ36nGc/lPlFS8D86oSq9jzXR /ZTyvHcNIeIRQHAeCFhHaDQ9siM23PAYbH/WEKKs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20K=C3=B6nig?= , Srinivasan Shanmugam , Alex Deucher , Sasha Levin Subject: [PATCH 6.13 160/414] drm/amdgpu: grab an additional reference on the gang fence v2 Date: Thu, 17 Apr 2025 19:48:38 +0200 Message-ID: <20250417175117.873676815@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175111.386381660@linuxfoundation.org> References: <20250417175111.386381660@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian König [ Upstream commit 0d9a95099dcb05b5f4719c830d15bf4fdcad0dc2 ] We keep the gang submission fence around in adev, make sure that it stays alive. v2: fix memory leak on retry Signed-off-by: Christian König Acked-by: Srinivasan Shanmugam Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index cb9e627b407d9..d29c6716af31a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -6707,18 +6707,26 @@ struct dma_fence *amdgpu_device_switch_gang(struct amdgpu_device *adev, { struct dma_fence *old = NULL; + dma_fence_get(gang); do { dma_fence_put(old); old = amdgpu_device_get_gang(adev); if (old == gang) break; - if (!dma_fence_is_signaled(old)) + if (!dma_fence_is_signaled(old)) { + dma_fence_put(gang); return old; + } } while (cmpxchg((struct dma_fence __force **)&adev->gang_submit, old, gang) != old); + /* + * Drop it once for the exchanged reference in adev and once for the + * thread local reference acquired in amdgpu_device_get_gang(). + */ + dma_fence_put(old); dma_fence_put(old); return NULL; } -- 2.39.5