Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5483157rwb; Mon, 14 Nov 2022 05:27:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gNaOIUw320L1HttrMtx0AIMeDYGczvP1GyDGDFTFB+xoI9yGm1gJUDl1rDpKbnWN9qg+e X-Received: by 2002:a63:4c26:0:b0:43c:969f:18a7 with SMTP id z38-20020a634c26000000b0043c969f18a7mr11854754pga.12.1668432443920; Mon, 14 Nov 2022 05:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668432443; cv=none; d=google.com; s=arc-20160816; b=PYSel2aNCNhTZ6MV0JCawgbsC99sfQHV4Y4cYCJU6cMmStCF0fhpwiDsZdxDJKVOkg jeRUEZ9gGb/zIisLHEpNDkD/NeubfAuqdLhf4QV6vTvqp+tAErJ+B5QAVzOODmbo11k7 sBd4VXPG0OHiZwjcYuLulsC3JwqLAx1xB2yCSSkvrYKEGBm4Ed8PGx9clB4HgpMOgvOh Z5RvVuVuQuUgrRmcdja4BJ0oko2GuMZgbuBA1gYkUz3XQVyVEfKlP/weY9h1VjM+VWoF bp1tdK1mC9B35qkL4cayA7EpNq3e81xHnDHWwBVQ2A6CZJbcufNUnvBggYWIi4DmjFmt 1lqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=ttCgPrrDy2IICKQrDbdIgY1poygCCyxyyp9/KDQm5eM=; b=qat0uv8HrVOV/H+f0MN7uvnVpz1enwD5HXRawgMDOWqku3RELuIwTb2X2YlimcrAj/ 9A6CQuXWwTf4bsId7mKnPjqBbj3gT1Ls/IJmDThG8sBwld9SJhyx1k8QwGDkm0FvK7+c dgv5cqMEfvAKW+GBVu33AskE9I3cW+H2AeOBtv4FW1CkZpXeBufZm6NW7X9BIkgeaqXB HsOIcKaIN0DwATxOVlrOTx31sP8RiiOoVEsyyo6UT+wW3YYOti7TjF5CMu1DDlkH79zY lRpE1Oloy9Xd71lF7GzKbpgTedNhLH3UvW0TzSCzZ7GaY2qEzbmVd2fetUT/GY999XMt szfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="igy5/gKa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np15-20020a17090b4c4f00b0020055731860si10583612pjb.105.2022.11.14.05.27.01; Mon, 14 Nov 2022 05:27:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="igy5/gKa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237647AbiKNNA1 (ORCPT + 87 others); Mon, 14 Nov 2022 08:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237556AbiKNNA0 (ORCPT ); Mon, 14 Nov 2022 08:00:26 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4235528707 for ; Mon, 14 Nov 2022 05:00:25 -0800 (PST) Received: from [192.168.2.143] (109-252-117-140.nat.spd-mgts.ru [109.252.117.140]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id B13D36601817; Mon, 14 Nov 2022 13:00:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1668430823; bh=I7Rpp4vjv2bTlnUA9D9XQHB0GDaagjm7RngqTua3rzg=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=igy5/gKa0meQyDSAnpXboPvHhDqBpu3sZRKp7BSN63XidUujuFhe/QkCkj9ksZrZl 1wrpJtwHWvo1AMCr/pRckEbsGNXc/0a5FP7uyBXXvQdxC70iHfM1ry/4TZpmZV5GkB vd411yki9WjopoPKbZHSmrIXy6BpkNk09dNRytfwL7ftYwwC8pb7oMg5SMm0w+1GJg aVu4/l7GIxMzwknBylROzQprq5edkl5QeIycQDk4BhoPcBaHScVchEAU8bFtOZWx4d kp6GNPyUprE9FWX1UWlchYvSlP3wXVWanhNfgjPUw4FaZBc/Qknb6jIZYxNj9lOGcK odD971GP7Mj0w== Message-ID: <36fff1bc-1c72-b254-9d7f-4b344cc711d3@collabora.com> Date: Mon, 14 Nov 2022 16:00:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v1] drm/gem-vram: Fix deadlock in drm_gem_vram_vmap() From: Dmitry Osipenko To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?UTF-8?Q?Christian_K=c3=b6nig?= , David Airlie , Daniel Vetter , Dmitry Vyukov Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20221113233850.427704-1-dmitry.osipenko@collabora.com> Content-Language: en-US In-Reply-To: <20221113233850.427704-1-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/14/22 02:38, Dmitry Osipenko wrote: > Recently DRM framebuffer core and all drivers were moved to unlocked > vmapping functions that take the reservation lock. The drm_gem_vram_vmap() > was missed out by accident and now deadlocks drivers that use drm_gem_vram > helpers when framebuffer is updated, like Bochs driver. Remove the locking > from drm_gem_vram_v[un]map() functions to fix the deadlock. > > Reported-by: Dmitry Vyukov > Fixes: 79e2cf2e7a19 ("drm/gem: Take reservation lock for vmap/vunmap operations") > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/drm_gem_vram_helper.c | 18 +++--------------- > 1 file changed, 3 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > index 125160b534be..b6c7e3803bb3 100644 > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > @@ -433,25 +433,19 @@ int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map) > { > int ret; > > - ret = ttm_bo_reserve(&gbo->bo, true, false, NULL); > - if (ret) > - return ret; > + dma_resv_assert_held(gbo->bo.base.resv); > > ret = drm_gem_vram_pin_locked(gbo, 0); > if (ret) > - goto err_ttm_bo_unreserve; > + return ret; > ret = drm_gem_vram_kmap_locked(gbo, map); > if (ret) > goto err_drm_gem_vram_unpin_locked; > > - ttm_bo_unreserve(&gbo->bo); > - > return 0; > > err_drm_gem_vram_unpin_locked: > drm_gem_vram_unpin_locked(gbo); > -err_ttm_bo_unreserve: > - ttm_bo_unreserve(&gbo->bo); > return ret; > } > EXPORT_SYMBOL(drm_gem_vram_vmap); > @@ -467,16 +461,10 @@ EXPORT_SYMBOL(drm_gem_vram_vmap); > void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, > struct iosys_map *map) > { > - int ret; > - > - ret = ttm_bo_reserve(&gbo->bo, false, false, NULL); > - if (WARN_ONCE(ret, "ttm_bo_reserve_failed(): ret=%d\n", ret)) > - return; > + dma_resv_assert_held(gbo->bo.base.resv); > > drm_gem_vram_kunmap_locked(gbo, map); > drm_gem_vram_unpin_locked(gbo); > - > - ttm_bo_unreserve(&gbo->bo); > } > EXPORT_SYMBOL(drm_gem_vram_vunmap); > Applied to drm-misc-next -- Best regards, Dmitry