Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9373809rwp; Thu, 20 Jul 2023 04:07:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGjDPcro4AxrUWfP94QHf0n7ZCeeHRqNYIci40lMfM2bK52t9a5NkGYG+6jXVibXpRn9siT X-Received: by 2002:a2e:84ca:0:b0:2b6:a08d:e142 with SMTP id q10-20020a2e84ca000000b002b6a08de142mr1330227ljh.7.1689851270339; Thu, 20 Jul 2023 04:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689851270; cv=none; d=google.com; s=arc-20160816; b=iL56Qa8PLNON9RDtZs8c5OQ11RaaepDQNzPXiafQcqGjZvO7h/t+Fk66JumdCqe5I1 /GiRa5a6b2kDphwsvxEARNwI9V8NQI4jQlpTtpGyLbgtrIR0x17aAp2gXhJv7Watfz+W L3ZZAQezhj/ORrgMElRFdf5yflq9LZCFCxVaR6fs7AIvnuXA/wBIl38GqUTBNF9Mt0Vb 3q+wldRA56I8UW9jUzV+jkxfZNzpF4IrHWFCltmKVxV41QAwEb/uCON1TjcCOFlP18I3 JFZLFfX/vXOGRTIUH+0IVVDNqJ7SCesGUpYsN+C2Kmfh9eha2kXmlFGoFgo4HfW6dv6E NsOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0yzcRg8vo6jZwdrtEOJdY9TQmtMAb2wIwRs1BcyFMqc=; fh=Sk5QlGO35jByDHNRtdNwVqFV8RyrNg+lW5yAcjCo6AA=; b=q+0GBtr/g48F26yCbTQ9ahUMsQ5iJOkW2ZZ0rjMWB/yuS+G5SVncWdSWFsAOK6mS9q fyQBIZXXhVSUX8/0xgYpGf/I9STBQuQrQR+JVwUmhC7YvBDud2BWkAMsoMtM0YiyUbPl cJl7yKe/ILA721v3LNeKksCeAkZAT5bQ4KeU6Sb9d1pAK3onGjOQnep8bJaf33x//rOH Z4Z9miTJlZw1B7AQVuNBrhQYSqqdRTKSUMcve+W9ZtnU5TgmRmqk5NQXYPYhkTN2Wyp3 Yfh40tf5MRlx9TSUBBeySHa084hzyar8JYZRbaWe2SnhEtb3oIxWiBfEff15TxZ0ExFA jbdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TtgG3Rzr; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx13-20020a170906a1cd00b00987a1823cfesi467531ejb.569.2023.07.20.04.07.25; Thu, 20 Jul 2023 04:07:50 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=TtgG3Rzr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbjGTKIC (ORCPT + 99 others); Thu, 20 Jul 2023 06:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231246AbjGTKHx (ORCPT ); Thu, 20 Jul 2023 06:07:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D6C5136 for ; Thu, 20 Jul 2023 03:07:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B9F26619FE for ; Thu, 20 Jul 2023 10:07:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DEE0C433C8; Thu, 20 Jul 2023 10:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689847659; bh=FfhZgQ+pQ/UDSPLyRjHsPzAtbC9LrIGVDPMAddOMUQM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TtgG3RzrHCE4UsgIX10QOxdl4FsX3G8YGwzAMuZLNXLo5WRw80ZhzWl5cIeBLYZPx lVwaRLJQQO+AGnPhGUSRr8lHhMjRyFCVERmb20DfVgoFTfWMpnXElOJuRYPkUlXGJ5 MV6TRixTPKIkfZJT+krnEQxw11O+Mxd6X/qlT/MdatEtDkclPddOVfURhOlErtXMcp NKyJJ21cKHiJqq63zOmxVU0O6/UX+eYsOOHH+D1ix3hdWiwhQ0TuBPF6ly3lqw/98H ioMd4bi90X0xuV+wZREAR1jzeUHefRIUii/WirAhnHTK6UZ9wcwTuxTOtp4xt2BCBo kxr3LeFs9T6zw== Date: Thu, 20 Jul 2023 12:07:36 +0200 From: Maxime Ripard To: Javier Martinez Canillas Cc: suijingfeng , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [05/11] drm/tests: helpers: Create an helper to allocate a locking ctx Message-ID: <5khgq6xy4ztci45qtxzo7fyvmdj3i6rrnl5yuny3gusgeeumdq@eobkes722rky> References: <20230710-kms-kunit-actions-rework-v1-5-722c58d72c72@kernel.org> <970f4a65-25dc-1805-3776-6447a61f77c5@loongson.cn> <87o7k7hg1d.fsf@minerva.mail-host-address-is-not-set> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="p3xg2ps427f43xcp" Content-Disposition: inline In-Reply-To: <87o7k7hg1d.fsf@minerva.mail-host-address-is-not-set> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --p3xg2ps427f43xcp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 19, 2023 at 09:12:14PM +0200, Javier Martinez Canillas wrote: > suijingfeng writes: >=20 > > Hi, > > > > On 2023/7/10 15:47, Maxime Ripard wrote: >=20 > [...] >=20 > >> + > >> +/** > >> + * drm_kunit_helper_context_alloc - Allocates an acquire context > >> + * @test: The test context object > >> + * > >> + * Allocates and initializes a modeset acquire context. > >> + * > >> + * The context is tied to the kunit test context, so we must not call > >> + * drm_modeset_acquire_fini() on it, it will be done so automatically. > >> + * > >> + * Returns: > >> + * An ERR_PTR on error, a pointer to the newly allocated context othe= rwise > >> + */ > >> +struct drm_modeset_acquire_ctx * > >> +drm_kunit_helper_acquire_ctx_alloc(struct kunit *test) > >> +{ > >> + struct drm_modeset_acquire_ctx *ctx; > >> + int ret; > >> + > >> + ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); > >> + KUNIT_ASSERT_NOT_NULL(test, ctx); > >> + > >> + drm_modeset_acquire_init(ctx, 0); > >> + > >> + ret =3D kunit_add_action_or_reset(test, > >> + action_drm_release_context, > >> + ctx); > >> + if (ret) > >> + return ERR_PTR(ret); > >> + > >> + return ctx; > >> +} > >> +EXPORT_SYMBOL_GPL(drm_kunit_helper_acquire_ctx_alloc); > >> + > > > > I think all of the patch inside this series are quite well. > > > > Personally, I can't find problems in it. > > > > > > But I still want to ask a question: > > > > Should the managed functions you introduced be prefixed with drmm_=20 > > (instead of drm_) ? > > >=20 > That's a good question. But personally I think that the drmm_ prefix > should be reserved for drm_device managed resources and helpers. Yeah, to me drmm functions are meant for resources that are tied to the DRM device lifetime. These resources are tied to the test lifetime, so they shouldn't share the same prefix. > > As mindless programmer may still want to call drm_modeset_acquire_fini(= )=20 > > on the pointer returned by > > > > drm_kunit_helper_acquire_ctx_alloc()? > > >=20 > The function kernel-doc already mentions that there's no need to do that > and that will be done automatically by kunit. So shouldn't be different of > other functions helper where the programmer didn't read the documentation. Right Maxime --p3xg2ps427f43xcp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZLkHaAAKCRDj7w1vZxhR xToyAP4hkRI/8aKpOKams5XwxbGYROu5Qb2VT8DyZViYoQZlhAEAky8Oe4eJS3dM 4NDsW3WmKERxiFbfmvNxib5fvgiE9AU= =7/bm -----END PGP SIGNATURE----- --p3xg2ps427f43xcp--