Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3383971pxb; Mon, 17 Jan 2022 19:13:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqp6cKU4PbBmWDrTzlIZCJXPWc4nUVoNdIKEU0whYTaRwD/nHT+QQHkh9J0ApWx7nv1UOS X-Received: by 2002:a17:90a:1b28:: with SMTP id q37mr28022647pjq.48.1642475601150; Mon, 17 Jan 2022 19:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475601; cv=none; d=google.com; s=arc-20160816; b=EmldvJihKrfNwgA30AyedZDMMY69B9Dh0nTWWA57MkQZLNfcttpE0FKjKQQfi7EotL JEhMOYhRe4Ip8j0A2x2Ddize6F4D/kgihnp1HUv1nv3I7kkIGi6I3kXWuVCzBnxWAu1s Faz05PZD7ncK1QE1GFOIBMdQdDNMesZNpOkCDMI385AlHrv+HgZbuM43QsiSmIKcSVb8 BYcS6Mn+BVEOsK3+o2Gl5aKDftNg94TAEXZwTgmtbqWWR1+DeUXDEOBbQeVDbDEOc1uG RMQ85x7UNSR6vUcTmxErsRkU+MS58hkkp06HCYwRUo65oeLb81Y9E5/u6YEqnCFDpCkF Nh8w== 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=JsiHwFx+T5M3UtGCawWG7tY4qsH0Rt0tH1533lm5qzE=; b=EkcBnOUxg5R54NLkE7BIwh4cR1AOAUARr6TVnXjpEF76eRhyNMvYljpJMCnuWuZGeD XFfyff3zFtSzSxOFza8kJvRKtChrDSaELOnYlVsoBcJCLisMhxuvZnrG88M6YwMSdaEg pfFPGio2qV7nZ/9XFjf+RaV5v0rfnidoNypeAWuxW+sb9MX+JVOkYb6YXcSeWXVSD4ix DV/Tz7+NDNymRMsRNcaSDUkyrAz4ksGptymMtt7Z+GmOLgvWyhVLE7z9ZsB7BYP6+p2n b5XuDfTGtV8N6a2olA7IJMoSuZSLWxLexfsndBh98XYBdkU2k1y1nkXiXjG+mXW+3a8D RTtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ARaaXh1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si6489194pgn.181.2022.01.17.19.13.09; Mon, 17 Jan 2022 19:13:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ARaaXh1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S244282AbiARCVW (ORCPT + 99 others); Mon, 17 Jan 2022 21:21:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244591AbiARCUj (ORCPT ); Mon, 17 Jan 2022 21:20:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAB52C06177E; Mon, 17 Jan 2022 18:20:33 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 404CB612B9; Tue, 18 Jan 2022 02:20:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 844B6C36AEB; Tue, 18 Jan 2022 02:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472432; bh=0tDVZXKr9K09AvgqRFA/1j1lSWqb13QUoRj3scev9K0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARaaXh1YUYrzudbBSo54q4bskMt9FUD3BC1dEBKa9idG7avmVj7w1kP+kqXQj0H4G aYdkinK3RlWGSnr1vv06D+oUjbooG11eoPUKOjtIVpNZWFlWmWOljBYbuj1dbCGwkJ Ly4eJpZzS05Zd5MxyRq5M4NqfzGcYLikRAPn406GjtQ+8+hfL2p4gkgHYcGtE8M8cg EQpfdTr1loxSgzWA44mYihE7rMGyQyGxR5l5kjNd3LaK1IJlenAc+X8vWKLFd/N2GF GxfN2lI5Cxa5sJfoblQoCdjqw/NQzOdD9ErEyCK8Xo5rRDX5FKf9i1B8xqlO35+P8C 1fc84beTii64w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ben Skeggs , Diego Viola , Karol Herbst , Sasha Levin , lyude@redhat.com, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.16 017/217] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR Date: Mon, 17 Jan 2022 21:16:20 -0500 Message-Id: <20220118021940.1942199-17-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ben Skeggs [ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ] There have been reports of the WFI timing out on some boards, and a patch was proposed to just remove it. This stuff is rather fragile, and I believe the WFI might be needed with our FW prior to GM200. However, we probably should not be touching PMU during init on GPUs where we depend on NVIDIA FW, outside of limited circumstances, so this should be a somewhat safer change that achieves the desired result. Reported-by: Diego Viola Signed-off-by: Ben Skeggs Reviewed-by: Karol Herbst Signed-off-by: Karol Herbst Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10 Signed-off-by: Sasha Levin --- .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c index 24382875fb4f3..455e95a89259f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c @@ -94,20 +94,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend) return 0; } -static int +static void nvkm_pmu_reset(struct nvkm_pmu *pmu) { struct nvkm_device *device = pmu->subdev.device; if (!pmu->func->enabled(pmu)) - return 0; - - /* Inhibit interrupts, and wait for idle. */ - nvkm_wr32(device, 0x10a014, 0x0000ffff); - nvkm_msec(device, 2000, - if (!nvkm_rd32(device, 0x10a04c)) - break; - ); + return; /* Reset. */ if (pmu->func->reset) @@ -118,25 +111,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu) if (!(nvkm_rd32(device, 0x10a10c) & 0x00000006)) break; ); - - return 0; } static int nvkm_pmu_preinit(struct nvkm_subdev *subdev) { struct nvkm_pmu *pmu = nvkm_pmu(subdev); - return nvkm_pmu_reset(pmu); + nvkm_pmu_reset(pmu); + return 0; } static int nvkm_pmu_init(struct nvkm_subdev *subdev) { struct nvkm_pmu *pmu = nvkm_pmu(subdev); - int ret = nvkm_pmu_reset(pmu); - if (ret == 0 && pmu->func->init) - ret = pmu->func->init(pmu); - return ret; + struct nvkm_device *device = pmu->subdev.device; + + if (!pmu->func->init) + return 0; + + if (pmu->func->enabled(pmu)) { + /* Inhibit interrupts, and wait for idle. */ + nvkm_wr32(device, 0x10a014, 0x0000ffff); + nvkm_msec(device, 2000, + if (!nvkm_rd32(device, 0x10a04c)) + break; + ); + + nvkm_pmu_reset(pmu); + } + + return pmu->func->init(pmu); } static void * -- 2.34.1