Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp119682ybg; Mon, 8 Jun 2020 18:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycTzywLniSv+9s+4Px0uQIXpX+MkC3elBEsQsUlP1vescwsu9rOa2W7xyoR66nj1kXI5T3 X-Received: by 2002:a17:906:f49:: with SMTP id h9mr7785781ejj.155.1591664980849; Mon, 08 Jun 2020 18:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664980; cv=none; d=google.com; s=arc-20160816; b=f2Dwd6L2HiHX8XUz6Wu5InGxqZutKhs3gte61AmMfIg80BZ6WWz//6OD7pEzQAY2Wg rmAgoaV+tBiAVLtNk1cILJCxbxvgeFbBrJIWSFqUZrz9Di+0ddzysQL5wFDwjQynirXp Ksa0zjFnKauqw0iQZe8zlRfy1j+BBYoX4a3+2rnUDZe0aOLdYjP+AHu1rJSBb7GDzuK5 uNFmnpALPEDmNnxzgcDhrbpa0SQp6cFVwXgG6pP5fITh6b5WMlWSs+86fWi6qZjLKWF+ WHYaXUoFP6NS5GDJKSj6pRqmtrlzIigFDhxq7sV49Afl9g5HWKbDDRKmMmjr9lGYxJbm 77Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4bbZ4+uSS+dPpvSidt4mzKwWHJTFVDsvLnNCTi7x0tg=; b=W2TsBjRzKxmmuqpUptEqjL9RGWZhC+f+ch+/HEgGu3EX7hSijSsagmrBrFo7BaN5of yJ7BefiWMrUXYqeMiVKXoJdbRejfhaYoooHlvQcXcBrR7umiyiBxaWu6wMRvThyvzM7x ugpprzflXm2XFNvHZFXGdzrTTHrwXFoo8b2xpfNE5HqyUSQvs9cCX1geykpSrx8cJR9/ m4Q2hpO6sjJEGxgwgxx16VPhhQXgRSpn2WYGmgRffsNP8m2f0+vZwvBJA/pT3OjQSLIF PdBXNiXCavJLqqMSHITtyELR8hWnUM8yGRhmz0LLPK0T8qSAx+vN7Hf6dcntd8QZ8y7x TwdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YP8pPkKb; 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 ay19si9891015ejb.372.2020.06.08.18.09.16; Mon, 08 Jun 2020 18:09:40 -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=default header.b=YP8pPkKb; 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 S1727101AbgFHXG4 (ORCPT + 99 others); Mon, 8 Jun 2020 19:06:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:49738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgFHXGc (ORCPT ); Mon, 8 Jun 2020 19:06:32 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 151D920820; Mon, 8 Jun 2020 23:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657591; bh=x7XNxG+6Ey9iNd/8UiXWD76fUZIbSvQFJ+JJaQo5fqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YP8pPkKbQFz25zt4gifp3yg/NIvpC8zOuz4CaJURDjLKfy56qMgPKgZORxfFg2ouC ZRHLoMuDvl1pJBaoBwjT+tJw9TTt1sImXbXbl2fr+rqhKGGEP2lqe6e7NPZrdNa4jV dAFWQVXNfkiio/j1THRY7vtg9uyQ/rIjo0gUxj3k= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: limingyu , zhoubinbin , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.7 019/274] drm/amdgpu: Init data to avoid oops while reading pp_num_states. Date: Mon, 8 Jun 2020 19:01:52 -0400 Message-Id: <20200608230607.3361041-19-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: limingyu [ Upstream commit 6f81b2d047c59eb77cd04795a44245d6a52cdaec ] For chip like CHIP_OLAND with si enabled(amdgpu.si_support=1), the amdgpu will expose pp_num_states to the /sys directory. In this moment, read the pp_num_states file will excute the amdgpu_get_pp_num_states func. In our case, the data hasn't been initialized, so the kernel will access some ilegal address, trigger the segmentfault and system will reboot soon: uos@uos-PC:~$ cat /sys/devices/pci0000\:00/0000\:00\:00.0/0000\:01\:00 .0/pp_num_states Message from syslogd@uos-PC at Apr 22 09:26:20 ... kernel:[ 82.154129] Internal error: Oops: 96000004 [#1] SMP This patch aims to fix this problem, avoid that reading file triggers the kernel sementfault. Signed-off-by: limingyu Signed-off-by: zhoubinbin Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index abe94a55ecad..49e2e43f2e4a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c @@ -444,8 +444,11 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev, ret = smu_get_power_num_states(&adev->smu, &data); if (ret) return ret; - } else if (adev->powerplay.pp_funcs->get_pp_num_states) + } else if (adev->powerplay.pp_funcs->get_pp_num_states) { amdgpu_dpm_get_pp_num_states(adev, &data); + } else { + memset(&data, 0, sizeof(data)); + } pm_runtime_mark_last_busy(ddev->dev); pm_runtime_put_autosuspend(ddev->dev); -- 2.25.1