Skip to content

Commit

Permalink
FROM AOSC: Use linux/aperture.c for removing conflicting PCI devices …
Browse files Browse the repository at this point in the history
…on Linux 6.13.0-rc1+

Cherry-pick of 8113cd50461f05da52b66934237415dd303ec55c from AOSC-Tracking/nvidia-driver

Link: torvalds/linux@689274a
Link: torvalds/linux@7283f86
Link: NVIDIA#749
  • Loading branch information
xtexChooser committed Dec 14, 2024
1 parent 74962a6 commit 04d2a1e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kernel-open/conftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6615,6 +6615,8 @@ compile_test() {
# Added by commit 2916059147ea ("drm/aperture: Add infrastructure
# for aperture ownership") in v5.14.
#
# Removed by commit 689274a56c0c ("drm: Remove DRM aperture helpers") in v6.13.
#
CODE="
#if defined(NV_DRM_DRM_APERTURE_H_PRESENT)
#include <drm/drm_aperture.h>
Expand All @@ -6626,6 +6628,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT" "" "functions"
;;

aperture_remove_conflicting_pci_devices)
#
# Determine whether aperture_remove_conflicting_pci_devices is present.
#
# Added by commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/") in v6.0.
#
CODE="
#if defined(NV_LINUX_APERTURE_H_PRESENT)
#include <linux/aperture.h>
#endif
void conftest_aperture_remove_conflicting_pci_devices(void) {
aperture_remove_conflicting_pci_devices();
}"

compile_check_conftest "$CODE" "NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT" "" "functions"
;;

drm_aperture_remove_conflicting_pci_framebuffers_has_driver_arg)
#
# Determine whether drm_aperture_remove_conflicting_pci_framebuffers
Expand Down
1 change: 1 addition & 0 deletions kernel-open/header-presence-tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ NV_HEADER_PRESENCE_TESTS = \
generated/autoconf.h \
generated/compile.h \
generated/utsrelease.h \
linux/aperture.h \
linux/efi.h \
linux/kconfig.h \
linux/platform/tegra/mc_utils.h \
Expand Down
15 changes: 15 additions & 0 deletions kernel-open/nvidia-drm/nvidia-drm-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@
#endif

#if defined(NV_DRM_FBDEV_AVAILABLE)
// Commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/")
// moved implementation of drm_aperture_... to linux/aperture.c.
// Commit 689274a56c0c ("drm: Remove DRM aperture helpers")
// removed drm/drm_aperture.h.
#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
#include <drm/drm_aperture.h>
#endif
#if defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
#include <linux/aperture.h>
#endif
#include <drm/drm_fb_helper.h>
#endif

Expand Down Expand Up @@ -2013,10 +2022,16 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
if (bus_is_pci) {
struct pci_dev *pdev = to_pci_dev(device);

#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
printk(KERN_INFO "AOSC OS: %s: using drm_aperture for old kernels\n", nv_drm_driver.name);
#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_HAS_DRIVER_ARG)
drm_aperture_remove_conflicting_pci_framebuffers(pdev, &nv_drm_driver);
#else
drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name);
#endif
#elif defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
printk(KERN_INFO "AOSC OS: %s: using linux/aperture workaround for Linux 6.13+\n", nv_drm_driver.name);
aperture_remove_conflicting_pci_devices(pdev, nv_drm_driver.name);
#endif
nvKms->framebufferConsoleDisabled(nv_dev->pDevice);
}
Expand Down
10 changes: 10 additions & 0 deletions kernel-open/nvidia-drm/nvidia-drm-os-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ typedef struct nv_timer nv_drm_timer;
#define NV_DRM_FBDEV_GENERIC_AVAILABLE
#endif

#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
#define NV_DRM_FBDEV_AVAILABLE
#define NV_DRM_FBDEV_GENERIC_AVAILABLE
#endif

#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
#define NV_DRM_FBDEV_AVAILABLE
#define NV_DRM_FBDEV_TTM_AVAILABLE
#endif

#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
#define NV_DRM_FBDEV_AVAILABLE
#define NV_DRM_FBDEV_TTM_AVAILABLE
#endif

struct page;

/* Set to true when the atomic modeset feature is enabled. */
Expand Down
1 change: 1 addition & 0 deletions kernel-open/nvidia-drm/nvidia-drm-sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_fence_set_error
NV_CONFTEST_FUNCTION_COMPILE_TESTS += fence_set_error
NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers
NV_CONFTEST_FUNCTION_COMPILE_TESTS += aperture_remove_conflicting_pci_devices
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property
Expand Down

0 comments on commit 04d2a1e

Please sign in to comment.