Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2229520rwi; Tue, 1 Nov 2022 05:31:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FXuKWdk51n7NSheiVWGuRvI8eYHMSvmO4CfdQsx+CxGi2hY9Z+4gvHptFbX+YY1ZhbRhx X-Received: by 2002:a17:90a:cf06:b0:212:d9ab:811b with SMTP id h6-20020a17090acf0600b00212d9ab811bmr20412330pju.65.1667305916305; Tue, 01 Nov 2022 05:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667305916; cv=none; d=google.com; s=arc-20160816; b=mjPSdnZZwCxE1j2dfHJgOvvybWDdvpPZ30ghDoE7Yark5v++LoydCegZ6aHmc98jKD b0CQEtIzIA0iUi0flMnyYezD1kIq1QfKmOJQ3rOtut5d+7FB+yeztjIhXV5as3sPAneV 6bLJTBL7x8kkcIYi1/aUWaSak3r7Y44nmIcV85IToC9aQBABU84VHfkfRRWBhA6EFExs OMV0BN+NNFg5UEoyflt2MNnhKpylca+qN0OIzhQWR2vn6waCKuq9D89B2xekWrnFO1aZ gzzd2EV3+Pb4zuGXPjPoVDWC1YpnGo/JL2DgKvj9GQNofuUhUeA1+dr3teUFZwFcEiBU UFNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xlSQsAFwQEL27M8uAWMTJQ2fXG7zRDB1JO1K6nuzcDE=; b=FmQiIDI2x2bMED9TwIxZLMNNDVOQCHvsX4Aa7ZCYnW0y3g95AKpaCkNhTT8xhy6Rpc 8q9SM+NmNJCRDrbI43g0LzrQzsDiUd4ZcNK9ujcZCNSMk3hsBCA5dKHHHTcGm27gTHvJ iZHvcfjJ5fPGFogTlTBRahjmLIuyiX3CoA7/0dBVt8n2EiwXOtmRvRsJZqRbkxTa/UBf M9bPAQ30ahGrD6jyBeKBb4zIgQ79/mCwX3kSrMYB+e+TOG4p8gaFv/QkwmOcPk/9tbWF oeUaxWss3kItl3V1TJBxroGD6cl8e3u8hQ92HWvc/t1o8pBVPP8SATEmqbl3obin5O9M mDIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q6SfJeeC; 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 o17-20020a170903301100b001868827ed1esi10231311pla.131.2022.11.01.05.31.40; Tue, 01 Nov 2022 05:31:56 -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=q6SfJeeC; 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 S230478AbiKALbQ (ORCPT + 97 others); Tue, 1 Nov 2022 07:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230322AbiKALaj (ORCPT ); Tue, 1 Nov 2022 07:30:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F3E6464; Tue, 1 Nov 2022 04:29:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 580B3B81CC3; Tue, 1 Nov 2022 11:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69DCDC433D6; Tue, 1 Nov 2022 11:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667302153; bh=3jXtpSIwEXAW4EAq4OZoPSPi8/gX8DtutC4ENnfdEM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6SfJeeC+m1Q0l+pNOooRVEisJhLwdzeXO54fbR9q5+iIV6mFh0WdOfpRhwR2dE/7 z12ium+mUJcRPQGm9oNKfZZ5ViiCn4qW4RtWxfpgmXHTFFuAziZf1aDtoXPupI5AW2 TYK1hrjc+7/EhuF6fjQ+3au3N9GwaP613jkYaEcASefJEEJpLp7cBgpMZPVw7TgEY+ jbk7uGYBdxWDpidlQUUVtmZIIey6Ga9oZNFbFu8iWa2r9G6eIHrJTG85JiiJvX944+ INfTPC39um/KOGTA8tlBScxinlmvDncsfiCqfY26s1UQ8A32k5HBYqdT+OBG57p3FZ tXWsjlvmCVsFw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: YuBiao Wang , Jack Xiao , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Hawking.Zhang@amd.com, Felix.Kuehling@amd.com, Graham.Sider@amd.com, yifan1.zhang@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.0 30/34] drm/amdgpu: dequeue mes scheduler during fini Date: Tue, 1 Nov 2022 07:27:22 -0400 Message-Id: <20221101112726.799368-30-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101112726.799368-1-sashal@kernel.org> References: <20221101112726.799368-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: YuBiao Wang [ Upstream commit 2abe92c7adc9c0397ba51bf74909b85bc0fff84b ] [Why] If mes is not dequeued during fini, mes will be in an uncleaned state during reload, then mes couldn't receive some commands which leads to reload failure. [How] Perform MES dequeue via MMIO after all the unmap jobs are done by mes and before kiq fini. v2: Move the dequeue operation inside kiq_hw_fini. Signed-off-by: YuBiao Wang Reviewed-by: Jack Xiao Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 42 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c index f92744b8d79d..2dd827472d6e 100644 --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c @@ -1145,6 +1145,42 @@ static int mes_v11_0_sw_fini(void *handle) return 0; } +static void mes_v11_0_kiq_dequeue_sched(struct amdgpu_device *adev) +{ + uint32_t data; + int i; + + mutex_lock(&adev->srbm_mutex); + soc21_grbm_select(adev, 3, AMDGPU_MES_SCHED_PIPE, 0, 0); + + /* disable the queue if it's active */ + if (RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1) { + WREG32_SOC15(GC, 0, regCP_HQD_DEQUEUE_REQUEST, 1); + for (i = 0; i < adev->usec_timeout; i++) { + if (!(RREG32_SOC15(GC, 0, regCP_HQD_ACTIVE) & 1)) + break; + udelay(1); + } + } + data = RREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL); + data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL, + DOORBELL_EN, 0); + data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL, + DOORBELL_HIT, 1); + WREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL, data); + + WREG32_SOC15(GC, 0, regCP_HQD_PQ_DOORBELL_CONTROL, 0); + + WREG32_SOC15(GC, 0, regCP_HQD_PQ_WPTR_LO, 0); + WREG32_SOC15(GC, 0, regCP_HQD_PQ_WPTR_HI, 0); + WREG32_SOC15(GC, 0, regCP_HQD_PQ_RPTR, 0); + + soc21_grbm_select(adev, 0, 0, 0, 0); + mutex_unlock(&adev->srbm_mutex); + + adev->mes.ring.sched.ready = false; +} + static void mes_v11_0_kiq_setting(struct amdgpu_ring *ring) { uint32_t tmp; @@ -1196,6 +1232,9 @@ static int mes_v11_0_kiq_hw_init(struct amdgpu_device *adev) static int mes_v11_0_kiq_hw_fini(struct amdgpu_device *adev) { + if (adev->mes.ring.sched.ready) + mes_v11_0_kiq_dequeue_sched(adev); + mes_v11_0_enable(adev, false); return 0; } @@ -1251,9 +1290,6 @@ static int mes_v11_0_hw_init(void *handle) static int mes_v11_0_hw_fini(void *handle) { - struct amdgpu_device *adev = (struct amdgpu_device *)handle; - - adev->mes.ring.sched.ready = false; return 0; } -- 2.35.1