Skip to content
Open
37 changes: 35 additions & 2 deletions kernel-open/conftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4919,6 +4919,38 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_DATE" "" "types"
;;

drm_connector_helper_funcs_mode_valid_has_int_ret_type)
#
# Determine if the return type is 'int' for
# drm_connector_helper_funcs::mode_valid.
#
# It was changed to 'enum drm_mode_status' by commit 0993f1d0d8a1
# ("drm: Make the connector mode_valid() vfunc return a
# drm_mode_status enum") in v3.14.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From README.md: kernel 4.15 or newer are supported, so this could be changed without a conftest, or am I missing something?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, sure. When I started this work based on 580.105.08, I even fixed up the missing tests for atomic_long_read_acquire(), atomic_long_set_release(),... After rebasing to 590.48.01, I noticed that "TODO" was dropped and the general availability of these functions was taken for granted.

I was probably just mislead by comments in conftest.sh that refer to ancient versions like v2.6.30 or v2.6.32. So, conftest.sh can probably get a few more cleanups but I will drop this test and simply change the prototype.

#
CODE="
#include <drm/drm_atomic_helper.h>

#ifndef __same_type
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#endif

/* BUILD_BUG_ON() from <linux/kernel.h> isn't working */
#define CONF_BUILD_BUG_ON(cond) \
char conf_bug_on_trigger[0 - !!(cond)]

/* We exploit the fact, that 'int' and 'enum' are compatible but
* 'enum e1' and 'enum e2' are not to cause a build error if the
* return type of drm_connector_helper_funcs::mode_valid is an enum.
*/
enum conftest_enum { CONFTEST = -1 } conftest_enum;
const struct drm_connector_helper_funcs conftest_func;
CONF_BUILD_BUG_ON(!__same_type(conftest_func.mode_valid(NULL, NULL), conftest_enum));
"

compile_check_conftest "$CODE" "NV_DRM_CONNECTOR_HELPER_FUNCS_MODE_VALID_HAS_INT_RET_TYPE" "" "types"
;;

