From patchwork Thu Jun 13 16:59:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697156 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0269CC27C75 for ; Thu, 13 Jun 2024 17:01:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73FB710EB29; Thu, 13 Jun 2024 17:01:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="dMflzdwY"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF35510EB07; Thu, 13 Jun 2024 17:00:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ENddFGwA8nWLGN62mz3QehEayN0EMi7GPpt67KAN4faNn0Xc7Jvmd9FCSvy4Ax0TMERFAdxGySpKaIp0fcJ5dcaV09920hh+T7uR8irN+6EdwM+/SABYjHmMGebi+I5NmHTnOVZhpev7pGgQhxpV96J+ngq9vvMcoacBSTvBxnoDUP6rSD3nFhk78VYrX+0M2hvPHggtjTK4Z8bzgkN4Hvdnk5yBkzGr5TtQfziyc09HzrH2QZr9iHx98D8qbC5nhE7yhX5/7Oh+OKOVC98B+mQpaf2gQbfrPegBOMH1C9+nl3DbDGHL20mkxbRqwI7E4Wg3R5uItbjNZGWXYfhZiQ== 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=RQ2k7RfrGgI6aaQ0Kd7fmVBlbuY+nJAZbDL1cJqsBB8=; b=Wks1ldpPQxBUWgCIar0l3CPwwoD7wKuQmaH36cEwS0mSYtSmtqiUh6NRr/1EpVbWy9yNyfkJMFwPhq7yQG84gvVq/ee25S2YZGLqHciUpvE0mZHON5r2udN66HfxDOIsyHqgUZzoJiLWRmjwoSfhwi0migXNdOAGdo2woafnlvajCTNljr8mHlbotEg/QCLsC01t+XgDy7bcP4H/sZ19HaHG5J8mwdkfr6kEwPzwPWxyyhzry6WoHRMZ3sug3azdZUJBb2GNjHh9FqGUfaHroRT9q/vfFqgJYzpdbdV+HaeBEIOSg9VgAJr1l68GSt9Rv86PokeE27cDGHM2iR/P0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RQ2k7RfrGgI6aaQ0Kd7fmVBlbuY+nJAZbDL1cJqsBB8=; b=dMflzdwYUZAlRZa7u6sBRvq2tV4fE0Zlym41OnZeOnAbpjWKKxAN9EQ2ne4+ulet2fJAW5T5jSkfSnF/TgP6KHwBPgbjWDfICCF1L7JD/G4ilXlDhYaxJaB6UvvPQa6gF7o/CbqsBB5Nyu3x7VQH5H9UFdIeDo1Q8OQ3hSAkyrlZfffePDn4dTsL9yIhtIg4A9Ijc+Yf70NTurUJbqCkLoMcwsm+px/esfsBFyHNWEffQtZCOgMG5qaqTRBHLJuimkunagE75qox/MteHQxd/CGlcfYvyTCy9UFr30zAcYbscNmyR35mAhY3SRDXPu5QVgXl9cUH3HyKFvohJpWzfw== Received: from SN4PR0501CA0043.namprd05.prod.outlook.com (2603:10b6:803:41::20) by CH3PR12MB8994.namprd12.prod.outlook.com (2603:10b6:610:171::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22; Thu, 13 Jun 2024 16:59:51 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:803:41:cafe::2c) by SN4PR0501CA0043.outlook.office365.com (2603:10b6:803:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 16:59:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:37 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:36 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 01/21] drm/nouveau: fix a couple of KBuild comments Date: Fri, 14 Jun 2024 02:59:53 +1000 Message-ID: <20240613170046.88687-2-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F61:EE_|CH3PR12MB8994:EE_ X-MS-Office365-Filtering-Correlation-Id: 71b6f0f6-c033-4baf-6b53-08dc8bca3dcd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: MQwM8dfxj5Dq3CRuzOh/8lCBWRASlhzXHI149g3OiUtrpsD4ur/VQG9jAhIfHrcuWZOXJMCS7YBfnuWGS+WLfQntx6xg0ooxQN9DVqeq/esyXYO6BAbjEDxFSlEI1+3LKzZ9psPe6sOFdUw36nH9flVkhNjvoBlcYbD41IytyWPi9Y7DNUAEO2E6InEo+bP2ggGXeCh8/FCMsS/KSqb5I24ahmezXybNk2XKM6zar9HhUj8/9QVgBG0sf6tfOgyR4yOsoWyVPXqTafi8SkUexLNUqxa5X2l4tfkHXAaOhOaeKGEOyjdUkOfi0mj8+EX/bC1ozbcbLrlmmpiqKF3CGbucVYxmFF06tAsc2s2IWexo51p0OxxbcZct/Jw+QiAJyT93RywL8333z5X+zz+VhyTf3CaqS1IVVrs+VbKu3YyESlMQl8VzZeB+ofoq6FNIkLz3z0kZFP1aQU2/m11M7ZYnOwwYxjH10Ae9zIYaqj2hob0jBGMyNUibpey3SkRfzH7H+U44Y1eIpFwc/C/9DshSeJqevy9v9W+sKei2tt404+U+RchG6iTjKat6lBKsO+78Hii/6eHSjEGdW5RHSqOYRq5qqofXJT47DKpZ8e+j89quXD0ox2GXPBSM4C3w3Ogh0AngmBnV35JRHSfrmYfnqKvvF92F/GW4C9hkXEJ8s8dBLb4U/q8VSSVDBFoeSfaeBxasWZK79ai+t29n/jW0CXwuNUcCThAws+SLx8pRB/OeJlcdtSy6VGNUR8UnnC3AbyPBccQX1rE5R1oXCIoMyVt16o2yY1gZRp/NdIsS+DczJuhjSF0cIcCvxrML8ctqAdFq+BvXp0HQnLtv2pKQnsCiPQFGsZgMAzi5qfqBrH6NZEiYR8ag2OmfJMxVuTgzG59Rwg/eUnSpleLdo6YNCRmnuS1+5Vs/Yqx/Md1zskYJXPkke1zvFyKsSfZFCI6sJJRFGh1XFMtOClN19mEl419sqqNXSfl2aqyp+eiWsqXmoNedah//ET/sGfs3j9ablzMSmQRUaR4GVzJCv0AuE5415iO8GV+6mr58210uc+tw2J1JklrxOoq/f9c81wOjoTYLzIwN1jrm17zMREAg0CaPZGJaqIYtbJflJRj/hmyNevwVNrTUvtwKTAm8bA7638zVU12KYpcunTMGjeVJpfP+TLNYB8qyEkgpOaIKlBXQ1Oc7I/EP3KfkrtJELd42ZiHp4dqpxVAfWEMsq+WozM+Tbunb2UfmwQfIciBkZc4Xhb5gqK9ICGBkPRzTYBFu7ujKwcS3K8I7PgonP9mRo1gE4W/NftUMRCBmV1kL/zw7M1L3utzxGW6WQVl6DZAw1tJ61ASlYjjXLKoyHYlvHNXNCxtv2yEQJ2sEF4IC+P9R6IHKRKbabQt8GBLFLOvcDwCbHqgFKGH0mdn3DA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:51.4888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71b6f0f6-c033-4baf-6b53-08dc8bca3dcd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8994 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The NVIF/NVKM comments were backwards. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/Kbuild | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild index f99b7b227947..61eeef83847a 100644 --- a/drivers/gpu/drm/nouveau/Kbuild +++ b/drivers/gpu/drm/nouveau/Kbuild @@ -7,14 +7,12 @@ ccflags-y += -I $(NOUVEAU_PATH)/$(src)/nvkm ccflags-y += -I $(NOUVEAU_PATH)/$(src) # NVKM - HW resource manager -#- code also used by various userspace tools/tests -include $(src)/nvif/Kbuild -nouveau-y := $(nvif-y) +include $(src)/nvkm/Kbuild +nouveau-y := $(nvkm-y) # NVIF - NVKM interface library (NVKM user interface also defined here) -#- code also used by various userspace tools/tests -include $(src)/nvkm/Kbuild -nouveau-y += $(nvkm-y) +include $(src)/nvif/Kbuild +nouveau-y += $(nvif-y) # DRM - general ifdef CONFIG_X86 From patchwork Thu Jun 13 16:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697146 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 184DFC27C4F for ; Thu, 13 Jun 2024 17:00:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E1ACF10EB02; Thu, 13 Jun 2024 17:00:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="GT0kTLkc"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2040.outbound.protection.outlook.com [40.107.93.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21BD910EB01; Thu, 13 Jun 2024 16:59:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RDY+wOfMk6JxhOlaDGFCbe31sgrDukQwVdmAOqPHC9mfjKgLO2U+1AvNy+bEZmVrd/WwH+TYmcvvTiOBHoqvN3LI47Ady+M/CYxphluSGVkdgELv6c2mbkZpaly6uPuNYm1KEtkfqqIHSpjKuwLPXRtZYr6NYmHlSpScZgj/E0ge15ptMUrzNwYKxIl2Id1Ep+DpqCd6lAG1IoXnYeabZLfFP4C7M1ivV20bOJBBVFSsP5riT8ssnBdbfH8Go4kEAdXGFhgjvfEONLMK96LBLTLSrL+yYOzzPtrfvQjkVBzy8tbIfO4whPavR5FDU1VikQlWQTIBGjCUdx7c4EYJjg== 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=iTuLLUy31K65op6xGQ22GuSGw/42gslJTpRqQVTJhsE=; b=epWJcG+wNDDKJvDvhf/Jlc0c0mmNiRvB3mhYL6RZFOlIubBRSzzICJ6V/9b3SsEsRXY6qtbWMf6XFbpe0SNz9NEmdTaw8eI4hoewlMKFACFmMMS/EKel0BQifWxYVfKgXcRzSvTbiPLeahaZkHM1wwm0tiJftvBrvGwIbcmXr3aHsJKnw+4J1w+fRpjjXj508NO5LpwYcKek7wBQ/WgD9+LgtODGfhU1P4Z2NHsBA8YV4YYpAcpimzB0tNwdeJgBnSBTORg5HUo6LtcG93wGEPFP2YHDBKuwxqWXVs6JdDk/hTkZU1SCPuwQqZmQYph2fxQYGZfRet+7uOOck0SjuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iTuLLUy31K65op6xGQ22GuSGw/42gslJTpRqQVTJhsE=; b=GT0kTLkcaFv649NdJjMq9kB/I209TUm+LWHaPPGq4H/2kuxzLcGsiI5U4FlRqWuvGuD1Vsg9okDGkqENARefSKnEblxZTNdUIxEFveecmhscY1ZrIDStC9K46wf8xtOMfdJ8as/GpLWjh4FskCIVD7WQrcvJs2A7hgCYbugFHVrlqpD8dju0UXOjst4tYzKyDyY/Q27Zfi0gvbJWCmiw5MqDn1kFNSd58VEHHUmgNL8WPSIQ3Y2f82WYpip4e9aSk2Tf4cEp8e3eJcEZsa1x7H4R88hBZwAZezpXawTzfrSd2oigjydqbvnDG/6OOqMjNUaQIftqFZKi+J/7TWlhHw== Received: from SA9PR10CA0030.namprd10.prod.outlook.com (2603:10b6:806:a7::35) by IA0PR12MB8255.namprd12.prod.outlook.com (2603:10b6:208:404::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 16:59:53 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:806:a7:cafe::e6) by SA9PR10CA0030.outlook.office365.com (2603:10b6:806:a7::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 16:59:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:39 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:37 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 02/21] drm/nouveau/nvkm: delay calling subdev ctor()'s until device oneinit() Date: Fri, 14 Jun 2024 02:59:54 +1000 Message-ID: <20240613170046.88687-3-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|IA0PR12MB8255:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d0148a0-a659-4b5f-d642-08dc8bca3ee5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: bWqoigDr9ccWpDZkFZ5IvlaOT7rqnHVl1QDYFlvxJmHRfzy6VYLzOQBkPYj9cSQwZl14hoICGzhkKdps/XP6Km7kpaP/ZOIDq6apTS2MDBLXY4bNRr4xcVPKjj+BPzOXOYaCjmdS8+OBZIi1DUa0URj4lOvwcbUUuM87AUy9e2WsepzU5DMqw8fb/EWZTw1lcnQKInBNentCh1bgFyDEpWou/87QiQUj9llN/XUK/Nu2bTrr6QfWjBO4BwsuAJEm3nFyH8Y7F2subgH2+3Q1FPgpADSGcpLTjCUuFKDx2MXv9IbQy1l/f3n+OGFocpVvMbNXqAjuSrK7DN8Q9g0PIoyx7yUq+xdtX7OowRCt5MjpbPW88JxMMB1gJ+Cj2esfV7Lgu8FS1J2O6Vs8hlSWZH3P/qZxkn0ZpP5QE5nSQX7pNuPEZhyhs2KEPGiFYPwGMphyIboSrE2KeXDMN5/dGIeYVLa/yf6FpFE4tZC9C5a4eVCaU4gk7bzQlIbLN+bLw+MUnzvAo5p+YHa1jAOeU2J5dfly3X2+CVG/qDmgMcnyLQJrm5/SUMpYuYNMw4S26VsuVhcnOumdhplDHpQ/2aBhKgA+ituHwMLbT5aH4O7N1dVNfmdmyJICNMBnDYtl1YZ1EuwepHQn0LfTEUOXzWaeRibzkmLX4hTrPpLZxPRUZQ1jDioIz9ro6IAA+Kya0JMgycLYxY64SwAqBmN0aShiOZUlKRH9iM0aSY/4NqNlL97JnuMDt9uosfuTbrvaKHUh7lLTOV8vTdF7RekRwep+2fxB6OzInDYSCvjvDWrefU+tNfCdok5IxJaRecfbO9QjNY40VxYQxyS+4aoBPceZauHtoXXp3lWz+Jxz908wndyc+IqCRInG8Vsgzy5BtnrWvUTHtNTIeGti+HuNA5Wxd0HO9ONM5FYjUHMJB7BbPax57mYtMh6tM7YIcGn7NQyMK5wO//ATZM7E17rwjamO2iKHxwJ0z+18rPzoiX2LglfiMviik92PH7MvLfbKfBi1HHiU3yVuhCmE2e8XKVBzA0dch3aaColEdc3RJAJbyVWg/lL+ShSbImau16Ds5sku8rdr3hW4pGtxYeW8Xm5lhvCnIUKGfxwQ5+i+GB3YhWwQz1hnuwU2FFnfbDrHLgCqRahuWc6Bp2Rxwqhx/HHnNJR+sqICll2SKHQa8eR4EWjnCS/KS+V6u32R09TF6zwV8FttUsg+D5Ew/HilL7w8nbE30/SYA92EA5riFk6K+Kqb/rrLt1YgwQWzbV/YQB+9aVc/NiKxXP84+ZLnsISsYHwRdzQX+YRHHDpnO0nF+BVr8dEFfhI+HTrADVflfUnwg+WNtggUbfz/oORe3PIAxhGXV4mMNixQ81g1sT1jwOIe2Keic3pkyEdMW6qjR/+7McqbRSB1tXxwyHYvBg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:53.3266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d0148a0-a659-4b5f-d642-08dc8bca3ee5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8255 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A later patch in the series converts nvkm_device_{pci_tegra}_new into PCI/platform device probe functions, as a step towards moving all the PCI/Tegra-specific handling into NVKM. nouveau.ko has two module options (nouveau.config/nouveau.debug) that affect the behaviour of NVKM, however, and the probe() functions will not have access to these, which would break a user's configuration if they depend on any of the options to workaround a problem, etc. To avoid this, we delay calling constructors for each subdev (which could depend on module parameters) until allocation of the first nvif_device, which will allow the DRM driver a chance to override device.{cfg,dbg}opt before they're needed. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 + drivers/gpu/drm/nouveau/nvkm/device/base.c | 112 ++++++++++++-------- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 2 +- drivers/gpu/drm/nouveau/nvkm/device/priv.h | 3 +- drivers/gpu/drm/nouveau/nvkm/device/tegra.c | 2 +- 5 files changed, 71 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 965331e65fda..18990d21dc48 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -644,6 +644,9 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren drm->nvkm = device; + device->cfgopt = nouveau_config; + device->dbgopt = nouveau_debug; + nvif_parent_ctor(&nouveau_parent, &drm->parent); ret = nvkm_driver_ctor(device, &driver, &impl, &priv); diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c index 20609571793e..1b76c2a60799 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c @@ -2908,6 +2908,62 @@ nvkm_device_preinit(struct nvkm_device *device) return ret; } +static int +nvkm_device_oneinit(struct nvkm_device *device) +{ + struct nvkm_subdev *subdev, *subtmp; + int ret, j; + +#define NVKM_LAYOUT_ONCE(type,data,ptr) \ + if (device->chip->ptr.inst) { \ + WARN_ON(device->chip->ptr.inst != 0x00000001); \ + ret = device->chip->ptr.ctor(device, (type), -1, &device->ptr); \ + subdev = nvkm_device_subdev(device, (type), 0); \ + if (ret) { \ + nvkm_subdev_del(&subdev); \ + device->ptr = NULL; \ + if (ret != -ENODEV) { \ + nvdev_error(device, "%s ctor failed: %d\n", \ + nvkm_subdev_type[(type)], ret); \ + goto done; \ + } \ + } else { \ + subdev->pself = (void **)&device->ptr; \ + } \ + } +#define NVKM_LAYOUT_INST(type,data,ptr,cnt) \ + WARN_ON(device->chip->ptr.inst & ~((1 << ARRAY_SIZE(device->ptr)) - 1)); \ + for (j = 0; device->chip->ptr.inst && j < ARRAY_SIZE(device->ptr); j++) { \ + if (device->chip->ptr.inst & BIT(j)) { \ + ret = device->chip->ptr.ctor(device, (type), (j), &device->ptr[j]); \ + subdev = nvkm_device_subdev(device, (type), (j)); \ + if (ret) { \ + nvkm_subdev_del(&subdev); \ + device->ptr[j] = NULL; \ + if (ret != -ENODEV) { \ + nvdev_error(device, "%s%d ctor failed: %d\n", \ + nvkm_subdev_type[(type)], (j), ret); \ + goto done; \ + } \ + } else { \ + subdev->pself = (void **)&device->ptr[j]; \ + } \ + } \ + } +#include +#undef NVKM_LAYOUT_INST +#undef NVKM_LAYOUT_ONCE + + ret = nvkm_intr_install(device); +done: + if (ret) { + list_for_each_entry_safe_reverse(subdev, subtmp, &device->subdev, head) + nvkm_subdev_del(&subdev); + } + + return ret; +} + int nvkm_device_init(struct nvkm_device *device) { @@ -2915,6 +2971,12 @@ nvkm_device_init(struct nvkm_device *device) int ret; s64 time; + if (list_empty(&device->subdev)) { + ret = nvkm_device_oneinit(device); + if (ret) + return ret; + } + ret = nvkm_device_preinit(device); if (ret) return ret; @@ -3012,13 +3074,11 @@ int nvkm_device_ctor(const struct nvkm_device_func *func, const struct nvkm_device_quirk *quirk, struct device *dev, enum nvkm_device_type type, u64 handle, - const char *name, const char *cfg, const char *dbg, - struct nvkm_device *device) + const char *name, struct nvkm_device *device) { - struct nvkm_subdev *subdev; u64 mmio_base, mmio_size; u32 boot0, boot1, strap; - int ret = -EEXIST, j; + int ret = -EEXIST; unsigned chipset; device->func = func; @@ -3026,8 +3086,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func, device->dev = dev; device->type = type; device->handle = handle; - device->cfgopt = cfg; - device->dbgopt = dbg; device->name = name; device->debug = nvkm_dbgopt(device->dbgopt, "device"); INIT_LIST_HEAD(&device->subdev); @@ -3265,47 +3323,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, mutex_init(&device->mutex); nvkm_intr_ctor(device); -#define NVKM_LAYOUT_ONCE(type,data,ptr) \ - if (device->chip->ptr.inst) { \ - WARN_ON(device->chip->ptr.inst != 0x00000001); \ - ret = device->chip->ptr.ctor(device, (type), -1, &device->ptr); \ - subdev = nvkm_device_subdev(device, (type), 0); \ - if (ret) { \ - nvkm_subdev_del(&subdev); \ - device->ptr = NULL; \ - if (ret != -ENODEV) { \ - nvdev_error(device, "%s ctor failed: %d\n", \ - nvkm_subdev_type[(type)], ret); \ - goto done; \ - } \ - } else { \ - subdev->pself = (void **)&device->ptr; \ - } \ - } -#define NVKM_LAYOUT_INST(type,data,ptr,cnt) \ - WARN_ON(device->chip->ptr.inst & ~((1 << ARRAY_SIZE(device->ptr)) - 1)); \ - for (j = 0; device->chip->ptr.inst && j < ARRAY_SIZE(device->ptr); j++) { \ - if (device->chip->ptr.inst & BIT(j)) { \ - ret = device->chip->ptr.ctor(device, (type), (j), &device->ptr[j]); \ - subdev = nvkm_device_subdev(device, (type), (j)); \ - if (ret) { \ - nvkm_subdev_del(&subdev); \ - device->ptr[j] = NULL; \ - if (ret != -ENODEV) { \ - nvdev_error(device, "%s%d ctor failed: %d\n", \ - nvkm_subdev_type[(type)], (j), ret); \ - goto done; \ - } \ - } else { \ - subdev->pself = (void **)&device->ptr[j]; \ - } \ - } \ - } -#include -#undef NVKM_LAYOUT_INST -#undef NVKM_LAYOUT_ONCE - - ret = nvkm_intr_install(device); + ret = 0; done: if (ret && device->pri) { iounmap(device->pri); diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 3ff6436007fa..8bfedd79d7a5 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1679,7 +1679,7 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, pci_dev->bus->number << 16 | PCI_SLOT(pci_dev->devfn) << 8 | PCI_FUNC(pci_dev->devfn), name, - cfg, dbg, &pdev->device); + &pdev->device); if (ret) return ret; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/priv.h b/drivers/gpu/drm/nouveau/nvkm/device/priv.h index e42b18820a95..176cb1dfb2fe 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/priv.h +++ b/drivers/gpu/drm/nouveau/nvkm/device/priv.h @@ -54,8 +54,7 @@ int nvkm_device_ctor(const struct nvkm_device_func *, const struct nvkm_device_quirk *, struct device *, enum nvkm_device_type, u64 handle, - const char *name, const char *cfg, const char *dbg, - struct nvkm_device *); + const char *name, struct nvkm_device *); int nvkm_device_init(struct nvkm_device *); int nvkm_device_fini(struct nvkm_device *, bool suspend); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c index d1c294f00665..bb514ccdfff4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c @@ -310,7 +310,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, tdev->gpu_speedo_id = tegra_sku_info.gpu_speedo_id; ret = nvkm_device_ctor(&nvkm_device_tegra_func, NULL, &pdev->dev, NVKM_DEVICE_TEGRA, pdev->id, NULL, - cfg, dbg, &tdev->device); + &tdev->device); if (ret) goto powerdown; From patchwork Thu Jun 13 16:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697147 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D513FC27C75 for ; Thu, 13 Jun 2024 17:00:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7446510EB07; Thu, 13 Jun 2024 17:00:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="kJD1BS8G"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2081.outbound.protection.outlook.com [40.107.220.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id A80A010EB08; Thu, 13 Jun 2024 17:00:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G6fDPBRq9IyN/6U8Avypm00YdiQ4O/RpZMReICFHZ3TgktX3K3iJClrUdPdv2CidAC0mG4dcichEEbVMNcX1rTYQ4xRUZk77UiJz3F98iw+56cCZ2SZLoYT2D6gxlUiNjaF38C/k4Iutoj8CBjsuvVu0vfuJSLiWaPpDR9WFmyzs3o/7mgOnMeMpq8x4idHsx0hCNsnKZ5qOpBYO/HfDxBxlvMIbmWdL4RoSZRoN6S2k9dYAak17PQi3m8MPLR4WW/vo1v8FGE0ro/jT3C5tpefznZ9/wpJWBnRUsBmpW29DVQDC2CfTd2LxleVd3f8H5SAkRts76BykHMhVWfp3Ig== 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=nqjVwfXBjSBY4LKXfslRF2VbLR6thzhJT34hmkShqgQ=; b=ADdb+mwnKOyOPCX2DlbEsri3sA1ZOfQ59AVfR/EcGMkWg4lM8zDzd+RyIdMsF8ymfFCn36BoZwv58ebd8sTI6IquB8AzBPuKjO6LSVz2/KM+aVJVuB6PE5OIxgkAipOwrBYjDVA0naMTZhqo28aQYao7H4dmn72+yENfqaNe3vagU5Ym3t5f7O5HGr3dODKC3OjVLKp5qUnlYLdHz4MQH8NCfBw/AaRBr3zQgWDEE+ueQrHKbzgMbeIaUjpCJs76ehYRZ8T0f8YT0vzaP03WjG7lNZLQSygbGUpDTlqweVZDt3gqt4S7FVUYS8jN3s1vYzhZX9UcsVHgLDlNPb7dPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nqjVwfXBjSBY4LKXfslRF2VbLR6thzhJT34hmkShqgQ=; b=kJD1BS8GlwqWSui3YX20NBQtkkn4noU4bMfSmD334ZtbKIA/xTcTbXJeSre4MtQClvCSWwS4hfMm6ILBuCfAXTcaUqCyQ51gAcPJWhfuUv/EPFktDeONmzM92pmsLbTmP2s/U9Q7Ujpu47lp2pVxHm4cb+ZcXxedHPUZclI226aTHa9XmHkL8kSA1B6JUnmYWsQHIK6mri/1pfoeqX8FllljEjxAxk9ztdym1pNFG+LVU4pi9fmwZiDlWCpJBIc62w+u0g7hKnjeOzi9aOJQFiO3qqM32sIP93canMdtdgU8vOYfT6ttMhSgDSCDQ57ohVT6hhpyPx9ch9FuaZrjyQ== Received: from BYAPR05CA0059.namprd05.prod.outlook.com (2603:10b6:a03:74::36) by LV8PR12MB9452.namprd12.prod.outlook.com (2603:10b6:408:200::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24; Thu, 13 Jun 2024 16:59:55 +0000 Received: from SJ1PEPF00002326.namprd03.prod.outlook.com (2603:10b6:a03:74:cafe::ae) by BYAPR05CA0059.outlook.office365.com (2603:10b6:a03:74::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.23 via Frontend Transport; Thu, 13 Jun 2024 16:59:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002326.mail.protection.outlook.com (10.167.242.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:54 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:41 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:39 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 03/21] drm/nouveau/nvkm: add nvkm_client_event() Date: Fri, 14 Jun 2024 02:59:55 +1000 Message-ID: <20240613170046.88687-4-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002326:EE_|LV8PR12MB9452:EE_ X-MS-Office365-Filtering-Correlation-Id: 0492a8d3-84dc-4659-7ce6-08dc8bca3fb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: i8y1kwm+LY6X1eZmFWeQrm2lu47hFMqvSN+iBRmxm2K4xp1KgjbctXY+dNBZpLhOEtSro89EwBQyV/k/z6/2EF+sDvTXeujcESanR+1MungeyKkPc3VK1XO/by56vREgvgA4dLST7Z2qyzRD/mNwCt2TOpWxs6VIbYshYWV5WdZI8haewNOEhXxXV+sPtiK/AOSsuxFxBzREBriVY/lURrVE919tNL7iUH7i6zleKF55AI1dosMHPSP7a2NKspA+vYz1Nd95BIBvBCP7rkzT0OB/JDGLWxL27ALWEJ8PFEj6a/0Yl+9hcMAf+woKqhccByWOVDyncTx3LARvryReM0oXGqEHk4p+Hj2Wgz2ioaIuntYp8AZZ+jd7utljOdZVXmib4FJBdBI5WSooOlduWfudVO54j2bzMK+ccZi2EKUAj+Xlww220HcOPl2UqCRVJe4Jklagf+L615V17fdBE+fXD9A8ucsLH649a8vV1iJ2eD1SAKtpZL5SbOoOxUZqFepZiSqHXFQOI9slDTV6sE9m6x7jXMGFPFX9DeRVV5AWJV+WMPkIBYXtZgJTvMSLosF05OMv396/r0wEayJQHkkNRf3NOdPF+SUxqb4jbnW8AesMCkxfweJc9TgiLDPVemo8FGm+HRi8Y8/9N2+3xqu/YQ+l1vHi2kbjRJ9pH2TsgMv4MvWcPd4DK03/Zh1IWIMt/rN05W1hr9KZpwY6jN8nNzZcHmWX0EYagjFhqUnTjAUjlIIfTypY5E/bEZNTJmKQfp8dilp3OCteUYpgOw8A2jmZFz2Tgq05ilA7zUE9iqrU7KrbACRVoKx4Iu7yWAxpAfqcBr6KsHgDmmLWrznSnCN53K3Z21Qfw0I9TlARMu6eEsGEsDCVYPYS380JWNY/JTXbWloLipj1y86/WWnseHHjA2Mu+kDlTYJaySb2REGUBuS4ZS86jpiEJZPGQ/bbWCcJWrVmWbtEigLUeijVXicLxju2sqgXbgPePtXKtIz0agGMa7s2qVDBKElYL/acguTtzz8FkCr65y6fk1h5XpWYNpexyqSeKgrDuRbNUdjWOQ8qDN3Z+KhiQie+VMkgMI7xVCC/WaZ/HvNfvEjhM6pmE9bX9iG6oKx/ww39kolTE7dOI7ui0q7OlNxtdzWmbs7snOSw9t6uhzkfIwtL4bN1KafXwbFSRwW47YyjcPXH+B12DtTzwYWY2SBwJk4FmJEvm15PvyZNBCzeOOPdGbL9K6fCj6PqVTafgmHEOza+Kejg3Q7r2p5+AexZvQ7VPTgOx6OQ1knx+VONHjpNrfJNdZdARpRb4yb3EgZngW11vSP9Bm1ni3pz1zS1BZqRQujNoifN8vMk8Idek/AYcUprCSQ8YXMFwPmM8ItFtSvCB1xK7CjnnhYC4VLDNiWRkeZrHTDOfhRgGIYWbA== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:54.7706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0492a8d3-84dc-4659-7ce6-08dc8bca3fb1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002326.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9452 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A later patch in this series moves the nvif_event callback function, but all the callers directly dereference object->client->event(). Add a helper function so this only has to be changed in one place. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/include/nvkm/core/client.h | 1 + drivers/gpu/drm/nouveau/nvkm/core/client.c | 6 ++++++ drivers/gpu/drm/nouveau/nvkm/core/uevent.c | 2 +- drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h index 2da9dfbf0d56..5c9a54d4bd64 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h @@ -19,6 +19,7 @@ struct nvkm_client { int nvkm_client_new(const char *name, struct nvkm_device *, int (*event)(u64, void *, u32), const struct nvif_client_impl **, struct nvif_client_priv **); +int nvkm_client_event(struct nvkm_client *client, u64 token, void *repv, u32 repc); /* logging for client-facing objects */ #define nvif_printk(o,l,p,f,a...) do { \ diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c index 6471edda8a96..beb966d65daf 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/client.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c @@ -31,6 +31,12 @@ #include #include +int +nvkm_client_event(struct nvkm_client *client, u64 token, void *repv, u32 repc) +{ + return client->event(token, repv, repc); +} + static int nvkm_client_new_device(struct nvif_client_priv *client, const struct nvif_device_impl **pimpl, struct nvif_device_priv **ppriv) diff --git a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c index 365e41134f3d..fccf6477d3d1 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/uevent.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/uevent.c @@ -111,7 +111,7 @@ nvkm_uevent_ntfy(struct nvkm_event_ntfy *ntfy, u32 bits) if (uevent->func) return uevent->func(uevent->parent, uevent->object.object, bits); - return client->event(uevent->object.object, NULL, 0); + return nvkm_client_event(client, uevent->object.object, NULL, 0); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c index 9c7b83c99b80..4284e7b924fc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c @@ -50,7 +50,7 @@ nvkm_uconn_uevent_gsp(struct nvkm_object *object, u64 token, u32 bits) if (bits & NVKM_DPYID_IRQ) args.v0.types |= NVIF_CONN_EVENT_V0_IRQ; - return object->client->event(token, &args, sizeof(args.v0)); + return nvkm_client_event(object->client, token, &args, sizeof(args.v0)); } static int @@ -67,7 +67,7 @@ nvkm_uconn_uevent_aux(struct nvkm_object *object, u64 token, u32 bits) if (bits & NVKM_I2C_IRQ) args.v0.types |= NVIF_CONN_EVENT_V0_IRQ; - return object->client->event(token, &args, sizeof(args.v0)); + return nvkm_client_event(object->client, token, &args, sizeof(args.v0)); } static int @@ -82,7 +82,7 @@ nvkm_uconn_uevent_gpio(struct nvkm_object *object, u64 token, u32 bits) if (bits & NVKM_GPIO_LO) args.v0.types |= NVIF_CONN_EVENT_V0_UNPLUG; - return object->client->event(token, &args, sizeof(args.v0)); + return nvkm_client_event(object->client, token, &args, sizeof(args.v0)); } static bool From patchwork Thu Jun 13 16:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697155 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1E360C27C78 for ; Thu, 13 Jun 2024 17:01:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34DE010EB26; Thu, 13 Jun 2024 17:00:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="braEiYXR"; dkim-atps=neutral Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2054.outbound.protection.outlook.com [40.107.212.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF32710EB0B; Thu, 13 Jun 2024 17:00:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=By+YBX5qZTd12MBi/N7ExT5nXGUOpommq59THyK9VyUoe1RFGqAG/3wLQo23/Q4v1hjRBg2wSIjykjKkYEu2P3LAfCCR93WdpKG/di//b2xe/xI5SlXUOHvJ+ddqNTKrZzAAouNBrO1d0+O1ryDo9DH1M1UPhU26r4OInoW4HCX/n4bTB1nW6jDi4ieBW8tZeWEPtb9dCoXgwvvroVjlMDmMRbpraW/q6VzjRmjL8q15dAmW++qqSxZQUAU56R6SjI0B+GXr0Z5sEkXrz9n+Mcdf+JR/ofDVDLVp/lDs9a5R9C6UnFu4xuwJOJSwyDleQjDeocB1LybZGsnD8K4Zag== 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=nwfaihetMxi76tFfC1a8EM4K9ZoRYl3H/iGE0RxHhsI=; b=dL/zRgMt4W/R309FFfEpWcrMQ9i5EZ/torjLYqdNikNek1/xtZ51it0Tw3wbhmK0SXQ5ammv9HFNC2ImjBbH1D6v5WEbpbt4seoWuhpb+3jE7rTeNDLHTqYhGdVrs0W5XdodgIPfG4NnRDP4NBEO+VVy6ySmeCgXsXze58wT7tOjAPc/juPm83gLeZ5uWC3UPraTQ6zST6a4bhPUgxBbx3FhyeT+45lCQ5l72Tlhl6/o65bDAxtVJIdI1GMoKu661vCBM3VXL2CY2cL8gM84FEOQUpij9Nl7L6zjV/i7VJH1lw32upp5Pww2/Iugxd+hJg9EHmyrS0I6y66znbyhtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nwfaihetMxi76tFfC1a8EM4K9ZoRYl3H/iGE0RxHhsI=; b=braEiYXRpeClON8jlLXssZuBeJawvTVNNpBXihgPVqhJjRH4XGCT4Vo7oxr1c1BdQXAbuetFUuskI6meBx1MqPC7MKLdMMbEDWeGttPFgqqEFq4r7poYe5GBFOTk16EuEqrJLl501RTE2yJf42/Scrn+2ONwMpnWjC9JCWaFU11iLR/9qy5ySzYlqEfBlYXGz9StT0K4I+Y/+0n8ZfYEpMrFpyeF0B4tKbPrDlsYYgk+t5XBd5migwA61goiAYn7ceVyK1Kc01uszya5z6Nmpiw7yuRkAhTINjez/uApHuIYgVzyldgAAoDVI8CGhCPaFnG5XiF90nN8M6VoGd9V/w== Received: from BYAPR05CA0051.namprd05.prod.outlook.com (2603:10b6:a03:74::28) by CH3PR12MB8660.namprd12.prod.outlook.com (2603:10b6:610:177::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 16:59:56 +0000 Received: from SJ1PEPF00002326.namprd03.prod.outlook.com (2603:10b6:a03:74:cafe::5d) by BYAPR05CA0051.outlook.office365.com (2603:10b6:a03:74::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 16:59:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002326.mail.protection.outlook.com (10.167.242.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:56 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:42 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:41 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 04/21] drm/nouveau/nvif: add nvif_event_stat Date: Fri, 14 Jun 2024 02:59:56 +1000 Message-ID: <20240613170046.88687-5-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002326:EE_|CH3PR12MB8660:EE_ X-MS-Office365-Filtering-Correlation-Id: e06c9584-2faf-4370-fbc2-08dc8bca40b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: ++hS2NEkOkV7/NFn4lEUtn0k8AGMddyRgQwB2fQvDIoFarjWhyJPFRqIgu8xoaW3uu8TZxp4oC2dIl3LFjxWjM+donUfMCznIKWVIyb2yrFV56OTKXlyhpsi+naBFEbTavZWNE8aLKDm5L5xQzH7RppD2XHfM+fL4C1WAbV+xTPiCqOxFxetD2BN+NMJycmz3STg7Y3rmSjvFVfygLLtSZuWDWsgqu/XCKhf0tPs2qBVQxpIqptWxPxXFWBoZYhZuPXtkgmdQ6nmV7gw+X3t0r3reVrKkeEjEMmZHcItkdl2LR25iSbiRLmLijWL+AsA+nFZ+NxtvtTzDjf3z6JpuGCXxitak5GTKadvD8psRP2rf9hBfMsucaVsv/S5SjsNWTjfyRJUWPr8AE7199tZy2QXulmyVG4ScNFkGCEBgtwCx7r73gWdcGZ5i9U0RuWETCYV4hlyNX8KHtc0+OMZ0t4P9w7VsAXWfSec1fvUCm1qREyVJGSg9mXfDArh3umBN6XKbhkVZ2rYiQv3sK22hZPxvKJz8JBgG4yl6VkVgoDKOvv8BryCk0jSA8s0u53Z1b3xZl6SAjOEJYmqFzhp/fUTnSakiprvTbIUYbVP5YZ0H2wQUn435dMINGgmnLITrxcHAqvVQiR1u9VtZpH9eSgjOx1VkmbfMVd7yxe5lbxby0epgn174UAVu9dtwWWScUw4+0zQ4TMNxjG4IOSL38P91DgiKsVUK/9PeP++WcFhJgbeakyjdy33iqOzqkA0T0x1K1MAMdlQsoIU5MD4/Pas3wmHUIgG/Xpshs7ebj+CPeI8ot0Hbt8sTwoTBelvLQPR0KVpIC+RcL3oL6EC1n+N3/nRAvwzO17CXWitKr0jLL3EbBlP6eG0yyzfdSYx+aGCtnK62oIaj6yxBq4nkg05THpRHG0EEqNW30PAIcET+9wIXmMv2KkiWQqNpLU83Iqcs2xm1w1iLyETpnQSrKaGzd97LXLgG0EVNF4P2dUAzvoEXe0VfmqBOYG3BJCYILkWSDfbr56ToX9nGZQKp1K2HLqwJpg94CfdhuIbHaxuVo+mzc8YEV/IYV5a1dIe/hgumuz+9LHhqU45eQIo2qniQ9ofN2ixtCYIXSBKK8c/5haqIpkm6swzL29CTMNzi0eKnfz54vUzSMCZVtNzedyz+PCMk0hSBBNvuBsvz/BpcLOPgko35+B49yFNFSrTf/tO0T2V8CRDM/D4mlJTSeWSoFddr8XyyXG1/g/DLoClqf+vqFGAo5b1ALOf1Ql5+sCT/BpCBjdrLVE7iyCP8UGPbT/masopfnXVFK3fq5Lpb4FFOEcZ+G1pb/QslKwRaOoCpxRcACPNlwHX8NzEvRyjvw3JO7KiDAoLSnnRxMQO755+TDk9gOEsEUGnFJ1/CkwKiv2TXMTYXIva51ok9Q== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:56.4425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e06c9584-2faf-4370-fbc2-08dc8bca40b2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002326.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8660 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Return an enum rather than an int from nvif_event callbacks. Also moves the NVIF_EVENT_* definitions to driverif.h, with the rest of the DRM<->NVKM interfaces. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++-- drivers/gpu/drm/nouveau/dispnv04/disp.h | 2 +- drivers/gpu/drm/nouveau/dispnv50/head.c | 2 +- drivers/gpu/drm/nouveau/include/nvif/driverif.h | 5 +++++ drivers/gpu/drm/nouveau/include/nvif/event.h | 5 ++--- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c index 225716d47c56..d7575ece9214 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c @@ -1072,7 +1072,7 @@ nv04_finish_page_flip(struct nouveau_channel *chan, return 0; } -int +enum nvif_event_stat nv04_flip_complete(struct nvif_event *event, void *argv, u32 argc) { struct nv04_display *disp = container_of(event, typeof(*disp), flip); @@ -1272,7 +1272,7 @@ static const struct drm_plane_funcs nv04_primary_plane_funcs = { DRM_PLANE_NON_ATOMIC_FUNCS, }; -static int +static enum nvif_event_stat nv04_crtc_vblank_handler(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_crtc *nv_crtc = container_of(event, struct nouveau_crtc, vblank); diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h index 8eba76ab880e..88df31b6ac6b 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/disp.h +++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h @@ -182,5 +182,5 @@ nouveau_bios_run_init_table(struct drm_device *dev, u16 table, ); } -int nv04_flip_complete(struct nvif_event *, void *, u32); +enum nvif_event_stat nv04_flip_complete(struct nvif_event *, void *, u32); #endif diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c index 4ad117b01d69..fd7791540f6f 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c @@ -549,7 +549,7 @@ nvd9_head_func = { .late_register = nv50_head_late_register, }; -static int +static enum nvif_event_stat nv50_head_vblank_handler(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_crtc *nv_crtc = container_of(event, struct nouveau_crtc, vblank); diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 40f58a94c09a..0476dd6621b5 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -23,6 +23,11 @@ struct nvif_cgrp_priv; struct nvif_chan_priv; struct nvif_engobj_priv; +enum nvif_event_stat { + NVIF_EVENT_KEEP, + NVIF_EVENT_DROP, +}; + struct nvif_event_impl { void (*del)(struct nvif_event_priv *); int (*allow)(struct nvif_event_priv *); diff --git a/drivers/gpu/drm/nouveau/include/nvif/event.h b/drivers/gpu/drm/nouveau/include/nvif/event.h index 42c2d0b5f66b..6c52de0e17d0 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/event.h +++ b/drivers/gpu/drm/nouveau/include/nvif/event.h @@ -2,11 +2,10 @@ #ifndef __NVIF_EVENT_H__ #define __NVIF_EVENT_H__ #include +#include struct nvif_event; -#define NVIF_EVENT_KEEP 0 -#define NVIF_EVENT_DROP 1 -typedef int (*nvif_event_func)(struct nvif_event *, void *repv, u32 repc); +typedef enum nvif_event_stat (*nvif_event_func)(struct nvif_event *, void *repv, u32 repc); struct nvif_event { const struct nvif_event_impl *impl; diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index 3a17e30d6c49..6a2b7e21afbf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -47,7 +47,7 @@ nouveau_channel_kill(struct nouveau_channel *chan) nouveau_fence_context_kill(chan->fence, -ENODEV); } -static int +static enum nvif_event_stat nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_channel *chan = container_of(event, typeof(*chan), kill); diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 7d9cba7bcb8f..e3071ea845e6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -1199,7 +1199,7 @@ nouveau_connector_hpd(struct nouveau_connector *nv_connector, u64 bits) spin_unlock_irqrestore(&drm->hpd_lock, flags); } -static int +static enum nvif_event_stat nouveau_connector_irq(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_connector *nv_connector = container_of(event, typeof(*nv_connector), irq); @@ -1208,7 +1208,7 @@ nouveau_connector_irq(struct nvif_event *event, void *repv, u32 repc) return NVIF_EVENT_KEEP; } -static int +static enum nvif_event_stat nouveau_connector_hotplug(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_connector *nv_connector = container_of(event, typeof(*nv_connector), hpd); diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index 9443cbaa8cff..2b6b60ec10fa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -168,7 +168,7 @@ nouveau_fence_uevent_work(struct work_struct *work) spin_unlock_irqrestore(&fctx->lock, flags); } -static int +static enum nvif_event_stat nouveau_fence_wait_uevent_handler(struct nvif_event *event, void *repv, u32 repc) { struct nouveau_fence_chan *fctx = container_of(event, typeof(*fctx), event); diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 5b94f6e3a39d..b8a3c3d2d3aa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -870,7 +870,7 @@ nouveau_svm_fault(struct work_struct *work) nouveau_svm_fault_replay(svm); } -static int +static enum nvif_event_stat nouveau_svm_event(struct nvif_event *event, void *argv, u32 argc) { struct nouveau_svm_fault_buffer *buffer = container_of(event, typeof(*buffer), notify); From patchwork Thu Jun 13 16:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697163 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E7AF5C27C75 for ; Thu, 13 Jun 2024 17:01:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1512B10EB3E; Thu, 13 Jun 2024 17:01:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="c3YWNBmd"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55A0E10EB0E; Thu, 13 Jun 2024 17:00:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7r1ZGMWBaXHuW4ShWDU7+QqcO1hjl1KU/TyuyH+9XKN3fM1Sp9kWU4noqw97jj/uRmOsVE8kXasd1c7ovvQOdt6tTPjCSbygm3uD8GJBBlQRqsA1CQKz6RNZuJZ6J7tPneuGDL61Rj0E2b9Lu5XtK/dPoAynq90cBSdEOj+2Apvr+Ws1+5/sX2XaLsAApXz3YzzuKJxxfajz/FzDAY3LHLgCpnUcQHBa8yOGA0bcTdDVFfqwmqSDLIeu/Cx+07p85F/Hrnbq+c5pPJ55sTyqccuTFfXFLY8UkHwSCkJWFiYtvY7QN4pbL+yOaMM8KCjHjxTcSPV9YWU8I6fYui2xA== 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=5DzgEROFQ3oyDqWVe1dvAPduxS6pFPwHavV5m2Oya5Q=; b=MaAUXTf0WZhM8eaohB2dVt1zzj7VmmRCqeoFTH+EZ7p8fvHoAIoTDYvwPMlsjEYYtqsCDjeR/zkQJGQwrkaNERIwp8BCuCkl6KJcAOcgvG1YHXzCNBiJRbqTg31asEGsIPeg4457qCFM6S5awNGNxmY6tNbaw435V5Nau5Bxxb4yJDtO7dU/o5bPfVIEIc19O+eXjEwg+vKIHWmfMDNMNHaI8hWrWshXze39Tbj5ALsS2wRrENrtjPuD3uxePVNhXVLD3bFj0espeMwsNz4uhyxZB9bZ4ZyBhDJ6VYBn7hG/jiaCFOBXLBq8wpfrplTJDcT3iYq6fai9C9Cf4YLsqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5DzgEROFQ3oyDqWVe1dvAPduxS6pFPwHavV5m2Oya5Q=; b=c3YWNBmd3sjvWuqwYRnD8N5a/RKnkAxmOtGMeRw/7K87tLV98ZbuM1Bey5gg2pp+A2dXE5WPcymJumrS3IK+vkbojK+/YPhIS4YPfkbi7PBXmGbmEjo9gOsmR/QSlR0VzDq/Ge1wsfdh+8KaRA4+tm/s15u9L2692wMC/aArK7J495r119o5SKRF+6wDytOSNHWuRjsZV9u5bofwu/jmUSMcNvXVTtlqMXoH6Fju0/k7VWAV0AlIlrV1fHvC/JIkOmf9VzPiT0e7SP5E47gDrDOuazhF+OH3JWgaNry6KBqboo7jMONslYTr9xctsQ/+LOYPvudA2S9eNYrbXX+Lpg== Received: from SJ0PR05CA0018.namprd05.prod.outlook.com (2603:10b6:a03:33b::23) by SA1PR12MB6726.namprd12.prod.outlook.com (2603:10b6:806:255::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 16:59:58 +0000 Received: from SJ1PEPF00002325.namprd03.prod.outlook.com (2603:10b6:a03:33b:cafe::c3) by SJ0PR05CA0018.outlook.office365.com (2603:10b6:a03:33b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 16:59:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002325.mail.protection.outlook.com (10.167.242.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:44 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:42 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 05/21] drm/nouveau/nvif: add nvif_driver_func for nvkm->drm callbacks Date: Fri, 14 Jun 2024 02:59:57 +1000 Message-ID: <20240613170046.88687-6-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002325:EE_|SA1PR12MB6726:EE_ X-MS-Office365-Filtering-Correlation-Id: f2007161-f220-4566-1ffc-08dc8bca420c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: mE5eIUHJpaAEEBUvMZyP1aVGq+YCEEPcZK+dB0FQ6A/R29ju+tWWY8tskq/rS+9uKJnQAuZ/VP2GmcMo2AyngADXDXMtCQ7U6if5RRcPVq6iMxeViLae2hk36dqCwPZ1DNnxnolQOZ+YBADN3Ero4XKSSvmVooacNUzNYYqCgbpJjGMd+4mZ3l15bFC4KlbJSCivmW6e4pF11ecHAfeAxP4WMu8+BVh3+4G3DGyIoS/EGFpZIxkklzPyTQsooJuqXawkG7u3QHjqNn4+BYlRJ7sY/mmg9E4be/YTmXXFi5ru0MxTuyo0qjBSAwOftq214mgI8oaq27Zz1+1dHKGRMY//xE3g3zjKhAg6V883kP5Dys/HUr7Pf+jZBsX6bVub74bBVHS1wM18w/QjQ5XYhM6lgcjPT4uWHS/yvqCWWCpO7K9zsrXaaEB1Df1Wlow0b43qMZDdAGBKZS/J48DZDjed3GN35tFqB8v7827zscT4muum4760tdZTuzMd0HHJCaQi71eraTeONUvigqqKGaqKoJRI9tpDjAEngWz9myVejeq7ASE2663TxU2j9Ock46YH78n6j9xhmvmEgcXGL87tdzctqRcsqknm6gLT0l/vRkbVZCsaJ7PdGuZuNNrPnOhuDKCZ4aJj9SAoXiNOe1u9UkycDTia0/DTOX1xf1+SzMefE8nBFsE4Mn8dubJoLASgCAPHLu80bQQ848ZhA7Q0GUfhcRhkEBEG4zGbf4Ot6M2U96b2AlyKriNBcrqDBTvquPJ44JlM1THILGi0AZHuF8VhOgkF3dKqyafwazif1dUBrtLypJMG42ALncpAykEloo12JuUn0MMJkrxit8MCvUKjbM11CS+6Loa3hZedWnyqQO4p18kne+gswRU/W5DXVpwChFMTegdknZCme/ydoA/jSLGY81j1q4xDYq9fymU07GLnWM2QVk3X3fSLJb3JBmVZxU7BNTfJEZIW+w38smAYdVHVtWt5JtuVwPIpjUvPGOswYPYe596wvaVFmnOEsY99zfDyKgFDk+Ry6vz1/7pbWHWB0FRpp1d+LZhTFvoLrOg9S+bfqQxCy8psmeWH06+3bKE9ZYtW4mm8Bdox1AUShxvNLHt/q5FJBeAlJO92ch48TpBE7bPtHARbUHrajbMeL2/9J0hfW2Iakxujj7CXej6DIN4xQOoXtbpCST1SgVMbX5RrgoJPYkkxoS2sj1hP+84r1nBg30e+EoeEbB4OUNDHLUf5naimgvWZQA2oiDJPE+rdKs1J4qNbpMIwNIFuBV/VUYt1jixHJW6qIVLr5r8MV+sZ9VI85fA5j464t5qeliMZvg+jmiIe/eOiENGnzIEsEloENSgCcsN5LuwQwSf/Igg6GR8/JoXC4/oC+gAxIYADcWuPwg186HvzBc/f34OV5dtScpXXzw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:58.7200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2007161-f220-4566-1ffc-08dc8bca420c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002325.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6726 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A later patch in this series will move the code that binds to a PCI/ Tegra device into NVKM, and requires a couple of callbacks to handle switcheroo, etc. nvif_event is generally used for NVKM->DRM callbacks, but these will need to be registered before nvif_event is ready. This patch replaces the event() function pointer that was passed to nvkm_driver_ctor() during init with a nvif_driver_func struct, that contains the existing event() callback. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/include/nvif/driverif.h | 4 ++++ drivers/gpu/drm/nouveau/include/nvif/event.h | 2 ++ drivers/gpu/drm/nouveau/include/nvkm/core/client.h | 3 +-- drivers/gpu/drm/nouveau/include/nvkm/core/device.h | 2 ++ drivers/gpu/drm/nouveau/nouveau_drm.c | 7 +++++++ drivers/gpu/drm/nouveau/nouveau_drv.h | 1 + drivers/gpu/drm/nouveau/nvif/event.c | 9 +++++++++ drivers/gpu/drm/nouveau/nvkm/core/client.c | 13 +++++++++---- drivers/gpu/drm/nouveau/nvkm/core/driver.c | 14 +------------- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 0476dd6621b5..638c72c1b580 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -34,6 +34,10 @@ struct nvif_event_impl { int (*block)(struct nvif_event_priv *); }; +struct nvif_driver_func { + enum nvif_event_stat (*event)(u64 token, void *repv, u32 repc); +}; + struct nvif_driver { const char *name; int (*suspend)(struct nvif_client_priv *); diff --git a/drivers/gpu/drm/nouveau/include/nvif/event.h b/drivers/gpu/drm/nouveau/include/nvif/event.h index 6c52de0e17d0..ce14e478b1fe 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/event.h +++ b/drivers/gpu/drm/nouveau/include/nvif/event.h @@ -5,6 +5,8 @@ #include struct nvif_event; +enum nvif_event_stat nvif_event(u64 token, void *repv, u32 repc); + typedef enum nvif_event_stat (*nvif_event_func)(struct nvif_event *, void *repv, u32 repc); struct nvif_event { diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h index 5c9a54d4bd64..4e5d56056b81 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/client.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/client.h @@ -14,10 +14,9 @@ struct nvkm_client { spinlock_t obj_lock; void *data; - int (*event)(u64 token, void *argv, u32 argc); }; -int nvkm_client_new(const char *name, struct nvkm_device *, int (*event)(u64, void *, u32), +int nvkm_client_new(const char *name, struct nvkm_device *, const struct nvif_client_impl **, struct nvif_client_priv **); int nvkm_client_event(struct nvkm_client *client, u64 token, void *repv, u32 repc); diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index fff0d7dd0e1b..c9965934b0d5 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -71,6 +71,8 @@ struct nvkm_device { bool armed; bool legacy_done; } intr; + + const struct nvif_driver_func *driver; }; struct nvkm_subdev *nvkm_device_subdev(struct nvkm_device *, int type, int inst); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 18990d21dc48..09947790f677 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -614,6 +614,11 @@ nouveau_drm_device_init(struct nouveau_drm *drm) return ret; } +static const struct nvif_driver_func +nouveau_driver = { + .event = nvif_event, +}; + static void nouveau_drm_device_del(struct nouveau_drm *drm) { @@ -643,9 +648,11 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren return ERR_PTR(-ENOMEM); drm->nvkm = device; + drm->driver = nouveau_driver; device->cfgopt = nouveau_config; device->dbgopt = nouveau_debug; + device->driver = &drm->driver; nvif_parent_ctor(&nouveau_parent, &drm->parent); diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 832651fe9f42..52589d5eab63 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -202,6 +202,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) struct nouveau_drm { struct nvkm_device *nvkm; + struct nvif_driver_func driver; struct nvif_parent parent; struct nvif_client client; struct nvif_device device; diff --git a/drivers/gpu/drm/nouveau/nvif/event.c b/drivers/gpu/drm/nouveau/nvif/event.c index 2974ec8e13af..816e3d1bedb4 100644 --- a/drivers/gpu/drm/nouveau/nvif/event.c +++ b/drivers/gpu/drm/nouveau/nvif/event.c @@ -23,6 +23,15 @@ #include #include +enum nvif_event_stat +nvif_event(u64 token, void *repv, u32 repc) +{ + struct nvif_object *object = (void *)(unsigned long)token; + struct nvif_event *event = container_of(object, typeof(*event), object); + + return event->func(event, repv, repc); +} + int nvif_event_block(struct nvif_event *event) { diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c index beb966d65daf..b767d77ad205 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/client.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c @@ -23,6 +23,7 @@ */ #include #include +#include #include #include @@ -34,7 +35,12 @@ int nvkm_client_event(struct nvkm_client *client, u64 token, void *repv, u32 repc) { - return client->event(token, repv, repc); + enum nvif_event_stat stat = client->device->driver->event(token, repv, repc); + + if (stat == NVIF_EVENT_KEEP) + return NVKM_EVENT_KEEP; + + return NVKM_EVENT_DROP; } static int @@ -59,7 +65,7 @@ nvkm_client_new_client(struct nvif_client_priv *parent, struct nvkm_client *client; int ret; - ret = nvkm_client_new("client", parent->device, parent->event, pimpl, &client); + ret = nvkm_client_new("client", parent->device, pimpl, &client); if (ret) return ret; @@ -96,7 +102,7 @@ nvkm_client = { }; int -nvkm_client_new(const char *name, struct nvkm_device *device, int (*event)(u64, void *, u32), +nvkm_client_new(const char *name, struct nvkm_device *device, const struct nvif_client_impl **pimpl, struct nvif_client_priv **ppriv) { struct nvkm_oclass oclass = {}; @@ -112,7 +118,6 @@ nvkm_client_new(const char *name, struct nvkm_device *device, int (*event)(u64, client->device = device; client->debug = NV_DBG_ERROR; spin_lock_init(&client->obj_lock); - client->event = event; *pimpl = &nvkm_client_impl; *ppriv = client; diff --git a/drivers/gpu/drm/nouveau/nvkm/core/driver.c b/drivers/gpu/drm/nouveau/nvkm/core/driver.c index 86ada3c888ec..dcc5dc7f246e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/driver.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/driver.c @@ -56,18 +56,6 @@ nvkm_driver_suspend(struct nvif_client_priv *client) return nvkm_object_fini(&client->object, true); } -static int -nvkm_driver_event(u64 token, void *repv, u32 repc) -{ - struct nvif_object *object = (void *)(unsigned long)token; - struct nvif_event *event = container_of(object, typeof(*event), object); - - if (event->func(event, repv, repc) == NVIF_EVENT_KEEP) - return NVKM_EVENT_KEEP; - - return NVKM_EVENT_DROP; -} - static const struct nvif_driver nvkm_driver = { .name = "nvkm", @@ -83,7 +71,7 @@ nvkm_driver_ctor(struct nvkm_device *device, const struct nvif_driver **pdrv, { int ret; - ret = nvkm_client_new("driver", device, nvkm_driver_event, pimpl, ppriv); + ret = nvkm_client_new("driver", device, pimpl, ppriv); if (ret) return ret; From patchwork Thu Jun 13 16:59:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697149 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 96CD8C27C4F for ; Thu, 13 Jun 2024 17:00:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FC1510EB06; Thu, 13 Jun 2024 17:00:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="cxhNzPzX"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AD8A10EB0F; Thu, 13 Jun 2024 17:00:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m6Me/RjqdKFI/roSn+BYOS/qZjQR/+FQqJHI0jRFAMNjjZgIGbbv1jFVJppO2Nq1Hebq8kvVy0LbVhEUxqeQmqCLjKVIJVq9+wiu8jdmQrwmyvnptSxyDEeuMyrHyGOWFbFH6F/W4P8Xmrjl04+UGvoUNJ9it71b+xX2aNZlQYMBuAX48MAo4BgYDt5sg87fhVt3yGJHnpV6J83c2nNFl7Cj/2d6Qfpc8XbN8JnaPxmDDfCNOQ4V14MbzecgIae7qghj3VbNVicjx79QrYNEV6nId9Vra6iMvd8/mqQxkmHVTRm5BzTPLNt10QTfaX+RhYrFh1lHo1U9V14CP5klmQ== 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=bo98WnsOcDQuuodKfVb7+IugZMSMpt0pnBibAGkSCYw=; b=GiE/b30OVtFjNBs5h46jNkKL7SunJdukJrG31vnhLVs0oe6Wzaa/jzDE+Q9JxPYwLFFWya07vDJYMBQ3jPm9b77pbVjFmNf/DFQqPKcYOrdv6QcHlLmjQ4qw8H42sqpLbODqiWJTr4aih8sJeriUGehaDs+WRtOegsay+TQ+jSeAUfGMzaTYQwL0gEgna0V5P4GcFYhVHQAbCXSiamqKkoQ88CmfcdI7vQu5Pm3sssLtGl5RHI7te5HYLsn5Ed3G9KgKIpaNRYKxQkletnLnEh1hVVh3oM/BiyN8s+2TdC59cESFwYpgCpM2spVDiWlFC3pPdczb11Tq6lYVsqo8Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bo98WnsOcDQuuodKfVb7+IugZMSMpt0pnBibAGkSCYw=; b=cxhNzPzXTFIRlxX3Kkgs0AyZIAUJ0WE5nj/2VF4ZakquJxFcuTeeQBmsFrosE+TVHGnIS6kytHveRp5+fLL+SEjHmVDaqFCiTLXWm34RZhtwDfQnj1uupFIMmeIqflKuSHYo/Vr84oO4nF/TVozAkavrfwPfDm7eG8BsfQ1qWI61q+X7zHda1zvzQEKSdRyJqFsAK8SHXB3+m6L9aboQeV7jV69b/OC9ZTjQw2d3BGF9pPKMj51+uzPBcmkFlymluT87KUCgQ0vsH6aJ0Zy4FhjllxHiR7L7DvEkO+Svi5VC44WW7zapZEYnFnW1oek4f/eWZlg95QELgFctCK0xCA== Received: from SA9PR10CA0013.namprd10.prod.outlook.com (2603:10b6:806:a7::18) by SA1PR12MB8888.namprd12.prod.outlook.com (2603:10b6:806:38a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 17:00:01 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:806:a7:cafe::5b) by SA9PR10CA0013.outlook.office365.com (2603:10b6:806:a7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:01 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:45 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:44 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 06/21] drm/nouveau/nvkm: add init()/exit() Date: Fri, 14 Jun 2024 02:59:58 +1000 Message-ID: <20240613170046.88687-7-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|SA1PR12MB8888:EE_ X-MS-Office365-Filtering-Correlation-Id: 20b17b59-9a63-48c1-891a-08dc8bca43e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: LcOkMGGV4XcdcxVRp4VFu3repM/BdgPs54DgSCeGEmRwl1DvmoMwjAIN3TCLObliMywCOXzUSRr6wEwgIScaPjoDjc/5azuDWzxVHAJz6M415UU0Why6KAg4bUVwp5/iCuMXvvWHCuZSH2cijPgoG+MlqWShDbK6nwE3HBNjFZsEOBepdOmImgsoyZUayLpTiITAb9Lwe72H4QHWMgDFjOSXy8kkkwJX59ILPTTJ8hlqIewYQGap/mx5zHDpKw3NPggpVvD32BN6jo0IyHoW9fMq+3hXFlVYG1ZC+jtyBuYjgtSd26OsaGzGKY3wqU85XkjO9R8cpbfkOflfGomKQBBHZLENsSvceAL/rCLr9DWq4rJj6m7CtGVpHWcWxbhupkB26YdggfLdib3V1W49maIslq6yZmJBUkTslU9fyV41Hd2+t2uOdIeJlOZ1nKwz9eCshpabsysLgfnfG/8hCHRRIPr427YiV1ngQqFBKMSeKknEfyKFMyEXZos/Mn0pAkSLoHDq9DrSI8futXhykRG2zAIeMIp+nznfPWnkgOec9rcU9/d5bUw8wYJfIPMMJQuIE9ptmvKwQJ2WwRPmgo7i8jqPnmLUpMJsfbLCzi6HLVbQu6G8Vg1reZP3M1jVx1k18wMg2TqEMnTVyOsNBDne36/KIkm/nGRmUM7qceIwpIcJ0N1tp2k9iSI8NV64eAAlvOzr/ZDniVCwQcA+VJP6kEMTn4v1G8Hh3X77lBR/UuGj+MosNn53PsxMCMRDH3ESArhKrdEgp3hWRheq3xFPI1qshYc8N3yNDlEd7GmhavnEMro+S4cdqyS2G4QgG4N79tVYrbvMixlf9RTSKVbe3TjfWaIvc+jQc3O48PddnACuRlaKg94OxyZh2MwMhBWoUi24dX/vXi6NbKFuP/wXIDUMhMin5S7RMIoizGMjeeYBnI5IEaYGmSGX8VV5F2L6Kqkfngt73gqaf5kcC5jlm0jckN7sKNLrTsAOx6wluYvixk3S1mC/XI6AZ/pQxlTNJn8tgiG2nNXOU3QTEulN8VOqgkQ3+ZW1GuD2YVlkVUpoX/900lK0T344XCEyV5z7ptqdDzlPYjfi/PbBdkTFdgtsifWvPi7o1M4XbixgfVz2CpsK2p1+B7f9zjkLrD/VxIuNrsmLTvPW7lwUvReFGYk70/b199vhJ019AKFaMl47RsHr9u/etSqOYluLxCzOztGdV1BFlZ7lqTTFQrlpwrtUB1xKkFR1XdVHIwq2bgjsZWuBlbQNPDqmCi96PJoi2ZdNojlQb8cqUL1nkCBTFI96iKAVPcorAdvlaC/O95GEOENd/kB80MBXwNpeuqgF1CHbb6pvKBYd0M/naz+Yhb5VQTjmx5js0N07fVP5a4msfTY+dvczU0c+bLtAheRYF7U3HXdowCoib4tjww== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:01.7172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20b17b59-9a63-48c1-891a-08dc8bca43e8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8888 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add stub init()/exit() functions that subsequent patches will use as they move the pci/platform-specific code out of the DRM driver. Signed-off-by: Ben Skeggs --- .../drm/nouveau/include/nvkm/core/module.h | 8 +++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +++++ drivers/gpu/drm/nouveau/nvkm/Kbuild | 3 ++ drivers/gpu/drm/nouveau/nvkm/core/Kbuild | 2 +- drivers/gpu/drm/nouveau/nvkm/module.c | 33 +++++++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/include/nvkm/core/module.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/module.c diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/module.h b/drivers/gpu/drm/nouveau/include/nvkm/core/module.h new file mode 100644 index 000000000000..5cf80e4deb90 --- /dev/null +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/module.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVKM_MODULE_H__ +#define __NVKM_MODULE_H__ +#include + +int __init nvkm_init(void); +void __exit nvkm_exit(void); +#endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 09947790f677..0bf39b05926f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -1375,6 +1376,8 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, static int __init nouveau_drm_init(void) { + int ret; + driver_pci = driver_stub; driver_platform = driver_stub; @@ -1388,6 +1391,10 @@ nouveau_drm_init(void) if (!nouveau_modeset) return 0; + ret = nvkm_init(); + if (ret) + return ret; + #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER platform_driver_register(&nouveau_platform_driver); #endif @@ -1419,6 +1426,8 @@ nouveau_drm_exit(void) #endif if (IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM)) mmu_notifier_synchronize(); + + nvkm_exit(); } module_init(nouveau_drm_init); diff --git a/drivers/gpu/drm/nouveau/nvkm/Kbuild b/drivers/gpu/drm/nouveau/nvkm/Kbuild index f68c19586b53..9e1a6ab937e1 100644 --- a/drivers/gpu/drm/nouveau/nvkm/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/Kbuild @@ -1,4 +1,7 @@ # SPDX-License-Identifier: MIT + +nvkm-y := nvkm/module.o + include $(src)/nvkm/core/Kbuild include $(src)/nvkm/nvfw/Kbuild include $(src)/nvkm/device/Kbuild diff --git a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild index 50ff041ecdf0..70cec7bbb018 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/core/Kbuild @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -nvkm-y := nvkm/core/client.o +nvkm-y += nvkm/core/client.o nvkm-y += nvkm/core/driver.o nvkm-y += nvkm/core/engine.o nvkm-y += nvkm/core/enum.o diff --git a/drivers/gpu/drm/nouveau/nvkm/module.c b/drivers/gpu/drm/nouveau/nvkm/module.c new file mode 100644 index 000000000000..66d28465514b --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/module.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include + +void __exit +nvkm_exit(void) +{ +} + +int __init +nvkm_init(void) +{ + return 0; +} From patchwork Thu Jun 13 16:59:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697148 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 06EB0C27C6E for ; Thu, 13 Jun 2024 17:00:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C75CE10EB19; Thu, 13 Jun 2024 17:00:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="X2mTLYI9"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2073.outbound.protection.outlook.com [40.107.236.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3676A10EB06; Thu, 13 Jun 2024 17:00:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XlMKG9KWQ4pLCiVDh526P2/T4YOqX4Bu94pvz7aKJrNlwtlxyps8yG7XEIwzwEcV+gcTKEmrTqaKwANje/PSbdQmyC9VS8sptmf24YFLuTvIYLJfcEA4XsZaBTfUCRhqOKuodRIsZysmD8soNTYuE7roZ9k8ZbWEuyHn/L1gF3ew7/da6uwU1N9PIB7GHbjpwk1W4wZZSsqas+AfPsvBJiaqQbDAa+d60bZq2xNDPR5ncnPGkimcmane4EFIo8Ba2b7SezNieb9ELwDKzddrS0fz2xpwWxtd2pxQ/dQcvNr9QlGeHGVmtSZjY2Zqjrqj3NWtrA+r5NTaZ/TrKiQ9gw== 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=P7mn/u4ruBIHr+UJb27n0VtaZ3sXleJtxlcFeSlwRik=; b=iEkiyBJz0dgKCgINrXGFUi7WcsKjWhE4Kslda8bHUXlJnUEXJojHCoU5d6HO9tL+kmjHFmLnryspZy7UT1DfIwvRz6BdDY9RCiIu9Q+RBN15K1UsLwK9EshLLJuyt8gTOLoxfyFvCiHOwRCRq5ELBTI8XeUksPTu85OZWMvKdoO6rC/h6L/3tfFJb+/6UT6VQ/8rWelLqesWqyRtZZebTDNFw77v9zHSZ74S08VlGAvv7u+4LhLyCXz+LOLNFaC7sDrlTLj9Eihi4AKOcLEp3gJwVbUwMJNs/+kMYrhNpRT6BDDzvQ1ZF42iBQsLQRN+Q8Q2iBCi5tFJm2CjljrCTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P7mn/u4ruBIHr+UJb27n0VtaZ3sXleJtxlcFeSlwRik=; b=X2mTLYI9TjB4TdB0Oj5bJ4ijpwSSexTsSt4DoZv+09XXD+vIrvVLDD5QwPpw0bGvPf7GMYgNPb7K6UJBQxjNpKh+4Phayq3URoq9vXfzd6M/ieEFL/Fd+AKwaxhb2feSdtZWSw3D5I6uK463a6ERRS+iJwlVTSmagVH06EIjpZpzT98cK2726uGifbY/NL6rbkSlpXcvFmfdT0TA20YiMvgiOc4d842Di9pW26L9pLhMiPNERIuArUABQ+FOuCYFMD8DKe+2rufMZZZoW5xQrFe8qyyRK8kIwE6z+ZNtaMCmS/Vfr0JuwSr90+8rdW3/UMpaFQrABRoqWAyp6vaS3A== Received: from SJ0PR05CA0027.namprd05.prod.outlook.com (2603:10b6:a03:33b::32) by DM4PR12MB7549.namprd12.prod.outlook.com (2603:10b6:8:10f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 16:59:59 +0000 Received: from SJ1PEPF00002325.namprd03.prod.outlook.com (2603:10b6:a03:33b:cafe::55) by SJ0PR05CA0027.outlook.office365.com (2603:10b6:a03:33b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 16:59:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002325.mail.protection.outlook.com (10.167.242.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 16:59:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:47 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:45 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 07/21] drm/nouveau/nvkm: cleanup in nvkm_device_{pci, tegra}_new() on failure Date: Fri, 14 Jun 2024 02:59:59 +1000 Message-ID: <20240613170046.88687-8-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002325:EE_|DM4PR12MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: 1aa04893-8fe0-45fd-c9cf-08dc8bca42b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: YrV33HABbARWe6CBRAxN7hi2pfXNgk/nwSqhxmWIO7YejhhrSpkHjlOr6OiK6DMckYXBISbFrrMNzCrZypF9BoC/tvMigREi80niKR0ZiZxpzODoGXcY3tG2iW4zGXDWPea9WybavCQ6oIcXNAAbzKn7jAp4fIbltR8Llz0QlJi0E/C+mJqmS1fbvvCdamHtTL71X9pyOCgbmBiqHuUHbBvVakxrdX1SnQti1VFjj0REFyaZxFiWMogYDI3FQmMYFyoPutPrgITt/XJg8Ln1Cp1c4/ZN4naso0LkHzvt32UvCM8Cb502bLr8eoH0kCKTYBH8acwcq3XLJdRq5MJxtZas5qP0DrQ/JzPKZZ0F7S+PDU1mLReTrDPAsKZmjiUXCOXULtsJ49q/2V5biYs17FGOEq3XqTK03cqdlcI+JZAz5fQ/jOgLQGT+oXh+Eha9wNjoVnz04PecPDCULhkuSohH0TwiQGaOmOcBZONk+AxTrnOZ4H46fad93aME98sYvq7MdqCbZ2fT6KyZECe/4FKu4z15rZ8GnKrephWxApksWPA9yrYJgHAEJ+v7H8fsZ2OHPeEwOSQACu3QV233Ck0bojxIXM7MUegEO+7ul1fEtuBzO8rimekTqqDIunXn5M8vU+iPrlERATb9Ay2F8UpUNfUJK77pgmvfiqqVNs1E+6UrBrMw6HmQQSTp2Jh9hNDGIXQ6erUp0ucy/Lfx+hfNnaMb/J4BDr0fNB9xuC6kxLlGaubxcuMiAObssLg5xh2mARzof0bgjEHRC5Dg3Ez9GrXVrOvZ95e8A0fLTqKMakrafYJGChf490xz+aymPYGINjPsQNYveYveKH4kLxvI0P1Y9nnbMe51RscXyV2clopAVZBrFKpA08WV54UoMSWe2R0NWp64PXZPw+XDgzCWOxYB9v2GGkZbXqxUdJM0a+lf0kTythTvL1P8lwjuj0H1iZwh1hrKvKsI/KZRIrjHFaUKngrKLb1sQQqnmCnVnsQfdlsnLXb8EhaDKf3KYAGWB+Clz1uqqWEvLphVYs95ZWLVaJZ71SP3ojozQwK4qbAmc0YqZGyzwRgqSIHAErgoTvJgQaHnJDSTOXvPzkdkV877gOZQK95xdUt35Prsm2ry2MNX28Bde1JStOdm0xT4DxlCs6T9mn4FMOW05+HCsZB3NZGD2jHHvTb7xZQlMbzyqIz7r4HUMQaJ1SBKv7u9mxGvVmF4B1N7evUX7I9sxJfDkDqGGehXyV2ao9rQKBhn/HbqrxAei9b+Gkprvw/QhwEZT22HDHDoAIDtDpn27SfsHo0zy2FpiTMaJnAkha+rODB7kpV5+oETXaVQos30MF5SkwD7i35KXXXcc2ttqmhrFSw3zfjJszdcVJTvjRwzhdTav0WrfnDIISo5vCmnUmdso1e+FEHs3b+21g== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 16:59:59.8450 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa04893-8fe0-45fd-c9cf-08dc8bca42b7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002325.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7549 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" These previously depended on the caller calling nvkm_device_del() to cleanup if nvkm_device_*_new() fails. That's a little odd for starters, but only the Tegra path cleaned up, and the PCI path would have leaked the memory, FWs etc that had been allocated as NVKM ran each subdev's ctor(). A later patch turns these into pci/platform driver probe() functions, so they need to learn how to clean up after themselves regardless. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 26 ++++++++++++++------- drivers/gpu/drm/nouveau/nvkm/device/tegra.c | 11 +++++---- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 0bf39b05926f..6c1cfc38d8fa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1351,7 +1351,7 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug, pdevice); if (err) - goto err_free; + return ERR_PTR(err); drm = nouveau_drm_device_new(&driver_platform, &pdev->dev, *pdevice); if (IS_ERR(drm)) { diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 8bfedd79d7a5..e48f3219f047 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1633,12 +1633,9 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, const struct nvkm_device_pci_vendor *pciv; const char *name = NULL; struct nvkm_device_pci *pdev; + struct nvkm_device *device; int ret, bits; - ret = pci_enable_device(pci_dev); - if (ret) - return ret; - switch (pci_dev->vendor) { case 0x10de: pcid = nvkm_device_pci_10de; break; default: @@ -1664,12 +1661,16 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, pcid++; } - if (!(pdev = kzalloc(sizeof(*pdev), GFP_KERNEL))) { - pci_disable_device(pci_dev); + if (!(pdev = kzalloc(sizeof(*pdev), GFP_KERNEL))) return -ENOMEM; - } - *pdevice = &pdev->device; pdev->pdev = pci_dev; + device = &pdev->device; + + ret = pci_enable_device(pci_dev); + if (ret) { + kfree(pdev); + return ret; + } ret = nvkm_device_ctor(&nvkm_device_pci_func, quirk, &pci_dev->dev, pci_is_pcie(pci_dev) ? NVKM_DEVICE_PCIE : @@ -1682,7 +1683,7 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, &pdev->device); if (ret) - return ret; + goto done; /* Set DMA mask based on capabilities reported by the MMU subdev. */ if (pdev->device.mmu && !pdev->device.pci->agp.bridge) @@ -1696,5 +1697,12 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, pdev->device.mmu->dma_bits = 32; } +done: + if (ret) { + nvkm_device_del(&device); + return ret; + } + + *pdevice = &pdev->device; return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c index bb514ccdfff4..9c3673c74b19 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c @@ -240,6 +240,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, struct nvkm_device **pdevice) { struct nvkm_device_tegra *tdev; + struct nvkm_device *device; unsigned long rate; int ret; @@ -248,6 +249,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, tdev->func = func; tdev->pdev = pdev; + device = &tdev->device; if (func->require_vdd) { tdev->vdd = devm_regulator_get(&pdev->dev, "vdd"); @@ -311,15 +313,14 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, ret = nvkm_device_ctor(&nvkm_device_tegra_func, NULL, &pdev->dev, NVKM_DEVICE_TEGRA, pdev->id, NULL, &tdev->device); - if (ret) - goto powerdown; + if (ret) { + nvkm_device_del(&device); + return ret; + } *pdevice = &tdev->device; - return 0; -powerdown: - nvkm_device_tegra_power_down(tdev); remove: nvkm_device_tegra_remove_iommu(tdev); free: From patchwork Thu Jun 13 17:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697152 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E43D8C27C6E for ; Thu, 13 Jun 2024 17:00:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 203BB10EB1A; Thu, 13 Jun 2024 17:00:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="MSq7Z6AB"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id C693D10EB16; Thu, 13 Jun 2024 17:00:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FoSVpXuBc3y23MYfClYYRe7oGSaofJ89OpalfuDTQei+gqE4ExaMbBkcZ+pXtJ8ODZCjuBsWGEb9Lgj2eFVjAAt39mWaxPORBf2/eEkLq+fX8OVORQoK1xOD7n59YewUmIO/BGKXSby5yDrr5eloLyz16W6wxu4MBF1NNQWQRpKlEhVtqXyajsePBFEMVhUWfvho168MJl8Ot0t4IfrA5Kb1UIKExfAEi0DEMkvVw+weI6SUp3NCf0ie95tb62aVSG2yUf+ZAMBEdjTgQHuV3OudG1CID/sDyNdOcvIUU3WQDpepWVUYlcUyoe6Y4M4CiK/qrv+rk1lVAiH6mZUwgQ== 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=mHXBOY/8OiNnwAS/KQMVF3wk0PNmKvHDm0F3HCwwZ8s=; b=jSBUOqOt2Z8jI4B1amq7S/5OcOlQ6MFxUwNC9wVB+lEqdIYTIpRg9pOFCYmPLVlo02V8s0aztawUwkosxQ+cyOi7zf0WCRq1tQz8y3Ohs4MRhnSVx8tJCBEuWt1xKKh9xO/dYDCxeEi2JbKc69RUWfp31QI4LM9FDCx/iAHb2gCnil3TB0befiIHFa8xsZUEdfHdjBIT3ciar3gycHD3ILcPazILsamD+eajAn5x47MaoinXIjxeVbh1GREcI84G2S8dxNZdT96UifOj9BVOncS3KZyO/krBPCtKcaFAo2l0JdnKGVsCbwlwvD72uPUZyA3OCFdyJc8ZSirnAg3r5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mHXBOY/8OiNnwAS/KQMVF3wk0PNmKvHDm0F3HCwwZ8s=; b=MSq7Z6ABXh+8VQZObLb5QS+wNuPa4RO6CC+u2Tm3icQInHg7HrPIvjMWyG9JvZRoRf2YjBUXU7VqQVFDqwMjgmRPJllJIbrf6tfqY0wWhysa+WvyGDs16PL2kvwJCJk9uaCFo8eSszduwEjuJfNW2Y9+LnBNX6J5ALIYWtO+2uY4w1hhTtHtxMoY6cbFQnIVqB+SoM6ts5l1Q8eC5fk1eFmwgyTtu5eLwx2iP/9VQ86Rzt9+JCVNIC+52/m8M/MXPcVFYAhLBxK1OcHts8h2O/8pqkjDG0JCP+pBIW5Aco9IX363umzVgQDvpR6HqbAB90ZKItTfBIAqEspdsTb+gw== Received: from SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) by PH0PR12MB7814.namprd12.prod.outlook.com (2603:10b6:510:288::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 17:00:05 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:806:a7:cafe::20) by SA9PR10CA0004.outlook.office365.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:48 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:47 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 08/21] drm/nouveau/nvkm: move vgaarb code from drm Date: Fri, 14 Jun 2024 03:00:00 +1000 Message-ID: <20240613170046.88687-9-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|PH0PR12MB7814:EE_ X-MS-Office365-Filtering-Correlation-Id: 911626f8-7314-4c5c-fc4a-08dc8bca45e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: Lkjqj/wqjgNFOiPMJwU4vQjuoG/qQJzv9eHW/yQZhb4hvfg5ID0XLtvKBJ4rdRVcG0cw8ZlqEVqhHfwMeuUdtf5cf0DhXVTsrdhafFXC1G+Noq1D9E6r+I2Mr5vANSDjqmmOAx+/KvHcnrjN0dIDWh+6iwamj3D90KWxkDSpZkKCHM3H4B6ouDxmuJmx/KjQfy9gmCH8GpIb/jTQFlhLx8Na6FobqN3z6tQvZpqoosESWQC71bYtFUiR/ivEPlYOvK+VOyqQ0IgQiTu7izI3FbKUdbio/7o3ZTz2hRmf2lwdJGbS5duSD8PAvMb5AGBmNxTwivMVR2ddVFM9bFxmEKGCq48j+k5CWoD90XrOFWczxEX+40utEk4op424UqSKjMPb8fgugjoDG7Vm+X2WoGtPQ/jNMNoiFfpjkeffuXWYYgzGunwJ+JIQilf70m9CEauT7FOj4zej22ipeJGEIG0f1sb5TAyNdCfINusQo0c9ojP30iOD+RV2QxgviLP0fnadEYHDYaHjE6XcY4+2nb6yu3pOCjjmFqV2CgG1c6UC64/mY2KbgmvzD6B01lDREFcDYgkvuSc04C2KuzNXGx/45ukpmQGPsKUNPvG0VjbcjTp7z5OPpVn87MZPdJuFTFtjoB7ZTHy4QpCui8VTVQGUCPgaIP4DszZqVLV5DuD5qOeAtbNcGNeZcOHY742e3KLNCbOjZT5o2oQomxTg1lhmiUyFIw1GSCUcFSPhS3TNl3gJOJ71CneClYbqGb2qC3x7pXrAbH5v1auG6RtojL3SpPyjm5mryFF/IkKYPMJMM/VH2cRZhf0Qq+vhPxWcfns9FFINVVWfTF8iMjAa91zH4Z9Y6L7XDCheXGzwRiDjcfMoouhAh0HsXYVumO7p2s/jCYmtS3ZX/yWB36H/vCgjLKYVKde2QkHq+8RD4SupmDdg281DFqWFwDjhZT+6vDoQH3m7Z6JKGbl8sY10TMzY/FF6Nm24xjk4pAbwjnsZ3PeQ9xc2ZojcDzu+51eSZhc+akr4f2XLCSs5avxv4yJpNYHnpDy/QhbHodmcIJ7r/Ngn9PrlVS8m14dXCbXRb2C5FzeaKDUC+NpcK73yLU+wD+ncXgAoczNXwif3yxh+CJ8+pT/7HXs3esTxzS1rm8cAyl5Osd5BISSasNK4DoXByEnmhzf+lAbePPGvr8663/GU5mL/sZWy3Pw3sBxRRq52bu60nOlJpVqez0FDwRzDrDpUmvnWHbRVpnos911ap6FR9NoEB8YWBn4zWA9yVLOcnhAlurVUbcT3qL+FCDhEsT/sDAB0BeWPgC2MU4WMeKL42J7x1ykLYyS82E9ebPFwk9jtNXoxnbj9DFXdjPRqQRkuvx0dcA0WasrkGv60F3rMGdil0cu2YoYvC0EMvNLMGSYgPQ0Qnzkn2rFSNQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:05.0454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 911626f8-7314-4c5c-fc4a-08dc8bca45e1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7814 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_vga.c | 27 ---------------- .../gpu/drm/nouveau/nvkm/subdev/pci/base.c | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c index 83496af605a1..53b332708061 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: MIT -#include #include #include @@ -8,28 +7,6 @@ #include "nouveau_acpi.h" #include "nouveau_vga.h" -static unsigned int -nouveau_vga_set_decode(struct pci_dev *pdev, bool state) -{ - struct nouveau_drm *drm = pci_get_drvdata(pdev); - struct nvif_device *device = &drm->device; - - if (device->impl->family == NVIF_DEVICE_CURIE && - device->impl->chipset >= 0x4c) - nvif_wr32(device, 0x088060, state); - else - if (device->impl->chipset >= 0x40) - nvif_wr32(device, 0x088054, state); - else - nvif_wr32(device, 0x001854, state); - - if (state) - return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM | - VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; - else - return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; -} - static void nouveau_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state) @@ -94,8 +71,6 @@ nouveau_vga_init(struct nouveau_drm *drm) return; pdev = to_pci_dev(dev->dev); - vga_client_register(pdev, nouveau_vga_set_decode); - /* don't register Thunderbolt eGPU with vga_switcheroo */ if (pci_is_thunderbolt_attached(pdev)) return; @@ -118,8 +93,6 @@ nouveau_vga_fini(struct nouveau_drm *drm) return; pdev = to_pci_dev(dev->dev); - vga_client_unregister(pdev); - if (pci_is_thunderbolt_attached(pdev)) return; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c index 5a0de45d36ce..e4737b89cb63 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c @@ -27,6 +27,8 @@ #include #include +#include + void nvkm_pci_msi_rearm(struct nvkm_device *device) { @@ -62,6 +64,29 @@ nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 value) return data; } +#include "nouveau_drv.h" + +static unsigned int +nvkm_pci_vga_set_decode(struct pci_dev *pdev, bool state) +{ + struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + + if (device->card_type == NV_40 && + device->chipset >= 0x4c) + nvkm_wr32(device, 0x088060, state); + else + if (device->chipset >= 0x40) + nvkm_wr32(device, 0x088054, state); + else + nvkm_wr32(device, 0x001854, state); + + if (state) + return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM | + VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; + else + return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; +} + void nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow) { @@ -76,11 +101,16 @@ nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow) static int nvkm_pci_fini(struct nvkm_subdev *subdev, bool suspend) { + struct nvkm_device_pci *pdev = subdev->device->func->pci(subdev->device); struct nvkm_pci *pci = nvkm_pci(subdev); + if (!subdev->use.enabled) + return 0; + if (pci->agp.bridge) nvkm_agp_fini(pci); + vga_client_unregister(pdev->pdev); return 0; } @@ -111,6 +141,7 @@ nvkm_pci_oneinit(struct nvkm_subdev *subdev) static int nvkm_pci_init(struct nvkm_subdev *subdev) { + struct nvkm_device_pci *pdev = subdev->device->func->pci(subdev->device); struct nvkm_pci *pci = nvkm_pci(subdev); int ret; @@ -131,6 +162,7 @@ nvkm_pci_init(struct nvkm_subdev *subdev) if (pci->msi) pci->func->msi_rearm(pci); + vga_client_register(pdev->pdev, nvkm_pci_vga_set_decode); return 0; } From patchwork Thu Jun 13 17:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697150 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 529CEC27C4F for ; Thu, 13 Jun 2024 17:00:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE3C710EB08; Thu, 13 Jun 2024 17:00:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="EpOIzKYy"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DA2B10EB17; Thu, 13 Jun 2024 17:00:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZGssb26XBz9NVx+AL7AfwaDeZllrLU9/ZyPWESNbmZiws1r337nHfCiB5InxG19vKpgqLUPiG4PVhBMzsG/IN0llJjYmRQFhnICubhvhOcQCVZYwHcPG6RdzloMckzA3Wqh7sD81Eiylpp+w13LCGPkxxrjBlYNPPTtFaEWKuH3tJwxsZKfJmxJDlZrGrm3xOzhOoGF7wUqtwn3SHSegRTCiinSo234sxTVVh+uEByd+9ZQTskqvftbwoNheWVNzQ/LPTqSYHKvDL6Z0tdl6bE7O2QMmrk+LAALHa5AOxUzZCBtouIQjJ+eEAaFVDosNU85YHXjAfeIXSkEI3Nm8A== 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=uO2K5JspyBKWOtx49f5u2rEjRjx3SGImVhiUXHix7KQ=; b=iI4UPJkFrFwaGFlMhE9H1vSLSgC9a/mjkfAYPZyGRUZw0rTkjBw2Tve2sI7Y/OG8krjx2+x8TWEdMRb/C99WX1C/GVFVygHasNIX0piDxyAmvFO3Sd3OolOgVQ7c/99cgb1jjFsS9XoyNT3GWZRKG3s6sI5/JfAyDxknM9c+vjpK5erK2CHYcX8ADWleCkBl+Kivz38ltgCp79c+h5Sy7FeEBATR6elRuWuNLSifKPVBpV7sJxtZmTd1/jJeGy2Anc7hHah0cubc4FTo0NevF0IrdAfoAjomNx+a6bxTXuv+rqHm9Dl/4kXoVcjos2fwxxk6a85LUsj/KwrF8NrRFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uO2K5JspyBKWOtx49f5u2rEjRjx3SGImVhiUXHix7KQ=; b=EpOIzKYyKWVPlxyM3rRrccnPCCTzN+Xd/KGU07T4E4+oMjU0CJiYL8/cmFOJXJ/91NLvveG8BAdZNJ6gTGplNFOM6Eg4fqoIlnDqt/VUSfw86i1bFN3bthzhvhkYOsq+CL+41lsPVt35wYdnXJBy/Mu3TAv1Qyp7gsMoyiUCxEoVRnK2YaeCCru6sNnnsljs39gauw9MISCwuKji/mBQ0yO3a97xBQ5DAHFoUW6gdQTnCrKLm0mdDzqHhIRDw6EI6FDodewTy2Dsd/iSvlO3EuACk6+0/R3659BhZaVcTpJ/kWTV21bO+/AfGgfS5uSsO65BuTDqRmRzKUIqqbvjug== Received: from BYAPR05CA0062.namprd05.prod.outlook.com (2603:10b6:a03:74::39) by IA1PR12MB6580.namprd12.prod.outlook.com (2603:10b6:208:3a0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Thu, 13 Jun 2024 17:00:03 +0000 Received: from SJ1PEPF00002326.namprd03.prod.outlook.com (2603:10b6:a03:74:cafe::58) by BYAPR05CA0062.outlook.office365.com (2603:10b6:a03:74::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Thu, 13 Jun 2024 17:00:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002326.mail.protection.outlook.com (10.167.242.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:50 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:48 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 09/21] drm/nouveau/nvkm: move switcheroo init from drm Date: Fri, 14 Jun 2024 03:00:01 +1000 Message-ID: <20240613170046.88687-10-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002326:EE_|IA1PR12MB6580:EE_ X-MS-Office365-Filtering-Correlation-Id: e3153333-9101-4ac1-f720-08dc8bca44b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: mUtC5iaLhkaJ/ux4d2BsQKVKhajt6QyN/16HgK4AVuaVtBYvy77HpamG5Ot6oelBoodejfl81sm/w6wywkPZVbYl5qhuVYn554XfmhZmRHZoIoViYzdYeoA6GRpuX/LK7F7LwytnyjBLdgvr3+HGDquoA2R+3CisgXa0rKxLCzqWHgQvDn0IojUoew6sC45zCir3Z2L6d4LaN4twbTLKZe8NwH4igk4dHL118GpPcW6JHQJS8cmXFetT05hLXSDfXFxephZqLm+HcEJQZels20HrnxPgbfjFwgUpzaPDnP+eFPavm7urO5/yiJMPH02/sfezVK98G3NF1nauoE1TFAaarOYbNjoRpG8qcQoRnskDhbbc95gAF8s1Mq4UhiiyjEtLNse0ma5eN5gar3ft8DZax3IDxC77Ru30d72LN7Y5HMErealRtCVRoetHnMFEwu/Vhmmx600W0E34D1zz+ZK47gM1b9LFwXA+KTjXwiJz/jf2wcFVU3HMedSrVDBtOJuOAJOhVd/z4QBnSO5kg0NTC2Z8T6NwkCyaUJP9FymJ5qwiULQNqPtNWpxr08ZwII4x81AgsIrZEnGWo8BXm2ulfhiRxU9HMuAm/tu2YIB8UX/VRrfpZipg4wTGkiJzE3ikvQF6lw5BGZi6hRfmfYmW8+JFCyaIyFMobqUCJwLSdklA5D4q3qWNa0RArOKeWJVETETpee8Lk14lNv2auKmQisYKuWKG9qrqpvZDfeAnetnqLrC1yjfi/TgubaMwmVxnISoNne36QgZiLMLZWTSXYg/grBEKGF1vRVPcOkRsNkVxjQTs7JiE66sRRQR4UFhgLbABET86i4E5nfH4doU6079AdfduqPtmaFR3iqys7RZwvl/AjcgyziMoHGwRxeFZeQZiEX9N4b4RghH1/s0QQAB4w1hZngk/LeCgGvJJ/M2yEFKHt7F0CV7dUgoAOuVanKLMKQOIdGS7bkvGndlgDXXJbl7RvkSmRP16WGiweNQFtARRI3U098kIshxvJYUzXHJSZaa3nOlpO1oWAMTUuz1uza/vlbUNuWzsxfHQJwpsrNYno0ROCWel/SMz/lpnMRCnWr0meKY4aL6cb/LGf1DhFzuk/xOpeFEovXq2Di8XPXBOo/RtsrBr0e1FoYGHpDUMn01G4KynfqnV1XNE2XWPupSv6XBVLq569etrVo0uA+7+Uqbp7C9Fyfu/ZNWcZEGtyEMDF9PR/Kkf3613s+kH8Vvyg8s7ul8lZ4Tt/EMIpQsXoxy7zFCFQ7Kd4tOju5QzW7U3nTwgSQYCDSMg2zMQT5qcisla7hir3dkxYOJDLQ3ONY8JH86gjiPKldPiO5uJ5XR/D4LR6dTEidvnNqz8j9Vao6S0ZaQf//0mpLQO6nUgF3mNNRnNo72E2PlZusBX+SPlNEVcBsDgOQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:03.2082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3153333-9101-4ac1-f720-08dc8bca44b8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002326.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6580 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 344 --------------------- drivers/gpu/drm/nouveau/nouveau_acpi.h | 7 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 - drivers/gpu/drm/nouveau/nvkm/device/acpi.c | 339 +++++++++++++++++++- drivers/gpu/drm/nouveau/nvkm/device/acpi.h | 19 ++ drivers/gpu/drm/nouveau/nvkm/module.c | 3 + 6 files changed, 362 insertions(+), 352 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index 8f0c69aad248..b9c43fe552c0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -2,55 +2,12 @@ #include #include #include -#include -#include #include #include #include "nouveau_drv.h" #include "nouveau_acpi.h" -#define NOUVEAU_DSM_LED 0x02 -#define NOUVEAU_DSM_LED_STATE 0x00 -#define NOUVEAU_DSM_LED_OFF 0x10 -#define NOUVEAU_DSM_LED_STAMINA 0x11 -#define NOUVEAU_DSM_LED_SPEED 0x12 - -#define NOUVEAU_DSM_POWER 0x03 -#define NOUVEAU_DSM_POWER_STATE 0x00 -#define NOUVEAU_DSM_POWER_SPEED 0x01 -#define NOUVEAU_DSM_POWER_STAMINA 0x02 - -#define NOUVEAU_DSM_OPTIMUS_CAPS 0x1A -#define NOUVEAU_DSM_OPTIMUS_FLAGS 0x1B - -#define NOUVEAU_DSM_OPTIMUS_POWERDOWN_PS3 (3 << 24) -#define NOUVEAU_DSM_OPTIMUS_NO_POWERDOWN_PS3 (2 << 24) -#define NOUVEAU_DSM_OPTIMUS_FLAGS_CHANGED (1) - -#define NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN (NOUVEAU_DSM_OPTIMUS_POWERDOWN_PS3 | NOUVEAU_DSM_OPTIMUS_FLAGS_CHANGED) - -/* result of the optimus caps function */ -#define OPTIMUS_ENABLED (1 << 0) -#define OPTIMUS_STATUS_MASK (3 << 3) -#define OPTIMUS_STATUS_OFF (0 << 3) -#define OPTIMUS_STATUS_ON_ENABLED (1 << 3) -#define OPTIMUS_STATUS_PWR_STABLE (3 << 3) -#define OPTIMUS_DISPLAY_HOTPLUG (1 << 6) -#define OPTIMUS_CAPS_MASK (7 << 24) -#define OPTIMUS_DYNAMIC_PWR_CAP (1 << 24) - -#define OPTIMUS_AUDIO_CAPS_MASK (3 << 27) -#define OPTIMUS_HDA_CODEC_MASK (2 << 27) /* hda bios control */ - -static struct nouveau_dsm_priv { - bool dsm_detected; - bool optimus_detected; - bool optimus_flags_detected; - bool optimus_skip_dsm; - acpi_handle dhandle; -} nouveau_dsm_priv; - bool nouveau_is_optimus(void) { return nouveau_dsm_priv.optimus_detected; } @@ -59,307 +16,6 @@ bool nouveau_is_v1_dsm(void) { return nouveau_dsm_priv.dsm_detected; } -#ifdef CONFIG_VGA_SWITCHEROO -static const guid_t nouveau_dsm_muid = - GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48, - 0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4); - -static const guid_t nouveau_op_dsm_muid = - GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B, - 0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0); - -static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result) -{ - int i; - union acpi_object *obj; - char args_buff[4]; - union acpi_object argv4 = { - .buffer.type = ACPI_TYPE_BUFFER, - .buffer.length = 4, - .buffer.pointer = args_buff - }; - - /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */ - for (i = 0; i < 4; i++) - args_buff[i] = (arg >> i * 8) & 0xFF; - - *result = 0; - obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100, - func, &argv4, ACPI_TYPE_BUFFER); - if (!obj) { - acpi_handle_info(handle, "failed to evaluate _DSM\n"); - return AE_ERROR; - } else { - if (obj->buffer.length == 4) { - *result |= obj->buffer.pointer[0]; - *result |= (obj->buffer.pointer[1] << 8); - *result |= (obj->buffer.pointer[2] << 16); - *result |= (obj->buffer.pointer[3] << 24); - } - ACPI_FREE(obj); - } - - return 0; -} - -/* - * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special - * requirements on the fourth parameter, so a private implementation - * instead of using acpi_check_dsm(). - */ -static int nouveau_dsm_get_optimus_functions(acpi_handle handle) -{ - int result; - - /* - * Function 0 returns a Buffer containing available functions. - * The args parameter is ignored for function 0, so just put 0 in it - */ - if (nouveau_optimus_dsm(handle, 0, 0, &result)) - return 0; - - /* - * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. - * If the n-th bit is enabled, function n is supported - */ - if (result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS)) - return result; - return 0; -} - -static int nouveau_dsm(acpi_handle handle, int func, int arg) -{ - int ret = 0; - union acpi_object *obj; - union acpi_object argv4 = { - .integer.type = ACPI_TYPE_INTEGER, - .integer.value = arg, - }; - - obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102, - func, &argv4, ACPI_TYPE_INTEGER); - if (!obj) { - acpi_handle_info(handle, "failed to evaluate _DSM\n"); - return AE_ERROR; - } else { - if (obj->integer.value == 0x80000002) - ret = -ENODEV; - ACPI_FREE(obj); - } - - return ret; -} - -static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id) -{ - mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); - mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); - return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id); -} - -static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state) -{ - int arg; - if (state == VGA_SWITCHEROO_ON) - arg = NOUVEAU_DSM_POWER_SPEED; - else - arg = NOUVEAU_DSM_POWER_STAMINA; - nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg); - return 0; -} - -static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id) -{ - if (!nouveau_dsm_priv.dsm_detected) - return 0; - if (id == VGA_SWITCHEROO_IGD) - return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA); - else - return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED); -} - -static int nouveau_dsm_power_state(enum vga_switcheroo_client_id id, - enum vga_switcheroo_state state) -{ - if (id == VGA_SWITCHEROO_IGD) - return 0; - - /* Optimus laptops have the card already disabled in - * nouveau_switcheroo_set_state */ - if (!nouveau_dsm_priv.dsm_detected) - return 0; - - return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state); -} - -static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *pdev) -{ - /* easy option one - intel vendor ID means Integrated */ - if (pdev->vendor == PCI_VENDOR_ID_INTEL) - return VGA_SWITCHEROO_IGD; - - /* is this device on Bus 0? - this may need improving */ - if (pdev->bus->number == 0) - return VGA_SWITCHEROO_IGD; - - return VGA_SWITCHEROO_DIS; -} - -static const struct vga_switcheroo_handler nouveau_dsm_handler = { - .switchto = nouveau_dsm_switchto, - .power_state = nouveau_dsm_power_state, - .get_client_id = nouveau_dsm_get_client_id, -}; - -static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out, - bool *has_mux, bool *has_opt, - bool *has_opt_flags, bool *has_pr3) -{ - acpi_handle dhandle; - bool supports_mux; - int optimus_funcs; - struct pci_dev *parent_pdev; - - if (pdev->vendor != PCI_VENDOR_ID_NVIDIA) - return; - - *has_pr3 = false; - parent_pdev = pci_upstream_bridge(pdev); - if (parent_pdev) { - if (parent_pdev->bridge_d3) - *has_pr3 = pci_pr3_present(parent_pdev); - else - pci_d3cold_disable(pdev); - } - - dhandle = ACPI_HANDLE(&pdev->dev); - if (!dhandle) - return; - - if (!acpi_has_method(dhandle, "_DSM")) - return; - - supports_mux = acpi_check_dsm(dhandle, &nouveau_dsm_muid, 0x00000102, - 1 << NOUVEAU_DSM_POWER); - optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle); - - /* Does not look like a Nvidia device. */ - if (!supports_mux && !optimus_funcs) - return; - - *dhandle_out = dhandle; - *has_mux = supports_mux; - *has_opt = !!optimus_funcs; - *has_opt_flags = optimus_funcs & (1 << NOUVEAU_DSM_OPTIMUS_FLAGS); - - if (optimus_funcs) { - uint32_t result; - nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, - &result); - dev_info(&pdev->dev, "optimus capabilities: %s, status %s%s\n", - (result & OPTIMUS_ENABLED) ? "enabled" : "disabled", - (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "", - (result & OPTIMUS_HDA_CODEC_MASK) ? "hda bios codec supported" : ""); - } -} - -static bool nouveau_dsm_detect(void) -{ - char acpi_method_name[255] = { 0 }; - struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name}; - struct pci_dev *pdev = NULL; - acpi_handle dhandle = NULL; - bool has_mux = false; - bool has_optimus = false; - bool has_optimus_flags = false; - bool has_power_resources = false; - int vga_count = 0; - bool guid_valid; - bool ret = false; - - /* lookup the MXM GUID */ - guid_valid = mxm_wmi_supported(); - - if (guid_valid) - printk("MXM: GUID detected in BIOS\n"); - - /* now do DSM detection */ - while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { - if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && - (pdev->class != PCI_CLASS_DISPLAY_3D << 8)) - continue; - - vga_count++; - - nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus, - &has_optimus_flags, &has_power_resources); - } - - /* find the optimus DSM or the old v1 DSM */ - if (has_optimus) { - nouveau_dsm_priv.dhandle = dhandle; - acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, - &buffer); - pr_info("VGA switcheroo: detected Optimus DSM method %s handle\n", - acpi_method_name); - if (has_power_resources) - pr_info("nouveau: detected PR support, will not use DSM\n"); - nouveau_dsm_priv.optimus_detected = true; - nouveau_dsm_priv.optimus_flags_detected = has_optimus_flags; - nouveau_dsm_priv.optimus_skip_dsm = has_power_resources; - ret = true; - } else if (vga_count == 2 && has_mux && guid_valid) { - nouveau_dsm_priv.dhandle = dhandle; - acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, - &buffer); - pr_info("VGA switcheroo: detected DSM switching method %s handle\n", - acpi_method_name); - nouveau_dsm_priv.dsm_detected = true; - ret = true; - } - - - return ret; -} - -void nouveau_register_dsm_handler(void) -{ - bool r; - - r = nouveau_dsm_detect(); - if (!r) - return; - - vga_switcheroo_register_handler(&nouveau_dsm_handler, 0); -} - -/* Must be called for Optimus models before the card can be turned off */ -void nouveau_switcheroo_optimus_dsm(void) -{ - u32 result = 0; - if (!nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.optimus_skip_dsm) - return; - - if (nouveau_dsm_priv.optimus_flags_detected) - nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS, - 0x3, &result); - - nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, - NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result); - -} - -void nouveau_unregister_dsm_handler(void) -{ - if (nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.dsm_detected) - vga_switcheroo_unregister_handler(); -} -#else -void nouveau_register_dsm_handler(void) {} -void nouveau_unregister_dsm_handler(void) {} -void nouveau_switcheroo_optimus_dsm(void) {} -#endif - void * nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.h b/drivers/gpu/drm/nouveau/nouveau_acpi.h index e39dd8b94b8b..a7fac1f7a73d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.h +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.h @@ -7,17 +7,14 @@ #if defined(CONFIG_ACPI) && defined(CONFIG_X86) bool nouveau_is_optimus(void); bool nouveau_is_v1_dsm(void); -void nouveau_register_dsm_handler(void); -void nouveau_unregister_dsm_handler(void); -void nouveau_switcheroo_optimus_dsm(void); +#include +static inline void nouveau_switcheroo_optimus_dsm(void) { nvkm_acpi_switcheroo_set_powerdown(); } void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *); bool nouveau_acpi_video_backlight_use_native(void); void nouveau_acpi_video_register_backlight(void); #else static inline bool nouveau_is_optimus(void) { return false; }; static inline bool nouveau_is_v1_dsm(void) { return false; }; -static inline void nouveau_register_dsm_handler(void) {} -static inline void nouveau_unregister_dsm_handler(void) {} static inline void nouveau_switcheroo_optimus_dsm(void) {} static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; } static inline bool nouveau_acpi_video_backlight_use_native(void) { return true; } diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 6c1cfc38d8fa..0ac17da04819 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1399,7 +1399,6 @@ nouveau_drm_init(void) platform_driver_register(&nouveau_platform_driver); #endif - nouveau_register_dsm_handler(); nouveau_backlight_ctor(); #ifdef CONFIG_PCI @@ -1419,7 +1418,6 @@ nouveau_drm_exit(void) pci_unregister_driver(&nouveau_drm_pci_driver); #endif nouveau_backlight_dtor(); - nouveau_unregister_dsm_handler(); #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER platform_driver_unregister(&nouveau_platform_driver); diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c index c948a0dc9e62..2bead7e879a5 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c @@ -26,6 +26,343 @@ #include #include +#include +#include + +#ifdef CONFIG_VGA_SWITCHEROO +struct nouveau_dsm_priv nouveau_dsm_priv = {}; + +static const guid_t nouveau_op_dsm_muid = + GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B, + 0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0); + +#define NOUVEAU_DSM_OPTIMUS_CAPS 0x1A +#define NOUVEAU_DSM_OPTIMUS_FLAGS 0x1B + +#define NOUVEAU_DSM_OPTIMUS_POWERDOWN_PS3 (3 << 24) +#define NOUVEAU_DSM_OPTIMUS_NO_POWERDOWN_PS3 (2 << 24) +#define NOUVEAU_DSM_OPTIMUS_FLAGS_CHANGED (1) + +#define NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN (NOUVEAU_DSM_OPTIMUS_POWERDOWN_PS3 | NOUVEAU_DSM_OPTIMUS_FLAGS_CHANGED) + +/* result of the optimus caps function */ +#define OPTIMUS_ENABLED (1 << 0) +#define OPTIMUS_STATUS_MASK (3 << 3) +#define OPTIMUS_STATUS_OFF (0 << 3) +#define OPTIMUS_STATUS_ON_ENABLED (1 << 3) +#define OPTIMUS_STATUS_PWR_STABLE (3 << 3) +#define OPTIMUS_DISPLAY_HOTPLUG (1 << 6) +#define OPTIMUS_CAPS_MASK (7 << 24) +#define OPTIMUS_DYNAMIC_PWR_CAP (1 << 24) + +#define OPTIMUS_AUDIO_CAPS_MASK (3 << 27) +#define OPTIMUS_HDA_CODEC_MASK (2 << 27) /* hda bios control */ + +static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result) +{ + int i; + union acpi_object *obj; + char args_buff[4]; + union acpi_object argv4 = { + .buffer.type = ACPI_TYPE_BUFFER, + .buffer.length = 4, + .buffer.pointer = args_buff + }; + + /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */ + for (i = 0; i < 4; i++) + args_buff[i] = (arg >> i * 8) & 0xFF; + + *result = 0; + obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100, + func, &argv4, ACPI_TYPE_BUFFER); + if (!obj) { + acpi_handle_info(handle, "failed to evaluate _DSM\n"); + return AE_ERROR; + } else { + if (obj->buffer.length == 4) { + *result |= obj->buffer.pointer[0]; + *result |= (obj->buffer.pointer[1] << 8); + *result |= (obj->buffer.pointer[2] << 16); + *result |= (obj->buffer.pointer[3] << 24); + } + ACPI_FREE(obj); + } + + return 0; +} + +/* Must be called for Optimus models before the card can be turned off */ +void nvkm_acpi_switcheroo_set_powerdown(void) +{ + u32 result = 0; + if (!nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.optimus_skip_dsm) + return; + + if (nouveau_dsm_priv.optimus_flags_detected) + nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS, + 0x3, &result); + + nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, + NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result); + +} + +/* + * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special + * requirements on the fourth parameter, so a private implementation + * instead of using acpi_check_dsm(). + */ +static int nouveau_dsm_get_optimus_functions(acpi_handle handle) +{ + int result; + + /* + * Function 0 returns a Buffer containing available functions. + * The args parameter is ignored for function 0, so just put 0 in it + */ + if (nouveau_optimus_dsm(handle, 0, 0, &result)) + return 0; + + /* + * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. + * If the n-th bit is enabled, function n is supported + */ + if (result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS)) + return result; + return 0; +} + +static const guid_t nouveau_dsm_muid = + GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48, + 0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4); + +#define NOUVEAU_DSM_LED 0x02 +#define NOUVEAU_DSM_LED_STATE 0x00 +#define NOUVEAU_DSM_LED_OFF 0x10 +#define NOUVEAU_DSM_LED_STAMINA 0x11 +#define NOUVEAU_DSM_LED_SPEED 0x12 + +#define NOUVEAU_DSM_POWER 0x03 +#define NOUVEAU_DSM_POWER_STATE 0x00 +#define NOUVEAU_DSM_POWER_SPEED 0x01 +#define NOUVEAU_DSM_POWER_STAMINA 0x02 + +static int nouveau_dsm(acpi_handle handle, int func, int arg) +{ + int ret = 0; + union acpi_object *obj; + union acpi_object argv4 = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = arg, + }; + + obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102, + func, &argv4, ACPI_TYPE_INTEGER); + if (!obj) { + acpi_handle_info(handle, "failed to evaluate _DSM\n"); + return AE_ERROR; + } else { + if (obj->integer.value == 0x80000002) + ret = -ENODEV; + ACPI_FREE(obj); + } + + return ret; +} + +static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id) +{ + mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); + mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); + return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id); +} + +static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state) +{ + int arg; + if (state == VGA_SWITCHEROO_ON) + arg = NOUVEAU_DSM_POWER_SPEED; + else + arg = NOUVEAU_DSM_POWER_STAMINA; + nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg); + return 0; +} + +static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id) +{ + if (!nouveau_dsm_priv.dsm_detected) + return 0; + if (id == VGA_SWITCHEROO_IGD) + return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA); + else + return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED); +} + +static int nouveau_dsm_power_state(enum vga_switcheroo_client_id id, + enum vga_switcheroo_state state) +{ + if (id == VGA_SWITCHEROO_IGD) + return 0; + + /* Optimus laptops have the card already disabled in + * nouveau_switcheroo_set_state */ + if (!nouveau_dsm_priv.dsm_detected) + return 0; + + return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state); +} + +static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *pdev) +{ + /* easy option one - intel vendor ID means Integrated */ + if (pdev->vendor == PCI_VENDOR_ID_INTEL) + return VGA_SWITCHEROO_IGD; + + /* is this device on Bus 0? - this may need improving */ + if (pdev->bus->number == 0) + return VGA_SWITCHEROO_IGD; + + return VGA_SWITCHEROO_DIS; +} + +static const struct vga_switcheroo_handler nouveau_dsm_handler = { + .switchto = nouveau_dsm_switchto, + .power_state = nouveau_dsm_power_state, + .get_client_id = nouveau_dsm_get_client_id, +}; + +static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out, + bool *has_mux, bool *has_opt, + bool *has_opt_flags, bool *has_pr3) +{ + acpi_handle dhandle; + bool supports_mux; + int optimus_funcs; + struct pci_dev *parent_pdev; + + if (pdev->vendor != PCI_VENDOR_ID_NVIDIA) + return; + + *has_pr3 = false; + parent_pdev = pci_upstream_bridge(pdev); + if (parent_pdev) { + if (parent_pdev->bridge_d3) + *has_pr3 = pci_pr3_present(parent_pdev); + else + pci_d3cold_disable(pdev); + } + + dhandle = ACPI_HANDLE(&pdev->dev); + if (!dhandle) + return; + + if (!acpi_has_method(dhandle, "_DSM")) + return; + + supports_mux = acpi_check_dsm(dhandle, &nouveau_dsm_muid, 0x00000102, + 1 << NOUVEAU_DSM_POWER); + optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle); + + /* Does not look like a Nvidia device. */ + if (!supports_mux && !optimus_funcs) + return; + + *dhandle_out = dhandle; + *has_mux = supports_mux; + *has_opt = !!optimus_funcs; + *has_opt_flags = optimus_funcs & (1 << NOUVEAU_DSM_OPTIMUS_FLAGS); + + if (optimus_funcs) { + uint32_t result; + nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, + &result); + dev_info(&pdev->dev, "optimus capabilities: %s, status %s%s\n", + (result & OPTIMUS_ENABLED) ? "enabled" : "disabled", + (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "", + (result & OPTIMUS_HDA_CODEC_MASK) ? "hda bios codec supported" : ""); + } +} + +static bool nouveau_dsm_detect(void) +{ + char acpi_method_name[255] = { 0 }; + struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name}; + struct pci_dev *pdev = NULL; + acpi_handle dhandle = NULL; + bool has_mux = false; + bool has_optimus = false; + bool has_optimus_flags = false; + bool has_power_resources = false; + int vga_count = 0; + bool guid_valid; + bool ret = false; + + /* lookup the MXM GUID */ + guid_valid = mxm_wmi_supported(); + + if (guid_valid) + printk("MXM: GUID detected in BIOS\n"); + + /* now do DSM detection */ + while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { + if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && + (pdev->class != PCI_CLASS_DISPLAY_3D << 8)) + continue; + + vga_count++; + + nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus, + &has_optimus_flags, &has_power_resources); + } + + /* find the optimus DSM or the old v1 DSM */ + if (has_optimus) { + nouveau_dsm_priv.dhandle = dhandle; + acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, + &buffer); + pr_info("VGA switcheroo: detected Optimus DSM method %s handle\n", + acpi_method_name); + if (has_power_resources) + pr_info("nouveau: detected PR support, will not use DSM\n"); + nouveau_dsm_priv.optimus_detected = true; + nouveau_dsm_priv.optimus_flags_detected = has_optimus_flags; + nouveau_dsm_priv.optimus_skip_dsm = has_power_resources; + ret = true; + } else if (vga_count == 2 && has_mux && guid_valid) { + nouveau_dsm_priv.dhandle = dhandle; + acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, + &buffer); + pr_info("VGA switcheroo: detected DSM switching method %s handle\n", + acpi_method_name); + nouveau_dsm_priv.dsm_detected = true; + ret = true; + } + + + return ret; +} + +void +nvkm_acpi_switcheroo_fini(void) +{ + if (nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.dsm_detected) + vga_switcheroo_unregister_handler(); +} + +void +nvkm_acpi_switcheroo_init(void) +{ + bool r; + + r = nouveau_dsm_detect(); + if (!r) + return; + + vga_switcheroo_register_handler(&nouveau_dsm_handler, 0); +} +#endif + #ifdef CONFIG_ACPI static int nvkm_acpi_ntfy(struct notifier_block *nb, unsigned long val, void *data) @@ -38,7 +375,7 @@ nvkm_acpi_ntfy(struct notifier_block *nb, unsigned long val, void *data) return NOTIFY_DONE; } -#endif +#endif /* CONFIG_ACPI */ void nvkm_acpi_fini(struct nvkm_device *device) diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h index 1d3c5cf7c3b4..34854d10026d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h @@ -6,4 +6,23 @@ struct nvkm_device; void nvkm_acpi_init(struct nvkm_device *); void nvkm_acpi_fini(struct nvkm_device *); + +#ifdef CONFIG_VGA_SWITCHEROO +extern struct nouveau_dsm_priv { + bool dsm_detected; + bool optimus_detected; + bool optimus_flags_detected; + bool optimus_skip_dsm; + acpi_handle dhandle; +} nouveau_dsm_priv; + +void nvkm_acpi_switcheroo_init(void); +void nvkm_acpi_switcheroo_fini(void); +void nvkm_acpi_switcheroo_set_powerdown(void); +#else +static inline void nvkm_acpi_switcheroo_init(void) {}; +static inline void nvkm_acpi_switcheroo_fini(void) {}; +static inline void nvkm_acpi_switcheroo_set_powerdown(void) {}; +#endif + #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/module.c b/drivers/gpu/drm/nouveau/nvkm/module.c index 66d28465514b..cf71c68af89a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/module.c +++ b/drivers/gpu/drm/nouveau/nvkm/module.c @@ -20,14 +20,17 @@ * DEALINGS IN THE SOFTWARE. */ #include +#include void __exit nvkm_exit(void) { + nvkm_acpi_switcheroo_fini(); } int __init nvkm_init(void) { + nvkm_acpi_switcheroo_init(); return 0; } From patchwork Thu Jun 13 17:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697176 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6876CC27C4F for ; Thu, 13 Jun 2024 17:01:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C38510EB30; Thu, 13 Jun 2024 17:01:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="YAc6hsZ1"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A43910EB15; Thu, 13 Jun 2024 17:00:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T36y9Wkmkjez9JqPSK8Bz4u3nQyGejN6os0dTemJyYyrVJvSqiRVpdgS8H+Rxze98WTiY397EWMTuW2hBp2PJxaKlX9WaQuIJi8dr/VOItuMCFwoi6rFzVBFjE2rKDLFBOiBkwL+4LjQ1daAFb2gHcM9QRxM3G/7FhHXjO2n5sJ2uwMKDqdfwxx7wSfQ59LtA0IBmDv0kzzivGJ9OurMLblCRCmz0IX3C4ahl9RDdRwTajKoasZfn8A8N+L6ybVPuaSLsXqG8RO8BLDHl/0rImpyT/lys2+HVvEMAcNcJrR6hAxe034RQfamYTRra2ZFQ9yZNmUiVgALeOA6Jo1rZg== 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=lyr3WMOCIteDmaS5ZrBx+YRtrEaXDLizInJjEcmaLys=; b=jrcz52wbySNnR/bZk55cEnkn6FvNDN+Mt4lJnnSeykywzBP2L3CPwx8ZWAG8y8ugEaEJIiVYDsLcl3LUQEG1ERX2aQvOeDABExr+IOWTK6rezPPcatBVR5h8LzGV0B/E9Mxw1wmVO9WN65hY5VEPt4yA2cEbsePSFuqTRV8k8+aTz7DSipGswfzaatO4ORX+NEWPkK8UERTFvtle6xoyf0Y0kWaJTPMOvaW8qKLwARiVGN4/mRcLBOG4Yn6Gn0No0f1dySmP122/fCMOn4QKv9S+e6KVWFrI/HGmsNxd9FBq/0wsEjKr33IXmlOz/IsALQyU+HoNpf9HFKC7RNfPig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lyr3WMOCIteDmaS5ZrBx+YRtrEaXDLizInJjEcmaLys=; b=YAc6hsZ1T0FNtYvliyZAKPug3VyfnUiNh7ek9TxWGtUN5H8SgI03uGrTG64NIDG+CLGhwC8+QM1WWF+rmehJPSXqhNtYWPlZOD1exuzYq1iL0oRXzKanKMAKajlrrgfILnfpgVIUFuBDpTZx3tR3XdUr4RnWlER0lJWvg3N2JNuFKbMiJkR4jTdvQ8luauAZNJdwV8iFj6yG+RNyK5PbVgjaAWMww/hYbBU/AvPZsaRJiIzlGGFcWvHLrbea3/MESmT22nmujwBLf4H5Smb91Ri+PBmJRAQXyex+uUyH4spX8v0wqs1TtkqKDxODGXhNnxEl5vuJaX30vQNV488T8Q== Received: from MW4PR02CA0004.namprd02.prod.outlook.com (2603:10b6:303:16d::19) by MW4PR12MB7437.namprd12.prod.outlook.com (2603:10b6:303:21a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 17:00:04 +0000 Received: from SJ1PEPF00002324.namprd03.prod.outlook.com (2603:10b6:303:16d:cafe::fe) by MW4PR02CA0004.outlook.office365.com (2603:10b6:303:16d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002324.mail.protection.outlook.com (10.167.242.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:51 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:50 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 10/21] drm/nouveau/nvif: add runpm supported flag to device impl Date: Fri, 14 Jun 2024 03:00:02 +1000 Message-ID: <20240613170046.88687-11-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002324:EE_|MW4PR12MB7437:EE_ X-MS-Office365-Filtering-Correlation-Id: aeac2850-4233-43ee-9e01-08dc8bca455f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: 9ry9zOUyD7ACzVBqVPgFXmmXbaA9djtF8dtc7la2qu9jm1y0appxmoIfD5o96WfzOfrAYSHQsXKWwSzvUMtTUI68CDY8QNulAV8ulbXCcaIALZQB6DUvAlRynD2xGT5MOcAYAid9IB5ghkfveRQXGgUHIoaCb6JOaGb1T3+5+EgJkvQQCpqqJdOyYrkEuLgvYGrMHxh3YFKJQ4E9DkJljArXqJSrIu8iw55oWW/3EBVPITRi4nmt+szivreSm4cb71M31CUWrMXi/GPr6thXYDEgmsqBB6qzbI1PP0jmsaCNQNfdITV3JxPbcePHRWtHyPnW+6i6t3PChE8eI4VD86jmVsifx28Ejwzi4iDMMjYax+v0c166JexldXJ9u+8quI/DYJDzz4g6ZypJZST02aTviFIHO9AtY7gg5uy35NUIRbiViBTJGg0YICdNg3PxyIbGBeUh7ST/VLvBw5MOAXerI2iU7PZfAWxAVQQou/TZBlH5opLjCiQWRgvc/OELbZX6VfLMzyhQsA1rkGydzlsM5+HSQxD3VF6rvSzvda7Id9Jtk2nnecwvZKPzAyv5QMtea+7TjSCiLR8e1V2HPHwuzgSFPhjo/QK3iFeRJ1SjEIbYSn/U0K/qDwn/kCP2bbPvmgsitPvQWZ8PV6ze+wC+go/8ILIQI/Jh2iNhTEF34nHRZiQEJ+k/jkxlua824krzTfESiGQkj6AsiWQN1oj+kYCbJDyYdf3o9FD8QZs2lIkICWTNd8Ey6vERupj7cvYuH6VCgwGSz5gwu+Rjh0j+UIjw7onv1NJgn49YWpTxT/bIs7UKxIPhOl0xKDfXu+t5bv1u8urT1P/fExFPLc5q5o5Q4B4LaSj/zFaNDSS1bkOBnkA2l7WhWV0bJSEqZnAFYc66AIS202EIY38HAEYBIHZSD2UuGUK1zesVTjDnrdgTZ/cCdBqBhp6wxsZvu84+jezbZE0CnkwWl6e8oPny8Cx8PKzSw4KsJ1kuLDBGOUDTiAoHP45ipDam8V44LwnHomU8XrfbW7f6Rc38swAYKZiZXhsuZt7FfvdUmuAhbrt/cTWH//X1rkHQvy8GwVW967665CdOiUk2GiCp1iKoIf9SllQ+O7bv0pHlJvMg3J3XHImcJiDEOnPEaJFeZUtPYRt+dM3nG97L06D4/k2NMNZmza+stYepkZBkV5dFargOjxcgrWYlvYzIpUM348OSpzCvC7X1mcvKlZiWMAFqkXBFhA7jvO936p/9BRDqrIArgDU545b69rrkIyJ2qY9FAx+DcjTR9P1INAkSdrovKufEVG8o0rFceqppMkuWa35Xt7HPo++N4yk4mhkoqNyRRa349LOhzz3gwDfxVERYqvI51WRz9lRNuADn24ljEdpxdPkdIflBtmy4NE4uE92MpGOAvKBpirLONrxU8A== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:04.3004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aeac2850-4233-43ee-9e01-08dc8bca455f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002324.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7437 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DRM driver uses "nouveau_is_optimus() || nouveau_is_v1_dsm()", which have been moved to NVKM, to determine support for runtime pm. Replace with a feature flag returned when allocating an nvif_device. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/include/nvif/driverif.h | 2 ++ .../gpu/drm/nouveau/include/nvkm/core/device.h | 6 ++++++ .../gpu/drm/nouveau/include/nvkm/core/module.h | 2 ++ drivers/gpu/drm/nouveau/nouveau_drm.c | 17 ++++++++++------- drivers/gpu/drm/nouveau/nouveau_drv.h | 2 +- drivers/gpu/drm/nouveau/nouveau_vga.c | 4 ++-- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 12 ++++++++++++ drivers/gpu/drm/nouveau/nvkm/device/user.c | 2 ++ drivers/gpu/drm/nouveau/nvkm/module.c | 2 ++ 9 files changed, 39 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 638c72c1b580..e1d3ccc2128c 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -538,6 +538,8 @@ struct nvif_device_impl { u64 ram_size; u64 ram_user; + bool runpm; + u64 (*time)(struct nvif_device_priv *); struct { diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index c9965934b0d5..3c11d3068ced 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -55,6 +55,12 @@ struct nvkm_device { struct notifier_block nb; } acpi; + enum { + NVKM_DEVICE_RUNPM_NONE = 0, + NVKM_DEVICE_RUNPM_V1, + NVKM_DEVICE_RUNPM_OPTIMUS, + } runpm; + #define NVKM_LAYOUT_ONCE(type,data,ptr) data *ptr; #define NVKM_LAYOUT_INST(type,data,ptr,cnt) data *ptr[cnt]; #include diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/module.h b/drivers/gpu/drm/nouveau/include/nvkm/core/module.h index 5cf80e4deb90..fc42ace93a1c 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/module.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/module.h @@ -5,4 +5,6 @@ int __init nvkm_init(void); void __exit nvkm_exit(void); + +extern int nvkm_runpm; #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 0ac17da04819..52c4c3f58799 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -486,7 +486,7 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) struct drm_device *dev = drm->dev; struct nouveau_cli *cli, *temp_cli; - if (nouveau_pmops_runtime()) { + if (nouveau_pmops_runtime(dev->dev)) { pm_runtime_get_sync(dev->dev); pm_runtime_forbid(dev->dev); } @@ -584,7 +584,7 @@ nouveau_drm_device_init(struct nouveau_drm *drm) nouveau_dmem_init(drm); nouveau_led_init(dev); - if (nouveau_pmops_runtime()) { + if (nouveau_pmops_runtime(dev->dev)) { pm_runtime_use_autosuspend(dev->dev); pm_runtime_set_autosuspend_delay(dev->dev, 5000); pm_runtime_set_active(dev->dev); @@ -1031,10 +1031,13 @@ nouveau_pmops_thaw(struct device *dev) } bool -nouveau_pmops_runtime(void) +nouveau_pmops_runtime(struct device *dev) { + struct nouveau_drm *drm = nouveau_drm(dev_get_drvdata(dev)); + if (nouveau_runtime_pm == -1) - return nouveau_is_optimus() || nouveau_is_v1_dsm(); + return drm->device.impl->runpm; + return nouveau_runtime_pm == 1; } @@ -1045,7 +1048,7 @@ nouveau_pmops_runtime_suspend(struct device *dev) struct nouveau_drm *drm = pci_get_drvdata(pdev); int ret; - if (!nouveau_pmops_runtime()) { + if (!nouveau_pmops_runtime(dev)) { pm_runtime_forbid(dev); return -EBUSY; } @@ -1067,7 +1070,7 @@ nouveau_pmops_runtime_resume(struct device *dev) struct nouveau_drm *drm = pci_get_drvdata(pdev); int ret; - if (!nouveau_pmops_runtime()) { + if (!nouveau_pmops_runtime(dev)) { pm_runtime_forbid(dev); return -EBUSY; } @@ -1098,7 +1101,7 @@ nouveau_pmops_runtime_resume(struct device *dev) static int nouveau_pmops_runtime_idle(struct device *dev) { - if (!nouveau_pmops_runtime()) { + if (!nouveau_pmops_runtime(dev)) { pm_runtime_forbid(dev); return -EBUSY; } diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 52589d5eab63..c2014a29891c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -324,7 +324,7 @@ nouveau_drm_use_coherent_gpu_mapping(struct nouveau_drm *drm) int nouveau_pmops_suspend(struct device *); int nouveau_pmops_resume(struct device *); -bool nouveau_pmops_runtime(void); +bool nouveau_pmops_runtime(struct device *); #include diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c index 53b332708061..1f5ccec025d7 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c @@ -63,7 +63,7 @@ void nouveau_vga_init(struct nouveau_drm *drm) { struct drm_device *dev = drm->dev; - bool runtime = nouveau_pmops_runtime(); + bool runtime = nouveau_pmops_runtime(dev->dev); struct pci_dev *pdev; /* only relevant for PCI devices */ @@ -85,7 +85,7 @@ void nouveau_vga_fini(struct nouveau_drm *drm) { struct drm_device *dev = drm->dev; - bool runtime = nouveau_pmops_runtime(); + bool runtime = nouveau_pmops_runtime(dev->dev); struct pci_dev *pdev; /* only relevant for PCI devices */ diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index e48f3219f047..16e059866168 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -22,6 +22,8 @@ * Authors: Ben Skeggs */ #include +#include +#include "acpi.h" #include "priv.h" struct nvkm_device_pci_device { @@ -1704,5 +1706,15 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, } *pdevice = &pdev->device; + + if (nvkm_runpm) { + if (!nouveau_dsm_priv.optimus_detected) { + if (nouveau_dsm_priv.dsm_detected) + device->runpm = NVKM_DEVICE_RUNPM_V1; + } else { + device->runpm = NVKM_DEVICE_RUNPM_OPTIMUS; + } + } + return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/device/user.c b/drivers/gpu/drm/nouveau/nvkm/device/user.c index 4ffcd7c6e0b9..a510d24019f6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/user.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/user.c @@ -393,6 +393,8 @@ nvkm_udevice_new(struct nvkm_device *device, if (device->imem && udev->impl.ram_size > 0) udev->impl.ram_user = udev->impl.ram_user - device->imem->reserved; + udev->impl.runpm = (device->runpm != NVKM_DEVICE_RUNPM_NONE); + if (device->vfn) { udev->impl.usermode.oclass = device->vfn->user.base.oclass; udev->impl.usermode.new = nvkm_udevice_usermode_new; diff --git a/drivers/gpu/drm/nouveau/nvkm/module.c b/drivers/gpu/drm/nouveau/nvkm/module.c index cf71c68af89a..7a56ef8c3b6b 100644 --- a/drivers/gpu/drm/nouveau/nvkm/module.c +++ b/drivers/gpu/drm/nouveau/nvkm/module.c @@ -22,6 +22,8 @@ #include #include +int nvkm_runpm = -1; + void __exit nvkm_exit(void) { From patchwork Thu Jun 13 17:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697160 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 03FAEC27C6E for ; Thu, 13 Jun 2024 17:01:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D84FC10EB33; Thu, 13 Jun 2024 17:01:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="t+aZ6HP/"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 00EE810EB19; Thu, 13 Jun 2024 17:00:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ocX0Cl5rnzXlfIfkxyY2HtWHZ+YRZft+ln6d2t4aPfX87rA/ubqr/ME5pgSqFj2dhLc2PVX63iI9ycfeJk0OiCFjlnuUyd5mZs0VUapEFyMP1V1Ryc06pOEGZ2HBq1etKXrWqWLdn4dtAm7ZeykFtR+Pu5b1qPCAlsgSGa7tGaZvYyrtuDqa6RuYf/bxAf5eFM2dUI+Kz3ev2dnLJHvu+Zh3H6vrh8z8vRtqq/R3wZkfiy7AVb0a6RmZKnUZQtt7XsVSEVkCqVNn+C0YbeF6hQ11gtFjE7BisUxKwgkY96iPTfKqUukjzbGlhDNlgnbdlyOAn0lzua4pwXt8W7tkBw== 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=WYwGodSCEo4o8qng0Xi7VHXUq0eon05cbXGB4ZtQTJA=; b=EUfEJSgW5IQUrEqzrOFEeqY3AD7o4vKk1JGPK/zCiy2mpppY7kXKKPDZH2BH7WSKpHIm8NovMVe1CHoOFVU7QdNgFhLc5zDTHXbhRveFeLSrHt9u0kYQXrdNrNvjxZ0rTNCEBFB6OzqegOWwz4ylI4ixfYDrSiPEMsIcde+NbnJy63mflshivg+9PDWekTFZSSdicpZ7acEsJGER8QeAOFnpKJYiEmdiBIKkZSKOzYlYh22yFcObdbYNCgIpWQb7fixKoZECDNsA4AOaVIEVJq9PEGqKsc2eYYqwoFGhPfgKKIpW+Nv0cZDdTo0Rw8W7iMFpkSZOxJkvtPkAMWhr/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WYwGodSCEo4o8qng0Xi7VHXUq0eon05cbXGB4ZtQTJA=; b=t+aZ6HP/wMy9dzXq11TGq5iTdSAyldocSLcwTOZbrd1qpr8SFgBJ3Gm+V0yNwHCwPKRdbswcIGFnOBkv0N9Wg0ByOiRZLE09D0u8iP3IUmCf73d9kVIb5Mx7hKh7ng/zZ7y3F9qDL1WNyyfQthngL4GJXG5y/cxjSlvtOQHwRl95jDYxWzXpIifCJFXp+qHv5cBWrt+I5S9hCoi93e9Xju3cGELrqqxBO7r2qTqSzE81dKz6v3kkmgOexBOrKWb46fX6fGRakgdK7dg4TJquLnIVkft+bq6wO75z1KtcJSJAw0gs0Pye0tQmJBia8iCB/98tVjqminbIaW/rsH/i0Q== Received: from MW4PR02CA0007.namprd02.prod.outlook.com (2603:10b6:303:16d::33) by SJ0PR12MB6831.namprd12.prod.outlook.com (2603:10b6:a03:47d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 17:00:05 +0000 Received: from SJ1PEPF00002324.namprd03.prod.outlook.com (2603:10b6:303:16d:cafe::64) by MW4PR02CA0007.outlook.office365.com (2603:10b6:303:16d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002324.mail.protection.outlook.com (10.167.242.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:53 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:51 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 11/21] drm/nouveau/nvkm: move switcheroo from drm Date: Fri, 14 Jun 2024 03:00:03 +1000 Message-ID: <20240613170046.88687-12-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002324:EE_|SJ0PR12MB6831:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c07368c-fe47-4400-d3ce-08dc8bca45d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: PmDAWQvxVjFndykm4Y3y5DUDMpW4K26mvMrHv0zdN89NNA1QNaoD9XncVijf8rMvxIxBTF1nWZJmZJ+aq1KlTyd57CJbxRPtpewhWFv9Yy92Ib2iGsAMjnohepJpMhLy1mg7Jsd9I2oMZ/UhdEiAw1N9cQQA5ca6OMPfqtPY880Uh5Irf7UDAI8B2a9PcKygWJlVfAUk2N3hYsEXHAGHQqAk06fRwpq2JRLucbO2jp94EXUzwbr70BRSKhpU3YjqzBF9w9+kKoakZy4/jg9dhvHs7LEx4xk62f9whBWhwTtL6DnN/63IJS0ZXub0uUDyHungTpSJOqh0Av2PBehi4qmhi0vNhr71ivAHotyH+QqTqwtU7P7NVeDvNkJQjR77ksWdhgSgey2MiUkjLht8n+zjjQwSoQ4XVc0sFNbTYc8iEz+JOlwTzGj+8C38RVYa121gYRIZ592kkF4Q9PhJBFgz66xvdCVT8nWJgiaLPgXG3GtQFm1Qplou04xGxAQxTTYecZbHBaXxo6opcq7BiesMJeZVoUr9e9HRnRwbHm/WVw5eqTadaWwEbYzWodX7Yjw/1ch4Vb6FJLdVUuSbFtfNtvgNZN75nOTVQ7kZ8wZshL0pt4EIX+gdwtqXuXLCIoSY6mbz9QK644sYCCLsWltqkHmZ2PYO15narojNCPHhCkIgAvqlow8+EddmeSDZmiJN+Z07qootxPtB+CX1Y6NVFBaT7AmZPzC91DnTq+ashLsQRby6oUMjauMiLO4akEKvMVpULmmGLk3fpxJ/46VWVB3eIT23h9jyeMkuDYDRcInKVK+7pQv1UFBCKqMJyaFN5yt/O0LHzUhg+7stHPHZRaBtWKVYs5Uz7rGo27+OSrDlDCLekYn1mPqjRsfzeMPaaUgdfoEXHosco6OrIUORdgXpOeC9a4etQLg9Cm6MWsKdOw9Bxmz1Hi/Pn8az2SZoC61qSzuI7Vaedne+vICD9p9NVZ5Oejnhte7UhTNsWIn7w+nXSt+w4foDojI8X8cF5N8DDi0HC9zrkS3sHi6SXuUqwC5qMvBKaSpx5U4wup5KGYhX1kMXqN5ZuUImfIdO4pR/7PYhDpovpL+w0YsDArrPiTBRHLbvrt1peSDdbzq5p2MS6iDLOh+28xI3zOlzp9P5qQypiix6irjqj/cLvRehfzKmLcJHMrS7Qz+N33kmx6Ta1Z17XCuIsch7HWXDKdaMqba97xX0dCRfL9s1+1ZcWuf+W7L+qEGhqf/Vdp4XOcwgjW/cE1cVy/Jj5tZtylrc1suhQAAq2WmDUv+GtKyn037Cqhjtp3IC0vhuzc3eIHApWjnqnIRLHpFriPxzhGv5609/LeqtWf/GSVxxSYWr5huIkbnRD4xFECG/T/+aC47lHeN8b2ZWiAgRfBZylXAi6DdBk0qI9xJ4ww== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:05.0816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c07368c-fe47-4400-d3ce-08dc8bca45d6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002324.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6831 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DRM driver needs to do things in response to vga_switcheroo_client callbacks, so this move isn't a direct copy+paste. 3 new callbacks are added to nvif_driver_func, which are basically the same as the switcheroo callbacks, except NVKM handles all the PCI/ACPI parts, and calls into the DRM driver for the rest. Signed-off-by: Ben Skeggs --- .../gpu/drm/nouveau/include/nvif/driverif.h | 7 ++ .../gpu/drm/nouveau/include/nvkm/core/pci.h | 2 + drivers/gpu/drm/nouveau/nouveau_acpi.c | 8 -- drivers/gpu/drm/nouveau/nouveau_acpi.h | 4 - drivers/gpu/drm/nouveau/nouveau_drm.c | 5 +- drivers/gpu/drm/nouveau/nouveau_drv.h | 2 - drivers/gpu/drm/nouveau/nouveau_vga.c | 71 +++------------- drivers/gpu/drm/nouveau/nouveau_vga.h | 3 +- drivers/gpu/drm/nouveau/nvkm/device/acpi.c | 83 ++++++++++++++++++- 9 files changed, 104 insertions(+), 81 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index e1d3ccc2128c..49db239f1156 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -2,6 +2,7 @@ #ifndef __NVIF_DRIVERIF_H__ #define __NVIF_DRIVERIF_H__ #include +#include struct nvif_event_priv; struct nvif_client_priv; @@ -36,6 +37,12 @@ struct nvif_event_impl { struct nvif_driver_func { enum nvif_event_stat (*event)(u64 token, void *repv, u32 repc); + + struct nvif_driver_func_switcheroo { + bool (*can_switch)(const struct nvif_driver_func *); + void (*set_state)(const struct nvif_driver_func *, enum vga_switcheroo_state); + void (*reprobe)(const struct nvif_driver_func *); + } switcheroo; }; struct nvif_driver { diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h index 7444c4d59e09..a1e9ee6da44e 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h @@ -7,6 +7,8 @@ struct nvkm_device_pci { struct nvkm_device device; struct pci_dev *pdev; bool suspend; + + struct dev_pm_domain vga_pm_domain; }; int nvkm_device_pci_new(struct pci_dev *, const char *cfg, const char *dbg, diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index b9c43fe552c0..da3120258527 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -8,14 +8,6 @@ #include "nouveau_drv.h" #include "nouveau_acpi.h" -bool nouveau_is_optimus(void) { - return nouveau_dsm_priv.optimus_detected; -} - -bool nouveau_is_v1_dsm(void) { - return nouveau_dsm_priv.dsm_detected; -} - void * nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.h b/drivers/gpu/drm/nouveau/nouveau_acpi.h index a7fac1f7a73d..be1b218cb921 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.h +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.h @@ -5,16 +5,12 @@ #define ROM_BIOS_PAGE 4096 #if defined(CONFIG_ACPI) && defined(CONFIG_X86) -bool nouveau_is_optimus(void); -bool nouveau_is_v1_dsm(void); #include static inline void nouveau_switcheroo_optimus_dsm(void) { nvkm_acpi_switcheroo_set_powerdown(); } void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *); bool nouveau_acpi_video_backlight_use_native(void); void nouveau_acpi_video_register_backlight(void); #else -static inline bool nouveau_is_optimus(void) { return false; }; -static inline bool nouveau_is_v1_dsm(void) { return false; }; static inline void nouveau_switcheroo_optimus_dsm(void) {} static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; } static inline bool nouveau_acpi_video_backlight_use_native(void) { return true; } diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 52c4c3f58799..580849b78231 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -505,7 +505,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) nouveau_bios_takedown(dev); nouveau_ttm_fini(drm); - nouveau_vga_fini(drm); /* * There may be existing clients from as-yet unclosed files. For now, @@ -556,8 +555,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm) if (drm->device.impl->chipset == 0xc1) nvif_mask(&drm->device, 0x00088080, 0x00000800, 0x00000000); - nouveau_vga_init(drm); - ret = nouveau_ttm_init(drm); if (ret) goto fail_ttm; @@ -608,7 +605,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm) fail_bios: nouveau_ttm_fini(drm); fail_ttm: - nouveau_vga_fini(drm); nouveau_cli_fini(&drm->cli); fail_wq: destroy_workqueue(drm->sched_wq); @@ -650,6 +646,7 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren drm->nvkm = device; drm->driver = nouveau_driver; + drm->driver.switcheroo = nouveau_switcheroo; device->cfgopt = nouveau_config; device->dbgopt = nouveau_debug; diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index c2014a29891c..b44f0d408ccc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -295,8 +295,6 @@ struct nouveau_drm { /* led management */ struct nouveau_led *led; - struct dev_pm_domain vga_pm_domain; - struct nouveau_svm *svm; struct nouveau_dmem *dmem; diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c index 1f5ccec025d7..cb5cd4b93fdf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c @@ -8,41 +8,35 @@ #include "nouveau_vga.h" static void -nouveau_switcheroo_set_state(struct pci_dev *pdev, - enum vga_switcheroo_state state) +nouveau_switcheroo_set_state(const struct nvif_driver_func *driver, enum vga_switcheroo_state state) { - struct nouveau_drm *drm = pci_get_drvdata(pdev); - struct drm_device *dev = drm->dev; - - if ((nouveau_is_optimus() || nouveau_is_v1_dsm()) && state == VGA_SWITCHEROO_OFF) - return; + struct drm_device *dev = container_of(driver, struct nouveau_drm, driver)->dev; if (state == VGA_SWITCHEROO_ON) { pr_err("VGA switcheroo: switched nouveau on\n"); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; - nouveau_pmops_resume(&pdev->dev); + nouveau_pmops_resume(dev->dev); dev->switch_power_state = DRM_SWITCH_POWER_ON; } else { pr_err("VGA switcheroo: switched nouveau off\n"); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; - nouveau_switcheroo_optimus_dsm(); - nouveau_pmops_suspend(&pdev->dev); + nouveau_pmops_suspend(dev->dev); dev->switch_power_state = DRM_SWITCH_POWER_OFF; } } static void -nouveau_switcheroo_reprobe(struct pci_dev *pdev) +nouveau_switcheroo_reprobe(const struct nvif_driver_func *driver) { - struct nouveau_drm *drm = pci_get_drvdata(pdev); + struct nouveau_drm *drm = container_of(driver, struct nouveau_drm, driver); drm_fb_helper_output_poll_changed(drm->dev); } static bool -nouveau_switcheroo_can_switch(struct pci_dev *pdev) +nouveau_switcheroo_can_switch(const struct nvif_driver_func *driver) { - struct nouveau_drm *drm = pci_get_drvdata(pdev); + struct nouveau_drm *drm = container_of(driver, struct nouveau_drm, driver); /* * FIXME: open_count is protected by drm_global_mutex but that would lead to @@ -52,56 +46,13 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev) return atomic_read(&drm->dev->open_count) == 0; } -static const struct vga_switcheroo_client_ops -nouveau_switcheroo_ops = { - .set_gpu_state = nouveau_switcheroo_set_state, +const struct nvif_driver_func_switcheroo +nouveau_switcheroo = { + .set_state = nouveau_switcheroo_set_state, .reprobe = nouveau_switcheroo_reprobe, .can_switch = nouveau_switcheroo_can_switch, }; -void -nouveau_vga_init(struct nouveau_drm *drm) -{ - struct drm_device *dev = drm->dev; - bool runtime = nouveau_pmops_runtime(dev->dev); - struct pci_dev *pdev; - - /* only relevant for PCI devices */ - if (!dev_is_pci(dev->dev)) - return; - pdev = to_pci_dev(dev->dev); - - /* don't register Thunderbolt eGPU with vga_switcheroo */ - if (pci_is_thunderbolt_attached(pdev)) - return; - - vga_switcheroo_register_client(pdev, &nouveau_switcheroo_ops, runtime); - - if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus()) - vga_switcheroo_init_domain_pm_ops(drm->dev->dev, &drm->vga_pm_domain); -} - -void -nouveau_vga_fini(struct nouveau_drm *drm) -{ - struct drm_device *dev = drm->dev; - bool runtime = nouveau_pmops_runtime(dev->dev); - struct pci_dev *pdev; - - /* only relevant for PCI devices */ - if (!dev_is_pci(dev->dev)) - return; - pdev = to_pci_dev(dev->dev); - - if (pci_is_thunderbolt_attached(pdev)) - return; - - vga_switcheroo_unregister_client(pdev); - if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus()) - vga_switcheroo_fini_domain_pm_ops(drm->dev->dev); -} - - void nouveau_vga_lastclose(struct drm_device *dev) { diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.h b/drivers/gpu/drm/nouveau/nouveau_vga.h index 951a83f984dd..119b39cfbbcc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.h +++ b/drivers/gpu/drm/nouveau/nouveau_vga.h @@ -2,8 +2,7 @@ #ifndef __NOUVEAU_VGA_H__ #define __NOUVEAU_VGA_H__ -void nouveau_vga_init(struct nouveau_drm *); -void nouveau_vga_fini(struct nouveau_drm *); +extern const struct nvif_driver_func_switcheroo nouveau_switcheroo; void nouveau_vga_lastclose(struct drm_device *dev); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c index 2bead7e879a5..cbaad3ea10eb 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c @@ -23,9 +23,11 @@ */ #include "acpi.h" -#include +#include #include +#include + #include #include @@ -189,6 +191,48 @@ static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switchero return 0; } +#include "nouveau_drv.h" +#include "nouveau_acpi.h" + +static void +nvkm_acpi_switcheroo_reprobe(struct pci_dev *pdev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + + device->driver->switcheroo.reprobe(device->driver); +} + +static void +nvkm_acpi_switcheroo_set_state(struct pci_dev *pdev, + enum vga_switcheroo_state state) +{ + struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + + if (state == VGA_SWITCHEROO_OFF) { + if (nouveau_dsm_priv.dsm_detected || nouveau_dsm_priv.optimus_detected) + return; + + nvkm_acpi_switcheroo_set_powerdown(); + } + + device->driver->switcheroo.set_state(device->driver, state); +} + +static bool +nvkm_acpi_switcheroo_can_switch(struct pci_dev *pdev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + + return device->driver->switcheroo.can_switch(device->driver); +} + +static const struct vga_switcheroo_client_ops +nvkm_acpi_switcheroo_ops = { + .can_switch = nvkm_acpi_switcheroo_can_switch, + .set_gpu_state = nvkm_acpi_switcheroo_set_state, + .reprobe = nvkm_acpi_switcheroo_reprobe, +}; + static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id) { if (!nouveau_dsm_priv.dsm_detected) @@ -380,16 +424,53 @@ nvkm_acpi_ntfy(struct notifier_block *nb, unsigned long val, void *data) void nvkm_acpi_fini(struct nvkm_device *device) { + struct nvkm_device_pci *pdev; + + if (!device->func->pci) + return; + + pdev = device->func->pci(device); + (void)pdev; + #ifdef CONFIG_ACPI unregister_acpi_notifier(&device->acpi.nb); #endif + +#ifdef CONFIG_VGA_SWITCHEROO + if (pci_is_thunderbolt_attached(pdev->pdev)) + return; + + vga_switcheroo_unregister_client(pdev->pdev); + if (device->runpm == NVKM_DEVICE_RUNPM_V1) + vga_switcheroo_fini_domain_pm_ops(device->dev); +#endif } void nvkm_acpi_init(struct nvkm_device *device) { + struct nvkm_device_pci *pdev; + + if (!device->func->pci) + return; + + pdev = device->func->pci(device); + (void)pdev; + #ifdef CONFIG_ACPI device->acpi.nb.notifier_call = nvkm_acpi_ntfy; register_acpi_notifier(&device->acpi.nb); #endif + +#ifdef CONFIG_VGA_SWITCHEROO + /* don't register Thunderbolt eGPU with vga_switcheroo */ + if (pci_is_thunderbolt_attached(pdev->pdev)) + return; + + vga_switcheroo_register_client(pdev->pdev, &nvkm_acpi_switcheroo_ops, + device->runpm != NVKM_DEVICE_RUNPM_NONE); + + if (device->runpm == NVKM_DEVICE_RUNPM_V1) + vga_switcheroo_init_domain_pm_ops(device->dev, &pdev->vga_pm_domain); +#endif } From patchwork Thu Jun 13 17:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697157 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A363DC27C6E for ; Thu, 13 Jun 2024 17:01:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA44910EB2A; Thu, 13 Jun 2024 17:01:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="tclbTbiu"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CE7910EB18; Thu, 13 Jun 2024 17:00:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XMsUChnvelVUbJUwFgM7Nf948a8bl84NAEfFMnJlOiurH0gLJugyWm+qhwkfXImRDyZgiC9uOXSHJdWW9veFor+886/ne2DHhrYT6hGyGpv9YipIaHDb/WDveMAHCUPC/9/sPbkHN/7dE6tMTc7BhgLhNzi3dNkpA22He8m/bOLsFuY+fqegjhPIeqFfHQk3IB5A+dMEDJlen9ncUIozg6bxUawEaWvjtZqiQIgSDhAFTToADB8zGbMw+Al3wdohJGGdsGZ9oeEXcTR67Am9Q0qyFs4Qr2b5t/6U5HOsaU45eBQp+qBcOBDGFc1jKgdSAb0+x3jxEcvtior/v8zJRQ== 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=yeamXsoNP8XsMfiai1c6C4O+TYg5s/XKFdmaZDyqF98=; b=eghy+svMDjBa+6wLiPLSLmoCwQhCpprVgESLjzX23lyih5CXniO+pPecKyljDujTBMEIArkl2YftkjnNxZ5CEG9BSEBgGKceTBQsBN66HZ1dYG82y2jg+EBrYIXEEM/qTiybofmDYshxQoI/cHlrO7LpFRQ/HwNR0dHN5EdGsK4yYxvn3CE0tdvr4C+jE3TrrSYBHoRLTSKbrPaWxdYkTefwSt1MT7BjIO7LRp1brNoKwYqvT8bFyY1FmbgsIO9rf1CwaabeNDnWzd4foTo048/JbpnfI0p75aZyu3xLFMf6YJsLrEHCy3HjZYTlSwwlFS9zIrttRV2613JVkcow9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yeamXsoNP8XsMfiai1c6C4O+TYg5s/XKFdmaZDyqF98=; b=tclbTbiuIZVD+vwCoKR4j0IWYtlbEph3wyhiidEyDE5b4vH3NxUX0LvhXwA/ptUuchZ6XfmWsCHw8ILyDv5E+6sX6uOr9OZP+xWcZxcwgVlZsfSkzy/hSSyOavmGOiNFxyXfkF7jltCcF9IaTLq4AHY7A9gKauVpdTKC3yy8xV02e1gVgD3EI/1erf56w7GiMox3d0USoufRXQDZj5mUSE0UYfVIn4YRzalupbvACq8vP6LKPoqEuLUXxOHw8dxaUCFVROcdsaLZP7ZONnBGpwIyjbB6d/iTatAB3bTDNPoLm/UTRT7zrn8fpDAOulQzPd4gO73dvwM+FS7C6wlUxA== Received: from SJ0PR03CA0349.namprd03.prod.outlook.com (2603:10b6:a03:39c::24) by CY8PR12MB8194.namprd12.prod.outlook.com (2603:10b6:930:76::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.23; Thu, 13 Jun 2024 17:00:08 +0000 Received: from SJ1PEPF00002323.namprd03.prod.outlook.com (2603:10b6:a03:39c:cafe::b5) by SJ0PR03CA0349.outlook.office365.com (2603:10b6:a03:39c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 17:00:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002323.mail.protection.outlook.com (10.167.242.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:54 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:53 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 12/21] drm/nouveau/nvkm: prepare pci/tegra probe()/remove() functions Date: Fri, 14 Jun 2024 03:00:04 +1000 Message-ID: <20240613170046.88687-13-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002323:EE_|CY8PR12MB8194:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b668ce6-62d6-42ef-7f42-08dc8bca4756 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: Q50Rw4Ct91hTaowyESL/N87NdV9Ov05YOsk0EHbxagxwv+/dGtSvCHkMgLcTQrXrnSS0FcXsy6DK9nIBOrdPq9CYqUYkpcILLtv1yTEj0FSplkytpv8ByDDFHgEMZ3fn2V1vSNfUk78wLGs3rSi69e46KVK6MwYAYTXcW5deMit1SPeQpV8jEgOjr0knFXUQyer0HT/JgpquPSji+V6aoTMFJXirE/ykcu6AUU6HM+7FsBxmz9aSGUntU0A2f8+yHA5uEJUFq/vLlyqzwsF2WduZZTC1qGNbiHSU0d+Q5i0BwDv40BiV7KzYx51xly4Mjkz5mfwmxcqkoWPcilCua6PtXKYCi0lMtBIK9l/FJQuL3yAoqfMQs8XY73TQnx93w0Hh/EoARGv6bd4+XckIPuWshCcE+tytYitNzjs5zlLpH3Ymf2taAFIKoQN2s6kxSFMt2l546oFIgRKIEzydwbcRJUIcxWmINUW3SsuEyGiQYti99eAEshWWgSoSf39s06N5zV9Evd9Zr19JnttKANvOFMIcEp0iiFTYs9qg6uVshhceMd9N2Qo0y62/4AFxNJZ0GW61f+d0BwIXjxHgI8D58zOgbIq2YJHwVvjatDOwLbqGEKAr9rfXktSE1m1BSqx8MB9QagDywW8AUJEe5wBTLIprYogE1U2/ID6W7qFl0BmPu6BWoqqlYLx1Br0KHoPnReXGLZYLQ/uJ21wMZuyRdxIAeKGVgGOfF4T/6UXEiUzoMnV6HQYsnJZRPCVI5IkQetYIikWowWBayoS/tmv6O1csYjtdsrFRoLXu4BQ6VF6yo7KOLWVJ3qinH45cuPc0SMmpNaKVAt/WeZUSUAeiLmP+hF8RsYObLqX+rQY1NS1RtB02QrRo5OLg5pTUFtnTZDRCvnuDJ4p/Y57p5iaCH0qdnWNdCNRWjqjyC1V8rPDMirEe7q1nS28xB/g3IvEt4UjovMoQdPrSqOceN8rLxjknAQ60MZn+zUJjwKkR2b59l/BlzURx7rlR+KFwFQrzTdLjIvJuxp2cMAtlV3pJ6rPS+032eogd1Gion+2/9CHzOxmWCfsF5Y+l0NmdTQa6pRJn2ri3GSdKgAcH2MRn5NFJoJtgdm/5iuVqr9I2lX3w4dudM8rPjPf2X7DAK0z5eHOZJ1O+VznVX5n9nrHYrIvmULcLWBx098SVVBKy/9Rah5kQW0oJay9po9ZqjFb10k8RCNPGIi4Y9Btuhd1Cm+P7umjVWzQo5Du5rwDydUNO1T0q2ycq2PIgxV3mtUHxODja65P0LHZoI4EQbfsBB0moQ+L2X35Oxqioi8r7f9LmD1nl7yJ5slgSKwJZ7pZoXGJYQXyxTkU+8LL9KBq3Z2CxHmOMJyPTajY9r4GZV29PDXxzzsY720FER7Ddt3LI/i8T9CIajWmQdTJl4A== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:07.5961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b668ce6-62d6-42ef-7f42-08dc8bca4756 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002323.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8194 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Rename, and modify the signatures of nvkm_device_{pci,tegra}_new() to be consistent with pci/platform driver probe() functions. The DRM driver is still calling the functions as it did before, just via the new pci/platform driver structs in NVKM that will eventually be used for driver registration. Signed-off-by: Ben Skeggs --- .../gpu/drm/nouveau/include/nvkm/core/pci.h | 3 +- .../gpu/drm/nouveau/include/nvkm/core/tegra.h | 5 +-- drivers/gpu/drm/nouveau/nouveau_drm.c | 13 ++++--- drivers/gpu/drm/nouveau/nouveau_platform.c | 2 + drivers/gpu/drm/nouveau/nvkm/device/pci.c | 24 ++++++++++-- drivers/gpu/drm/nouveau/nvkm/device/tegra.c | 37 ++++++++++++------- 6 files changed, 55 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h index a1e9ee6da44e..b9e10dad6ee9 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h @@ -11,6 +11,5 @@ struct nvkm_device_pci { struct dev_pm_domain vga_pm_domain; }; -int nvkm_device_pci_new(struct pci_dev *, const char *cfg, const char *dbg, - struct nvkm_device **); +extern struct pci_driver nvkm_device_pci_driver; #endif diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h index 22f74fc88cd7..e641f387fa3e 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/tegra.h @@ -48,8 +48,5 @@ struct nvkm_device_tegra_func { bool require_vdd; }; -int nvkm_device_tegra_new(const struct nvkm_device_tegra_func *, - struct platform_device *, - const char *cfg, const char *dbg, - struct nvkm_device **); +extern struct platform_driver nvkm_device_tegra; #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 580849b78231..632635c16b88 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -801,10 +801,12 @@ static int nouveau_drm_probe(struct pci_dev *pdev, /* We need to check that the chipset is supported before booting * fbdev off the hardware, as there's no way to put it back. */ - ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug, &device); + ret = nvkm_device_pci_driver.probe(pdev, NULL); if (ret) return ret; + device = pci_get_drvdata(pdev); + /* Remove conflicting drivers (vesafb, efifb etc). */ ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver_pci); if (ret) @@ -849,13 +851,10 @@ static int nouveau_drm_probe(struct pci_dev *pdev, void nouveau_drm_device_remove(struct nouveau_drm *drm) { - struct nvkm_device *device = drm->nvkm; - drm_dev_unplug(drm->dev); nouveau_drm_device_fini(drm); nouveau_drm_device_del(drm); - nvkm_device_del(&device); } static void @@ -868,6 +867,8 @@ nouveau_drm_remove(struct pci_dev *pdev) pdev->pm_cap = drm->old_pm_cap; nouveau_drm_device_remove(drm); pci_disable_device(pdev); + + nvkm_device_pci_driver.remove(pdev); } static int @@ -1349,10 +1350,12 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, struct nouveau_drm *drm; int err; - err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug, pdevice); + err = nvkm_device_tegra.probe(pdev); if (err) return ERR_PTR(err); + *pdevice = platform_get_drvdata(pdev); + drm = nouveau_drm_device_new(&driver_platform, &pdev->dev, *pdevice); if (IS_ERR(drm)) { err = PTR_ERR(drm); diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c index 3194b110eff8..23beac1f96f1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c @@ -42,6 +42,8 @@ static void nouveau_platform_remove(struct platform_device *pdev) struct nouveau_drm *drm = platform_get_drvdata(pdev); nouveau_drm_device_remove(drm); + + nvkm_device_tegra.remove_new(pdev); } #if IS_ENABLED(CONFIG_OF) diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 16e059866168..be6433eab814 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1626,9 +1626,19 @@ nvkm_device_pci_func = { .cpu_coherent = !IS_ENABLED(CONFIG_ARM), }; -int -nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, - struct nvkm_device **pdevice) +#include "nouveau_drv.h" + +static void +nvkm_device_pci_remove(struct pci_dev *dev) +{ + struct drm_device *drm_dev = pci_get_drvdata(dev); + struct nvkm_device *device = nouveau_drm(drm_dev)->nvkm; + + nvkm_device_del(&device); +} + +static int +nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { const struct nvkm_device_quirk *quirk = NULL; const struct nvkm_device_pci_device *pcid; @@ -1705,7 +1715,7 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, return ret; } - *pdevice = &pdev->device; + pci_set_drvdata(pci_dev, &pdev->device); if (nvkm_runpm) { if (!nouveau_dsm_priv.optimus_detected) { @@ -1718,3 +1728,9 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, return 0; } + +struct pci_driver +nvkm_device_pci_driver = { + .probe = nvkm_device_pci_probe, + .remove = nvkm_device_pci_remove, +}; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c index 9c3673c74b19..f0c1258170f4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c @@ -233,12 +233,20 @@ nvkm_device_tegra_func = { .cpu_coherent = false, }; -int -nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, - struct platform_device *pdev, - const char *cfg, const char *dbg, - struct nvkm_device **pdevice) +#include "nouveau_drv.h" + +static void +nvkm_device_tegra_remove(struct platform_device *pdev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)platform_get_drvdata(pdev))->nvkm; + + nvkm_device_del(&device); +} + +static int +nvkm_device_tegra_probe(struct platform_device *pdev) { + const struct nvkm_device_tegra_func *func = of_device_get_match_data(&pdev->dev); struct nvkm_device_tegra *tdev; struct nvkm_device *device; unsigned long rate; @@ -318,7 +326,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, return ret; } - *pdevice = &tdev->device; + platform_set_drvdata(pdev, &tdev->device); return 0; remove: @@ -327,13 +335,14 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, kfree(tdev); return ret; } + +struct platform_driver +nvkm_device_tegra = { + .probe = nvkm_device_tegra_probe, + .remove_new = nvkm_device_tegra_remove, +}; #else -int -nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, - struct platform_device *pdev, - const char *cfg, const char *dbg, - struct nvkm_device **pdevice) -{ - return -ENOSYS; -} +struct platform_driver +nvkm_device_tegra = { +}; #endif From patchwork Thu Jun 13 17:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697154 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 72691C2BA16 for ; Thu, 13 Jun 2024 17:00:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B0F210EB22; Thu, 13 Jun 2024 17:00:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="amdXAAgV"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id B23A510EB06; Thu, 13 Jun 2024 17:00:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foPjeOhiPvTcic8Jw1IX8FJk1Bca2S0VJg/xdZAUMGXb81aBhOEEgV0sjXlF6kmieI3WymUo9dSnbwpx6bFkxHariSUq5alX9k0ir35InrEXaCoIFgyWcYYEMSdH6NGX9Y61AG/k1jBuFBnEKx7l0YqU38GgHODYKqXZ0+8Q0by99B39gB9TlbA944JqHSk8dSsly0ok1U723uKXCoQj6V4pxBwrKSMIbEG2NsHzJNNISAsAM3tWaHWCbCStvDlEfCGLdHop8ACuwOgJL1oC1BrQnQe1nuZfZLiPZ/Kng3XDrgZRmuZnFr/lhC5gK52whkGNRJNiTsT6LMW7gEsBfQ== 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=aZR4dcqhN9w5AabxzoD29gQeV+VNaORpylxFAAmPQno=; b=k4B+LbM2L19pUyklrcSvWozV8/+0L9rEExWCts7VhBzpIvdweBYbaHjogvsgOLOEcGil8IfDLhbZLoISXsjMnNBzdhpV9gaSGMxDKCCeaBl1Cy5NGS54IjtiUG5SYygPFR/QvU8GTmCn3Z78nc6vEEsDC2FLBLasMVGTUDb4Ab7QnyJD0rl3R/cnGPiUf6gxiaWb1TbaiIxYo3MpGyKXwS3f1iurMg41oQ/H9MIMr9jNoqaH2MeHzyGGqHWvDDebpWLKr/MOOp/zKYA8TC2MMqgSeu60pi8m3j2EJJjGI+TwcYNcyXnX3ukB5PSqrT1Dn6VbD8ngN8KAVtgPMdTvEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aZR4dcqhN9w5AabxzoD29gQeV+VNaORpylxFAAmPQno=; b=amdXAAgVcEYgrQnkk0yL/TU5mZNKTn/68A8h7qwZa6qaNPJgEhMzRL1cA2PI03CLQvltBVEOQyvn8IpoJw8FmJV0vLPG7BlmyOTdAI6f/oxRk5ro7cOEstf0bsqrfdjck+ZCUV42vmBTJvnMPCXpryDjaIvA1IhkI3lDNeUULTk4qxktAzFwKSEpZmkGIfsdDPR2dmmgsgWgr+MhdsydveaMAQm6AKzIabh4L5ISfPSjb/bdoBfZoVWlj+J3JUawK97LaxAdWPNUgODQIqxNc7Oy4iAePai1XzAKn5Bc6wthRMGBBvCDsie+7ngRBtX7iq7RMX5/Y6VTv9qsYVcC+w== Received: from SN4PR0501CA0059.namprd05.prod.outlook.com (2603:10b6:803:41::36) by LV8PR12MB9333.namprd12.prod.outlook.com (2603:10b6:408:1fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 17:00:10 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:803:41:cafe::6f) by SN4PR0501CA0059.outlook.office365.com (2603:10b6:803:41::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Thu, 13 Jun 2024 17:00:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:09 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:56 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:54 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 13/21] drm/nouveau/nvkm: move pci probe() defer from drm Date: Fri, 14 Jun 2024 03:00:05 +1000 Message-ID: <20240613170046.88687-14-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F61:EE_|LV8PR12MB9333:EE_ X-MS-Office365-Filtering-Correlation-Id: df40ad2f-4da9-47e8-65b8-08dc8bca48a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: hfeWz2oquwkdPXApF5tbrDkmj5U+UuzMWRkz2bpmhBfiAyxQu/T0N1DRLeL7yhPXiUxrxhW+7LkpD9HgcHfbje9V+7GXnlwMP1+4rT7/8LkFlxOpeZprRvGjgrcFAzPjcUprxZsXXOFc25atxR6OWnpapmtAEnz3UqmK5PPgM083cvC9t8vLovj9e48DAKGFLgMb+orDM9fXbJuoe+6NBYtLXlVWA+2R8o/p7KnUV45HgxLRU3qYBARDD4NnED8pGe2cNvY9gU0IMNejg5ea92kD6hkDGsiDpfh5PrI39s7a0aD1/512yH5ty2nF+z+VQQPjL8iyI5cmOnItOQRM3tPPaMRKQJd9k3ekmWx1ZtDtgC+pTaIfP8c6FD3l9JoFrF0hXxj35k0VRzYDglrqpQWJOnTyX0jaPb7JS67xKyUvbiVfe/eE7TjYLTM0MJBEpk5+nUsqpTWtp1vnWt43NSTCegTqJFQH1KFLPNK8xotwqtAKqODaaKLKnRcEyivxXmQhym0z4lzO/7qOgfqPkTd5cIXRbT4sBbE9cA1Ue4XX1Q6L6T5fmIWwjClww7LLVSpyCLIXrF/d9Zbx0Nrtshgl78JtchsFOpfV8sx6ujLvwAUj6jN/t7OtVihZhnktmiNYGq9Eq+gE9aNJEeimvlgY094que/dq9UXQD+ceqJQTSwER3W0CJKIs1OJMgXeUmpdZPQwAAJWoSxQb5RaBbffs2c8M65297RB148ZRp5q6Zpo0OssyL3D8e9bS4HkP+hZ8A3nHKnVLefnyZy+Gc8a1efH9gnCR+kfBe+7db+Yjn3S2FSUVmyWGTPvK7KJ2Gwh6p48B4/WxFoo7OZz+ktUY6PbTxxfKaqKcZPzuf9bHo1wxNHAR3wulUWgGNueyHfzHz6T4vjXTr2nNIMuSHY4G62nv1bRxLAYfzJsp4eE5fdD98n4ZKqOqzH6wJACVfy7B/oONzoBFlJi5rhyvPuMAi7+2zE3JsQOfm8XurQ5izxIEe+YJz8LtHMWUQxjOvI30hgGMVIMtNul/l5SyZtomHt8blRChtfP6Ph1u1dcrje09JkveNZZymXwdmSIAQpkSJUF1WQ5U6Sa0wV7dXC7M8EZDt+B6ff0+d6bqgUmedk1mUzr4eIwKyaNi2nqCl+vRHPsqaAkl49AvntyI4z1hpSwr0YRUI0orvkPTkTMxJlmPSrbyuHJ7coRBAY736t+N/F7rwXAN4hyV6X8SE7eq5+5B6R1kmj92d/K3DnybyHYiM8D9+rI71ANg8ADsKvSADAZgp1+cXgDCWCCYBRh9FuSfduQtrt6GS6FTomq9d+T6TYu12fUCUJ6pmPJlDZoxNJB+XVpCOCei0TAglFRCsfRGVNwmRA+cK4gA1nx98y/js/D8fSLkzSMQGTrg7F6+1CJn3Fv2HbyVZRLxA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:09.7077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df40ad2f-4da9-47e8-65b8-08dc8bca48a9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9333 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 --- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 632635c16b88..3f1f93fa7029 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -795,9 +795,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev, struct nouveau_drm *drm; int ret; - if (vga_switcheroo_client_probe_defer(pdev)) - return -EPROBE_DEFER; - /* We need to check that the chipset is supported before booting * fbdev off the hardware, as there's no way to put it back. */ diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index be6433eab814..21ca094df54f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -26,6 +26,8 @@ #include "acpi.h" #include "priv.h" +#include + struct nvkm_device_pci_device { u16 device; const char *name; @@ -1648,6 +1650,9 @@ nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) struct nvkm_device *device; int ret, bits; + if (vga_switcheroo_client_probe_defer(pci_dev)) + return -EPROBE_DEFER; + switch (pci_dev->vendor) { case 0x10de: pcid = nvkm_device_pci_10de; break; default: From patchwork Thu Jun 13 17:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697151 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 35AC8C27C75 for ; Thu, 13 Jun 2024 17:00:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD35410EB18; Thu, 13 Jun 2024 17:00:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="UR0F9W0o"; dkim-atps=neutral Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2078.outbound.protection.outlook.com [40.107.96.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC80010EB15; Thu, 13 Jun 2024 17:00:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hM4eeNfhnCKMgmhwIEYsmiQfvOOLCxQycsyn1MJBvdOOHVL11mpp6iFXHqgFfFioFvUxU8jkriTjmyjTyXYkhE2xxH3FopB3lIKuwIad6LvPSowNweV0ds7PJnBFY3QTLUH7r+xY+dUNZQRYWGw3BKiRuPoMH3l8Fs7oZ0z/1sBum84IWC410m6WYL3wNeKv1+zZ2u+5hpan2Wm0zxw7hvg+bhEaA7fpwi3AOXzciEjFfGSneqht0+VhOWA27VL8UZ+/n22GY8UbrbESRNZw3yMMIh+HRfEjPJ+V5JnmycCscl4daG7HGe6+pfnExcbmpBAOC4od4QVVbY/fOOZLzQ== 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=lmDccZCuC/5lF1ALCsrgbJw7LLbXB5yypJhylkZDwag=; b=lMc7lxNn6gdIrE6Z70cS5CbAvshEOBuAkAP+sCFMPySnzqH6nos0XqqHnmdCHm7x2rUbeZah/GyVWHY7ZVLrIPlwjJGxv/s9DTc8fTh0nlmC6anRDzWgYz25Qk3nr8IR5WsYNDgbtxqiYYxT3iZxbViiHqXS9ZFcOGLJvKtZQqA8ltN+1wqX/dnTzB4ZZjahwrHd43jkotlIVspX8rmi625TU/oS914Yf1aB3/z3lf3Az85CK1VvjSJv6wDQjV6pyDwcZWzJ4NvR1sUKI7OqPNchqdmaasO9ms7mh7Iqnofcw0UWy5EElW9Kc7m5r70Vwrjl0kqrDpJ96O4kxN++zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lmDccZCuC/5lF1ALCsrgbJw7LLbXB5yypJhylkZDwag=; b=UR0F9W0oJ/fcIvclWpam7d4aYiyuFXh7jqtTHp1U8ppku60f0myzzBgKG6bjv7w8v3S8TgLPe+qKhkE1G1sN5PTRxD1pMu5nAfQq3PT/UUzO5eaVtW9iLMwhrKL9aSnO4Oi++nRh+OFB4onR+3pOw7xf0ax2S4muMBpWRdXfpBtTCyl0RkUEgW4N+aZGkPhh8EBy/RguEjAedBVSDHG5j9Y06CzWiAJZeGMQGCmlhVClI3d9Y1EOnceZWwILSTC/wal+sA4P+h+886u9hjP6gOg3KTbWfLvXCvSPmiHbEsBp5jc7uFk9hOCihbRFusEZ2aBdbYwaol5lqZlSdLV11w== Received: from BY5PR17CA0025.namprd17.prod.outlook.com (2603:10b6:a03:1b8::38) by CH3PR12MB9250.namprd12.prod.outlook.com (2603:10b6:610:1ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21; Thu, 13 Jun 2024 17:00:08 +0000 Received: from SJ1PEPF00002320.namprd03.prod.outlook.com (2603:10b6:a03:1b8:cafe::22) by BY5PR17CA0025.outlook.office365.com (2603:10b6:a03:1b8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 17:00:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002320.mail.protection.outlook.com (10.167.242.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:57 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:56 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 14/21] drm/nouveau/nvkm: move pci probe() fb handoff from drm Date: Fri, 14 Jun 2024 03:00:06 +1000 Message-ID: <20240613170046.88687-15-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002320:EE_|CH3PR12MB9250:EE_ X-MS-Office365-Filtering-Correlation-Id: 054ce8df-11bd-4851-bdea-08dc8bca47c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: 67HJ7qHr4S5cmIo+T/PnIRqQhQsXh983c9NJ/+2NdPaFbd79+YKhL7qwC0paDXGkp6+vXMa+bioZKadYjVyGT1gMWmec12dyv80eEr0mTkv2QTgDFih5slND3ywxxz7fuIXi0/L4391MxoE7GAiE4J6eVfGWeMirAgc5t0urXMr3RhuT3DqBF38Xsbw3IRBmy4DXSqYQDz6TaJ4XvOoY6gTP5w9vJYIYNgs3JF21iFto7jFiDez5deIaEbWTHc9UnMvzeD6tOrfTM4d8TG3yv3yGX6x0ZSOY0EykpNfiGRPcKGLKodzivMqX11zwVGjdiFqNOaEYfmoVBto0c5dEA5HukFG7cJNd4IiIvVqGsYIHNt7tzj115eHf0ZWVc1FK34F0rzFDeTE0tdI5VVwi6MbtV/hnTVm064gahx5JHXt58axI/o4lJPt0bS7+2jJ7E6wUj+sR2euGaseJ4J13/dmuzMuYsczy8fYXoiePi1Xy/9yn0BB+MGg/VRpPxl3f3WCoF0k4Gwaq8chUdVXz/Qlbqv0RNRNgKeQ4onQYrISgOsp5+03kqgL28nTUC6YLqSh6EErJ0tMtPKsc9OGgsUBemaA6UMBi+73jEv5Fjx+tYFaakmXC93M/cxS3pOaayyPfUdWZsrecfRXvS5USLLlWU8VwoEp0fpsPJEmkZlj2FoM0F0jqdNbRu0p/Iq2d1SzaYnXy6O8RsznhymXlHuQB/O6GVf7bJ4pnkrhhCfExoTWOSZOcgfoKuWsBNN/LmRZfACBhCMyX5+3WrPgG7Gk0qoRJ5dkEXQRvgCwxzxI7dnQNTNiu8Ns4NvUW5bz3djrJwXfbcYC5jvDcpdYa8v97YI+bvSDR21BlgBAe1u2ntSbYSQRundMo3tOfvPfF6Ot9eS9t2Ij2rCqOeEU6kQeDgnS7We/GIeC5neSOuuGXaHF8FkIkffP5ebN8+3B6xzBTfflIZFxzK4b3vnN3+t+2mQlU+JWHKNYoZHZio9uFFvSAqnOvxvKCTsqkCqBn5//IKtoba2DUSqUmtAYzBIUr5E8NIt9ncyQwQGl1daRqreQg8b/HCLUwzLCTP/Qkg6VssD0/HiPxxnimehalqbU3+7GAfH6vRn7jwz6sJkN9A0WnaVNmWCQO+uU3Swqog9mlTULvpZKYRVdd2G36y2xM8cWZRyzovctThZMwvjY7B3FGIURRkOk1HiL15BmSI6tptNwGyd6EEILTnQ76awTFxEYYq/D8ABvi9LiVDwQ1V5vO6k4bQlLUV/RMtcLcqU1GunTRd+Ln06c4grn8vq6s3IbwW3MrqBdNbuXOKkd6TutxrgPG4N3bMv8pwsjX6am9PmthA5UzCdm11h8IdlqASbMVVl3emsVO7Ht8ny7LiKd+jWGfoKAjxbE8N6A9uKHD/HJiwE20yXrPxzWzRQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:08.3473 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 054ce8df-11bd-4851-bdea-08dc8bca47c6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002320.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9250 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/include/nvkm/core/device.h | 1 + drivers/gpu/drm/nouveau/nouveau_drm.c | 5 ----- drivers/gpu/drm/nouveau/nvkm/device/base.c | 6 ++++++ drivers/gpu/drm/nouveau/nvkm/device/pci.c | 11 +++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index 3c11d3068ced..d8596fe0adea 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -89,6 +89,7 @@ struct nvkm_device_func { struct nvkm_device_tegra *(*tegra)(struct nvkm_device *); void *(*dtor)(struct nvkm_device *); int (*preinit)(struct nvkm_device *); + int (*oneinit)(struct nvkm_device *); int (*init)(struct nvkm_device *); void (*fini)(struct nvkm_device *, bool suspend); int (*irq)(struct nvkm_device *); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 3f1f93fa7029..be31e8ea4fee 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -804,11 +804,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev, device = pci_get_drvdata(pdev); - /* Remove conflicting drivers (vesafb, efifb etc). */ - ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver_pci); - if (ret) - return ret; - pci_set_master(pdev); if (nouveau_atomic) diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c index 1b76c2a60799..4f8298bf71ee 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c @@ -2954,6 +2954,12 @@ nvkm_device_oneinit(struct nvkm_device *device) #undef NVKM_LAYOUT_INST #undef NVKM_LAYOUT_ONCE + if (device->func->oneinit) { + ret = device->func->oneinit(device); + if (ret) + goto done; + } + ret = nvkm_intr_install(device); done: if (ret) { diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 21ca094df54f..7d0ddc968246 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -26,6 +26,7 @@ #include "acpi.h" #include "priv.h" +#include #include struct nvkm_device_pci_device { @@ -1608,6 +1609,15 @@ nvkm_device_pci_preinit(struct nvkm_device *device) return 0; } +static int +nvkm_device_pci_oneinit(struct nvkm_device *device) +{ + struct nvkm_device_pci *pdev = nvkm_device_pci(device); + + /* Remove conflicting drivers (vesafb, efifb etc). */ + return aperture_remove_conflicting_pci_devices(pdev->pdev, "nvkm"); +} + static void * nvkm_device_pci_dtor(struct nvkm_device *device) { @@ -1621,6 +1631,7 @@ nvkm_device_pci_func = { .pci = nvkm_device_pci, .dtor = nvkm_device_pci_dtor, .preinit = nvkm_device_pci_preinit, + .oneinit = nvkm_device_pci_oneinit, .fini = nvkm_device_pci_fini, .irq = nvkm_device_pci_irq, .resource_addr = nvkm_device_pci_resource_addr, From patchwork Thu Jun 13 17:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697161 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C27EAC27C4F for ; Thu, 13 Jun 2024 17:01:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C28FC10EB31; Thu, 13 Jun 2024 17:01:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="F8G6kbPY"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DB0810EB1A; Thu, 13 Jun 2024 17:00:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azbszUqifooAcR/Dzn0Xs7a88WjZBfN5EgdrZHnfzfQCF9tHU/TSI005p3/WMlxUKfMLpeG8ZjqpmH8HqegctFRGAAni/Q1eNz+O6QSckwi7rQmFm0cxgGkpkXuQQqId8gPFgqCw24rbN1T8gcdw8i5VAXuFIct/FFyok1HH4GnDTVJn7eUMaz6yGwhN6wyl1WApmm5uQ0l8YvnQJtI4zW9n6aN26kT9HVnaj0z1z3dUj/P05pFn7DtD7rX/i59U49ZBzGSZCMG1xtBlz3JwTwq32N9vjkz8kMCCflfQTbXbD8/ZNFeEGWWSBTiJXf2f1GfB4jE/0RlegeDbJJ9Thg== 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=sxs56OHAtYKzW75XmP6d5140RXeRJTnKfiLbOZ6opJA=; b=XVl7VGCeLaQhLHxhsdIt1SR+p1wsJ3XVC6VJHlJlFH4lo/qr6DWUBLpePdINueCcgcY6a4yt73cgOFG5yU4xVmLYmBYruI8LWIMujBJiJm5sZCHzp1sN+XPSa43eC2D28Xhbxnptr/N6eEv4XZJbpAeD/mV5FxPZDGwJnR9uNlfGlWSO2vxNHofbeZNEOwz9awRvA3hVRJ8TOfvXQz6rFhx28bo2e5kQ9ujVETM0UYdG1jFwmGjHRRjdc7ufeTZL/f0OBZPOvjWYfYXSm76V7hlJ35keUHP+ZaRGN9voFIllxB3GoB5ud/a0TIlxkrrIbnNpsGmkxeAc7w+zwn8v8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sxs56OHAtYKzW75XmP6d5140RXeRJTnKfiLbOZ6opJA=; b=F8G6kbPYclslddziDtz0XBl3JQbGzKhOoY/YxpSp3atO7AjtfxNj4THriw/FwFV1kTHCRvj325+wnIPuvJ12jVmZOSaONOpf7OshdEEEaUb7ChDmCJIhRB40rc5JLcv5+sN97kUKWI8aV8VWvWTn/xwZa132VX7Dz5ZcANWGDKyvfLFe2kYtPU8gA9taZrX+uLKFEScc3SkP8/VtFrDZQIqlN2HnF6WWXQ51vPeXxhmyPOchcmnE/9XkyA8WQdqc30aAvpHOwMx+riKBLsu0GL+tC3vSwOEMwoMC86c5orXMh8QrCP09E25Kt3Ee5j2BeN9ZXxzSE9dZomWmFQtPuw== Received: from BYAPR05CA0057.namprd05.prod.outlook.com (2603:10b6:a03:74::34) by PH8PR12MB6961.namprd12.prod.outlook.com (2603:10b6:510:1bc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 17:00:10 +0000 Received: from SJ1PEPF00002326.namprd03.prod.outlook.com (2603:10b6:a03:74:cafe::9a) by BYAPR05CA0057.outlook.office365.com (2603:10b6:a03:74::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Thu, 13 Jun 2024 17:00:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002326.mail.protection.outlook.com (10.167.242.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:09 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:59 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:57 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 15/21] drm/nouveau/nvkm: move pci probe() enable/disable handling from drm Date: Fri, 14 Jun 2024 03:00:07 +1000 Message-ID: <20240613170046.88687-16-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002326:EE_|PH8PR12MB6961:EE_ X-MS-Office365-Filtering-Correlation-Id: 814a15ca-2790-440e-1aeb-08dc8bca48a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: 1G19HoSyq3GMqtZum88PXT/d8CXUNEiT3cmZb5kxz8PtB2ao541uqmqhIq6TLX3CYyvm9dIaAewKh8VCgRZITockUi0lWoQ8Xr9eMl/DAfwQWaP7HLAonXaFjhSXVlxM0EjRx2kOPsuTTsrtXMiAZhbG1frQw8Mdt3zTOefJF7HqHViq26FNA7DtBjsgrFaIDIep0weZxk7YaG0Ld7BQJVgVztg42OydYI5Hb+qJ6MuGYksaIQ8TGIC6862MRkQ8W5QAc63PgVI5GXGF18u7SPVfjtCnvx0YUoC7mAjzI9LtV+wVikUC9YbMVyyXLUNdPpeAv5jbn0/M5/Fs/cg+zWW2uCUZ/tWkk6fE9yaPFwN6KVdnPsWaUgghCwG2Z4nF4Er9hXp2Ccd8Te+BzlhYAEEvTlNqjTgAlCYqVie/7mpfD0OLuqPYlp6R3uVd+BLrQqe1H75brKS0JXDQ9w33ClwYGp0jKiEZg2jasMlK/3+mAYIyTOcRZRpqI1KJSjQeFAXtd9/JgZ1kiCDMKjkfFICcAS/NIZ1iGPoj2EdQJMqnx1uNq7ZAhrshO8d4l78fU1dlLpQOMNTdSxintt6iyPiCpwVjQO7WY8k4xcu1aDKY0XsXPHZeI5uBcTNT4O47O9Cx8RvXzfq/IuYRnzTYBqRu74iQSlEKDKaQ6xDZndTo270sXAh7q7neVmjtTw9mKeJYxc2pSzDj3AeQEtY1Tp49QOVTfabXguQcfmal9engrtRNTo6pjGhrwJ2jCSzoHZbRGKzv02k7wz3pKPd9WTRcaYkuYKZEKrH+Kdmg28ZnnaEI9zVp+ph5bUJM+YF2EosPkgvObqHGTVUpgs1WATcaKkLwMtQgMi69EJgGp0HG2nd+nmyByWA8iqCoucjwHNDand/WpCnJrANJGmpj+kaPFV6ZzM07oBn+1WcgoWSOa+9sXPVFOYdCbJIUB6xZj3jbiRnTYhMNJPG8k721AOexuCNQvcpShKEDGFTOSdWvYFzsRBTGBgCYL1To1YmXbagf/lx3d/lKOeSA6i3o1JaRr4Ok7yRsBfEavRPWp7kuRcxjibC4xXwbDQDwu736AdGh6eJeewfhAs97gQ/MB4z61XoZUgsvtZMNc66icrQAsPzbbMSNGuYhcuMYWX/rLGlIYLnB4S+VejcwfWzp9vxRaV//l+QhTiuWMZozdjeW+UefqZJyO0tMEVUo22+HVndYL2xPdXCQx2M2TuAEfnL6lUMzHSiceWoB+++VXrBHmX5X4WbK/hrB4n2TSLATV+ZC4JXg1Me+iiWRoIbH31fI1oFzI5VF4JU70CwnDYKbV1hBGT/7QrwAyIm8FgQBV160Ez6BzNXn8/OHsCVUg7tbRY6BR+G5QaM6oyBGVcyCcvn8pNEe28/t870Q3L1CmBLR2avNM+H+46RGzyG7Ng== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:09.8020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 814a15ca-2790-440e-1aeb-08dc8bca48a7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002326.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6961 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- .../gpu/drm/nouveau/include/nvkm/core/pci.h | 1 - drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +------- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 28 ++----------------- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h index b9e10dad6ee9..0797225ab038 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h @@ -6,7 +6,6 @@ struct nvkm_device_pci { struct nvkm_device device; struct pci_dev *pdev; - bool suspend; struct dev_pm_domain vga_pm_domain; }; diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index be31e8ea4fee..4bcfc2291c4d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -804,8 +804,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev, device = pci_get_drvdata(pdev); - pci_set_master(pdev); - if (nouveau_atomic) driver_pci.driver_features |= DRIVER_ATOMIC; @@ -815,13 +813,9 @@ static int nouveau_drm_probe(struct pci_dev *pdev, goto fail_nvkm; } - ret = pci_enable_device(pdev); - if (ret) - goto fail_drm; - ret = nouveau_drm_device_init(drm); if (ret) - goto fail_pci; + goto fail_drm; if (drm->device.impl->ram_size <= 32 * 1024 * 1024) drm_fbdev_ttm_setup(drm->dev, 8); @@ -831,8 +825,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev, quirk_broken_nv_runpm(pdev); return 0; -fail_pci: - pci_disable_device(pdev); fail_drm: nouveau_drm_device_del(drm); fail_nvkm: @@ -858,7 +850,6 @@ nouveau_drm_remove(struct pci_dev *pdev) if (drm->old_pm_cap) pdev->pm_cap = drm->old_pm_cap; nouveau_drm_device_remove(drm); - pci_disable_device(pdev); nvkm_device_pci_driver.remove(pdev); } diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 7d0ddc968246..d9b8e3bc4169 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1585,30 +1585,6 @@ nvkm_device_pci_irq(struct nvkm_device *device) return nvkm_device_pci(device)->pdev->irq; } -static void -nvkm_device_pci_fini(struct nvkm_device *device, bool suspend) -{ - struct nvkm_device_pci *pdev = nvkm_device_pci(device); - if (suspend) { - pci_disable_device(pdev->pdev); - pdev->suspend = true; - } -} - -static int -nvkm_device_pci_preinit(struct nvkm_device *device) -{ - struct nvkm_device_pci *pdev = nvkm_device_pci(device); - if (pdev->suspend) { - int ret = pci_enable_device(pdev->pdev); - if (ret) - return ret; - pci_set_master(pdev->pdev); - pdev->suspend = false; - } - return 0; -} - static int nvkm_device_pci_oneinit(struct nvkm_device *device) { @@ -1630,9 +1606,7 @@ static const struct nvkm_device_func nvkm_device_pci_func = { .pci = nvkm_device_pci, .dtor = nvkm_device_pci_dtor, - .preinit = nvkm_device_pci_preinit, .oneinit = nvkm_device_pci_oneinit, - .fini = nvkm_device_pci_fini, .irq = nvkm_device_pci_irq, .resource_addr = nvkm_device_pci_resource_addr, .resource_size = nvkm_device_pci_resource_size, @@ -1700,6 +1674,8 @@ nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) return ret; } + pci_set_master(pci_dev); + ret = nvkm_device_ctor(&nvkm_device_pci_func, quirk, &pci_dev->dev, pci_is_pcie(pci_dev) ? NVKM_DEVICE_PCIE : pci_find_capability(pci_dev, PCI_CAP_ID_AGP) ? From patchwork Thu Jun 13 17:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697158 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D04B4C27C6E for ; Thu, 13 Jun 2024 17:01:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1234A10EB2D; Thu, 13 Jun 2024 17:01:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="XdBPFMZu"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3B8B10EB1A; Thu, 13 Jun 2024 17:00:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hP9FuqcoHPWngXyQjpVNn5QRzsEBK43ckaQ8vS0fcupqbo4ovo5VCfTJavinc4adjQjQ7C9PHrQ5OPNa9pPCZLcIpTGtAeXZmYd4Vtwo2iyqsozp8qI6Zcxm5A74NY9Pp1igqumPhPsbhlqtl/x1mr1FL6vt2Y9BeJ/dpbqHjUSTD9z0edKt3ndOOgnggbzExwt0V1lhMziuDat71VEL9g/nzM7Wd6xate9oeilEARRpkSwwk8/Wo+krjl4fyA8ItRDz/ZA1clGfQ7L0CluHYxPCXhgBYJ66ya2tM03gVEnORtvATfCMs7DL/2E782S3LGy/qyZ97LA/CKZ+ve1m6Q== 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=AV1vuEFMovDfxPLy3ODtP2O9GA0nTTNiggIUDi0TUCI=; b=imnKXpc2zpk/DbSUcdjeN6EEVKPRq1YIxl/x56ZReJqGAoYdJEj9N9Q20GAh/JPVYfdERbz5OFtYPLWlWFCdzehwQMXlB8tVY481J/iS8N5keVC8UBVVloONQn1CNzb4Y5ykZ1TA8gBo1qI00rh0jiAnmjQWr/8kGT6AD3BR4FShxTLtSo0GPggfDXvInBvI/DFr9BkyfmKNwCmPLx4xqm7om0B0jxwisN7r1SkFvyLZxmYRZMmH7/EeBrlxX2Rs180QoiKc+lJ87NvWNPM2wFNEv0CeIZz6hZ1iitgV3N87CiUJw+co/3NZH31HoChyet6zJ0JcLaR8afaTcyNtCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AV1vuEFMovDfxPLy3ODtP2O9GA0nTTNiggIUDi0TUCI=; b=XdBPFMZuJr0OI650WOJFsGdgNEogA5BXhIN3nz42koOLd3X8B9UJ7+CVpfJckVgLbIZYiimeGyGXFmY6qXvSlJVbGl7NQ9pXkmr1bwjiUmdQhflhmKQTk+VvzJDVMv11kAtbn0LKe2BTSRYAizO4RtvgLR3DPY75Gv9ErX+FCqSNVGofoPYPLUQmIHT9W2yUdBGrm/UpKvVVseJsL+jyODcL4KSrFts6xV/TYizHpt9YcDGsOOgmhFVuQLh2vBvirTQt1+28mM+GZNZrAnxULoQCPU3uNehC+Cu7iGaRb0ZjlBSw5hCJxrUrPxP8IlSFp9NAxknCeKEgblfOzZiVaQ== Received: from SN4PR0501CA0066.namprd05.prod.outlook.com (2603:10b6:803:41::43) by DM4PR12MB6109.namprd12.prod.outlook.com (2603:10b6:8:ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 17:00:13 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:803:41:cafe::59) by SN4PR0501CA0066.outlook.office365.com (2603:10b6:803:41::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Thu, 13 Jun 2024 17:00:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:00 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 09:59:59 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 16/21] drm/nouveau/nvkm: move pci probe() runpm quirk from drm Date: Fri, 14 Jun 2024 03:00:08 +1000 Message-ID: <20240613170046.88687-17-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F61:EE_|DM4PR12MB6109:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eb20acc-d755-420c-c325-08dc8bca4acd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xsNTWv33IykfUq/r5bmL7vk5hkJllkg?= =?utf-8?q?D8zWOC1O9FzNyFPiCAmhTXeOR3A+CM5rfjT6OwG3fgJ91HAPeX6lCVQsbi85NM4/W?= =?utf-8?q?748d+rbWvVLnbLqh+bynhdggjV2nNDmz2nn+efPZvW7iJ7He9iwgx3X8u4wm05Gcx?= =?utf-8?q?+ToG+E+bVdVuYvgBnF+y0sPHOY6OJ/rdU1Aaw/uvB3x+5LPBortcTMIAP36w1Ak2N?= =?utf-8?q?WdbsCmYjyhoTw3JI/Loaon3F5OPXlJUOjtMxK6o7Q9l7ncltdBTgkCxtT3C2KO1VN?= =?utf-8?q?q+2d9OVZMLcVDu26VGR196X0V4NFY0JoPLC9fiMdnIB3NGdY/veCf6NfMBpe9mb75?= =?utf-8?q?nRc3dlNwBt7bUx/BaPTPVil2bq+ARwbYCDoCrxlnh3RaPPH/w/RKLzKfCAI5G+Qmx?= =?utf-8?q?nw06Vvy3IIAAGg001UJYtkWEeap5RMBni0qlv62hEKD3K486yKjfhayR4wWPpeWNk?= =?utf-8?q?mEM4WcNYqq4tPo/Uzbdz96GsqOokNjDccJO8kCH+xwy35J4MjntWewAGtyZftUoxI?= =?utf-8?q?zdMq+d0J0+tntDdiNJ9fbPk/5nuuya9r6OeVgFfHyhMocaDTO8Ggjogknk+kNiX4k?= =?utf-8?q?mKDfJv98bPl+82YPDoF1CRkKjJ+vPKofO6rv6obKXMMba1dUU3H5xT339KtODFBb5?= =?utf-8?q?/Ez1LR66i20RIjFWHXnJ3BDW9UKy8FupYHUTCxwptHWPVdZGz7b9+Dqfqrz16h4Ez?= =?utf-8?q?/oJUzKSEdQYg5pQUFLc0WN7sUYT5nOk/90Nne78soBzbPFQ+BI0h/kkRyXUa7eTD+?= =?utf-8?q?scVaWcEnkVP/J565oOwJdPAPi1zhcgQzYDonOfkkBDzAKXHDeRu1byFJqbhGsjsVj?= =?utf-8?q?F7BsRtpZuVfZeERYOy/2gEDKCpV6jdPB7eBhaisAy3KNDUboHm4DJJFfKrKqi6Kmn?= =?utf-8?q?YmG59bTeHtTyRBlYTJzQtYjOYJxBMw9vu+NHUBYsy3s49cQ0xrs/vGK9J2/zFh0TG?= =?utf-8?q?5c6MQWGsGa/WBJkObnNAqoLKiAztELVhH7v1rHBV7hMo/9MwZvCsgSJVEOTNxeu1H?= =?utf-8?q?8TJceLDVQtIMCd0FPocvDM1+pJFlC3/M3KlIKFeTxfqH4jZsd+NSWDMigSjnudQwT?= =?utf-8?q?7TdOnqIppbC+6Jx0YPJtoHDoIvK/cUff5o0Z/TSqhkmuMDhaDW2UOlIUSiidJJumr?= =?utf-8?q?6vZFg9LD2SjmTXM24M6/yYcnhw3yCz3EVrduXTNM4DcGF0aVrqbx3Ubh3911oMXiy?= =?utf-8?q?rb1cY/KBRld8OAzT7libE4iWM5sFONz7wsGjAZGTzono1lGpBBhVeDD7QVtQ4+Y1K?= =?utf-8?q?Yqct+0J/cNYk3KJyLE6fjRyCXyL7m0f44NRrTjROYXUXP+3ntCUlyT+pk9kbBuxHx?= =?utf-8?q?Mwkx81uDkz0w3J8MGN/J8l+D0GstMMw2Bw=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:13.3015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2eb20acc-d755-420c-c325-08dc8bca4acd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6109 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Ben Skeggs --- .../gpu/drm/nouveau/include/nvkm/core/pci.h | 2 + drivers/gpu/drm/nouveau/nouveau_drm.c | 61 ------------------ drivers/gpu/drm/nouveau/nouveau_drv.h | 2 - drivers/gpu/drm/nouveau/nvkm/device/pci.c | 62 +++++++++++++++++++ 4 files changed, 64 insertions(+), 63 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h index 0797225ab038..95deea8c65ff 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/pci.h @@ -7,6 +7,8 @@ struct nvkm_device_pci { struct nvkm_device device; struct pci_dev *pdev; + u8 old_pm_cap; + struct dev_pm_domain vga_pm_domain; }; diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 4bcfc2291c4d..76eddf172bb5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -731,63 +731,6 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren return ret ? ERR_PTR(ret) : drm; } -/* - * On some Intel PCIe bridge controllers doing a - * D0 -> D3hot -> D3cold -> D0 sequence causes Nvidia GPUs to not reappear. - * Skipping the intermediate D3hot step seems to make it work again. This is - * probably caused by not meeting the expectation the involved AML code has - * when the GPU is put into D3hot state before invoking it. - * - * This leads to various manifestations of this issue: - * - AML code execution to power on the GPU hits an infinite loop (as the - * code waits on device memory to change). - * - kernel crashes, as all PCI reads return -1, which most code isn't able - * to handle well enough. - * - * In all cases dmesg will contain at least one line like this: - * 'nouveau 0000:01:00.0: Refused to change power state, currently in D3' - * followed by a lot of nouveau timeouts. - * - * In the \_SB.PCI0.PEG0.PG00._OFF code deeper down writes bit 0x80 to the not - * documented PCI config space register 0x248 of the Intel PCIe bridge - * controller (0x1901) in order to change the state of the PCIe link between - * the PCIe port and the GPU. There are alternative code paths using other - * registers, which seem to work fine (executed pre Windows 8): - * - 0xbc bit 0x20 (publicly available documentation claims 'reserved') - * - 0xb0 bit 0x10 (link disable) - * Changing the conditions inside the firmware by poking into the relevant - * addresses does resolve the issue, but it seemed to be ACPI private memory - * and not any device accessible memory at all, so there is no portable way of - * changing the conditions. - * On a XPS 9560 that means bits [0,3] on \CPEX need to be cleared. - * - * The only systems where this behavior can be seen are hybrid graphics laptops - * with a secondary Nvidia Maxwell, Pascal or Turing GPU. It's unclear whether - * this issue only occurs in combination with listed Intel PCIe bridge - * controllers and the mentioned GPUs or other devices as well. - * - * documentation on the PCIe bridge controller can be found in the - * "7th Generation Intel® Processor Families for H Platforms Datasheet Volume 2" - * Section "12 PCI Express* Controller (x16) Registers" - */ - -static void quirk_broken_nv_runpm(struct pci_dev *pdev) -{ - struct nouveau_drm *drm = pci_get_drvdata(pdev); - struct pci_dev *bridge = pci_upstream_bridge(pdev); - - if (!bridge || bridge->vendor != PCI_VENDOR_ID_INTEL) - return; - - switch (bridge->device) { - case 0x1901: - drm->old_pm_cap = pdev->pm_cap; - pdev->pm_cap = 0; - NV_INFO(drm, "Disabling PCI power management to avoid bug\n"); - break; - } -} - static int nouveau_drm_probe(struct pci_dev *pdev, const struct pci_device_id *pent) { @@ -822,7 +765,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev, else drm_fbdev_ttm_setup(drm->dev, 32); - quirk_broken_nv_runpm(pdev); return 0; fail_drm: @@ -846,9 +788,6 @@ nouveau_drm_remove(struct pci_dev *pdev) { struct nouveau_drm *drm = pci_get_drvdata(pdev); - /* revert our workaround */ - if (drm->old_pm_cap) - pdev->pm_cap = drm->old_pm_cap; nouveau_drm_device_remove(drm); nvkm_device_pci_driver.remove(pdev); diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index b44f0d408ccc..9ca0f6ab4359 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -218,8 +218,6 @@ struct nouveau_drm { */ struct mutex clients_lock; - u8 old_pm_cap; - struct { struct agp_bridge_data *bridge; u32 base; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index d9b8e3bc4169..d454d56a7909 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1598,6 +1598,11 @@ static void * nvkm_device_pci_dtor(struct nvkm_device *device) { struct nvkm_device_pci *pdev = nvkm_device_pci(device); + + /* revert our workaround */ + if (pdev->old_pm_cap) + pdev->pdev->pm_cap = pdev->old_pm_cap; + pci_disable_device(pdev->pdev); return pdev; } @@ -1624,6 +1629,62 @@ nvkm_device_pci_remove(struct pci_dev *dev) nvkm_device_del(&device); } +/* + * On some Intel PCIe bridge controllers doing a + * D0 -> D3hot -> D3cold -> D0 sequence causes Nvidia GPUs to not reappear. + * Skipping the intermediate D3hot step seems to make it work again. This is + * probably caused by not meeting the expectation the involved AML code has + * when the GPU is put into D3hot state before invoking it. + * + * This leads to various manifestations of this issue: + * - AML code execution to power on the GPU hits an infinite loop (as the + * code waits on device memory to change). + * - kernel crashes, as all PCI reads return -1, which most code isn't able + * to handle well enough. + * + * In all cases dmesg will contain at least one line like this: + * 'nouveau 0000:01:00.0: Refused to change power state, currently in D3' + * followed by a lot of nouveau timeouts. + * + * In the \_SB.PCI0.PEG0.PG00._OFF code deeper down writes bit 0x80 to the not + * documented PCI config space register 0x248 of the Intel PCIe bridge + * controller (0x1901) in order to change the state of the PCIe link between + * the PCIe port and the GPU. There are alternative code paths using other + * registers, which seem to work fine (executed pre Windows 8): + * - 0xbc bit 0x20 (publicly available documentation claims 'reserved') + * - 0xb0 bit 0x10 (link disable) + * Changing the conditions inside the firmware by poking into the relevant + * addresses does resolve the issue, but it seemed to be ACPI private memory + * and not any device accessible memory at all, so there is no portable way of + * changing the conditions. + * On a XPS 9560 that means bits [0,3] on \CPEX need to be cleared. + * + * The only systems where this behavior can be seen are hybrid graphics laptops + * with a secondary Nvidia Maxwell, Pascal or Turing GPU. It's unclear whether + * this issue only occurs in combination with listed Intel PCIe bridge + * controllers and the mentioned GPUs or other devices as well. + * + * documentation on the PCIe bridge controller can be found in the + * "7th Generation Intel® Processor Families for H Platforms Datasheet Volume 2" + * Section "12 PCI Express* Controller (x16) Registers" + */ + +static void quirk_broken_nv_runpm(struct nvkm_device_pci *pdev) +{ + struct pci_dev *bridge = pci_upstream_bridge(pdev->pdev); + + if (!bridge || bridge->vendor != PCI_VENDOR_ID_INTEL) + return; + + switch (bridge->device) { + case 0x1901: + pdev->old_pm_cap = pdev->pdev->pm_cap; + pdev->pdev->pm_cap = 0; + nvdev_info(&pdev->device, "Disabling PCI power management to avoid bug\n"); + break; + } +} + static int nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { @@ -1701,6 +1762,7 @@ nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) pdev->device.mmu->dma_bits = 32; } + quirk_broken_nv_runpm(pdev); done: if (ret) { nvkm_device_del(&device); From patchwork Thu Jun 13 17:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697164 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E15FAC27C4F for ; Thu, 13 Jun 2024 17:01:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A83910EB2F; Thu, 13 Jun 2024 17:01:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="KR4lkfVW"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2053.outbound.protection.outlook.com [40.107.220.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62DB310EB22; Thu, 13 Jun 2024 17:00:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WFEneJCtYdW+O6LEUC2s7ijWawimK815ulZ0XcfxJoPEcRoecmqXhaQxOOIezAcPZLqIBqI96pVw+4NOwWROjtqhisZv+Hl+2MbFytpMU2MVTmuisdl+hh6L3ncVDpLqQJ84UJM9RUwgdy/42CHn/wG/fJZC4rR/q9FdZzo5SJl5TRh8UwAO1NhMrXQuIfMUwyeOz4I4ohw2Muf7i5Psz9KmMGg5MV5qizwLf8Eh41rkbjbQbmhtTkaNctM43l1SP9PrdA9udj1I7O7LTaZ9vU6WedfGsBVkQw/1bHv3SQq0tR8Ty72N7rvMtoZYNAWLe+Qn1UdE6jVu9GmZ8cD5pw== 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=75YrCojF5xB7KCzVHie7EonGAF5wXXnqVg0JOQb07rE=; b=UvldcpgUvjQ/cgkxgtbzsMMFZTLy5rkiwmOZhnG6pl284K+FSd+KWRHBBgw10HpaXynTnl+AlJZgmQ3ENtzpGZvGnZYXtHrPY/OCVurce4mFkbNpvtwFAz12bhrKx1bhNK9l00geAky51LvXyupcp5VEaGvsmO5kL4DKM7WDyOb7T5ZPdxX8oxD2d+XTUnIZ9LSyeSJ7/rFriwp11v83RKrL/1ebhxjTU3n7JDYFK2lSo+IUiYhRO4/YYR7LT7/Dv4ZNz/GiGduVqFd2OLxgxos7Z0Q1rDdAu2CcmGqtDgX0m1e4THe0MmwscaWPON6NFkHRJOzkPGzHAFfHh3j4HQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=75YrCojF5xB7KCzVHie7EonGAF5wXXnqVg0JOQb07rE=; b=KR4lkfVWS3DnjBuFWvryo2H7tCFIU/r7XVxeiqOYr6G5EZAy1ZzY+GPhZLH/9d5KPndXXv1sjejSOjlL8aUJNQs80KNpyMVe69n44mVNQ2pCQk7g44s0p16lfKRpYRSSim8MWsfNd/ISGG3VWrVNZ+Fj6kcyDA+LC9pf04r8usShXC7SnEXUmzfFOlkpj8YCkIkUayUhnKWxmGJ8Jz1d8iNx3mhlR32KuTJHzYuFbOeNwSy6nkALoKXKUyFMcn7bd7S5TeJh3P64MEKiS96moXvHVkLKCZ4RrjZhgn+ij+oyLoJ+my5K7+wmIX8geZCUMMWZEArNpH0WgJG6xPSvOg== Received: from SN7PR04CA0066.namprd04.prod.outlook.com (2603:10b6:806:121::11) by MW4PR12MB7238.namprd12.prod.outlook.com (2603:10b6:303:229::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 17:00:17 +0000 Received: from SA2PEPF00003F66.namprd04.prod.outlook.com (2603:10b6:806:121:cafe::1c) by SN7PR04CA0066.outlook.office365.com (2603:10b6:806:121::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F66.mail.protection.outlook.com (10.167.248.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:16 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:02 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:00 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 17/21] drm/nouveau/nvkm: move pci pm ops from drm Date: Fri, 14 Jun 2024 03:00:09 +1000 Message-ID: <20240613170046.88687-18-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F66:EE_|MW4PR12MB7238:EE_ X-MS-Office365-Filtering-Correlation-Id: a02f8748-0598-4377-fbf9-08dc8bca4cc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: EqJpod7TgksTIOG/ccLtEgEhLUVySVkv6E5ovwMIrm5ZVw3pc4e+IPAH4oT4RO7+vsK6RI1T3RmFJl8hD1ilBkrMvoEttbA1loFKkhT2LlU96Hcyv5hWBKE3jS7bVUaUcH9WGmvTBPQkLibTPf9YtKnRaf1U98TqNG71etJLuU9uYM48rnA1C48ps94Kmi91i3BZ7NDvVEiK2AXbhV374T2fP/dDLiQesEQ6hQgItCb6njAKKRhit2F0tK+NyG+XJPBbmgjgJK92kcfzho5O6sAQxd82uuuOYfYeastS4N53yDJeZCyilvHwr2ZCpBrIgny3faA8P5JdRBSCDvqec+D/FtbK5pHn96VCHnUp+vpIQE2yus7yS1L9xY4Ko/ztjgBVNH6WO6CYOpFtqgW8boJtbd42ZlqtYaBxfLdhbulRSs7Gg8O5c8Hdf+SyJEwU0I76XizHs9IjUJIvzMnyLIVoiZYi9nSMQiNtbZvir3nG2HZbUlBidCOdn0ppPUqrFKYHPkAxVjv5UgpodTd0LpFPeDSvyzvbXOlWwXSQMRbjgWzvYuhzkvy4kcz2BhgZ5roeoISxJu2NcF41j/1COVB5ArlJr3Tch2en9i8gL6xFEDBUzjgFf736sOHwNHA12bUtfhxUrXVg96ClPywYJRqtlf2mnV+hbolB+5M03DKgZ5T30FuZpYre3khZI3THja8V8c8LT/jWKaPYcb+iKjK9XFMPQ78pXD9p4TZmuVLwL62eC3fs0jJqYRHMpuQS0bhVW3BJn7ChFZErIIhgdHLC77qeonW6Qu/w3XFq8tEa+UbbqNo7UyUnQF8cAE0XpsJwvAvybXdU63mKhH/S+GPrfsWSpSouptCqF7j8ZJfy8nAiYG2gOpjOjtmojXa2DQw0qBxKHdHFWTEZ3mPantpSdiAKEPCcR0jIL6pJkaHPeqIhv3zzcCH8QQzv+eQiOq7LEGa0CTHEyERvDFtXxFuQt1WIDAgdAn93DFRktKw3wzM4xhC5OPIGZxkMbS1etY/Rhj162/0Ex5gD2aEIqarqTRZsgyibi4R0d1NW1+kY/a3lEVgprPbUxo28Q0yh8VmjSefQx65a/BhpwqUGncCIUWTnxfYGbEIYUbR3NrYXuHhDSPKKaR0aXRwxMZHnQ/a5kFg31EcY4GwxcT1FSC52GzbCZ2wM6d/xo+OGVy6W+dm+WsA5mSx1vE643uOFu90Afi+6yTR00bYOBpQo+RC7xBbyVXG1kCnnBPDxhF5MctpqzD/dmWKIWcrMxoX4hN3K0sft5MEro9UbmROFn3cB1FHz7lSMlOyKmw+ijzkbsHxCtL59nMYf2LIFat+eHGG3plxQH37koe5fcErIwqi/3oodEgHHR99EdKQn/N8C3TrbuVGYEl2z+u1icv5H6H3Zs1HP0boIyw+83F1azg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:16.5394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a02f8748-0598-4377-fbf9-08dc8bca4cc2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7238 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Moves the PCI-specific portions of nouveau_pmops to NVKM, leaving the DRM pieces where they are. The NVKM functions are called through the the nvkm_device_pci_driver struct from DRM for now, but will be fully separated once the DRM driver is implemented on an auxiliary device. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_acpi.h | 3 - drivers/gpu/drm/nouveau/nouveau_drm.c | 24 ++----- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 76 +++++++++++++++++++++++ 3 files changed, 80 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.h b/drivers/gpu/drm/nouveau/nouveau_acpi.h index be1b218cb921..b4c7ae78cedc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.h +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.h @@ -5,13 +5,10 @@ #define ROM_BIOS_PAGE 4096 #if defined(CONFIG_ACPI) && defined(CONFIG_X86) -#include -static inline void nouveau_switcheroo_optimus_dsm(void) { nvkm_acpi_switcheroo_set_powerdown(); } void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *); bool nouveau_acpi_video_backlight_use_native(void); void nouveau_acpi_video_register_backlight(void); #else -static inline void nouveau_switcheroo_optimus_dsm(void) {} static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; } static inline bool nouveau_acpi_video_backlight_use_native(void) { return true; } static inline void nouveau_acpi_video_register_backlight(void) {} diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 76eddf172bb5..aa54aee23814 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -901,11 +901,7 @@ nouveau_pmops_suspend(struct device *dev) if (ret) return ret; - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, PCI_D3hot); - udelay(200); - return 0; + return nvkm_device_pci_driver.driver.pm->suspend(dev); } int @@ -919,12 +915,9 @@ nouveau_pmops_resume(struct device *dev) drm->dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) return 0; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - ret = pci_enable_device(pdev); + ret = nvkm_device_pci_driver.driver.pm->resume(dev); if (ret) return ret; - pci_set_master(pdev); ret = nouveau_do_resume(drm, false); @@ -973,12 +966,8 @@ nouveau_pmops_runtime_suspend(struct device *dev) return -EBUSY; } - nouveau_switcheroo_optimus_dsm(); ret = nouveau_do_suspend(drm, true); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_ignore_hotplug(pdev); - pci_set_power_state(pdev, PCI_D3cold); + ret = nvkm_device_pci_driver.driver.pm->runtime_suspend(dev); drm->dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF; return ret; } @@ -995,12 +984,9 @@ nouveau_pmops_runtime_resume(struct device *dev) return -EBUSY; } - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - ret = pci_enable_device(pdev); + ret = nvkm_device_pci_driver.driver.pm->runtime_resume(dev); if (ret) return ret; - pci_set_master(pdev); ret = nouveau_do_resume(drm, true); if (ret) { @@ -1008,8 +994,6 @@ nouveau_pmops_runtime_resume(struct device *dev) return ret; } - /* do magic */ - nvif_mask(&drm->device, 0x088488, (1 << 25), (1 << 25)); drm->dev->switch_power_state = DRM_SWITCH_POWER_ON; /* Monitors may have been connected / disconnected during suspend */ diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index d454d56a7909..a66cb9d474d5 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1620,6 +1620,81 @@ nvkm_device_pci_func = { #include "nouveau_drv.h" +static int +nvkm_device_pci_pm_runtime_resume(struct device *dev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct pci_dev *pdev = nvkm_device_pci(device)->pdev; + int ret; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + ret = pci_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + + /* do magic */ + nvkm_mask(device, 0x088488, (1 << 25), (1 << 25)); + return 0; +} + +static int +nvkm_device_pci_pm_runtime_suspend(struct device *dev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct pci_dev *pdev = nvkm_device_pci(device)->pdev; + + nvkm_acpi_switcheroo_set_powerdown(); + + pci_save_state(pdev); + pci_disable_device(pdev); + pci_ignore_hotplug(pdev); + pci_set_power_state(pdev, PCI_D3cold); + return 0; +} + +static int +nvkm_device_pci_pm_resume(struct device *dev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct pci_dev *pdev = nvkm_device_pci(device)->pdev; + int ret; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + ret = pci_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + return 0; +} + +static int +nvkm_device_pci_pm_suspend(struct device *dev) +{ + struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct pci_dev *pdev = nvkm_device_pci(device)->pdev; + + pci_save_state(pdev); + pci_disable_device(pdev); + pci_set_power_state(pdev, PCI_D3hot); + udelay(200); + return 0; +} + +static const struct dev_pm_ops +nvkm_device_pci_pm = { + .suspend = nvkm_device_pci_pm_suspend, + .resume = nvkm_device_pci_pm_resume, + .runtime_suspend = nvkm_device_pci_pm_runtime_suspend, + .runtime_resume = nvkm_device_pci_pm_runtime_resume, +}; + static void nvkm_device_pci_remove(struct pci_dev *dev) { @@ -1787,4 +1862,5 @@ struct pci_driver nvkm_device_pci_driver = { .probe = nvkm_device_pci_probe, .remove = nvkm_device_pci_remove, + .driver.pm = &nvkm_device_pci_pm, }; From patchwork Thu Jun 13 17:00:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697153 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7D6CBC27C6E for ; Thu, 13 Jun 2024 17:00:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 274F310EB1D; Thu, 13 Jun 2024 17:00:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="sKpdFkhq"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2045.outbound.protection.outlook.com [40.107.100.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF7B110EB08; Thu, 13 Jun 2024 17:00:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h210SqNY2buKk1JSjzCjEK2+KX/NztfZNcXAmao2K6tp5n+7GXcBjlrEX23DxgDT/lg92fx/zYEJUGvpwBiQBNZhP8ZqUjp7j2D39Pohy9HDyxR2UWC7k+Wh6YAFVOND9k2QJ3E7LSi01YZDmjdXJCmvx1meF0g8qaPQSTjppI/8BD/LozL+1H0YwPPMX4HvHyrHFmN9xxp902zLQIoqrQmGsrs/IoPja/NdqhWN6mxUi8YAQEldBffLu2q/DnvMiqftekS9vajG0kcMQLvC/ZMrbVkPaMRPeoEnCHb1gB7iV5I8Iak0Dm7ynjc9APQgnq5U/SsD6QkKnbZYq5WHUA== 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=s/zq3+bRdr5nagyyEDBAPewdx0AOfBPTk6Jeu0NlYCc=; b=FihGp6+DneFGPiJmsObtoYxrhKOzHwHKv/7U0fCils9TsqX8KexhM6vLzLHFpW17t5raig4jlXcDi2OWRkvMmgkveC/SSnVLP+ln3jFrA8+YhuPW8cLUdeOFv23ASAEcCZUMSRDJON8dKrQWQfEmQtsnaJf+MbXJMx5NYF+pajuQXQ7qiS+UPMtKsypTvZM5u+4JB0WPuvFDgU2TvEP8gZiQJVbI9/Y0beVIo5W86iQf/HIbpC8ko2ZkMDzPE6+JPev+4NJe5MJeYGFx/NrLqSQFfvdlwAWPeG5Suzri0hnvR5diZFOaagJdabTQJpf8J/iv0s3+l0Qoma9kqQZ64A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s/zq3+bRdr5nagyyEDBAPewdx0AOfBPTk6Jeu0NlYCc=; b=sKpdFkhqUC2FKOhAPRSZNZfbhi6DKANcUiy6JDj9eHl0HNApY/Xf2oZ6fTyHJrHqBt7J0HU7xx745xvAtJUjDjab8sbj5x1uQKNKs7A+n1QG3XnYTOxh/yPU5Id0RmVN8+uWf1sEzXcH1QUHcuWrPruFCys71Si1FaQlk4TS122BFd3uhi5yQXtCFqzdPcuFML/ZJ59k0GCAXUt4ZMM4syfhg/fwhj4K5GMK4N1JAmynVJN6lwF0KLqliLmYh+uFhV3xJC05l/Qyoi03BkM8xvcdioi7XXcqGniyz1hWCJq3HpRcfP5gOnM5E84yiNwzCIYaRnEVZF/X2sjphKj0qA== Received: from SA9PR10CA0024.namprd10.prod.outlook.com (2603:10b6:806:a7::29) by SN7PR12MB7347.namprd12.prod.outlook.com (2603:10b6:806:29a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 17:00:21 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:806:a7:cafe::ad) by SA9PR10CA0024.outlook.office365.com (2603:10b6:806:a7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:03 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:02 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 18/21] drm/nouveau/nvkm: add device to auxiliary bus for each nvkm_device Date: Fri, 14 Jun 2024 03:00:10 +1000 Message-ID: <20240613170046.88687-19-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|SN7PR12MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: c8464981-be2a-4b11-142e-08dc8bca4fd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: HEQL4e1zOL8EKUt9q2qS9Th0UTveDpj0DGujXUrQ/Q8zj/2BiJRjKsoJbDwYQX+PtxKmix7ThBc6H0TC67Ny+0WKjzHg5ujzbdjbmKv+EajIAaQbQuYVsfKEw6c4MnEbny0o9I46or8qnmr1Qxs64SHTQXq8al1//v5REDeaYFC9VjYNN1YPNiscNPQOCPVi5FaUIbYFHjX8l9Kt3i21H7EVRf9tGlyBntUXu40nBt+N5MO1GAnMauS4GtZxoOdPkC7BalkUpRi7caRbzzOzGRY20XWCAvmUQrjbfXGBpB0z0UGur8wZFD4cIU0g5uyEInoJL5ppkLecFkaO/uybAihCM+j0zrALHuKSCzl7WVm4j+BqbmYT52r1AKMB8aqhiJfgU7Ffe8knmmvZHhJm5iQgQESCdyJkBu11nV3zYcUldifPZyqa9kKiy3LaTSgxyBPf1N9X77offy+KrSIlN/E2qRMrnv3/42cq/YP3Ji6jdw1G2iLiirH3Ujemp17tM6la3ByWd4FkZUVuq+XyBtQJ233+CkSGNdddjfvZFHX07E8b28jouxjyVi3uMrbtrHckqBvEAdWxnVW0OzXY/jePWOBa17/R5cRxy8pI/u/Vyp6hch/6Fj+K3CDL4aTuRT0s/h6rBo+ij6SfdGU2UZ92Wa3ERISxv1FnF8i6uM6HfzuSnWDrkO2QufYGWOkuh5IyaA3SMe5xTNVRun7vktiJ/v3oXy/nbUXZJUa40alhTHcfSsyBoXHVZ4CV0/3x1QXMcg7S7Mz8xsu4FRvi4q1c4/SrfOS2a/c10AxsG0XaWTp2bahz5gKDHbgJhbaQZWLuAzFe4PmRcv8F7nQuNN/wrz4bIE9K4L56TC6BCR1k+oVE0M/mK4jioBxNXL1HWQsi9/ztpzGIGPpDf1YkDawuwXkZdTcyyu4OtfYts0rgLu30pRmuGSB4ICV46aTq47X2zP+VqYLIRCh35HZtesw9rGpMC8vd3taYiq2rrR6gOlCvzzQc/wUgjfa+8u3vVZaCqufB5FslOBHRUSbuu6MhC7/jAkiL84LWh1GsODz/4e/HXXyZ2M22CmIWjSkF/52nWQHmrAwArsNk/1Ak5hLgoxD/caFZx9mJI5pvDZg6nPHSkcFKTA7yV3kBh68RUaJj+DSnDtXMJtPhSOra0Hwk6vWlwnwbhBO7fq9q8S1AkocyRZ7SvSYPbn/JzDxDvKRv5pLyL0Gu4uczZnHAOFg+peW+QWdVL/LJ3LB1SQnAS1tU9BjOL+EjJjZzDZHQ00geFGlsgbgx7tOzHTA2mNQuOp3H0LqTirzMM3+bPF9tH43WBO1XZ/M40ESedCwBr8HU8xwhyI4C+tDt+X6MRhY23TRuuYrBrQSXlhMqP6vK4zGfZlQtvMlkN4gbH80StefWLZgfG+2B/tAwxVM0cA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:21.7642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8464981-be2a-4b11-142e-08dc8bca4fd9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7347 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This commit registers a device on the aux bus after core NVKM init has finished, which will be used by a later commit to have the DRM driver probe() against an aux device instead of a PCI or platform device (in the case of Tegra). Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/Kconfig | 1 + .../drm/nouveau/include/nvkm/core/device.h | 3 ++ drivers/gpu/drm/nouveau/nvkm/device/base.c | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig index 4c10b400658c..6d0d46a0e66f 100644 --- a/drivers/gpu/drm/nouveau/Kconfig +++ b/drivers/gpu/drm/nouveau/Kconfig @@ -7,6 +7,7 @@ config DRM_NOUVEAU depends on DRM_DISPLAY_HELPER depends on PCI depends on MMU + select AUXILIARY_BUS select IOMMU_API select FW_LOADER select DRM_KMS_HELPER diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index d8596fe0adea..855d1b20820d 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -5,6 +5,8 @@ #include enum nvkm_subdev_type; +#include + enum nvkm_device_type { NVKM_DEVICE_PCI, NVKM_DEVICE_AGP, @@ -78,6 +80,7 @@ struct nvkm_device { bool legacy_done; } intr; + struct auxiliary_device auxdev; const struct nvif_driver_func *driver; }; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/base.c b/drivers/gpu/drm/nouveau/nvkm/device/base.c index 4f8298bf71ee..fbb6e20bc1f2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/base.c @@ -3029,6 +3029,9 @@ nvkm_device_del(struct nvkm_device **pdevice) struct nvkm_device *device = *pdevice; struct nvkm_subdev *subdev, *subtmp; if (device) { + auxiliary_device_delete(&device->auxdev); + auxiliary_device_uninit(&device->auxdev); + nvkm_intr_dtor(device); list_for_each_entry_safe_reverse(subdev, subtmp, &device->subdev, head) @@ -3076,6 +3079,16 @@ nvkm_device_endianness(struct nvkm_device *device) return true; } +static DEFINE_IDA(nvkm_device_id); + +static void +nvkm_device_release(struct device *dev) +{ + struct nvkm_device *device = container_of(dev, typeof(*device), auxdev.dev); + + ida_free(&nvkm_device_id, device->auxdev.id); +} + int nvkm_device_ctor(const struct nvkm_device_func *func, const struct nvkm_device_quirk *quirk, @@ -3335,5 +3348,25 @@ nvkm_device_ctor(const struct nvkm_device_func *func, iounmap(device->pri); device->pri = NULL; } + + if (ret == 0) { + ret = ida_alloc(&nvkm_device_id, GFP_KERNEL); + if (ret < 0) + return ret; + + device->auxdev.dev.parent = device->dev; + device->auxdev.dev.release = nvkm_device_release; + device->auxdev.name = "device"; + device->auxdev.id = ret; + + ret = auxiliary_device_init(&device->auxdev); + if (ret) + return ret; + + ret = auxiliary_device_add(&device->auxdev); + if (ret) + auxiliary_device_uninit(&device->auxdev); + } + return ret; } From patchwork Thu Jun 13 17:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697162 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AB1FDC27C6E for ; Thu, 13 Jun 2024 17:01:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0415110EB32; Thu, 13 Jun 2024 17:01:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="Ee/87avQ"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 337E010EB27; Thu, 13 Jun 2024 17:01:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLiOdUnQnTIfNhDostZ4bx+3IMu94SPo8wEE/mdGebxru0gA/iLdMnLvhRlSFSQlZ+K7GaEoHF+svNkdiRwy7EEs3FU92sxW79gHRY5KBgi00Cjqra4y5Df5FzG3Cz6/weOoHQnM8A9yr0rOceVZ5/tEW28C+7RsMwgDxLkiJffsQezp6S1h/mqjvHcTTnodgA9Com6+QqX+TnLFtMNZEvkxWvLeE1K9V1txyYXnblARo63uGfynFoqfnNxUbch5RJhiNH7g6YsLB8dJXH4dD870bQPL5XS0WLdVDloBmDppubj3xWNnBP823g0ItkUwaeMbpK+BcRxrtAElSVGCLw== 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=bUKDIIHh7zc+jLnu+bG1wf5BWverLBq5ntsDilv8nsU=; b=B/56bPa3furJ0LBZzHppjOB/iZWfT4XFVBygTh+11ox5ynmcMFsQJ48OQEaiRQWu9vj+w4NRZ92nh4OlzIcTXwPJv+Abva1vkw+HCOecf1JdUzl/8hPIVBQyCUrQBJ/47iqS2xZk5vuLemYcDli/NWgG6uSg2cNEnWExy28wkBu4+HsMSuDBLsAKdNSfBs6DDOZRY2zZa3I1ZPZs4srXa6zN5XHwg2+CjdtnuSDxksCG2rd1mJ0UJVigA3lgPRGBl376TyHs1m0VfHmtYXEaG5dEEskdSdRV7/9eU8B8Us8gIVP9rJtf2q7sERkl/qCEYmG07IxSvwPcgeQRwO4Orw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bUKDIIHh7zc+jLnu+bG1wf5BWverLBq5ntsDilv8nsU=; b=Ee/87avQbtWaPe+S8RFbrTcn+0eWkvHnIFX64Z1i8ksToWaZkfGsjXWVpSUpGzafiTdXhXXuhzIrNgAynFK2hIbCtvI61TZjg0/7oPbwzUocg4PkMkxoKsXW6KVw4KzKw4V/Hv0GX2VLUMhOw+zKu5/56KrraVLiaeibWM7Ox+etARqcj8hWQ+Ep4fx4hEuTPlR1Ok0RkKhHCvhLJaOc4ko3DiMx+XSf0SzP72Jx7PEg1T3q7jXWbU6urZRCPqL2vPaQUm7t6kmN89jCex0UIfzzJdUzIrE+Hvw5Fczm9Kqkx78U9SBDFp4zaY1nUwNABsCyv1X2pJn+gWo3PmpwSQ== Received: from BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) by SJ2PR12MB8782.namprd12.prod.outlook.com (2603:10b6:a03:4d0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 17:00:24 +0000 Received: from SJ1PEPF00002320.namprd03.prod.outlook.com (2603:10b6:a03:1b8:cafe::f4) by BY5PR17CA0029.outlook.office365.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.24 via Frontend Transport; Thu, 13 Jun 2024 17:00:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00002320.mail.protection.outlook.com (10.167.242.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:04 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:03 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 19/21] drm/nouveau: wrap pm_runtime_* calls with nouveau_runpm Date: Fri, 14 Jun 2024 03:00:11 +1000 Message-ID: <20240613170046.88687-20-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002320:EE_|SJ2PR12MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: 8428ac8d-c7f1-4281-f29e-08dc8bca501e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230035|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: I5y+zRWiCiCNUM6lL8ctRiZb3dvbIiM/+ZoLw4Mbm0Kn2H8OGOSCibXRE+5zoUm8XIevUI2XM27BrN9piJym+0KGKC4XPXelAIqcsERjYv4h33TT+k5go44YqkNc6wS3cjgjMYHwQjCO9uR0PHK1z0j2w+rbdPWgvwPwr8D2pSEds5c3vlAr4krjuk5uRTMG3TXW8C6Ai+PiOxlinwybgz6AJfLuL9qtrv2iviJHWZUYxVtViEKFYn0zWSSSrZxin74CSJvndA6Dh0XoHBYPSGgALt4xXjSpbiNLrj/gk8TY1ikiluLidwLr5XQ5LurXMUdhldetMonE2+yvckMfVRVcwE7UyO7HXzmjG8ooWYlVXhS34AtOFCT6dOTeEx9SbP3AwjOIWoCFEmoKO4MjtZTwZfLgQZbgYevt8Wsl4plQfMyHSp5ZHe+1jjGIZ3RohN/LLQOUg+guY6o1zQa02vOTMR7vAofBiesNgQtRvoHVIq/UHfkdD0tzsXEJE4/CfPM9EOY8OqFV5qNNpOAB7E1L1mUaqTfUClPg4DmnARA1nvuGGAEJGp6u8/ptvwwCC3SliTZpAuB5RBcBA1wB5Jr7gudtthRNuuxciQa4fAakz2oENkh+BDL4SDBwK9p3aZVOyvtZK0Ba1wl+YVe3ywol8TQ6D+dC/yZc9clGvlMcPrW4771oyKKfvyZUQ4djRxrAaTPP6OUm84wI7NGnlKBagKrqsHVhrYqcQ4xZXPaUUfSryZrLpT4aWhvdcEZcl1nfw356nfUnaEE0E6yTzoark6RYpmMy7tlq0biAXfi8bZnr+H6oxesqzYX0/SLjztP6qquib0kNrqEmCqqzj3Q/e0IpieT6nZzzSgVodLlgiWCx/vYDQwtDxVkI/1gBqsRxJ4kqBFWstbdMJO78cZUrivg+70RVCZrkJWPQTs31oVfWo+5waJ8RiSpi3UZYF+pM5RD9n0zJFmRAW1lJzjlXB5jNPrXQw7MbbEV1mWBOcC/ZRvUuJcq5QHV9JHpyqMDwL1nWM+hf1Q4MkrInnF1yGKSFjdA12ErmrmD9ve4LBAlBONlsRukhsOOloa+f7BgKKrbT/NPhxnN9Tuo/DpqiSj4PqALkg1B6m/jwSqlV0/ZKb+dIgqpc2FUSZzv++HMDtjsw2RYUdWuwcCvCIjqdaorg8y9ifuntK7K2lBlb67XVQ/sYTC4Eu20t0dPJaOtICE/66e4SvvLOqGn1zRUE3vi89guRD5MG0Qia5EQFuK0Ce6HJXDjEotem6S3DuOY8UUz/OsOGAPZN2Y++hQ1xcwgJKz0hvSpca3/SXFQB/docWC8fDeYD8icYpwyl6jboFN+I5zF3R661kplFXMK0VSYee6PR/HBPkU0JffxNVEwsjJaNJogKpc6Meiyd1KW0EkO7OmgnYYxRGxA9gA== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230035)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:22.3471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8428ac8d-c7f1-4281-f29e-08dc8bca501e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002320.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8782 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This wraps direct calls to pm_runtime functions to cleanup some common usage patterns, and keep the logic in one place. From the next commit, the pm_runtime calls will need to operate against the DRM driver's auxiliary device instead of directly on the underlying PCI device. This commit will help make that switch cleaner. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 31 ++++--- drivers/gpu/drm/nouveau/nouveau_connector.c | 12 ++- drivers/gpu/drm/nouveau/nouveau_connector.h | 1 + drivers/gpu/drm/nouveau/nouveau_debugfs.c | 24 +++--- drivers/gpu/drm/nouveau/nouveau_display.c | 19 ++--- drivers/gpu/drm/nouveau/nouveau_drm.c | 45 ++++------- drivers/gpu/drm/nouveau/nouveau_gem.c | 30 +++---- drivers/gpu/drm/nouveau/nouveau_runpm.h | 89 +++++++++++++++++++++ 8 files changed, 156 insertions(+), 95 deletions(-) create mode 100644 drivers/gpu/drm/nouveau/nouveau_runpm.h diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 64f3a1b00173..c0fc5233ebd4 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -952,17 +952,16 @@ static int nv50_mstc_detect(struct drm_connector *connector, struct drm_modeset_acquire_ctx *ctx, bool force) { + struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nv50_mstc *mstc = nv50_mstc(connector); int ret; if (drm_connector_is_unregistered(connector)) return connector_status_disconnected; - ret = pm_runtime_get_sync(connector->dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(connector->dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) return connector_status_disconnected; - } ret = drm_dp_mst_detect_port(connector, ctx, mstc->port->mgr, mstc->port); @@ -970,8 +969,7 @@ nv50_mstc_detect(struct drm_connector *connector, goto out; out: - pm_runtime_mark_last_busy(connector->dev->dev); - pm_runtime_put_autosuspend(connector->dev->dev); + nouveau_runpm_put(drm); return ret; } @@ -1950,7 +1948,7 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) asyh->clr.mask, asyh->set.mask); if (old_crtc_state->active && !new_crtc_state->active) { - pm_runtime_put_noidle(dev->dev); + nouveau_runpm_put_noidle(drm); drm_crtc_vblank_off(crtc); } @@ -2040,7 +2038,7 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) if (new_crtc_state->active) { if (!old_crtc_state->active) { drm_crtc_vblank_on(crtc); - pm_runtime_get_noresume(dev->dev); + nouveau_runpm_get_noresume(drm); } if (new_crtc_state->event) drm_crtc_vblank_get(crtc); @@ -2159,8 +2157,7 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) drm_atomic_state_put(state); /* Drop the RPM ref we got from nv50_disp_atomic_commit() */ - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); } static void @@ -2175,15 +2172,14 @@ static int nv50_disp_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state, bool nonblock) { + struct nouveau_drm *drm = nouveau_drm(dev); struct drm_plane_state *new_plane_state; struct drm_plane *plane; int ret, i; - ret = pm_runtime_get_sync(dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) return ret; - } ret = drm_atomic_helper_setup_commit(state, nonblock); if (ret) @@ -2219,7 +2215,7 @@ nv50_disp_atomic_commit(struct drm_device *dev, * Grab another RPM ref for the commit tail, which will release the * ref when it's finished */ - pm_runtime_get_noresume(dev->dev); + nouveau_runpm_get_noresume(drm); if (nonblock) queue_work(system_unbound_wq, &state->commit_work); @@ -2230,7 +2226,7 @@ nv50_disp_atomic_commit(struct drm_device *dev, if (ret) drm_atomic_helper_unprepare_planes(dev, state); done: - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); return ret; } @@ -2439,6 +2435,7 @@ static inline void nv50_display_read_hw_or_state(struct drm_device *dev, struct nv50_disp *disp, struct nouveau_encoder *outp) { + struct nouveau_drm *drm = nouveau_drm(dev); struct drm_crtc *crtc; struct drm_connector_list_iter conn_iter; struct drm_connector *conn; @@ -2501,7 +2498,7 @@ nv50_display_read_hw_or_state(struct drm_device *dev, struct nv50_disp *disp, armh->state.connector_mask = drm_connector_mask(conn); armh->state.active = true; armh->state.enable = true; - pm_runtime_get_noresume(dev->dev); + nouveau_runpm_get_noresume(drm); outp->crtc = crtc; outp->ctrl = NVVAL(NV507D, SOR_SET_CONTROL, PROTOCOL, proto) | BIT(crtc->index); diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index e3071ea845e6..c5386166b15d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -26,7 +26,6 @@ #include -#include #include #include @@ -579,11 +578,11 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) * if possible. */ if (drm_kms_helper_is_poll_worker()) { - pm_runtime_get_noresume(dev->dev); + nouveau_runpm_get_noresume(drm); } else { - ret = pm_runtime_get_sync(dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) { + nouveau_runpm_put(drm); nouveau_connector_set_edid(nv_connector, NULL); return conn_status; } @@ -674,8 +673,7 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) if (!nv_connector->edid) drm_dp_cec_unset_edid(&nv_connector->aux); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); return conn_status; } diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h index 0608cabed058..d2035855861d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.h +++ b/drivers/gpu/drm/nouveau/nouveau_connector.h @@ -40,6 +40,7 @@ #include "nouveau_crtc.h" #include "nouveau_encoder.h" +#include "nouveau_runpm.h" struct nvkm_i2c_port; struct dcb_output; diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c index aff6ee476f65..4c0e122ba724 100644 --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c @@ -31,6 +31,7 @@ #include #include "nouveau_debugfs.h" #include "nouveau_drv.h" +#include "nouveau_runpm.h" static int nouveau_debugfs_vbios_image(struct seq_file *m, void *data) @@ -51,18 +52,14 @@ nouveau_debugfs_strap_peek(struct seq_file *m, void *data) struct nouveau_drm *drm = nouveau_drm(node->minor->dev); int ret; - ret = pm_runtime_get_sync(drm->dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(drm->dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) return ret; - } seq_printf(m, "0x%08x\n", nvif_rd32(&drm->device, 0x101000)); - pm_runtime_mark_last_busy(drm->dev->dev); - pm_runtime_put_autosuspend(drm->dev->dev); - + nouveau_runpm_put(drm); return 0; } @@ -135,8 +132,9 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, size_t len, loff_t *offp) { struct seq_file *m = file->private_data; - struct drm_device *drm = m->private; - struct nouveau_debugfs *debugfs = nouveau_debugfs(drm); + struct drm_device *dev = m->private; + struct nouveau_debugfs *debugfs = nouveau_debugfs(dev); + struct nouveau_drm *drm = nouveau_drm(dev); struct nvif_control_pstate_user args = { .pwrsrc = -EINVAL }; char buf[32] = {}, *tmp, *cur = buf; long value, ret; @@ -174,14 +172,12 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, args.ustate = value; } - ret = pm_runtime_get_sync(drm->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(drm->dev); + ret = nouveau_runpm_get(drm); + if (ret) return ret; - } ret = debugfs->impl->pstate.user(debugfs->priv, &args); - pm_runtime_put_autosuspend(drm->dev); + nouveau_runpm_put(drm); if (ret < 0) return ret; diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index e892f5f5ea16..57d31a17ad68 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -466,7 +466,7 @@ nouveau_display_hpd_work(struct work_struct *work) int changed = 0; struct drm_connector *first_changed_connector = NULL; - pm_runtime_get_sync(dev->dev); + nouveau_runpm_try_get(drm); spin_lock_irq(&drm->hpd_lock); pending = drm->hpd_pending; @@ -474,8 +474,10 @@ nouveau_display_hpd_work(struct work_struct *work) spin_unlock_irq(&drm->hpd_lock); /* Nothing to do, exit early without updating the last busy counter */ - if (!pending) - goto noop; + if (!pending) { + nouveau_runpm_put_noop(drm); + return; + } mutex_lock(&dev->mode_config.mutex); drm_connector_list_iter_begin(dev, &conn_iter); @@ -532,9 +534,7 @@ nouveau_display_hpd_work(struct work_struct *work) if (first_changed_connector) drm_connector_put(first_changed_connector); - pm_runtime_mark_last_busy(drm->dev->dev); -noop: - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); } #ifdef CONFIG_ACPI @@ -545,24 +545,25 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, { struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); struct acpi_bus_event *info = data; + struct device *dev = drm->dev->dev; int ret; if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { if (info->type == ACPI_VIDEO_NOTIFY_PROBE) { - ret = pm_runtime_get(drm->dev->dev); + ret = pm_runtime_get(dev); if (ret == 1 || ret == -EACCES) { /* If the GPU is already awake, or in a state * where we can't wake it up, it can handle * it's own hotplug events. */ - pm_runtime_put_autosuspend(drm->dev->dev); + pm_runtime_put_autosuspend(dev); } else if (ret == 0 || ret == -EINPROGRESS) { /* We've started resuming the GPU already, so * it will handle scheduling a full reprobe * itself */ NV_DEBUG(drm, "ACPI requested connector reprobe\n"); - pm_runtime_put_noidle(drm->dev->dev); + pm_runtime_put_noidle(dev); } else { NV_WARN(drm, "Dropped ACPI reprobe event due to RPM error: %d\n", ret); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index aa54aee23814..2a9faf0fc277 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -72,6 +71,7 @@ #include "nouveau_exec.h" #include "nouveau_uvmm.h" #include "nouveau_sched.h" +#include "nouveau_runpm.h" DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, "DRM_UT_CORE", @@ -486,10 +486,8 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) struct drm_device *dev = drm->dev; struct nouveau_cli *cli, *temp_cli; - if (nouveau_pmops_runtime(dev->dev)) { - pm_runtime_get_sync(dev->dev); - pm_runtime_forbid(dev->dev); - } + if (nouveau_pmops_runtime(dev->dev)) + nouveau_runpm_disable(drm); nouveau_led_fini(dev); nouveau_dmem_fini(drm); @@ -581,14 +579,8 @@ nouveau_drm_device_init(struct nouveau_drm *drm) nouveau_dmem_init(drm); nouveau_led_init(dev); - if (nouveau_pmops_runtime(dev->dev)) { - pm_runtime_use_autosuspend(dev->dev); - pm_runtime_set_autosuspend_delay(dev->dev, 5000); - pm_runtime_set_active(dev->dev); - pm_runtime_allow(dev->dev); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put(dev->dev); - } + if (nouveau_pmops_runtime(dev->dev)) + nouveau_runpm_enable(drm); ret = drm_dev_register(drm->dev, 0); if (ret) { @@ -1025,11 +1017,9 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) int ret; /* need to bring up power immediately if opening device */ - ret = pm_runtime_get_sync(dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) return ret; - } get_task_comm(tmpname, current); rcu_read_lock(); @@ -1058,8 +1048,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) kfree(cli); } - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); return ret; } @@ -1079,7 +1068,7 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv) if (!drm_dev_enter(dev, &dev_index)) return; - pm_runtime_get_sync(dev->dev); + nouveau_runpm_try_get(drm); mutex_lock(&cli->mutex); if (cli->abi16) @@ -1092,8 +1081,9 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv) nouveau_cli_fini(cli); kfree(cli); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + + nouveau_runpm_put(drm); + drm_dev_exit(dev_index); } @@ -1122,14 +1112,12 @@ long nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct drm_file *filp = file->private_data; - struct drm_device *dev = filp->minor->dev; + struct nouveau_drm *drm = nouveau_drm(filp->minor->dev); long ret; - ret = pm_runtime_get_sync(dev->dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(dev->dev); + ret = nouveau_runpm_get(drm); + if (ret) return ret; - } switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) { case DRM_NOUVEAU_NVIF: @@ -1140,8 +1128,7 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + nouveau_runpm_put(drm); return ret; } diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index ede2bf30ebc2..e650cb52e267 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -30,6 +30,7 @@ #include "nouveau_dma.h" #include "nouveau_fence.h" #include "nouveau_abi16.h" +#include "nouveau_runpm.h" #include "nouveau_ttm.h" #include "nouveau_gem.h" @@ -78,22 +79,18 @@ nouveau_gem_object_del(struct drm_gem_object *gem) { struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); - struct device *dev = drm->dev->dev; int ret; - ret = pm_runtime_get_sync(dev); - if (WARN_ON(ret < 0 && ret != -EACCES)) { - pm_runtime_put_autosuspend(dev); + ret = nouveau_runpm_get(drm); + if (WARN_ON(ret)) return; - } if (gem->import_attach) drm_prime_gem_destroy(gem, nvbo->bo.sg); ttm_bo_put(&nvbo->bo); - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); + nouveau_runpm_put(drm); } int @@ -102,7 +99,6 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); - struct device *dev = drm->dev->dev; struct nouveau_uvmm *uvmm = nouveau_cli_uvmm(cli); struct nouveau_vmm *vmm = nouveau_cli_vmm(cli); struct nouveau_vma *vma; @@ -119,19 +115,17 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) if (ret) return ret; - ret = pm_runtime_get_sync(dev); - if (ret < 0 && ret != -EACCES) { - pm_runtime_put_autosuspend(dev); + ret = nouveau_runpm_get(drm); + if (ret) goto out; - } /* only create a VMA on binding */ if (!nouveau_cli_uvmm(cli)) ret = nouveau_vma_new(nvbo, vmm, &vma); else ret = 0; - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); + + nouveau_runpm_put(drm); out: ttm_bo_unreserve(&nvbo->bo); return ret; @@ -188,7 +182,6 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); - struct device *dev = drm->dev->dev; struct nouveau_vmm *vmm = nouveau_cli_vmm(cli); struct nouveau_vma *vma; int ret; @@ -206,12 +199,11 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) vma = nouveau_vma_find(nvbo, vmm); if (vma) { if (--vma->refs == 0) { - ret = pm_runtime_get_sync(dev); - if (!WARN_ON(ret < 0 && ret != -EACCES)) { + ret = nouveau_runpm_get(drm); + if (!WARN_ON(ret)) { nouveau_gem_object_unmap(nvbo, vma); - pm_runtime_mark_last_busy(dev); + nouveau_runpm_put(drm); } - pm_runtime_put_autosuspend(dev); } } ttm_bo_unreserve(&nvbo->bo); diff --git a/drivers/gpu/drm/nouveau/nouveau_runpm.h b/drivers/gpu/drm/nouveau/nouveau_runpm.h new file mode 100644 index 000000000000..92d6c518bdad --- /dev/null +++ b/drivers/gpu/drm/nouveau/nouveau_runpm.h @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NOUVEAU_RUNPM_H__ +#define __NOUVEAU_RUNPM_H__ +#include + +static inline struct device * +nouveau_runpm_dev(struct nouveau_drm *drm) +{ + return drm->dev->dev; +} + +static inline void +nouveau_runpm_put_noidle(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_put_noidle(dev); +} + +static inline void +nouveau_runpm_put_noop(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_put_autosuspend(dev); +} + +static inline void +nouveau_runpm_put(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); +} + +static inline int +nouveau_runpm_try_get(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + return pm_runtime_get_sync(dev); +} + +static inline __must_check int +nouveau_runpm_get(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + int ret; + + ret = pm_runtime_get_sync(dev); + if (ret < 0 && ret != -EACCES) { + pm_runtime_put_autosuspend(dev); + return ret; + } + + return 0; +} + +static inline void +nouveau_runpm_get_noresume(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_get_noresume(dev); +} + +static inline void +nouveau_runpm_disable(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_get_sync(dev); + pm_runtime_forbid(dev); +} + +static inline void +nouveau_runpm_enable(struct nouveau_drm *drm) +{ + struct device *dev = nouveau_runpm_dev(drm); + + pm_runtime_use_autosuspend(dev); + pm_runtime_set_autosuspend_delay(dev, 5000); + pm_runtime_set_active(dev); + pm_runtime_allow(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put(dev); +} +#endif From patchwork Thu Jun 13 17:00:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697159 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0F690C27C4F for ; Thu, 13 Jun 2024 17:01:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8ECD610EB27; Thu, 13 Jun 2024 17:01:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="crkBG3Ey"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 90B8010EB0B; Thu, 13 Jun 2024 17:00:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lX80SwEPXkhyDf4Yie5iplXZh6aIH9oBn5Z5Ja+4Nz4iyQ9SUvPgQ2qWXQ7+zhOjBu7S9+WXb/7X8ZKR3gtR/Zf+lxpxoh8y5zVHJ6bM/3c3PgGrnr9fbynW2fWc4KaIgzIgy2eW+ktlDWmiKOV5xeX+k5gOM1kS9RkTPcYYI0NLU3N/cNMXlUU0o5nJDVZl2p0HLH+pJdR8HBiR8YtgKNmFJJOCAEAeEa8zXddl1sBxKxLMwHjLQoZplAKENMJPzGxvGKrjXZHkzUH0qgVhSSzm+u/BONGibPTLLSoJtQvSEB7AjJkozeNvrPJ4dRX00ia6guw7DHzRO5p5bN0s3A== 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=EXTvaBvIagHsZoBUhTb6+KSJ2C5holbF/iaIy7qJTxY=; b=g9GcFTWdE2V8lOIsObzB07tgJ3VJWleYeU+SNhIleNgSxlZUUgmyMmvTcz/4+0dBi8I0B3htzrjkpyUKMNUWSehxhySTYvqnLBdq5U0iaRcKjBRAcP3+o/To5dGkj6pFUMSgTZx19ZuBuI93GeJEnCuq1cUJRPJtDL20UpKC3Nw1Hwx0xGlH2ic+DhLHuh6jFEomqInSRww2KZpwTf2iQoecs8mwFgHFDgntmwomQgkg2Q28e0Slrn4jZQLNZZcjsXjKOqT3uEublhY/sUOshKVzsqchOEWX/mNNM2dieFDTPguZP3qNffKKulvHJyRCmqgioEDaa9xqNCDXBRw+kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EXTvaBvIagHsZoBUhTb6+KSJ2C5holbF/iaIy7qJTxY=; b=crkBG3EydmZ7gIaQkz7toQMPjhhKynX+8USCCfa6CTPgFM5MtyYjSP/PhG15V6wZoL+iVkkr8nom3EVCEZHusPV1D+sCgK5b3U6oE8pFDx1Xsfm2bTKY2ukoBkvyMvx/JlWlrqUPw9vqvZCOAs+53DbmMf8YaCd9oYgcpxHNm+Wo22AWEulfF5xFE/wsCfXpf00xC/pazALw1luK23xFAB4/nSxfIGGJjvbgV1/N6IWQ3Vx0yddTl3ZeyCD00xkGVKhzpUWEokn/k5WQq8UNflUhdX9UalOenG5DzoIjx7XWPYGLm52y2gDkmnIl1pDfooTB8ncHij+rPV8GMktO4w== Received: from SA9PR10CA0013.namprd10.prod.outlook.com (2603:10b6:806:a7::18) by MW4PR12MB7439.namprd12.prod.outlook.com (2603:10b6:303:22b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 17:00:29 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:806:a7:cafe::31) by SA9PR10CA0013.outlook.office365.com (2603:10b6:806:a7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25 via Frontend Transport; Thu, 13 Jun 2024 17:00:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:27 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:06 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:04 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 20/21] drm/nouveau: probe() against nvkm-provided auxiliary devices Date: Fri, 14 Jun 2024 03:00:12 +1000 Message-ID: <20240613170046.88687-21-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|MW4PR12MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: d7e4da70-e749-432f-76a9-08dc8bca5346 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: XIdh0LXtGbWqlJgXTInYRFpENILGAMShUcMOgCQmq+3CQ+utlkm9COd9Zhu6E1AIZWIVFlAPg0pQRADSZ/x1wVVDR6JRXl+bC17h+6ZD4CCMOV86EI2nQ3adeN2MGDKNNpc+Bu8kwPuPNRVq3LfmKdHqNxl/CoKKa7+XrvgFnHLFSTRgf/Ra7AsioDi64CjEW84Jo/fl5f7FXSPqpxv9Iq0WmumqgVePhgR77bqAzu3wUc1S/QATaV8FiVTASzewGP+0RinRt7jiqAsk6WlsxIVjPUF/cwjRx0++n7W6llPuArNIS5/IF6qFaNmJje19sw5gs+cww1y/ieAZlVJXDBIUHn+2uGpiycHoXkjT0qENK1fv5a5fFqdpp6UTUu+rGw33iSIPqDzrNQ4KFxxPVATxmcKzvm9vsKZWMgWy+1aJ6o0rDyA5UWkqqEL7P/ybRBS9qLf1qJM+Bl/gwP25Ag8DAXQgIdiaxVnlvLPp8L3iJSMKmwuPJO/GhEVFwngsne8PIFFWTZBgGIFeYd26G4rxbK09+DVaqp6JYFsye8gTyZlgECa+jEOLOYq0lTE7NA1kTnUFvvtM8u8PdcDy1v9kXmA4nCtT3HOFlkg3itwCGfPNaZWXjrQk3SoS0/C1FkipaYYY2/sFv0LZawWsDMMf+DuZvjiL1VuX4kjhBGX49O6A7Ide8/FMcwaXCkLQ3xa6oBql3A8+vrgxzLV2euEKyQPxySFupn/xcRtxPhchpkPBfJbRhnhJR+c/p4nJVfH8kwkCdJdJByc3B5fOZG0VfaKaRv2XAozpkGvzNdhzzQkr4O9YKLF4IujZfyxKa3C0lMA5wJPQpA1TfiP1xWs2xGTnTnazCck8UjhkXhtAmAneLUrXMICWBF7oPeJ+sZ3VVs0ZOOfWUvJczhieWrAFENFJchOKcXobIJ5W77BtSLACKDGfcnoz3a+vgGMgZFErpj8wLJGcn8Uge8sI1HFICj6nwIYOS1YTd6OulT87KNXDrdsvYWeVQZ7hYaSlTcEXei+ARwe9Sf/iPdm8JLCIKQ3Rdv+3ZPOIzu6KJJWKYXL+LYacqTAlm5hYL/lwKW4yD/YO2EuLHqCSNfERjjpHAWzh1QlKdsIhWcqn/V+4gwX9PirzIaQNIDi4CjdZmc+hO1kJ2N6YWmuG1PrzWAleJPiPS+CS60KsSnC6MmvO7HJqgKxJ4SAy5vnUW0yC0/vacNzJm0jrx2/RUd0PdyKnQliPYV5y7bT9+Uj5/K+CEkVS8BPrPJ0gq41eakkXLS2CxgPfrz3yrUAXdk+Ziym2uyvQckCXdEn+xoAHsN9k2qG5Uq8c1kas/PCgZ2bLlyL+Ji2vcKclfUbBHBRUMAUo2jmlLPuUIchCqW8fy5lCIKDqtP+pXgpIWgjBeDLCr2SvWbMCBHeWJiEa6gd+7A== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:27.5143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7e4da70-e749-432f-76a9-08dc8bca5346 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7439 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Previously, the DRM driver was the entry-point for the pci/platform bus probe() functions, and calls into NVKM to create an nvkm_device from pci/platform devices, then continues on with DRM init. Most of the code handling PCI/Tegra-specific functions has now been moved to NVKM (though prior to this commit, still *called* from DRM) and NVKM registers devices named "nvkm.device." on the auxiliary bus for each PCI or Tegra GPU in the system. The final step is to move pci/platform driver registration to NVKM, and have the DRM driver register as an auxiliary driver, from where it can gain access to the nvkm_device and proceed as it did before. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/Kbuild | 1 - drivers/gpu/drm/nouveau/dispnv50/disp.c | 9 +- drivers/gpu/drm/nouveau/nouveau_display.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 178 ++++-------------- drivers/gpu/drm/nouveau/nouveau_drv.h | 17 +- drivers/gpu/drm/nouveau/nouveau_platform.c | 93 --------- drivers/gpu/drm/nouveau/nouveau_platform.h | 27 --- drivers/gpu/drm/nouveau/nouveau_runpm.h | 2 +- drivers/gpu/drm/nouveau/nvkm/device/acpi.c | 9 +- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 42 ++++- drivers/gpu/drm/nouveau/nvkm/device/tegra.c | 43 ++++- drivers/gpu/drm/nouveau/nvkm/module.c | 24 +++ .../gpu/drm/nouveau/nvkm/subdev/pci/base.c | 4 +- 13 files changed, 155 insertions(+), 296 deletions(-) delete mode 100644 drivers/gpu/drm/nouveau/nouveau_platform.c delete mode 100644 drivers/gpu/drm/nouveau/nouveau_platform.h diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild index 61eeef83847a..cc471ab6a7ec 100644 --- a/drivers/gpu/drm/nouveau/Kbuild +++ b/drivers/gpu/drm/nouveau/Kbuild @@ -23,7 +23,6 @@ nouveau-y += nouveau_drm.o nouveau-y += nouveau_hwmon.o nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o nouveau-$(CONFIG_LEDS_CLASS) += nouveau_led.o -nouveau-$(CONFIG_NOUVEAU_PLATFORM_DRIVER) += nouveau_platform.o nouveau-y += nouveau_vga.o # DRM - memory management diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index c0fc5233ebd4..60affaedb933 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -353,7 +353,8 @@ static int nv50_audio_component_get_eld(struct device *kdev, int port, int dev_id, bool *enabled, unsigned char *buf, int max_bytes) { - struct nouveau_drm *drm = dev_get_drvdata(kdev); + struct nvkm_device *device = dev_get_drvdata(kdev); + struct nouveau_drm *drm = container_of(device->driver, typeof(*drm), driver); struct drm_encoder *encoder; struct nouveau_encoder *nv_encoder; struct nouveau_crtc *nv_crtc; @@ -398,7 +399,8 @@ static int nv50_audio_component_bind(struct device *kdev, struct device *hda_kdev, void *data) { - struct nouveau_drm *drm = dev_get_drvdata(kdev); + struct nvkm_device *device = dev_get_drvdata(kdev); + struct nouveau_drm *drm = container_of(device->driver, typeof(*drm), driver); struct drm_audio_component *acomp = data; if (WARN_ON(!device_link_add(hda_kdev, kdev, DL_FLAG_STATELESS))) @@ -416,7 +418,8 @@ static void nv50_audio_component_unbind(struct device *kdev, struct device *hda_kdev, void *data) { - struct nouveau_drm *drm = dev_get_drvdata(kdev); + struct nvkm_device *device = dev_get_drvdata(kdev); + struct nouveau_drm *drm = container_of(device->driver, typeof(*drm), driver); struct drm_audio_component *acomp = data; drm_modeset_lock_all(drm->dev); diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index 57d31a17ad68..5ec320fdfaf8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -545,7 +545,7 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, { struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); struct acpi_bus_event *info = data; - struct device *dev = drm->dev->dev; + struct device *dev = &drm->auxdev->dev; int ret; if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 2a9faf0fc277..7e77e950eba2 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -40,8 +40,6 @@ #include #include #include -#include -#include #include #include @@ -65,7 +63,6 @@ #include "nouveau_fence.h" #include "nouveau_debugfs.h" #include "nouveau_connector.h" -#include "nouveau_platform.h" #include "nouveau_svm.h" #include "nouveau_dmem.h" #include "nouveau_exec.h" @@ -111,8 +108,6 @@ static int nouveau_runtime_pm = -1; module_param_named(runpm, nouveau_runtime_pm, int, 0400); static struct drm_driver driver_stub; -static struct drm_driver driver_pci; -static struct drm_driver driver_platform; static inline bool nouveau_cli_work_ready(struct dma_fence *fence) @@ -530,6 +525,7 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) static int nouveau_drm_device_init(struct nouveau_drm *drm) { + struct nvkm_device *device = container_of(drm->auxdev, typeof(*device), auxdev); struct drm_device *dev = drm->dev; int ret; @@ -623,7 +619,7 @@ nouveau_drm_device_del(struct nouveau_drm *drm) } static struct nouveau_drm * -nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *parent, +nouveau_drm_device_new(const struct drm_driver *drm_driver, struct auxiliary_device *parent, struct nvkm_device *device) { const struct nvif_driver *driver; @@ -636,7 +632,7 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren if (!drm) return ERR_PTR(-ENOMEM); - drm->nvkm = device; + drm->auxdev = parent; drm->driver = nouveau_driver; drm->driver.switcheroo = nouveau_switcheroo; @@ -705,14 +701,14 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren goto done; } - drm->dev = drm_dev_alloc(drm_driver, parent); + drm->dev = drm_dev_alloc(drm_driver, parent->dev.parent); if (IS_ERR(drm->dev)) { ret = PTR_ERR(drm->dev); goto done; } drm->dev->dev_private = drm; - dev_set_drvdata(parent, drm); + auxiliary_set_drvdata(parent, drm); done: if (ret) { @@ -723,68 +719,51 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren return ret ? ERR_PTR(ret) : drm; } -static int nouveau_drm_probe(struct pci_dev *pdev, - const struct pci_device_id *pent) +static int +nouveau_drm_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id) { - struct nvkm_device *device; + struct nvkm_device *device = container_of(auxdev, typeof(*device), auxdev); struct nouveau_drm *drm; int ret; - /* We need to check that the chipset is supported before booting - * fbdev off the hardware, as there's no way to put it back. - */ - ret = nvkm_device_pci_driver.probe(pdev, NULL); - if (ret) - return ret; - - device = pci_get_drvdata(pdev); - - if (nouveau_atomic) - driver_pci.driver_features |= DRIVER_ATOMIC; - - drm = nouveau_drm_device_new(&driver_pci, &pdev->dev, device); + drm = nouveau_drm_device_new(&driver_stub, auxdev, device); if (IS_ERR(drm)) { ret = PTR_ERR(drm); - goto fail_nvkm; + return ret; } ret = nouveau_drm_device_init(drm); if (ret) goto fail_drm; - if (drm->device.impl->ram_size <= 32 * 1024 * 1024) - drm_fbdev_ttm_setup(drm->dev, 8); - else - drm_fbdev_ttm_setup(drm->dev, 32); + if (drm->device.impl->disp.oclass) { + if (drm->device.impl->ram_size <= 32 * 1024 * 1024) + drm_fbdev_ttm_setup(drm->dev, 8); + else + drm_fbdev_ttm_setup(drm->dev, 32); + + if (nouveau_atomic) + drm->dev->driver_features |= DRIVER_ATOMIC; + } return 0; fail_drm: nouveau_drm_device_del(drm); -fail_nvkm: - nvkm_device_del(&device); return ret; } -void -nouveau_drm_device_remove(struct nouveau_drm *drm) +static void +nouveau_drm_remove(struct auxiliary_device *auxdev) { + struct nouveau_drm *drm = auxiliary_get_drvdata(auxdev); + drm_dev_unplug(drm->dev); nouveau_drm_device_fini(drm); nouveau_drm_device_del(drm); } -static void -nouveau_drm_remove(struct pci_dev *pdev) -{ - struct nouveau_drm *drm = pci_get_drvdata(pdev); - - nouveau_drm_device_remove(drm); - - nvkm_device_pci_driver.remove(pdev); -} - static int nouveau_do_suspend(struct nouveau_drm *drm, bool runtime) { @@ -881,36 +860,25 @@ nouveau_do_resume(struct nouveau_drm *drm, bool runtime) int nouveau_pmops_suspend(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct nouveau_drm *drm = pci_get_drvdata(pdev); - int ret; + struct nouveau_drm *drm = dev_get_drvdata(dev); if (drm->dev->switch_power_state == DRM_SWITCH_POWER_OFF || drm->dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) return 0; - ret = nouveau_do_suspend(drm, false); - if (ret) - return ret; - - return nvkm_device_pci_driver.driver.pm->suspend(dev); + return nouveau_do_suspend(drm, false); } int nouveau_pmops_resume(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct nouveau_drm *drm = pci_get_drvdata(pdev); + struct nouveau_drm *drm = dev_get_drvdata(dev); int ret; if (drm->dev->switch_power_state == DRM_SWITCH_POWER_OFF || drm->dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) return 0; - ret = nvkm_device_pci_driver.driver.pm->resume(dev); - if (ret) - return ret; - ret = nouveau_do_resume(drm, false); /* Monitors may have been connected / disconnected during suspend */ @@ -949,8 +917,7 @@ nouveau_pmops_runtime(struct device *dev) static int nouveau_pmops_runtime_suspend(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct nouveau_drm *drm = pci_get_drvdata(pdev); + struct nouveau_drm *drm = dev_get_drvdata(dev); int ret; if (!nouveau_pmops_runtime(dev)) { @@ -959,7 +926,6 @@ nouveau_pmops_runtime_suspend(struct device *dev) } ret = nouveau_do_suspend(drm, true); - ret = nvkm_device_pci_driver.driver.pm->runtime_suspend(dev); drm->dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF; return ret; } @@ -967,8 +933,7 @@ nouveau_pmops_runtime_suspend(struct device *dev) static int nouveau_pmops_runtime_resume(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct nouveau_drm *drm = pci_get_drvdata(pdev); + struct nouveau_drm *drm = dev_get_drvdata(dev); int ret; if (!nouveau_pmops_runtime(dev)) { @@ -976,10 +941,6 @@ nouveau_pmops_runtime_resume(struct device *dev) return -EBUSY; } - ret = nvkm_device_pci_driver.driver.pm->runtime_resume(dev); - if (ret) - return ret; - ret = nouveau_do_resume(drm, true); if (ret) { NV_ERROR(drm, "resume failed with: %d\n", ret); @@ -1183,21 +1144,6 @@ driver_stub = { .patchlevel = DRIVER_PATCHLEVEL, }; -static struct pci_device_id -nouveau_drm_pci_table[] = { - { - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), - .class = PCI_BASE_CLASS_DISPLAY << 16, - .class_mask = 0xff << 16, - }, - { - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID), - .class = PCI_BASE_CLASS_DISPLAY << 16, - .class_mask = 0xff << 16, - }, - {} -}; - static void nouveau_display_options(void) { DRM_DEBUG_DRIVER("Loading Nouveau with parameters:\n"); @@ -1226,57 +1172,26 @@ static const struct dev_pm_ops nouveau_pm_ops = { .runtime_idle = nouveau_pmops_runtime_idle, }; -static struct pci_driver -nouveau_drm_pci_driver = { +static const struct auxiliary_device_id +nouveau_drm_id_table[] = { + { .name = "nouveau.device" }, + {} +}; + +static struct auxiliary_driver +nouveau_auxdrv = { .name = "nouveau", - .id_table = nouveau_drm_pci_table, + .id_table = nouveau_drm_id_table, .probe = nouveau_drm_probe, .remove = nouveau_drm_remove, .driver.pm = &nouveau_pm_ops, }; -struct drm_device * -nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, - struct platform_device *pdev, - struct nvkm_device **pdevice) -{ - struct nouveau_drm *drm; - int err; - - err = nvkm_device_tegra.probe(pdev); - if (err) - return ERR_PTR(err); - - *pdevice = platform_get_drvdata(pdev); - - drm = nouveau_drm_device_new(&driver_platform, &pdev->dev, *pdevice); - if (IS_ERR(drm)) { - err = PTR_ERR(drm); - goto err_free; - } - - err = nouveau_drm_device_init(drm); - if (err) - goto err_put; - - return drm->dev; - -err_put: - nouveau_drm_device_del(drm); -err_free: - nvkm_device_del(pdevice); - - return ERR_PTR(err); -} - static int __init nouveau_drm_init(void) { int ret; - driver_pci = driver_stub; - driver_platform = driver_stub; - nouveau_display_options(); if (nouveau_modeset == -1) { @@ -1291,17 +1206,9 @@ nouveau_drm_init(void) if (ret) return ret; -#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER - platform_driver_register(&nouveau_platform_driver); -#endif - nouveau_backlight_ctor(); -#ifdef CONFIG_PCI - return pci_register_driver(&nouveau_drm_pci_driver); -#else - return 0; -#endif + return auxiliary_driver_register(&nouveau_auxdrv); } static void __exit @@ -1310,14 +1217,10 @@ nouveau_drm_exit(void) if (!nouveau_modeset) return; -#ifdef CONFIG_PCI - pci_unregister_driver(&nouveau_drm_pci_driver); -#endif + auxiliary_driver_unregister(&nouveau_auxdrv); + nouveau_backlight_dtor(); -#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER - platform_driver_unregister(&nouveau_platform_driver); -#endif if (IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM)) mmu_notifier_synchronize(); @@ -1327,7 +1230,6 @@ nouveau_drm_exit(void) module_init(nouveau_drm_init); module_exit(nouveau_drm_exit); -MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 9ca0f6ab4359..ee1116bf7824 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -61,7 +61,6 @@ #include "uapi/drm/nouveau_drm.h" struct nouveau_channel; -struct platform_device; #include "nouveau_fence.h" #include "nouveau_bios.h" @@ -201,7 +200,8 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) #include struct nouveau_drm { - struct nvkm_device *nvkm; + struct auxiliary_device *auxdev; + struct nvif_driver_func driver; struct nvif_parent parent; struct nvif_client client; @@ -322,20 +322,13 @@ int nouveau_pmops_suspend(struct device *); int nouveau_pmops_resume(struct device *); bool nouveau_pmops_runtime(struct device *); -#include - -struct drm_device * -nouveau_platform_device_create(const struct nvkm_device_tegra_func *, - struct platform_device *, struct nvkm_device **); -void nouveau_drm_device_remove(struct nouveau_drm *); - #define NV_PRINTK(l,c,f,a...) do { \ struct nouveau_cli *_cli = (c); \ dev_##l(_cli->drm->dev->dev, "%s: "f, _cli->name, ##a); \ } while(0) -#define NV_PRINTK_(l,drm,f,a...) do { \ - dev_##l((drm)->nvkm->dev, "drm: "f, ##a); \ +#define NV_PRINTK_(l,drm,f,a...) do { \ + dev_##l(&(drm)->auxdev->dev, "drm: "f, ##a); \ } while(0) #define NV_FATAL(drm,f,a...) NV_PRINTK_(crit, (drm), f, ##a) #define NV_ERROR(drm,f,a...) NV_PRINTK_(err, (drm), f, ##a) @@ -371,7 +364,7 @@ extern int nouveau_modeset; static inline struct nvkm_device * nvxx_device(struct nouveau_drm *drm) { - return drm->nvkm; + return container_of(drm->auxdev, struct nvkm_device, auxdev); } #define nvxx_bios(a) nvxx_device(a)->bios diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c deleted file mode 100644 index 23beac1f96f1..000000000000 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include "nouveau_platform.h" - -static int nouveau_platform_probe(struct platform_device *pdev) -{ - const struct nvkm_device_tegra_func *func; - struct nvkm_device *device = NULL; - struct drm_device *drm; - int ret; - - func = of_device_get_match_data(&pdev->dev); - - drm = nouveau_platform_device_create(func, pdev, &device); - if (IS_ERR(drm)) - return PTR_ERR(drm); - - return 0; -} - -static void nouveau_platform_remove(struct platform_device *pdev) -{ - struct nouveau_drm *drm = platform_get_drvdata(pdev); - - nouveau_drm_device_remove(drm); - - nvkm_device_tegra.remove_new(pdev); -} - -#if IS_ENABLED(CONFIG_OF) -static const struct nvkm_device_tegra_func gk20a_platform_data = { - .iommu_bit = 34, - .require_vdd = true, -}; - -static const struct nvkm_device_tegra_func gm20b_platform_data = { - .iommu_bit = 34, - .require_vdd = true, - .require_ref_clk = true, -}; - -static const struct nvkm_device_tegra_func gp10b_platform_data = { - .iommu_bit = 36, - /* power provided by generic PM domains */ - .require_vdd = false, -}; - -static const struct of_device_id nouveau_platform_match[] = { - { - .compatible = "nvidia,gk20a", - .data = &gk20a_platform_data, - }, - { - .compatible = "nvidia,gm20b", - .data = &gm20b_platform_data, - }, - { - .compatible = "nvidia,gp10b", - .data = &gp10b_platform_data, - }, - { } -}; - -MODULE_DEVICE_TABLE(of, nouveau_platform_match); -#endif - -struct platform_driver nouveau_platform_driver = { - .driver = { - .name = "nouveau", - .of_match_table = of_match_ptr(nouveau_platform_match), - }, - .probe = nouveau_platform_probe, - .remove_new = nouveau_platform_remove, -}; diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.h b/drivers/gpu/drm/nouveau/nouveau_platform.h deleted file mode 100644 index a90d72767b8b..000000000000 --- a/drivers/gpu/drm/nouveau/nouveau_platform.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#ifndef __NOUVEAU_PLATFORM_H__ -#define __NOUVEAU_PLATFORM_H__ -#include "nouveau_drv.h" - -extern struct platform_driver nouveau_platform_driver; -#endif diff --git a/drivers/gpu/drm/nouveau/nouveau_runpm.h b/drivers/gpu/drm/nouveau/nouveau_runpm.h index 92d6c518bdad..0de62022db58 100644 --- a/drivers/gpu/drm/nouveau/nouveau_runpm.h +++ b/drivers/gpu/drm/nouveau/nouveau_runpm.h @@ -6,7 +6,7 @@ static inline struct device * nouveau_runpm_dev(struct nouveau_drm *drm) { - return drm->dev->dev; + return &drm->auxdev->dev; } static inline void diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c index cbaad3ea10eb..c4cbdf172499 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c @@ -191,13 +191,10 @@ static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switchero return 0; } -#include "nouveau_drv.h" -#include "nouveau_acpi.h" - static void nvkm_acpi_switcheroo_reprobe(struct pci_dev *pdev) { - struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + struct nvkm_device *device = pci_get_drvdata(pdev); device->driver->switcheroo.reprobe(device->driver); } @@ -206,7 +203,7 @@ static void nvkm_acpi_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state) { - struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + struct nvkm_device *device = pci_get_drvdata(pdev); if (state == VGA_SWITCHEROO_OFF) { if (nouveau_dsm_priv.dsm_detected || nouveau_dsm_priv.optimus_detected) @@ -221,7 +218,7 @@ nvkm_acpi_switcheroo_set_state(struct pci_dev *pdev, static bool nvkm_acpi_switcheroo_can_switch(struct pci_dev *pdev) { - struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + struct nvkm_device *device = pci_get_drvdata(pdev); return device->driver->switcheroo.can_switch(device->driver); } diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index a66cb9d474d5..735bf0a9931d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1618,12 +1618,10 @@ nvkm_device_pci_func = { .cpu_coherent = !IS_ENABLED(CONFIG_ARM), }; -#include "nouveau_drv.h" - static int nvkm_device_pci_pm_runtime_resume(struct device *dev) { - struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct nvkm_device *device = dev_get_drvdata(dev); struct pci_dev *pdev = nvkm_device_pci(device)->pdev; int ret; @@ -1644,7 +1642,7 @@ nvkm_device_pci_pm_runtime_resume(struct device *dev) static int nvkm_device_pci_pm_runtime_suspend(struct device *dev) { - struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct nvkm_device *device = dev_get_drvdata(dev); struct pci_dev *pdev = nvkm_device_pci(device)->pdev; nvkm_acpi_switcheroo_set_powerdown(); @@ -1659,7 +1657,7 @@ nvkm_device_pci_pm_runtime_suspend(struct device *dev) static int nvkm_device_pci_pm_resume(struct device *dev) { - struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct nvkm_device *device = dev_get_drvdata(dev); struct pci_dev *pdev = nvkm_device_pci(device)->pdev; int ret; @@ -1677,7 +1675,7 @@ nvkm_device_pci_pm_resume(struct device *dev) static int nvkm_device_pci_pm_suspend(struct device *dev) { - struct nvkm_device *device = ((struct nouveau_drm *)dev_get_drvdata(dev))->nvkm; + struct nvkm_device *device = dev_get_drvdata(dev); struct pci_dev *pdev = nvkm_device_pci(device)->pdev; pci_save_state(pdev); @@ -1698,8 +1696,12 @@ nvkm_device_pci_pm = { static void nvkm_device_pci_remove(struct pci_dev *dev) { - struct drm_device *drm_dev = pci_get_drvdata(dev); - struct nvkm_device *device = nouveau_drm(drm_dev)->nvkm; + struct nvkm_device *device = pci_get_drvdata(dev); + + if (device->runpm) { + pm_runtime_get_sync(device->dev); + pm_runtime_forbid(device->dev); + } nvkm_device_del(&device); } @@ -1855,12 +1857,36 @@ nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) } } + if (device->runpm) { + pm_runtime_allow(device->dev); + pm_runtime_put(device->dev); + } + return 0; } +static struct pci_device_id +nvkm_device_pci_id_table[] = { + { + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16, + }, + { + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16, + }, + {} +}; + struct pci_driver nvkm_device_pci_driver = { + .name = "nvkm", + .id_table = nvkm_device_pci_id_table, .probe = nvkm_device_pci_probe, .remove = nvkm_device_pci_remove, .driver.pm = &nvkm_device_pci_pm, }; + +MODULE_DEVICE_TABLE(pci, nvkm_device_pci_id_table); diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c index f0c1258170f4..743a781586c0 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c @@ -233,12 +233,10 @@ nvkm_device_tegra_func = { .cpu_coherent = false, }; -#include "nouveau_drv.h" - static void nvkm_device_tegra_remove(struct platform_device *pdev) { - struct nvkm_device *device = ((struct nouveau_drm *)platform_get_drvdata(pdev))->nvkm; + struct nvkm_device *device = platform_get_drvdata(dev); nvkm_device_del(&device); } @@ -336,11 +334,50 @@ nvkm_device_tegra_probe(struct platform_device *pdev) return ret; } +static const struct nvkm_device_tegra_func gk20a_platform_data = { + .iommu_bit = 34, + .require_vdd = true, +}; + +static const struct nvkm_device_tegra_func gm20b_platform_data = { + .iommu_bit = 34, + .require_vdd = true, + .require_ref_clk = true, +}; + +static const struct nvkm_device_tegra_func gp10b_platform_data = { + .iommu_bit = 36, + /* power provided by generic PM domains */ + .require_vdd = false, +}; + +static const struct of_device_id nouveau_platform_match[] = { + { + .compatible = "nvidia,gk20a", + .data = &gk20a_platform_data, + }, + { + .compatible = "nvidia,gm20b", + .data = &gm20b_platform_data, + }, + { + .compatible = "nvidia,gp10b", + .data = &gp10b_platform_data, + }, + { } +}; + struct platform_driver nvkm_device_tegra = { + .driver = { + .name = "nvkm", + .of_match_table = of_match_ptr(nouveau_platform_match), + }, .probe = nvkm_device_tegra_probe, .remove_new = nvkm_device_tegra_remove, }; + +MODULE_DEVICE_TABLE(of, nouveau_platform_match); #else struct platform_driver nvkm_device_tegra = { diff --git a/drivers/gpu/drm/nouveau/nvkm/module.c b/drivers/gpu/drm/nouveau/nvkm/module.c index 7a56ef8c3b6b..c14dd7fa15c2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/module.c +++ b/drivers/gpu/drm/nouveau/nvkm/module.c @@ -20,6 +20,8 @@ * DEALINGS IN THE SOFTWARE. */ #include +#include +#include #include int nvkm_runpm = -1; @@ -27,12 +29,34 @@ int nvkm_runpm = -1; void __exit nvkm_exit(void) { +#ifdef CONFIG_PCI nvkm_acpi_switcheroo_fini(); + pci_unregister_driver(&nvkm_device_pci_driver); +#endif + +#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER + platform_driver_unregister(&nvkm_device_tegra); +#endif } int __init nvkm_init(void) { + int ret; + +#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER + ret = platform_driver_register(&nvkm_device_tegra); + if (ret) + return ret; +#endif + +#ifdef CONFIG_PCI nvkm_acpi_switcheroo_init(); + + ret = pci_register_driver(&nvkm_device_pci_driver); + if (ret) + return ret; +#endif + return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c index e4737b89cb63..919e07d85f2e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c @@ -64,12 +64,10 @@ nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 value) return data; } -#include "nouveau_drv.h" - static unsigned int nvkm_pci_vga_set_decode(struct pci_dev *pdev, bool state) { - struct nvkm_device *device = ((struct nouveau_drm *)pci_get_drvdata(pdev))->nvkm; + struct nvkm_device *device = pci_get_drvdata(pdev); if (device->card_type == NV_40 && device->chipset >= 0x4c) From patchwork Thu Jun 13 17:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 13697165 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5B24FC27C4F for ; Thu, 13 Jun 2024 17:01:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B7DD10EB37; Thu, 13 Jun 2024 17:01:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.b="OBaJd/sB"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85BBE10EB08; Thu, 13 Jun 2024 17:00:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NfaWJoPUe5DPODNHN5dM1OD4Nv70M5Kw/HktJJD13Yp0o/YtBAbgO6n9Oq+Nl1tf/nlG7YYCs3ZmqUXbOCSZyTnkAj74obgT1q6PEvR+Gjgfz/i4ozblojLcVKp3kqM7F2VC2TuMcMttEUmzcrJFXT7eISMcUqlXXTIyuaRg3Ua2/YWBtIkxT055e1+HQvJelJVw+oXB7JvNyQmPXVaFYUBcrg5qvb15vzZTeCciYrxKxJTK4609a2GCfuMFqhWo6U8btg/vRp3DBbn+1+BOVE5NNygL2ME487pVyteZxrwaZmNCgWAQS3K8/31MHydXHURBBVJ4osuh/MJItRo8rg== 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=RV7AjZ+3B21X2dGN5XfZTJUji46AefPMgcv8CJzZpKE=; b=debcx53pGrfZksh4SaDzJF3Ok/U/Ttn4xM0Wz4adLeN/pRl5aRpufBY7sWtpD7G6+Vs4cjqCcEsgozM8Vrl2Qn3k7e2RoXolvr5jpjfciHB1XGATK7O+jjdYCYvcN711EV56JSkxINoKuNbZ8YIaEAPrwbzKHuR6IC4zE+YWi6xhJYjXg0IcrziogoKQlSw3UWCLxbKPHoV+CwWaKN07oP3Uji2s2dCTys1+PfTgv/nWgLim209YyMVYYexo81cjJmNF80lCMXgtReR2YtwSyhhzvnXQI+lws/skT3l9aGrQ/qyO2VAXVeNdU6LBhkY0jZ5Ko/KfcIrAPB1U2zVbIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RV7AjZ+3B21X2dGN5XfZTJUji46AefPMgcv8CJzZpKE=; b=OBaJd/sBw7+RkvD4jx7u75OjRFzDdVaREXEhoUfiPF0R6rfNerOL7aUzS7P9pOBjX0PSovBvJFHlmQ1GUUxVWiOtwDm4BibFXys9fPWU6HFX+2OHWU1r2y4J/YFG7xKdXMm26WhBpA+RzNfG0AiPSSPIQnjOE8ybO4JC6zJUf3g5zJyG2OZqGI/PY2DsnHkTzToLGIU5reksxeHsfFvToN4qk0qrnH3G0SndL0LxIh2xyzILBz8ZlfDsYmIS/yNhr2g5jcUs66rvS1tiOf7pzLdlivKLOXKApOQ0jcALDg2Fan8B1HrckXdDr6TVgN3WW8DJCzR7rv+qkfG15Th6Sg== Received: from SN4PR0501CA0044.namprd05.prod.outlook.com (2603:10b6:803:41::21) by IA1PR12MB6625.namprd12.prod.outlook.com (2603:10b6:208:3a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 17:00:31 +0000 Received: from SA2PEPF00003F65.namprd04.prod.outlook.com (2603:10b6:803:41:cafe::8a) by SN4PR0501CA0044.outlook.office365.com (2603:10b6:803:41::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20 via Frontend Transport; Thu, 13 Jun 2024 17:00:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F65.mail.protection.outlook.com (10.167.248.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Thu, 13 Jun 2024 17:00:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:08 -0700 Received: from fedora.mshome.net (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 13 Jun 2024 10:00:06 -0700 From: Ben Skeggs To: , CC: Ben Skeggs Subject: [PATCH 21/21] drm/nouveau/nvkm: s/nouveau/nvkm/ over code moved from drm Date: Fri, 14 Jun 2024 03:00:13 +1000 Message-ID: <20240613170046.88687-22-bskeggs@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240613170046.88687-1-bskeggs@nvidia.com> References: <20240613170046.88687-1-bskeggs@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F65:EE_|IA1PR12MB6625:EE_ X-MS-Office365-Filtering-Correlation-Id: c0fabad1-2179-4e17-9e69-08dc8bca556c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230035|376009|1800799019|82310400021|36860700008; X-Microsoft-Antispam-Message-Info: s8AzxOq2/C8nOUYL7fVhb9KyGCq33QOH7Yaob2fR+p2HWZBUSd1fjIxbzlPdBkI3CFdiNo+sttdEMP84A/j1dCuiHYY8kIbfFRlQSZ2d+OJF8NyB09QE3+iPzMKnzE/Tsh8/psiwnHSI9EBro33Nc27HAj5JeBOhuQFx15+NrPdJk78lHjMgXCnrF1cR1Ysi0szMhQq9hZGVO9mzpqGJ8idLnaTiEW0UcDRyX4p7aECk5zpGxmv2n6sqMkY0ko0A3UWD1rpSLSXqQ6iFNd9ehbu1Fa3QtpGd4aoQDqVY+qKop7ISUqoYGYoX55KbTO1XvySK3fNMnErwXfnU4tE5ry5l884Nb8I+PENdow+NgpwUenUU2z7rTH0Z3mWLSSzmNAHGoKtF/3VUaFZ6QXThaoprMQMh/AY8J09WEce5RYlEY2HXpfCdY9jMA2iln4yqnFZ+s1capmhZHU1lLUgNhMEqobiOVp8/BGe+sn4sC2qGWctS4LBoKAInrTwbyHq2HteETPg0Pes8L8nroR19yHXL4/nCXuK24SL5vwWUhfB/Rj9u/EhOWzTkV8uWYQ6hS7VrD0Zt/J1DHCsm9R0sW2oglZWXFWEP36FyIpoRCFU1SFo/2Ge4L5JymaVic2d1V6dRq5SHtcvi0tZZ6DUozEQJNutdI5YrugpgyWnq+Sz0SWcJ1zHP/CsZ2oIbT170c3VZGtNgJvSu/uCW6n/4h9F9XN292spXA2qbOq6KET6GIH9RZaNsc5wsSrWlI68hHCaEVkomoeeCu0kp71phfLtc0szPqEOLMxXFwzrm5sp6K1qV3HqlK9SErHICisijrZA2br0lpk82ilKCQTBvE6/jZfSHBEugQD5Qn82cYnr98R3kkVj7FT8SUWYeNLLmNlIz/cUQpCFYYS8AE2kmeddZ8FQ+JJey7pvphQT8KNg1RtYSB+4ua34X5VtaPP+DdhZeRw/u8DwUAMMAUv/0D5mYqfBVmZAGTB+QuyB+s990FyeaiXu5honCmNTG41yvxRn5uo62NaGKeZU5nm4crt8DH28VZpgAHlHrnn1+qJZmkJ3bq+sIm5KGfbB1qCsLZUEo0I23Zsvb+Ebfxb6UWxIi6w5pJU38THqD12FgS0kjFzp6sYbYJ2A2pzT+DB6LtQTzLSHyhJlFp6oLqr/XzBt87bQoYG7vW+lRlhM2+W3c8JYEWWjWuFjlBCiP8f/TCjx3ACAiJMi4ioor6khkg+U8jjm62gHMQEVtASOBRB0d5z62/BllieJWmybe03kuxLq5XSoQ9PD4HLzg6c+E8rS/eHnuAHQnVy8B/FEWrsmk5Ij1cE+wyHU70nl7VZ8i7TmjKzazaewRFthTMX1qg3tzzmORCWE3HYpoTcPsxr3cKjqS9V3+AbkYXuo4sleGPUX4NREl15OGeY5cUs0rfQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230035)(376009)(1800799019)(82310400021)(36860700008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 17:00:31.1198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0fabad1-2179-4e17-9e69-08dc8bca556c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6625 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The move and renames were kept separate for cleaner diffs. Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nvkm/device/acpi.c | 113 ++++++++++---------- drivers/gpu/drm/nouveau/nvkm/device/acpi.h | 4 +- drivers/gpu/drm/nouveau/nvkm/device/pci.c | 8 +- drivers/gpu/drm/nouveau/nvkm/device/tegra.c | 6 +- 4 files changed, 64 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c index c4cbdf172499..ff8a3027c1bc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c @@ -32,9 +32,9 @@ #include #ifdef CONFIG_VGA_SWITCHEROO -struct nouveau_dsm_priv nouveau_dsm_priv = {}; +struct nvkm_dsm_priv nvkm_dsm_priv = {}; -static const guid_t nouveau_op_dsm_muid = +static const guid_t nvkm_op_dsm_muid = GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B, 0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0); @@ -60,7 +60,7 @@ static const guid_t nouveau_op_dsm_muid = #define OPTIMUS_AUDIO_CAPS_MASK (3 << 27) #define OPTIMUS_HDA_CODEC_MASK (2 << 27) /* hda bios control */ -static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result) +static int nvkm_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result) { int i; union acpi_object *obj; @@ -76,7 +76,7 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t * args_buff[i] = (arg >> i * 8) & 0xFF; *result = 0; - obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100, + obj = acpi_evaluate_dsm_typed(handle, &nvkm_op_dsm_muid, 0x00000100, func, &argv4, ACPI_TYPE_BUFFER); if (!obj) { acpi_handle_info(handle, "failed to evaluate _DSM\n"); @@ -98,24 +98,24 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t * void nvkm_acpi_switcheroo_set_powerdown(void) { u32 result = 0; - if (!nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.optimus_skip_dsm) + if (!nvkm_dsm_priv.optimus_detected || nvkm_dsm_priv.optimus_skip_dsm) return; - if (nouveau_dsm_priv.optimus_flags_detected) - nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS, - 0x3, &result); + if (nvkm_dsm_priv.optimus_flags_detected) + nvkm_optimus_dsm(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS, + 0x3, &result); - nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, - NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result); + nvkm_optimus_dsm(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, + NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result); } /* - * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special + * On some platforms, _DSM(nvkm_op_dsm_muid, func0) has special * requirements on the fourth parameter, so a private implementation * instead of using acpi_check_dsm(). */ -static int nouveau_dsm_get_optimus_functions(acpi_handle handle) +static int nvkm_dsm_get_optimus_functions(acpi_handle handle) { int result; @@ -123,7 +123,7 @@ static int nouveau_dsm_get_optimus_functions(acpi_handle handle) * Function 0 returns a Buffer containing available functions. * The args parameter is ignored for function 0, so just put 0 in it */ - if (nouveau_optimus_dsm(handle, 0, 0, &result)) + if (nvkm_optimus_dsm(handle, 0, 0, &result)) return 0; /* @@ -135,7 +135,7 @@ static int nouveau_dsm_get_optimus_functions(acpi_handle handle) return 0; } -static const guid_t nouveau_dsm_muid = +static const guid_t nvkm_dsm_muid = GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48, 0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4); @@ -150,7 +150,7 @@ static const guid_t nouveau_dsm_muid = #define NOUVEAU_DSM_POWER_SPEED 0x01 #define NOUVEAU_DSM_POWER_STAMINA 0x02 -static int nouveau_dsm(acpi_handle handle, int func, int arg) +static int nvkm_dsm(acpi_handle handle, int func, int arg) { int ret = 0; union acpi_object *obj; @@ -159,7 +159,7 @@ static int nouveau_dsm(acpi_handle handle, int func, int arg) .integer.value = arg, }; - obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102, + obj = acpi_evaluate_dsm_typed(handle, &nvkm_dsm_muid, 0x00000102, func, &argv4, ACPI_TYPE_INTEGER); if (!obj) { acpi_handle_info(handle, "failed to evaluate _DSM\n"); @@ -173,21 +173,21 @@ static int nouveau_dsm(acpi_handle handle, int func, int arg) return ret; } -static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id) +static int nvkm_dsm_switch_mux(acpi_handle handle, int mux_id) { mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); - return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id); + return nvkm_dsm(handle, NOUVEAU_DSM_LED, mux_id); } -static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state) +static int nvkm_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state) { int arg; if (state == VGA_SWITCHEROO_ON) arg = NOUVEAU_DSM_POWER_SPEED; else arg = NOUVEAU_DSM_POWER_STAMINA; - nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg); + nvkm_dsm(handle, NOUVEAU_DSM_POWER, arg); return 0; } @@ -206,7 +206,7 @@ nvkm_acpi_switcheroo_set_state(struct pci_dev *pdev, struct nvkm_device *device = pci_get_drvdata(pdev); if (state == VGA_SWITCHEROO_OFF) { - if (nouveau_dsm_priv.dsm_detected || nouveau_dsm_priv.optimus_detected) + if (nvkm_dsm_priv.dsm_detected || nvkm_dsm_priv.optimus_detected) return; nvkm_acpi_switcheroo_set_powerdown(); @@ -230,31 +230,31 @@ nvkm_acpi_switcheroo_ops = { .reprobe = nvkm_acpi_switcheroo_reprobe, }; -static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id) +static int nvkm_dsm_switchto(enum vga_switcheroo_client_id id) { - if (!nouveau_dsm_priv.dsm_detected) + if (!nvkm_dsm_priv.dsm_detected) return 0; if (id == VGA_SWITCHEROO_IGD) - return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA); + return nvkm_dsm_switch_mux(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA); else - return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED); + return nvkm_dsm_switch_mux(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED); } -static int nouveau_dsm_power_state(enum vga_switcheroo_client_id id, +static int nvkm_dsm_power_state(enum vga_switcheroo_client_id id, enum vga_switcheroo_state state) { if (id == VGA_SWITCHEROO_IGD) return 0; /* Optimus laptops have the card already disabled in - * nouveau_switcheroo_set_state */ - if (!nouveau_dsm_priv.dsm_detected) + * nvkm_switcheroo_set_state */ + if (!nvkm_dsm_priv.dsm_detected) return 0; - return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state); + return nvkm_dsm_set_discrete_state(nvkm_dsm_priv.dhandle, state); } -static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *pdev) +static enum vga_switcheroo_client_id nvkm_dsm_get_client_id(struct pci_dev *pdev) { /* easy option one - intel vendor ID means Integrated */ if (pdev->vendor == PCI_VENDOR_ID_INTEL) @@ -267,15 +267,15 @@ static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *p return VGA_SWITCHEROO_DIS; } -static const struct vga_switcheroo_handler nouveau_dsm_handler = { - .switchto = nouveau_dsm_switchto, - .power_state = nouveau_dsm_power_state, - .get_client_id = nouveau_dsm_get_client_id, +static const struct vga_switcheroo_handler nvkm_dsm_handler = { + .switchto = nvkm_dsm_switchto, + .power_state = nvkm_dsm_power_state, + .get_client_id = nvkm_dsm_get_client_id, }; -static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out, - bool *has_mux, bool *has_opt, - bool *has_opt_flags, bool *has_pr3) +static void nvkm_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out, + bool *has_mux, bool *has_opt, + bool *has_opt_flags, bool *has_pr3) { acpi_handle dhandle; bool supports_mux; @@ -301,9 +301,9 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out if (!acpi_has_method(dhandle, "_DSM")) return; - supports_mux = acpi_check_dsm(dhandle, &nouveau_dsm_muid, 0x00000102, + supports_mux = acpi_check_dsm(dhandle, &nvkm_dsm_muid, 0x00000102, 1 << NOUVEAU_DSM_POWER); - optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle); + optimus_funcs = nvkm_dsm_get_optimus_functions(dhandle); /* Does not look like a Nvidia device. */ if (!supports_mux && !optimus_funcs) @@ -316,8 +316,7 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out if (optimus_funcs) { uint32_t result; - nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, - &result); + nvkm_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, &result); dev_info(&pdev->dev, "optimus capabilities: %s, status %s%s\n", (result & OPTIMUS_ENABLED) ? "enabled" : "disabled", (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "", @@ -325,7 +324,7 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out } } -static bool nouveau_dsm_detect(void) +static bool nvkm_dsm_detect(void) { char acpi_method_name[255] = { 0 }; struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name}; @@ -353,30 +352,28 @@ static bool nouveau_dsm_detect(void) vga_count++; - nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus, - &has_optimus_flags, &has_power_resources); + nvkm_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus, + &has_optimus_flags, &has_power_resources); } /* find the optimus DSM or the old v1 DSM */ if (has_optimus) { - nouveau_dsm_priv.dhandle = dhandle; - acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, - &buffer); + nvkm_dsm_priv.dhandle = dhandle; + acpi_get_name(nvkm_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); pr_info("VGA switcheroo: detected Optimus DSM method %s handle\n", acpi_method_name); if (has_power_resources) - pr_info("nouveau: detected PR support, will not use DSM\n"); - nouveau_dsm_priv.optimus_detected = true; - nouveau_dsm_priv.optimus_flags_detected = has_optimus_flags; - nouveau_dsm_priv.optimus_skip_dsm = has_power_resources; + pr_info("nvkm: detected PR support, will not use DSM\n"); + nvkm_dsm_priv.optimus_detected = true; + nvkm_dsm_priv.optimus_flags_detected = has_optimus_flags; + nvkm_dsm_priv.optimus_skip_dsm = has_power_resources; ret = true; } else if (vga_count == 2 && has_mux && guid_valid) { - nouveau_dsm_priv.dhandle = dhandle; - acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, - &buffer); + nvkm_dsm_priv.dhandle = dhandle; + acpi_get_name(nvkm_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); pr_info("VGA switcheroo: detected DSM switching method %s handle\n", acpi_method_name); - nouveau_dsm_priv.dsm_detected = true; + nvkm_dsm_priv.dsm_detected = true; ret = true; } @@ -387,7 +384,7 @@ static bool nouveau_dsm_detect(void) void nvkm_acpi_switcheroo_fini(void) { - if (nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.dsm_detected) + if (nvkm_dsm_priv.optimus_detected || nvkm_dsm_priv.dsm_detected) vga_switcheroo_unregister_handler(); } @@ -396,11 +393,11 @@ nvkm_acpi_switcheroo_init(void) { bool r; - r = nouveau_dsm_detect(); + r = nvkm_dsm_detect(); if (!r) return; - vga_switcheroo_register_handler(&nouveau_dsm_handler, 0); + vga_switcheroo_register_handler(&nvkm_dsm_handler, 0); } #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h index 34854d10026d..2dd8a3029b55 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h +++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h @@ -8,13 +8,13 @@ void nvkm_acpi_init(struct nvkm_device *); void nvkm_acpi_fini(struct nvkm_device *); #ifdef CONFIG_VGA_SWITCHEROO -extern struct nouveau_dsm_priv { +extern struct nvkm_dsm_priv { bool dsm_detected; bool optimus_detected; bool optimus_flags_detected; bool optimus_skip_dsm; acpi_handle dhandle; -} nouveau_dsm_priv; +} nvkm_dsm_priv; void nvkm_acpi_switcheroo_init(void); void nvkm_acpi_switcheroo_fini(void); diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c index 735bf0a9931d..8eb3a66f53d6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c @@ -1720,8 +1720,8 @@ nvkm_device_pci_remove(struct pci_dev *dev) * to handle well enough. * * In all cases dmesg will contain at least one line like this: - * 'nouveau 0000:01:00.0: Refused to change power state, currently in D3' - * followed by a lot of nouveau timeouts. + * 'nvkm 0000:01:00.0: Refused to change power state, currently in D3' + * followed by a lot of nvkm timeouts. * * In the \_SB.PCI0.PEG0.PG00._OFF code deeper down writes bit 0x80 to the not * documented PCI config space register 0x248 of the Intel PCIe bridge @@ -1849,8 +1849,8 @@ nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) pci_set_drvdata(pci_dev, &pdev->device); if (nvkm_runpm) { - if (!nouveau_dsm_priv.optimus_detected) { - if (nouveau_dsm_priv.dsm_detected) + if (!nvkm_dsm_priv.optimus_detected) { + if (nvkm_dsm_priv.dsm_detected) device->runpm = NVKM_DEVICE_RUNPM_V1; } else { device->runpm = NVKM_DEVICE_RUNPM_OPTIMUS; diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c index 743a781586c0..75ce47f25e19 100644 --- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c @@ -351,7 +351,7 @@ static const struct nvkm_device_tegra_func gp10b_platform_data = { .require_vdd = false, }; -static const struct of_device_id nouveau_platform_match[] = { +static const struct of_device_id nvkm_platform_match[] = { { .compatible = "nvidia,gk20a", .data = &gk20a_platform_data, @@ -371,13 +371,13 @@ struct platform_driver nvkm_device_tegra = { .driver = { .name = "nvkm", - .of_match_table = of_match_ptr(nouveau_platform_match), + .of_match_table = of_match_ptr(nvkm_platform_match), }, .probe = nvkm_device_tegra_probe, .remove_new = nvkm_device_tegra_remove, }; -MODULE_DEVICE_TABLE(of, nouveau_platform_match); +MODULE_DEVICE_TABLE(of, nvkm_platform_match); #else struct platform_driver nvkm_device_tegra = {