Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1917665pxb; Thu, 16 Sep 2021 20:12:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvptu6jDe0L70WH/RGm5B1GAAoTklBNxdUuPcGucJsgD7CWXoFN6ZR0ZLqRqnVnrXXGHC7 X-Received: by 2002:a05:6402:2810:: with SMTP id h16mr10066235ede.133.1631848349648; Thu, 16 Sep 2021 20:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631848349; cv=none; d=google.com; s=arc-20160816; b=Ww7jKXGQb0mRyrJir26RdiZyQAG3vtRm1HAFy2kUbhlUqPq2Ivq05AoIw+z0cKI8tA 3xk49Yn/XfgEgwXnGo0TFXGNy2dfRXjk4AOs14aM6STDy5976OPqKI7KJ7aEHdiZwWpx 2MAEXrNZe6DduDF1TYd1eW7u6GyH0UVyW72i4zUTV3IeKjQlmc6+M9c5z6ZvgZHu8vG0 0r1VqyzB7dWKt3AIE6YOnMCeRw5TXGQYcmG/blmyebx7VBkDKhhGDXFCRDQYTtkJJ9Jl ciOZ9kmz9fW7PQCsbHZlcNjdQyTM6caAAF1RVPiMX4JofIrRG5nBz86KcNayknStpM/3 kQbA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+c/sRKM/FH0rDpxktti36O7M8p36ciTBYJFCaMNjmUw=; b=bk1/Imn4xmJgzKe2Cu/C5LY5naBRdVZImJJDeJf/cTebMIxoq6z1FYRdao9vNS2QHv JcrYMPMo546wQO4mWvKWI7bwkeN79h+/H3WFGeHTcCkhXuYEDpK1Hc4cQ/feNP4O8LhB o/+ayRO49oY2EmOIRALYVLYU3ofex6AeCUE7HumnOc4Buu9JfeXuWSFSM5tHk1S5LWty lZZq39Ix6C9r6IECde/cNHuSI9ta/duwmbOMR8CIV+Da0jYh2KPU0rQAy246d8AnlZYc wnBJeX5KjWXfajByuJ1tO3YbCjgBFGICjImqqaAkF3cvDYVwznyczJBgubhJG2iNiI5j riBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jV1tACSB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si5977826ejh.638.2021.09.16.20.12.06; Thu, 16 Sep 2021 20:12:29 -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=@linuxfoundation.org header.s=korg header.b=jV1tACSB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353263AbhIPRaZ (ORCPT + 99 others); Thu, 16 Sep 2021 13:30:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:44342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352226AbhIPRUu (ORCPT ); Thu, 16 Sep 2021 13:20:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C9D5B61B9F; Thu, 16 Sep 2021 16:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810545; bh=qgrvvbgVxAgBnFAp5WVpU5JvVXZIGj1Kxl6i3UuX4rA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jV1tACSBzIm2OGFCZv4H8TONJZhQ2a5C2MmVyooszBjJsUCwoSWCoZ00zYD/4m1tQ yIZVxuIeUxo6+Dsfp+pnalUpkV/4v7XkzMD1yUUa34F0IKAACw4HtaVbQUvTvBNn2i Ic4a+E2CFY0oZuvASbJvx6tpJvUPsfmR4wD6xe0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Deucher , John Clements , Hawking Zhang , Luben Tuikov , Alex Deucher , Sasha Levin Subject: [PATCH 5.14 163/432] drm/amdgpu: Fix koops when accessing RAS EEPROM Date: Thu, 16 Sep 2021 17:58:32 +0200 Message-Id: <20210916155816.273246131@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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