From patchwork Wed Nov 23 15:25:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13053848 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 94EE2C4332F for ; Wed, 23 Nov 2022 15:29:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3738310E580; Wed, 23 Nov 2022 15:29:20 +0000 (UTC) Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id A04DB10E580 for ; Wed, 23 Nov 2022 15:29:13 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 7D47C2B069B4; Wed, 23 Nov 2022 10:29:10 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 23 Nov 2022 10:29:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1669217350; x= 1669224550; bh=u+1ymrAP+Uo/CwDGmXOacIfISOEP++Rwn9qJQbSVq8E=; b=N AYi2/vcBLMDWtLcwQpME0YLmuCi9gO7LsXeCue+VQagjDk5HrYfyp4b8CMi4w00Z 29LsG7Hidtz2Aj3+4qtkKuG6ckk73eZRiqWkEIL3NUGRQE2FJb+9WhvmE6MJaLa0 jr8ZzP7WUkpLf34Tx4ULGV9RlqYQId6MXhGtKeiKDkTJM4X2tPTu7HpSh5HW7xNr tHQnI9Uth/aM5y+TjnvGJuJDM3R9hgukxgbIJKVGGmPGnClzod+B1rU5++wFZm8O njtADye0efyK8UESnJFARByB+MZoR81y4erJtAmcCF1fI0DwrO5YvdCARYUM+ia9 qLwyVrsUXdHLYnoxt2Q+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1669217350; x= 1669224550; bh=u+1ymrAP+Uo/CwDGmXOacIfISOEP++Rwn9qJQbSVq8E=; b=c Lt3gFaILhOvjOrVYOdI+Wgg/D7a8koC99CI0KJnHxGhvfPt+8XgeIldOaNFJg0Ig JDmpt9qfY501ux2kvQzrA/xNzCJxfvfn+oiWI+Dq8dQFHyi1G90p/42KCXVseEfm IQgdJjb6JtAgq0V+gdYbzRLSSHaeWxp+Ol1q5VGcPMupW0nZ1bn/O6Wn1hEFTdrK 7O6JyC/5L4iRdE6/1Tw6eqUgvRbw1HAi9nlcuhM9RqmR7dyT0XX7y4+dMtyr5J5r A0akVPLgNInkC5RwECExampf3PqA3em9OKFw80bno4drszNe9PupQVWs2OcWBJKz ypYcOmG5oZvyy0sgQmZ0A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeduudduhfevjeetfeegvdffvdevvdejudegudekjeehtdelhfffveethfej ledtveenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Nov 2022 10:29:09 -0500 (EST) From: Maxime Ripard Date: Wed, 23 Nov 2022 16:25:49 +0100 Subject: [PATCH 07/24] drm/tests: helpers: Allow to pass a custom drm_driver MIME-Version: 1.0 Message-Id: <20221123-rpi-kunit-tests-v1-7-051a0bb60a16@cerno.tech> References: <20221123-rpi-kunit-tests-v1-0-051a0bb60a16@cerno.tech> In-Reply-To: <20221123-rpi-kunit-tests-v1-0-051a0bb60a16@cerno.tech> To: Maxime Ripard , Maarten Lankhorst , Daniel Vetter , David Airlie , Thomas Zimmermann X-Mailer: b4 0.11.0-dev-d416f X-Developer-Signature: v=1; a=openpgp-sha256; l=3124; i=maxime@cerno.tech; h=from:subject:message-id; bh=Ahr/dzE3tn44EjPLHFard1PjEGhVLUGRIQk+hZvFDEQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMl11tV372yR3ysf8KIgQf+wyCf3JaeUf3ieFtW8eYt3+7Ql 091kO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRg5yMDIv8H17brcQsWCGx8rS63p yo5rf+PdO9uXW2Os0vcMz+IsjI8LGsq+5SwMqjPHMNn87Ifj/zau6mdW5VZTILWLlW3pyhwA0A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D 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: =?unknown-8bit?q?David_Gow_=3Cdavidgow=40google=2Ecom=3E=2C_Brendan_Higg?= =?unknown-8bit?q?ins_=3Cbrendan=2Ehiggins=40linux=2Edev=3E=2C_Greg_Kroah-Ha?= =?unknown-8bit?q?rtman_=3Cgregkh=40linuxfoundation=2Eorg=3E=2C_Dave_Stevens?= =?unknown-8bit?q?on_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_Javier_Ma?= =?unknown-8bit?q?rtinez_Canillas_=3Cjavierm=40redhat=2Ecom=3E=2C_dri-devel?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_linux-kernel=40vger=2Ekern?= =?unknown-8bit?q?el=2Eorg=2C_linaro-mm-sig=40lists=2Elinaro=2Eorg=2C_Ma=C3?= =?unknown-8bit?q?=ADra_Canal_=3Cmairacanal=40riseup=2Enet=3E=2C_Maxime_Ripa?= =?unknown-8bit?q?rd_=3Cmaxime=40cerno=2Etech=3E=2C_linux-kselftest=40vger?= =?unknown-8bit?q?=2Ekernel=2Eorg=2C_kunit-dev=40googlegroups=2Ecom=2C_linux?= =?unknown-8bit?q?-media=40vger=2Ekernel=2Eorg?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some tests will need to provide their own drm_driver instead of relying on the dumb one in the helpers, so let's create a helper that allows to do so. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 13 ++++--------- drivers/gpu/drm/tests/drm_kunit_helpers.h | 29 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index 6d614f9e62d8..5c758a22f526 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -100,20 +100,15 @@ void drm_kunit_helper_free_device(struct kunit *test, struct device *dev) } struct drm_device * -__drm_kunit_helper_alloc_drm_device(struct kunit *test, struct device *dev, - size_t size, size_t offset, - u32 features) +__drm_kunit_helper_alloc_drm_device_with_driver(struct kunit *test, + struct device *dev, + size_t size, size_t offset, + const struct drm_driver *driver) { struct drm_device *drm; - struct drm_driver *driver; void *container; int ret; - driver = kunit_kzalloc(test, sizeof(*driver), GFP_KERNEL); - if (!driver) - return ERR_PTR(-ENOMEM); - - driver->driver_features = features; container = __devm_drm_dev_alloc(dev, driver, size, offset); if (IS_ERR(container)) return ERR_CAST(container); diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.h b/drivers/gpu/drm/tests/drm_kunit_helpers.h index 70abc8c806c9..45bc12a53cd4 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.h +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.h @@ -10,9 +10,34 @@ struct device *drm_kunit_helper_alloc_device(struct kunit *test); void drm_kunit_helper_free_device(struct kunit *test, struct device *dev); struct drm_device * -__drm_kunit_helper_alloc_drm_device(struct kunit *test, struct device *dev, +__drm_kunit_helper_alloc_drm_device_with_driver(struct kunit *test, + struct device *dev, + size_t size, size_t offset, + const struct drm_driver *driver); + +#define drm_kunit_helper_alloc_drm_device_with_driver(_test, _dev, _type, _member, _drv) \ + ((_type *) __drm_kunit_helper_alloc_drm_device_with_driver(_test, _dev, \ + sizeof(_type), \ + offsetof(_type, _member), \ + _drv)) + +static inline struct drm_device * +__drm_kunit_helper_alloc_drm_device(struct kunit *test, + struct device *dev, size_t size, size_t offset, - u32 features); + u32 features) +{ + struct drm_driver *driver; + + driver = kunit_kzalloc(test, sizeof(*driver), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, driver); + + driver->driver_features = features; + + return __drm_kunit_helper_alloc_drm_device_with_driver(test, dev, + size, offset, + driver); +} #define drm_kunit_helper_alloc_drm_device(_test, _dev, _type, _member, _feat) \ ((_type *) __drm_kunit_helper_alloc_drm_device(_test, _dev, \