NetBSD Problem Report #57119

From reinoud@gorilla.13thmonkey.org  Sun Dec 18 15:28:37 2022
Return-Path: <reinoud@gorilla.13thmonkey.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 354DC1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 18 Dec 2022 15:28:37 +0000 (UTC)
Message-Id: <20221218152833.3D9C22FF07B2@gorilla.13thmonkey.org>
Date: Sun, 18 Dec 2022 16:28:33 +0100 (CET)
From: reinoud@13thmonkey.org
Reply-To: reinoud@13thmonkey.org
To: gnats-bugs@NetBSD.org
Subject: Add trivial amdsmn(4) / amdccpi(4) pmf code to allow for sleeping
X-Send-Pr-Version: 3.95

>Number:         57119
>Category:       port-amd64
>Synopsis:       Add trivial amdsmn(4) / amdccp(4) pmf code to allow for sleeping
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 18 15:30:00 +0000 2022
>Closed-Date:    Sun Dec 18 16:02:33 +0000 2022
>Last-Modified:  Sun Dec 18 16:02:33 +0000 2022
>Originator:     Reinoud Zandijk
>Release:        NetBSD 9.99.107
>Organization:

>Environment:


System: NetBSD gorilla.13thmonkey.org 9.99.107 NetBSD 9.99.107 (GENERIC) #0: Wed Dec 14 13:12:41 CET 2022 reinoud@gorilla.13thmonkey.org:/tmp/obj-bisect/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
The machine won't attempt to sleep since the amdccp(4) and amdsmn(4) drivers
have no power management support code.

>How-To-Repeat:

Try to sleep the amd64 machine and it will complain about the two devices not
having power management.
>Fix:
Apply the following patch:
Index: sys/arch/x86/pci/amdsmn.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/pci/amdsmn.c,v
retrieving revision 1.14
diff -u -p -r1.14 amdsmn.c
--- sys/arch/x86/pci/amdsmn.c	1 Oct 2022 15:50:05 -0000	1.14
+++ sys/arch/x86/pci/amdsmn.c	18 Dec 2022 15:19:13 -0000
@@ -159,6 +159,10 @@ amdsmn_attach(device_t parent, device_t 

 	// aprint_normal(": AMD Family 17h System Management Network\n");
 	aprint_normal(": AMD System Management Network\n");
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	amdsmn_rescan(self, NULL, NULL);
 }

@@ -178,6 +182,8 @@ amdsmn_detach(device_t self, int flags)
 {
 	struct amdsmn_softc *sc = device_private(self);

+	pmf_device_deregister(self);
+
 	mutex_destroy(&sc->smn_lock);
 	aprint_normal_dev(self,"detach!\n");

Index: sys/dev/acpi/amdccp_acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/amdccp_acpi.c,v
retrieving revision 1.5
diff -u -p -r1.5 amdccp_acpi.c
--- sys/dev/acpi/amdccp_acpi.c	29 Jan 2021 15:49:55 -0000	1.5
+++ sys/dev/acpi/amdccp_acpi.c	18 Dec 2022 15:19:14 -0000
@@ -104,6 +104,9 @@ amdccp_acpi_attach(device_t parent, devi

 	amdccp_common_attach(sc);

+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 done:
 	acpi_resource_cleanup(&res);
 }
Index: sys/dev/fdt/amdccp_fdt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/fdt/amdccp_fdt.c,v
retrieving revision 1.6
diff -u -p -r1.6 amdccp_fdt.c
--- sys/dev/fdt/amdccp_fdt.c	27 Jan 2021 03:10:21 -0000	1.6
+++ sys/dev/fdt/amdccp_fdt.c	18 Dec 2022 15:19:14 -0000
@@ -89,4 +89,7 @@ amdccp_fdt_attach(device_t parent, devic
 	aprint_normal(": AMD CCP\n");

 	amdccp_common_attach(sc);
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
Index: sys/dev/pci/amdccp_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/amdccp_pci.c,v
retrieving revision 1.3
diff -u -p -r1.3 amdccp_pci.c
--- sys/dev/pci/amdccp_pci.c	26 Oct 2022 13:35:25 -0000	1.3
+++ sys/dev/pci/amdccp_pci.c	18 Dec 2022 15:19:14 -0000
@@ -122,4 +122,7 @@ amdccp_pci_attach(device_t parent, devic
 	}

 	amdccp_common_attach(sc);
+
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }



>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: reinoud@NetBSD.org
State-Changed-When: Sun, 18 Dec 2022 16:02:33 +0000
State-Changed-Why:
The patches are comitted with a small change.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.