Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D00DCC07CA9 for ; Tue, 28 Nov 2023 15:25:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0550110E56D; Tue, 28 Nov 2023 15:25:59 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8441410E56D for ; Tue, 28 Nov 2023 15:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701185157; x=1732721157; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=d168n8zWh0HllQmMYOVdN/NLrpY/UHDXaJIOeUe2dkU=; b=d2I1nyYw7a2yYe6iokAJI4cu6BzkfacHpkZrt2krDG2TSzZPdHf9Ck4V JIbZ7QoBfZUro3tF6yFhc+86czjSLsZpedj+n1Ylo+H+pGiLSDDUjnyjE 4KdjvgLApcOFgzwujoh3BrL3dA6Q9O85qab/sZSzqLi/lG5Z7PCWh6tML phCSXNTqjY1eXXmyKNUc4CPWgYRh002Mn5BPumjwYOlXfHCIYsfW19vGN 0dyqsJdKuSugBet6IG/eUycaiZkyhJrRjsp35r7H+iaqwOODmJQNnpIQc 35BQ3ZqhhKv+Kt380H4wToZ5/wNS7iQiOTdfhlQ5eRTqkAC+NpqZxLwDq w==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="377969261" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="377969261" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 07:25:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="718412782" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="718412782" Received: from sgruszka-mobl.ger.corp.intel.com (HELO intel.com) ([10.252.59.234]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 07:25:55 -0800 Date: Tue, 28 Nov 2023 16:25:52 +0100 From: Andi Shyti To: Karolina Stolarek Subject: Re: [PATCH v7 3/8] drm/ttm/tests: Add tests for ttm_bo functions Message-ID: References: <61e723d67ebf8eaec226eea176fa19da1994a3b7.1700207346.git.karolina.stolarek@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <61e723d67ebf8eaec226eea176fa19da1994a3b7.1700207346.git.karolina.stolarek@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amaranath Somalapuram , Nirmoy Das , Christian =?iso-8859-15?Q?K=F6nig?= , dri-devel@lists.freedesktop.org, Andi Shyti Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Karolina, > +/* > + * A test case heavily inspired by ww_test_edeadlk_normal(). Checks > + * if -EDEADLK is properly propagated by ttm_bo_reserve() > + */ > +static void ttm_bo_reserve_deadlock(struct kunit *test) > +{ > + struct ttm_buffer_object *bo1, *bo2; > + struct ww_acquire_ctx ctx1, ctx2; > + bool interruptible = false; > + bool no_wait = false; > + int err; > + > + bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); > + bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); > + > + ww_acquire_init(&ctx1, &reservation_ww_class); > + mutex_lock(&bo2->base.resv->lock.base); > + > + /* The deadlock will be caught by WW mutex, don't warn about it */ > + lock_release(&bo2->base.resv->lock.base.dep_map, 1); OK... by motidfying the lock map, you avoid lockdep to complain. > + bo2->base.resv->lock.ctx = &ctx2; > + ctx2 = ctx1; > + ctx2.stamp--; /* Make the context holding the lock younger */ > + err = ttm_bo_reserve(bo1, interruptible, no_wait, &ctx1); > + KUNIT_ASSERT_EQ(test, err, 0); > + > + err = ttm_bo_reserve(bo2, interruptible, no_wait, &ctx1); > + KUNIT_ASSERT_EQ(test, err, -EDEADLK); > + > + dma_resv_unlock(bo1->base.resv); > + ww_acquire_fini(&ctx1); > +} so... what you're doing here is swapping the lock timing and catch and report the deadlock... Could you please add some more comment to better explain the idea behind this test and its implementation? Anyway, looks good to me and you can add my: Reviewed-by: Andi Shyti Andi