NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/57325: Crash on boot w/ amdgpu driver on Lenovo ThinkCentre M75n



The following reply was made to PR kern/57325; it has been noted by GNATS.

From: Germain Le Chapelain <germain%lanvaux.ca@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57325: Crash on boot w/ amdgpu driver on Lenovo
 ThinkCentre M75n
Date: Wed, 12 Jul 2023 17:40:44 -0700

 Following is the patch to get to problem 57059
 
 I think it's good to check-in!
 
 Kindest regards,
 -- 
 Germain Le Chapelain <germain.lechapelain%lanvaux.fr@localhost>
 
 Index: sys/arch/amd64/conf/GENERIC
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
 retrieving revision 1.602
 diff -u -r1.602 GENERIC
 --- sys/arch/amd64/conf/GENERIC	12 Apr 2023 06:39:15 -0000	1.602
 +++ sys/arch/amd64/conf/GENERIC	13 Jul 2023 00:15:10 -0000
 @@ -461,8 +461,8 @@
  radeon* 	at pci? dev ? function ?
  radeondrmkmsfb* at radeonfbbus?
  
 -#amdgpu*	at pci? dev ? function ?
 -#amdgpufb*	at amdgpufbbus?
 +amdgpu*	at pci? dev ? function ?
 +amdgpufb*	at amdgpufbbus?
  
  nouveau*	at pci? dev ? function ?
  nouveaufb*	at nouveaufbbus?
 Index: sys/external/bsd/drm2/amdgpu/files.amdgpu
 ===================================================================
 RCS file: /cvsroot/src/sys/external/bsd/drm2/amdgpu/files.amdgpu,v
 retrieving revision 1.29
 diff -u -r1.29 files.amdgpu
 --- sys/external/bsd/drm2/amdgpu/files.amdgpu	24 Jul 2022 20:05:00 -0000	1.29
 +++ sys/external/bsd/drm2/amdgpu/files.amdgpu	13 Jul 2023 00:15:12 -0000
 @@ -32,7 +32,10 @@
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-I$S/external/bsd/drm2/dist/drm/amd/display/amdgpu_dm"
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-I$S/external/bsd/drm2/dist/drm/amd/display/dmub/inc"
  
 +makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_ACPI=1"
 +makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DNACPICA=1"
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_DRM_AMD_ACP=1"
 +makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_DRM_AMD_DC=1"
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_DRM_AMD_DC_DCN=1"
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_DRM_AMD_DC_HDCP=1"
  makeoptions	amdgpu	"CPPFLAGS.amdgpu"+="-DCONFIG_PERF_EVENTS=0"
 @@ -353,7 +356,7 @@
  file	external/bsd/drm2/dist/drm/amd/amdgpu/../powerplay/smumgr/amdgpu_vega20_smumgr.c	amdgpu
  file	external/bsd/drm2/dist/drm/amd/amdgpu/../powerplay/smumgr/amdgpu_vegam_smumgr.c	amdgpu
  file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acp.c	amdgpu
 -#file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c	amdgpu
 +file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c	amdgpu
  file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_afmt.c	amdgpu
  file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_amdkfd.c	amdgpu
  file	external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_arct_reg_init.c	amdgpu
 Index: sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c
 ===================================================================
 RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c,v
 retrieving revision 1.5
 diff -u -r1.5 amdgpu_acpi.c
 --- sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c	27 Feb 2022 14:24:26 -0000	1.5
 +++ sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c	13 Jul 2023 00:15:12 -0000
 @@ -40,6 +40,9 @@
  #include "amd_acpi.h"
  #include "atom.h"
  
 +#include <linux/nbsd-namespace.h>
 +#include <linux/nbsd-namespace-acpi.h>
 +
  struct amdgpu_atif_notification_cfg {
  	bool enabled;
  	int command_code;
 @@ -362,6 +365,7 @@
  	return err;
  }
  
 +#ifndef __NetBSD__
  /**
   * amdgpu_atif_get_sbios_requests - get requested sbios event
   *
 @@ -487,6 +491,7 @@
  	 */
  	return NOTIFY_BAD;
  }
 +#endif
  
  /* Call the ATCS method
   */
 @@ -635,7 +640,12 @@
  	struct amdgpu_atcs *atcs = &adev->atcs;
  
  	/* Get the device handle */
 +#if defined(__NetBSD__)
 +	handle = (adev->pdev->pd_ad ? adev->pdev->pd_ad->ad_handle
 +		  : NULL);
 +#else
  	handle = ACPI_HANDLE(&adev->pdev->dev);
 +#endif
  	if (!handle)
  		return -EINVAL;
  
 @@ -678,7 +688,12 @@
  		return -EINVAL;
  
  	/* Get the device handle */
 +#if defined(__NetBSD__)
 +	handle = (adev->pdev->pd_ad ? adev->pdev->pd_ad->ad_handle
 +		  : NULL);
 +#else
  	handle = ACPI_HANDLE(&adev->pdev->dev);
 +#endif
  	if (!handle)
  		return -EINVAL;
  
 @@ -695,8 +710,13 @@
  	atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
  	atcs_input.perf_req = perf_req;
  
 +#if defined(__NetBSD__)
 +	params.Length = sizeof(struct atcs_pref_req_input);
 +	params.Pointer = &atcs_input;
 +#else
  	params.length = sizeof(struct atcs_pref_req_input);
  	params.pointer = &atcs_input;
 +#endif
  
  	while (retry--) {
  		info = amdgpu_atcs_call(handle, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST, &params);
 @@ -747,6 +767,9 @@
  			     unsigned long val,
  			     void *data)
  {
 +#ifdef __NetBSD__
 +	return 0;
 +#else
  	struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, acpi_nb);
  	struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
  
 @@ -761,6 +784,7 @@
  
  	/* Check for pending SBIOS requests */
  	return amdgpu_atif_handler(adev, entry);
 +#endif
  }
  
  /* Call all ACPI methods here */
 @@ -781,7 +805,12 @@
  	int ret;
  
  	/* Get the device handle */
 +#if defined(__NetBSD__)
 +	handle = (adev->pdev->pd_ad ? adev->pdev->pd_ad->ad_handle
 +		  : NULL);
 +#else
  	handle = ACPI_HANDLE(&adev->pdev->dev);
 +#endif
  
  	if (!adev->bios || !handle)
  		return 0;
 @@ -863,7 +892,9 @@
  
  out:
  	adev->acpi_nb.notifier_call = amdgpu_acpi_event;
 +#ifndef __NetBSD__
  	register_acpi_notifier(&adev->acpi_nb);
 +#endif
  
  	return ret;
  }
 @@ -889,6 +920,8 @@
   */
  void amdgpu_acpi_fini(struct amdgpu_device *adev)
  {
 +#ifndef __NetBSD__
  	unregister_acpi_notifier(&adev->acpi_nb);
 +#endif
  	kfree(adev->atif);
  }
 Index: sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h
 ===================================================================
 RCS file: /cvsroot/src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h,v
 retrieving revision 1.1
 diff -u -r1.1 nbsd-namespace-acpi.h
 --- sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h	27 Feb 2022 14:22:42 -0000	1.1
 +++ sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h	13 Jul 2023 00:15:13 -0000
 @@ -39,6 +39,7 @@
  #define	type		Type
  #define	value		Value
  
 +#define	acpi_get_name		AcpiGetName
  #define	acpi_get_handle		AcpiGetHandle
  #define	acpi_get_table		AcpiGetTable
  #define	acpi_evaluate_object	AcpiEvaluateObject
 Index: sys/modules/amdgpu/Makefile
 ===================================================================
 RCS file: /cvsroot/src/sys/modules/amdgpu/Makefile,v
 retrieving revision 1.5
 diff -u -r1.5 Makefile
 --- sys/modules/amdgpu/Makefile	30 Jul 2022 03:29:52 -0000	1.5
 +++ sys/modules/amdgpu/Makefile	13 Jul 2023 00:15:14 -0000
 @@ -34,7 +34,10 @@
  CPPFLAGS+=	-I${S}/external/bsd/drm2/dist/drm/amd/display/modules/hdcp
  CPPFLAGS+=	-I${S}/external/bsd/drm2/dist/drm/amd/display/amdgpu_dm
  CPPFLAGS+=	-I${S}/external/bsd/drm2/dist/drm/amd/display/dmub/inc
 +CPPFLAGS+=	-DCONFIG_ACPI=1
 +CPPFLAGS+=	-DNACPICA=1
  CPPFLAGS+=	-DCONFIG_DRM_AMD_ACP=1
 +CPPFLAGS+=	-DCONFIG_DRM_AMD_DC=1
  CPPFLAGS+=	-DCONFIG_DRM_AMD_DC_DCN=1
  CPPFLAGS+=	-DCONFIG_DRM_AMD_DC_HDCP=1
  CPPFLAGS+=	-DCONFIG_PERF_EVENTS=0
 @@ -143,6 +146,7 @@
  # sed -ne 's,^file	external/bsd/drm2/.*/\([^/ 	]*\)	.*,SRCS+=	\1,gp' <files.amdgpu | sort -u
  SRCS+=	amdgpu_acp.c
  SRCS+=	amdgpu_acp_hw.c
 +SRCS+=	amdgpu_acpi.c
  SRCS+=	amdgpu_afmt.c
  SRCS+=	amdgpu_amd_powerplay.c
  SRCS+=	amdgpu_amdkfd.c
 



Home | Main Index | Thread Index | Old Index