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 5A5564502F; Thu, 17 Apr 2025 18:47:23 +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=1744915643; cv=none; b=OCYl3VP0ImsIXYsyy90z+DzvvDuS+jFdR5o3q844Srn+SPPpeMPVNhIIUoSMX3ryZMnX5hO3Imkae0YW+LeyiXzI+euh1XNbymPGt+RmFlGMl9WOpsC5ztasGjS9pG3UsSz1vTkMv9SAHnJtN2dUiaOKaZvnTpYJ4u7Hh9YHjYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744915643; c=relaxed/simple; bh=Pw5Ea5rXVtB3/Lpjx35RcCjFx/rCFKaeIFU+/lbNfFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rc1i/i4rGDMiTnwEKmGawoqASFOno2yUQG/h4hjVf8JrazN4p49HWBz3WICAvXLgXM+H87qAozsiVue18kBER+GcrOVIGo4mQLen6j/ziUGjjmXwMD2Tic70kfT3qTgcJhC/Y1noGPsyZUNL+wXzrBVX/SEDe0kDTIuAYGKzxfg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LqIh65Nx; 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="LqIh65Nx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1619C4CEE4; Thu, 17 Apr 2025 18:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744915643; bh=Pw5Ea5rXVtB3/Lpjx35RcCjFx/rCFKaeIFU+/lbNfFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LqIh65Nxy3pK02wLgpYm2zOVnmQLFOx6hkc/jSsc+RrM+my9MAphvXU2V6Pa2mNDX Tmc481MnhiUhJyC0FP9/FIke4Ipx33Zb3PEOO+3C6A7nUNZRst6TWoKjkgs0GeSSYM Gm0Aa5x0iXga8v9ZbwowUNjQ6prLsWwbW8ZwPtI4= 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.12 153/393] drm/amdgpu: grab an additional reference on the gang fence v2 Date: Thu, 17 Apr 2025 19:49:22 +0200 Message-ID: <20250417175113.741617806@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175107.546547190@linuxfoundation.org> References: <20250417175107.546547190@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-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 96845541b2d25..31d4df9688981 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -6575,18 +6575,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