From 920715dc1d03b818f9c9ebcd6e1b563560f998f9 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 26 Feb 2022 09:33:50 +0000 Subject: [PATCH] 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. --- .../drm2/dist/drm/i915/display/intel_acpi.h | 2 ++ .../dist/drm/i915/display/intel_opregion.h | 1 + .../bsd/drm2/dist/drm/i915/i915_drv.h | 2 +- .../drm/nouveau/include/nvkm/core/device.h | 3 +++ .../bsd/drm2/dist/drm/nouveau/nouveau_acpi.c | 27 +++++++++++++++++++ .../bsd/drm2/dist/drm/nouveau/nouveau_acpi.h | 10 +++++++ .../drm2/dist/drm/nouveau/nouveau_display.c | 5 ++++ .../device/nouveau_nvkm_engine_device_acpi.c | 5 ++++ .../device/nouveau_nvkm_engine_device_base.c | 6 +++++ .../device/nouveau_nvkm_engine_device_pci.c | 6 ++++- .../device/nouveau_nvkm_engine_device_tegra.c | 6 ++++- .../drm/nouveau/nvkm/engine/device/priv.h | 3 +++ .../nouveau_nvkm_subdev_bios_shadowacpi.c | 10 ++++++- .../subdev/mxm/nouveau_nvkm_subdev_mxm_base.c | 13 +++++++++ .../bsd/drm2/dist/drm/radeon/radeon_acpi.c | 7 +++++ sys/external/bsd/drm2/include/acpi/acpi_bus.h | 0 sys/external/bsd/drm2/include/acpi/video.h | 2 ++ sys/external/bsd/drm2/include/linux/acpi.h | 4 +++ sys/external/bsd/drm2/include/linux/mxm-wmi.h | 0 sys/external/bsd/drm2/nouveau/files.nouveau | 1 + 20 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 sys/external/bsd/drm2/include/acpi/acpi_bus.h create mode 100644 sys/external/bsd/drm2/include/linux/mxm-wmi.h diff --git a/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h b/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h index f0c9b9c8ae5b..8411f2a16073 100644 --- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h +++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h @@ -8,6 +8,8 @@ #ifndef __INTEL_ACPI_H__ #define __INTEL_ACPI_H__ +#include + struct drm_i915_private; #ifdef CONFIG_ACPI diff --git a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h b/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h index 29dd067515cf..56016397184d 100644 --- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h +++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h @@ -29,6 +29,7 @@ #include #include +#include struct drm_i915_private; struct intel_encoder; diff --git a/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h b/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h index 477208744437..92840b81f19a 100644 --- a/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h +++ b/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h @@ -37,7 +37,7 @@ #include "acpica.h" #endif /* _KERNEL_OPT */ #if (NACPICA > 0) -#define CONFIG_ACPI +#define CONFIG_ACPI 1 #endif /* NACPICA > 0 */ #endif /* __NetBSD__ */ diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h index fada213319d3..520b1bf48b94 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h +++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/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; diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c index 5eeb381ecfa4..453b102e968e 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c @@ -15,6 +15,13 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh E #include "nouveau_drv.h" #include "nouveau_acpi.h" +#ifdef __NetBSD__ +#include +#define _COMPONENT ACPI_DISPLAY_COMPONENT +ACPI_MODULE_NAME("nouveau_acpi") +#include +#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 pci_dev *pdev, acpi_handle *dhandle_out 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 rom_handle, uint8_t *bios, 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 *bios, int offset, int len) 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, struct drm_connector *connector) 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, struct drm_connector *connector) return NULL; return kmemdup(edid, EDID_LENGTH, GFP_KERNEL); +#endif } diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h index d4c1985bf097..d5a3355308fe 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h @@ -4,6 +4,8 @@ #ifndef __NOUVEAU_ACPI_H__ #define __NOUVEAU_ACPI_H__ +#include + #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(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) {} +#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 diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c index e2dc47cdd1c2..9736f23a08c2 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c @@ -49,6 +49,11 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_display.c,v 1.5 2021/12/18 23:45:32 riastrad #include #include +#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) { diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c index d93bdb6e7c20..f23f986d4359 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c @@ -30,6 +30,11 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_device_acpi.c,v 1.3 2021/12/18 2 #include +#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) diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c index 5b6d86097b90..7982d3ea1559 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c @@ -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_device_func *func, 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; diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c index 308f9e46c971..b4849b941f7d 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c @@ -1721,7 +1721,11 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, (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); diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c index 0ffa23fc6e87..c24d9ac704ff 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c @@ -364,7 +364,11 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, 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) diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h index 10c0489fbfd3..df868112e231 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/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 *); diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c index 10e9af3c3e0f..0d8dfaa8ee13 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c @@ -29,10 +29,18 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_bios_shadowacpi.c,v 1.3 2021/12/ #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, u32 length, struct nvkm_bios *bios) 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; } diff --git a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c index 98b1f0712788..8e36aa78471f 100644 --- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c +++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c @@ -33,6 +33,15 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mxm_base.c,v 1.4 2022/02/27 14:2 #include #include +#ifdef __NetBSD__ +#ifdef CONFIG_ACPI +#include +#define _COMPONENT ACPI_DISPLAY_COMPONENT +ACPI_MODULE_NAME("nouveau_nvkm_subdev_mxm_base") +#include +#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 version) 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; diff --git a/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c b/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c index da0afa688390..94b5ebcdee4f 100644 --- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c +++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c @@ -42,6 +42,13 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.4 2022/02/27 14:24:27 riastradh Ex #include "radeon.h" #include "radeon_acpi.h" +#ifdef __NetBSD__ +#include +#define _COMPONENT ACPI_DISPLAY_COMPONENT +ACPI_MODULE_NAME("radeon_acpi") +#include +#endif + #if defined(CONFIG_VGA_SWITCHEROO) bool radeon_atpx_dgpu_req_power_for_displays(void); #else diff --git a/sys/external/bsd/drm2/include/acpi/acpi_bus.h b/sys/external/bsd/drm2/include/acpi/acpi_bus.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sys/external/bsd/drm2/include/acpi/video.h b/sys/external/bsd/drm2/include/acpi/video.h index 9b54640916ed..511d6f15fce1 100644 --- a/sys/external/bsd/drm2/include/acpi/video.h +++ b/sys/external/bsd/drm2/include/acpi/video.h @@ -32,6 +32,8 @@ #ifndef _DRM2_COMPAT_ACPI_VIDEO_H_ #define _DRM2_COMPAT_ACPI_VIDEO_H_ +#include + static inline void acpi_video_register(void) { diff --git a/sys/external/bsd/drm2/include/linux/acpi.h b/sys/external/bsd/drm2/include/linux/acpi.h index 9cde7872a6d4..dad6e8f68fc4 100644 --- a/sys/external/bsd/drm2/include/linux/acpi.h +++ b/sys/external/bsd/drm2/include/linux/acpi.h @@ -37,6 +37,9 @@ #endif #if NACPICA > 0 + +#define CONFIG_ACPI 1 + #include #include @@ -58,4 +61,5 @@ union acpi_object *acpi_evaluate_dsm_typed(acpi_handle, const guid_t *, bool acpi_check_dsm(acpi_handle, const guid_t *, uint64_t, uint64_t); #endif /* NACPICA > 0 */ + #endif /* _LINUX_ACPI_H_ */ diff --git a/sys/external/bsd/drm2/include/linux/mxm-wmi.h b/sys/external/bsd/drm2/include/linux/mxm-wmi.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sys/external/bsd/drm2/nouveau/files.nouveau b/sys/external/bsd/drm2/nouveau/files.nouveau index 2341c8fcf780..43480947fbf2 100644 --- a/sys/external/bsd/drm2/nouveau/files.nouveau +++ b/sys/external/bsd/drm2/nouveau/files.nouveau @@ -99,6 +99,7 @@ file external/bsd/drm2/dist/drm/nouveau/dispnv50/nouveau_dispnv50_wndw.c 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