Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5884407rwp; Mon, 17 Jul 2023 10:58:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpe7n0hBZfblAqOo5zpxFBEgFOrMqs1y953Ipe9AYuY9Ki5NKHDwRldNeaqZNPCVaDvBm8 X-Received: by 2002:a05:6402:104f:b0:521:985d:7314 with SMTP id e15-20020a056402104f00b00521985d7314mr2806490edu.18.1689616712310; Mon, 17 Jul 2023 10:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689616712; cv=none; d=google.com; s=arc-20160816; b=fDRRoZdTRrwSFhtxQ1SR/jS/Rp3bID/aepA5TqENokPHpK+EddZt44BIXXW18h0TMO HZ81iUMNCa2N0338ufmYUT9k1zPB4Zq6B33SmDt+YhxaUcn/rY3oIdxse49XU76m8Da5 QoldYAMk6u3PpynIf+4qvrMI988Ik4MSv8I/6TZxKf7fuiK5U9jeqxgj5GtTw/MMMwpd 5EhLKq97V9Pu4T1M/0dlDRhsYzjcYGAphpL6gw9EHDygxX/fsbXIKcQNpCcML684e1ke s8TTXyZgu/eA9EC3sY9TJNzpnNiEaSWsejqsQBa4ZVPdHxr3R7F37UoF4XcyF5dIoDpc duZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=mA/mFo6xcptzGc4Vk7y4FG1BnZYZ4ZamFJJaRmxUMqk=; fh=lh8NludGOHNxTFx19Kz4FFj4sU98M8UL6N8PrHBgVXw=; b=fITBTtJEgc4U890+pyND0fdMjB3qfs+ZN/0FKv5zPWFVQ3IOzeL8xAJIWDZgGfRAH4 OGQvYdODNDReyGLkVMeBp4B60GJFiLT14TIJnRX+k3UDAwXdAxPHaZ5Ab+IHrxSZaggB /5f9wIbog/UYpv+pMRlNXyhOIxELKn7gSryeyK3O2ALWfZDYp1SUnMAd2CaRY5RxEo+l gKRtazBiZv7rA416gBBUn5XBaKaSx+kp+bA+BSvVdnjQgjVUHg8QVo3xh3sBHKfN3Tmk 2MpGDMkWQqHqgfAFHsuw1ziZK9IVxVPpQwaLf4hOUpZgUH/MVcvxE/14Ez2bGniQ2K5A 1JnA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020aa7c40e000000b0051df648a32esi13380626edq.61.2023.07.17.10.58.07; Mon, 17 Jul 2023 10:58:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjGQRYh (ORCPT + 99 others); Mon, 17 Jul 2023 13:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjGQRYf (ORCPT ); Mon, 17 Jul 2023 13:24:35 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A55C71B4 for ; Mon, 17 Jul 2023 10:24:32 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8CxLOtOebVk+goGAA--.10766S3; Tue, 18 Jul 2023 01:24:30 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxriNNebVke7oxAA--.31760S3; Tue, 18 Jul 2023 01:24:29 +0800 (CST) Message-ID: Date: Tue, 18 Jul 2023 01:24:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init Content-Language: en-US To: Maxime Ripard , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20230710-kms-kunit-actions-rework-v1-9-722c58d72c72@kernel.org> From: suijingfeng In-Reply-To: <20230710-kms-kunit-actions-rework-v1-9-722c58d72c72@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf8CxriNNebVke7oxAA--.31760S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoW3XFW7KF4rZFy8tF4DXF43Arc_yoW3Jw45pr 1kJFyUKFW5Jr4kWasrJayv9r9akw4UtryfKr97Ww4SvF1jgFyYy3Wvq34UZFW5ArZ5XFs3 Aw1ayw15Xw4DAwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU3529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUPFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYI kI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWU twAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMx k0xIA0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l 4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxV WUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI 7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r 1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU4SoGDUUUU X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hi, On 2023/7/10 15:47, Maxime Ripard wrote: > The new helper to init the locking context allows to remove some > boilerplate. > > Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 ++++++++++++-------------- > 1 file changed, 19 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c > index 776a7b01608f..ff1deaed0cab 100644 > --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c > +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c > @@ -20,7 +20,6 @@ > > struct pv_muxing_priv { > struct vc4_dev *vc4; > - struct drm_modeset_acquire_ctx ctx; > struct drm_atomic_state *state; > }; > > @@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test) > static int vc4_pv_muxing_test_init(struct kunit *test) > { > const struct pv_muxing_param *params = test->param_value; > + struct drm_modeset_acquire_ctx *ctx; > struct drm_atomic_state *state; > struct pv_muxing_priv *priv; > struct drm_device *drm; > @@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test) > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); > priv->vc4 = vc4; > > - drm_modeset_acquire_init(&priv->ctx, 0); > + ctx = drm_kunit_helper_acquire_ctx_alloc(test); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); > The pointer returned by drm_kunit_helper_acquire_ctx_alloc() function can't be NULL, if ctx is NULL, the current kthread will be terminated by the KUNIT_ASSERT_NOT_NULL() in the drm_kunit_helper_acquire_ctx_alloc(). so only a PTR_ERR is possible, right? If so, probably invent a KUNIT_ASSERT_NOT_ERR() function to call is enough. I'm fine with this patch, but I feel the checking if the ctx is NULL is redundant. > drm = &vc4->base; > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &priv->ctx; > + state->acquire_ctx = ctx; > > priv->state = state; > > @@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test) > struct drm_atomic_state *state = priv->state; > > drm_atomic_state_put(state); > - drm_modeset_drop_locks(&priv->ctx); > - drm_modeset_acquire_fini(&priv->ctx); > } > > static struct kunit_case vc4_pv_muxing_tests[] = { > @@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = { > */ > static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *test) > { > - struct drm_modeset_acquire_ctx ctx; > + struct drm_modeset_acquire_ctx *ctx; > struct drm_atomic_state *state; > struct vc4_crtc_state *new_vc4_crtc_state; > struct vc4_hvs_state *new_hvs_state; > @@ -811,13 +810,14 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes > vc4 = vc5_mock_device(test); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); > > - drm_modeset_acquire_init(&ctx, 0); > + ctx = drm_kunit_helper_acquire_ctx_alloc(test); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); > > drm = &vc4->base; > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -844,7 +844,7 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -866,13 +866,11 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes > KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel); > > drm_atomic_state_put(state); > - drm_modeset_drop_locks(&ctx); > - drm_modeset_acquire_fini(&ctx); > } > > static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) > { > - struct drm_modeset_acquire_ctx ctx; > + struct drm_modeset_acquire_ctx *ctx; > struct drm_atomic_state *state; > struct vc4_crtc_state *new_vc4_crtc_state; > struct vc4_hvs_state *new_hvs_state; > @@ -885,13 +883,14 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) > vc4 = vc5_mock_device(test); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); > > - drm_modeset_acquire_init(&ctx, 0); > + ctx = drm_kunit_helper_acquire_ctx_alloc(test); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); > > drm = &vc4->base; > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -954,14 +953,12 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) > } > > drm_atomic_state_put(state); > - drm_modeset_drop_locks(&ctx); > - drm_modeset_acquire_fini(&ctx); > } > > static void > drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct kunit *test) > { > - struct drm_modeset_acquire_ctx ctx; > + struct drm_modeset_acquire_ctx *ctx; > struct drm_atomic_state *state; > struct vc4_crtc_state *new_vc4_crtc_state; > struct drm_device *drm; > @@ -971,13 +968,14 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku > vc4 = vc5_mock_device(test); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); > > - drm_modeset_acquire_init(&ctx, 0); > + ctx = drm_kunit_helper_acquire_ctx_alloc(test); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); > > drm = &vc4->base; > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -993,7 +991,7 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku > state = drm_atomic_state_alloc(drm); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > > - state->acquire_ctx = &ctx; > + state->acquire_ctx = ctx; > > ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); > KUNIT_ASSERT_EQ(test, ret, 0); > @@ -1006,8 +1004,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku > KUNIT_EXPECT_NULL(test, new_vc4_crtc_state); > > drm_atomic_state_put(state); > - drm_modeset_drop_locks(&ctx); > - drm_modeset_acquire_fini(&ctx); > } > > static struct kunit_case vc5_pv_muxing_bugs_tests[] = {