From patchwork Mon Dec 27 18:26:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Deucher, Alexander" X-Patchwork-Id: 528421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A321C433F5 for ; Mon, 27 Dec 2021 18:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231609AbhL0S1S (ORCPT ); Mon, 27 Dec 2021 13:27:18 -0500 Received: from mail-dm6nam10on2059.outbound.protection.outlook.com ([40.107.93.59]:34753 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231622AbhL0S1S (ORCPT ); Mon, 27 Dec 2021 13:27:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XqBBXYA9Qd0QvRnqyMWDovfk9bEWIqN2/Mo7vgfHnxoXorQ7r4oGZfiwpn/p4QckQcfN0uYD50I9DtND5O+ds5IRVEMoEreIYQWx9qONoveKWof8VMcmlMfUIp7wG5WCZPMHaRPVvFac/xE6PAnH1cEik53N2N6DcjaX+oTNWF2Wv9AB8EnipEA7zSoaoRLJGiRRURuob+2q9gEVhUMQb4YDtGfOYmSdJOsLK6Gylf4R9R7No08ApqJ4hWEnti/wssbWptTBqVlAWDayMcCAOCcpQ/VVZXiuJpK1GH6Pf5/zMAf1bDHUYCBYj+HQF5C60riw6E6BAPogJjUurkZrWQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vW+p8NKGCiwOFZOb7xERZK7JbWeLxtGJ/fWV75NyPUc=; b=F3L7smnc6Lu6VywC3OXagOY2qmA2YLETwhKZP6sRE/GqekzY/0mEl59CjHRK2NZQJzZfDLnHrEBkOtvdLisdABDMaHy9voeKXhNeU5jKDPOLs+AaHxwscVjBPFsvzUNiB9mCxBraO0dTuwdnEnGt/b7Ls/PR2A11NUvt6jjRc6Wc6M9t/YXN8l+52eMeBv5LMTeBfv8dqH40i7np0YSKKur7ktoAWWgIp3HMgT6VYP6iKXsj4vw/pQH0zItiVJQWP0IW8JTPYL9EfCVr+PZcaMmLsSeNA2IA/h9ICT0LdRERMZ6OSYsM0LaPyrIhTn9zLFevhNkSP9amRQpRHz/8Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=vW+p8NKGCiwOFZOb7xERZK7JbWeLxtGJ/fWV75NyPUc=; b=Vfbp3tIMt2UjEihFdQI+NIZRpAGR2bwSdUp6WRRiflV5GpKWIDcBMgi5cHZBcN+z19bcUqrv/nPFCzR5Nv+hdR3jIOfmDgfxc6CQC3Z+IcypNznaEaAW9OLklT5D04KK/zwwcOaWm99dzgrESbn2zTOEU+21j9HxTyFvYfb8aKk= Received: from BN9PR03CA0227.namprd03.prod.outlook.com (2603:10b6:408:f8::22) by MWHPR12MB1840.namprd12.prod.outlook.com (2603:10b6:300:114::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19; Mon, 27 Dec 2021 18:27:09 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::48) by BN9PR03CA0227.outlook.office365.com (2603:10b6:408:f8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.18 via Frontend Transport; Mon, 27 Dec 2021 18:27:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4823.18 via Frontend Transport; Mon, 27 Dec 2021 18:27:09 +0000 Received: from tr4.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 27 Dec 2021 12:27:08 -0600 From: Alex Deucher To: , , CC: Alex Deucher Subject: [PATCH 1/2] fbdev: fbmem: add a helper to determine if an aperture is used by a fw fb Date: Mon, 27 Dec 2021 13:26:55 -0500 Message-ID: <20211227182656.2110664-1-alexander.deucher@amd.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b45c6d42-4ae1-4118-8e01-08d9c9667e43 X-MS-TrafficTypeDiagnostic: MWHPR12MB1840:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Tqj7gXIkQx6ow2uXsHc/pJVSGPT+5Wik4Uo3iDI7CaufVoIR+b4H+5k5kgqxNgb/WCJnj0bygrZ+RxMqj07A72qaF+fdg6AhrjxvsoRlABoXY4z+0WngmfiJ4rU7TXFS6FG3zn/FyoNqJpkxNMmC01+asZ37X3ywi21QuxdP2LMjZXJcll5T0xRBukYSYyu+UIAo893Hbe3LrsoScj8sc9kFvNJVP6oWn7kQiGFWyD/O8HxD/O/f86mo5aa1H6/tVzbpOtq4bEFehsfuTUcX/J2gndlbqJJ1SQjnZn8LxWlY/pl/b8Yl9s6oDaS9eG5FNlanhHMN68je0H+5NfF7HOILXlJqWNZfwraEbrjsfQ4JAztsCiwXR08lnN9A62uWH3ETOPkXxHZ2Iyn2a3f+2UMTdRZku2PDCy0khYLT1WCYQ9epywRaF5SFK78MX6HPbjKtZeLoTeFetnZGSzPzRvkruI2AO4nwYP+kNSBTxXoB/YSkWJPhKozm8sqIGj5odmlgWp32E27CXxO8w09gREIHxu3u6cnB6rbIgpKzHLsRZFYwzgvIsWgVzYfUJLn5bABdPpCNOfEpDJW+jQTWUipxnQDfBOs9v8VXsRuolov0PmEIUhn1myjzvtRmIR/QyuHLqQVkeM6nLWU1s57ex4+SY804TmUbH/mX9uxgfjjrxUw9vQ/Q/cs2lJ6sRGizu+mRO1ubRy11hvsQVYFCcH15p0w4QHq7xUJ4ZxOeCfv7nebagUsR9/W4tdXms+TELmJDUWwpINjfR2rA8l0WEFQK0Mrsfu/CXNET+a7rPMFoqdiXi+abWEIlCB+9q3byonclxm1BhzvR5GoKBbapm2k9Nj04ZMAES92zFHMIrKPCGfkdk/rh1lyy2TLLg0N X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700002)(46966006)(36840700001)(316002)(16526019)(26005)(186003)(7696005)(110136005)(336012)(5660300002)(86362001)(426003)(8936002)(1076003)(356005)(36860700001)(2616005)(8676002)(47076005)(81166007)(70586007)(70206006)(508600001)(966005)(82310400004)(83380400001)(40460700001)(6666004)(36756003)(2906002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2021 18:27:09.1370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b45c6d42-4ae1-4118-8e01-08d9c9667e43 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1840 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Add a function for drivers to check if the a firmware initialized fb is corresponds to their aperture. This allows drivers to check if the device corresponds to what the firmware set up as the display device. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=215203 Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1840 Signed-off-by: Alex Deucher --- drivers/video/fbdev/core/fbmem.c | 47 ++++++++++++++++++++++++++++++++ include/linux/fb.h | 1 + 2 files changed, 48 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 826175ad88a2..0fa7ede94fa6 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1762,6 +1762,53 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, } EXPORT_SYMBOL(remove_conflicting_framebuffers); +/** + * is_firmware_framebuffer - detect if firmware-configured framebuffer matches + * @a: memory range, users of which are to be checked + * + * This function checks framebuffer devices (initialized by firmware/bootloader) + * which use memory range described by @a. If @a matchesm the function returns + * true, otherwise false. + */ +bool is_firmware_framebuffer(struct apertures_struct *a) +{ + bool do_free = false; + bool found = false; + int i; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return false; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } + + mutex_lock(®istration_lock); + /* check all firmware fbs and kick off if the base addr overlaps */ + for_each_registered_fb(i) { + struct apertures_struct *gen_aper; + + if (!(registered_fb[i]->flags & FBINFO_MISC_FIRMWARE)) + continue; + + gen_aper = registered_fb[i]->apertures; + if (fb_do_apertures_overlap(gen_aper, a)) { + found = true; + break; + } + } + mutex_unlock(®istration_lock); + + if (do_free) + kfree(a); + + return found; +} +EXPORT_SYMBOL(is_firmware_framebuffer); + /** * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices * @pdev: PCI device diff --git a/include/linux/fb.h b/include/linux/fb.h index 6f3db99ab990..3da95842b207 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -610,6 +610,7 @@ extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const char *name); extern int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary); +extern bool is_firmware_framebuffer(struct apertures_struct *a); extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); extern int fb_show_logo(struct fb_info *fb_info, int rotate); extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size); From patchwork Mon Dec 27 18:26:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Deucher, Alexander" X-Patchwork-Id: 529930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3967C433F5 for ; Mon, 27 Dec 2021 18:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbhL0S1N (ORCPT ); Mon, 27 Dec 2021 13:27:13 -0500 Received: from mail-co1nam11on2066.outbound.protection.outlook.com ([40.107.220.66]:36001 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231609AbhL0S1M (ORCPT ); Mon, 27 Dec 2021 13:27:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MnbQ0Ns8L4xZWahrMnATC+dybx0HLF8kD+G+ZAf4ZP4SFXaYEEu45D4PT9J8IOHLxj0WYA0LsH39zKWUAerUMjwhF/sawOJ3fm9xrbkunenH0PulHlxw3QRZ2XclU1iOE2VjEBYlJcwKDdsvjKgBjb96jst6xs5X0hgz1DnDWHqbR4rnzaY7ZDuaSi/LyejkXQiaY4Z1vkFRZiLmq4LTxo7ea73nKIVL0WjfffK3PtrG/qHa7a9m4Oxb4vjXqhzT08wkqXnN0g+u70iHRNMaqU1EQPbAPgRmlXVb/zQk09d02gZuF0UYfSDpiDLzXhotztcvWB08DvmHT3lKDsScsQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RdWhkNxtd9/J4K14eZk1dhGVPdbC5d4CyzIHw0T9AxI=; b=OQH2st9Jh3mRoDj50pjISoGtdYsZUmGv/pUY+aiSIq1blFGf7ctvO7qlRWRyt3GFx8FpDV2mhKPiBogAO7FMtsue9fWWWHdyHfO8kkX29QZpdC2RvO8SaNiMhifDdfwWYRn1w/sZgOk9qqMcApKvvGl8UZBm63M+86Ush2hpE6YqGRQ2uHAUIUX4msg0bH9pJvQt2089zJ877ri4jfYWj+AqSh0TyeNj+kYkiKT5vkfTx9bUQJjBWmEB6gxWEOJ+wxhN1/UWlYSgKPDbJjKxnfgtKRBiCORiqkw4RAtiRbl33bJCN9bxbUR9zecB+W+MaiwAtaJ/Nhprwph0cNiGYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=RdWhkNxtd9/J4K14eZk1dhGVPdbC5d4CyzIHw0T9AxI=; b=NEECXV+6E6DlXWqmx7s8HmiFvl4c8LpHBvKf9xko1ZHHaZSpVOhwxXmSjxfGGfcga7pLkWW+fSCn3quI0o+sNVPKKj4BOwuUV+nhk1gPB5L02kNbZ2GOY8XozQDXl8QP6y96O9pQIGU2SiruA2ZiexCzK48IuD/MbpZAN3x4EZ8= Received: from BN9PR03CA0230.namprd03.prod.outlook.com (2603:10b6:408:f8::25) by BY5PR12MB5509.namprd12.prod.outlook.com (2603:10b6:a03:1d7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19; Mon, 27 Dec 2021 18:27:10 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::e5) by BN9PR03CA0230.outlook.office365.com (2603:10b6:408:f8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19 via Frontend Transport; Mon, 27 Dec 2021 18:27:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4823.18 via Frontend Transport; Mon, 27 Dec 2021 18:27:09 +0000 Received: from tr4.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 27 Dec 2021 12:27:08 -0600 From: Alex Deucher To: , , CC: Alex Deucher Subject: [PATCH 2/2] drm/amdgpu: disable runpm if we are the primary adapter Date: Mon, 27 Dec 2021 13:26:56 -0500 Message-ID: <20211227182656.2110664-2-alexander.deucher@amd.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211227182656.2110664-1-alexander.deucher@amd.com> References: <20211227182656.2110664-1-alexander.deucher@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ce62275-0044-44a0-5f4d-08d9c9667eb8 X-MS-TrafficTypeDiagnostic: BY5PR12MB5509:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:68; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lkhqAV/jMjK43wj2z2AcbQ2QE7jLeUD8Q6s5PrzoNilXHmBmMup0Cjd42+ymyAQ8CbcrGdHl6Nccf+v1N00fGKxW86N1e2YKWKrF2TMdGDKONVhMCQCfsg0dk9MX2c4Ys5dS8TCfGWhJjEX9t/mvz1gPuA7bxzgvJThOcw6rqKcuZ5ee4RuxDzO2/ErJRh5aoM/8fvKIuDVGzWiNscYiGnL0FWr7AOROguWSsSioKaaZijyiVEJYIfEX3RL0wlhw4YlKs49iB0Dbzs5CiVG7XeYvHYJV++KniXHchx7G4jDTWLAOBQWfQSXY5N1dHTPB8cqm7Nc57kFah4u6itXaqeSD1/Tmj5ea3N5lUNHB7pjojKLuUnJ5UPYvIViBcmSLDKZwE3Enwq1sR29p8WolFEs5rm1Lcg3plZLRbHHsmtLdZkFyCEsk76QH+miq4co9gkDtUFibR+0e3A50qkMUMeUycM44CWJy0+quzWWFAD+etW9mzf/IBrzCVrpOBVKRxNFAOsDCcL29XGmSeNsPGDlLwDp4RRrCKJFt6LEpdm199fXIe/xdgul1W0MAuPG0czj7Qv/bwV/wTUDBflI4Ai00W1WhH6rlrsUN4NXMyO0oQPLX6wG4LjMcg8yxn488HgWgR7/Z4UOR2BCRCPDaMnX0BMOL9VjU/nGI+YZXOXjp+yqEBiQlzimtlu43FmjJbFa1uBUwSaRX0H4fu4DRCfoAK39SnT/tNuMcDreHETbizlStirYL+TSmxEDpPDLKYLC/C+sMn95hUAweW+d5ilInkwbOjZqPZcDTjtyiieEo9v21qqOPzOdQuHpZHZyGgS4YgaMAptVMlSbxsUJdXdyVN5HXaevzRaqsfdqP7n8Xzq5U5EFR/j73CF/3NRHNWi2XtNbTU62Yc68aCBg7xw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700002)(36840700001)(46966006)(7696005)(336012)(40460700001)(2616005)(2906002)(966005)(82310400004)(356005)(81166007)(83380400001)(8676002)(426003)(508600001)(6666004)(8936002)(70586007)(70206006)(47076005)(86362001)(110136005)(26005)(316002)(36756003)(5660300002)(1076003)(186003)(16526019)(36860700001)(4326008)(21314003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2021 18:27:09.9026 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ce62275-0044-44a0-5f4d-08d9c9667eb8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5509 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org If we are the primary adapter (i.e., the one used by the firwmare framebuffer), disable runtime pm. This fixes a regression caused by commit 55285e21f045 which results in the displays waking up shortly after they go to sleep due to teh device coming out of runtime suspend and sending a hotplug uevent. v2: squash in reworked fix from Evan Fixes: 55285e21f045 ("fbdev/efifb: Release PCI device's runtime PM ref during FB destroy") Bug: https://bugzilla.kernel.org/show_bug.cgi?id=215203 Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1840 Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 28 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 3 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index b85b67a88a3d..7d67aec6f4a2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1077,6 +1077,7 @@ struct amdgpu_device { bool runpm; bool in_runpm; bool has_pr3; + bool is_fw_fb; bool pm_sysfs_en; bool ucode_sysfs_en; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 86ca80da9eea..99370bdd8c5b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_irq.h" @@ -1890,6 +1891,26 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static const struct drm_driver amdgpu_kms_driver; +static bool amdgpu_is_fw_framebuffer(resource_size_t base, + resource_size_t size) +{ + bool found = false; +#if IS_REACHABLE(CONFIG_FB) + struct apertures_struct *a; + + a = alloc_apertures(1); + if (!a) + return false; + + a->ranges[0].base = base; + a->ranges[0].size = size; + + found = is_firmware_framebuffer(a); + kfree(a); +#endif + return found; +} + static int amdgpu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1898,6 +1919,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, unsigned long flags = ent->driver_data; int ret, retry = 0, i; bool supports_atomic = false; + bool is_fw_fb; + resource_size_t base, size; /* skip devices which are owned by radeon */ for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) { @@ -1966,6 +1989,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, } #endif + base = pci_resource_start(pdev, 0); + size = pci_resource_len(pdev, 0); + is_fw_fb = amdgpu_is_fw_framebuffer(base, size); + /* Get rid of things like offb */ ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &amdgpu_kms_driver); if (ret) @@ -1978,6 +2005,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, adev->dev = &pdev->dev; adev->pdev = pdev; ddev = adev_to_drm(adev); + adev->is_fw_fb = is_fw_fb; if (!supports_atomic) ddev->driver_features &= ~DRIVER_ATOMIC; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 651c7abfde03..09ad17944eb2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -206,6 +206,12 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) adev->runpm = true; break; } + /* XXX: disable runtime pm if we are the primary adapter + * to avoid displays being re-enabled after DPMS. + * This needs to be sorted out and fixed properly. + */ + if (adev->is_fw_fb) + adev->runpm = false; if (adev->runpm) dev_info(adev->dev, "Using BACO for runtime pm\n"); }