Skip to content

Commit 0ef97c1

Browse files
committed
Quick fix for driver version 575 failures.
1 parent 58b4e43 commit 0ef97c1

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

nvidia-include/nvidia-drm-ioctl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
DRM_IOWR((DRM_COMMAND_BASE + DRM_NVIDIA_GET_DEV_INFO), \
6161
struct drm_nvidia_get_dev_info_params_545)
6262

63+
#define DRM_IOCTL_NVIDIA_GET_DEV_INFO_575 \
64+
DRM_IOWR((DRM_COMMAND_BASE + DRM_NVIDIA_GET_DEV_INFO), \
65+
struct drm_nvidia_get_dev_info_params_575)
66+
6367
/*
6468
* XXX Solaris compiler has issues with DRM_IO. None of this is supported on
6569
* Solaris anyway, so just skip it.
@@ -155,6 +159,22 @@ struct drm_nvidia_get_dev_info_params_545 {
155159
uint32_t supports_semsurf; /* OUT */
156160
};
157161

162+
struct drm_nvidia_get_dev_info_params_575 {
163+
uint32_t gpu_id; /* OUT */
164+
uint32_t mig_device; /* OUT */
165+
uint32_t primary_index; /* OUT; the "card%d" value */
166+
167+
uint32_t supports_alloc; /* OUT */
168+
/* The generic_page_kind, page_kind_generation, and sector_layout
169+
* fields are only valid if supports_alloc is true.
170+
* See DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D definitions of these. */
171+
uint32_t generic_page_kind; /* OUT */
172+
uint32_t page_kind_generation; /* OUT */
173+
uint32_t sector_layout; /* OUT */
174+
uint32_t supports_sync_fd; /* OUT */
175+
uint32_t supports_semsurf; /* OUT */
176+
};
177+
158178

159179
struct drm_nvidia_fence_context_create_params {
160180
uint32_t handle; /* OUT GEM handle to fence context */

src/direct/nv-driver.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,20 @@ static bool nv0_register_fd(const int nv0_fd, int nvctl_fd) {
239239
static bool get_device_info(const int fd, NVDriverContext *context) {
240240
//NVIDIA driver v545.29.02 changed the devInfo struct, and partly broke it in the process
241241
//...who adds a field to the middle of an existing struct....
242-
if (context->driverMajorVersion >= 545 && context->driverMinorVersion >= 29) {
242+
if (context->driverMajorVersion >= 575) {
243+
struct drm_nvidia_get_dev_info_params_575 devInfo575;
244+
const int ret = ioctl(fd, DRM_IOCTL_NVIDIA_GET_DEV_INFO_575, &devInfo575);
245+
246+
if (ret != 0) {
247+
LOG("get_device_info failed: %d %d", ret, errno)
248+
return false;
249+
}
250+
251+
context->gpu_id = devInfo575.gpu_id;
252+
context->sector_layout = devInfo575.sector_layout;
253+
context->page_kind_generation = devInfo575.page_kind_generation;
254+
context->generic_page_kind = devInfo575.generic_page_kind;
255+
} else if (context->driverMajorVersion >= 545 && context->driverMinorVersion >= 29) {
243256
struct drm_nvidia_get_dev_info_params_545 devInfo545;
244257
const int ret = ioctl(fd, DRM_IOCTL_NVIDIA_GET_DEV_INFO_545, &devInfo545);
245258

@@ -534,6 +547,9 @@ bool alloc_memory(const NVDriverContext *context, const uint32_t size, int *fd)
534547
}
535548
};
536549

550+
//TODO find the proper page size
551+
imageSizeInBytes = ROUND_UP(imageSizeInBytes, 65536);
552+
537553
struct drm_nvidia_gem_import_nvkms_memory_params params = {
538554
.mem_size = imageSizeInBytes,
539555
.nvkms_params_ptr = (uint64_t) &nvkmsParams,

0 commit comments

Comments
 (0)