Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp951673lqp; Thu, 23 May 2024 05:14:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVSC6IrzN8r5Q2Gp40DHd3MEkn+3K/26UuZKcQHlagj35QdfU8QKLTwuxlYOJCeaXuTpXJpLrOIyE68yEm02j0smZNqSQ+/ej0+kaBQeg== X-Google-Smtp-Source: AGHT+IHBP9bUCf9qMIyIzP+mc1uUKR8m8sfOWVHz6wDVI7OO2okkxSME23ijq4swC7GMBnSQkZSu X-Received: by 2002:ac2:551d:0:b0:523:b068:a6d4 with SMTP id 2adb3069b0e04-526c0a68fa1mr3756962e87.45.1716466456786; Thu, 23 May 2024 05:14:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716466456; cv=pass; d=google.com; s=arc-20160816; b=iFW+BkHIxo4dMlTvB8XMif9CzoNfPnyNLxsI8pvAPR0ZPtLSoLib432NKw8dsEBUNn JAzoH8G7Rfs3ARdqS1/ORVm9PkQfEPmxYzDP+pYzGO3xoWUPvUIZFPbcChjdY44kjAxv w+1oAr0/3DEOyNu/g4eLLH5royLEQ9WcbFf/fETuGZ0Xz7/U6JfBC0itsuxobb3PzH+f r5uCh7EDQXcvvmkjeCKZ7WfndsIrEmdkulrsmN2w9/TS/9wO/2qWuXxC9ES9q8NZMeKn lJyWwbnXh24dioK0I3Kaa1diJ2B9M0RdqUjFcbeUOLcdRv1w5k00B/bwjRzoBbIahD07 8oFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=JCO0IQuzh9+zBSwMxk5YaHle9zHRxpLhKeQpHE0g0a4=; fh=PUgK/+R5zKTCmY4zd/8A6YXkla42L9Z29s0jfB5hlew=; b=RGNUomgVvF6WHJGbY/+MwwCbFPxc762bVGGThEUrRv2KeP0Fr2PCvKTcagJp9V6UKI agqbwczQzZOCCskOO+/M7h+pLkv+gIrrnJAxIs4e8YjeuXXOMySIe9rdiQpGcQHzlsL8 Gz096kD8YBQ2R/rOkITubsucbEQkgdW4Opywvfcu8XWSrqlIdKYrJB8L5pUEFrTz/Mof s24JV/b5tx/LjpKVGSlhBXhjsYY5MHzRsmn8VoBJBQh8EDWnWMQ+4215HUws4AbtyDJG m7XVdThMpFu4Lr2fI9kzJQ2b82PWNHLmSTGJaUOZrecwBI1h1PEKZKa1XnijBonXp3B1 83hA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LsRnHD7U; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-187446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17bb1a78si1694811166b.697.2024.05.23.05.14.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LsRnHD7U; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-187446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7BFB51F21801 for ; Thu, 23 May 2024 12:14:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E7BC144D10; Thu, 23 May 2024 12:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LsRnHD7U" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 D84CD149E08; Thu, 23 May 2024 12:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716466396; cv=none; b=SIib0OWi2eBukFHvGpOJjhXM69MFIfOF0OLTeMc8SfoTinW8AE2O2ee4JCIvJ7SQDXy0FyerRDLbjYI7pet+S9nGRRAFnvX4FELWqDnEm1mSi85mtLxJL99JUXb9nwbqO/kwflGzZ3Jl2c+ftXjBBCyyMmptBsKw9fY9OIwe0eI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716466396; c=relaxed/simple; bh=133f/ppm7e5WBFptxyFQbVG8EMvUy33o+cg2kVvmScs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q45WOyzfEXYSlw+YG3d1bMsNEWRFSetw5HgAWuCgMS38yyAHUV5wSLSKNTbTrAks84N7VXRd0NrlZRRTo/lDGf9u1xX10TXCc5Sbigh14nW+6wJrRlhKLRBtcIxWNb6pHh526b4ujDGxCahv8oMQqc4d1/OosR66U15F841Ftu0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=LsRnHD7U; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1716466392; bh=133f/ppm7e5WBFptxyFQbVG8EMvUy33o+cg2kVvmScs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LsRnHD7Uog2ITakq18wy7ygWug9EUT5qq3HeLJPOLkNCEWXIWvV3jEGvKsSXitW+L +Q0s/o0GlcJv03qWXltfU4ZIym4/y+4S6bo/4euqa865crfewK2SsJTDcIg7cnnHtw 2pqgNAqpF3qEH0uZ00g9b0ouzJcI+qPVx613LpkpINUCHcAjq2h51ZXh9ZbPIWKGhD aTK9hMQYrG0cJKzQopG+cFrea36aO3ueov7NiMz3A2uRovuGwfbVuNCcWbvu0fqsnk utNHZm4Aio+FkPH03/08V8ZwbzBhDvAmIbOvJ8M5hGHwQQDLPMowTlweFEkRqhLxrT c1Evhc1QMnppQ== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E5B303782039; Thu, 23 May 2024 12:13:11 +0000 (UTC) Date: Thu, 23 May 2024 14:13:10 +0200 From: Boris Brezillon To: =?UTF-8?B?QWRyacOhbg==?= Larumbe Cc: Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sumit Semwal , Christian =?UTF-8?B?S8O2bmln?= , Dmitry Osipenko , Zack Rusin , kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: Re: [PATCH v4 1/3] drm/panfrost: Fix dma_resv deadlock at drm object pin time Message-ID: <20240523141310.0b12c83c@collabora.com> In-Reply-To: <20240523113236.432585-2-adrian.larumbe@collabora.com> References: <20240523113236.432585-1-adrian.larumbe@collabora.com> <20240523113236.432585-2-adrian.larumbe@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 23 May 2024 12:32:17 +0100 Adri=C3=A1n Larumbe wrote: > When Panfrost must pin an object that is being prepared a dma-buf > attachment for on behalf of another driver, the core drm gem object pinni= ng > code already takes a lock on the object's dma reservation. >=20 > However, Panfrost GEM object's pinning callback would eventually try taki= ng > the lock on the same dma reservation when delegating pinning of the object > onto the shmem subsystem, which led to a deadlock. >=20 > This can be shown by enabling CONFIG_DEBUG_WW_MUTEX_SLOWPATH, which throws > the following recursive locking situation: >=20 > weston/3440 is trying to acquire lock: > ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_sh= mem_pin+0x34/0xb8 [drm_shmem_helper] > but task is already holding lock: > ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_pi= n+0x2c/0x80 [drm] >=20 > Fix it by replacing drm_gem_shmem_pin with its locked version, as the lock > had already been taken by drm_gem_pin(). >=20 > Cc: Thomas Zimmermann > Cc: Dmitry Osipenko > Cc: Boris Brezillon > Cc: Steven Price > Fixes: a78027847226 ("drm/gem: Acquire reservation lock in drm_gem_{pin/u= npin}()") > Signed-off-by: Adri=C3=A1n Larumbe Reviewed-by: Boris Brezillon > --- > drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/pa= nfrost/panfrost_gem.c > index d47b40b82b0b..8e0ff3efede7 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_gem.c > +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c > @@ -192,7 +192,7 @@ static int panfrost_gem_pin(struct drm_gem_object *ob= j) > if (bo->is_heap) > return -EINVAL; > =20 > - return drm_gem_shmem_pin(&bo->base); > + return drm_gem_shmem_pin_locked(&bo->base); > } > =20 > static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_obj= ect *obj)