Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2386931ioo; Sat, 28 May 2022 12:03:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeE8WzSphnVXLi3V2fx3j3VLWjQTZFJNdz6mDa4TM6kLtsaOR37eA0Z3n1HBhy/CrCncAZ X-Received: by 2002:a17:902:db11:b0:163:53b3:493a with SMTP id m17-20020a170902db1100b0016353b3493amr20086779plx.96.1653764597074; Sat, 28 May 2022 12:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653764597; cv=none; d=google.com; s=arc-20160816; b=RmGa4GYL3aDqVIbFgb25kbFBleuBNP63EGr06XLe1l3ofGX1cd9bZNXBf9b+m3k+GN aHFJsAPkxXC2qF3Wj3uAg5aI22if1t4FKSfLSasg3NKfrD8hc06B8aIGaBxKrc0WaxLQ GLyIXOSMGrAcbfc+mRJyKmcBGiFkWV8nDDOIWrtwlcHTS/j0Nl3PBqzTFSHHdG5XN6Xs sHSQ4p3wm+oE7MjntkVWA/yc4r4+kgLgUuo6bSjpxum7yO+V4UPg+dZClOotVHu3b34q BWZ2IQGjIIRNN0pyMBiwlWlI0aKd0DmSgIqL0jX98OC7ZjJPAHW8/7c/0dFB8DMgzyEV lUQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EHxl3LtOQ8hAyAwU2HZjyP0k0y3hWSY1IfNDf4exHc4=; b=grnzN+KNDOSdgaCCJsjwPsvuJeOHm9RKDAiT2tAEio/JUjZKgpUsm4RuYzUSfozxvw /2dI/e7biLiRni487QEMkL3QkcpKobX09aYJ0RMZ35tMC0udPboS2pfT89eZTHd+wfsp v4+JhkOD96SgalCy+oZGT4mVN2pXAPNp1SLjmNGFJukRSO2PleRDXgsMB5MnCg2rN8yN xeEy2Q/dI9/YRC7IklCVmacMzMgKPxM/o1nZSbpUult7Ww/+r1Ledb6QmOQ1VOodX7yB jKW4ibQQwpmounCZ7TQyTkvM60DPuA/fEq+kaXC8lvVjOso+64OOLe6qs4VLUVirc5jW 2ewg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=denQs0WI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c6-20020a170902d48600b00162099e48ebsi3031487plg.287.2022.05.28.12.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:03:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=denQs0WI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2EFD3BFAD; Sat, 28 May 2022 11:44:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349550AbiEZXyT (ORCPT + 99 others); Thu, 26 May 2022 19:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349532AbiEZXyO (ORCPT ); Thu, 26 May 2022 19:54:14 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 660D86D946; Thu, 26 May 2022 16:54:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 59AAC1F40878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653609252; bh=hQQeDrOOx+1JCRSXi7OKWs0mUskygEo1Q1XD4BRlE0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=denQs0WIZ08+E6kW9JjgKq0KczlpedRQBync8cvXdUc/idQKbB6uafoeg89eoZRXX fd0O+TV9m9gN9MnlfFYQ6hiAqeG7PjzLToZEKGh3pruZK5PnOBbvPCW+UXHPzaJVaA Bgigrnz4HvCZBsAm0uP0lmQWOPKJiQb56yz07hyFtvKMbCGXvoUHcMfIWTmDFJ1YI8 moEUQReSjPpVzp90kx4McPoRvrc/gFUZfdb/ufWZd2v6Zsy7YknSLXuDteEl4Fh2Rh lP82QwUta8X7dfbA7HPR3fq60l8kPX0Zxm9aa5TMUQOCc/1UKNp1W8HRCOYp01Cbuo VSTuDPrFCedhw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com Subject: [PATCH v6 01/22] drm/gem: Properly annotate WW context on drm_gem_lock_reservations() error Date: Fri, 27 May 2022 02:50:19 +0300 Message-Id: <20220526235040.678984-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220526235040.678984-1-dmitry.osipenko@collabora.com> References: <20220526235040.678984-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 Use ww_acquire_fini() in the error code paths. Otherwise lockdep thinks that lock is held when lock's memory is freed after the drm_gem_lock_reservations() error. The WW needs to be annotated as "freed", which fixes the noisy "WARNING: held lock freed!" splat of VirtIO-GPU driver with CONFIG_DEBUG_MUTEXES=y and enabled lockdep. Cc: stable@vger.kernel.org Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index eb0c2d041f13..86d670c71286 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1226,7 +1226,7 @@ drm_gem_lock_reservations(struct drm_gem_object **objs, int count, ret = dma_resv_lock_slow_interruptible(obj->resv, acquire_ctx); if (ret) { - ww_acquire_done(acquire_ctx); + ww_acquire_fini(acquire_ctx); return ret; } } @@ -1251,7 +1251,7 @@ drm_gem_lock_reservations(struct drm_gem_object **objs, int count, goto retry; } - ww_acquire_done(acquire_ctx); + ww_acquire_fini(acquire_ctx); return ret; } } -- 2.35.3