drm_connector_helper_funcs_mode_valid_has_const_mode_arg)
#
# Determine if the 'mode' pointer argument is const in
Expand All @@ -4932,8 +4964,9 @@ compile_test() {
CODE="
#include <drm/drm_atomic_helper.h>

static int conftest_drm_connector_mode_valid(struct drm_connector *connector,
const struct drm_display_mode *mode) {
static enum drm_mode_status
conftest_drm_connector_mode_valid(struct drm_connector *connector,
const struct drm_display_mode *mode) {
return 0;
}

Expand Down
11 changes: 8 additions & 3 deletions kernel-open/nvidia-drm/nvidia-drm-connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,16 @@ static int nv_drm_connector_get_modes(struct drm_connector *connector)
return count;
}

static int nv_drm_connector_mode_valid(struct drm_connector *connector,
#ifdef NV_DRM_CONNECTOR_HELPER_FUNCS_MODE_VALID_HAS_INT_RET_TYPE
static int
#else
static enum drm_mode_status
#endif
nv_drm_connector_mode_valid(struct drm_connector *connector,
#if defined(NV_DRM_CONNECTOR_HELPER_FUNCS_MODE_VALID_HAS_CONST_MODE_ARG)
const struct drm_display_mode *mode)
const struct drm_display_mode *mode)
#else
struct drm_display_mode *mode)
struct drm_display_mode *mode)
#endif
{
struct drm_device *dev = connector->dev;
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 @@ -107,5 +107,6 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_format_info_has_is_yuv
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_mmap
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_output_poll_changed
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_date
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_helper_funcs_mode_valid_has_int_ret_type
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_helper_funcs_mode_valid_has_const_mode_arg
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_fb_create_takes_format_info
7 changes: 4 additions & 3 deletions kernel-open/nvidia/linux_nvswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct file_operations ctl_fops =
static int nvswitch_initialize_device_interrupt(NVSWITCH_DEV *nvswitch_dev);
static void nvswitch_shutdown_device_interrupt(NVSWITCH_DEV *nvswitch_dev);
static void nvswitch_load_bar_info(NVSWITCH_DEV *nvswitch_dev);
static void nvswitch_task_dispatch(NVSWITCH_DEV *nvswitch_dev);
static void nvswitch_task_dispatch(void *nvswitch_dev);

static NvBool
nvswitch_is_device_blacklisted
Expand Down Expand Up @@ -313,7 +313,7 @@ nvswitch_init_background_tasks
NV_ATOMIC_SET(nvswitch_dev->task_q_ready, 1);

nv_kthread_q_item_init(&nvswitch_dev->task_item,
(nv_q_func_t) &nvswitch_task_dispatch,
&nvswitch_task_dispatch,
nvswitch_dev);

if (!nv_kthread_q_schedule_q_item(&nvswitch_dev->task_q,
Expand Down Expand Up @@ -1208,9 +1208,10 @@ nvswitch_isr_thread
static void
nvswitch_task_dispatch
(
NVSWITCH_DEV *nvswitch_dev
void *_nvswitch_dev
)
{
NVSWITCH_DEV *nvswitch_dev = _nvswitch_dev;
NvU64 nsec;
NvU64 timeout;
NvS64 rc;
Expand Down
6 changes: 3 additions & 3 deletions kernel-open/nvidia/nvidia.Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ $(call ASSIGN_PER_OBJ_CFLAGS, $(NVIDIA_OBJECTS), $(NVIDIA_CFLAGS))
# nv-procfs.c requires nv-compiler.h
#

NV_COMPILER_VERSION_HEADER = $(obj)/nv_compiler.h
NV_COMPILER_VERSION_HEADER = nv_compiler.h

$(NV_COMPILER_VERSION_HEADER):
$(obj)/$(NV_COMPILER_VERSION_HEADER):
@echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@

$(obj)/nvidia/nv-procfs.o: $(NV_COMPILER_VERSION_HEADER)
$(obj)/nvidia/nv-procfs.o: $(obj)/$(NV_COMPILER_VERSION_HEADER)

clean-files += $(NV_COMPILER_VERSION_HEADER)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ dmaFreeMapping_GM107

if (pCliMapInfo != NULL && pCliMapInfo->pDmaMappingInfo->bNeedL2InvalidateAtUnmap)
{
GMMU_APERTURE aperture = (pCliMapInfo->pDmaMappingInfo->aperture == GMMU_APERTURE_PEER) ?
FB_CACHE_MEMTYPE aperture = (pCliMapInfo->pDmaMappingInfo->aperture == GMMU_APERTURE_PEER) ?
FB_CACHE_PEER_MEMORY : FB_CACHE_SYSTEM_MEMORY;

kmemsysCacheOp_HAL(pGpu, GPU_GET_KERNEL_MEMORY_SYSTEM(pGpu), NULL, aperture, FB_CACHE_INVALIDATE);
Expand Down
4 changes: 2 additions & 2 deletions src/nvidia/src/kernel/gpu/timer/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ tmrapiDeregisterEvents_IMPL(TimerApi *pTimerApi)
// inner callback and calls it correctly from itself. Hacky but it should work around the
// limitations in the SDK (all RM derived types undefined, so TIMEPROC type is impossible).
//
typedef NvU32 (*TMR_CALLBACK_FUNCTION)(void *pCallbackData);
typedef void (*TMR_CALLBACK_FUNCTION)(void *pCallbackData);

typedef struct
{
Expand Down Expand Up @@ -1822,7 +1822,7 @@ tmrCtrlCmdEventCreate
)
{
NV_STATUS rc;
TMR_EVENT *pEvent;
TMR_EVENT *pEvent = NULL;
wrapperStorage_t *pWrapper;
OBJTMR *pTmr = GPU_GET_TIMER(pGpu);

Expand Down