Received: by 2002:a05:6520:1682:b0:147:d1a0:b502 with SMTP id ck2csp5595592lkb; Mon, 11 Oct 2021 09:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgPba2CulyzAa3Po/stRdziGXqzunobg8fQmU4ET/G2uWP/obPJZd19DUTLtiOYrYXgal+ X-Received: by 2002:aa7:dcc2:: with SMTP id w2mr42177700edu.192.1633970270847; Mon, 11 Oct 2021 09:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970270; cv=none; d=google.com; s=arc-20160816; b=lnasTkwdFfhUGs8TvQhuZhep3zOC/WNw7JkJQJu/Nw5uEAFeaC3tg7lDvbBmt8dQCC AacUVRXMGDboOxjEquwc28FsPdbimAHJfbtOAGzvC+4setUUpRnQmchFEyBxyge+uUS3 Ia3RRukNgUIDEb8+1juhl0JdkjrIai4P9YMbgjuxS+PGkDd94UlCIfyAPkhieSKJ9HBs FaYl+myQiDYfxZuntEdn8MSED99lIiqEv0bdjTy3hJaiE8sL7B8BOVHtQLHS7d07aSAB FN/oFw5VPJw0DI86HKEa0hRq7Y5M90eIdWhu12bxS8SvSd/JOZrgOAolXV24/m/BSw1n bkjw== 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=VgvFQOn3IEbAWzZ/wS0YKExRMmDnC0vdbnMHCIJ3V1Q=; b=CCuW77zUEK9K/jc5ohhIXCf3ITqmAXkTwngvxFin2Ymd+4cwRB1OL4reGZFf/1hjHl FEZvQM+4amsMxvDpuzGO/Ot/EgJzfC6uMOGq/X2jMNqivPoQZcLrhUsuFnui7H7ArmQ+ rI6NePEOANFgDDSGlJo/txJ05zGRK9DeJqdfQwe+5gzBMoeU0ToNFcc74eqTZSP3TBe0 5MqtqPcCa9hT5doCdHUHuU5MaJunWEuA5K1bzCFebPiAIS95eHCbtSiSD97YgLHY9Da7 TxKFUmHEI93zTn/yzyCaYCRRQNcitLR2TfO/nTmXhXlcnKoehyO4cA1UFA3zrZvykX0p scIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kf3WdR6R; 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 k3si5318134edk.215.2021.10.11.09.37.25; Mon, 11 Oct 2021 09:37:50 -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=kf3WdR6R; 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 S241105AbhJKOLZ (ORCPT + 99 others); Mon, 11 Oct 2021 10:11:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:56480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238701AbhJKOHm (ORCPT ); Mon, 11 Oct 2021 10:07:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9799360EB1; Mon, 11 Oct 2021 14:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960860; bh=igZ02GF3y8nG1INDR4EmmByHGxWL1B2xWoUCVF7N9eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kf3WdR6Rhfsv38YRr2slpUYQO5devCgE0YCdFoxIKVekz67sT3xY6J91ViKakEYOr WJ57gXuXNGcGm4uzQuQUTGftvz+McG6lKle9QwWRMpW45TBGcrltDKgksuui909wQD Bezq3xFpN9nV0u4+DhBEIxZZUsIH1ltqYbAcefgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Grodzovsky , Guchun Chen , Alex Deucher , Sasha Levin Subject: [PATCH 5.14 096/151] drm/amdgpu: handle the case of pci_channel_io_frozen only in amdgpu_pci_resume Date: Mon, 11 Oct 2021 15:46:08 +0200 Message-Id: <20211011134520.928526753@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134517.833565002@linuxfoundation.org> References: <20211011134517.833565002@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: Guchun Chen [ Upstream commit 248b061689a40f4fed05252ee2c89f87cf26d7d8 ] In current code, when a PCI error state pci_channel_io_normal is detectd, it will report PCI_ERS_RESULT_CAN_RECOVER status to PCI driver, and PCI driver will continue the execution of PCI resume callback report_resume by pci_walk_bridge, and the callback will go into amdgpu_pci_resume finally, where write lock is releasd unconditionally without acquiring such lock first. In this case, a deadlock will happen when other threads start to acquire the read lock. To fix this, add a member in amdgpu_device strucutre to cache pci_channel_state, and only continue the execution in amdgpu_pci_resume when it's pci_channel_io_frozen. Fixes: c9a6b82f45e2 ("drm/amdgpu: Implement DPC recovery") Suggested-by: Andrey Grodzovsky Signed-off-by: Guchun Chen Reviewed-by: Andrey Grodzovsky Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 177a663a6a69..a1c5bd2859fc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1082,6 +1082,7 @@ struct amdgpu_device { bool no_hw_access; struct pci_saved_state *pci_state; + pci_channel_state_t pci_channel_state; struct amdgpu_reset_control *reset_cntl; }; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index d3247a5cceb4..d60096b3b2c2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -5329,6 +5329,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta return PCI_ERS_RESULT_DISCONNECT; } + adev->pci_channel_state = state; + switch (state) { case pci_channel_io_normal: return PCI_ERS_RESULT_CAN_RECOVER; @@ -5471,6 +5473,10 @@ void amdgpu_pci_resume(struct pci_dev *pdev) DRM_INFO("PCI error: resume callback!!\n"); + /* Only continue execution for the case of pci_channel_io_frozen */ + if (adev->pci_channel_state != pci_channel_io_frozen) + return; + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { struct amdgpu_ring *ring = adev->rings[i]; -- 2.33.0