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 5B4D13EA71; Wed, 21 Feb 2024 13:13:01 +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=1708521181; cv=none; b=htOEq0Swh/SicwN4EcoOqGcj7gdlyzl9Br3T+DhOqIvWn0E04tZ/LK+6koXWq6XSU8Ume7fJXieObKjY85BvNea80PGeLyGecvqb1M/jfrRZ4m7ZGN9cd0AVPf6uQUovi9QzCMHrZAgjJ9SrEdeOtB0ahkDt4qbsvHHvGQcOnP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521181; c=relaxed/simple; bh=bBzYYVawFcMEN75xIRIwx47zSFgvhpjF7Nn/zrW6UKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lEvsq5FEk2j2KeuR2iFA3ayssni3woNWVO7tJSG7whxK5JOff+mPb77RTP7Y03h+XrUSjmZS9R3A1SNmFgk6EyR6pkTqZEvwNNtEpmRr+G08FZ5OYKlBrD6QZwqiyxFnqN2pWMokAefZAjHgbU+DZ9MO7c4WE3cEJ6xomRo94wU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Kj0BK/LX; 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="Kj0BK/LX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B8FC433C7; Wed, 21 Feb 2024 13:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708521181; bh=bBzYYVawFcMEN75xIRIwx47zSFgvhpjF7Nn/zrW6UKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kj0BK/LXS1516dRys0McEBanheauaH8Ers6CZSDJ1RuezLHp1BwfsBqyKNQVF7xL3 3NPNKdFp6dRwjPAe84o3lQLFtEUKn6nd20eJxgn/61z2ShV804zNcoJGniFGmXUNm0 KIHFPIxP1cdrm7yrbo0NvD+PWQU/rHc796g3BCjA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Javier Martinez Canillas Subject: [PATCH 4.19 041/202] drm: Dont unref the same fb many times by mistake due to deadlock handling Date: Wed, 21 Feb 2024 14:05:42 +0100 Message-ID: <20240221125933.120874811@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125931.742034354@linuxfoundation.org> References: <20240221125931.742034354@linuxfoundation.org> User-Agent: quilt/0.67 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ville Syrjälä commit cb4daf271302d71a6b9a7c01bd0b6d76febd8f0c upstream. If we get a deadlock after the fb lookup in drm_mode_page_flip_ioctl() we proceed to unref the fb and then retry the whole thing from the top. But we forget to reset the fb pointer back to NULL, and so if we then get another error during the retry, before the fb lookup, we proceed the unref the same fb again without having gotten another reference. The end result is that the fb will (eventually) end up being freed while it's still in use. Reset fb to NULL once we've unreffed it to avoid doing it again until we've done another fb lookup. This turned out to be pretty easy to hit on a DG2 when doing async flips (and CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y). The first symptom I saw that drm_closefb() simply got stuck in a busy loop while walking the framebuffer list. Fortunately I was able to convince it to oops instead, and from there it was easier to track down the culprit. Cc: stable@vger.kernel.org Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20231211081625.25704-1-ville.syrjala@linux.intel.com Acked-by: Javier Martinez Canillas Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_plane.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1183,6 +1183,7 @@ retry: out: if (fb) drm_framebuffer_put(fb); + fb = NULL; if (plane->old_fb) drm_framebuffer_put(plane->old_fb); plane->old_fb = NULL;