Module Name: src
Committed By: riastradh
Date: Tue Apr 16 14:34:03 UTC 2024
Modified Files:
src/sys/external/bsd/drm2/amdgpu: files.amdgpu
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu.h amdgpu_acpi.c
src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr: amdgpu_hwmgr.c
amdgpu_smu7_hwmgr.c
src/sys/external/bsd/drm2/dist/drm/i915: i915_drv.h
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_acpi.h
intel_opregion.h
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_acpi.c
nouveau_acpi.h nouveau_display.c nouveau_drv.h
src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core: device.h
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device:
nouveau_nvkm_engine_device_acpi.c nouveau_nvkm_engine_device_base.c
nouveau_nvkm_engine_device_pci.c nouveau_nvkm_engine_device_tegra.c
priv.h
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios:
nouveau_nvkm_subdev_bios_shadowacpi.c
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm:
nouveau_nvkm_subdev_mxm_base.c
src/sys/external/bsd/drm2/dist/drm/radeon: radeon.h radeon_acpi.c
radeon_bios.c radeon_drv.h
src/sys/external/bsd/drm2/include/acpi: video.h
src/sys/external/bsd/drm2/include/linux: acpi.h nbsd-namespace-acpi.h
src/sys/external/bsd/drm2/nouveau: files.nouveau
src/sys/external/bsd/drm2/radeon: files.radeon
src/sys/modules/amdgpu: Makefile
Added Files:
src/sys/external/bsd/drm2/include/acpi: acpi_bus.h
src/sys/external/bsd/drm2/include/linux: mxm-wmi.h
Log Message:
drm: Set CONFIG_ACPI in linux/acpi.h and make it build.
Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/external/bsd/drm2/amdgpu/files.amdgpu
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c
cvs rdiff -u -r1.48 -r1.49 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c
\
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c
\
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/include/acpi/acpi_bus.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/include/acpi/video.h
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/drm2/include/linux/acpi.h
cvs rdiff -u -r0 -r1.1 src/sys/external/bsd/drm2/include/linux/mxm-wmi.h
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h
cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/nouveau/files.nouveau
cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/radeon/files.radeon
cvs rdiff -u -r1.8 -r1.9 src/sys/modules/amdgpu/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/amdgpu/files.amdgpu
diff -u src/sys/external/bsd/drm2/amdgpu/files.amdgpu:1.30 src/sys/external/bsd/drm2/amdgpu/files.amdgpu:1.31
--- src/sys/external/bsd/drm2/amdgpu/files.amdgpu:1.30 Fri Jul 14 13:05:59 2023
+++ src/sys/external/bsd/drm2/amdgpu/files.amdgpu Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.amdgpu,v 1.30 2023/07/14 13:05:59 riastradh Exp $
+# $NetBSD: files.amdgpu,v 1.31 2024/04/16 14:34:01 riastradh Exp $
version 20180827
@@ -354,7 +354,7 @@ file external/bsd/drm2/dist/drm/amd/amdg
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: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h:1.8 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h:1.9
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h:1.8 Sat Oct 8 19:06:30 2022
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu.h,v 1.8 2022/10/08 19:06:30 riastradh Exp $ */
+/* $NetBSD: amdgpu.h,v 1.9 2024/04/16 14:34:01 riastradh Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
@@ -46,6 +46,7 @@
#include <linux/rbtree.h>
#include <linux/hashtable.h>
#include <linux/dma-fence.h>
+#include <linux/acpi.h>
#include <drm/ttm/ttm_bo_api.h>
#include <drm/ttm/ttm_bo_driver.h>
Index: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c:1.5 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c:1.5 Sun Feb 27 14:24:26 2022
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu_acpi.c,v 1.5 2022/02/27 14:24:26 riastradh Exp $ */
+/* $NetBSD: amdgpu_acpi.c,v 1.6 2024/04/16 14:34:01 riastradh Exp $ */
/*
* Copyright 2012 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_acpi.c,v 1.5 2022/02/27 14:24:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_acpi.c,v 1.6 2024/04/16 14:34:01 riastradh Exp $");
#include <linux/pci.h>
#include <linux/acpi.h>
@@ -40,6 +40,14 @@ __KERNEL_RCSID(0, "$NetBSD: amdgpu_acpi.
#include "amd_acpi.h"
#include "atom.h"
+#ifdef __NetBSD__
+#include <dev/acpi/acpi_pci.h>
+#include <dev/acpi/acpireg.h>
+#define _COMPONENT ACPI_DISPLAY_COMPONENT
+ACPI_MODULE_NAME("radeon_acpi")
+#include <linux/nbsd-namespace-acpi.h>
+#endif
+
struct amdgpu_atif_notification_cfg {
bool enabled;
int command_code;
@@ -362,6 +370,8 @@ out:
return err;
}
+#ifndef __NetBSD__ /* XXX amdgpu acpi */
+
/**
* amdgpu_atif_get_sbios_requests - get requested sbios event
*
@@ -488,6 +498,8 @@ static int amdgpu_atif_handler(struct am
return NOTIFY_BAD;
}
+#endif /* __NetBSD__ */
+
/* Call the ATCS method
*/
/**
@@ -635,7 +647,17 @@ int amdgpu_acpi_pcie_notify_device_ready
struct amdgpu_atcs *atcs = &adev->atcs;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &adev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&adev->pdev->dev);
+#endif
if (!handle)
return -EINVAL;
@@ -678,7 +700,17 @@ int amdgpu_acpi_pcie_performance_request
return -EINVAL;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &adev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&adev->pdev->dev);
+#endif
if (!handle)
return -EINVAL;
@@ -743,6 +775,7 @@ int amdgpu_acpi_pcie_performance_request
* acpi events.
* Returns NOTIFY code
*/
+#ifndef __NetBSD__ /* XXX amdgpu acpi */
static int amdgpu_acpi_event(struct notifier_block *nb,
unsigned long val,
void *data)
@@ -762,6 +795,7 @@ static int amdgpu_acpi_event(struct noti
/* Check for pending SBIOS requests */
return amdgpu_atif_handler(adev, entry);
}
+#endif
/* Call all ACPI methods here */
/**
@@ -781,7 +815,17 @@ int amdgpu_acpi_init(struct amdgpu_devic
int ret;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &adev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&adev->pdev->dev);
+#endif
if (!adev->bios || !handle)
return 0;
@@ -862,8 +906,10 @@ int amdgpu_acpi_init(struct amdgpu_devic
}
out:
+#ifndef __NetBSD__ /* XXX amdgpu acpi */
adev->acpi_nb.notifier_call = amdgpu_acpi_event;
register_acpi_notifier(&adev->acpi_nb);
+#endif
return ret;
}
@@ -889,6 +935,8 @@ void amdgpu_acpi_get_backlight_caps(stru
*/
void amdgpu_acpi_fini(struct amdgpu_device *adev)
{
+#ifndef __NetBSD__ /* XXX radeon acpi */
unregister_acpi_notifier(&adev->acpi_nb);
+#endif
kfree(adev->atif);
}
Index: src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c:1.2 src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c:1.2 Sat Dec 18 23:45:26 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu_hwmgr.c,v 1.2 2021/12/18 23:45:26 riastradh Exp $ */
+/* $NetBSD: amdgpu_hwmgr.c,v 1.3 2024/04/16 14:34:01 riastradh Exp $ */
/*
* Copyright 2015 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_hwmgr.c,v 1.2 2021/12/18 23:45:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_hwmgr.c,v 1.3 2024/04/16 14:34:01 riastradh Exp $");
#include "pp_debug.h"
#include <linux/delay.h>
@@ -32,6 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdgpu_hwmgr
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/pci.h>
+#include <linux/acpi.h>
#include <drm/amdgpu_drm.h>
#include "power_state.h"
#include "hwmgr.h"
Index: src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c:1.4 src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c:1.4 Sun Dec 19 12:37:54 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu_smu7_hwmgr.c,v 1.4 2021/12/19 12:37:54 riastradh Exp $ */
+/* $NetBSD: amdgpu_smu7_hwmgr.c,v 1.5 2024/04/16 14:34:01 riastradh Exp $ */
/*
* Copyright 2015 Advanced Micro Devices, Inc.
@@ -23,7 +23,7 @@
*
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_smu7_hwmgr.c,v 1.4 2021/12/19 12:37:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_smu7_hwmgr.c,v 1.5 2024/04/16 14:34:01 riastradh Exp $");
#include "pp_debug.h"
#include <linux/delay.h>
@@ -31,6 +31,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdgpu_smu7_
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
+#include <linux/acpi.h>
#include <asm/div64.h>
#include <drm/amdgpu_drm.h>
#include "ppatomctrl.h"
Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.48 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.49
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.48 Thu Sep 22 14:37:38 2022
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_drv.h,v 1.48 2022/09/22 14:37:38 riastradh Exp $ */
+/* $NetBSD: i915_drv.h,v 1.49 2024/04/16 14:34:02 riastradh Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
@@ -32,15 +32,6 @@
#ifndef _I915_DRV_H_
#define _I915_DRV_H_
-#if defined(__NetBSD__)
-#ifdef _KERNEL_OPT
-#include "acpica.h"
-#endif /* _KERNEL_OPT */
-#if (NACPICA > 0)
-#define CONFIG_ACPI
-#endif /* NACPICA > 0 */
-#endif /* __NetBSD__ */
-
#include <uapi/drm/i915_drm.h>
#include <uapi/drm/drm_fourcc.h>
@@ -59,6 +50,7 @@
#include <linux/stackdepot.h>
#include <linux/xarray.h>
#include <linux/uuid.h>
+#include <linux/acpi.h>
#include <drm/intel-gtt.h>
#include <drm/drm_legacy.h> /* for struct drm_dma_handle */
Index: src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h:1.4 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h:1.4 Sun Dec 19 11:16:17 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_acpi.h,v 1.4 2021/12/19 11:16:17 riastradh Exp $ */
+/* $NetBSD: intel_acpi.h,v 1.5 2024/04/16 14:34:01 riastradh Exp $ */
/* SPDX-License-Identifier: MIT */
/*
@@ -8,6 +8,8 @@
#ifndef __INTEL_ACPI_H__
#define __INTEL_ACPI_H__
+#include <linux/acpi.h>
+
struct drm_i915_private;
#ifdef CONFIG_ACPI
Index: src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h:1.5 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h:1.5 Sun Feb 27 21:22:01 2022
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h Tue Apr 16 14:34:01 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_opregion.h,v 1.5 2022/02/27 21:22:01 riastradh Exp $ */
+/* $NetBSD: intel_opregion.h,v 1.6 2024/04/16 14:34:01 riastradh Exp $ */
/*
* Copyright © 2008-2017 Intel Corporation
@@ -29,6 +29,7 @@
#include <linux/workqueue.h>
#include <linux/pci.h>
+#include <linux/acpi.h>
struct drm_i915_private;
struct intel_encoder;
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c:1.4 Sun Feb 27 14:24:27 2022
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c Tue Apr 16 14:34:02 2024
@@ -1,8 +1,8 @@
-/* $NetBSD: nouveau_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $ */
+/* $NetBSD: nouveau_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */
// SPDX-License-Identifier: MIT
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $");
#include <linux/pci.h>
#include <linux/acpi.h>
@@ -15,6 +15,13 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_acpi
#include "nouveau_drv.h"
#include "nouveau_acpi.h"
+#ifdef __NetBSD__
+#include <dev/acpi/acpireg.h>
+#define _COMPONENT ACPI_DISPLAY_COMPONENT
+ACPI_MODULE_NAME("nouveau_acpi")
+#include <linux/nbsd-namespace-acpi.h>
+#endif
+
#define NOUVEAU_DSM_LED 0x02
#define NOUVEAU_DSM_LED_STATE 0x00
#define NOUVEAU_DSM_LED_OFF 0x10
@@ -256,7 +263,11 @@ static void nouveau_dsm_pci_probe(struct
bool supports_mux;
int optimus_funcs;
+#ifdef __NetBSD__
+ dhandle = pdev->pd_ad->ad_handle;
+#else
dhandle = ACPI_HANDLE(&pdev->dev);
+#endif
if (!dhandle)
return;
@@ -421,12 +432,20 @@ static int nouveau_rom_call(acpi_handle
return len;
}
+#ifdef __NetBSD__
+bool nouveau_acpi_rom_supported(struct acpi_devnode *acpidev)
+#else
bool nouveau_acpi_rom_supported(struct device *dev)
+#endif
{
acpi_status status;
acpi_handle dhandle, rom_handle;
+#ifdef __NetBSD__
+ dhandle = (acpidev ? acpidev->ad_handle : NULL);
+#else
dhandle = ACPI_HANDLE(dev);
+#endif
if (!dhandle)
return false;
@@ -446,6 +465,9 @@ int nouveau_acpi_get_bios_chunk(uint8_t
void *
nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector)
{
+#ifdef __NetBSD__ /* XXX nouveau acpi video */
+ return NULL;
+#else
struct acpi_device *acpidev;
acpi_handle handle;
int type, ret;
@@ -460,7 +482,11 @@ nouveau_acpi_edid(struct drm_device *dev
return NULL;
}
+#ifdef __NetBSD__
+ handle = (dev->pdev->pd_ad ? dev->pdev->pd_ad->ad_handle : NULL);
+#else
handle = ACPI_HANDLE(&dev->pdev->dev);
+#endif
if (!handle)
return NULL;
@@ -473,4 +499,5 @@ nouveau_acpi_edid(struct drm_device *dev
return NULL;
return kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
+#endif
}
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h:1.5
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h:1.4 Sat May 21 17:50:21 2022
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_drv.h,v 1.4 2022/05/21 17:50:21 riastradh Exp $ */
+/* $NetBSD: nouveau_drv.h,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */
/* SPDX-License-Identifier: MIT */
#ifndef __NOUVEAU_DRV_H__
@@ -40,6 +40,7 @@
* - implemented limited ABI16/NVIF interop
*/
+#include <linux/acpi.h>
#include <linux/notifier.h>
#include <nvif/client.h>
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h:1.3 Sat Dec 18 23:45:32 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h Tue Apr 16 14:34:02 2024
@@ -1,9 +1,11 @@
-/* $NetBSD: nouveau_acpi.h,v 1.3 2021/12/18 23:45:32 riastradh Exp $ */
+/* $NetBSD: nouveau_acpi.h,v 1.4 2024/04/16 14:34:02 riastradh Exp $ */
/* SPDX-License-Identifier: MIT */
#ifndef __NOUVEAU_ACPI_H__
#define __NOUVEAU_ACPI_H__
+#include <linux/acpi.h>
+
#define ROM_BIOS_PAGE 4096
#if defined(CONFIG_ACPI) && defined(CONFIG_X86)
@@ -13,7 +15,11 @@ void nouveau_register_dsm_handler(void);
void nouveau_unregister_dsm_handler(void);
void nouveau_switcheroo_optimus_dsm(void);
int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);
+#ifdef __NetBSD__
+bool nouveau_acpi_rom_supported(struct acpi_devnode *);
+#else
bool nouveau_acpi_rom_supported(struct device *);
+#endif
void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *);
#else
static inline bool nouveau_is_optimus(void) { return false; };
@@ -21,7 +27,11 @@ static inline bool nouveau_is_v1_dsm(voi
static inline void nouveau_register_dsm_handler(void) {}
static inline void nouveau_unregister_dsm_handler(void) {}
static inline void nouveau_switcheroo_optimus_dsm(void) {}
+#ifdef __NetBSD__
+static inline bool nouveau_acpi_rom_supported(struct acpi_devnode *acpidev) { return false; }
+#else
static inline bool nouveau_acpi_rom_supported(struct device *dev) { return false; }
+#endif
static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }
static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; }
#endif
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c:1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c:1.5 Sat Dec 18 23:45:32 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_display.c,v 1.5 2021/12/18 23:45:32 riastradh Exp $ */
+/* $NetBSD: nouveau_display.c,v 1.6 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright (C) 2008 Maarten Maathuis.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_display.c,v 1.5 2021/12/18 23:45:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_display.c,v 1.6 2024/04/16 14:34:02 riastradh Exp $");
#include <acpi/video.h>
@@ -49,6 +49,11 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_disp
#include <nvif/cl0046.h>
#include <nvif/event.h>
+#ifdef __NetBSD__
+/* Used only for runtime power management, not in NetBSD for now. */
+#undef CONFIG_ACPI
+#endif
+
static int
nouveau_display_vblank_handler(struct nvif_notify *notify)
{
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h:1.9 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h:1.10
--- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h:1.9 Sat Dec 18 23:45:33 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.9 2021/12/18 23:45:33 riastradh Exp $ */
+/* $NetBSD: device.h,v 1.10 2024/04/16 14:34:02 riastradh Exp $ */
/* SPDX-License-Identifier: MIT */
#ifndef __NVKM_DEVICE_H__
@@ -92,6 +92,9 @@ struct nvkm_device {
struct device *dev;
enum nvkm_device_type type;
u64 handle;
+#ifdef __NetBSD__
+ struct acpi_devnode *acpidev;
+#endif
const char *name;
const char *cfgopt;
const char *dbgopt;
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c:1.3 Sat Dec 18 23:45:34 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_engine_device_acpi.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_engine_device_acpi.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2014 Red Hat Inc.
@@ -24,12 +24,17 @@
* Authors: Ben Skeggs
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_acpi.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_acpi.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $");
#include "acpi.h"
#include <core/device.h>
+#ifdef __NetBSD__
+/* This should be a PMF hook, not an ACPI notifier. */
+#undef CONFIG_ACPI
+#endif
+
#ifdef CONFIG_ACPI
static int
nvkm_acpi_ntfy(struct notifier_block *nb, unsigned long val, void *data)
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c:1.3 Sat Dec 18 23:45:34 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_engine_device_tegra.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_engine_device_tegra.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
@@ -22,7 +22,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_tegra.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_tegra.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $");
#include <core/tegra.h>
#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
@@ -364,7 +364,11 @@ nvkm_device_tegra_new(const struct nvkm_
tdev->gpu_speedo = tegra_sku_info.gpu_speedo_value;
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,
+ NVKM_DEVICE_TEGRA, pdev->id,
+#ifdef __NetBSD__
+ /*acpidev*/NULL,
+#endif
+ /*name*/NULL,
cfg, dbg, detect, mmio, subdev_mask,
&tdev->device);
if (ret)
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h:1.3 Sat Dec 18 23:45:34 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: priv.h,v 1.3 2021/12/18 23:45:34 riastradh Exp $ */
+/* $NetBSD: priv.h,v 1.4 2024/04/16 14:34:02 riastradh Exp $ */
/* SPDX-License-Identifier: MIT */
#ifndef __NVKM_DEVICE_PRIV_H__
@@ -54,6 +54,9 @@
int nvkm_device_ctor(const struct nvkm_device_func *,
const struct nvkm_device_quirk *,
struct device *, enum nvkm_device_type, u64 handle,
+#ifdef __NetBSD__ /* XXX nouveau acpi */
+ struct acpi_devnode *acpidev,
+#endif
const char *name, const char *cfg, const char *dbg,
bool detect, bool mmio, u64 subdev_mask,
struct nvkm_device *);
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c:1.12 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c:1.13
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c:1.12 Sun Dec 19 10:50:22 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_engine_device_base.c,v 1.12 2021/12/19 10:50:22 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_engine_device_base.c,v 1.13 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2012 Red Hat Inc.
@@ -24,7 +24,7 @@
* Authors: Ben Skeggs
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_base.c,v 1.12 2021/12/19 10:50:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_base.c,v 1.13 2024/04/16 14:34:02 riastradh Exp $");
#include "priv.h"
#include "acpi.h"
@@ -2961,6 +2961,9 @@ 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,
+#ifdef __NetBSD__ /* XXX nouveau acpi */
+ struct acpi_devnode *acpidev,
+#endif
const char *name, const char *cfg, const char *dbg,
bool detect, bool mmio, u64 subdev_mask,
struct nvkm_device *device)
@@ -2986,6 +2989,9 @@ nvkm_device_ctor(const struct nvkm_devic
device->dev = dev;
device->type = type;
device->handle = handle;
+#ifdef __NetBSD__ /* XXX nouveau acpi */
+ device->acpidev = acpidev;
+#endif
device->cfgopt = cfg;
device->dbgopt = dbg;
device->name = name;
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c:1.11 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c:1.12
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c:1.11 Sun Dec 19 10:51:57 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_engine_device_pci.c,v 1.11 2021/12/19 10:51:57 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_engine_device_pci.c,v 1.12 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2015 Red Hat Inc.
@@ -24,7 +24,7 @@
* Authors: Ben Skeggs <[email protected]>
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_pci.c,v 1.11 2021/12/19 10:51:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_pci.c,v 1.12 2024/04/16 14:34:02 riastradh Exp $");
#include <core/pci.h>
#include "priv.h"
@@ -1721,7 +1721,11 @@ nvkm_device_pci_new(struct pci_dev *pci_
(u64)pci_domain_nr(pci_dev->bus) << 32 |
pci_dev->bus->number << 16 |
PCI_SLOT(pci_dev->devfn) << 8 |
- PCI_FUNC(pci_dev->devfn), name,
+ PCI_FUNC(pci_dev->devfn),
+#ifdef __NetBSD__
+ /*acpidev*/pci_dev->pd_ad,
+#endif
+ name,
cfg, dbg, detect, mmio, subdev_mask,
&pdev->device);
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c:1.3 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c:1.3 Sat Dec 18 23:45:38 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_subdev_bios_shadowacpi.c,v 1.3 2021/12/18 23:45:38 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_subdev_bios_shadowacpi.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2012 Red Hat Inc.
@@ -23,16 +23,24 @@
*
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_bios_shadowacpi.c,v 1.3 2021/12/18 23:45:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_bios_shadowacpi.c,v 1.4 2024/04/16 14:34:02 riastradh Exp $");
#include "priv.h"
#if defined(CONFIG_ACPI) && defined(CONFIG_X86)
int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);
+#ifdef __NetBSD__
+bool nouveau_acpi_rom_supported(struct acpi_devnode *);
+#else
bool nouveau_acpi_rom_supported(struct device *);
+#endif
#else
static inline bool
+#ifdef __NetBSD__
+nouveau_acpi_rom_supported(struct acpi_devnode *dev)
+#else
nouveau_acpi_rom_supported(struct device *dev)
+#endif
{
return false;
}
@@ -93,7 +101,7 @@ acpi_read_slow(void *data, u32 offset, u
static void *
acpi_init(struct nvkm_bios *bios, const char *name)
{
- if (!nouveau_acpi_rom_supported(bios->subdev.device->dev))
+ if (!nouveau_acpi_rom_supported(bios->subdev.device->acpidev))
return ERR_PTR(-ENODEV);
return NULL;
}
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c:1.4 Sun Feb 27 14:24:27 2022
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_nvkm_subdev_mxm_base.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $ */
+/* $NetBSD: nouveau_nvkm_subdev_mxm_base.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2011 Red Hat Inc.
@@ -24,7 +24,7 @@
* Authors: Ben Skeggs
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mxm_base.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mxm_base.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $");
#include "mxms.h"
@@ -33,6 +33,15 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm
#include <subdev/bios/mxm.h>
#include <subdev/i2c.h>
+#ifdef __NetBSD__
+#ifdef CONFIG_ACPI
+#include <dev/acpi/acpireg.h>
+#define _COMPONENT ACPI_DISPLAY_COMPONENT
+ACPI_MODULE_NAME("nouveau_nvkm_subdev_mxm_base")
+#include <linux/nbsd-namespace-acpi.h>
+#endif
+#endif
+
static bool
mxm_shadow_rom_fetch(struct nvkm_i2c_bus *bus, u8 addr,
u8 offset, u8 size, u8 *data)
@@ -99,7 +108,11 @@ mxm_shadow_dsm(struct nvkm_mxm *mxm, u8
acpi_handle handle;
int rev;
+#ifdef __NetBSD__
+ handle = (device->acpidev ? device->acpidev->ad_handle : NULL);
+#else
handle = ACPI_HANDLE(device->dev);
+#endif
if (!handle)
return false;
Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h:1.11 src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h:1.12
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h:1.11 Sun Dec 19 11:52:38 2021
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: radeon.h,v 1.11 2021/12/19 11:52:38 riastradh Exp $ */
+/* $NetBSD: radeon.h,v 1.12 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
@@ -69,6 +69,7 @@
#include <linux/interval_tree.h>
#include <linux/hashtable.h>
#include <linux/dma-fence.h>
+#include <linux/acpi.h>
#ifdef CONFIG_MMU_NOTIFIER
#include <linux/mmu_notifier.h>
Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.4 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c:1.4 Sun Feb 27 14:24:27 2022
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: radeon_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $ */
+/* $NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2012 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $");
#include <linux/acpi.h>
#include <linux/pci.h>
@@ -42,6 +42,14 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_acpi.
#include "radeon.h"
#include "radeon_acpi.h"
+#ifdef __NetBSD__
+#include <dev/acpi/acpi_pci.h>
+#include <dev/acpi/acpireg.h>
+#define _COMPONENT ACPI_DISPLAY_COMPONENT
+ACPI_MODULE_NAME("radeon_acpi")
+#include <linux/nbsd-namespace-acpi.h>
+#endif
+
#if defined(CONFIG_VGA_SWITCHEROO)
bool radeon_atpx_dgpu_req_power_for_displays(void);
#else
@@ -310,6 +318,8 @@ out:
return err;
}
+#ifndef __NetBSD__ /* XXX radeon acpi */
+
/**
* radeon_atif_get_sbios_requests - get requested sbios event
*
@@ -430,6 +440,8 @@ static int radeon_atif_handler(struct ra
return NOTIFY_BAD;
}
+#endif /* __NetBSD__ */
+
/* Call the ATCS method
*/
/**
@@ -577,7 +589,17 @@ int radeon_acpi_pcie_notify_device_ready
struct radeon_atcs *atcs = &rdev->atcs;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &rdev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&rdev->pdev->dev);
+#endif
if (!handle)
return -EINVAL;
@@ -617,7 +639,17 @@ int radeon_acpi_pcie_performance_request
u32 retry = 3;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &rdev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&rdev->pdev->dev);
+#endif
if (!handle)
return -EINVAL;
@@ -682,6 +714,7 @@ int radeon_acpi_pcie_performance_request
* acpi events.
* Returns NOTIFY code
*/
+#ifndef __NetBSD__ /* XXX radeon acpi */
static int radeon_acpi_event(struct notifier_block *nb,
unsigned long val,
void *data)
@@ -701,6 +734,7 @@ static int radeon_acpi_event(struct noti
/* Check for pending SBIOS requests */
return radeon_atif_handler(rdev, entry);
}
+#endif
/* Call all ACPI methods here */
/**
@@ -720,7 +754,17 @@ int radeon_acpi_init(struct radeon_devic
int ret;
/* Get the device handle */
+#ifdef __NetBSD__
+ const struct pci_attach_args *pa = &rdev->pdev->pd_pa;
+ struct acpi_devnode *const d =
+ acpi_pcidev_find(pci_get_segment(pa->pa_pc),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ if (d == NULL)
+ return -EINVAL;
+ handle = d->ad_handle;
+#else
handle = ACPI_HANDLE(&rdev->pdev->dev);
+#endif
/* No need to proceed if we're sure that ATIF is not supported */
if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
@@ -789,8 +833,10 @@ int radeon_acpi_init(struct radeon_devic
}
out:
+#ifndef __NetBSD__ /* XXX radeon acpi */
rdev->acpi_nb.notifier_call = radeon_acpi_event;
register_acpi_notifier(&rdev->acpi_nb);
+#endif
return ret;
}
@@ -804,5 +850,7 @@ out:
*/
void radeon_acpi_fini(struct radeon_device *rdev)
{
+#ifndef __NetBSD__ /* XXX radeon acpi */
unregister_acpi_notifier(&rdev->acpi_nb);
+#endif
}
Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.4 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.5
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h:1.4 Sat May 28 01:07:47 2022
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: radeon_drv.h,v 1.4 2022/05/28 01:07:47 manu Exp $ */
+/* $NetBSD: radeon_drv.h,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */
/* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
*
@@ -33,15 +33,6 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
-#if defined(__NetBSD__)
-#ifdef _KERNEL_OPT
-#include "acpica.h"
-#endif /* _KERNEL_OPT */
-#if (NACPICA > 0)
-#define CONFIG_ACPI
-#endif /* NACPICA > 0 */
-#endif /* __NetBSD__ */
-
#include <linux/firmware.h>
#include <linux/platform_device.h>
#include <drm/drm_legacy.h>
Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.13 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.14
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:1.13 Mon Nov 6 14:33:51 2023
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c Tue Apr 16 14:34:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $ */
+/* $NetBSD: radeon_bios.c,v 1.14 2024/04/16 14:34:02 riastradh Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.13 2023/11/06 14:33:51 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_bios.c,v 1.14 2024/04/16 14:34:02 riastradh Exp $");
#include <linux/acpi.h>
#include <linux/pci.h>
@@ -41,8 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_bios.
#include "radeon.h"
#include "radeon_reg.h"
-#if defined(__NetBSD__) && NACPICA > 0
-#define CONFIG_ACPI
+#if defined(__NetBSD__) && defined(CONFIG_ACPI)
#include <dev/acpi/acpireg.h>
#define _COMPONENT ACPI_DISPLAY_COMPONENT
ACPI_MODULE_NAME("radeon_acpi")
Index: src/sys/external/bsd/drm2/include/acpi/video.h
diff -u src/sys/external/bsd/drm2/include/acpi/video.h:1.2 src/sys/external/bsd/drm2/include/acpi/video.h:1.3
--- src/sys/external/bsd/drm2/include/acpi/video.h:1.2 Tue Mar 18 18:20:42 2014
+++ src/sys/external/bsd/drm2/include/acpi/video.h Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: video.h,v 1.2 2014/03/18 18:20:42 riastradh Exp $ */
+/* $NetBSD: video.h,v 1.3 2024/04/16 14:34:03 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
#ifndef _DRM2_COMPAT_ACPI_VIDEO_H_
#define _DRM2_COMPAT_ACPI_VIDEO_H_
+#include <linux/acpi.h>
+
static inline void
acpi_video_register(void)
{
Index: src/sys/external/bsd/drm2/include/linux/acpi.h
diff -u src/sys/external/bsd/drm2/include/linux/acpi.h:1.10 src/sys/external/bsd/drm2/include/linux/acpi.h:1.11
--- src/sys/external/bsd/drm2/include/linux/acpi.h:1.10 Sat May 28 01:07:47 2022
+++ src/sys/external/bsd/drm2/include/linux/acpi.h Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.h,v 1.10 2022/05/28 01:07:47 manu Exp $ */
+/* $NetBSD: acpi.h,v 1.11 2024/04/16 14:34:03 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,6 +37,9 @@
#endif
#if NACPICA > 0
+
+#define CONFIG_ACPI 1
+
#include <dev/acpi/acpivar.h>
#include <linux/types.h>
@@ -58,4 +61,5 @@ union acpi_object *acpi_evaluate_dsm_typ
bool acpi_check_dsm(acpi_handle, const guid_t *, uint64_t, uint64_t);
#endif /* NACPICA > 0 */
+
#endif /* _LINUX_ACPI_H_ */
Index: src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h
diff -u src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h:1.1 src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h:1.2
--- src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h:1.1 Sun Feb 27 14:22:42 2022
+++ src/sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: nbsd-namespace-acpi.h,v 1.1 2022/02/27 14:22:42 riastradh Exp $ */
+/* $NetBSD: nbsd-namespace-acpi.h,v 1.2 2024/04/16 14:34:03 riastradh Exp $ */
/*-
* Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
#define value Value
#define acpi_get_handle AcpiGetHandle
+#define acpi_get_name AcpiGetName
#define acpi_get_table AcpiGetTable
#define acpi_evaluate_object AcpiEvaluateObject
#define acpi_format_exception AcpiFormatException
Index: src/sys/external/bsd/drm2/nouveau/files.nouveau
diff -u src/sys/external/bsd/drm2/nouveau/files.nouveau:1.39 src/sys/external/bsd/drm2/nouveau/files.nouveau:1.40
--- src/sys/external/bsd/drm2/nouveau/files.nouveau:1.39 Sat Jun 3 21:30:22 2023
+++ src/sys/external/bsd/drm2/nouveau/files.nouveau Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.nouveau,v 1.39 2023/06/03 21:30:22 lukem Exp $
+# $NetBSD: files.nouveau,v 1.40 2024/04/16 14:34:03 riastradh Exp $
version 20180827
@@ -99,6 +99,7 @@ file external/bsd/drm2/dist/drm/nouveau/
file external/bsd/drm2/dist/drm/nouveau/dispnv50/nouveau_dispnv50_wndwc37e.c nouveau
file external/bsd/drm2/dist/drm/nouveau/dispnv50/nouveau_dispnv50_wndwc57e.c nouveau
file external/bsd/drm2/dist/drm/nouveau/nouveau_abi16.c nouveau
+file external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c nouveau & acpi
file external/bsd/drm2/dist/drm/nouveau/nouveau_bios.c nouveau
file external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c nouveau
file external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c nouveau
Index: src/sys/external/bsd/drm2/radeon/files.radeon
diff -u src/sys/external/bsd/drm2/radeon/files.radeon:1.39 src/sys/external/bsd/drm2/radeon/files.radeon:1.40
--- src/sys/external/bsd/drm2/radeon/files.radeon:1.39 Sat Jun 3 21:31:47 2023
+++ src/sys/external/bsd/drm2/radeon/files.radeon Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.radeon,v 1.39 2023/06/03 21:31:47 lukem Exp $
+# $NetBSD: files.radeon,v 1.40 2024/04/16 14:34:03 riastradh Exp $
version 20180827
@@ -48,7 +48,7 @@ file external/bsd/drm2/radeon/radeon_pci
file external/bsd/drm2/radeon/radeondrmkmsfb.c radeondrmkmsfb
# Generated from radeon2netbsd.
-#file external/bsd/drm2/dist/drm/radeon/radeon_acpi.c radeon
+file external/bsd/drm2/dist/drm/radeon/radeon_acpi.c radeon
file external/bsd/drm2/dist/drm/radeon/radeon_agp.c radeon
file external/bsd/drm2/dist/drm/radeon/radeon_asic.c radeon
file external/bsd/drm2/dist/drm/radeon/radeon_atom.c radeon
Index: src/sys/modules/amdgpu/Makefile
diff -u src/sys/modules/amdgpu/Makefile:1.8 src/sys/modules/amdgpu/Makefile:1.9
--- src/sys/modules/amdgpu/Makefile:1.8 Sun Sep 10 15:12:39 2023
+++ src/sys/modules/amdgpu/Makefile Tue Apr 16 14:34:03 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2023/09/10 15:12:39 mrg Exp $
+# $NetBSD: Makefile,v 1.9 2024/04/16 14:34:03 riastradh Exp $
.include "../Makefile.inc"
.include "../drmkms/Makefile.inc"
@@ -15,6 +15,11 @@ COPTS.amdgpu_float+= ${${ACTIVE_CC} == "
COPTS.amdgpu_float+= -march=armv8-a
.endif
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
+ ${MACHINE_CPU} == "arm" || ${MACHINE_CPU} == "aarch64"
+CPPFLAGS+= -DNACPICA=1
+.endif
+
# sed -ne 's,^makeoptions amdgpu "\([^.]*\)\.amdgpu"+="\(.*\)",\1+= \2,gp' <files.amdgpu | sed -e 's,\$S,${S},g'
# Note: order of includes is significant.
CPPFLAGS+= -I${S}/external/bsd/drm2/dist/drm/amd/include/asic_reg
@@ -145,6 +150,7 @@ COPTS.amdgpu_rn_clk_mgr.c+= ${COPTS.amdg
# 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
Added files: