From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11013381AFC for ; Fri, 10 Jul 2026 19:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783710480; cv=none; b=T/jMa7GWa6ZT+x/rPG4D12F1M1BdCL4jeyXdzopODQYF5izpF9lmUnJ7F0kFW9LuKc37IqFcQp9nnnj0ivq5Olk1PteW1GfeiLGfpS7zaqvnbN5TZ40VJ+UXY1r80ilOL/zbVc0DiUwgzwzKdsUBWPUmWz/5rOKAj1a6RW7//Y0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783710480; c=relaxed/simple; bh=N2xxg4uVrJ9mzA1uIKlRTErHesZ6sMQ31isKaSxZ9SY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pLxHoLH4KbiFos1rzaDesV4TcLXgcWjWhmKl16fZ1e6DxjbqtRYnPWEG6NXoP2GabDhkdebVRp2o2jtSqa7dUXx+RonOwA1EBDXYCi/eUKyfQctk/Lh14jrxQE+m+NM6C8w1rURiJhKO6At+TpPo3zWXcKOwnodPuHTlxp+/MMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qFhv+721; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qFhv+721" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-493c5220cb7so9747885e9.3 for ; Fri, 10 Jul 2026 12:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783710477; x=1784315277; darn=vger.kernel.org; h=content-transfer-encoding:reply-to:content-type:mime-version :references:in-reply-to:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to:content-type; bh=/fM2g6hrSRmJlUHgqQyOMFyX9IRPiNo3S9XYkHpe50w=; b=qFhv+721HdALNLrP9Gw/GOBS59xVcPdFyVpTxcPP4Rr4mtm8YRZJfolPcRiofe6kD1 rHAB3B55eKTH4T6o00ft/N1AafeoMnFRfMojV7qZ8hCrZ4J+gnJOuMC1CHmESvBMDANs zb+BCl7ATLp7lUsxidj7WFd7kb3f3ZphkdxtFDVgOn8fATCpvMAoTnk4P5BXLqfdjltG 4AUSMcTqoPsC5p2mvARDw0TuiYK0Wnb9Wo1wBz04ZR5XCYwx7Mzj0T42LacLeNtFKYjY ofTximhBm08wT3yss8CMppyTpAt7kPYT6dppcnudaj0SUNUYNav8czXqceUdrzbC1rlW UWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783710477; x=1784315277; h=content-transfer-encoding:reply-to:content-type:mime-version :references:in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/fM2g6hrSRmJlUHgqQyOMFyX9IRPiNo3S9XYkHpe50w=; b=SlKzlDa3fTe+gdXh8Hhlz8qa6ZgzlxHJnL/eOc2O9HFU3+s56zZAX8Hh71nJ7YmAoB hklNwx5taW2rCTHN8F4ViTYR+E/1+cqplEb3rKKGZJUcWvmdhuz7UFv+42EQppQNtrSU z/exrAvwFCDOGYx+o6DYVyF4n46UEinqvgVDQbSqDkqDlEOduORwU0f4aWw9Ul5+rp1o ut8LAZz0QjpKtqFoC4VBIfJV33P/DnahucQAqrxYFspiTN21CujYBrRJTbwPNE513shV 6zWzHpqBEb721/WzWGHsBJhVjyNh4hQQQBQINw0B+sChDEMg/D+B33zaET9/Q3TK1iWb 60lQ== X-Forwarded-Encrypted: i=1; AHgh+RrqsaDMzrgV1NELEC1oSLeMrorl9zdLlv4RWxZP1xzrEGINyo2DTA8MoadCycjS0hpejMi0MgvRCRuYQNA=@vger.kernel.org X-Gm-Message-State: AOJu0YyD7oTYoGBJlGHOh4c0wDIDNSk3rJ7NSC5ZaaTlf7HdTcRi0sDU uiS3GiaeprfxhOvRHQ5YcDg/BtXjj7PWHVUhS3jW4a/DLywT0ZVHslXb X-Gm-Gg: AfdE7cki03Kxs4NENOv/tioNPPorzddh9LhLZnTaGqlFmsmVGjpPr50IN6OZLPiWG9N 7c75sTo360ulFWtbhy6JundAtg65oOsARTsr5kOcUw6ZNlEcgS5YoLDGICU8IVdISlWlVbeiRoa gYeq+F5mJNl3yE2fKlEdC7I35tyeAdYVoWb+YTLHdL1WUONTeQnR2o0/gRZ2akGOBksBY19w+q1 ghSD7XBEvD6hRKcC4nB3Bd+jtGBC9aQ9yQzEbVfDOLvVjIpMXzujInoN87lXSFLoTLOHPuTrTOJ 0L9R8nxB/5QQkCB05Yu7Lz5TR8WO22MI3KGX7QsC3tU/l8jKqCI4FwcA9hxFH6Vens+1LFAvnZa nZMjbSzjxyfjh2XSqsNRci50q1RuvjAXEmAUQzjLVJOjkQReuNwJ9wEuaYk+4EEff5UDB1KHB1R I2fyVz50F8RErIFjtip6KskLeahA== X-Received: by 2002:a05:600c:821a:b0:493:bba7:e9f4 with SMTP id 5b1f17b1804b1-493f881ddfbmr1001965e9.18.1783710477135; Fri, 10 Jul 2026 12:07:57 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:154f:ec00:aa08:de24:db33:4496]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493f567eadfsm55000755e9.6.2026.07.10.12.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 12:07:56 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, dakr@kernel.org, ecourtney@nvidia.com, simona@ffwll.ch, matthew.brost@intel.com, nat@pixelcluster.dev, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 02/12] dma-buf/tests: Convert st-dma-resv tests to use dma_resv_alloc Date: Fri, 10 Jul 2026 20:52:42 +0200 Message-ID: <20260710190752.2355-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260710190752.2355-1-christian.koenig@amd.com> References: <20260710190752.2355-1-christian.koenig@amd.com> 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 Reply-To: christian.koenig@amd.com Content-Transfer-Encoding: 8bit Update all test cases in st-dma-resv.c to use the new dma_resv_alloc() API instead of stack-allocating dma_resv objects. This demonstrates the proper usage of the new allocation and reference counting interface. All five test functions now: - Use dma_resv_alloc() to allocate objects - Check for allocation failure with KUNIT_ASSERT_NOT_NULL - Clean up with dma_resv_put() which handles freeing This change also provides better test coverage for the reference counting implementation. Signed-off-by: Christian König Assisted-by: Claude:Sonnet 4 --- drivers/dma-buf/st-dma-resv.c | 90 +++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c index 2c43d2d2b0169..b843d90417822 100644 --- a/drivers/dma-buf/st-dma-resv.c +++ b/drivers/dma-buf/st-dma-resv.c @@ -41,7 +41,7 @@ static struct dma_fence *alloc_fence(void) static void test_sanitycheck(struct kunit *test) { - struct dma_resv resv; + struct dma_resv *resv; struct dma_fence *f; int r; @@ -53,20 +53,22 @@ static void test_sanitycheck(struct kunit *test) dma_fence_signal(f); dma_fence_put(f); - dma_resv_init(&resv); - r = dma_resv_lock(&resv, NULL); + resv = dma_resv_alloc(); + KUNIT_ASSERT_NOT_NULL(test, resv); + + r = dma_resv_lock(resv, NULL); if (r) KUNIT_FAIL(test, "Resv locking failed\n"); else - dma_resv_unlock(&resv); - dma_resv_put(&resv); + dma_resv_unlock(resv); + dma_resv_put(resv); } static void test_signaling(struct kunit *test) { const struct dma_resv_usage_param *param = test->param_value; enum dma_resv_usage usage = param->usage; - struct dma_resv resv; + struct dma_resv *resv; struct dma_fence *f; int r; @@ -75,33 +77,35 @@ static void test_signaling(struct kunit *test) dma_fence_enable_signaling(f); - dma_resv_init(&resv); - r = dma_resv_lock(&resv, NULL); + resv = dma_resv_alloc(); + KUNIT_ASSERT_NOT_NULL(test, resv); + + r = dma_resv_lock(resv, NULL); if (r) { KUNIT_FAIL(test, "Resv locking failed"); goto err_free; } - r = dma_resv_reserve_fences(&resv, 1); + r = dma_resv_reserve_fences(resv, 1); if (r) { KUNIT_FAIL(test, "Resv shared slot allocation failed"); goto err_unlock; } - dma_resv_add_fence(&resv, f, usage); - if (dma_resv_test_signaled(&resv, usage)) { + dma_resv_add_fence(resv, f, usage); + if (dma_resv_test_signaled(resv, usage)) { KUNIT_FAIL(test, "Resv unexpectedly signaled"); goto err_unlock; } dma_fence_signal(f); - if (!dma_resv_test_signaled(&resv, usage)) { + if (!dma_resv_test_signaled(resv, usage)) { KUNIT_FAIL(test, "Resv not reporting signaled"); goto err_unlock; } err_unlock: - dma_resv_unlock(&resv); + dma_resv_unlock(resv); err_free: - dma_resv_put(&resv); + dma_resv_put(resv); dma_fence_put(f); } @@ -111,7 +115,7 @@ static void test_for_each(struct kunit *test) enum dma_resv_usage usage = param->usage; struct dma_resv_iter cursor; struct dma_fence *f, *fence; - struct dma_resv resv; + struct dma_resv *resv; int r; f = alloc_fence(); @@ -119,23 +123,25 @@ static void test_for_each(struct kunit *test) dma_fence_enable_signaling(f); - dma_resv_init(&resv); - r = dma_resv_lock(&resv, NULL); + resv = dma_resv_alloc(); + KUNIT_ASSERT_NOT_NULL(test, resv); + + r = dma_resv_lock(resv, NULL); if (r) { KUNIT_FAIL(test, "Resv locking failed"); goto err_free; } - r = dma_resv_reserve_fences(&resv, 1); + r = dma_resv_reserve_fences(resv, 1); if (r) { KUNIT_FAIL(test, "Resv shared slot allocation failed"); goto err_unlock; } - dma_resv_add_fence(&resv, f, usage); + dma_resv_add_fence(resv, f, usage); r = -ENOENT; - dma_resv_for_each_fence(&cursor, &resv, usage, fence) { + dma_resv_for_each_fence(&cursor, resv, usage, fence) { if (!r) { KUNIT_FAIL(test, "More than one fence found"); goto err_unlock; @@ -158,9 +164,9 @@ static void test_for_each(struct kunit *test) } dma_fence_signal(f); err_unlock: - dma_resv_unlock(&resv); + dma_resv_unlock(resv); err_free: - dma_resv_put(&resv); + dma_resv_put(resv); dma_fence_put(f); } @@ -170,7 +176,7 @@ static void test_for_each_unlocked(struct kunit *test) enum dma_resv_usage usage = param->usage; struct dma_resv_iter cursor; struct dma_fence *f, *fence; - struct dma_resv resv; + struct dma_resv *resv; int r; f = alloc_fence(); @@ -178,25 +184,27 @@ static void test_for_each_unlocked(struct kunit *test) dma_fence_enable_signaling(f); - dma_resv_init(&resv); - r = dma_resv_lock(&resv, NULL); + resv = dma_resv_alloc(); + KUNIT_ASSERT_NOT_NULL(test, resv); + + r = dma_resv_lock(resv, NULL); if (r) { KUNIT_FAIL(test, "Resv locking failed"); goto err_free; } - r = dma_resv_reserve_fences(&resv, 1); + r = dma_resv_reserve_fences(resv, 1); if (r) { KUNIT_FAIL(test, "Resv shared slot allocation failed"); - dma_resv_unlock(&resv); + dma_resv_unlock(resv); goto err_free; } - dma_resv_add_fence(&resv, f, usage); - dma_resv_unlock(&resv); + dma_resv_add_fence(resv, f, usage); + dma_resv_unlock(resv); r = -ENOENT; - dma_resv_iter_begin(&cursor, &resv, usage); + dma_resv_iter_begin(&cursor, resv, usage); dma_resv_for_each_fence_unlocked(&cursor, fence) { if (!r) { KUNIT_FAIL(test, "More than one fence found"); @@ -231,7 +239,7 @@ static void test_for_each_unlocked(struct kunit *test) dma_resv_iter_end(&cursor); dma_fence_signal(f); err_free: - dma_resv_put(&resv); + dma_resv_put(resv); dma_fence_put(f); } @@ -240,7 +248,7 @@ static void test_get_fences(struct kunit *test) const struct dma_resv_usage_param *param = test->param_value; enum dma_resv_usage usage = param->usage; struct dma_fence *f, **fences = NULL; - struct dma_resv resv; + struct dma_resv *resv; int r, i; f = alloc_fence(); @@ -248,24 +256,26 @@ static void test_get_fences(struct kunit *test) dma_fence_enable_signaling(f); - dma_resv_init(&resv); - r = dma_resv_lock(&resv, NULL); + resv = dma_resv_alloc(); + KUNIT_ASSERT_NOT_NULL(test, resv); + + r = dma_resv_lock(resv, NULL); if (r) { KUNIT_FAIL(test, "Resv locking failed"); goto err_resv; } - r = dma_resv_reserve_fences(&resv, 1); + r = dma_resv_reserve_fences(resv, 1); if (r) { KUNIT_FAIL(test, "Resv shared slot allocation failed"); - dma_resv_unlock(&resv); + dma_resv_unlock(resv); goto err_resv; } - dma_resv_add_fence(&resv, f, usage); - dma_resv_unlock(&resv); + dma_resv_add_fence(resv, f, usage); + dma_resv_unlock(resv); - r = dma_resv_get_fences(&resv, usage, &i, &fences); + r = dma_resv_get_fences(resv, usage, &i, &fences); if (r) { KUNIT_FAIL(test, "get_fences failed"); goto err_free; @@ -282,7 +292,7 @@ static void test_get_fences(struct kunit *test) dma_fence_put(fences[i]); kfree(fences); err_resv: - dma_resv_put(&resv); + dma_resv_put(resv); dma_fence_put(f); } -- 2.43.0