Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kernel-open/nvidia-uvm/uvm_hmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,11 @@ static void fill_dst_pfn(uvm_va_block_t *va_block,

UVM_ASSERT(!page_count(dpage));
UVM_ASSERT(!dpage->zone_device_data);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
zone_device_page_init(dpage, 0, 0);
#else
zone_device_page_init(dpage);
#endif
dpage->zone_device_data = gpu_chunk;
atomic64_inc(&va_block->hmm.va_space->hmm.allocated_page_count);
}
Expand Down
32 changes: 32 additions & 0 deletions kernel-open/nvidia-uvm/uvm_pmm_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
#include "uvm_test.h"
#include "uvm_linux.h"

#include <linux/version.h>

#if defined(CONFIG_PCI_P2PDMA) && defined(NV_STRUCT_PAGE_HAS_ZONE_DEVICE_DATA)
#include <linux/pci-p2pdma.h>
#endif
Expand Down Expand Up @@ -2999,8 +3001,13 @@ static bool uvm_pmm_gpu_check_orphan_pages(uvm_pmm_gpu_t *pmm)
return ret;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
static void devmem_folio_free(struct folio *folio) {
struct page *page = &folio->page;
#else
static void devmem_page_free(struct page *page)
{
#endif
uvm_gpu_chunk_t *chunk = uvm_pmm_devmem_page_to_chunk(page);
uvm_gpu_t *gpu = uvm_gpu_chunk_get_gpu(chunk);

Expand Down Expand Up @@ -3060,7 +3067,11 @@ static vm_fault_t devmem_fault_entry(struct vm_fault *vmf)

static const struct dev_pagemap_ops uvm_pmm_devmem_ops =
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
.folio_free = devmem_folio_free,
#else
.page_free = devmem_page_free,
#endif
.migrate_to_ram = devmem_fault_entry,
};

Expand Down Expand Up @@ -3148,8 +3159,14 @@ static void device_p2p_page_free_wake(struct nv_kref *ref)
wake_up(&p2p_mem->waitq);
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
static void device_p2p_folio_free(struct folio *folio)
{
struct page *page = &folio->page;
#else
static void device_p2p_page_free(struct page *page)
{
#endif
uvm_device_p2p_mem_t *p2p_mem = page->zone_device_data;

page->zone_device_data = NULL;
Expand All @@ -3158,14 +3175,25 @@ static void device_p2p_page_free(struct page *page)
#endif

#if UVM_CDMM_PAGES_SUPPORTED()
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
static void device_coherent_folio_free(struct folio *folio)
{
device_p2p_folio_free(folio);
}
#else
static void device_coherent_page_free(struct page *page)
{
device_p2p_page_free(page);
}
#endif

static const struct dev_pagemap_ops uvm_device_coherent_pgmap_ops =
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
.folio_free = device_coherent_folio_free,
#else
.page_free = device_coherent_page_free,
#endif
};

static NV_STATUS uvm_pmm_cdmm_init(uvm_parent_gpu_t *parent_gpu)
Expand Down Expand Up @@ -3302,7 +3330,11 @@ static bool uvm_pmm_gpu_check_orphan_pages(uvm_pmm_gpu_t *pmm)

static const struct dev_pagemap_ops uvm_device_p2p_pgmap_ops =
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
.folio_free = device_p2p_folio_free,
#else
.page_free = device_p2p_page_free,
#endif
};

void uvm_pmm_gpu_device_p2p_init(uvm_parent_gpu_t *parent_gpu)
Expand Down
8 changes: 5 additions & 3 deletions src/nvidia-modeset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ endif

CFLAGS += -fno-pic
CFLAGS += -fno-common
CFLAGS += -fomit-frame-pointer
CFLAGS += -fno-strict-aliasing
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
Expand All @@ -130,7 +129,7 @@ ifeq ($(TARGET_ARCH),x86_64)

#
# GCC flags -fcf-protection=branch and -mindirect-branch=extern-thunk can
# be used together after GCC version 9.4.0. See
# be used together after GCC version 9.4.0. See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654 for details.
# Check if GCC version is appropriate.
#
Expand All @@ -153,8 +152,11 @@ ifeq ($(TARGET_ARCH),x86_64)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fcf-protection=branch)
endif
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-jump-tables)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-asynchronous-unwind-tables)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch-register)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mfunction-return=thunk-extern)
endif

CFLAGS += $(CONDITIONAL_CFLAGS)
Expand Down
7 changes: 5 additions & 2 deletions src/nvidia/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ CFLAGS += -Werror-implicit-function-declaration
CFLAGS += -Wwrite-strings
CFLAGS += -Wundef
CFLAGS += -fno-common
CFLAGS += -fno-strict-aliasing
CFLAGS += -ffreestanding
CFLAGS += -fno-stack-protector

Expand Down Expand Up @@ -160,7 +161,7 @@ ifeq ($(TARGET_ARCH),x86_64)

#
# GCC flags -fcf-protection=branch and -mindirect-branch=extern-thunk can
# be used together after GCC version 9.4.0. See
# be used together after GCC version 9.4.0. See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654 for details.
# Check if GCC version is appropriate.
#
Expand All @@ -184,7 +185,9 @@ ifeq ($(TARGET_ARCH),x86_64)
endif
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-jump-tables)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch-register)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mfunction-return=thunk-extern)
endif

CFLAGS += $(CONDITIONAL_CFLAGS)
Expand Down