From patchwork Fri May 21 20:14:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12273677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32D5C04FF3 for ; Fri, 21 May 2021 20:14:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 569EB61353 for ; Fri, 21 May 2021 20:14:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 569EB61353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A7AA6F8DA; Fri, 21 May 2021 20:14:31 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2052.outbound.protection.outlook.com [40.107.223.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BC046F8DA; Fri, 21 May 2021 20:14:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TC5YJ/on0hCRrhTMSSXRv4dCxMohcKtFPvGF0PQ86bPeuHTCzBNoWsN0aJ5tOPHP9E5zX/HJCppwm/vWLDNsc5mz8kvEDCFroeXxGU7TcM+pR/iju3RopcJpRRt/nbym4aYli9icJLmsdrGQVlRcW/7EEgUthyraElkNPzBHXB5Ec4kDeRKHz4xziTVHzGlLzpmtd7UGiPTMneL2fFyZnH0OnRKhPLezU6CX1C06am2w+CqvLJVQCgARASes/ZKLIgDcn/cqKi6L0UlfNjx09+YSq/EZ7oAKJuqr3W/CxbVdeoOqOLbYNs6R8abjDDWv7Jc5S+/TO6Ko9a42kOAwhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVisVSSzU4/yujfVmyvXCHGhdgz4QE3euQLV38Az1J4=; b=QUHJV57OPUu9R+hLEc0M6VQOZYko+nvbkCOH3BY1XZquCkNIQT7j/58tv8OUqB1RUlULAVjItZg3U2ndmrkWgaUq7aWO+RGijf4j+JBrdVM10gxdLyzy1cFYYXiH+KTT155+MP/73/L/xAd2xE9R3s+v6epPreW2N9mZyQ5Zxs6Y+2iVDM01rIK3n5Jk7qXOQ8H/a2rWcGsC0ZRYiXSif1rIuYGu4cAGEhR83Z7O7aZU8qL7OoXyloRNSsz9VSorZzaE1zXL4bATTYUY9tGnxSG4VuBGuWR63a3M6qxietGsgdme1D3gxTdwIKhZc9TdKKJMD2A+v6fL4a0eVEd3Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVisVSSzU4/yujfVmyvXCHGhdgz4QE3euQLV38Az1J4=; b=VBYWsxwy24fQZzuJLzHDxA1e6ASK6Bv5w6ZNv8LYpx2Xh3tdbIxjuLDtysVfuWSr+uz5heSztTAEaZewxTHU8Of6Hm7IUtZDD4oJMURIVngZwCsyVFNWasIMLGeMOM10abHLkroCB9md6Wyr2/h+4bRhBwafgIv+YsyUn1b3ZpY= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB4615.namprd12.prod.outlook.com (2603:10b6:a03:96::21) by BY5PR12MB3906.namprd12.prod.outlook.com (2603:10b6:a03:1a9::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Fri, 21 May 2021 20:14:27 +0000 Received: from BYAPR12MB4615.namprd12.prod.outlook.com ([fe80::58e2:2ca1:afbc:5122]) by BYAPR12MB4615.namprd12.prod.outlook.com ([fe80::58e2:2ca1:afbc:5122%7]) with mapi id 15.20.4129.035; Fri, 21 May 2021 20:14:27 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, ckoenig.leichtzumerken@gmail.com Subject: [PATCH] drm/amdgpu: Fix crash when hot unplug in BACO. Date: Fri, 21 May 2021 16:14:12 -0400 Message-Id: <20210521201412.746745-1-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2607:fea8:3edf:49b0:b74b:1af9:3eb:e31d] X-ClientProxiedBy: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To BYAPR12MB4615.namprd12.prod.outlook.com (2603:10b6:a03:96::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:b74b:1af9:3eb:e31d) by YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.31 via Frontend Transport; Fri, 21 May 2021 20:14:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c712d03b-f7f0-469d-f0b1-08d91c95086d X-MS-TrafficTypeDiagnostic: BY5PR12MB3906: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cV0R3+lFAJ1WAkKNNUe5xdHLgEmrX1kRHDFHkxGE9g8ekmDlMBOjKYo8vo3NRskX3cZkyapL+qzrf8HXJbEihM3QtoCD6oR16bs3Tf0HPY5v/Rd7rlPoTQKkA2wVSN8zQ1glpW3/qZgO0e2erc6Li+X5zxXLpGKDGIBSdNUcC7aJvxvjMnQf73VDypqkolUYQMDYtScIBp0r3SXdxHKkphZE4V2mOeuIUooDvg7778Kmv1uyrwjzl2qmFufLhpMurAO1AUJ2Gr4k9Jy8ECWJQix6dU4Kk2TYvVEjSvZg5cfABSo7jhW2cLTdmiNs5nFNvwrx0//sFW2aZxs2kuEnWoKk0G8/U6i5n1QMCRnVZ/0XofZUvTVHnPCDgGOSLndPskkLr20Hmg0m2O+Q7wPyiWfXxmLfXfwxYou0LlkUnY00iOaC2NkHENdOkvKkh1eNWau9I1nAUHiPUZ7X2IebYfu6E517iQP8Mq8tAo8Ty3kJnViTsS9WppPSJkqnHsBh+8RCeh9sW44zKWs3t7ZKyT2etBpBesXj6HaEiHyLlnMJOTMNUilo058I9ArzQaa5LSAQlagoqBrpkbSY053WbH8E8/Be0oWbJeWRQ56uSbCTOJ/wA4WhcFAsqRDd1/XUXcaZ4nnB6uaixLM2O5wXqg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB4615.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(6506007)(966005)(38100700002)(52116002)(6666004)(86362001)(44832011)(478600001)(316002)(36756003)(2616005)(5660300002)(1076003)(83380400001)(6512007)(8936002)(8676002)(4326008)(66476007)(66556008)(66946007)(186003)(2906002)(16526019)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ys3NjIeIGw/LALEW4nCAkIQvCFhn9+UQ8Gs2uBp3KXYqq/ZbKjscQ73AWMnkT70MgnVKLG5XMPg8zawTqOPmnRIXc3vfanTUR19ze8axaZYLgf1yW1vQLRHD8FaTWIy5+T2nS2NeYKoVnvj66FISrfwCDay7ppB+kwik10ngytFGhdu1xGvL5LxxjOvCQwCI7GGHw8aDvt6Pl+Jqgp826iY7wqkp8kXf9F9+7Ei3WYCDFRrbFiGzNbktcLsyZbhAoI6Km8IwtFDKiYF7uXuUL5xwa+qUPh41VAzW/HzciCB20NnSw4nI6e2hOxsQNEf0Oh2I7Zctkj+rT6yFZ5gCW2zT6LGupLvjYzcm7UfRxrvDBmAdj3vU9OXLh2TT8N5te5SUEVXI66YbUmtrcd4LpnN3ohEEdDs7nUdxrAq42Fqc2xoCofS5G4S2Nt49w4N+fnPZ89yovQLfhd3/rbCaOzTX+iEeS6G1gqnAtXCbXnvSfXEo90zWx5X+UTiPwUwEr6tRx8mA1/64mWHeciynlI0PRQQOOtjXnqN3ayWuib+IIi6gBKOLxWA2W0MN5iNF3OzK2Tq1pN9BhqEPseOhPsjKBjgB1Cp+otdMc6rCyxJmSgCSkCbH2yomC4LP5UkX0jl+myevp7cgRJO1woZd8FG9DJ3EK6ugVe+orbNM864WmyV6meJnbdYwyEW9X0q3LVtrV55ejK9xr8JsQyBMk1cnNPSrRL8726pB8AhDmd+wjavmDDevf1Id5Z00OOVmsBZoSqmUGVGite+Xzpo3wbtYeE5KVc1cT7FUOm3CNeJyIZ7cVcemP5ZtFmTyKdFgwGnjM7Sxn2bIjrm4H16nZ3Vn3Wj9nM3iTQBZr73C0+25Ce0srhWJx6YY05ZqCYd6Cr7bftu/ZlTqGqM8BPKoJ+G72W4fUhWm/Lx+UMBcz57j4mAWfloW72zDOAfoGEaE1XgnMIGoXXLA96EblkZZRWZkWfn2e74U5XHF5puNOYTTdo1Z3xl/iXP0SOOU9fDi9oky9KXomGlH7Sk+AXvg8/4OrV0ugpBwM8+s1wAhpYe68n9Vzu/npmVMXOHnYZlBJcAc3mxX+VK/T0ph836EoYX7hPOXdZb2Rtj+fVqqJkowsk3+VW/f6t7/e5vbAx6MNm4fmJmp+v9haT93QL72dvFsDA25Oa9CAcJsIFeJJBKdsxIUTQNwQ3rH4dECglhMzhU00X2JamZ6vMk+QQULkaZKnbms2bz9DfLB8MY4rT5rYUHQEdwj3+1GLY14IBg0qgvGr/gjI6yahpnGc6dmdw/ayFBcqfkppHFqSH7Tgzw3kDKGxfkgpPTmphFhyOg7/MysGWUuiDFeZoGtOR/S/NJv8R/tJPr0fx/emg/1DQQLh1Jmq0pVDayxriur6PuX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c712d03b-f7f0-469d-f0b1-08d91c95086d X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4615.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 20:14:26.8672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZDhMpLnjthMptKM+EiHVO+9bi/J/L5yBIuOrr42gcN/GlsyvxShhZERsLrLmosF80CDmVRHmXana7eui+10U8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3906 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander.Deucher@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Problem: When device goes into sleep state due to prolonged innactivity (e.g. BACO sleep) and then hot unplugged, PCI core will try to wake up the device as part of unplug process. Since the device is gone all HW programming during rpm resume fails leading to a bad SW state later during pci remove handling. Fix: Use a flag we use for PCIe error recovery to avoid accessing registres. This allows to succefully complete rpm resume sequence and finish pci remove. P.S Must use pci_device_is_present and not drm_dev_enter/exit here since rpm resume happens before PCI remove and so the unplug flag is not set yet. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1081 Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index d8db5929cdd9..ab95ebf56636 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1555,6 +1555,11 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) if (!adev->runpm) return -EINVAL; + /* Avoids registers access if device is physically gone */ + if (!pci_device_is_present(adev->pdev)) + adev->in_pci_err_recovery = true; + + if (amdgpu_device_supports_px(drm_dev)) { drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;