Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2774893rdb; Mon, 12 Feb 2024 16:57:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJz7Ml44rOX2ntRBHny02LzPBVXJZmbYY8038a/jrYJjIOO/tcHgyWsii9zzdwLOGPOovnbWZTTkad1cRiyuCQnQY/nQhhrAaLRqnpvQ== X-Google-Smtp-Source: AGHT+IGPQmCFlYUX1zP0Mfmz2ppCrOogjRWNpe+lfGL/Q1P1jyQODdOR3EAgx1nMO+n2ZM9saHtO X-Received: by 2002:a25:5f09:0:b0:dc7:6d9a:37f2 with SMTP id t9-20020a255f09000000b00dc76d9a37f2mr6576684ybb.38.1707785832240; Mon, 12 Feb 2024 16:57:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707785832; cv=pass; d=google.com; s=arc-20160816; b=QiNdvVDGKokgwjF4+w6nlXUyCBiOV49mHxj5ZW6YXSC2VEJdmYouow55xvI9PPAJ5O lHOuo4coCxaOQN3sPqC1YjPXjg6rMVX+k/7jFnGjvmTLX00Y7rg6NzXlAQ6tKndtU8Wp 3kYLtCDCd4Rw+DupXf2A4V2eEGUNklxtlH2zGfRcO9a0suqJLl8iWveWRYfeFyaPA3U2 i7+MoK5CyQGIY8zyt2T4/cqvLxiJBrAxv56bI7Khk4zOHFFNUfXgprkSiEz6ckBNOCOF qmGfY9VN377hxmjeTKkFgDkZrqd1x20dnpBrZxGzKUIS4KrsERzLTX1aSK75oR5fn5rm VSxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yDQx2wAzMmdkfHNWrS4a3+a/Wv6sn2mL3nY5zl3h6AU=; fh=gR8HVtz5OhXcMu3h3sPWk8vKVZNm83tJhJHoFbV94SI=; b=Qt8xwUvCcVPozjSHFOGaoyuBBhlIR0ATq0eUqcOL+4pr/sdPmwKnilgnAxZ74sCDbb I9KK+1/5fN55mTKOOZdaJcZzBo+YVg409+Q96EeVubrwJOJDAiu0zMH9584paFrNnaQC 333var7kOmXA/xtPLE1J7DhgYyZeMuJDW05+HZD6JHpRA8PTLjhB7hPFXzzDV3qQeurP 5lPtpVmaNpTqg1GLGicyZ8OX/vIV2+ngCZ6WLEIaHKKTws91vS5R7c89sVbLbH4W/D9C 2/cXj0YO61IdAfsI110318P5FRfHh5yQ8RUBTPYKZm7ay50Z7EdG2odCqQg9/hE9NG+I 6Xcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PkO+sMXh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUJClun55ZOqBmUu56MV3JR2Bv2tYl+03HXcPv7g5P9/GRaaIPNaPK8O5DlG+1NJR5fovod0c1L+CFydEIvboOJZqp5qD5ube1p9ZHMfg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j23-20020a05620a0a5700b00785d59f3f94si3823917qka.447.2024.02.12.16.57.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 16:57:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PkO+sMXh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 05DA41C23780 for ; Tue, 13 Feb 2024 00:57:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF92922625; Tue, 13 Feb 2024 00:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PkO+sMXh" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE419839E2; Tue, 13 Feb 2024 00:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783800; cv=none; b=MIjZa16YTy7vd05BV8sOLS8wD9OI4z/dDJUt7kp0C/YscaMj1RIIoZJs1mBoXlH3Jc0b/hfpdWsXrriQu9GMSZOz97a9Wq2te53LApFDrxLXxeKiK+mZK3VPRWEPwnXFSfDmFMLk4EjHRwnNldWqRNzHejkr4JuSlVB4PclHbBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783800; c=relaxed/simple; bh=6ryKZXEJRLnRj7J4B6wkp1zy0wxQlLN4XSjp4TGtT9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fuvVYVKtNe1cHeTh6O5b2Q80/hueku7SagLPFX3P6gho0ZL+VrY7J5neFkjnkevLaBy4plKcrGt/BcVX9vxZ5MWEpvokmUTmM/1y8bYA2P0NKR0FZbFBcft2pHaeRCoQSyJU7AeqAvKvOa+2EuSSdR976szIyWmMAFqsTkNo95Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PkO+sMXh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B300C433F1; Tue, 13 Feb 2024 00:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707783799; bh=6ryKZXEJRLnRj7J4B6wkp1zy0wxQlLN4XSjp4TGtT9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PkO+sMXhT3gwB0ctHjTumT5bHyyQggpTr5Kis49bBvOtwjQbWodH++7Mz3lYDNclF MhftX1/WzAIVBorsMSNi0mCbzKAEwzDZt2xQvIU2LomzMzAmSDaz+tpzRUOyR+7T1b JGKJc9xFUjcmmkCoNcyu7+IZJFvi9gKgJaDUlFpc08Eb3GrXjM5za/Ml2Fw9Ql2R67 mtpO688z1P/OHNF9tagvbdqyAsH17/t7cJ8tzjPybQaRKTJ8KY/mXy3Krim95ipwP8 SxIjts3DGOuSPDOkJ0zLR0ZLPTKeWlf7wEtN+etvMTHO2ur4icW7D3LxB01KetbR2p zRIrrvr7bdYlg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Prike Liang , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Hawking.Zhang@amd.com, lijo.lazar@amd.com, le.ma@amd.com, James.Zhu@amd.com, shane.xiao@amd.com, sonny.jiang@amd.com, Likun.Gao@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.1 25/28] drm/amdgpu: reset gpu for s3 suspend abort case Date: Mon, 12 Feb 2024 19:22:23 -0500 Message-ID: <20240213002235.671934-25-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213002235.671934-1-sashal@kernel.org> References: <20240213002235.671934-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.77 Content-Transfer-Encoding: 8bit From: Prike Liang [ Upstream commit 6ef82ac664bb9568ca3956e0d9c9c478e25077ff ] In the s3 suspend abort case some type of gfx9 power rail not turn off from FCH side and this will put the GPU in an unknown power status, so let's reset the gpu to a known good power state before reinitialize gpu device. Signed-off-by: Prike Liang Acked-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/soc15.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 811dd3ea6362..489c89465c78 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -1285,10 +1285,32 @@ static int soc15_common_suspend(void *handle) return soc15_common_hw_fini(adev); } +static bool soc15_need_reset_on_resume(struct amdgpu_device *adev) +{ + u32 sol_reg; + + sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81); + + /* Will reset for the following suspend abort cases. + * 1) Only reset limit on APU side, dGPU hasn't checked yet. + * 2) S3 suspend abort and TOS already launched. + */ + if (adev->flags & AMD_IS_APU && adev->in_s3 && + !adev->suspend_complete && + sol_reg) + return true; + + return false; +} + static int soc15_common_resume(void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; + if (soc15_need_reset_on_resume(adev)) { + dev_info(adev->dev, "S3 suspend abort case, let's reset ASIC.\n"); + soc15_asic_reset(adev); + } return soc15_common_hw_init(adev); } -- 2.43.0