Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp445240pxb; Thu, 9 Sep 2021 04:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1+q4PdaaOORIeku6wEeYVBasp1uQkJpvSzuh2n6O0QYlg2P3TKROfVPjKhEOV6USXPjxp X-Received: by 2002:a50:ba84:: with SMTP id x4mr2700794ede.376.1631187967426; Thu, 09 Sep 2021 04:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631187967; cv=none; d=google.com; s=arc-20160816; b=jiUKlguuOWVIlBAwNMd25pOUI9NqDodR1wALRpzpnn7Elv74Hhli1RUFqGKAFPT/2q 2pyTKpabyj5uNgB2hj9Todc2cHmYEKvu+5oNlAoyaPvIuoOzYRTpO419Jw/9RH/Z//Js Z3WJKqRN5QdiFAXQaHkAcgw3K3uunVdBUAxSA0nMPpXEpiQJIyuYNdd7cIQgtKgN+H1n hFXYGDrdBEicfhNmmHAdPSIVoG/IWXp2P7krQK9yug0jZ5Y/apphrqgYbPqsgkDd7txf 8ZDQK1wtLTS5wabyUaLldfZB8O3bXJdVqfyNk4uMxQhaU6j11SWkxN5zYgB5A/gWgQXt Ba4w== 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=+c/sRKM/FH0rDpxktti36O7M8p36ciTBYJFCaMNjmUw=; b=rpklmcmSXOM6s75TCUicRVZjAKsEHA6gHFaZSlwvebJMz54Ga8DR5Pcl5OPAuJwbHj qfgS+Uaa04L34AF4mnfY1nKTgTQxjQ+bYNw41SVFvEG0c8xhCJ83eDWuaa+6EWC/Dt9c pTcF57yEjpB03fIlAmF0CgsuxV76+aBUfhcUgN4ShFellgib1NoXeP/VE5AUOO/WT2sF QxAZJ+CIwjRE+/rLWjlOv5VzGAEj0apHmKQYLJg6vXrfD1TkiWUNoEmDfozwMD9oZWaS s2r1aECh//PFCcsxklFWlT0YGUdr59ln3nqrUd7vS7rpxFX++RmmsYTxhlcSB+o4jz1b zN8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A6gFDD5x; 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 e20si1622996edz.441.2021.09.09.04.45.42; Thu, 09 Sep 2021 04:46:07 -0700 (PDT) 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=A6gFDD5x; 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 S237356AbhIILm6 (ORCPT + 99 others); Thu, 9 Sep 2021 07:42:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236219AbhIILm1 (ORCPT ); Thu, 9 Sep 2021 07:42:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EB662611BD; Thu, 9 Sep 2021 11:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187678; bh=qgrvvbgVxAgBnFAp5WVpU5JvVXZIGj1Kxl6i3UuX4rA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A6gFDD5xxTjX8qv5xL5U8X+c2Ne/Jmdjbsi6CZ681uC5HIziFlWfPIJLFsqbsBu1e kdL2A6wSD8+dGvJiRB9yo+qpIkFLPoucor7scCMqWCVXfbj3pY34gXK2COU1qJxh/M U9HnjQ2NYNy5qfpML333dRsq72jFowM9XDe8Nmiv/ULv3aGSmZYSXJkzgOQEMaULjg 57sP6B91Vx45hzC4VF32nsT7EmSl30FwjGkOIfzsJA+TlZcm8IDh14Haw0yjw0v0Zd ihsEL0msqb2s/zsmAuYdM4Ee1OJJv/MDQ9mVJ+IUMdcJMetGhUofYwkP8KYw23kp+Y 1lF7oQ68dpPFQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luben Tuikov , Alexander Deucher , John Clements , Hawking Zhang , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.14 008/252] drm/amdgpu: Fix koops when accessing RAS EEPROM Date: Thu, 9 Sep 2021 07:37:02 -0400 Message-Id: <20210909114106.141462-8-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-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: Luben Tuikov [ Upstream commit 1d9d2ca85b32605ac9c74c8fa42d0c1cfbe019d4 ] Debugfs RAS EEPROM files are available when the ASIC supports RAS, and when the debugfs is enabled, an also when "ras_enable" module parameter is set to 0. However in this case, we get a kernel oops when accessing some of the "ras_..." controls in debugfs. The reason for this is that struct amdgpu_ras::adev is unset. This commit sets it, thus enabling access to those facilities. Note that this facilitates EEPROM access and not necessarily RAS features or functionality. Cc: Alexander Deucher Cc: John Clements Cc: Hawking Zhang Signed-off-by: Luben Tuikov Acked-by: Alexander Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index fc66aca28594..95d5842385b3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -1966,11 +1966,20 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev) bool exc_err_limit = false; int ret; - if (adev->ras_enabled && con) - data = &con->eh_data; - else + if (!con) + return 0; + + /* Allow access to RAS EEPROM via debugfs, when the ASIC + * supports RAS and debugfs is enabled, but when + * adev->ras_enabled is unset, i.e. when "ras_enable" + * module parameter is set to 0. + */ + con->adev = adev; + + if (!adev->ras_enabled) return 0; + data = &con->eh_data; *data = kmalloc(sizeof(**data), GFP_KERNEL | __GFP_ZERO); if (!*data) { ret = -ENOMEM; @@ -1980,7 +1989,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev) mutex_init(&con->recovery_lock); INIT_WORK(&con->recovery_work, amdgpu_ras_do_recovery); atomic_set(&con->in_recovery, 0); - con->adev = adev; max_eeprom_records_len = amdgpu_ras_eeprom_get_record_max_length(); amdgpu_ras_validate_threshold(adev, max_eeprom_records_len); -- 2.30.2